/sicpri/01_cobranzas/cronjob_V01.php
PHP | 76 lines | 71 code | 2 blank | 3 comment | 3 complexity | dd3f97b075efab3b685193faf693dd6c MD5 | raw file
- <?php
- set_time_limit(0);
- #date_default_timezone_set("America/Lima");
- require("../../poo/clases/daoCobranzas.php");
- $cb=new daoCobranzas();
- $cn=new daoCobranzas();
- $cn1=new daoCobranzas();
- $cn2=new daoCobranzas();
- function traer_detalle($id){
- $td=new daoCobranzas();
- $sql="select cod_pre, tip_pre, mnt_pre, fra_pre, int_pre, dia_pre,
- (c.mnt_cli-(select sum(mnt_pre) from si_prestamos where id_cli=c.id_cli)) as 'saldo', c.cod_cli
- from si_prestamos p, si_clientes c where p.id_cli=c.id_cli and id_pre=".$id."";
- $td->ejecutar_sql(base64_encode($sql));
- $cel=$td->resultado_sql();
- $row=$td->cantidad_sql();
- if($cel['tip_pre']=="p"){
- $diario=($cel['mnt_pre']+($cel['mnt_pre']*$cel['int_pre']))/$cel['dia_pre'];
- $diario=number_format($diario,2,'.',',');
- $array['cod']=$cel['cod_pre'];
- $array['tip']=$cel['tip_pre'];
- $array['dro']=$diario;
- }else{
- $array['cod']=$cel['cod_pre'];
- $array['tip']=$cel['tip_pre'];
- $array['saldo']=$cel['saldo'];
- $array['monto']=$cel['mnt_pre'];
- $array['inter']=$cel['fra_pre'];
- }
- $td->limpiar_sql();
- $td->cerrar_sql();
- return $array;
- }
- $dias=-1;
- $fecha=date("Y-m-d", strtotime("$dias days"));
- echo "$fecha \n\n";
- $sql="select id_pre, cod_pre, tip_pre, fecha from si_prestamos where est_pre='a' and fecha<>'$fecha' order by id_pre desc";
- $cn->ejecutar_sql(base64_encode($sql));
- $row=$cn->cantidad_sql();
- if($row>0){
- $i=1;
- while($cel=$cn->resultado_sql()){
- $idp=$cel['id_pre'];
- #$sql1="select id_pre from si_cobranzas where id_pre=".$cel['id_pre']." and fecha='$fecha' and fecha<>'".$cel['fecha']."'";
- $sql1="select id_pre from si_cobranzas where id_pre=".$cel['id_pre']." and fecha='$fecha' and cierre not in('pa')";
- $cn1->ejecutar_sql(base64_encode($sql1));
- $row1=$cn1->cantidad_sql();
- if($row1<=0){
- echo "$i - ($idp) - ";
- $array=traer_detalle($idp);
- $dro=($array['dro']=="")?0:$array['dro'];
- $mnt=0;
- $fra=0;
- $dto=0;
- $add=0;
- $cie="np";
- $tip=$array['tip'];
- $mto=$array['monto'];
- $inr=$array['inter'];
- $cob="cronjob";
- //echo "$idp, $dro, $mnt, $fra, $dto, $add, $cie, $tip, $mto, $inr, $cob <br />";
- echo ($cb->guardar_cobranzas($idp, $dro, $mnt, $fra, $dto, $add, $cie, $tip, $mto, $inr, $cob, $fecha)==1)?"Cobrado":"No cobrado";
- echo " \n(ayer)\n";
- }
- $i++;
- }
- $cn1->limpiar_sql();
- $cn1->cerrar_sql();
- }else{
- $msj="Nada";
- }
- $cn->limpiar_sql();
- $cn->cerrar_sql();
- ?>