PageRenderTime 33ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/sicpri/01_cobranzas/cronjob_V01.php

https://bitbucket.org/webdev_pe/dmejiasoft
PHP | 76 lines | 71 code | 2 blank | 3 comment | 3 complexity | dd3f97b075efab3b685193faf693dd6c MD5 | raw file
  1. <?php
  2. set_time_limit(0);
  3. #date_default_timezone_set("America/Lima");
  4. require("../../poo/clases/daoCobranzas.php");
  5. $cb=new daoCobranzas();
  6. $cn=new daoCobranzas();
  7. $cn1=new daoCobranzas();
  8. $cn2=new daoCobranzas();
  9. function traer_detalle($id){
  10. $td=new daoCobranzas();
  11. $sql="select cod_pre, tip_pre, mnt_pre, fra_pre, int_pre, dia_pre,
  12. (c.mnt_cli-(select sum(mnt_pre) from si_prestamos where id_cli=c.id_cli)) as 'saldo', c.cod_cli
  13. from si_prestamos p, si_clientes c where p.id_cli=c.id_cli and id_pre=".$id."";
  14. $td->ejecutar_sql(base64_encode($sql));
  15. $cel=$td->resultado_sql();
  16. $row=$td->cantidad_sql();
  17. if($cel['tip_pre']=="p"){
  18. $diario=($cel['mnt_pre']+($cel['mnt_pre']*$cel['int_pre']))/$cel['dia_pre'];
  19. $diario=number_format($diario,2,'.',',');
  20. $array['cod']=$cel['cod_pre'];
  21. $array['tip']=$cel['tip_pre'];
  22. $array['dro']=$diario;
  23. }else{
  24. $array['cod']=$cel['cod_pre'];
  25. $array['tip']=$cel['tip_pre'];
  26. $array['saldo']=$cel['saldo'];
  27. $array['monto']=$cel['mnt_pre'];
  28. $array['inter']=$cel['fra_pre'];
  29. }
  30. $td->limpiar_sql();
  31. $td->cerrar_sql();
  32. return $array;
  33. }
  34. $dias=-1;
  35. $fecha=date("Y-m-d", strtotime("$dias days"));
  36. echo "$fecha \n\n";
  37. $sql="select id_pre, cod_pre, tip_pre, fecha from si_prestamos where est_pre='a' and fecha<>'$fecha' order by id_pre desc";
  38. $cn->ejecutar_sql(base64_encode($sql));
  39. $row=$cn->cantidad_sql();
  40. if($row>0){
  41. $i=1;
  42. while($cel=$cn->resultado_sql()){
  43. $idp=$cel['id_pre'];
  44. #$sql1="select id_pre from si_cobranzas where id_pre=".$cel['id_pre']." and fecha='$fecha' and fecha<>'".$cel['fecha']."'";
  45. $sql1="select id_pre from si_cobranzas where id_pre=".$cel['id_pre']." and fecha='$fecha' and cierre not in('pa')";
  46. $cn1->ejecutar_sql(base64_encode($sql1));
  47. $row1=$cn1->cantidad_sql();
  48. if($row1<=0){
  49. echo "$i - ($idp) - ";
  50. $array=traer_detalle($idp);
  51. $dro=($array['dro']=="")?0:$array['dro'];
  52. $mnt=0;
  53. $fra=0;
  54. $dto=0;
  55. $add=0;
  56. $cie="np";
  57. $tip=$array['tip'];
  58. $mto=$array['monto'];
  59. $inr=$array['inter'];
  60. $cob="cronjob";
  61. //echo "$idp, $dro, $mnt, $fra, $dto, $add, $cie, $tip, $mto, $inr, $cob <br />";
  62. echo ($cb->guardar_cobranzas($idp, $dro, $mnt, $fra, $dto, $add, $cie, $tip, $mto, $inr, $cob, $fecha)==1)?"Cobrado":"No cobrado";
  63. echo " \n(ayer)\n";
  64. }
  65. $i++;
  66. }
  67. $cn1->limpiar_sql();
  68. $cn1->cerrar_sql();
  69. }else{
  70. $msj="Nada";
  71. }
  72. $cn->limpiar_sql();
  73. $cn->cerrar_sql();
  74. ?>