<?
header("Content-Type: application/xhtml+xml; charset=iso-8859-1");
use_helper('UrlFunctions');
use_helper('UtilFunctions');
$o_ObjectBean = new ClienteBean();
  
$tamanioPag = 3000;
//COLOCAR CAMPOS DE LA CABECERA DEL LISTADO  


if(myUser::getUser()->getRoleId() == "sys.gen" || myUser::getUser()->getRoleId() == "sys.res" || myUser::getUser()->getRoleId() == "sys.sup"|| myUser::getUser()->getRoleId() == "sys.view"){
	
}else{
	$o_ObjectBean->setIdColaboradorPrestamo(myUser::getUser()->getIdColaborador());
}


//Sacar el nombre de la sucursal
$o_SucursalBean = new SucursalBean();
$o_SucursalBean->setIdAdministrador(myUser::getUser()->getIdColaborador());

$o_SucursalBL = new SucursalBL();
$a_o_sucursal = $o_SucursalBL->busquedaSucursal($o_SucursalBean);

foreach ($a_o_sucursal as $key => $o_sucursal){
	$IdSucursal 	= $o_sucursal->getIdSucursal();
	$NombreSucursal = $o_sucursal->getDescripcion();
}


	 
 
$o_ClienteDP = new ClienteDP($o_ObjectBean);
$a_ObjectBean = $o_ClienteDP->seleccionarClientesReCaptacion($IdSucursal,$cboMercado);





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

?>
<script>
functionSort = function(campo, type){
  var typeSort      = "";
  var elmSortCampos = $('sortCampos');
  var elmSortType   = $('sortType');
  var a_sortCampos  = elmSortCampos.value!=""?elmSortCampos.value.split(";"):[];
  var a_sortType    = elmSortType.value!=""?elmSortType.value.split(";"):[];
  var pos           = a_sortCampos.indexOf(campo);
  switch (type){
     case 'A' :
       a_sortType[pos]    = "2";
     break;
     case 'D' :
       a_sortCampos = sliceByPos(a_sortCampos, pos);
       a_sortType   = sliceByPos(a_sortType, pos);
     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>
            <table class="grid" width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr height="23">
               <th width="4%" >Nro.</th>
    
			    <th width="5%" align="left">Cod.Cliente&nbsp;&nbsp;&nbsp;</th>
			    <th width="28%" align="left">Cliente&nbsp;&nbsp;&nbsp;</th>
			    <th width="3%"  align="center" >F. Cancelado</th>
				<th width="3%">N.Prestamos&nbsp;C.</th>
                 
               
              
              </tr>
              <? if(count($a_ObjectBean)>0){ 
              	$i =1;
              	echo "<pre>";
				//print_r($a_ObjectBean);
				echo "</pre>"; 
              foreach ($a_ObjectBean as $iKey => $o_objBean){ ?>
              <tr onClick="TR_click(this);">
                <td align="center"><?=$i++?></td>
                <td align="left"><?=$iKey?></td>
                <td align="left"><?=$o_objBean['NombreCliente']?></td>
                <td  align="center"><?=substr($o_objBean['fechaMaximoCancelado'],0,10);?></td>
                <td align="center"><?=$o_objBean['C'];?></td>  
				
				
				</tr>
              <? } ?>
              <? }else{ ?>
              <tr>
                <td colspan="7" align="center">No se produjo resultado</td>
              </tr>
              <? } ?>
            </table>
          </td>
        </tr>
         <tr>
          <td>
	          <table class="marco" border="1" cellpadding="0" cellspacing="0" width="100%" bgcolor="#CCCCCC">
	            <tr>
	          		<td width="49%" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:bold; color:#000000">T Registros: <?=count($a_ObjectBean)?></td>
	          		
	          	</tr>
	          </table>
          </td>
        </tr>
        <!--<tr>
          <td>Total Registros: <?=count($a_ObjectBean)?></td>
        </tr>-->
      </table>