27 |
$error = 0; |
$error = 0; |
28 |
$nbcommit = 0; |
$nbcommit = 0; |
29 |
$datetime = time(); |
$datetime = time(); |
30 |
|
$space = str_repeat(" ",28); |
31 |
$user = new User($db, 1); |
$user = new User($db, 1); |
32 |
$user->login = "Rodo"; |
$user->login = "Rodo"; |
33 |
|
|
146 |
$avance = round($avance * 0.0001, 2); |
$avance = round($avance * 0.0001, 2); |
147 |
|
|
148 |
fputs($fp, "DIS : ".$obj->fk_distributeur); |
fputs($fp, "DIS : ".$obj->fk_distributeur); |
149 |
fputs($fp, " avance : $avance\n"); |
fputs($fp, " av avance po ".substr($space.$obj->rowid,-4)); |
150 |
|
fputs($fp, " : ".substr($space.$avance,-8)."\n"); |
151 |
|
|
152 |
$sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commission_avance"; |
$sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commission_avance"; |
153 |
$sqli .= " (date, fk_distributeur, fk_po,fk_contrat, montant, pourcentage, avance)"; |
$sqli .= " (date, fk_distributeur, fk_po,fk_contrat, montant, pourcentage, avance)"; |
344 |
|
|
345 |
$avan_regul[$distributeur_id] = $avan_regul[$distributeur_id] + $row[0]; |
$avan_regul[$distributeur_id] = $avan_regul[$distributeur_id] + $row[0]; |
346 |
|
|
347 |
|
fputs($fp, "DIS : ".$distributeur_id); |
348 |
|
fputs($fp, " av regul po ".substr($space.$rowa[0],-4)); |
349 |
|
fputs($fp, " : ".substr($space.$row[0],-8)."\n"); |
350 |
|
|
351 |
dolibarr_syslog("* Avance ".$row[0] . " statut : ".$row[2]); |
dolibarr_syslog("* Avance ".$row[0] . " statut : ".$row[2]); |
352 |
|
|
353 |
/* Communications relatives */ |
/* Communications relatives */ |
543 |
$amount = $amount - $avan_regul[$distributeur_id]; |
$amount = $amount - $avan_regul[$distributeur_id]; |
544 |
$amount = $amount + $comm_conso[$distributeur_id]; |
$amount = $amount + $comm_conso[$distributeur_id]; |
545 |
|
|
546 |
$space = str_repeat(" ",8); |
fputs($fp, "DIS : ".$distributeur_id); |
547 |
|
fputs($fp, " ".str_repeat("-",35)."\n"); |
548 |
|
|
549 |
fputs($fp, "DIS : ".$distributeur_id); |
fputs($fp, "DIS : ".$distributeur_id); |
550 |
fputs($fp, " Comm Regul : ".substr($space.$comm_regul[$distributeur_id],-8)."\n"); |
fputs($fp, " Comm Regul : ".substr($space.$comm_regul[$distributeur_id],-15)."\n"); |
551 |
|
|
552 |
fputs($fp, "DIS : ".$distributeur_id); |
fputs($fp, "DIS : ".$distributeur_id); |
553 |
fputs($fp, " Comm Conso : ".substr($space.$comm_conso[$distributeur_id],-8)."\n"); |
fputs($fp, " Comm Conso : ".substr($space.$comm_conso[$distributeur_id],-15)."\n"); |
554 |
|
|
555 |
|
|
556 |
/******************************************************** |
/******************************************************** |
572 |
if ($row = $db->fetch_row($resql)) |
if ($row = $db->fetch_row($resql)) |
573 |
{ |
{ |
574 |
fputs($fp, "DIS : ".$distributeur_id); |
fputs($fp, "DIS : ".$distributeur_id); |
575 |
fputs($fp, " Avances : ".substr($space.$row[0],-8)."\n"); |
fputs($fp, " Avances : ".substr($space.$row[0],-15)."\n"); |
576 |
|
|
577 |
fputs($fp, "DIS : ".$distributeur_id); |
fputs($fp, "DIS : ".$distributeur_id); |
578 |
fputs($fp, " Avan Regul : ".substr($space."-".$avan_regul[$distributeur_id],-8)."\n"); |
fputs($fp, " Avan Regul : ".substr($space."-".$avan_regul[$distributeur_id],-15)."\n"); |
579 |
|
|
580 |
$amount = $amount + $row[0]; |
$amount = $amount + $row[0]; |
581 |
|
|
582 |
$sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commission"; |
$sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commission"; |
583 |
$sqli .= " (date, fk_distributeur, montant)"; |
$sqli .= " (date, fk_distributeur, montant)"; |
584 |
$sqli .= " VALUES ('".$year.$month."'"; |
$sqli .= " VALUES ('".$year_prev.$month_prev."'"; |
585 |
$sqli .= ",".$distributeur->id; |
$sqli .= ",".$distributeur->id; |
586 |
$sqli .= ",".ereg_replace(",",".",$amount).")"; |
$sqli .= ",".ereg_replace(",",".",$amount).")"; |
587 |
|
|
594 |
dolibarr_syslog("Commission finale ".$amount); |
dolibarr_syslog("Commission finale ".$amount); |
595 |
|
|
596 |
fputs($fp, "DIS : ".$distributeur_id); |
fputs($fp, "DIS : ".$distributeur_id); |
597 |
fputs($fp, " Comm final : ".substr($space.$amount,-8)."\n"); |
fputs($fp, " Comm final : ".substr($space.$amount,-15)."\n"); |
598 |
} |
} |
599 |
else |
else |
600 |
{ |
{ |