78 lines
3.3 KiB
PHP
Executable File
78 lines
3.3 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
|
|
// ---------------------------------------------------
|
|
// Cartouche
|
|
// ---------------------------------------------------
|
|
// Si il y a des options depuis le formulaire option du panier, les inscrire dans la table option
|
|
// Par simplicité on fera un delete avant, en cas ou l'utilisateur veut modifier des options, plus simple que un update
|
|
// Par la suite bdans le panier on viendra lire les lignes options en plus des lignes produit
|
|
// ---------------------------------------------------
|
|
|
|
if (!empty($idCde) && !empty($idPrd)) {
|
|
|
|
// ---------------------------------------------------
|
|
// Récup des données
|
|
// ---------------------------------------------------
|
|
$itemNum=$lineItemNumber[$opt];
|
|
|
|
$prixOptHt=$lineItemPrixHT[$opt];
|
|
if (empty($prixOptHt)) $prixOptHt='0.00';
|
|
|
|
$prixOptTTC=$lineItemPrixTTC[$opt];
|
|
if (empty($prixOptTTC)) $prixOptTTC='0.00';
|
|
|
|
$prixTotTTC=$lineItemPrixTtcTOT[$opt];
|
|
if (empty($prixTotTTC)) $prixTotTTC='0.00';
|
|
|
|
// pas utilisé ici mais besoin pour le total HT commande
|
|
$prixTotHT=$lineItemPrixHtTOT[$opt];
|
|
if (empty($prixTotTTC)) $prixTotHT='0.00';
|
|
|
|
// Anti patate
|
|
if (!empty($lineItemQuantite[$opt])) $qteOpt=$lineItemQuantite[$opt];
|
|
// else if (!empty($quantitePost)) $qteOpt=$quantitePost;
|
|
|
|
$libOpt=$lineItemLibelle[$opt];
|
|
$tvaOptTaux=$lineItemTvaTaux[$opt];
|
|
|
|
// ---------------------------------------------------
|
|
// Calcul TVA à la ligne
|
|
// ---------------------------------------------------
|
|
|
|
$prixOptHt=formatNB($prixOptHt,'MYSQL');
|
|
$prixOptTTC=formatNB($prixOptTTC,'MYSQL');
|
|
$prixTotHT=formatNB($prixTotHT,'MYSQL');
|
|
$prixTotTTC=formatNB($prixTotTTC,'MYSQL');
|
|
|
|
$tvaPrd=$lineItemTvaTaux[$opt];
|
|
include ("./pages/panier/_reqPanier/panier.reqSelectTvaPrd.php");
|
|
$tvaOptTaux=$tauxTvaPrd;
|
|
$tvaOptTaux=formatNB($tvaOptTaux,'MYSQL');
|
|
|
|
// $tvaOptMontant=($prixOptHt*$tvaOptTaux)/100;
|
|
$tvaOptMontant=($prixOptTTC-$prixOptHt);
|
|
$tvaOptMontant=formatNB($tvaOptMontant,'MYSQL');
|
|
|
|
$debugMsg .= 'qteOpt = ' .$qteOpt;
|
|
|
|
// ---------------------------------------------------
|
|
// Insert des options calculées
|
|
// ---------------------------------------------------
|
|
$reqInsert="INSERT INTO prdOptions values(0, " .$_SESSION['sOpt']. ", $opt, $itemNum, '" .$idMail. "', $idCde, $idLgCde, $idPrd, '" .$prixOptHt. "', '" .$prixOptTTC. "', $qteOpt, '" .$libOpt. "', '" .$tvaOptTaux. "', '" .$tvaOptMontant. "', '" .$prixTotHT. "', '" .$prixTotTTC. "');";
|
|
if (isset($debug[2]) && $debug[2] == '1' )
|
|
{$debugMsg .='<br><span style="font-weight:bold">Requête Insert lignes (reqInsertLignesOptions.php) </span> => ' .$reqInsert;}
|
|
$result='';
|
|
$resConn=$idPdo->query($reqInsert);
|
|
if (isset($debug[2]) && $debug[2] == '1' ) {
|
|
if ($resConn)
|
|
{$debugMsg .=mondebug(2,['Insert ligne option = ok ' => $result],'reqInsertLignesOptions');}
|
|
else
|
|
{$debugMsg .=mondebug(2,['Insert ligne option = ko ' => $result],'reqInsertLignesOptions');}
|
|
}
|
|
}
|
|
else if (isset($debug[2]) && $debug[2] == '1' ) {
|
|
{$debugMsg .= mondebug ( 2 ,['Pas de idCde dans reqInsertLignesOptions.php ' => ''],'reqInsertLignesOptions'); }
|
|
{$debugMsg .= mondebug ( 2 ,['Pas de idPrd dans reqInsertLignesOptions.php ' => ''],''); }
|
|
}
|
|
?>
|