<?php 
use_helper('UrlFunctions'); 
use_helper('UtilFunctions'); 
?>
<script type="text/javascript" src="<?php echo Constantes::ROOT_DIR_APP?>/web/js/JSClass/FusionCharts.js"></script>
<script>
findControl = function(){
  
  concatValueStr();
  
}
function visualizar(id){
	$(id).show();
}
function ocultar(id){
	$(id).hide();
}
exportFindControl = function(action){
  strFormSerialize = returnQueryStringForm();
  executeFind(strFormSerialize, action);
}

executeFind = function(str, action){
  if(typeof(action) == 'undefined'){
	  url = "<?=buildUrlComplet('mnt.php/cat/gridu_tabla', "block=".$block)?>";
	}else{
	  switch (action){
	    case 'excel': parent.objMainTab.reqBody('<?=buildUrl('cat/excel')?>','001&'+str); break;
        case 'pdf': parent.objMainTab.reqBody('<?=buildUrl('cat/pdf')?>','001&'+str); break;	    
	  }
	  
	  return;
	}
  //str = str + '&block=001';
  url = "<?=buildUrlComplet('mnt.php/cat/gridu_tabla', "block=".$block)?>";
	var myAjax  = new Ajax.Updater(
                                	"resultGrtid",
                                	url,
                                	{
                                		asynchronous:	true,
                                		method			: 'get',
                                		parameters	: str,
                                		evalScripts	: true,
                                		onLoading   : cargandoImagenSerch(),
                                		onComplete	: function(){
                                			//objMainTab.showMenu();
                                		}
                                	});
}

concatValueStr = function(){
  strFormSerialize = returnQueryStringForm();
  if(arguments[0]){
    strFormSerialize += '&'+arguments[0];
  }
  executeFind(strFormSerialize);
}

function detallePrestamos(idSucursal,idMercado,idColaborador,IdCategoria){
	
	params = $('form1').serialize();
	//alert(params);
	
	params = params.replace(/=&/g, '/-1/');
	params = params.replace(/&/g, '/');
	params = params.replace(/=/g, '/');
	
	params = params+'/IdSucursal/'+idSucursal+'/IdMercado/'+idMercado+'/IdRepresentante/'+idColaborador+'/IdCategoria/'+IdCategoria;
	
	url = "<?=buildUrlComplet('rep.php/cat/show', '')?>";
	parent.objMainTab.modalDialog (url+params,{width:1200,height:570});
}

function returnQueryStringForm(){
  cadenaFormulario = $('form1').serialize();
             var posicion = new Array();
             var a_pars = new Array();
             var miArray = new Array();
             posicion=[];
             a_pars=[];
             miArray=[];
             miArray = cadenaFormulario.split('&');
             x=0;
             for (i = 0; i < miArray.length; i++){
            	   posicion[i] = miArray[i].indexOf('=');
            	   if(typeof(miArray[i-1])!='undefined'){
            				if(miArray[i].substring(posicion[i],0)== miArray[i-1].substring(posicion[i-1],0) ){
           					 porcion = miArray[i].substring((1+posicion[i]));
           					 a_pars[x-1]+='@'+porcion;
           				}else{
          					 a_pars[x]= miArray[i];
         					 x++;
          				}
          		}else{
          			 a_pars[x]= miArray[i];
          			  x++;
          		}
           }
  cadenaFormulario = a_pars.join('&');
  cadenaFormulario += '&id_form=frmFindFedu';
  return(cadenaFormulario);
}

function cargandoImagenSerch(){
	//disabledWin.setPathImage('/images/common/progress.gif');
	disabledWin.show(true,true,'resultGrtid');
}

</script>
<script>
findControl = function(){
 	
  var valid = new Validation('form1', {immediate : true});
  var result = valid.validate();
 
  if(result){
	  var pars = $('form1').serialize();
	  
		disabledWin.setPathImage('/images/common/progress.gif');
		disabledWin.show(true,true,'resultGrtid');
	  
		url = "<?=buildUrl('cat/gridu_tabla', "block=".$block)?>";
		var myAjax  = new Ajax.Updater(
		"resultGrtid",
		url,
		{
			asynchronous:	true,
			method			: 'get',
			parameters	: pars,
			evalScripts	: true,
			onLoading		: function(){
				//$('contentMenu').innerHTML = $('messageLoadMenu').innerHTML;
			},
			onComplete	: function(){
				request();
			}
		});
  }
  
}

