<?
header("Content-Type: application/xhtml+xml; charset=utf-8");
use_helper('UrlFunctions');

$o_AjuCorrelativoExpFN = new AjuCorrelativoExpFN();

//$o_ObjectBean = new ClienteBean();
  
$tamanioPag = 22;
//COLOCAR CAMPOS DE LA CABECERA DEL LISTADO 
 
//Todos los Mercados de Todas las sucursales

if($estado   	!=""){ $o_AjuCorrelativoExpFN->setEstado($estado); }
if($anio   	!=""){ $o_AjuCorrelativoExpFN->setIdanio($anio); }



 $o_AjuCorrelativoExpFN->page = $page;
 $o_AjuCorrelativoExpFN->tamPag = $tamanioPag;

 
 if(!isset($sortCampos) || $sortCampos == ''){
	$o_AjuCorrelativoExpFN->sortCampos = "Fechacreacion";
}else{
	$o_AjuCorrelativoExpFN->sortCampos = $sortCampos;
}
if(!isset($sortType) || $sortType == ''){
	$o_AjuCorrelativoExpFN->sortType   = "2";
}else{
	$o_AjuCorrelativoExpFN->sortType   = $sortType;	
}


$a_o_AjuCorrelativoExpFN = $o_AjuCorrelativoExpFN->select();
 

$o_navigation = new navigation();
$o_navigation->setPaginaActual($page);
$o_navigation->setTamanioPagina($tamanioPag);
$o_navigation->setTotalRegistros($o_AjuCorrelativoExpFN->selectNumRows());
$valuesSort = array('sortCampos'=>$sortCampos, 'sortType'=>$sortType);

if(!$page) $page = 1;



ViewResponse::getInstance()->setMethodAjax();

?>
<script>
functionSort = function(campo, type){
  var typeSort      = "";
  
  var elmSortCampos = $('#sortCampos');
  var elmSortType   = $('#sortType');


 
  var a_sortCampos  = (elmSortCampos.attr('value')!="")?(elmSortCampos.attr('value')).split(";"):[];
  var a_sortType    = (elmSortType.attr('value')!="")?elmSortType.attr('value').split(";"):[];
 
  var pos           = jQuery.inArray(campo,a_sortCampos);
 
  switch (type){
     case 'A' :
       a_sortType[pos]    = "2";
     break;
     case 'D' :
       //if(pos>0){
       	a_sortCampos = sliceByPos(a_sortCampos, pos);
       	a_sortType   = sliceByPos(a_sortType, pos);
       //}else{
       	//a_sortCampos[pos] = campo;
       	//a_sortType[pos]   = "1";
       //}
     break;
     default :
       a_sortCampos[a_sortCampos.length] = campo;
       a_sortType[a_sortType.length]     = "1";
     break;
  }
 
  var strSortCampos = a_sortCampos.join(";");
  var strSortType   = a_sortType.join(";");
  
  concatValueStr('sortCampos='+strSortCampos+'&sortType='+strSortType+"&page=<?=$page?>");
}
</script>

<?php

$strConcat = "sortCampos=".$valuesSort['sortCampos']."&sortType=".$valuesSort['sortType'];

function showImgOrder($valuesSort, $campo, $nameCampos){
  $a_valCampos = explode(";", $valuesSort['sortCampos']);
  $a_valtype   = explode(";", $valuesSort['sortType']);
  $sImg = "
            <a href=\"JavaScript:functionSort('".$campo."', '');\">".$nameCampos."</a>
            <img src=\"/images/common/buttons/arrow.gif\" alt=\"Ordenado Ascendente\" width=\"8\" height=\"10\" align=\"absmiddle\" />
          ";
  foreach ($a_valCampos as $key => $val){
    if($val == $campo){
      switch ($a_valtype[$key]){
        case 1:
          $sImg = "
                    <a href=\"JavaScript:functionSort('".$campo."', 'A');\">".$nameCampos."</a>
                    <img src=\"/images/common/buttons/arrow_up.gif\" alt=\"Ordenado Ascendente\" width=\"8\" height=\"10\" align=\"absmiddle\" />
                  ";
        break;
        case 2:
          $sImg = "
                    <a href=\"JavaScript:functionSort('".$campo."', 'D');\">".$nameCampos."</a>
                    <img src=\"/images/common/buttons/arrow_down.gif\" alt=\"Ordenado Ascendente\" width=\"8\" height=\"10\" align=\"absmiddle\" />
                  ";
        break;
      }
    }
  };
  return $sImg;
}
?>

<input type="hidden" id="sortCampos" size="100" value="<?=$valuesSort['sortCampos']?>">
<input type="hidden" id="sortType" size="100" value="<?=$valuesSort['sortType']?>">
      <table class="marco" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td height="17" align="right" class="pager">
            <div id="contenedor">
              <? $o_navigation->ContruirHTMLNavigation('contenedor', $strConcat); ?>
            </div>
          </td>
        </tr>
        <tr>
          <td>
            <table class="grid" width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr height="35">
               <th width="3%" >Nro</th>
                
                <th width="20%" align="left">Año</th>
                <th width="40%" align="left">Correlativo</th>
                
				
				<th width="20%" align="left">Estado</th>
				<th width="10%" align="left"></th>
				
				              
               
              </tr>
              <? if(count($a_o_AjuCorrelativoExpFN)>0){ ?>
              <? foreach ($a_o_AjuCorrelativoExpFN as $iKey => $o_objBean){ 
              	//print_r($o_objBean);?>
             <tr onClick="TR_click(this,<?php echo ($iKey%2);?>);" class="<?php if($iKey%2) echo "aspecto2";?>">
               <td class="chk"><?=($tamanioPag)*($page-1)+($iKey+1)?></td>
               
                <td align="left"><?php echo $o_objBean->getIdanio()?></td>
                <td align="left"><?php echo $o_objBean->getNumeroactual()?></td>
				<td align="left"><?php if($o_objBean->getEstado()=="A") echo "Activo";else echo "Inactivo";?></td>
				<td align="left">
				<img src="/images/common/iconos/editar-2.png" title="Editar Entidad" onclick="parent.objMainTab.modalDialog('<?=buildUrl('correlativo/edit/idanio/'.$o_objBean->getIdanio(),'block=001');?>',{title:'Detalle de Entidad',width:490,height:320,nameOtherWindow:'ov'})">
				</td>
                 
              </tr>
              <? } ?>
              <? }else{ ?>
              <tr>
                <td colspan="7" align="center">No se produjo resultado</td>
              </tr>
              <? } ?>
            </table>
          </td>
        </tr>
        <tr>
          <td>Total Registros: <?=$o_AjuCorrelativoExpFN->selectNumRows()?></td>
        </tr>
      </table>