PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/sicpri/02_prestamos/10_hoy.php

https://bitbucket.org/webdev_pe/dmejiasoft
PHP | 356 lines | 326 code | 14 blank | 16 comment | 25 complexity | 732b290d1396e92a86d321366e045862 MD5 | raw file
  1. <?php
  2. session_start();
  3. set_time_limit(0);
  4. require("../../poo/clases/getConection.php");
  5. $cn=new getConection();
  6. $cod=$_POST['cod']; $cdc=$_POST['cdc']; $nom=$_POST['nom'];
  7. $dsd=($_POST['dsd']!="")?date("Y-m-d",strtotime($_POST['dsd'])):"";
  8. $hst=($_POST['hst']!="")?date("Y-m-d",strtotime($_POST['hst'])):"";
  9. $tip=$_POST['tip']; $opr=$_POST['opr']; $otx=$_POST['otx'];
  10. $zon=$_POST['zon']; $gal=$_POST['gal']; $ztx=$_POST['ztx']; $gtx=$_POST['gtx'];
  11. $idp=$_POST['idp']; $idc=$_POST['idc'];
  12. if($cod!=""){ $add_search1=" and c.cod_pre='$cod' ";
  13. }else if($idp!=""){ $add_search1=" and c.id_pre=$idp ";
  14. }else if($idc!=""){ $add_search1=" and l.id_cli=$idc ";
  15. }else{
  16. $add_search1 =($cdc!="")?" l.cod_cli='$cdc' and ":"";
  17. $add_search1.=($nom!="")?" concat(l.nom_cli,' ',l.ape_cli) like '%$nom%' and ":"";
  18. $add_search1.=($dsd!="" && $hst=="")?" c.fecha>='$dsd' and ":"";
  19. $add_search1.=($dsd=="" && $hst!="")?" c.fecha<='$hst' and ":"";
  20. $add_search1.=($dsd!="" && $hst!="")?" c.fecha between '$dsd' and '$hst' and ":"";
  21. $add_search1.=($tip!="t" && $tip!="")?" c.tip_pre='$tip' and ":"";
  22. $add_search1.=($opr!="nn" && $opr!="")?" u.id_usu=$opr and ":"";
  23. $add_search1.=($zon!="nn" && $zon!="")?" l.id_zon=$zon and ":"";
  24. $add_search1.=($gal!="nn" && $gal!="")?" l.id_gal=$gal and ":"";
  25. $add_search1=($add_search1!="")?" and ".$add_search1:"";
  26. $lenght=strlen($add_search1);
  27. $add_search1=substr($add_search1,0,($lenght-4));
  28. }
  29. if($_SESSION['sicpri_nivel']=="SUPER ADMINISTRADOR"){
  30. $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,
  31. case c.tip_pre
  32. when 'a' then 'C/D&iacute;a'
  33. when 'p' then 'C/Mes'
  34. end as 'tipo', concat(l.nom_cli,' ',l.ape_cli) as 'nombres',
  35. case c.est_pre
  36. when 'a' then 'Vigente'
  37. when 'c' then 'Cancelado'
  38. end as 'estado', z.nom_zon, g.nom_gal, 'Cr&eacute;dito' as 'titulo'
  39. from si_prestamos c, si_clientes l, si_usuarios u, si_zonas z, si_galerias g
  40. 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'
  41. ".$add_search1."
  42. order by fecha desc, hora desc
  43. ";
  44. $stmt=$cn->ejecutar_sql(base64_encode($sql));
  45. $cn->cantidad_sql();
  46. }else if($_SESSION['sicpri_nivel']=="ADMINISTRADOR" && $add_search1!=""){
  47. $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,
  48. case c.tip_pre
  49. when 'a' then 'C/D&iacute;a'
  50. when 'p' then 'C/Mes'
  51. end as 'tipo', concat(l.nom_cli,' ',l.ape_cli) as 'nombres',
  52. case c.est_pre
  53. when 'a' then 'Vigente'
  54. when 'c' then 'Cancelado'
  55. end as 'estado', z.nom_zon, g.nom_gal, 'Cr&eacute;dito' as 'titulo'
  56. from si_prestamos c, si_clientes l, si_usuarios u, si_zonas z, si_galerias g
  57. 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'
  58. ".$add_search1."
  59. order by fecha desc, hora desc
  60. ";
  61. $stmt=$cn->ejecutar_sql(base64_encode($sql));
  62. $cn->cantidad_sql();
  63. }
  64. #echo $sql;
  65. ?>
  66. <script type="text/javascript">
  67. $(document).ready(function(){
  68. $('#list_pre').dataTable({
  69. /*"bProcessing": true,
  70. "bServerSide": true,
  71. "sAjaxSource": "content/scripts/propiedades.php",*/
  72. 'bJQueryUI': true,
  73. 'sPaginationType': 'full_numbers',
  74. 'fnDrawCallback': function(oSettings){
  75. if(oSettings.bSorted || oSettings.bFiltered){
  76. for(var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++){
  77. $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[i]].nTr).html(i+1);
  78. }
  79. }
  80. },'aoColumnDefs': [
  81. {'bSortable': false, 'aTargets': [0]},
  82. {'bSortable': false, 'aTargets': [1]},
  83. {'bSortable': false, 'aTargets': [12]},
  84. {'bSortable': false, 'aTargets': [13]},
  85. {'bSortable': false, 'aTargets': [14]},
  86. {'bSortable': false, 'aTargets': [15]}
  87. ],"bAutoWidth" : false,
  88. "bSortClasses": false,
  89. "aoColumns" : [
  90. { sWidth : '18px'},
  91. { sWidth : '18px'},
  92. { sWidth : '80px'},
  93. { sWidth : '70px'},
  94. { sWidth : '70px'},
  95. { sWidth : 'auto'},
  96. { sWidth : '90px'},
  97. { sWidth : 'auto'},
  98. { sWidth : '80px'},
  99. { sWidth : 'auto'},
  100. { sWidth : 'auto'},
  101. { sWidth : '80px'},
  102. { sWidth : '20px'},
  103. { sWidth : '20px'},{ sWidth : '20px'},
  104. { sWidth : '20px'}
  105. ],'aaSorting': [[0, 'asc']]
  106. }).columnFilter({aoColumns: [
  107. null,
  108. null,
  109. { type: "text" },
  110. { type: "text" },
  111. { type: "text" },
  112. { type: "select", values: ['DNI', 'Carnet de Extranjería', 'Otros'] },
  113. { type: "text" },
  114. { type: "text" },
  115. { type: "text" },
  116. { type: "text" },
  117. { type: "text" },
  118. { type: "text" },
  119. null,
  120. null,null,
  121. null
  122. ]
  123. });
  124. $("#todos").live("click", function(){
  125. $checkboxes=$("#list_pre tbody td").find(":checkbox");
  126. if($(this).is(":checked")){ $checkboxes.attr("checked",1); }
  127. else{ $checkboxes.removeAttr("checked");}
  128. });
  129. $("#rept").click(function(){
  130. var s=$("#s").val();
  131. var new_tab=window.open("","_blank");
  132. <?php
  133. $cod=$_POST['cod']; $cdc=$_POST['cdc']; $nom=$_POST['nom'];
  134. $dsd=($_POST['dsd']!="")?date("Y-m-d",strtotime($_POST['dsd'])):"";
  135. $hst=($_POST['hst']!="")?date("Y-m-d",strtotime($_POST['hst'])):"";
  136. $tip=$_POST['tip']; $opr=$_POST['opr']; $otx=$_POST['otx'];
  137. ?>
  138. 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)?>";
  139. });
  140. });
  141. function editar(i){
  142. $.post("sicpri/02_prestamos/02_modificar.php",{i:i},function(data){
  143. $("#contenido_sicpri").html(data);
  144. $("#sicpri_tit").empty().text("MODIFICAR PRESTAMO");
  145. });
  146. }
  147. function verificar(i){
  148. /*var new_tab=window.open("","_blank");
  149. new_tab.location="sicpri/02_prestamos/visualizar.php?i="+i;*/
  150. var width=700;
  151. var height=590;
  152. var posx=$(window).width()/2 - width/2;
  153. var posy=$(window).height()/2 - height/2;
  154. 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);
  155. window.open("sicpri/02_prestamos/visualizar.php?i="+i,"SIPC",opciones);
  156. }
  157. function verificarc(i){
  158. /*var new_tab=window.open("","_blank");
  159. new_tab.location="sicpri/02_prestamos/visualizar.php?i="+i;*/
  160. var width=700;
  161. var height=590;
  162. var posx=$(window).width()/2 - width/2;
  163. var posy=$(window).height()/2 - height/2;
  164. 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);
  165. window.open("sicpri/01_cobranzas/visualizar.php?i="+i,"SIPC",opciones);
  166. }
  167. function eliminar(i,t){
  168. var selecteds = new Array();
  169. var trs=new Array();
  170. var chekeados = $("#list_pre tbody input[@name='cods[]']:checked").size();
  171. if(chekeados>1){
  172. $("#list_pre tbody input[@name='cods[]']:checked").each(function(){
  173. selecteds.push($(this).val());
  174. });
  175. if(confirm("Esta seguro de eliminar estos "+chekeados+" registros?")){
  176. $.post("sicpri/02_prestamos/dao.php", {opt:"dm",s:selecteds}, function(data){
  177. if(data==1){
  178. for(var i=0; i<trs.length; i++){
  179. $("#"+trs[i]).remove();
  180. }
  181. /*$.post("sicpri/02_prestamos/06_historial.php",function(data){
  182. $("#contenido_sicpri").html(data);
  183. $("#sicpri_tit").empty().text("HISTORIAL DE PRESTAMOS");
  184. });*/
  185. }
  186. });
  187. }
  188. }else{
  189. if(confirm("Esta seguro de eliminar este registro?")){
  190. $.post("sicpri/02_prestamos/dao.php", {opt:"d",i:i}, function(data){
  191. if(data==1){
  192. t.parent().parent().remove();
  193. /*$.post("sicpri/02_prestamos/06_historial.php",function(data){
  194. $("#contenido_sicpri").html(data);
  195. $("#sicpri_tit").empty().text("HISTORIAL DE PRESTAMOS");
  196. });*/
  197. }
  198. });
  199. }
  200. }
  201. }
  202. </script>
  203. <script type="text/javascript">
  204. $(document).ready(function(){
  205. $("#cod_pre").autocomplete({
  206. source: "sicpri/02_prestamos/_buscar_prestamo.php",
  207. minLength: 2
  208. });
  209. $("#cod_cli").autocomplete({
  210. source: "sicpri/02_prestamos/_buscar_codigo.php",
  211. minLength: 2,
  212. select: function(event,ui){
  213. var c=ui.item.value;
  214. $("#nom_cli").val(ui.item.id);
  215. }
  216. });
  217. $("#nom_cli").autocomplete({
  218. source: "sicpri/02_prestamos/_buscar_nombre.php",
  219. minLength: 2,
  220. select: function(event,ui){
  221. var c=ui.item.id;
  222. $("#cod_cli").val(ui.item.id);
  223. }
  224. });
  225. $("#btnfind").click(function(){
  226. var cod=$("#cod_pre").val();
  227. var cdc=$("#cod_cli").val();
  228. var nom=$("#nom_cli").val();
  229. var idp=$("#idc_pre").val();
  230. var idc=$("#idc_cli").val();
  231. $.post("sicpri/02_prestamos/10_hoy.php",{cod:cod,cdc:cdc,nom:nom,r:"r",idp:idp,idc:idc},function(data){
  232. $("#contenido_sicpri").html(data);
  233. $("#sicpri_tit").empty().text("RESULTADO DE BUSQUEDA");
  234. });
  235. });
  236. });
  237. </script>
  238. <?php if($_SESSION['sicpri_nivel']=="ADMINISTRADOR"){ ?>
  239. <table width="100%" border="0" id="tbl_prp">
  240. <tr>
  241. <td colspan="2">
  242. <table width="100%" border="0">
  243. <tr>
  244. <td width="16%">ID de cr&eacute;dito<br /><input type="text" id="idc_pre" /></td>
  245. <td width="16%">C&oacute;digo de cr&eacute;dito<br /><input type="text" id="cod_pre" /></td>
  246. <td width="16%">ID de cliente<br /><input type="text" id="idc_cli" /></td>
  247. <td width="16%">C&oacute;digo de cliente<br /><input type="text" id="cod_cli" /></td>
  248. <td width="16%">Nombre de cliente<br/><input type="text" id="nom_cli" /></td>
  249. <td width="20%"><button id="btnfind" class="btn"><span class="ui-icon ui-icon-search"></span>Buscar</button></td>
  250. </tr>
  251. </table>
  252. </td>
  253. </tr>
  254. </table>
  255. <?php }?>
  256. <input type="hidden" id="s" value="<?=base64_encode(utf8_encode($sql))?>" />
  257. <button id="rept" class="btn"><span class="ui-icon ui-icon-clipboard"></span>Generar previo de resultados</button>
  258. <table id="list_pre" class="list_tbl" width="100%">
  259. <thead>
  260. <tr>
  261. <th>N&ordm;</th>
  262. <th><input type="checkbox" id="todos" /></th>
  263. <th>FECHA</th>
  264. <th>CODIGO</th>
  265. <th>CLIENTE</th>
  266. <th>NOMBRE DEL CLIENTE</th>
  267. <th>OPERADOR</th>
  268. <th>MONTO</th>
  269. <th>TIPO</th>
  270. <th>ZONA/GALER&Iacute;A</th>
  271. <th>ORIGEN</th>
  272. <th>ESTADO</th>
  273. <th title="Eliminar registro"><div class="ui-icon ui-icon-trash custom_icon"></div></th>
  274. <th title="Editar registro"><div class="ui-icon ui-icon-pencil custom_icon"></div></th>
  275. <th title="Visualizar registro de cr&eacute;dito"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
  276. <th title="Visualizar registro de cobranza"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
  277. </tr>
  278. </thead>
  279. <tbody>
  280. <?php
  281. if($stmt){
  282. while($cell=$cn->resultado_sql()){
  283. ?>
  284. <tr>
  285. <td align="center"></td>
  286. <td align="center"><input type="checkbox" name="cods[]" id="cods" value="<?=$cell['id_pre']?>" /></td>
  287. <td align="center"><?=$cell['fecha']?></td>
  288. <td align="center"><?=$cell['cod_pre']?></td>
  289. <td align="center"><?=$cell['cod_cli']?></td>
  290. <td align="center"><?=$cell['nombres']?></td>
  291. <td align="center"><?=$cell['cod_usu']?></td>
  292. <td align="right"><span>S/.</span><?=number_format($cell['mnt_pre'],2,'.',',')?></td>
  293. <td align="center"><?=$cell['tipo']?></td>
  294. <td align="left"><?=$cell['nom_zon']?>/<?=$cell['nom_gal']?></td>
  295. <td align="center"><?=$cell['titulo']?></td>
  296. <td align="center"><?=$cell['estado']?></td>
  297. <td align="center">
  298. <button id="eliminar" class="btn" onclick="eliminar('<?=$cell['id_pre']?>',$(this))" title="Eliminar registro"><span class="ui-icon ui-icon-trash"></span></button>
  299. </td>
  300. <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>
  301. <td align="center"><button id="visualizar" class="btn" onclick="verificar('<?=$cell['id_pre']?>')" title="Visualizar registro de cr&eacute;dito"><span class="ui-icon ui-icon-zoomin"></span></button></td>
  302. <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>
  303. </tr>
  304. <?php
  305. $montos+=$cell['mnt_pre'];
  306. }
  307. $cn->limpiar_sql();
  308. $cn->cerrar_sql();
  309. }
  310. ?>
  311. </tbody>
  312. <tfoot>
  313. <tr>
  314. <td colspan="7" align="left">TOTAL PRESTADO: &raquo;</td>
  315. <td align="right"><span>S/.</span><?=number_format($montos,2,'.',',')?></td>
  316. <td></td>
  317. <td></td>
  318. <td></td>
  319. <td></td>
  320. <td></td>
  321. <td></td><td></td>
  322. </tr>
  323. <tr>
  324. <th>N&ordm;</th>
  325. <th><input type="checkbox" id="todos" /></th>
  326. <th>FECHA</th>
  327. <th>CODIGO</th>
  328. <th>CLIENTE</th>
  329. <th>NOMBRE DEL CLIENTE</th>
  330. <th>OPERADOR</th>
  331. <th>MONTO</th>
  332. <th>TIPO</th>
  333. <th>ZONA/GALER&Iacute;A</th>
  334. <th>ORIGEN</th>
  335. <th>ESTADO</th>
  336. <th title="Eliminar registro"><div class="ui-icon ui-icon-trash custom_icon"></div></th>
  337. <th title="Editar registro"><div class="ui-icon ui-icon-pencil custom_icon"></div></th>
  338. <th title="Visualizar registro de cr&eacute;dito"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
  339. <th title="Visualizar registro de cobranza"><div class="ui-icon ui-icon-zoomin custom_icon"></div></th>
  340. </tr>
  341. </tfoot>
  342. </table>