function request(){
			//Obtener el xml de las sucursales x categoria
			var cboSucursalFiltro = '';  
  			if($('cboSucursalFiltro')) cboSucursalFiltro = $('cboSucursalFiltro').value;
  			//alert(cboSucursalFiltro);
			var pars = $('form1').serialize();
			var url2 = '<?=buildUrl('ajax/request')?>';
  			pars = pars+'&type=sucursalesxCategoria&cboSucursalFiltro='+cboSucursalFiltro;
			new Ajax.Request(url2, {
			  method: 'get', 
              parameters: pars, 
			  onComplete: function(response) {
			    graficarSucursalesxCategoria(response.responseText);
			  }
			});	
			
			var cboSucursalFiltroMxC = '';  
  			if($('cboSucursalFiltroMxC')) cboSucursalFiltroMxC = $('cboSucursalFiltroMxC').value;
  			var cboMercadoFiltroMxC = '';  
  			if($('cboMercadoFiltroMxC')) cboMercadoFiltroMxC = $('cboMercadoFiltroMxC').value;
  			
			var pars = $('form1').serialize();
			var url2 = '<?=buildUrl('ajax/request')?>';
  			pars = pars+'&type=mercadosxCategoria&cboSucursalFiltroMxC='+cboSucursalFiltroMxC+'&cboMercadoFiltroMxC='+cboMercadoFiltroMxC;
			new Ajax.Request(url2, {
			  method: 'get', 
              parameters: pars, 
			  onComplete: function(response) {
			    graficarMercadosxCategoria(response.responseText);
			  }
			});	
			
			var cboSucursalFiltroCxS = '';  
  			if($('cboSucursalFiltroCxS')) cboSucursalFiltroCxS = $('cboSucursalFiltroCxS').value;
			
			var cboCategoriaFiltroCxS = '';  
  			if($('cboCategoriaFiltroCxS')) cboCategoriaFiltroCxS = $('cboCategoriaFiltroCxS').value;
  			
			var pars = $('form1').serialize();
			var url2 = '<?=buildUrl('ajax/request')?>';
  			pars = pars+'&type=categoriaxSucursal&cboSucursalFiltroCxS='+cboSucursalFiltroCxS+'&cboCategoriaFiltroCxS='+cboCategoriaFiltroCxS;
			new Ajax.Request(url2, {
			  method: 'get', 
              parameters: pars, 
			  onComplete: function(response) {
			    graficarCategoriaxSucursal(response.responseText);
			  }
			});	
			
			
			var cboCategoriaFiltroCxM = '';  
  			if($('cboCategoriaFiltroCxM')) cboCategoriaFiltroCxM = $('cboCategoriaFiltroCxM').value;
  			
			var cboSucursalFiltroCxM = '';  
  			if($('cboSucursalFiltroCxM')) cboSucursalFiltroCxM = $('cboSucursalFiltroCxM').value;
			
  			
			var pars = $('form1').serialize();
			var url2 = '<?=buildUrl('ajax/request')?>';
  			pars = pars+'&type=categoriaxMercado&cboCategoriaFiltroCxM='+cboCategoriaFiltroCxM+'&cboSucursalFiltroCxM='+cboSucursalFiltroCxM;
			new Ajax.Request(url2, {
			  method: 'get', 
              parameters: pars, 
			  onComplete: function(response) {
			    graficarCategoriaxMercado(response.responseText);
			  }
			});	
}



actualizarSucursalesxCategoria = function(){
  
 var cboSucursalFiltro = $('cboSucursalFiltro').value;
  
  var parsform = $('form1').serialize();
  var url = '<?=buildUrl('ajax/request')?>';
  var pars = 'type=sucursalesxCategoria&cboSucursalFiltro='+cboSucursalFiltro+'&'+parsform;
  new Ajax.Request(url, {
			  method: 'get', 
              parameters: pars, 
			  onComplete: function(response) {
			    graficarSucursalesxCategoria(response.responseText);
			  }
			});
	
}

