Files
resatennis_tyroltenn/www/site_marchand/produit/validpanier.php

227 lines
6.3 KiB
PHP
Executable File

<?php
session_start();
//pour avoir un mini historique de la navigation et revenir sur les dernieres pages visitées
$idfamille=$HTTP_GET_VARS["idfamille"];
$idcateg=$HTTP_GET_VARS["idcateg"];
$page=$HTTP_GET_VARS["page"];
$montantcmde=$HTTP_GET_VARS["prixtot"];
if($_SESSION["edu"]="on")
$edu=1;
else
$edu=0;
?>
<html>
<head>
<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 {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: underline;
color: #FFFFFF;
}
a:active {
text-decoration: none;
color: #FFFFFF;
}
.style1 {font-size: x-small}
.style2 {font-size: xx-small}
-->
</style>
<link href="../style.css" rel="stylesheet" type="text/css">
</head>
<body class="bgcolor" text="white">
<div align="center">
<?php
//creation variable tableau pour envoit donnee par mail
$debutproduitmail="<table align=center><tr align=center><td><b>Nom du produit</b></td><td><b>Quantité</b></td><td><b>Prix</b></td></tr>";
$finproduitmail="</table>";
// Connex Base dd
require("../connexion.php");
$conn = mysql_connect($host, $user, $password);
mysql_select_db($bdd) or die("IMpossible d'ouvrir la base de donnee $bdd");
// DATE
$var2=getdate();
$var2 = date("d-M-Y", mktime(0,0,0, $var2['mon'], $var2['mday'] ,$var2['year']));
//recap commande
//print "Total de la commande : $montantcmde<br>";
//print "Date : $var2<br>";
//print "compt : $compt<br>";
//print "idcli : $idcli<br>";
/*for ($i=0;$i<=$compt;$i++)
{
print "prod[$i] : $prod[$i]<br>";
print "qtecmd[$i] : $qtecmd[$i]<br>";
}*/
//requete sql pour la recuperation des infos détaillées avant l'envoit par mail
$var3=getdate();
$idcmde= date("ymdhi");
//print "idcmde : $idcmde<br>";
$datecmde = date ("dMy");
//print "date cmde : $datecmde<br>";
//insertion de la cmde dans la base
$requete1 = "insert into commande
(idcmde,montantcmde,datecmde,idcli,etatcmde,edu)
values
('$idcmde','$montantcmde','$datecmde','$idcli','debut','$edu')";
$result1=mysql_query($requete1) or die ("Erreur SQL :$requete1<br>".mysql_error()."...");
//insertion de la composition de la commande
for ($i=0;$i<=$compt;$i++)
{
$qte = $qtecmd[$i];
$prd = $prod[$i];
$requete = "insert into composee
(qtecmde,idprod,idcmde)
values
('$qte','$prd','$idcmde')";
$result=mysql_query($requete) or die ("Erreur SQL :$requete<br>".mysql_error()."...");
}
//récupération des infos sur le client et sur la commande pour envoit par mail
//1- Client
$reqcli="select nomcli,prenomcli,email,societe,telfixe,telport from client where idcli='$idcli'";
$rescli = mysql_query($reqcli) or die ("Erreur SQL :$reqcli<br>".mysql_error()."...");
while ($ligne=mysql_fetch_row($rescli))
{
$nomcli=$ligne[0];
$prenomcli=$ligne[1];
$email=$ligne[2];
$societe=$ligne[3];
$telfixe=$ligne[4];
$telport=$ligne[5];
}
print "$nomcli $prenomcli $email $societe $telfixe $telport<br>";
//2- Produits
for ($i=0;$i<=$compt;$i++)
{
$reqprod = "select denomination from produit where idprod='$prod[$i]'";
$resprod=mysql_query($reqprod) or die ("Erreur SQL :$reqprod<br>".mysql_error()."...");
while ($ligne4=mysql_fetch_row($resprod))
{
$denomination[$i]=$ligne4[0];
}
$ceproduitmail = "<tr align=center>
<td>
$denomination[$i]
</td>
<td>
$qtecmd[$i]
<td>
$prixlignes[$i]
</td>
</tr>";
$prodmail= $prodmail . $ceproduitmail;
}
$prodmail= $debutproduitmail . $prodmail;
$prodmail= $prodmail . $finproduitmail;
/*
print "$prodmail";
print "prixtot : $prixtot<br>";
*/
//Envoit des mails
/*
$insert = "<html>
<head>
<title>
Recapitulatif de votre commande
</title>
</head>
<body text=\"#FFFFFF\" ALINK=\"#FF0033\" VLINK=\"#0099FF\" LINK=\"#0099FF\" BGCOLOR=\"black\">
<div align=\"center\">
<h1>
Airtria
</h1>
</div>
<br><br>
Commande n° : <b>$idcmde</b><br><br>
Produits commandés :<br>";
$insert=$insert . $prodmail;
$fininsert="<br><br>Prix total : $prixtot<br><br>L'équipe <b>Airtria</b> vous remercie. ";
$insert=$insert . $fininsert;
$fichier = '../mail/mail.php';
$pointeur = fopen($fichier, 'w+');
fwrite($pointeur, $insert);
fclose($pointeur);
$pointeur = fopen($fichier, 'r');
$contenu = fread($pointeur, filesize($fichier));
fclose($pointeur);
$cmd="/usr/freeware/bin/smtpclient -v -f albin.quevillon@airtria.fr -b ../mail/mail.php -s 'Recapitulatif de votre commande' -P 25 --smtp-host=o2000 $email";
print "$cmd";
exec ("$cmd");
*/
// Mail à Mr Tallagrand
$insert = "<html><head><title>une commande !!!</title></head>
<body text=\"#FFFFFF\" ALINK=\"#FF0033\" VLINK=\"#0099FF\" LINK=\"#0099FF\" BGCOLOR=\"black\">
<div align=\"center\">
<h1>
Airtria
</h1>
</div>
<br>Date de commande : $var2<br>
<b>Information sur le client</b><br><br>
<b>Nom : $nomcli<br>
<b>Prénom : $prenomcli<br>
<b>email : <a href=\"mailto:$email\">$email</a><br>
<b>Tel Fixe : $telfixe<br>
<b>Tel Port : $telport<br>
<b>Societé : $societe<br><br>
Commande n° : $idcmde</b><br><br>
Produits commandés :<br>";
$insert=$insert . $prodmail;
$fininsert="<br><br>Prix total : $prixtot<br><br><a href=\"http://o2000/~airtria/site_marchand/commande/generexml.php?idcmde=$idcmde\">Cliquez ici pour valider la commande</a></body></html>";
$insert=$insert . $fininsert;
$fichier = '../mail/mail.php';
$pointeur = fopen($fichier, 'w+');
fwrite($pointeur, $insert);
fclose($pointeur);
$pointeur = fopen($fichier, 'r');
$contenu = fread($pointeur, filesize($fichier));
fclose($pointeur);
exec ("/usr/freeware/bin/smtpclient -v -f thierry.tallagrand@airtria.com -b ../mail/mail.php -s 'une commande !!!!' -P 25 -S o2000 thierry.tallagrand@airtria.fr");
?>
Commande validée.<br>
Un email vous sera envoyé avec un récapitulatif de votre commande.<br><br><br>
<a href="../vierge.php">Accueil</a>
</div>
<?php
// vidage du panier
$i=0;
do
{
$prod[$i]="";
$qtecmd[$i]="";
session_unregister("prod[$i]");
session_unregister("qtecmd[$i]");
$i++;
} while ($i <= $compt);
$compt=0;
session_unregister("compt");
?>
</body>
</html>