alpha_full/pages/produits/recherche.php
2026-04-06 22:58:51 +02:00

159 lines
9.4 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
// ---------------------------------------------------
// Cas de recherche
// $typeDeRecherche==0 => tous
// $typeDeRecherche==1 => gondoles
// $typeDeRecherche==2 => promos
// $typeDeRecherche==3 => nouveautés
// $typeDeRecherche==4 => categories ( ancien familles )
// $typeDeRecherche==5 => sous categories
// $typeDeRecherche==6 => nomPrd
// $typeDeRecherche==7 => references
if ($typeDeRecherche==0) {$idCat='';$nomPrd='';$ref='';}
if ($typeDeRecherche==1) {$idCat='';$nomPrd='';$ref='';}
if ($typeDeRecherche==2) {$idCat='';$nomPrd='';$ref='';}
if ($typeDeRecherche==4) {$idCat='';$nomPrd='';$ref='';}
if ($typeDeRecherche==5) {$nomPrd='';$ref='';}
if ($typeDeRecherche==6) {$idCat='';$ref='';}
if ($typeDeRecherche==6 && $nomPrd=='') {$typeDeRecherche=0;$idCat='';$ref='';}
if ($typeDeRecherche==7) {$idCat='';$nomPrd='';}
echo '<form name="recherche" id="recherche" method="POST" action="recherche" style="display:grid; grid-column:1 / span 4; grid-row:2" >';
// ---------------------------------------------------
// Titre de la page
// ---------------------------------------------------
dynamiqItemImage (0, 0, 'titresCat', 'span', '-action-','menu', 5, 'icones', '-textClass-','-varStyle-');
if ( $affMContext === true ) echo '<div class="tableCatalogue" style=" grid-column:1 / span 2; width:99%; max-width:99%; height:auto; cursor:context-menu" ' .$mouseOverMenuContextContainer. ' onContextMenu="return mConStyle(this, \'Catalogue\', \'tableCatalogue\', 2, \'catalog\', 1, 11 , event);" >';
else echo '<div class="tableCatalogue" style=" grid-column:1 / span 2; width:99%; max-width:99%; height:auto;" >';
dynamiqItemMessage( 0, 0, 'msgCatalogue', '-', 'span', 'msgCatalogue', '-action-', 'catalog', 20, '-');
// ---------------------------------------------------
// Champs cachés
// ---------------------------------------------------
echo '<input type="hidden" name="typeDeRecherche" id="typeDeRecherche" value="' .$typeDeRecherche. '" />';
echo '<input type="hidden" name="afficheRes" id="afficheRes" value="oui" />';
// ---------------------------------------------------
// Liste deroulante catégories
// ---------------------------------------------------
// if ($_SESSION['afficherSousCat']==1) {
dynamiqItemMessage(0, 1, 'libCatalogueCell', '-styleDiv-', 'span', 'libCatalogue', '-action-', 'catalog', 12, '-' );
if ( $affMContext === true ) echo '<div class="champsCatalogueCell" style="cursor:context-menu" ' .$mouseOverMenuContextContainer. ' onContextMenu="return mConStyle(this, \'Catalogue\', \'champsCatalogueCell\', 10, \'catalog\', 1, 12 , event);" >';
else echo '<div class="champsCatalogueCell" >';
$reqSelect="SELECT F.idFam, FL.libelle FROM familles AS F JOIN `familleslibelle` AS FL ON F.idFam = FL.idFam WHERE FL.idLg=:lg AND F.status=1 ORDER by F.idFam;";
$stmt = $idPdo->prepare($reqSelect);
$stmt->bindValue(':lg', $lg, PDO::PARAM_STR);
$stmt->execute();
$reqDebug = str_replace( [':lg'], [ $idPdo->quote($lg) ], $reqSelect );
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug(1, ['Requête liste déroulante catégories' => $reqDebug ],'recherche.php');}
echo '<span>';
if ( $affMContext === true ) echo '<select class="listeDeroulanteCat" name="idFam" id="idFam" onChange="typeRech(\'Cat\');" style="cursor:context-menu" ' .$mouseOverMenuContextContainer. ' onContextMenu="return mConStyle(this, \'Catalogue\', \'listeDeroulanteCat\', 15, \'catalog\', 1, 12 ,event);" >';
else echo '<select class="listeDeroulanteCat" name="idFam" id="idFam" onChange="typeRech(\'Fam\');" >';
$o=0;
while ($tabResult = $stmt->fetch(PDO::FETCH_ASSOC)) {
$idFamTab[$o]=$tabResult['idFam'];
$libFamTab[$o]=$tabResult['libelle'];
if ($idFam==$tabResult['idFam']) {
echo '<option value="' .$idFamTab[$o]. '" " selected>' .$libFamTab[$o]. '</option>';
}
else {
echo '<option value="' .$idFamTab[$o]. '" >' .$libFamTab[$o]. '</option>';
}
// if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .='<br> $idFamTab[$o] = ' .$idFamTab[$o]. '';}
// if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .=' $libFamTab[$o] = ' .$libFamTab[$o]. '';}
$o++;
}
echo '</select>';
echo '</span>';
echo '</div>';
// }
// else {
// if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug(1, ['$_SESSION[afficherSousCat]' => $_SESSION['afficherSousCat'] ],'recherche.php');}
// }
// ---------------------------------------------------
// Liste deroulante / saisie nomPrd
// ---------------------------------------------------
dynamiqItemMessage(0, 1, 'libCatalogueCell', '-styleDiv-', 'span', 'libCatalogue', '-action-', 'catalog', 13, '-' );
if ( $affMContext === true ) echo '<div class="champsCatalogueCell" data-tooltip="' .$catalogTitle[14]. '" style="cursor:context-menu" ' .$mouseOverMenuContextContainer. ' onContextMenu="return mConStyle(this, \'Catalogue\', \'champsCatalogueCell\', 10, \'catalog\', 1, 13 ,event);" >';
else echo '<div class="champsCatalogueCell" data-tooltip="' .$catalogTitle[14]. '" >';
if (isset($nomPrd) && $nomPrd!='undefined' ) echo '<input onChange="typeRech(\'NomPrd\');" class="champsCatalogue" name="nomPrd" type="text" id="nomPrd" value="' .$nomPrd. '" onKeyPress="if (event.keyCode == 13) {typeRech(\'NomPrd\');}" >';
else echo '<input onChange="typeRech(\'NomPrd\');" class="champsCatalogue" name="nomPrd" type="text" id="nomPrd" value="" placeHolder="ex : art" onKeyPress="if (event.keyCode == 13) {typeRech(\'NomPrd\');}" >';
echo '</div>';
// ---------------------------------------------------
// Si on veut une liste déroulante produits
// ---------------------------------------------------
// if (isset($debug[2]) && $debug[2] == '1' ) {echo 'reqSelect = ' .$reqSelect. '<br>';}
// $resConn=$idPdo->query($reqSelect);
// if (isset($debug[2]) && $debug[2] == '1' ) {echo 'resConn = ' .$resConn. '<br>';}
// echo '<select onChange="viderRefetType();" class="listeDeroulanteCat" name="nomPrd" id="nomPrd" style="width:300px;" size="1" >';
// $o=0;
// echo '<option class="listeDeroulanteCat" value="" name=""></option>';
// while ($tabResult=$resConn->fetch(PDO::FETCH_ASSOC))
// { $o++;
// if ($nomPrd==$tabResult[$o])
// {echo '<option value="' .$tabResult['nomPrd']. '" name="' .$tabResult[$o]. '" selected>' .$tabResult['nomPrd']. '</option>';
// $ref="";
// }
// else
// {echo '<option value="' .$tabResult['nomPrd']. '" name="' .$tabResult[$o]. '">' .$tabResult['nomPrd']. '</option>';}
// }
// if ($nomPrd==='')
// {echo '<option value="" name="nomPrd" selected></option>';
// }
// else {$ref='';}
// echo '</select>';
// ---------------------------------------------------
// Liste deroulante ref
// ---------------------------------------------------
if ($_SESSION['affRef']==1) {
dynamiqItemMessage(0, 1, 'libCatalogueCell', '-styleDiv-', 'span', 'libCatalogue', '-action-', 'catalog', 14, '-' );
if ( $affMContext === true ) echo '<div class="champsCatalogueCell" data-tooltip="' .$catalogTitle[16]. '" style="cursor:context-menu" ' .$mouseOverMenuContextContainer. ' onContextMenu="return mConStyle(this, \'Catalogue\', \'champsCatalogueCell\', 10, \'catalog\', 1, 14 ,event);" >';
else echo '<div class="champsCatalogueCell" data-tooltip="' .$catalogTitle[16]. '" >';
$reqSelect="SELECT refPrd from `produits` where statusPrd=1 order by refPrd;";
if (isset($debug[2]) && $debug[2] == '1' ) {$debugMsg .= monDebug(1, ['reqSelect' => $reqSelect ],'recherche.php');}
$tabResult=array();
$resConn='';
$resConn=$idPdo->query($reqSelect);
$o=0;
if ( $affMContext === true ) echo '<select onchange ="typeRech(\'Ref\');" class="listeDeroulanteCat" name="ref" id="ref" onKeyPress="if (event.keyCode == 13) {typeRech(\'Ref\');}" style="cursor:context-menu" ' .$mouseOverMenuContextContainer. ' onContextMenu="return mConStyle(this, \'Catalogue\', \'listeDeroulanteCat\', 15, \'catalog\', 1, 11 ,event);" >';
else echo '<select onchange ="typeRech(\'Ref\');" class="listeDeroulanteCat" name="ref" id="ref" onKeyPress="if (event.keyCode == 13) {typeRech(\'Ref\');}" >';
if ($ref=="-" || $ref=="") echo '<option value="-" selected>Aucune</option>';
while ($tabResult=$resConn->fetch(PDO::FETCH_ASSOC)) {
$o++;
if ($ref===$tabResult['refPrd'])
{echo '<option value="' .$tabResult['refPrd']. '" selected>' .$tabResult['refPrd']. '</option>';}
else
{echo '<option value="' .$tabResult['refPrd']. '" >' .$tabResult['refPrd']. '</option>';}
}
if ($ref==='') {echo '<option value="" name="ref" selected></option>';}
echo '</select>';
echo '</div>';
}
// ---------------------------------------------------
// Bouton valider
// ---------------------------------------------------
dynamiqItemImage (0, 0, 'boutons', 'span', 'onClick="document.recherche.submit();"', 'bouton', 6, 'icones', '-textClass-','grid-column:1 / span 2;margin:auto; max-width:29%; margin-top:10px;');
echo '</div>'; //tableCatalogue
// echo '</div>'; //page
echo '</form>';
$p=0;
$cpt_tr=0;
if ($afficheRes=='oui') {
include ("./pages/produits/gondole_accueil.php");
}
?>