62 lines
3.2 KiB
PHP
62 lines
3.2 KiB
PHP
<?php
|
|
/* COMMANDES */
|
|
// Modifier une commande (info de l'acheteur)
|
|
// Programmeur: Jean-Sébastien Proulx
|
|
// modifié: 2015-02-09 (adapté de express tours à ms1)
|
|
function fxModCommande($id) {
|
|
global $db;
|
|
|
|
if ($_POST['sta_id'] != $_POST['sta_id_old']) {
|
|
fxChangeStatut($_POST['sta_id'], $_POST['sta_id_old'], $id);
|
|
}
|
|
|
|
$sqlUpdate = "UPDATE inscriptions_panier_acheteurs SET com_prenom = '" . $db->fxEscape($_POST['com_prenom']) . "', com_nom = '" . $db->fxEscape($_POST['com_nom']) . "', com_courriel = '" . $db->fxEscape($_POST['com_courriel']) . "', com_telephone1 = '" . $db->fxEscape($_POST['com_telephone1']) . "', com_telephone2 = '" . $db->fxEscape($_POST['com_telephone2']) . "', com_adresse = '" . $db->fxEscape($_POST['com_adresse']) . "', com_ville = '" . $db->fxEscape($_POST['com_ville']) . "', pro_id = " . intval($_POST['pro_id']) . ", pay_id = " . intval($_POST['pay_id']) . ", com_codepostal = '" . $db->fxEscape($_POST['com_codepostal']) . "' WHERE ach_id = " . intval($id);
|
|
$qryUpdate = $db->fxQuery($sqlUpdate);
|
|
|
|
$_SESSION['msg'] = 126;
|
|
// header("Location: commandes.php?p=list");
|
|
header("Location: commandes.php?p=mod&ach_id=" . $id);
|
|
exit;
|
|
}
|
|
function fxChangeStatut($intStatutNew, $intStatutOld, $intAcheteur) {
|
|
global $db;
|
|
$arrRetour = array('state' => 'error');
|
|
|
|
if ($intStatutNew != $intStatutOld) {
|
|
$statut = ", sta_id = " . intval($intStatutNew);
|
|
$date_statut = ", ach_date_statut = '" . fxGetDateTime() . "'";
|
|
|
|
// ajout pour ajouter les qte si annulé
|
|
if (($intStatutOld == 3 && $intStatutNew == 6) || ($intStatutOld == 6 && $intStatutNew == 3) || ($intStatutOld == 4 && $intStatutNew == 6) || ($intStatutOld == 6 && $intStatutNew == 4)) {
|
|
$sql = "SELECT no_panier FROM inscriptions_panier_acheteurs WHERE ach_id = " . intval($intAcheteur);
|
|
$strNoPanier = $db->fxGetVar($sql);
|
|
|
|
$sqlEpreuves = "SELECT pec_id, epr_id FROM inscriptions_panier_epreuves_commandees WHERE no_panier = '" . $db->fxEscape($strNoPanier) . "'";
|
|
$arrEpreuves = $db->fxGetResults($sqlEpreuves);
|
|
|
|
// reset tables
|
|
if ($arrEpreuves != null) {
|
|
for ($intCtr = 1; $intCtr <= count($arrEpreuves); $intCtr++) {
|
|
$sqlEpreuves = "SELECT * FROM inscriptions_epreuves WHERE epr_id = " . intval($arrEpreuves[$intCtr]['epr_id']);
|
|
$tabEpreuve = $db->fxGetRow($sqlEpreuves);
|
|
|
|
//$tabEpreuve = fxGetEpreuve($arrEpreuves[$intCtr]['epr_id']);
|
|
$tabRetour = fxAnnulerRetablirInscription($tabEpreuve, $arrEpreuves[$intCtr]['pec_id']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$sqlUpdate = "UPDATE inscriptions_panier_acheteurs SET sta_id = " . intval($intStatutNew) . ", ach_date_statut = '" . fxGetDateTime() . "' WHERE ach_id = " . intval($intAcheteur);
|
|
$qryUpdate = $db->fxQuery($sqlUpdate);
|
|
|
|
if ($qryUpdate !== false) {
|
|
$sql = "SELECT sta_nom_fr FROM inscriptions_panier_statuts WHERE sta_id = " . intval($intStatutNew);
|
|
$strStatutNew = $db->fxGetVar($sql);
|
|
|
|
$arrRetour['state'] = 'success';
|
|
$arrRetour['statut'] = $strStatutNew;
|
|
}
|
|
}
|
|
|
|
return $arrRetour;
|
|
} |