actualizarGraficoCategoriaxSucursal = function(){
  
  
 	var cboSucursalFiltroCxS = '';  
	if($('cboSucursalFiltroCxS')) cboSucursalFiltroCxS = $('cboSucursalFiltroCxS').value;
	
	var cboCategoriaFiltroCxS = '';  
	if($('cboCategoriaFiltroCxS')) cboCategoriaFiltroCxS = $('cboCategoriaFiltroCxS').value;
	
	var pars = $('form1').serialize();
	var url2 = '<?=buildUrl('ajax/request')?>';
	pars = pars+'&type=categoriaxSucursal&cboSucursalFiltroCxS='+cboSucursalFiltroCxS+'&cboCategoriaFiltroCxS='+cboCategoriaFiltroCxS;
	new Ajax.Request(url2, {
		method: 'get', 
		parameters: pars, 
		onComplete: function(response) {
			graficarCategoriaxSucursal(response.responseText);
		}
	});	
}

actualizarMercadosxCategoria = function(){
  var cboSucursalFiltroMxC = '';
  if($('cboSucursalFiltroMxC')) cboSucursalFiltroMxC = $('cboSucursalFiltroMxC').value;
  var cboMercadoFiltroMxC = $('cboMercadoFiltroMxC').value;
  var parsform = $('form1').serialize();
  var url = '<?=buildUrl('ajax/request')?>';
  var pars = 'type=mercadosxCategoria&cboSucursalFiltroMxC='+cboSucursalFiltroMxC+'&cboMercadoFiltroMxC='+cboMercadoFiltroMxC+'&'+parsform;
  new Ajax.Request(url, {
			  method: 'get', 
              parameters: pars, 
			  onComplete: function(response) {
			    graficarMercadosxCategoria(response.responseText);
			  }
			});
	
}

actualizarCategoriaxMercado = function(){
  	var cboCategoriaFiltroCxM = '';  
	if($('cboCategoriaFiltroCxM')) cboCategoriaFiltroCxM = $('cboCategoriaFiltroCxM').value;
	
	var cboSucursalFiltroCxM = '';  
	if($('cboSucursalFiltroCxM')) cboSucursalFiltroCxM = $('cboSucursalFiltroCxM').value;
	
	
	var pars = $('form1').serialize();
	var url2 = '<?=buildUrl('ajax/request')?>';
	pars = pars+'&type=categoriaxMercado&cboCategoriaFiltroCxM='+cboCategoriaFiltroCxM+'&cboSucursalFiltroCxM='+cboSucursalFiltroCxM;
	new Ajax.Request(url2, {
		method: 'get', 
		parameters: pars, 
		onComplete: function(response) {
		graficarCategoriaxMercado(response.responseText);
		}
	});	
	
}

acutalizarMercado = function(destino,elm){
  $(destino).options.length = 1;
  var url = '<?=buildUrlComplet('mnt.php/ajax/request')?>';
  var pars = 'type=getMercado&nombreElm='+destino+'&value='+elm.value;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
    $('cboRepresentante').length = 1;
}
loadMeses = function(){
  $('cboPeriodoInicial').options.length = 1;
 
  value = $('cboAnio').value;
  var url = '<?=buildUrlComplet('rep.php/ajax/request')?>';
  var pars = 'type=getMeses&nombreElm=cboPeriodoInicial&value='+value;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
                            		
 
   
}
loadMesesFinal = function(){
  
  $('cboPeriodoFinal').options.length = 1;
  value = $('cboAnioFinal').value;
 
                            		
  var url = '<?=buildUrlComplet('rep.php/ajax/request')?>';
  var pars = 'type=getMeses&nombreElm=cboPeriodoFinal&value='+value;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
   
}

function graficarMercadosxCategoria(xml){
   
       	var chart = new FusionCharts("<?php echo Constantes::ROOT_DIR_APP?>/web/tools/Charts/Column3D.swf", "ChartId", "540", "400", "0", "0");
    	chart.addParam("WMode", "Transparent");
    	chart.setDataXML(xml);
   
       	chart.render("chartdiv_mercados_x_categoria");
}
function graficarSucursalesxCategoria(xml){
   
     	var chart1 = new FusionCharts("<?php echo Constantes::ROOT_DIR_APP?>/web/tools/Charts/Pie3D.swf", "ChartId", "540", "380", "0", "0");
     	chart1.addParam("WMode", "Transparent");
     	chart1.setDataXML(xml);
     	chart1.render("chartdiv_sucursales_x_categoria");
    	
   
       
}


