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
|
//Insertion des données en base de données
if ($_POST['ajoutCommande']=="ok"){
$compteID_compte = $_POST['compteID_compte'];
$nomDemandeurCommandePapier=$_POST['nomDemandeurCommandePapier'];
$lieuLivraisonCommandePapier=$_POST['lieuLivraisonCommandePapier'];
$dateCommandePapier=dateEN($_POST['date']);
$nbElement=$_POST['nbElement'];
//Récupération du compte sélectioné
mysql_select_db($database_connection, $connection);
$query_recupCompteSelect = "SELECT a.numeroCompte, b.descriptionService, c.descriptionDirection FROM compte a, services b, directions c WHERE a.compteID='".$_POST['compteID_compte']."' AND a.serviceID_services=b.serviceID AND b.directionsID_directions=c.directionsID ORDER BY a.numeroCompte ASC";
$recupCompteSelect = mysql_query($query_recupCompteSelect, $connection) or die(mysql_error());
$row_recupCompteSelect = mysql_fetch_assoc($recupCompteSelect);
//Affectation des valeur à des variables
$numeroCompteCommandePapier=$row_recupCompteSelect['numeroCompte'];
$descriptionServiceCommandePapier=addslashes($row_recupCompteSelect['descriptionService']);
$descriptionDirectionCommandePapier=addslashes($row_recupCompteSelect['descriptionDirection']);
//Récupération des informations sur le site sélectionné
mysql_select_db($database_connection, $connection);
$query_recupSiteSelect = "SELECT a.nomSite, adresseSite FROM site a WHERE a.siteID='".$_POST['lieuLivraisonCommandePapier']."'";
$recupSiteSelect = mysql_query($query_recupSiteSelect, $connection) or die(mysql_error());
$row_recupSiteSelect = mysql_fetch_assoc($recupSiteSelect);
//Affectation des valeur à des variables
$lieuLivraisonCommandePapier=$row_recupSiteSelect['nomSite']." - ".$row_recupSiteSelect['adresseSite'];
$lieuLivraisonCommandePapier=addslashes($lieuLivraisonCommandePapier);
//Insertion des données générales de la commande dans la table commandepapier
mysql_query("INSERT INTO commandepapier (dateCommandePapier, numeroCompteCommandePapier, descriptionServiceCommandePapier, descriptionDirectionCommandePapier, nomDemandeurCommandePapier, lieuLivraisonCommandePapier) VALUES ('$dateCommandePapier', '$numeroCompteCommandePapier', '$descriptionServiceCommandePapier', '$descriptionDirectionCommandePapier', '$nomDemandeurCommandePapier', '$lieuLivraisonCommandePapier')",$connection);
//Récupération del'ID que nous venons d'insérer.
mysql_select_db($database_connection, $connection);
$query_recupID = "SELECT commandePapierID FROM commandepapier ORDER BY commandePapierID DESC";
$recupID = mysql_query($query_recupID, $connection) or die(mysql_error());
$row_recupID = mysql_fetch_assoc($recupID);
$commandePapierID=$row_recupID['commandePapierID'];
//Insertion des données de la commande dans la table detailcommandepapier
for ($i = 0; $i < $_POST['compte']; $i++) {
if (isset($_POST["papierID_papier"][$i])) {
$totalSelect=$_POST['quantiteDetailCommandePapier'][$i]*$_POST['tarifPapier'][$i];
$papierID_papier=$_POST["papierID_papier"][$i];
$quantiteDetailCommandePapier=$_POST['quantiteDetailCommandePapier'][$i];
mysql_query("INSERT INTO detailcommandepapier (CommandePapierID_CommandePapier, papierID_papier, quantiteDetailCommandePapier, totalDetailCommandePapier) VALUES ('$commandePapierID', '$papierID_papier', '$quantiteDetailCommandePapier', '$totalSelect')",$connection);
}
}
header("Location:./maintenanceListePapierImprimante.php?nbElement=".$nbElement."");
} |
Partager