PageRenderTime 33ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/sicpri/02_prestamos/000_07_cancelados.php

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