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
| // select les offres ligne par ligne et fait les totaux facture par facture
$select2 = $connexion->prepare("SELECT
ft.num_client,
ft.num_facture,
ft.date_facture,
ft.etat_facture,
ft.num_devis,
C.num_client,
C.nom,
C.prenom,
C.adresse1,
C.adresse2,
C.ville,
C.cp,
C.pays,
fpt.num_facture,
fpt.nombre as nb_jours,
fpt.remise_prest as pourcent_remise,
fpt.id_prest,
fpt.id_animal,
tprs.tarif_ht_prest,
tprs.id_tva,
tv.taux_tva,
@ht_av_remise := tprs.tarif_ht_prest * fpt.nombre AS ht_av_remise,
@remise := @ht_av_remise * fpt.remise_prest/100 AS remise,
@ht_apres_remise := @ht_av_remise - @remise AS ht_apres_remise,
@somme_ttc := @ht_apres_remise + @ht_apres_remise * tv.taux_tva/100 AS somme_ttc,
@tva := @somme_ttc - @ht_apres_remise AS tva
FROM facture_tab ft
LEFT JOIN clients C ON ft.num_client=C.num_client
LEFT JOIN facture_prest_tab fpt ON ft.num_facture=fpt.num_facture
LEFT JOIN prestation tprs ON fpt.ID_prest=tprs.ID_prest
LEFT JOIN tva tv ON tprs.ID_tva=tv.ID_tva
WHERE ft.date_facture>=:date1 AND ft.date_facture<=:date2
ORDER BY ft.date_facture desc
");
$select2->execute(array(
':date1'=>$date1,
':date2'=>$date2
));
$rang=$select2->fetchALL(PDO::FETCH_ASSOC) ;
$nb_rang=count($rang); |
Partager