<!--
Author : Herpan // Last update   : 23/7/2014 // View For main menu
-->

<?php 
    $this->load->model('m_custom', 'custom', TRUE);
    $EmployeeCode  = $this->session->userdata('username'); 
//    $employee_name = $this->custom->get_employee_name($EmployeeCode); 
?>

<div id="mainmenu" class="easyui-layout" data-options="border:false" style="background:#eee;">
    <?php	
    $ds = "";

    foreach($menu as $sub){	 
        /*if(!in_array($sub['MenuID'],$enable_menu)) { 
                $ds = " disabled=true"; 
        }else{ 
                $ds = "";
        }*/

        $mainmenu = $this->m_menu->get_sub_menu($sub['MenuID']) ?  '<a href="#" class="easyui-menubutton" data-options="menu:'."'#mm".$sub['MenuID']."'".'"'." $ds".'>'.$sub['MenuLabel'].'</a>' : $sub['MenuLabel'];
        echo $mainmenu;
    } ?>
	
    <a href="#" class="easyui-menubutton" data-options="menu:'#mmWindow'">Windows</a>
    <a href="#" class="easyui-menubutton" data-options="menu:'#mmHelp'">Help</a>
    
    <span style="float:right;margin-right:10px;margin-top:1px;">
    	<?php
			if($this->session->userdata('jobtitle_status') == 0){
		?>
    	<span style="font-size:10px;color:#F00;"><b>Note:Remove this afterwards -> </b></span>
            <select class="easyui-combobox" id="cmb_jobtitle" name="cmb_jobtitle" style="width:125px;" editable="false"
                data-options="
                    valueField: 'DepartmentCode',
                    textField: 'DepartmentName',
                    value:'<?=$this->session->userdata('department')?>',
                    url:'<?=base_url()?>custom/get_data/department',
                    onSelect:function(val){
                        $.post('<?=base_url()?>/custom/custom/change_department',{department_code:val.DepartmentCode},function(result){location.reload();});
                    }
                ">
            </select>
        
            <select class="easyui-combobox" id="cmb_jobtitle" name="cmb_jobtitle" style="width:100px;" editable="false" 
                data-options="
                    valueField: 'JobTitleStatus',
                    textField: 'JobTitleStatusName',
                    value:'<?=$this->session->userdata('jobtitle_status')?>',
                    url:'<?=base_url()?>custom/get_data/jobtitlestatus',
                    onSelect:function(val){
                	$.post('<?=base_url()?>/custom/custom/change_jobtitlestatus',{jobtitle_status:val.JobTitleStatus},function(result){location.reload();});
                    }
                ">
        </select>
    </span>
    <?php
			}
	?>
</div>

<?php	
    $pmenuid = $submenu[0]['ParentID'];
    echo '<div id="mm' . $pmenuid . '" style="width:215px;">';

    foreach($submenu as $submn){
        if($submn['ParentID'] != $pmenuid) { 
            $pmenuid=$submn['ParentID'];
            echo '</div><div id="mm' . $pmenuid . '" style="width:215px;">'; 
        }
		
        if($sm = $this->m_menu->get_sub_menu($submn['MenuID'])){ ?>
            <div data-options="iconCls:'<?=$submn['Icon']?>'
                <?php  //if (!in_array($submn['MenuID'],$enable_menu)) { echo ",disabled:true"; } ?>">
                <span><?=$submn['MenuLabel']?></span>

                <div>	
                    <?php foreach($sm as $sb):?>
                            <?php if($sb['ActionType'] == 'Modal' or $sb['ActionType'] == 'Direct'):?>
                                <?php 
                                    $group_menu = $this->session->userdata('group_menu');
                                    $privillage = $this->m_menu->get_menuAuthority_byID($group_menu,$sb['MenuID']);  
                                ?>
                                <?php if($privillage):?>
                                    <div iconCls="<?=$submn['Icon']?>" onclick="<?=$this->m_menu->get_action($sb['ActionType'],array($sb['MenuLabel'],$sb['MenuLink'],$submn['Icon']))?>" <?php //if (!in_array($sb['MenuID'],$enable_menu)) { echo " disabled=true"; } ?>><?=$sb['MenuLabel']?></div>
                                <?php endif;?>
                            <?php else:?>
                                <div iconCls="<?=$submn['Icon']?>" onclick="<?=$this->m_menu->get_action($sb['ActionType'],array($sb['MenuLabel'],$sb['MenuLink'],$submn['Icon']))?>" <?php //if (!in_array($sb['MenuID'],$enable_menu)) { echo " disabled=true"; } ?>><?=$sb['MenuLabel']?></div>
                            <?php endif;?>
                           
                    <?php endforeach;?>
                </div>
            </div>
        <?php
        }
        else{ ?>
             <?php if($submn['ActionType'] == 'Modal' or $submn['ActionType'] == 'Direct'):?>
                <?php 
                    $group_menu = $this->session->userdata('group_menu');
                    $privillage = $this->m_menu->get_menuAuthority_byID($group_menu,$submn['MenuID']);  
                ?>
                <?php if($privillage):?>
                     <div data-options="iconCls:'<?=$submn['Icon']?>'" <?php  //if (!in_array($submn['MenuID'],$enable_menu)) { echo " disabled=true"; } ?> onclick="<?=$this->m_menu->get_action($submn['ActionType'],array($submn['MenuLabel'],$submn['MenuLink'],$submn['Icon']))?>"><?=$submn['MenuLabel']?></div>          
                <?php endif;?>
            <?php else:?>
                <div data-options="iconCls:'<?=$submn['Icon']?>'" <?php  //if (!in_array($submn['MenuID'],$enable_menu)) { echo " disabled=true"; } ?> onclick="<?=$this->m_menu->get_action($submn['ActionType'],array($submn['MenuLabel'],$submn['MenuLink'],$submn['Icon']))?>"><?=$submn['MenuLabel']?></div>          
            <?php endif;?>
            
        <?php
        }
    }	
    
    echo "</div>";
?>

<div id="mmWindow" style="width:150px;">
    <div onclick="tab_close_all()">Close All</div>
</div>
            
<div id="mmHelp" style="width:150px;">
    <div onclick="modal_open('About','dlg_about')">About</div>	
</div>