function graficarCategoriaxSucursal(xml){
   
     	var chart1 = new FusionCharts("<?php echo Constantes::ROOT_DIR_APP?>/web/tools/Charts/Column3D.swf", "ChartId", "540", "380", "0", "0");
     	chart1.addParam("WMode", "Transparent");
     	chart1.setDataXML(xml);
     	chart1.render("chartdiv_categoria_x_sucursal");
    	
   
       
}

function graficarCategoriaxMercado(xml){
   
     	var chart1 = new FusionCharts("<?php echo Constantes::ROOT_DIR_APP?>/web/tools/Charts/Column3D.swf", "ChartId", "540", "380", "0", "0");
     	chart1.addParam("WMode", "Transparent");
     	chart1.setDataXML(xml);
     	chart1.render("chartdiv_categoria_x_mercado");
    	
   
       
}

function graficarMercadosSucursales(xml){
   
     	var chart1 = new FusionCharts("<?php echo Constantes::ROOT_DIR_APP?>/web/tools/Charts/Pie3D.swf", "ChartId", "540", "380", "0", "0");
     	chart1.addParam("WMode", "Transparent");
     	chart1.setDataXML(xml);
     	chart1.render("chartdiv_mercados_x_sucursales");
    	
   
       
}
function graficarMercadosSucursalesxFecha(xml){
   
     	var chart1 = new FusionCharts("<?php echo Constantes::ROOT_DIR_APP?>/web/tools/Charts/Column3D.swf", "ChartId", "540", "380", "0", "0");
     	chart1.addParam("WMode", "Transparent");
     	chart1.setDataXML(xml);
     	chart1.render("chartdiv_mercados_x_sucursales_x_tiempo");
    	
   
       
}



</script>
<script>
acutalizarRepresentante = function(destino,elm){
  $(destino).options.length = 1;
  var url = '<?=buildUrlComplet('mnt.php/ajax/request')?>';
  var pars = 'type=getRepresentante&nombreElm='+destino+'&value='+elm.value;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
}

function actualizarMercadosxSucusales(valor){
	//Obtener el xml de las mercados x sucursal
	
	var pars = $('form1').serialize();
	var pars = pars+'&cboSucursalFiltro='+valor;
	var url2 = '<?=buildUrl('ajax/request')?>';
		pars = pars+'&type=mercadosSucursales&nombreElm';
	new Ajax.Request(url2, {
	  method: 'get', 
      parameters: pars, 
	  onComplete: function(response) {
	    graficarMercadosSucursales(response.responseText);
	  }
	});
}

function actualizarMercadosxTiempo(op){
	if(op == '1'){
		
		var cboSucursalFiltroMxT = '';
		var destino = 'cboMercadoFiltro';
		if($('cboSucursalFiltroMxT')) cboSucursalFiltroMxT= $('cboSucursalFiltroMxT').value;
		$('cboMercadoFiltro').options.length = 0;
	  	var url = '<?=buildUrlComplet('mnt.php/ajax/request')?>';
	  	var pars = 'type=getMercado&nombreElm='+destino+'&value='+cboSucursalFiltroMxT;
	  
		var myAjax = new Ajax.Request(
	                            		url, 
	                            		{
	                            			method: 'get', 
	                            			parameters: pars, 
	                            			onComplete: function (response, json){
	                            				actualizaJSON(response, json);
	                            				 actualizarGraficoMercadoxTiempo();
	                            			}
	                            		});
		
	}else{
		actualizarGraficoMercadoxTiempo();
	}
	
}

