<?php 
function main_head($text) {
  use_helper('UrlFunctions');
  use_helper('Javascript');
//  use_helper('Object');
?>
<!--trae los datos de la session-->
<?php
  //$ob_sfUser = sfContext::getInstance()->getUser();
  $ob_sfUser = myUser::getUser();
?>
<?php //$ob_sfRequest = sfContext::getInstance()->getRequest(); ?>

<table border="0" cellpadding="0" cellspacing="0" id="mainContainer">
  <tr>
    <td height="70">
			<table  id="mainCab" width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#006832"  >
		     				
        <tr>
            <td ><img src="../../../images/common/logo_akistah.png" border="0" alt=""></td>
           <td valign="bottom">
            <table  align="right" border="0" cellpadding="0" cellspacing="0">
              <tr>
  							<?php if ($ob_sfUser->isAuthenticated()){ ?>
                <td style="font-family:Arial, Helvetica, sans-serif;font-size: 15px;"><strong><label><font color='#2E3192' style="font-family:Arial, Helvetica, sans-serif;font-size: 15px;"><?php echo link_to('<font color=#EEB310>Logout</font>', 'user/logout'); ?></font></label></strong></td>
  							<?php }else{ ?>
                <td style="font-family:Arial, Helvetica, sans-serif;font-size: 15px;"><strong><label><font color=red style="font-family:Arial, Helvetica, sans-serif;font-size: 15px;"><?php echo link_to('<font color="#2D4896">Login</font>', 'user/login'); ?></font></label></strong></td>
  							<?php } ?>
               <!-- <td >&nbsp;<font color='#FFFFFF'>|</font>&nbsp;</td>-->
                <!--<td ><strong><label><font color='#FFFFFF'>Ayuda</font></label></strong></td>-->
                <td >&nbsp;<font color='#000000'>|</font>&nbsp;</td>
               <td style="font-family:Arial, Helvetica, sans-serif;font-size: 15px;"><strong><label><a href="https://sistema-creditos.dataexe.com/" style="color:#cecece;font-family:Arial, Helvetica, sans-serif;font-size: 15px;;color:#0000FF;">Ir a la Web</a></label></strong></td>
                
               <?php
           
               if($ob_sfUser->getUserId()!= "" &&  myUser::getUser()->getRoleId() != "sys.gen"){
               
						//Carga los Mercado
						 $o_ClienteSystemClass = new ClienteSystemClass(new TipoNegocioBean());
						  $a_Mercado = $o_ClienteSystemClass->LoadMercadoXRol();
						
						if(myUser::getUser()->getIdPadre() == '1'  || myUser::getUser()->getRoleId() == "sys.ope" || myUser::getUser()->getRoleId() == "sys.hip"){
							$o_ColaboradorBean_Temp = new ColaboradorBean();
							$o_ColaboradorBean_Temp->setIdColaborador(myUser::getUser()->getIdColaborador()); 
							$o_ColaboradorBL_Temp = new ColaboradorBL();
							$o_ColaboradorBeanResult = $o_ColaboradorBL_Temp->busquedaColaborador($o_ColaboradorBean_Temp);
							$idAdministrador = $o_ColaboradorBeanResult[0]->getIdPadre();
						}elseif(myUser::getUser()->getIdPadre() == "A"){ //Todos los Padres Rol actualmente sys.gen y sys.view
							//SIN FILTRO
						}else{
							$idAdministrador = myUser::getUser()->getIdColaborador();
						}
						
						if($idAdministrador){
							$o_SucursalBean = new SucursalBean();
							$o_SucursalBean->setIdAdministrador($idAdministrador);
							$o_SucursalBL = new SucursalBL();
							$a_o_sucursal = $o_SucursalBL->busquedaSucursal($o_SucursalBean);
							//----------------------------------------------------
							
							$IdSucursal = $a_o_sucursal[0]->getIdSucursal();
						
						}
						
						if($IdSucursal){
							$o_BalanceDia = new BalanceDiaBean();
							$o_BalanceDia->setIdSucursal($IdSucursal);
							$o_BalanceDia->setIdAdministrador($idAdministrador);
							
							$o_BalanceDiaDP = new BalanceDiaDP($o_BalanceDia);
							$fecha = $o_BalanceDiaDP->ObtenerDiaAbierto();
               			}
               			}	
               			//Obtener la fecha 	de dia abierto de Hipotecas
               			
               			if(myUser::getUser()->getRoleId() == "sys.res" || myUser::getUser()->getRoleId() == "sys.ope" || myUser::getUser()->getRoleId() == "sys.hip"){
               				
               			//	$o_cierreDiaFN = new CrCierrehipotecaCFN();
               			//	$fechaHipotecas = $o_cierreDiaFN->obtenerDiaAbiertoHipoteca($IdSucursal);
               				
               			}

				?>	
  				
              
                <? if($fecha){?>
	                <td ><strong><label class="aviso_inicial"><div style="color:#ff0000;font-size:16px">&nbsp;&nbsp;D&iacute;a Abierto:&nbsp;</div></strong></td>
	                <td ><div id="kuki" class="aviso_inicial" style="color:#ff0000;font-size:18px"><strong><?php echo $fecha?></strong><div></td>
                <? }else{?>
                	<td ><div id="kuki"><div></td>
                <? }?>
              
              </tr>
              <tr>
                <td colspan="9" align="right"><label><font color='#000000'>Bienvenido: <?php echo $ob_sfUser->getUserId(); ?></font></label></td>
				        <td>&nbsp;&nbsp;&nbsp;</td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td valign="bottom" colspan="2">
            <table cellpadding="0" cellspacing="0" id="mainMenu">
			
              <tr>
                <td class="mnuSep"><img src="/images/common/spacer.gif" width="10"></td>
          <?php
          $ob_MainMenu = new menu_class;
          $ob_MainMenu->getInit($ob_sfUser->getRoleId());

          /**
           * Esto tendria que ser un TAB
           */
					$menu_lst = $ob_MainMenu->getMenu($ob_MainMenu->getStartTaskId());
					$x = 0; $default = "";
					if ( count ($menu_lst) > 0){
						
						foreach ($menu_lst as $key => $value){
							if ($value['Access'] && $value['TaskType'] == 'menu'){
								if ($value['IsDisable'] == 'N'){
									if($x==0){ $default = $key;  }
						?>
	                  <td>
	                  	<table id="mainMenu_<?=$key?>" cellpadding="0" cellspacing="0" class="mnuElement" onClick="objMainTab.showMenuContent('<?=$value['TaskId']?>','<?=$key?>');">
	                    <tr>
	                      <td class="mnuInactivoIzq" type='maintTab_<?=$key?>'><img src="/images/common/spacer.gif" width="7"></td>
	                    	<? if ($value['TaskType'] == 'proc') {?>
	                      <td class="mnuInactivoTxt" type='maintTab_<?=$key?>' nowrap><? echo $value['ButtonText'];?></td>
	                    	<?}else{?>
	                      <td class="mnuInactivoTxt" type='maintTab_<?=$key?>' nowrap><? echo $value['ButtonText'];?></td>
	                    	<?}?>
	                      <td class="mnuInactivoDer" type='maintTab_<?=$key?>'><img src="/images/common/spacer.gif" width="8"></td>
	                    </tr>
	                  </table>
	                </td>
					
	                <td class="mnuSep"><img src="/images/common/spacer.gif"></td>
						<?
									$x++;
		            			}else{
		            				
						?>
	                  <td>
	                  	<table id="mainMenu_<?=$key?>" cellpadding="0" cellspacing="0" class="mnuElementDisabled">
	                    <tr>
	                      <td class="mnuDisabledIzq" type='maintTab_<?=$key?>'><img src="/images/common/spacer.gif" width="7"></td>
	                    	<? if ($value['TaskType'] == 'proc') {?>
	                      <td class="mnuDisabledTxt" type='maintTab_<?=$key?>' nowrap><? echo $value['ButtonText'];?></td>
	                    	<?}else{?>
	                      <td class="mnuDisabledTxt" type='maintTab_<?=$key?>' nowrap><? echo $value['ButtonText'];?></td>
	                    	<?}?>
	                      <td class="mnuDisabledDer" type='maintTab_<?=$key?>'><img src="/images/common/spacer.gif" width="8"></td>
	                    </tr>
	                  </table>
	                </td>
	                <td class="mnuSep" ><img src="/images/common/spacer.gif"></td>
						<?
		            			}
		            			
							}
						}
		          } else {
		              echo "<td>&nbsp;</td>";
		          }
          
          /**
           * Eso fue un TAB
           */
          ?>

                <td class="mnuEnd" ><img src="/images/common/spacer.gif" width="7"></td>
              </tr>

				
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td id="titleBar">&nbsp;
      
    </td>
  </tr>
  <tr>
    <td id="menuBar">
			<!--algo estaba aqui-->
  	</td>
  </tr>
  <tr>
    <td valign="top">
      <table border="0" cellpadding="0" cellspacing="0" class="bodyContainer" height="455px">
        <tr>
          <td align="left" valign="top" nowrap="nowrap" bgcolor="#E3E9E2">
          	<table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td align="left" width="10" valign="top" nowrap="nowrap" id="contentImg">
                <? if ($ob_sfUser->isAuthenticated()){ ?>
                	<img src='/images/common/btnMostrar.gif' width='7' height='25' style="cursor:pointer;" onClick='objMainTab.showMenu()'>
                <? }else{ ?>
					       <img src='/images/common/btnMostrar.gif' width='7' height='25'>
                <? } ?>
                	<img src="/images/common/spacer.gif" width="5" height="5">
                </td>
                <td valign="top" >
                	<div class="leftMenu" id="contentMenu" style="display:none;"></div>
                </td>
              </tr>
            </table>
            <img src="/images/common/spacer.gif" width="5" height="5">
          </td>
          <td class="marginLeft" width="10">
          	<img src='/images/common/spacer.gif' width='9' height='10'>
          </td>
          <td id="contentResult" align="left" valign="top" nowrap="nowrap" width="100%">
		  	    <img src='/images/common/spacer.gif' width='10' height='10'><img src='/images/common/spacer.gif' width='10' height='10' align='left'>
              	<?php echo $text; ?>
          </td>
          <td class="marginRight" width="10">
          	<img src='/images/common/spacer.gif' width='9' height='10'>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<div style="display:none" id="messageLoadMenu">
	<table  border="0" cellpadding="0" cellspacing="0" style="width:165px;">
		<tr>
			<td width="80px" id="menuBar" valign="middle">Cargando...</td>
			<td><img src="/images/common/progress.gif" width="15px" height="15px" align="middle"></td>
		</tr>
	</table>
</div>

<?php 
	if ($ob_sfUser->isAuthenticated()):
    echo javascript_tag("objMainTab.showMenuContent('".$menu_lst[$default]['TaskId']."','".$default."');");
	endif;
 }
