226 lines
5.6 KiB
PHP
Executable File
226 lines
5.6 KiB
PHP
Executable File
<?php
|
|
session_start();
|
|
$idcmde=$HTTP_GET_VARS["idcmde"];
|
|
?>
|
|
|
|
<html>
|
|
<head>
|
|
<link href="../style.css" rel="stylesheet" type="text/css">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
|
|
<!--
|
|
a:link {
|
|
color: #FFFFFF;
|
|
text-decoration: none;
|
|
}
|
|
a:visited {
|
|
color: #FFFFFF;
|
|
text-decoration: none;
|
|
}
|
|
a:hover {
|
|
color: #FFFFFF;
|
|
text-decoration: underline;
|
|
}
|
|
a:active {
|
|
color: #FFFFFF;
|
|
text-decoration: none;
|
|
}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body class="bgcolor" text="white">
|
|
<?php
|
|
|
|
require("../connexion.php");
|
|
$conn = mysql_connect($host, $user, $password);
|
|
mysql_select_db($bdd) or die("IMpossible d'ouvrir la base de donnee $bdd");
|
|
|
|
print "commande validee<br>";
|
|
|
|
// récupération des informations du client
|
|
|
|
$reqcli = "select idcli,edu from commande where idcmde='$idcmde'";
|
|
$result1=mysql_query($reqcli) or die ("Erreur SQL :$reqcli<br>".mysql_error()."...");
|
|
|
|
while ($ligne1 = mysql_fetch_row($result1))
|
|
{
|
|
$idcli=$ligne1[0];
|
|
$edu = $ligne1[1];
|
|
}
|
|
|
|
|
|
$reqcli2="SELECT nomcli, prenomcli,email, libelleadr, codepostal, ville FROM `client` , adresse WHERE adresse.idcli=$idcli AND client.idcli = adresse.idcli";
|
|
//$reqcli2 = "select nomcli,prenomcli,libelleadr,ville,codepostale email from client where idcli='$idcli'";
|
|
$result2=mysql_query($reqcli2) or die ("Erreur SQL :$reqcli2<br>".mysql_error()."...");
|
|
|
|
while ($ligne2 = mysql_fetch_row($result2))
|
|
{
|
|
$nomcli=$ligne2[0];
|
|
$prenomcli=$ligne2[1];
|
|
$email=$ligne2[2];
|
|
$adresse=$ligne2[3];
|
|
$codepostal=$ligne2[4];
|
|
$ville=$ligne2[5];
|
|
}
|
|
|
|
$storeaccountname="AirTria";
|
|
|
|
$id="$idcmde";
|
|
if($edu==1)
|
|
$edu="Yes";
|
|
else
|
|
$edu="No";
|
|
|
|
$time = time(); // la date au format système
|
|
|
|
$date = getdate($time); // passage de la variable time dans getdate pour ressortir les infos
|
|
print "id : $id<br>";
|
|
print "StoreAccountName : $storeaccountname<br>";
|
|
|
|
$time = $date[month].' '.$date[mday].', '.$date[year].', '.$date[hours].':'.$date[minutes];
|
|
print "time : $time<br>";
|
|
$numeric = time();
|
|
print "numeric : $numeric<br>";
|
|
|
|
$ship="
|
|
<AddressInfo type=\"ship\">
|
|
<Name>
|
|
<Full>$nomcli $prenomcli</Full>
|
|
</Name>
|
|
<Address1>$adresse</Address1>
|
|
<Address2></Address2>
|
|
<City>$ville</City>
|
|
<State></State>
|
|
<Country>FR</Country>
|
|
<Zip>$codepostal</Zip>
|
|
<Phone></Phone>
|
|
</AddressInfo>";
|
|
|
|
$bill="
|
|
<AddressInfo type=\"bill\">
|
|
<Name>
|
|
<Full>$nomcli $prenomcli</Full>
|
|
</Name>
|
|
<Address1>$adresse</Address1>
|
|
<Address2></Address2>
|
|
<City>$ville</City>
|
|
<State></State>
|
|
<Country>FR</Country>
|
|
<Zip>$codepostal</Zip>
|
|
<Phone></Phone>
|
|
<Email>$email</Email>
|
|
</AddressInfo>";
|
|
|
|
$suite1="
|
|
<Shipping>First Class Mail</Shipping>
|
|
<Edu>$edu</Edu>
|
|
<Cc>thierry.tallagrand@airtria.fr</Cc>
|
|
<Comments>$nomcli n :$id </Comments>
|
|
";
|
|
|
|
print "ship : '$ship'<br>";
|
|
print "bill : '$bill'<br>";
|
|
|
|
|
|
|
|
$reqprod = "select count(idprod) from composee where idcmde='$idcmde'";
|
|
$result=mysql_query($reqprod) or die ("Erreur SQL :$reqprod<br>".mysql_error()."...");
|
|
|
|
while ($ligne = mysql_fetch_row($result))
|
|
{
|
|
$compteur=$ligne[0]; //id produit
|
|
}
|
|
print "<br>il y a $compteur produits commandés";
|
|
|
|
$reqprod2 = "select idprod,qtecmde from composee where idcmde='$idcmde'";
|
|
$result2=mysql_query($reqprod2) or die ("Erreur SQL :$reqprod<br>".mysql_error()."...");
|
|
|
|
while ($ligne = mysql_fetch_row($result2))
|
|
{
|
|
$i++;
|
|
print "<br><br><b>Produit n°$i</b><br>";
|
|
$idprod[$i]=$ligne[0];
|
|
$qtecmde[$i]=$ligne[1];
|
|
|
|
print "<br>idprod : $idprod[$i] ---- Qte cmde : $qtecmde[$i]<br>";
|
|
|
|
$reqprix ="select prix,marge,qteprod from prix where idprod='$idprod[$i]' order by qteprod desc";
|
|
$resultprix=mysql_query($reqprix) or die ("Erreur SQL :$reqprix<br>".mysql_error()."...");
|
|
|
|
while ($ligne2 = mysql_fetch_row($resultprix))
|
|
{
|
|
$j++;
|
|
$code[$j]=$ligne2[0];
|
|
$marge=$ligne2[1];
|
|
$qteprod=$ligne2[2];
|
|
if ($marge) //prix dynamique
|
|
{
|
|
print "<br>Prix : $prix - marge : $marge -- qteprod : $qteprod<br>";
|
|
while ($qtecmde[$i]>= $qteprod)
|
|
{
|
|
|
|
$item[0][]=$code[$j];
|
|
$item[1][]=floor($qtecmde[$i]/$qteprod);
|
|
$qtecmde[$i]=$qtecmde[$i]%$qteprod;
|
|
|
|
}
|
|
}
|
|
}
|
|
//for($k=0;$k<count($item[0]);$k++)
|
|
//print "<br><br>code:".$item[0][$k].";qte:".$item[1][$k]."<BR>";
|
|
|
|
}
|
|
|
|
for($k=0;$k<count($item[0]);$k++)
|
|
{
|
|
$prixunit="http://crossover.codeweavers.com/vendor_price_query.php?user=tallagrand@airtria.fr;sku=".$item[0][$k];
|
|
$hwnd=fopen($prixunit,"r");
|
|
$prixunit = fread($hwnd, 100);
|
|
fclose($hwnd);
|
|
$xmlprod[$k]="
|
|
<Item num=\"$k\">
|
|
<Code>".$item[0][$k]."</Code>
|
|
<Quantity>".$item[1][$k]."</Quantity>
|
|
<Unit-Price>$prixunit</Unit-Price>
|
|
</Item>
|
|
";
|
|
print "$xmlprod[$k]<br>";
|
|
$xml=$xml.$xmlprod[$k];
|
|
$subtotal += ($prixunit * $item[1][$k]);
|
|
}
|
|
print "<br>Sous total : $subtotal";
|
|
|
|
$insert = "
|
|
<OrderList StoreAccountName=\"AirTria\">
|
|
<Order currency=\"USD\" id=\"$idcmde\">
|
|
<Time>$time</Time>
|
|
<NumericTime>$numeric</NumericTime>
|
|
".$ship."
|
|
".$bill."
|
|
".$suite1."
|
|
".$xml."
|
|
<Total>
|
|
<Line name=\"Subtotal\" type=\"Subtotal\">$subtotal</Line>
|
|
<Line name=\"Shipping\" type=\"Shipping\">0.00</Line>
|
|
<Line name=\"Tax\" type=\"Tax\">0.00</Line>
|
|
<Line name=\"Total\" type=\"Total\">$subtotal</Line>
|
|
</Total>
|
|
</Order>
|
|
</OrderList>
|
|
";
|
|
$fichier = '../mail/codeweaver.xml';
|
|
$pointeur = fopen($fichier, 'w+');
|
|
fwrite($pointeur, $insert);
|
|
fclose($pointeur);
|
|
$pointeur = fopen($fichier, 'r');
|
|
$contenu = fread($pointeur, filesize($fichier));
|
|
fclose($pointeur);
|
|
$codeweavers="store-process@codeweavers.com";
|
|
exec ("/usr/freeware/bin/smtpclient -v -f tallagrand@airtria.fr -b ../mail/codeweaver.xml -P 25 -S o2000 store-process@codeweavers.com ");
|
|
//store-process@codeweavers.com
|
|
?>
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|