89 lines
3.8 KiB
PHP
Executable File
89 lines
3.8 KiB
PHP
Executable File
<?php
|
|
// Cette requete est utilisée à la fois dans le treeviewPage_Cat.php et dans articles.
|
|
// Dans treeview on a besoin de tous les tableaux, on les parcours
|
|
// Dans articles uniquement tabIdPrd, on fera un select detaillé sur un des produit du recordset ( on parcours pas les tableaux entierement )
|
|
|
|
if(isset($idCatRech)) {
|
|
$tabResult= dynRequete_select('SELECT', 'produits as P JOIN produitslibelle as PL on P.idPrd=PL.idPrd', ['P.idPrd', 'P.refPrd', 'P.lienImagePt', 'P.gondole', 'PL.nomPrd'], ['P.idCat' =>$idCatRech, 'PL.idLg' => $lg ], 'ORDER by P.idPrd asc', 'reqSelectPrdFromSousCat.php', 0, 0,'tabResult');
|
|
if ($tabResult) {
|
|
$tabIdPrd=array();
|
|
$tabLibPrd=array();
|
|
$tabRefPrd=array();
|
|
$lienImgPrdPt=Array();
|
|
$tabGondole=Array();
|
|
foreach ($tabResult as $i => $row) {
|
|
$tabIdPrd[$i] = $row['idPrd'];
|
|
$tabRefPrd[$i] = $row['refPrd'];
|
|
$lienImgPrdPt[$i] = $row['lienImagePt'];
|
|
$tabGondole[$i] = $row['gondole'];
|
|
|
|
$tabLibPrd[$i] = $row['nomPrd'];
|
|
if ($i==0) {$idPrdRech=$tabIdPrd[0];}
|
|
}
|
|
$nbPrd=count($tabIdPrd);
|
|
$_SESSION['nbPrd']=$nbPrd;
|
|
$_SESSION['tabLibPrd']=$tabLibPrd;
|
|
$_SESSION['tabIdPrd']=$tabIdPrd;
|
|
$_SESSION['tabRefPrd']=$tabRefPrd;
|
|
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (1,['nbPrd categorie' => $nbPrd], '');}
|
|
}
|
|
else {
|
|
$admMsg .= "Pas de produits pour la sous-catégorie "; if (isset($tabLibSousCat[$c]) ) $admMsg .= $tabLibSousCat[$c]; $admMsg .= " ( ".$idCatRech." ) <br>"; $admMsgClass='ko';
|
|
}
|
|
}
|
|
else {
|
|
$admMsg .= "Pas de sous-catégorie pour la catégorie " .$idFam. "<br>"; $admMsgClass='ko';
|
|
}
|
|
|
|
|
|
|
|
// $reqSelect="SELECT idPrd, refPrd, lienImagePt, gondole FROM `produits` WHERE idCat=" .$idCatRech. " order by idPrd asc;";
|
|
// if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (2,['reqSelect' => $reqSelect, 'idCatRech' => $idCatRech ], 'reqSelectPrdFromSousCat.php');}
|
|
|
|
// if (!empty($idCatRech)) {
|
|
// $resConn = '';
|
|
// try{
|
|
// $resConn = $idPdo->query($reqSelect);
|
|
// if ($resConn) {
|
|
// // si la requête a fonctionné
|
|
// if ($resConn->rowCount() > 0) {
|
|
// // si la requête a retourné au moins un enregistrement
|
|
// $i = 0;
|
|
// while ($result = $resConn->fetch(PDO::FETCH_ASSOC)) {
|
|
// $tabIdPrd[$i] = $result['idPrd'];
|
|
// $tabRefPrd[$i] = $result['refPrd'];
|
|
// $lienImgPrdPt[$i] = $result['lienImagePt'];
|
|
// $tabGondole[$i] = $result['gondole'];
|
|
// if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug (2, ['idPrd' => $tabIdPrd[$i]], '','reqSelectPrdFromSousCat');}
|
|
// $idPrdRech = $tabIdPrd[$i];
|
|
// include ("reqSelectPrdLib.php");
|
|
// $tabLibPrd[$i] = $nomPrd;
|
|
// $i++;
|
|
// }
|
|
// $idPrdRech = $tabIdPrd[0];
|
|
// // $nbPrd = $i;
|
|
// if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug (1, ['idPrdRech' => $idPrdRech], '','reqSelectPrdFromSousCat');}
|
|
// }
|
|
// else {
|
|
// $admMsg .= "Nous sommes désolés, il n'y a pas d'articles trouvés avec cette sous-catégorie. Le filtre par défaut est activé.<br>";
|
|
// $admMsgClass='ko';
|
|
// if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug (1, ['Il est impossible de retrouver les données produit pour la sousCat : ' => $idCatRech], '');}
|
|
// $erreurSQL= 1;
|
|
// }
|
|
// }
|
|
// else {
|
|
// if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Pas de connection DB' => ''], '');}
|
|
// $admMsgClass = 'ko';
|
|
// $erreurSQL=1;
|
|
// }
|
|
// }
|
|
// catch (PDOException $e) {
|
|
// if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['PDO exception' => $e->getMessage()], '');}
|
|
// $erreurSQL=1;
|
|
// }
|
|
// }
|
|
// else $admMsg .= "Pas de sous catégorie pour la recherche"; $admMsgClass='ko';
|
|
|
|
|
|
|
|
?>
|