<?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();
  
  /*
  $_SESSION['user_system']['user_id'] 		  	= $ob_sfUser->getUserId();
  $_SESSION['user_system']['user_name'] 	  	= $ob_sfUser->getName();
  $_SESSION['user_system']['user_company_name'] = $ob_sfUser->getNameBusiness();
  $_SESSION['user_system']['user_company_id'] 	= $ob_sfUser->getIdBusiness();
  $_SESSION['user_system']['user_role_id'] 	    = $ob_sfUser->getRoleId();*/
?>
<?php //$ob_sfRequest = sfContext::getInstance()->getRequest(); ?>
<div style="text-align:center;margin:0px auto; background:#FFFFFF; background-position:top center; background-repeat:no-repeat;">
<table border="0" cellpadding="0" cellspacing="0" id="mainContainer">
  <tr width="100%">
    <td height="25" width="100%">
			<table  id="mainCab" style="" width="100%" border="0" cellspacing="0" cellpadding="0">
		        <tr>
		          <td ><!--<img src="<?=Constantes::ROOT_DIR_IMG?>common/logo_petcenter.png">-->&nbsp;</td> 
		          <td valign="bottom">
		          	<table align="right" border="0">
		          		<tr>
		          			<td>
								<?php if ($ob_sfUser->isAuthenticated()){ ?>
									<table  align="right" border="0" cellpadding="0" cellspacing="0">
									
										
										<tr>
											<td style="font-size:12px; color:#666666; text-align:right">Bienvenido&nbsp;&nbsp;</td>
											<td style="font-size:12px; padding:3px; background:#005ea8; color:#FFFFFF; border-bottom: 1px solid #C8D5EC;"><?=$ob_sfUser->getName()?></td>
									   
											<td style="font-size:12px; color:#666666; text-align:right">Usuario&nbsp;&nbsp;</td>
											<td style="font-size:12px; padding:3px; background:#005ea8; color:#FFFFFF; border-bottom: 1px solid #C8D5EC;" colspan="2"><?php echo $ob_sfUser->getUserId() ?> - <?php echo $ob_sfUser->getRoleId() ?></label></td>
										
											<td style="font-size:12px; color:#666666; text-align:right">Empresa&nbsp;&nbsp;</td>
											<td style="font-size:12px; padding:3px; background:#005ea8; color:#FFFFFF; border-bottom: 1px solid #C8D5EC;" colspan="2"><?=$ob_sfUser->getNameBusiness()?></td>
											
											<?php if( $ob_sfUser->getIdSucursal() ){ ?>
												<td style="font-size:12px; color:#666666; text-align:right">Sucursal&nbsp;&nbsp;</td>
												<td style="font-size:12px; padding:3px; background:#005ea8; color:#FFFFFF; border-bottom: 1px solid #C8D5EC;" colspan="2"><?php echo $ob_sfUser->getNameSucursal() ?></label></td>
											<?php } ?>	
											
											<td style="font-size:12px; padding:3px; color:#FFFFFF; border: 1px solid #C8D5EC;">[ <a href="<?php echo buildUrl('user/logout')?>" class="classMenuLogin" style="color: #ff0000; font-weight:bold !important; font-size: 11px;">Cerrar Sesi&oacute;n</a>  ]</td>
										
											
										</tr>
											
										
									</table>	
								<?php } ?>
		          			</td>
		          		</tr>
		          	</table>		            
		          </td>
		        </tr>
		<?php if ($ob_sfUser->isAuthenticated()){ ?>
        <tr>
          <td valign="bottom" colspan="2">
            <table cellpadding="0" cellspacing="0" id="mainMenu">
              <tr>
                <td class="mnuSep"><img src="<?=Constantes::ROOT_DIR_IMG?>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_<?php echo  $key?>" cellpadding="0" cellspacing="0" class="mnuElement" onClick="objMainTab.showMenuContent('<?php echo  $value['TaskId']?>','<?php echo  $key?>', '<?php echo  buildUrl('user/xmenu')?>');">
	                    <tr>
	                      <td class="mnuInactivoIzq"  type='maintTab_<?php echo  $key ?>'><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="0"></td>
	                    	<?php if ($value['TaskType'] == 'proc') {?>
	                      <td class="mnuInactivoTxt"  type='maintTab_<?php echo  $key ?>' nowrap><?php echo $value['ButtonText'];?></td>
	                    	<?php }else{?>
	                      <td class="mnuInactivoTxt"  type='maintTab_<?php echo  $key ?>' nowrap><?php echo $value['ButtonText'];?></td>
	                    	<?php } ?>
	                      <td class="mnuInactivoDer"  type='maintTab_<?php echo  $key ?>'><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="1"></td>
	                    </tr>
	                  </table>
	                </td>
	                <td class="mnuSep"><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif"></td>
						<?php
									$x++;
		            			}else{
		            				
						?>
	                  <td>
	                  	<table id="mainMenu_<?php echo  $key?>" cellpadding="0" cellspacing="0" class="mnuElementDisabled">
	                    <tr>
	                      <td class="mnuDisabledIzq" type='maintTab_<?php echo  $key ?>'><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="0"></td>
	                    	<?php if ($value['TaskType'] == 'proc') {?>
	                      <td class="mnuDisabledTxt"  type='maintTab_<?php echo  $key ?>' nowrap><?php echo $value['ButtonText']; ?></td>
	                    	<?php }else{ ?>
	                      <td class="mnuDisabledTxt" type='maintTab_<?php echo  $key ?>' nowrap><?php echo $value['ButtonText']; ?></td>
	                    	<?php } ?>
	                      <td class="mnuDisabledDer" type='maintTab_<?php echo  $key ?>'><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="1"></td>
	                    </tr>
	                  </table>
	                </td>
	                <td class="mnuSep"><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif"></td>
						<?php
		            			}
		            			
							}
						}
		          } else {
		              echo "<td>&nbsp;</td>";
		          }
          
          /**
           * Eso fue un TAB
           */
          ?>

                <td class="mnuEnd"><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="7"></td>
              </tr>


            </table>
          </td>
        </tr>
        <?php } ?>
      </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" class="bodyContainerTdBgColor">
          	<table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td align="left" width="10" valign="top" nowrap="nowrap" id="contentImg">
                <?php if ($ob_sfUser->isAuthenticated()){ ?>
                	<img src='<?=Constantes::ROOT_DIR_IMG?>common/btnMostrar.gif' width='7' height='25' style="cursor:pointer;" onClick='objMainTab.showMenu()'>
                <?php }else{ ?>
					       <img src='<?=Constantes::ROOT_DIR_IMG?>common/btnMostrar.gif' width='7' height='25'>
                <?php } ?>
                	<img src="<?=Constantes::ROOT_DIR_IMG?>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="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="5" height="5">
          </td>
          <td class="marginLeft" width="10">
          	<img src='<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif' width='9' height='10'>
          </td>
          <td id="contentResult" align="left" valign="top" nowrap="nowrap" width="100%">
		  	    <img src='<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif' width='10' height='10'><img src='<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif' width='10' height='10' align='left'>
              	<?php echo $text; ?>
          </td>
          <td class="marginRight" width="10">
          	<img src='<?=Constantes::ROOT_DIR_IMG?>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="<?=Constantes::ROOT_DIR_IMG?>common/progress.gif" width="15px" height="15px" align="middle"></td>
		</tr>
	</table>
</div>
</div>
<?php
	if ($ob_sfUser->isAuthenticated()):
    echo javascript_tag("objMainTab.showMenuContent('".$menu_lst[$default]['TaskId']."','".$default."', '".buildUrl('user/xmenu')."');");
	endif;
 }
?>