function actualizarGraficoMercadoxCategoria(){
	var cboSucursalFiltroMxC = '';
	var cboMercadoFiltroMxC = '';
	if($('cboSucursalFiltroMxC')) cboSucursalFiltroMxC= $('cboSucursalFiltroMxC').value;
	if($('cboMercadoFiltroMxC')) cboMercadoFiltroMxC= $('cboMercadoFiltroMxC').value;
	
	//Obtener el xml de las sucursales x
	var pars = $('form1').serialize();
	
	var pars = pars+'&cboSucursalFiltroMxC='+cboSucursalFiltroMxC+'&cboMercadoFiltroMxC='+cboMercadoFiltroMxC;
	var url2 = '<?=buildUrl('ajax/request')?>';
		pars = pars+'&type=mercadosxCategoria';
	new Ajax.Request(url2, {
	  method: 'get', 
      parameters: pars, 
	  onComplete: function(response) {
	    graficarMercadosxCategoria(response.responseText);
	  }
	});
}
</script>
<script>
actualizaJSON = function(request, json){
  var numeroElementos = json.length;
  for (var i = 0; i < numeroElementos; i++){
    if($(json[i][0])){
  	  switch ($(json[i][0]).tagName){
  	    case 'TD'      : Element.update(json[i][0], json[i][1]); break;
  	    case 'INPUT'   : $(json[i][0]).value=json[i][1]; break;
  	    case 'SELECT'  : 
  	      var objDDL = $(json[i][0]);
  	      if(typeof(cont) == 'undefined'){
  	        var cont = 0;
  	        //objDDL.options.length = 1;
  	      }
  	      var a_contentValues = json[i][1].split("_;_");
      		var value	= a_contentValues[0];
      		var text	= a_contentValues[1];
  	      var option	= new Option(text,value);
      		try{
      			objDDL.add(option,null);
      		}catch (e){
      			objDDL.add(option,-1);
      		}
  	      cont++;
  	    break;
  	  }
    }else{
      if(json[i][0].indexOf("function") > -1){
        eval("scriptEval = "+json[i][0]);
        scriptEval();
      }
    }
  }
}
</script>

<?php
//Carga los Mercado
$o_ClienteSystemClass = new ClienteSystemClass(new TipoNegocioBean());
$a_Mercado = $o_ClienteSystemClass->LoadMercadoXRol();

$idAdministrador = myUser::getUser()->getIdColaborador();

//echo $idAdministrador;

$o_SucursalBean = new SucursalBean();
if($idAdministrador && myUser::getUser()->getRoleId() == "sys.res")$o_SucursalBean->setIdAdministrador($idAdministrador);
$o_SucursalDP = new SucursalDP($o_SucursalBean);
$a_Sucursal = $o_SucursalDP->select();



//print_r($a_Sucursal);

/*
$o_SucursalBean = new SucursalBean();
$o_SucursalBL = new SucursalBL();
$a_Sucursal = $o_SucursalBL->busquedaSucursal($o_SucursalBean);

*/

$a_categorias = listaCategoria();

//Carga los Mercado
$o_ClienteSystemClass = new ClienteSystemClass(new TipoNegocioBean());
$a_Mercado = $o_ClienteSystemClass->LoadMercadoXRol();



$fecha =date('Y-m-d')
?>

