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
| // Traitement pour sélectionner tous les projets ou est responsable la personne concernée
$sql2="SELECT Projets.RéfProjet, Projets.NomProjet, Clients.NomSociété, Projets.Détails, Projets.MontantDevis, Projets.Responsable
FROM Clients RIGHT JOIN (Projets LEFT JOIN Employés ON Projets.Responsable = Employés.CodeEmployé) ON Clients.CodeClient = Projets.CodeClient
WHERE (((Projets.MontantDevis)>0) AND ((Projets.Cloture)=0))
GROUP BY Projets.RéfProjet, Projets.NomProjet, Clients.NomSociété, Projets.Détails, Projets.MontantDevis, Projets.Responsable, Projets.Cloture
HAVING (((Projets.RéfProjet) In (SELECT RéfProjet FROM Heures)))
ORDER BY Projets.NomProjet;
";
$req2=odbc_exec($cnx,$sql2) or die('erreur sql dans : '.$sql2);
while($data_emp=odbc_fetch_array($req2))
{
$res=0;
// Traitement pour avoir le nb heures restantes sur chaque dossier !
$montant_devis=$data_emp['MontantDevis'];
// Montant Facture
$sql6="SELECT SUM([Montant Facture]) AS mt_facture FROM Paiements WHERE RéfProjet=".$data_emp['RéfProjet'];
$req6=odbc_exec($cnx,$sql6) or die ('Erreur SQL dans :'.$sql6);
$data6=odbc_fetch_array($req6);
$montant_facture=$data6['mt_facture'];
// TxFacturation
$sql3="SELECT (TauxFacturation) AS TxFacturation2 FROM Employés WHERE CodeEmployé=".$data_emp['Responsable'];
$req3=odbc_exec($cnx,$sql3) or die (' Erreur SQL dans : '.$sql3);
$data3=odbc_fetch_array($req3);
$TxFacturation=$data3['TxFacturation2'];
// Tps Passés
$sql4="SELECT SUM(HeuresAFacturer) AS tps_passes FROM Heures WHERE RéfProjet=".$data_emp['RéfProjet'];
$req4=odbc_exec($cnx,$sql4) or die (' Erreur SQL dans : '.$sql4);
$data4=odbc_fetch_array($req4);
$tps_passes=$data4['tps_passes'];
// Calcul
$res=(($montant_devis-$montant_facture)/$TxFacturation)-(($tps_passes-($montant_facture/$TxFacturation)));
$heures_realises=(($tps_passes-($montant_facture/$TxFacturation)));
$res=floor($res);
$res=$res/8; // Nb Heures/8 = 1 jour !
$montant_restant=$montant_devis-$montant_facture;
$res=number_format($res, 2, ',', ' ');
echo $data_emp['NomProjet'].'- mt_devis:'.$montant_devis.' - mt_facture'.$montant_facture.' heures réalisés:'.$heures_realises. '- res:'.$res.'<br/>';
if ($res<0)
{
switch($data_emp['Responsable'])// Responsable 24=YD 29=AT 27=RP 28=DR dans GéoCd !
{
case 24:
$responsable='YD';
break;
case 29:
$responsable='AT';
break;
case 27:
$responsable='RP';
break;
case 28:
$responsable='DR';
break;
}
$res=number_format($res, 0, ',', ' ');
echo '<li/><b/><font color="red"/>'.$data_emp['NomProjet'].'</b></font> | '.$data_emp['NomSociété'].' | '.$data_emp['Détails'].' *** <b/> + '.abs($res).'h ('.$responsable.')</b></li>';
}
} |
Partager