165 lines
6.5 KiB
PHP
Executable File
165 lines
6.5 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
// -----------------------------------------------------
|
|
// On calcule le message suite pour le mail
|
|
// -----------------------------------------------------
|
|
$idPrdTab=array();
|
|
$qteLigneTab=array();
|
|
$prixUnitRemiseHtTab=array();
|
|
$libRemiseTab=array();
|
|
$montantTvaLigneTab=array();
|
|
$montantReducLigneTab=array();
|
|
$ttcLignesTab=array();
|
|
$nomPrd=array();
|
|
|
|
$libTraduit=array();
|
|
$quantite=array();
|
|
$prixTotTTC=array();
|
|
$tableau=array();
|
|
$tableauNom=array();
|
|
|
|
$suite='<ul>';
|
|
|
|
if (isset($idCde) && !empty($idCde) ) {
|
|
require_once ($includePath. "/_fonctions/fonctions.gene.php");
|
|
$reqSelect="SELECT * FROM `commandelignes` WHERE idCde=" .$idCde. ";";
|
|
$reConn='';
|
|
$tabResult='';
|
|
if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug (2, ['reqSelect' => $reqSelect ],'reqSelectFromLignesCde.php');
|
|
$resConn=$idPdo->query($reqSelect);
|
|
if ($resConn) {
|
|
// si la requête a fonctionnée
|
|
if ($resConn->rowCount()>0) {
|
|
|
|
// si la requête a retourné au moins un enregistrement
|
|
$l=0;
|
|
$nbArt=0;
|
|
while ($tabResult=$resConn->fetch(PDO::FETCH_ASSOC)) {
|
|
$idPrdTab[$l]=$tabResult['idPrd'];
|
|
$qteLigneTab[$l]=$tabResult['qte'];
|
|
$prixUnitRemiseHtTab[$l]=$tabResult['prixUnitRemiseHtLigne'];
|
|
$montantTvaLigneTab[$l]=$tabResult['montantTvaLigne'];
|
|
$libRemiseTab[$l]=$tabResult['typeReducLigne'];
|
|
$montantReducLigneTab[$l]=$tabResult['montantReducLigne'];
|
|
$ttcLignesTab[$l]=$tabResult['totTtcLigne'];
|
|
$nbArt=$nbArt+$qteLigneTab[$l];
|
|
|
|
|
|
if (isset($debug[2]) && $debug[2] == '1' ) {
|
|
monDebug (2, [
|
|
'prixUnitRemiseHtTab' => $prixUnitRemiseHtTab[$l],
|
|
'libRemiseTab' => $libRemiseTab[$l],
|
|
'montantReducLigneTab' => $montantReducLigneTab[$l],
|
|
'qteLigneTab' => $qteLigneTab[$l],
|
|
'ttcLignesTab' => $ttcLignesTab[$l]
|
|
],'');
|
|
}
|
|
$l++;
|
|
} //while
|
|
$nbLignes=count($idPrdTab);
|
|
}
|
|
else {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Remarque : pas de lignes de commandes pour la commande n°' => $idCde], '');}
|
|
}
|
|
|
|
$tableau=array();
|
|
$lienImagePt=array();
|
|
if (isset($idPrdTab) && count($idPrdTab)>0 ) {
|
|
for($i=0; $i<count($idPrdTab); $i++) {
|
|
// -----------------------------------------------------
|
|
// Recupère image
|
|
// -----------------------------------------------------
|
|
|
|
|
|
$reqSelect="SELECT produits.refPrd, produits.lienImagePt, produitslibelle.nomPrd FROM `produits`, `produitslibelle` WHERE produits.idPrd=" .$idPrdTab[$i]. " AND produits.idPrd=produitslibelle.idPrd AND produitslibelle.idLg='" .$lg. "' ;";
|
|
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (2, ['reqSelect' => $reqSelect ],'');}
|
|
|
|
try{
|
|
$resConn2=$idPdo->query($reqSelect);
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['result' => $result], '');}
|
|
$tableau=$resConn2->fetch(PDO::FETCH_ASSOC);
|
|
// echo '<br> var dump'.var_dump($tableau). '<br>';
|
|
$nomPrdTab[$i]=$tableau['nomPrd'];
|
|
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (2, ['nomPrdTab' => $nomPrdTab[$i] ],'');}
|
|
$suite .='<li>' .$nomPrdTab[$i]. ' (' .$qteLigneTab[$i]. ' )';
|
|
|
|
if (isset($tableau['lienImagePt'])) $lienImagePt[$i]=$tableau['lienImagePt'];
|
|
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (2, ['lienImagePt' => $lienImagePt[$i] ],'');}
|
|
$suite .='  <img src="../.' .$lienImagePt[$i]. '" style="max-width:90px;" /></li>';
|
|
|
|
$refPrdTab[$i]=$tableau['refPrd'];
|
|
if (isset($lienImagePt[$i]) && $lienImagePt[$i]!="-" && !empty($lienImagePt) ) {
|
|
$lienImagePt[$i]=str_replace( "./", "", $lienImagePt[$i]);
|
|
$lienImagePt[$i]=$_SESSION['server']. '/' .$lienImagePt[$i];
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Recup Options
|
|
// -----------------------------------------------------
|
|
$reqSelect2="SELECT libTraduit, quantite, prixTotTTC, prixTotHT, tvaMontant FROM `prdOptions` WHERE idCde=" .$idCde. " and idPrd=" .$idPrdTab[$i]. " ;";
|
|
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (2, ['reqSelect2' => $reqSelect2 ],'');}
|
|
$resConn4='';
|
|
$resConn4=$idPdo->query($reqSelect2);
|
|
if ($resConn4) {
|
|
$o=0;
|
|
while($resultOpt=$resConn4->fetch(PDO::FETCH_ASSOC)) {
|
|
$libTraduit[$i][$o]=$resultOpt['libTraduit'];
|
|
$quantite[$i][$o]=$resultOpt['quantite'];
|
|
|
|
$prixTotTTC[$i][$o]=$resultOpt['prixTotTTC'];
|
|
$prixTotTTC[$i][$o]=formatNB($prixTotTTC[$i][$o], $lg);
|
|
|
|
$prixTotHT[$i][$o]=$resultOpt['prixTotHT'];
|
|
$prixTotHT[$i][$o]=formatNB($prixTotHT[$i][$o], $lg);
|
|
|
|
$tvaMontant[$i][$o]=$resultOpt['tvaMontant'];
|
|
$tvaMontant[$i][$o]=formatNB($tvaMontant[$i][$o], $lg);
|
|
$o++;
|
|
}
|
|
}
|
|
else {
|
|
$admMsg .= "Echec select options. ";
|
|
$admMsgClass='ko';
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Message suite
|
|
// -----------------------------------------------------
|
|
if (!empty($libTraduit[$i])) {
|
|
$suite .="<ul>";
|
|
for($o=0;$o<count($libTraduit[$i]);$o++) {
|
|
$suite .="<li>" .$quantite[$i][$o]. " " .$libTraduit[$i][$o]. " " .$prixTotTTC[$i][$o]. "</li>";
|
|
}
|
|
$suite .="</ul>";
|
|
}
|
|
|
|
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (2, ['nomPrdTab' => $nomPrdTab[$i] ],'');}
|
|
|
|
// -----------------------------------------------------
|
|
// lignes
|
|
// -----------------------------------------------------
|
|
// $prixUnitRemiseHtTab[$l]=formatNB($prixUnitRemiseHtTab[$l],$lg);
|
|
// $montantTvaLigneTab[$l]=formatNB($montantTvaLigneTab[$l],$lg);
|
|
// $montantReducLigneTab[$l]=formatNB($montantReducLigneTab[$l],$lg);
|
|
// $ttcLignesTab[$l]=formatNB($ttcLignesTab[$l],$lg);
|
|
// $nbArt=$nbArt+$qteLigneTab[$l];
|
|
}
|
|
catch (Exception $e) {
|
|
echo 'Exception =' .$e;
|
|
}
|
|
} //for
|
|
}
|
|
}
|
|
else {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Pas de lignes pour la commande n°' => $idCde], '');}
|
|
$admMsgClass='ko';
|
|
}
|
|
}
|
|
else {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Pas de N° de commande' => $idCde], '');}
|
|
$admMsgClass='ko';
|
|
}
|
|
$suite .='</ul>';
|
|
|
|
if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug (2, ['SUITE' => $suite ],'');
|
|
?>
|