|
Server IP : 10.128.40.6 / Your IP : 216.73.216.233 Web Server : Apache System : Linux webd006.cluster128.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : logmcpe ( 111175) PHP Version : 7.3.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/logmcpe/www/mcg/pages/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$headers = "From:logmcpe";
$headers .= "MIME-version: 1.0\n";
$headers .= "Content-type: text/html; charset= UTF-8\n";
echo "<pre>" ;
print_r($_POST) ;
echo "</pre>" ;
$tab['ton_infos'] = "ddd" ;
$contenu = '<table border="1">';
// $rq = mysql_query("TA REQUETTE");
// while($tab = mysql_fetch_array($rq)){
$contenu .= '<tr><td> Numéro </td> <td> Date facture</td> <td> Montant </td> <td> Net à payer</td> <td> Echéance</td></tr>';
// $contenu .= '<tr><td>'.$tab['ton_infos'].'</td></tr>';
// }
// echo "test" ;
$cmp = 0 ;
$somme = 0 ;
$numfact ="" ;
foreach ($_POST['num_fact'] as $key => $num_fact) {
// $arr[3] sera mis à jour avec chaque valeur de $arr...
echo "{$key} => {$num_fact} ";
$numfact .=" - $num_fact " ;
list($total,$date_fact,$client_id ,$date_fact_plus_huit) = dbi_fetch_row(dbi_query("SELECT total , date_fact , f.client_id , DATE_ADD(STR_TO_DATE(date_fact, '%Y%m%d'), INTERVAL 8 DAY ) as date_fact_plus_huit FROM `facture` f , client c WHERE f.client_id = c.client_id and `num_fact` = $num_fact")) ;
$query2 = "SELECT
total-if(p.paye is null, 0, p.paye)-if(a.avoir is null, 0, a.avoir) AS paye,
if(a.avoir is null, 0, a.avoir) avoir,
f.date_fact, if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) >= total, 'Réglé', if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) = 0, 'Pas de règlement', 'Règlement partiel')) statut,
f.relance
FROM ".TABLE_FACT." f
LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) paye, fact_id FROM ".TABLE_PAIEMENT." where client_id = $client_id group by fact_id) p ON f.fact_id = p.fact_id
LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) avoir, fact_id FROM ".TABLE_AVOIR." group by fact_id) a ON f.fact_id = a.fact_id
WHERE f.client_id=$client_id
AND f.agence_id=$agence
AND if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) < total AND num_fact = $num_fact
" ;
list($paye)=dbi_fetch_row(dbi_query($query2)) ;
$date_fact_plus_huit=int2date(date2int_DSI($date_fact_plus_huit)) ;
$contenu .= '<tr><td> '.$num_fact.' </td> <td> '.int2date($date_fact).'</td> <td> '.$total.' </td> <td> '.$paye.'</td> <td> '.$date_fact_plus_huit.'</td></tr>';
$cmp ++ ;
$somme = $somme + $paye ;
}
$contenu .= '</table>';
// the message
if($cmp ==1)
{
$chaine_fact= "la facture" ;
}else
{
$chaine_fact= "les factures" ;
}
$msg = "Bonjour,<br/><br/>
L’examen de votre compte dans notre comptabilité fait apparaître qu’à ce jour, sauf erreur ou omission de notre part, ".$chaine_fact." ci-dessous, pour un montant de $somme €, reste impayée :
<br/><br/>".$contenu." <br/>
Nous vous remercions de bien vouloir régulariser votre situation dans les meilleurs délais.
Certains qu’il s’agit d’un oubli de votre part, nous vous remercions par avance.
<br/><br/>
Cordialement,
<br/> <br/><br/>
Tiffany MAZELLA <br/>
Service comptabilité et recouvrement";
// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
// mail("info@mc-pro.fr","Relance 1",$msg);
mail("info@mc-pro.fr","Relance 1",$msg ,$headers);
mail("dsi.pro2000@gmail.com","Relance 1",$msg ,$headers);
$date_relance = date('Ymd');
dbi_query("INSERT INTO `histo_relance` (`id_r`, `numfact`, `date_relance`, `type_relance`, `montant` , `client_id`) VALUES (NULL, '$numfact', '$date_relance', '1', '$somme' , '$client_id')") ;
header('Location:cRvouvrement.php?msg= Relance bien envoyé&color=success');
?>
