<?php

/**
* @package Clients
*/
class Reports_menu extends NE_MenuHook
{
    var $modulesViews = array(
        array('reports', 'ViewReport'),
    );

    function getMenuArr()
    {
        $tArray = array();
        $tSubArray = array();
        $navlinks = array();

        if (NE_Lib::isPublicDir() && $this->user->isAdmin()) {
            return;
        }

        if ($this->action == 'ViewReport') {
            $tSubArray[0] = "<a href=\"index.php?fuse=reports&amp;view=ViewReport\" class='sel'>".strtolower($this->user->lang("overview"))."</a>";
        } else {
            $tSubArray[0] = "<a href=\"index.php?fuse=reports&amp;view=ViewReport\">".strtolower($this->user->lang("overview"))."</a>";
        }
        $tSubArray[1] = 0;
        $tArray[] = $tSubArray;

        if ($this->action == 'ViewReport') {
            $tSubArray[0] = strtolower($this->user->lang("overview"));
            $tSubArray[1] = 1;
            $tSubArray[2] = 1;
            $tArray[] = $tSubArray;
            $navlinks[] = $tSubArray[0];
        } else {
            $tSubArray[0] = "<a href=\"index.php?fuse=reports&amp;view=ViewReport\">".strtolower($this->user->lang("overview"))."</a>";
            $tSubArray[1] = 1;
            $tSubArray[2] = 0;
            $tArray[] = $tSubArray;
        }

        $arrayInDataBase = $this->user->getQuickReports();
        if(isset($arrayInDataBase) && $arrayInDataBase != '') {
            $inDataBase = unserialize($arrayInDataBase);
            if (count($inDataBase) > 0) {
				$tSubArray[0] = "<div style='padding-top:4px;padding-bottom:4px;text-align:center;'>---- ".$this->user->lang("quick reports")." ----</div>";
                $tSubArray[1] = 0;
                $tArray[] = $tSubArray;
            }
            for ($i = 0; $i < count ($inDataBase); $i++) {            
                $file = $inDataBase[$i];
                $pos = strrpos($file,"-");
                $length = strlen($file);
                $type = substr($file,$pos,$length);
                $type = str_replace(array (".php","_","-"), array (""," ",""), $type);
                $type = ucwords($type);
                $file = substr($file,0,$pos);
                $file = str_replace("_"," ",$file);
                $file = ucwords($file);
                if(isset($_REQUEST['report']) && ($_REQUEST['report']==$file)) {
                    $tSubArray[0] = "<a href=\"index.php?fuse=reports&amp;report=".urlencode($file)."&amp;type=".urlencode($type)."&amp;view=ViewReport\" class='sel'>".$this->user->varLang($file)."</a>";
                } else {
                    $tSubArray[0] = "<a href=\"index.php?fuse=reports&amp;report=".urlencode($file)."&amp;type=".urlencode($type)."&amp;view=ViewReport\" >".$this->user->varLang($file)."</a>";
                }
                $tSubArray[1] = 0;
                $tArray[] = $tSubArray;
            }
        }

        return array('navlinks' => $navlinks, 'menus' => $tArray);
    }
}

?>
