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

179 lines
7.5 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
$max=5;
if (isset ($c1) && strtolower($c1)=='aucun') {$displayItem='none; background:lightgrey; border:0;'; } else {$displayItem='block;border:0;';}
// ---------------------------------------------------
// Colonne 1 : prix
// ---------------------------------------------------
echo '<div class="divChamps" id="' .$prefixIdItem .$numColonne[$x]. '" style="background:' .$bgCol. '; display:' .$displayItem. '; font-size:1rem; text-align:center; border:0; padding:10px;" data-tooltip="Prix TTC" >';
if (isset ($c3) && $typeDeListe[$x]!="Includée" && strtoupper($c3)!='SANS') {
echo '<span style="display:' .$displayItem. '; padding-top:7px;" > + ' .$prixTTCOptTab[$u]. ' €</span>';
}
$numColonne[$x]++;
echo '</div>';
// ---------------------------------------------------
// Colonne 2 : quantité
// ---------------------------------------------------
echo '<div class="divChamps" id="' .$prefixIdItem .$numColonne[$x]. '" style=" background:' .$bgCol. '; display:' .$displayItem. '; max-width:25%; overflow:inherit " data-tooltip="Choisissez la quantité" >';
// ---------------------------------------------------
// le code C2 donne la quantité à déduire '1 inclus '
// ---------------------------------------------------
if (isset ($c1) ) $test=substr($c2,-6);
if (strtolower($test)==strtolower('inclus')) {
$quantiteIncluse = substr($c2,0,1);
}
else {
$quantiteIncluse = 0;
}
// ---------------------------------------------------
// le code C3 donne la quantité max
// ---------------------------------------------------
if (isset ($c1)) $test=substr($c3,0,3);
if (strtolower($test)==strtolower('max')) {
$max = substr($c3,-2);
// max inlut le zero
$max = trim( intval($max) ) ;
$max = $max++ ;
}
// si OU on met tout a zero sauf le post
if ($ETOU=="OU") {
if ($quantitePost!='' && $itemNumberPost!='') {
if ($itemNumberPost!=$tabItemNumber[$u]) $tabQuantite[$u]=0;
}
}
// ---------------------------------------------------
// La liste deroulante select quantité
// ---------------------------------------------------
if (isset ($c3) && $typeDeListe[$x]=="Indep" && strtoupper($c3)!='SANS') {
if ($ETOU!="OU") echo '<span style="display:' .$displayItem. '; background:' .$bgCol. ';color:blue; border:1px solid grey; border-radius:9px; background:white; vertical-align:middle; padding-right:5px; margin:auto; " >';
else echo '<span style="display:' .$displayItem. '; background:' .$bgCol. '; ">';
if ($ETOU!="OU") echo '<span style="cursor:pointer; border-right:1px solid lightgrey; padding-left:10px; padding-right:10px; width:30px; " onClick="quantUp(\'' .$u. '\', \'' .$tabItemNumber[$u]. '\', \'minus\',\'' .$c1. '\'); ">-</span>';
echo '<span >';
echo '<select id="kant' .$u. '" name"kant' .$u. '" onChange="upQte(document.getElementById (\'kant' .$u. '\').value,\'' .$tabItemNumber[$u]. '\', \'' .$c1. '\');" >';
// Options liste
for($q=0; $q<=$max; $q++) {
if ($q==$tabQuantite[$u]) echo '<option value="' .$q. '" selected>' .$q. '</option>';
else echo '<option value="' .$q. '">' .$q. '</option>';
}
echo '</select>';
echo '</span>';
if ($ETOU!="OU") echo '<span style="cursor:pointer; border-left:1px solid lightgrey; padding-left:10px; padding-right:10px; width:30px; " onClick="quantUp(\'' .$u. '\', \'' .$tabItemNumber[$u]. '\', \'plus\',\'' .$c1. '\')">+</span>';
echo '</span>';
}
else echo '<input type="hidden" id="kant' .$u. '" >';
// pas de desactiv pour valeur unique
if ($idTypeCherche==1) {
$itemToDesactiv=$u;
echo '<script type="text/javascript">document.getElementById("itemToDesactiv").value=' .$u. '</script>';
}
$numColonne[$x]++;
echo '</div>';
// ---------------------------------------------------
// Scripts pour les boutons radio
// tout ça pour avoir une valeur par defaut
// ---------------------------------------------------
// if ($ETOU=="OU") {
// if ($quantiteIncluse==0) echo '<script>radioChange (' .$u. ',' .$x. '); </script>';
// if ($quantiteIncluse==0) echo '<script>defautChoixRadio(' .$u. '); </script>';
// }
// ---------------------------------------------------
// Colonne 3 : calcul total
// Ne pas compter en double les inclusions
// ---------------------------------------------------
if (!empty($tabQuantite[$u]) && ( $tabQuantite[$u]>0 ) ) {
$totQuantParListe=$totQuantParListe+$tabQuantite[$u];
$delta=(int)$totQuantParListe-$quantiteIncluse;
}
if ($delta > 0 && ( isset($tabQuantite[$u]) && $tabQuantite[$u] > 0 ) ) {
$tabTotalHT[$u]=$prixHTOptTab[$u]*($tabQuantite[$u]);
$tabTotalTTC[$u]=$prixTTCOptTab[$u]*($tabQuantite[$u]);
// ---------------------------------------------------
// Somme des options par liste
// ---------------------------------------------------
$totMontantParListe=$totMontantParListe+$tabTotalTTC[$u];
}
else {
$tabTotalTTC[$u]=0.00;
$tabTotalHT[$u]=0.00;
}
// ---------------------------------------------------
// Debug
// ---------------------------------------------------
if (isset($debug[15]) && $debug[15] == '1' ) {
$debugMsg .= monDebug(1, [
'Form 22' => isset($tabTagLib[$z])?$tabTagLib[$z]:'empty',
'nLigne actuel '=> $nLigne,
'$tabQuantite[$u]' => isset($tabTotalTTC[$u])?$tabTotalTTC[$u]:'empty',
'$tabQuantite[$u]' => isset($tabQuantite[$u])?$tabQuantite[$u]:'empty',
'totMontantParListe' => isset($totMontantParListe)?$totMontantParListe:'empty'
] ,'22-itemsQuantite');
// $debugMsg .= '<br> <span style="color:green">Form 22 :' .$tabTagLib[$z]. '</span>';
// $debugMsg .= ' | code1 = ' .$c1;
// $debugMsg .= ' | code2 = ' .$c2;
// $debugMsg .= ' | delta=' .$delta. ' ';
// $debugMsg .= ' | ETOU=' .$ETOU. ' ';
// $debugMsg .= ' | nLigne actuel = ' .$nLigne. ' ';
// $debugMsg .= ' | totQuantParListe=' .$totQuantParListe. '';
// $debugMsg .= ' | totMontantParListe=' .$totMontantParListe. '';
// $debugMsg .= '<br>$tabTotalTTC[$u]=' .$tabTotalTTC[$u]. '';
// $debugMsg .= ' | quantiteIncluse = ' .$quantiteIncluse;
// $debugMsg .= ' | max = ' .$max ;
// $debugMsg .= ' | $_SESSION['typeDeListe'] = ' .$_SESSION['typeDeListe'][$x] ;
// $debugMsg .= ' | $tabQuantite[$u] = ' .isset($tabQuantite[$u])?$tabQuantite[$u]:'empty' ;
// $debugMsg .= ' | $_SESSION[quantiteParListe] = ' .$_SESSION['quantiteParListe'] ;
}
$numColonne[$x]++;
// ---------------------------------------------------
// Pour le panier
// ---------------------------------------------------
if (isset($tabQuantite[$u]) && $tabQuantite[$u] !=0 && $tabQuantite[$u] !='' && $itemNumberPost==$tabItemNumber[$u]) {
$lineItemLibelle[$nLigne]=$tabTagLib[$z];
$lineItemQuantite[$nLigne]=$tabQuantite[$u];
$lineItemPrixHT[$nLigne]=$prixHTOptTab[$u];
$lineItemPrixTTC[$nLigne]=$prixTTCOptTab[$u];
$lineItemPrixHtTOT[$nLigne]=$tabTotalHT[$u];
$lineItemPrixTtcTOT[$nLigne]=$tabTotalTTC[$u];
$lineItemTvaTaux[$nLigne]=$tvaOptTab[$u];
$lineItemCode1[$nLigne]=$c1;
// pour mettre en db et retrouver les quantités par produit et pas en session : lorsque l'on revient de panier
$lineItemNumber[$nLigne]=$tabItemNumber[$u];
if (isset($debug[15]) && $debug[15] == '1' ) {
monDebug(1, [
'Je suis passé dans la maj de lineItem ' =>'oui',
'tabTotalTTC'=>$tabTotalTTC[$u],
'totMontantParListe'=>$totMontantParListe,
'nLigne'=>$nLigne,
'lineItemLibelle'=>$lineItemLibelle[$nLigne],
'lineItemNumber'=>$lineItemNumber[$nLigne]
],'');
}
}
$_SESSION['sOpt']=$sOpt;
?>