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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
<?
include("fonction.php");
$db=connexion();
$numdmd=$_POST['numdmd'];
$res=mysql_query("SELECT Numdmd,Nummat,jourenleve,heure_enleve,jour_retour,heure_retour,nb_jour,qte,obs,paiement,facture FROM correspondre WHERE Numdmd='$numdmd' HAVING Nummat=MIN(Nummat);", $db);
list($numdmd,$nummat,$jenlev,$henlev,$jret,$hret,$nbjour,$qte,$obs,$paie,$fact)=mysql_fetch_row($res);
$res2=mysql_query("SELECT numloc,designation,tarif,Unit FROM materiel WHERE numloc='$nummat';", $db);
list($numloc,$design,$tarif,$unit)=mysql_fetch_row($res2);
$res3=mysql_query("SELECT Numerodemande,datedmd,numcli FROM demande WHERE Numerodemande='$numdmd';", $db);
list($numdmd2,$datedmd,$numcli)=mysql_fetch_row($res3);
$res4=mysql_query("SELECT numcli,nom, prenom,raison_sociale,Adresse,Codepostal,Ville FROM client WHERE numcli='$numcli';", $db);
list($numcli2,$nom,$prenom,$rs,$ad,$cp,$vil)=mysql_fetch_row($res4);
$urlDoc="location.rtf";
//$urlDoc="./tests/docu.rtf";
$docWord=file_get_contents($urlDoc);
$var1="codef";
$var2="jenlev";
$var3="henlev";
$var4="jret";
$vara="hret";
$var5="nbjour";
$var6="qte";
$var7="obsf" ;
$var8="paie";
$var9="factuf";
$var10="design";
$var11="tarif";
$var12="unit";
$var13="tot";
$var14="datedmd";
$var15="nomf";
$var16="prenf";
$var17="rsf";
$var18="adressef";
$var19="cpf";
$var20="villef";
if($fact=1){
$fact="A PAYER";
}
else{
$fact="GRATUIT";
}
$docWord2 = str_replace($var1, $nummat, $docWord);
$docWord2 = str_replace($var2, $jenlev, $docWord2);
$docWord2 = str_replace($var3, $henlev, $docWord2);
$docWord2 = str_replace($var4, $jret, $docWord2);
$docWord2 = str_replace($vara, $hret, $docWord2);
$docWord2 = str_replace($var5, $nbjour, $docWord2);
$docWord2 = str_replace($var6, $qte, $docWord2);
$docWord2 = str_replace($var7, $obs, $docWord2);
$docWord2 = str_replace($var8, $paie, $docWord2);
$docWord2 = str_replace($var9, $fact, $docWord2);
$docWord2 = str_replace($var10, $design, $docWord2);
$docWord2 = str_replace($var11, $tarif, $docWord2);
$docWord2 = str_replace($var12, $unit, $docWord2);
$total= $tarif*$qte*$nbjour;
$docWord2 = str_replace($var13, $total, $docWord2);
$docWord2 = str_replace($var14, $datedmd, $docWord2);
$docWord2 = str_replace($var15, $nom, $docWord2);
$docWord2 = str_replace($var16, $prenom, $docWord2);
$docWord2 = str_replace($var17, $rs, $docWord2);
$docWord2 = str_replace($var18, $ad, $docWord2);
$docWord2 = str_replace($var19, $cp, $docWord2);
$docWord2 = str_replace($var20, $vil, $docWord2);
$totfin=$total;
$res5=mysql_query("SELECT Numdmd,Nummat,jourenleve,heure_enleve,jour_retour,heure_retour,nb_jour,qte,obs,paiement,facture FROM correspondre WHERE Numdmd='$numdmd' AND Nummat >'$nummat' ;", $db);
while(list($numdmd3,$nummat2,$jenlev2,$henlev2,$jret2,$hret2,$nbjour2,$qte2,$obs2,$paie2,$fact2)=mysql_fetch_row($res5)){
$temp=$nummat2;
$res6=mysql_query("SELECT numloc,designation,tarif,Unit FROM materiel WHERE numloc='$nummat2';", $db);
while(list($numloc3,$design3,$tarif3,$unit3)=mysql_fetch_row($res6)){
if($temp=$nummat2){
$var21="autcode";
$var22="autdes" ;
$var23="autu";
$var24="autq";
$var25="autp";
$var26="autnb";
$var27="autto";
}
else{
$var21="co";
$var22="ds";
$var23="uu";
$var24="qt";
$var25="pp";
$var26="nn";
$var27="ti";
}
$tot2=$tarif3*$qte2*$nbjour2;
$docWord2 = str_replace($var21, $numloc3, $docWord2);
$docWord2 = str_replace($var22, $design3, $docWord2);
$docWord2 = str_replace($var23, $unit3, $docWord2);
$docWord2 = str_replace($var24, $qte2, $docWord2);
$docWord2 = str_replace($var25, $tarif3, $docWord2);
$docWord2 = str_replace($var26, $nbjour2, $docWord2);
$docWord2 = str_replace($var27, $tot2, $docWord2);
$nummat=$nummat2;
}
}
$totfin=$totfin+$tot2;
$var28="finalto";
$docWord2 = str_replace($var28, $totfin, $docWord2);
$file_type = "msword";
$file_ending = "doc";
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=database_dump.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
echo $docWord2;
?>[ |
Partager