alpha_full/pages/panier/_formOptions/20-formCommun.php
2026-04-06 22:58:51 +02:00

125 lines
5.2 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
/*
A - Si quantité postée on la prends,
- si OU : on desactive les autres
B - Sinon si AUCUN
- on desactive tout, on coche aucun
C - Sinon si données existe en BDD
- on prends la quantité bdd et on coche l'item -- plus de bdd pour le moment
D - Sinon si DEFAUT existe
- si pas deja de quantité
- on prends quantité defaut et on coche l'item
E - Sinon rien
*/
$continuer=true;
$debugMsg .= monDebug(1, [
'<br>tabTagLib[$z]' =>$tabTagLib[$z],
'code C1' => isset($c1)? $c1:'empty',
'z' => $z,
'u' => $u,
'tabIdType[$z]' => $tabIdType[$z] ],
'20-formCommun');
// ---------------------------------------------------
// Calcul de l'icone a afficher dans entete ou items
// ---------------------------------------------------
if (isset($imageCATab[$z])) {
$test=false;
$test=strpos($imageCATab[$z], 'fa');
if ($test!==false ) $src='<i class="' .$imageCATab[$z]. ' fa-2x" style="color:' .$iColor. '; width:32px;margin:auto;"></i>';
else $src='<img style="max-width:32px;margin:auto;" src="' .$imageCATab[$z]. '" alt="option" />';
if (isset($debug[15]) && $debug[15] == '1' ) $debugMsg .= monDebug(1,['imageCATab[$z]' => $imageCATab[$z] ],'');
}
// ---------------------------------------------------
// A - Maj de la quantite postée
// ---------------------------------------------------
if (!empty($itemNumberPost) && ($quantitePost!='')) {
if ($tabItemNumber[$u]==$itemNumberPost) {
$continuer=false;
$tabQuantite[$u]=$quantitePost;
$lineItemQuantite[$nLigne]=$tabQuantite[$u];
echo '<script type="text/javascript">activBtn(\'1\',\'' .$sOpt. '\');</script>';
$activBtn=1;
if (isset($debug[15]) && $debug[15] == '1' ) $debugMsg .= monDebug(1, ['Changement de quantité par POST' =>'Oui' ],'');
}
else
// s'il y avait une quantité dans les autres on la vide
if ($ETOU=='OU' ) $tabQuantite[$u]=0;
}
// ---------------------------------------------------
// B - Si aucun et 'ET' désactiver tous les autres
// ---------------------------------------------------
if ($isAucun == strtoupper('AUCUN') && ($ETOU=='ET' ) && ($continuer == true) ) {
$tabQuantite[$u]=0;
if (isset($debug[15]) && $debug[15] == '1' ) $debugMsg .= monDebug(1, ['Quantité remise à zero par AUCUN' =>'Oui' ],'');
$lineItemQuantite[$nLigne]=0;
$continuer = false;
include ("./pages/panier/_formOptions/reqOpt/reqDeleteOptionAucun.php");
}
// ---------------------------------------------------
// C - Quantité depuis la BDD
// Desactivé pour le moment, car trop de bugs, et j'en ai marre, mais avait marché
// ---------------------------------------------------
// ---------------------------------------------------
// D - La quantité par defaut : code C1
// ---------------------------------------------------
if ($continuer==true && empty($tabQuantite[$u]) && isset($c1) && ( !empty($itemNumberPost) && $tabItemNumber[$u]==$itemNumberPost) && ($quantitePost!='') ) {
$test=-1;
$test=substr($c1,0,6);
if (strtoupper($test)=='DEFAUT') {
$defautQuant=substr($c1,-2);
$debugMsg .= monDebug(1, ['defautQuant' => $defautQuant, 'test' => $test ],'');
$tabQuantite[$u] = (int)$defautQuant;
// si on a une quantité par defaut on force la prise en compte pour la DB directement sans post, on active donc deja le bouton
$itemNumberPost=$tabItemNumber[$u];
$quantitePost=(int)$defautQuant;
$lineItemQuantite[$nLigne]=(int)$defautQuant;
$lineItemLibelle[$nLigne]=$tabTagLib[$z];
$codeOpeForm='majOptions';
echo '<script type="text/javascript">document.getElementById (\'codeOpeForm\').value=\'majOptions\';</script>';
echo '<script type="text/javascript">activBtn(\'1\',\'' .$sOpt. '\');</script>';
$activBtn=1;
}
}
if (isset($debug[15]) && $debug[15] == '1' ) {
$debugMsg .= monDebug(1, [
'tabItemNumber (u)' => isset($tabItemNumber[$u])?$tabItemNumber[$u]:'empty',
'itemNumberPost' => isset($itemNumberPost)?$itemNumberPost:'empty',
'quantitePost' => $quantitePost,
'c3' => isset($c3)? $c3:'empty',
'continuer' => $continuer,
'lineItemQuantite[nLigne]' => isset($lineItemQuantite[$nLigne])? $lineItemQuantite[$nLigne]:'empty'
],''); }
// ---------------------------------------------------
// Affichage formulaire : entete puis lignes
// - entete pour les check / radios
// - lignes pour le calcul des prix
echo '<style>#' .$prefixIdItem .$numColonne[$x]. '{background:#FFF;}</style>';$bgCol="#FFF";
if (isset ($c1) && $c1 == strtoupper('AUCUN') )
{ echo '<style>#' .$prefixIdItem .$numColonne[$x]. '{background:lightgrey;}</style>';$bgCol='lightgrey';}
if ($tabItemNumber[$u]==$itemNumberPost && strtoupper($c1)!='AUCUN' && $tabQuantite[$u]==0 )
{ echo '<style>#' .$prefixIdItem .$numColonne[$x]. '{background:orange;}</style>';$bgCol='orange';}
if (isset($tabQuantite[$u]) && $tabQuantite[$u]>0 && strtoupper($c1)!='AUCUN') {
if ($_SESSION['siteName']=="pizzaJeannot") {echo '<style>#' .$prefixIdItem .$numColonne[$x]. '{background:lightgreen;}</style>';$bgCol='lightgreen';}
else {echo '<style>#' .$prefixIdItem .$numColonne[$x]. '{background:#fbe3c1;}</style>';$bgCol='#fbe3c1';}
}
include ("21-itemCheck.php");
include ("22-itemsQuantite.php");
?>