<img src="/images/common/spacer.gif" width="10">
<table class="cuerpo" style="background: #E3E9E2" width="99%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top">
      <form name="form1" id="form1" method="POST">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td class="titleBody"><li>&nbsp;&nbsp;Categorización de Clientes</li></td>
          
        </tr>
      </table>
      <table class="marco" width="100%">
        <tr>
          <td align="center" valign="top"  width="35%" class="marco">
            	 <table border="0" cellpadding="3" cellspacing="0">
            	 	<tr>
						<td width="12%" height="26" nowrap="nowrap" class="cabecera"><label class="label" for="txtNombre">Zona</label></td>
					</tr>
					<tr>
						<td width="12%" height="26" nowrap="nowrap"><label class="label" for="txtNombre">Sucursal</label></td>
						<td width="10%" nowrap="nowrap">
							<select name="cboSucursal" id="cboSucursal" type="text" class="combo" onchange="acutalizarMercado('cboMercado',this);"/> 
									<option value="" > - Seleccionar - </option>
									<?php foreach ($a_Sucursal as $iKey => $o_SucursalBean){ ?>
									<option value="<?=$o_SucursalBean->getIdSucursal()?>">
									  <?=$o_SucursalBean->getDescripcion()?>
									</option>
									<?php } ?> 
							  </select>
						</td>
					</tr>
					<tr>
						<td width="12%" height="26" nowrap="nowrap"><label class="label" for="txtNombre">Mercado</label></td>
						<td width="10%" nowrap="nowrap">
								 <select name="cboMercado" id="cboMercado" type="text" class="combo"  onchange="acutalizarRepresentante('cboRepresentante',this);"/> 
									<option value="" > - Seleccionar - </option>
								</select>
						</td>
					</tr>
					<tr>
						<td width="12%" height="26" nowrap="nowrap"><label class="label" for="txtNombre">Representante</label></td>
						<td width="10%" nowrap="nowrap">
							 <select name="cboRepresentante" id="cboRepresentante" type="text" class="combo"/> 
								<option value="" > - Seleccionar - </option>
							</select>
					  </td>
					 
					</tr>
					<tr>
						<td width="12%" height="26" nowrap="nowrap" class="cabecera"></td>
					</tr>
				</table>
          </td>
          <td  width="65%" class="marco">
          		<table border="0" cellpadding="3" cellspacing="0">
          			<tr>
						<td width="12%" height="26" nowrap="nowrap" class="cabecera"><label class="label" for="txtNombre">Fecha</label></td>
										  		
						
						 <td  nowrap="nowrap">
						<input class="text required validate-date" type="text" ondblclick="this.value=''" size="8" maxlength="10" name="txtFecha" id="txtFecha" value='<?=$fecha?>'/>&nbsp;<button type="button" onclick="return false" id="btnFecha">...</button></td>
							 <script type="text/javascript">
								document.getElementById("txtFecha").disabled = false;
								Calendar.setup({
								  inputField : "txtFecha",
								  ifFormat : "%Y-%m-%d",
								  daFormat : "%Y-%m-%d",
								  button   : "btnFecha"
								});
							 </script>
							 
						
					</tr>
          			<tr>
						<td width="12%" height="26" nowrap="nowrap" class="cabecera"><label class="label" for="txtNombre">Categor&iacute;a</label></td>
									  		
						
						<td nowrap="nowrap"><label class="label" for="txtNombre">
							<select name="cboCategoria" id="cboCategoria" type="text" class="combo"/> 
								<option value="" >Seleccione </option>
									<?php foreach ($a_categorias as $key => $val){ ?>
									<option value="<?=$key?>">
									  <?=$val?>
									</option>
									<?php } ?> 
							 </select>
							 
						</td>
					</tr>
							
			
          			<tr>
						<td  height="26" nowrap="nowrap" class="cabecera"><label class="label" for="txtNombre">Prestamos</label></td>
					
						<td>
							<select name="estado" id="estado" class="combo">
							<option value="-1">Seleccione</option>
							<option value="P">Pendiente</option>
							<option value="C">Cancelado</option>
							
							
						&nbsp;<input class="button" type="button" value="Buscar" onclick="findControl();"/>
						</td>
					</tr>
					
					
				</table>
          </td>
          
        </tr>
      </table>
       
      </form>
      <div id="resultGrtid">
      </div>
    </td>
  </tr>
</table>


<?php
if(isset($insert)){
  ?>
  <script>
    elementLoad.show(undefined,"Se inserto la ficha satisfactoriamente.");
    setTimeout("elementLoad.hide()",5000);
    $('IdPrestamo').value = "<?=$id?>";
    //$('cboEstadoPrestamo').value = "<?=$cboEstadoPrestamo?>";
    //$('cboMercado').value = "<?=$cboMercado?>";
    
    
    findControl();
  </script>
  <?php
}
if(isset($update)){
  ?>
  <script>
    elementLoad.show(undefined,"Se actualizo la ficha satisfactoriamente.");
    setTimeout("elementLoad.hide()",5000);
    $('IdPrestamo').value = "<?=$id?>";
   
    findControl();
  </script>
  <?php
}
if(isset($delete)){
  ?>
  <script>
    elementLoad.show(undefined,"Se elimino la ficha satisfactoriamente.");
    setTimeout("elementLoad.hide()",5000);
    $('IdPrestamo').value = "<?=$id?>";
    
    findControl();
    
  </script>
  <?php 
  
}
?>