1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| <?php
// IMPAYER
// on selectionne par tva
$qr="select scat.scategorie,c.id,c.ordre,c.adresse,c.nom,c.ht,c.ville,c.FORMAT,c.numfact,c.montant_lettre,c.acompte1,c.idannee,c.ht,c.tva_client,c.ajustement,c.cp,c.date_finalpub,c.idcat,c.tva_assujeti,c.idscat, scat.idscat,scat.monaie,scat.monaie,scat.codif from lieu c, scategorie scat where c.idscat=scat.idscat GROUP BY scat.scategorie ORDER BY c.tva_client,c.idscat ASC ";
$resup=execute_sql($qr);
$compte_existant=mysql_num_rows($resup);
//group by scat.scategorie
while($row=mysql_fetch_array($resup)){
$ordre=$row['ordre'];
$adresse=$row["adresse"];
$idmodif=$row["id"];
$nom=$row["nom"];
$montant_ht=$row["ht"];
$ville1=$row["ville"];
$format=$row['FORMAT'];
$numfact=$row['numfact'];
$montant_lettre=$row['montant_lettre'];
$montant_ht=virgule($row['ht']);
$ajustement=$row['ajustement'];
$cp=$row['cp'];
$tva_client=$row['tva_client'];
$date_finalpub=$row['date_finalpub'];
$idcollaborateur=$row['idcollaborateur'];
$idsupport=$row['idcat'];
$tva_assujeti=$row['tva_assujeti'];
$idscat=$row['idscat'];
$courtier=$row['categorie'];
$mot=$row['scategorie'];
$monaie=$row['monaie'];
$codif=$row['codif'];
$tva=$tva_client;
// MONTANT TTC AVEC AJUSTEMENT
$montant_htaju=$montant_ht+$ajustement;
$montant_htaju1=$montant_htaju*$tva;
$montant_htaju2=$montant_htaju1/100;
$montant_htaju3=virgule_simple($montant_htaju2+$montant_htaju);
$montant_htaju4=virgule($montant_htaju3);
// ON RECUPERE VERSEMENT idmodif=idclient ou idcontrat
$q="select sum(montant) as masomme from banques where idcontrat='$idmodif' and idscat='$idscat' ";
$req=execute_sql($q);
echo "$q<br>";
$compte_banque=mysql_num_rows($req);
$detail=mysql_fetch_assoc($req);
// SI 0 VERSEMENT
if($compte_banque=="0"){
$montant_versement="0.00";
}
// ET SI VERSEMENT
else{
// MONTANT ENREGISTRER
$montant_versement=virgule($detail['masomme']);
}
// ON VERIFI SI LE versement ttc est inferieur au montant ttc demandé et affiche que les impayés
if($montant_versement<$montant_htaju4){
$du1=virgule($montant_htaju4-$montant_versement);
//DU HT
$duht=virgule($du1-$montant_htaju2);
// ON AFFICHE LE SCATEGORIE j'ai mis mot pensant faire un explode() et array_unique() mais fonctionne pas. normale je suis dans le while donc quoi qu'il arrive je ne vois pas
// COMMENT classer par tva et par scategorie les client relié a scategorie
echo $mot;
echo "<table border=1 width=80% cellspacing=0 cellpadding=0><tr><td width=10% valign=\"middle\">n° <B>$ordre</b><br>$codif</td><td width=40% valign=\"middle\"><a href=index.php?pages=modif_lieu2&idmodif=$idmodif class=\"info\">$nom<span>
Detaille du contrat:<br><font size=1 color=#3E92F2><br>Montant HT:<b>$montant_ht</b><br>Montant TTC : <b>$montant_htaju4</b> <br>Montant Versé : <b>$montant_versement</b><BR>T.V.A : $tva_client</font></span></a><br>(T.V.A : $tva_client)</td><td>$datedesfinpub</b></td><td valign=\"middle\"> - <font color=#ff0000>Doit H.T :$duht </font> </b> - <font color=#ff0000>doit : $du1 <b>$monaie T.T.C</font></td></tr></table>";
$tableht0[] = $du1;
// on détermine ici un tableau, mais il peux s'agir de valeur en BdD ça fonctionnerais pareil
$count_monaiedu1 = 0; // on initialise $count_monaie à 0, afin d'être sur de ne pas fausser le resultat
foreach ($tableht0 as $cht1){ // on lance la boucle
$count_monaiedu1=$cht1+$count_monaiedu1;
}
// FIN BOUCLE
} // SI MONTANT VERSER EST INFERIEUR
// ON AFFICHE LE MONTANT QUE LE CLIENT DOIT En ttc TTC selon la liste client de la scategorie classé par tva
echo $cout_monaiedu1
} // FIN DU while debut
?> |
Partager