/sicpri/02_prestamos/10_hoy.php
PHP | 356 lines | 326 code | 14 blank | 16 comment | 25 complexity | 732b290d1396e92a86d321366e045862 MD5 | raw file
- <?php
- session_start();
- set_time_limit(0);
- require("../../poo/clases/getConection.php");
- $cn=new getConection();
- $cod=$_POST['cod']; $cdc=$_POST['cdc']; $nom=$_POST['nom'];
- $dsd=($_POST['dsd']!="")?date("Y-m-d",strtotime($_POST['dsd'])):"";
- $hst=($_POST['hst']!="")?date("Y-m-d",strtotime($_POST['hst'])):"";
- $tip=$_POST['tip']; $opr=$_POST['opr']; $otx=$_POST['otx'];
- $zon=$_POST['zon']; $gal=$_POST['gal']; $ztx=$_POST['ztx']; $gtx=$_POST['gtx'];
- $idp=$_POST['idp']; $idc=$_POST['idc'];
- if($cod!=""){ $add_search1=" and c.cod_pre='$cod' ";
- }else if($idp!=""){ $add_search1=" and c.id_pre=$idp ";
- }else if($idc!=""){ $add_search1=" and l.id_cli=$idc ";
- }else{
- $add_search1 =($cdc!="")?" l.cod_cli='$cdc' and ":"";
- $add_search1.=($nom!="")?" concat(l.nom_cli,' ',l.ape_cli) like '%$nom%' and ":"";
- $add_search1.=($dsd!="" && $hst=="")?" c.fecha>='$dsd' and ":"";
- $add_search1.=($dsd=="" && $hst!="")?" c.fecha<='$hst' and ":"";
- $add_search1.=($dsd!="" && $hst!="")?" c.fecha between '$dsd' and '$hst' and ":"";
- $add_search1.=($tip!="t" && $tip!="")?" c.tip_pre='$tip' and ":"";
- $add_search1.=($opr!="nn" && $opr!="")?" u.id_usu=$opr and ":"";
- $add_search1.=($zon!="nn" && $zon!="")?" l.id_zon=$zon and ":"";
- $add_search1.=($gal!="nn" && $gal!="")?" l.id_gal=$gal and ":"";
- $add_search1=($add_search1!="")?" and ".$add_search1:"";
- $lenght=strlen($add_search1);
- $add_search1=substr($add_search1,0,($lenght-4));
- }
- if($_SESSION['sicpri_nivel']=="SUPER ADMINISTRADOR"){
- $sql="select c.id_pre, date_format(c.fecha,'%d-%m-%Y') as 'fecha', c.hora, c.cod_pre, l.cod_cli, u.cod_usu, c.mnt_pre,
- case c.tip_pre
- when 'a' then 'C/Día'
- when 'p' then 'C/Mes'
- end as 'tipo', concat(l.nom_cli,' ',l.ape_cli) as 'nombres',
- case c.est_pre
- when 'a' then 'Vigente'
- when 'c' then 'Cancelado'
- end as 'estado', z.nom_zon, g.nom_gal, 'Crédito' as 'titulo'
- from si_prestamos c, si_clientes l, si_usuarios u, si_zonas z, si_galerias g
- where c.id_cli=l.id_cli and c.id_usu=u.id_usu and l.id_zon=z.id_zon and l.id_gal=g.id_gal and moroso='m' and est_pre='a'
- ".$add_search1."
- order by fecha desc, hora desc
- ";
- $stmt=$cn->ejecutar_sql(base64_encode($sql));
- $cn->cantidad_sql();
- }else if($_SESSION['sicpri_nivel']=="ADMINISTRADOR" && $add_search1!=""){
- $sql="select c.id_pre, date_format(c.fecha,'%d-%m-%Y') as 'fecha', c.hora, c.cod_pre, l.cod_cli, u.cod_usu, c.mnt_pre,
- case c.tip_pre
- when 'a' then 'C/Día'
- when 'p' then 'C/Mes'
- end as 'tipo', concat(l.nom_cli,' ',l.ape_cli) as 'nombres',
- case c.est_pre
- when 'a' then 'Vigente'
- when 'c' then 'Cancelado'
- end as 'estado', z.nom_zon, g.nom_gal, 'Crédito' as 'titulo'
- from si_prestamos c, si_clientes l, si_usuarios u, si_zonas z, si_galerias g
- where c.id_cli=l.id_cli and c.id_usu=u.id_usu and l.id_zon=z.id_zon and l.id_gal=g.id_gal and moroso='m' and est_pre='a'
- ".$add_search1."
- order by fecha desc, hora desc
- ";
- $stmt=$cn->ejecutar_sql(base64_encode($sql));
- $cn->cantidad_sql();
- }
- #echo $sql;
- ?>
- <script type="text/javascript">
- $(document).ready(function(){
- $('#list_pre').dataTable({
- /*"bProcessing": true,
- "bServerSide": true,
- "sAjaxSource": "content/scripts/propiedades.php",*/
- 'bJQueryUI': true,
- 'sPaginationType': 'full_numbers',
- 'fnDrawCallback': function(oSettings){
- if(oSettings.bSorted || oSettings.bFiltered){
- for(var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++){
- $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[i]].nTr).html(i+1);
- }
- }
- },'aoColumnDefs': [
- {'bSortable': false, 'aTargets': [0]},
- {'bSortable': false, 'aTargets': [1]},
- {'bSortable': false, 'aTargets': [12]},
- {'bSortable': false, 'aTargets': [13]},
- {'bSortable': false, 'aTargets': [14]},
- {'bSortable': false, 'aTargets': [15]}
- ],"bAutoWidth" : false,
- "bSortClasses": false,
- "aoColumns" : [
- { sWidth : '18px'},
- { sWidth : '18px'},
- { sWidth : '80px'},
- { sWidth : '70px'},
- { sWidth : '70px'},
- { sWidth : 'auto'},
- { sWidth : '90px'},
- { sWidth : 'auto'},
- { sWidth : '80px'},
- { sWidth : 'auto'},
- { sWidth : 'auto'},
- { sWidth : '80px'},
- { sWidth : '20px'},
- { sWidth : '20px'},{ sWidth : '20px'},
- { sWidth : '20px'}
- ],'aaSorting': [[0, 'asc']]
- }).columnFilter({aoColumns: [
- null,
- null,
- { type: "text" },
- { type: "text" },
- { type: "text" },
- { type: "select", values: ['DNI', 'Carnet de ExtranjerÃa', 'Otros'] },
- { type: "text" },
- { type: "text" },
- { type: "text" },
- { type: "text" },
- { type: "text" },
- { type: "text" },
- null,
- null,null,
- null
- ]
- });
-
- $("#todos").live("click", function(){
- $checkboxes=$("#list_pre tbody td").find(":checkbox");
- if($(this).is(":checked")){ $checkboxes.attr("checked",1); }
- else{ $checkboxes.removeAttr("checked");}
- });
-
- $("#rept").click(function(){
- var s=$("#s").val();
- var new_tab=window.open("","_blank");
- <?php
- $cod=$_POST['cod']; $cdc=$_POST['cdc']; $nom=$_POST['nom'];
- $dsd=($_POST['dsd']!="")?date("Y-m-d",strtotime($_POST['dsd'])):"";
- $hst=($_POST['hst']!="")?date("Y-m-d",strtotime($_POST['hst'])):"";
- $tip=$_POST['tip']; $opr=$_POST['opr']; $otx=$_POST['otx'];
- ?>
- new_tab.location="sicpri/02_prestamos/reporte.php?s="+s+"&cp=<?=base64_encode($cod)?>&cc=<?=base64_encode($cdc)?>&nc=<?=base64_encode($nom)?>&fd=<?=base64_encode($dsd)?>&fh=<?=base64_encode($hst)?>&tp=<?=base64_encode($tip)?>&op=<?=base64_encode($otx)?>&zn=<?=base64_encode($ztx)?>&gl=<?=base64_encode($gtx)?>";
- });
- });
- function editar(i){
- $.post("sicpri/02_prestamos/02_modificar.php",{i:i},function(data){
- $("#contenido_sicpri").html(data);
- $("#sicpri_tit").empty().text("MODIFICAR PRESTAMO");
- });
- }
- function verificar(i){
- /*var new_tab=window.open("","_blank");
- new_tab.location="sicpri/02_prestamos/visualizar.php?i="+i;*/
- var width=700;
- var height=590;
- var posx=$(window).width()/2 - width/2;
- var posy=$(window).height()/2 - height/2;
- var opciones=("toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, fullscreen=no, width="+width+", height="+height+", top="+posy+", left="+posx);
- window.open("sicpri/02_prestamos/visualizar.php?i="+i,"SIPC",opciones);
- }
-
- function verificarc(i){
- /*var new_tab=window.open("","_blank");
- new_tab.location="sicpri/02_prestamos/visualizar.php?i="+i;*/
- var width=700;
- var height=590;
- var posx=$(window).width()/2 - width/2;
- var posy=$(window).height()/2 - height/2;
- var opciones=("toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, fullscreen=no, width="+width+", height="+height+", top="+posy+", left="+posx);
- window.open("sicpri/01_cobranzas/visualizar.php?i="+i,"SIPC",opciones);
- }
-
- function eliminar(i,t){
- var selecteds = new Array();
- var trs=new Array();
- var chekeados = $("#list_pre tbody input[@name='cods[]']:checked").size();
- if(chekeados>1){
- $("#list_pre tbody input[@name='cods[]']:checked").each(function(){
- selecteds.push($(this).val());
- });
- if(confirm("Esta seguro de eliminar estos "+chekeados+" registros?")){
- $.post("sicpri/02_prestamos/dao.php", {opt:"dm",s:selecteds}, function(data){
- if(data==1){
- for(var i=0; i<trs.length; i++){
- $("#"+trs[i]).remove();
- }
- /*$.post("sicpri/02_prestamos/06_historial.php",function(data){
- $("#contenido_sicpri").html(data);
- $("#sicpri_tit").empty().text("HISTORIAL DE PRESTAMOS");
- });*/
- }
- });
- }
- }else{
- if(confirm("Esta seguro de eliminar este registro?")){
- $.post("sicpri/02_prestamos/dao.php", {opt:"d",i:i}, function(data){
- if(data==1){
- t.parent().parent().remove();
- /*$.post("sicpri/02_prestamos/06_historial.php",function(data){
- $("#contenido_sicpri").html(data);
- $("#sicpri_tit").empty().text("HISTORIAL DE PRESTAMOS");
- });*/
- }
- });
- }
- }
- }
- </script>
- <script type="text/javascript">
- $(document).ready(function(){
- $("#cod_pre").autocomplete({
- source: "sicpri/02_prestamos/_buscar_prestamo.php",
- minLength: 2
- });
-
- $("#cod_cli").autocomplete({
- source: "sicpri/02_prestamos/_buscar_codigo.php",
- minLength: 2,
- select: function(event,ui){
- var c=ui.item.value;
- $("#nom_cli").val(ui.item.id);
- }
- });
-
- $("#nom_cli").autocomplete({
- source: "sicpri/02_prestamos/_buscar_nombre.php",
- minLength: 2,
- select: function(event,ui){
- var c=ui.item.id;
- $("#cod_cli").val(ui.item.id);
- }
- });
- $("#btnfind").click(function(){
- var cod=$("#cod_pre").val();
- var cdc=$("#cod_cli").val();
- var nom=$("#nom_cli").val();
- var idp=$("#idc_pre").val();
- var idc=$("#idc_cli").val();
-
- $.post("sicpri/02_prestamos/10_hoy.php",{cod:cod,cdc:cdc,nom:nom,r:"r",idp:idp,idc:idc},function(data){
- $("#contenido_sicpri").html(data);
- $("#sicpri_tit").empty().text("RESULTADO DE BUSQUEDA");
- });
- });
- });
- </script>
- <?php if($_SESSION['sicpri_nivel']=="ADMINISTRADOR"){ ?>
- <table width="100%" border="0" id="tbl_prp">
- <tr>
- <td colspan="2">
- <table width="100%" border="0">
- <tr>
- <td width="16%">ID de crédito<br /><input type="text" id="idc_pre" /></td>
- <td width="16%">Código de crédito<br /><input type="text" id="cod_pre" /></td>
- <td width="16%">ID de cliente<br /><input type="text" id="idc_cli" /></td>
- <td width="16%">Código de cliente<br /><input type="text" id="cod_cli" /></td>
- <td width="16%">Nombre de cliente<br/><input type="text" id="nom_cli" /></td>
- <td width="20%"><button id="btnfind" class="btn"><span class="ui-icon ui-icon-search"></span>Buscar</button></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <?php }?>
- <input type="hidden" id="s" value="<?=base64_encode(utf8_encode($sql))?>" />
- <button id="rept" class="btn"><span class="ui-icon ui-icon-clipboard"></span>Generar previo de resultados</button>
- <table id="list_pre" class="list_tbl" width="100%">
- <thead>
- <tr>
- <th>Nº</th>
- <th><input type="checkbox" id="todos" /></th>
- <th>FECHA</th>
- <th>CODIGO</th>
- <th>CLIENTE</th>
- <th>NOMBRE DEL CLIENTE</th>
- <th>OPERADOR</th>
- <th>MONTO</th>
- <th>TIPO</th>
- <th>ZONA/GALERÍA</th>
- <th>ORIGEN</th>
- <th>ESTADO</th>
- <th title="Eliminar registro"><div class="ui-icon ui-icon-trash custom_icon"></div></th>
- <th title="Editar registro"><div class="ui-icon ui-icon-pencil custom_icon"></div></th>
- <th title="Visualizar registro de crédito"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
- <th title="Visualizar registro de cobranza"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
- </tr>
- </thead>
- <tbody>
- <?php
- if($stmt){
- while($cell=$cn->resultado_sql()){
- ?>
- <tr>
- <td align="center"></td>
- <td align="center"><input type="checkbox" name="cods[]" id="cods" value="<?=$cell['id_pre']?>" /></td>
-
- <td align="center"><?=$cell['fecha']?></td>
- <td align="center"><?=$cell['cod_pre']?></td>
- <td align="center"><?=$cell['cod_cli']?></td>
- <td align="center"><?=$cell['nombres']?></td>
- <td align="center"><?=$cell['cod_usu']?></td>
- <td align="right"><span>S/.</span><?=number_format($cell['mnt_pre'],2,'.',',')?></td>
- <td align="center"><?=$cell['tipo']?></td>
- <td align="left"><?=$cell['nom_zon']?>/<?=$cell['nom_gal']?></td>
- <td align="center"><?=$cell['titulo']?></td>
- <td align="center"><?=$cell['estado']?></td>
- <td align="center">
- <button id="eliminar" class="btn" onclick="eliminar('<?=$cell['id_pre']?>',$(this))" title="Eliminar registro"><span class="ui-icon ui-icon-trash"></span></button>
- </td>
- <td align="center"><button id="editar" class="btn" onclick="editar('<?=$cell['id_pre']?>')" title="Modificar registro"><span class="ui-icon ui-icon-pencil"></span></button></td>
- <td align="center"><button id="visualizar" class="btn" onclick="verificar('<?=$cell['id_pre']?>')" title="Visualizar registro de crédito"><span class="ui-icon ui-icon-zoomin"></span></button></td>
- <td align="center"><button id="visualizar" class="btn" onclick="verificarc('<?=$cell['id_pre']?>')" title="Visualizar registro de cobranza"><span class="ui-icon ui-icon-zoomin"></span></button></td>
- </tr>
- <?php
- $montos+=$cell['mnt_pre'];
- }
- $cn->limpiar_sql();
- $cn->cerrar_sql();
- }
- ?>
- </tbody>
- <tfoot>
- <tr>
- <td colspan="7" align="left">TOTAL PRESTADO: »</td>
- <td align="right"><span>S/.</span><?=number_format($montos,2,'.',',')?></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td><td></td>
- </tr>
- <tr>
- <th>Nº</th>
- <th><input type="checkbox" id="todos" /></th>
- <th>FECHA</th>
- <th>CODIGO</th>
- <th>CLIENTE</th>
- <th>NOMBRE DEL CLIENTE</th>
- <th>OPERADOR</th>
- <th>MONTO</th>
- <th>TIPO</th>
- <th>ZONA/GALERÍA</th>
- <th>ORIGEN</th>
- <th>ESTADO</th>
- <th title="Eliminar registro"><div class="ui-icon ui-icon-trash custom_icon"></div></th>
- <th title="Editar registro"><div class="ui-icon ui-icon-pencil custom_icon"></div></th>
- <th title="Visualizar registro de crédito"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
- <th title="Visualizar registro de cobranza"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
- </tr>
- </tfoot>
- </table>