$codeOpe ], 'panier.calculLigne.php'); } // --------------------------------------------------- // Déclaration et formatage initial // --------------------------------------------------- $montantTvaLigne = 0; $montantReducLigne = 0; // $poidsLigne = 0; $qte = intval($qte); // --------------------------------------------------- // Recup Remise client // --------------------------------------------------- include ("./pages/panier/_reqPanier/panier.reqSelectClientRemise.php"); if (!empty($remiseCli)) $remiseCli = formatNB($remiseCli , 'MYSQL'); // --------------------------------------------------- // Recup des infos produit // --------------------------------------------------- include ("_reqPanier/panier.reqSelectPrd.php"); // --------------------------------------------------- // Formattage prixUnitHT // --------------------------------------------------- $prixUnitHT = formatNB($prixUnitHT , 'MYSQL'); // $poidsLigne = formatNB($poidsLigne , 'MYSQL'); $totTtcLigne = formatNB($totTtcLigne , 'MYSQL'); // --------------------------------------------------- // --------------------------------------------------- // MOTEUR DE REGLES : // --------------------------------------------------- $montantReducLigneAvantage=0; $theAvantageDesc=""; include ("reglePanier.reqSelect.php"); $prixUnitTtc = formatNB($prixUnitTtc , 'MYSQL'); $promo = formatNB($promo , 'MYSQL'); if (isset($debug[1]) && $debug[1] == '1') { $debugMsg .= monDebug (1, ['prixUnitTtc' => $prixUnitTtc, 'prixUnitTtc' => $prixUnitTtc, 'promo' => $promo ], 'panier.calculLigne.php'); } // --------------------------------------------------- // Prix affiché : ttc ou HT // --------------------------------------------------- if (!empty($_SESSION['affTTCOui']) && $_SESSION['affTTCOui'] == 1 ) { $prixAff = $prixUnitTtc; } else $prixAff = $prixUnitHT; $prixAff = formatNB($prixAff , 'MYSQL'); if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (1, ['prixAff' => $prixAff ], ''); } // --------------------------------------------------- // Calcul du montant de la reduc : promo OU remise Ou règle // --------------------------------------------------- if (!(empty($promo)) && $promo>0) { $montantReducLigne = $promo; $typeReducLigne = $cdeMsg[88]; } elseif ($remiseCli != 0 and !empty($remiseCli)) { // echo 'REMISE = ' .$remiseCli; // echo 'prixAff = ' .$prixAff; $rem2=$remiseCli/100; $montantReducLigne = $prixAff*($rem2); $typeReducLigne = $cdeMsg[32]; }// exemple 10 % de remise donne 10€ de remise else { $montantReducLigne = 0; $typeReducLigne = '-'; } // Si règle commerciale if ($montantReducLigneAvantage >0) { $montantReducLigne = $montantReducLigneAvantage; $typeReducLigne = $theAvantageDesc; } // --------------------------------------------------- // Formattage // --------------------------------------------------- $montantReducLigne = formatNB($montantReducLigne , 'MYSQL'); if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (1, ['theAvantageDesc' => $theAvantageDesc, 'montantReducLigneAvantage' => $montantReducLigneAvantage , 'montantReducLigne' => $montantReducLigne, 'typeReducLigne' => $typeReducLigne, 'codeOpe' => $codeOpe ], ''); } // --------------------------------------------------- // Cumul qte // --------------------------------------------------- // modif de la quantité par ajout nouvelle qte : codeOpe = 11 if ($codeOpe == 11) { // qte2 est pris depuis panier.php dans la boucle lignes = quantité recupéré de l'ancien panier if (!empty($qte2) && $qte2 > 0) { $qte2 = intval($qte2); $qte = $qte+$qte2; //quantité totale de la ligne $qte2=$qte; //des fois que qte2 soit utilisée à la place de qte } // gerer le stok ou pas : edt ne devrait pas etre dans tous les cas ? if (isset($_SESSION['geststockOui'])) $gererStock=$_SESSION['geststockOui']; else $gererStock=1; if ($qte > $stock && $gererStock == 1) { $reqSelect="SELECT nomPrd FROM `produitslibelle` WHERE idPrd='" .$idPrd. "' and idLg='" .$lg. "';"; $resConn=''; $libPrdDepass=''; $resConn= $idPdo->query($reqSelect); if($resConn) { $result=$resConn->fetch(PDO::FETCH_ASSOC); $libPrdDepass=$result['nomPrd']; } $usrSiteMsg .= '' .$cdeMsg[96]. ' ' .$libPrdDepass. ''; $usrSiteMsgClass='ko'; $qte = $stock; // $_SESSION['continuerPanier']=0; // flag edt a faire marcher recup theIdPrd + son libelle => et report en ligne 103 panierForm } else $qte=1; if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (1, ['qte2' => $qte2, 'qte' => $qte, 'gererStock' => $gererStock , '$_SESSION[geststockOui]' => $_SESSION['geststockOui'] ], 'panier.calculLigne'); } } // --------------------------------------------------- // Poids -> on mets tout en kilos // --------------------------------------------------- //poids depuis produit $poids = formatNB($poids , 'MYSQL'); if(!isset($unitePoids)) $unitePoids=2; switch ($unitePoids) { case '1': // grammes $poids = $poids/1000; break; case '2': // kilos break; case '3': break; } // --------------------------------------------------- // Poids total ligne // --------------------------------------------------- $poidsLigne = $poids*$qte; $poidsLigne = formatNB($poidsLigne , 'MYSQL'); if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (1, ['poids' => $poids, 'poidsLigne' => $poidsLigne ], 'panier.calculLigne'); } // --------------------------------------------------- // Prix final HT ligne apres reduc // --------------------------------------------------- $prixUnitRemiseLigne = $prixUnitHT - $montantReducLigne; $prixUnitRemiseLigne = formatNB($prixUnitRemiseLigne , 'MYSQL'); if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (1, ['prixUnitRemiseLigne' => $prixUnitRemiseLigne ], ''); } // --------------------------------------------------- // Montant TVA ligne selon TTC ou HT // --------------------------------------------------- include("./pages/panier/_reqPanier/panier.reqSelectTvaPrd.php"); $montantTvaLigne = ( ( $prixUnitRemiseLigne * ( $tauxTvaPrd ) / 100 ) ); $prixUnitTtc = $prixUnitRemiseLigne + ( $montantTvaLigne ); $montantTvaLigne= formatNB($montantTvaLigne,'MYSQL'); if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (1, ['montantTvaLigne' => $montantTvaLigne, 'prixUnitTtc' => $prixUnitTtc ], ''); } // --------------------------------------------------- // Montant Total TTC ligne // --------------------------------------------------- if (!empty($_SESSION['affTTCOui']) && $_SESSION['affTTCOui'] == 1 ) { $totTtcLigne = ((float)$montantTvaLigne+(float)$prixUnitRemiseLigne) * $qte; } $totTtcLigne = formatNB($totTtcLigne , 'MYSQL'); if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (2, ['totTtcLigne' => $totTtcLigne ], ''); } // --------------------------------------------------- // mise a jour reduc totale // --------------------------------------------------- if ($typeReducLigne!= '' && $typeReducLigne!= '-') { $montantReducLigne = $montantReducLigne*$qte; } // --------------------------------------------------- // Formattage // --------------------------------------------------- $montantReducLigne = formatNB($montantReducLigne , 'MYSQL'); ?>