372 lines
17 KiB
PHP
Executable File
372 lines
17 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
|
|
// -----------------------------------------------------
|
|
// Cartouche
|
|
// -----------------------------------------------------
|
|
// Auteur : eric
|
|
// datemaj : 11/07/2025
|
|
// Fonction : Gestion des articles
|
|
// Algo : selon le filtre on requete un recordset, on affiche un produit, on peut se déplacer dans le recordset avec les fleches
|
|
// A terme => passer en objet ou à minima en session pour arreter de faire des requets a tout va
|
|
|
|
// -----------------------------------------------------
|
|
// Init var
|
|
// -----------------------------------------------------
|
|
include ("art.init.php");
|
|
|
|
// -----------------------------------------------------
|
|
// Post
|
|
// -----------------------------------------------------
|
|
include ("art.post.php");
|
|
|
|
if (isset($_FILES["fileToUpload"]["tmp_name"]) && $_FILES["fileToUpload"]["tmp_name"]!='') {
|
|
$target_dir = "../Catalogue/_notices/";
|
|
$targetExtension =['pdf'];
|
|
$targetSize ='5242880'; //5 Mo
|
|
$largeurMax = 0;
|
|
$hauteurMax = 0;
|
|
$largeurMin = 0;
|
|
$hauteurMin = 0;
|
|
include ($includePathAdmin. "/_fonctions/uploadGenerique.php");
|
|
$lienNotice=$theFichier;
|
|
}
|
|
else
|
|
{if (isset($debug[1]) && $debug[1] == '1' ) $debugMsg .= monDebug(1, ['upload' => 'Non'],''); }
|
|
|
|
// if (isset($debug[1]) && $debug[1] == '1' ) {include ("./catalog/articles/art.debug.php"); }
|
|
|
|
// -----------------------------------------------------
|
|
// Requêtes Update
|
|
// -----------------------------------------------------
|
|
if ($codeOpe=="majA") {include ("./catalog/req/reqUpdatePrd.php"); }
|
|
else if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug(1, ["maj article" =>'Non'],''); }
|
|
|
|
if ($codeOpe=="activPrd") include ("./catalog/req/reqActPrd.php");
|
|
|
|
if ($codeOpe=="desactivPrd") include ("./catalog/req/reqDesactivProduit.php");
|
|
|
|
if ($codeOpe=="deleteNotice") include ("./catalog/req/reqDeleteNotice.php");
|
|
|
|
if ($codeOpe=="majG") include ("./catalog/req/updateGondole.php");
|
|
|
|
// ------------------------------------------------------
|
|
// si on a activé :
|
|
// - le filtre categories
|
|
// - ou le filtre sous categories
|
|
// - ou le filtre refPrd -> 1 seul
|
|
// - ou le filtre nomPrd -> 1seul
|
|
// ==> recherche specifique qui générent un recordset
|
|
// sinon
|
|
// - recherche sur categories avec un recordset
|
|
|
|
// avec alimentation des liste des catégories / nom / references selon le filtre
|
|
|
|
// ------------------------------------------------------
|
|
// garder la liste des catégories et articles sous jacent dans les combo deroulantes
|
|
// ------------------------------------------------------
|
|
if (!empty ($_SESSION['tabLibPrd'])) {$tabLibPrd=$_SESSION['tabLibPrd'];}
|
|
if (!empty ($_SESSION['tabIdPrd'])) {$tabIdPrd=$_SESSION['tabIdPrd'];}
|
|
if (!empty ($_SESSION['tabRefPrd'])) {$tabRefPrd=$_SESSION['tabRefPrd'];}
|
|
|
|
$all=1;
|
|
|
|
// Chaque filtre ramène un recordset de produits
|
|
if ($codeOpe=="cat") {include ("./catalog/req/reqSelectPrdFromCategories.php"); $all=0; }
|
|
|
|
if ($codeOpe=="sousCat") {
|
|
include ("./catalog/req/reqSelectPrdFromSousCat.php");
|
|
$all=0;
|
|
$_SESSION['tabLibPrd']=$tabLibPrd;
|
|
$_SESSION['tabIdPrd']=$tabIdPrd;
|
|
$_SESSION['tabRefPrd']=$tabRefPrd;
|
|
$codeOpeDeplacement='';
|
|
}
|
|
|
|
if ($codeOpe=="ref") {$codeOpeDeplacement=''; include ("./catalog/req/reqSelectPrdByRef.php"); $all=0; }
|
|
|
|
if ($codeOpe=="nom") {
|
|
// Pour la recherche par nom, en fait on utilise idPrd comme value depuis la liste deroulante select
|
|
if (!empty($nomPrdRech)) {$idPrdRech=$nomPrdRech;} else $idPrdRech=$idPrd;
|
|
$all=0;
|
|
$codeOpeDeplacement='';
|
|
}
|
|
|
|
// sinon recupérer sur premiere famille par defaut
|
|
//titi2026 ici pb pas premiere famille faire autre choix
|
|
if ($codeOpeDeplacement !='plus' && $codeOpeDeplacement !='moins' && $codeOpe=="" && empty($idPrdRech) ) {
|
|
if ($all==1 || $erreurSQL==1 ) {
|
|
if(empty($idFamRech)) $idFamRech=1;
|
|
include ("./catalog/req/reqSelectPrdFromCategories.php");
|
|
}
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// requete finale : 1 prd dans le recordset (idPrdRech) ou le suivant selon les fleches
|
|
// -----------------------------------------------------
|
|
include ("./catalog/req/reqSelectPrd.php");
|
|
|
|
// -----------------------------------------------------
|
|
// debug
|
|
// -----------------------------------------------------
|
|
if (isset($debug[1]) && $debug[1] == '1' ) {include ("art.debug.php");}
|
|
|
|
// ------------------------------------------------------
|
|
// Formulaire articles
|
|
// ------------------------------------------------------
|
|
echo '<form method="POST" name="fArt" id="fArt" enctype="multipart/form-data" >';
|
|
|
|
// ------------------------------------------------------
|
|
// Boite de recherche
|
|
// ------------------------------------------------------
|
|
echo '<div id="zoneRechercheWbm" style="top:138px">';
|
|
|
|
// -----------------------------------------------------
|
|
// List box langues
|
|
// -----------------------------------------------------
|
|
echo '<span>';
|
|
if ($_SESSION['nbLgActives']>1) {
|
|
$lgLien="affAdmin=8&ongletCatalog=4&affLv=" .$affOngArt. "&idFam=" .$idFam. "&idPrdRech=" .$idPrd. "&codeOpe=" .$codeOpe;
|
|
include ($includePathAdmin. "/drapeaux/drapeauxListBox.php");
|
|
}
|
|
echo '</span>';
|
|
|
|
// ------------------------------------------------------
|
|
// Champs cachés
|
|
// ------------------------------------------------------
|
|
include ("./catalog/req/reqMaxPrd.php");
|
|
echo '<input type="hidden" id="mxPrd" value="' .$mxPrd. '" />';
|
|
echo '<input type="hidden" id="affOngArt" name="affOngArt" value="' .$affOngArt. '" />';
|
|
echo '<input type="hidden" id="codeOpe" name="codeOpe" value="' .$codeOpe. '" />';
|
|
echo '<input type="hidden" id="codeOpeDeplacement" name="codeOpeDeplacement" value="' .$codeOpeDeplacement. '" />';
|
|
echo '<input type="hidden" id="idPrd" name="idPrd" value="' .$idPrd. '" />';
|
|
echo '<input type="hidden" id="idPrdRech" name="idPrdRech" value="' .$idPrdRech. '" />';
|
|
|
|
// ------------------------------------------------------
|
|
// Filtre Categories ( ancien familles )
|
|
// ------------------------------------------------------
|
|
include ("./catalog/articles/reqCategories.php");
|
|
echo '<span class="actionMessages" > Filtre par catégorie : ';
|
|
echo '<select class="selectWbm" name="idFamRech" id="idFamRech" onChange="rechercherParFam();" >';
|
|
for($i=0; $i<count($tabIdFam); $i++) {
|
|
if ($idFamRech==$tabIdFam[$i] )
|
|
{echo '<option value="' .$tabIdFam[$i]. '" selected>' .$tabNomFam[$i]. '</option>'; $libFam=$tabNomFam[$i];}
|
|
else
|
|
{echo '<option value="' .$tabIdFam[$i]. '">' .$tabNomFam[$i]. '</option>'; }
|
|
}
|
|
echo '<option value="0" >--- Pas de filtre ---</option>';
|
|
echo '</select></span>';
|
|
|
|
// ------------------------------------------------------
|
|
// Filtre par sous-categories
|
|
// ------------------------------------------------------
|
|
if ($_SESSION['afficherSousCat']==1) {
|
|
include ("./catalog/req/reqSelectLibellesSousCatFrom.php");
|
|
echo '<span class="actionMessages">  Filtre par sous-catégories : ';
|
|
|
|
echo '<select class="selectWbm" name="idCatRech" id="idCatRech" onChange="rechercherParSousCat();" >';
|
|
for($i=0; $i<count($tabIdSousCat); $i++) {
|
|
if ($idCatRech==$tabIdSousCat[$i])
|
|
{echo '<option value="' .$tabIdSousCat[$i]. '" selected>' .$tabLibSousCat[$i]. '</option>'; }
|
|
else
|
|
{echo '<option value="' .$tabIdSousCat[$i]. '">' .$tabLibSousCat[$i]. '</option>'; }
|
|
}
|
|
if ($idCatRech==0) echo '<option value="0" selected>--- Pas de filtre ---</option>';
|
|
else echo '<option value="0">--- Pas de filtre ---</option>';
|
|
echo '</select></span>';
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// Par reference
|
|
// ------------------------------------------------------
|
|
if ($_SESSION['affRef']==1) {
|
|
echo '<span class="actionMessages">  Filtre par référence : ';
|
|
echo '<select class="selectWbm" name="idRefRech" id="idRefRech" onChange="rechercherParRef();" >';
|
|
for($i=0; $i<count($tabRefPrd); $i++) {
|
|
if ($idRefRech==$tabRefPrd[$i] || $refPrd==$tabRefPrd[$i] )
|
|
{echo '<option value="' .$tabRefPrd[$i]. '" selected>' .$tabRefPrd[$i]. '</option>'; }
|
|
else
|
|
{echo '<option value="' .$tabRefPrd[$i]. '">' .$tabRefPrd[$i]. '</option>'; }
|
|
}
|
|
if ($idRefRech==0) echo '<option value="0" selected>--- Pas de filtre ---</option>';
|
|
else echo '<option value="0">--- Pas de filtre ---</option>';
|
|
echo '</select></span>';
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// Rechercher par nom
|
|
// ------------------------------------------------------
|
|
echo '<span class="actionMessages"> Filtre par nom : ';
|
|
echo '<select class="selectWbm" name="nomPrdRech" id="nomPrdRech" onChange="rechercherParNom();" >';
|
|
for($i=0; $i<count($tabLibPrd); $i++) {
|
|
if ($nomPrdRech==$tabIdPrd[$i])
|
|
{echo '<option value="' .$tabIdPrd[$i]. '" selected>' .$tabLibPrd[$i]. '</option>'; }
|
|
else
|
|
{echo '<option value="' .$tabIdPrd[$i]. '">' .$tabLibPrd[$i]. '</option>'; }
|
|
}
|
|
if ($nomPrdRech==0) echo '<option value="0" selected>--- Pas de filtre ---</option>';
|
|
else echo '<option value="0">--- Pas de filtre ---</option>';
|
|
echo '</select></span>';
|
|
|
|
// ------------------------------------------------------
|
|
// Nombres d'articles trouvés
|
|
// ------------------------------------------------------
|
|
echo ' <span class="informationsTechValue" >';
|
|
echo '    '; if (isset($tabIdPrd)) {$admMsg .= count($tabIdPrd). ' article(s) trouvé(s).<br>'; }
|
|
echo '</span>';
|
|
|
|
// ------------------------------------------------------
|
|
// Btn ajouter
|
|
// ------------------------------------------------------
|
|
echo ' <div class="boutonsWebmaster" onClick="window.self.location=\'./frmModale.php?affModale=84-1\';" >';
|
|
echo '<i class="fad fa-plus"></i>  ';
|
|
echo 'Ajouter un article';
|
|
echo '</div>';
|
|
echo '</div>';
|
|
|
|
// ------------------------------------------------------
|
|
// Afficher Nom PRD + image + corbeille
|
|
// ------------------------------------------------------
|
|
echo '<div id="zoneFormWbm" style="z-index:11">';
|
|
|
|
// -----------------------------------------------------
|
|
// Image + nom + deplacements
|
|
// -----------------------------------------------------
|
|
echo '<div style="width:100%; vertical-align:top; display:flex; flex-direction:row; flex-wrap:wrap; border-top: 2px solid #dcdcdc; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(255, 255, 255, 0.9); padding:10px; margin-top:5px; margin-bottom:5px" >';
|
|
|
|
// -----------------------------------------------------
|
|
// N° prd
|
|
// -----------------------------------------------------
|
|
echo '<span style="color:black; font-size:1rem; vertical-align:top;" >N° ' .$idPrd. '';
|
|
|
|
// -----------------------------------------------------
|
|
// Statut + delete
|
|
// -----------------------------------------------------
|
|
switch ($statusPrd) {
|
|
case 0:
|
|
$libStatusPrd ="Article " .$idPrd. " désactivé";
|
|
break;
|
|
|
|
case 1:
|
|
$libStatusPrd ="Article " .$idPrd. " activé";
|
|
break;
|
|
}
|
|
if ($statusPrd==1)
|
|
{echo '  <span class="activStatus" title="Désactiver l\'article" name="statusPrd" id="statusPrd" onClick="desactivPrd(' .$idPrd. ');" style="cursor:pointer; vertical-align:middle;">' .$libStatusPrd. '</span>'; }
|
|
else
|
|
{echo '  <span class="desactivStatus" title="Cliquez pour activer l\'article" onClick="activPrd(' .$idPrd. ');" name="statusPrd" id="statusPrd" style="cursor:pointer; vertical-align:middle;" >' .$libStatusPrd. '</span>'; }
|
|
echo '</span>';
|
|
|
|
// -----------------------------------------------------
|
|
// Déplacements dans le recordset : flèches
|
|
// -----------------------------------------------------
|
|
echo '<div style="display: flex; justify-content: center; align-items: center; cursor:pointer" >';
|
|
echo '<i class="fad fa-left fa-4x" style="font-size:2rem !important" onClick="previousArt();" ></i>';
|
|
echo '<span style="color:blue">Précédent  </span>';
|
|
echo '</div>';
|
|
|
|
// -----------------------------------------------------
|
|
// Image
|
|
// -----------------------------------------------------
|
|
echo '<span style="text-align:center;" title="Cliquez sur l\'image pour la modifier" >';
|
|
if ($lienImgPrdPt!='' && $lienImgPrdPt!='-') {
|
|
echo '<img src=".' .$lienImgPrdPt. '" class="imgCatalogue" style="width:170px; height:170px;" onClick="window.self.location=\'./frmModale.php?affModale=84-3&idPrd=' .$idPrd. '\';" />';
|
|
}
|
|
else {
|
|
echo '<img src="../Catalogue/_parDefaut/pasImgDefaut.png" style="width:170px; height:170px; border-radius:100%; border:1px solid lightgrey;padding:5px;" onClick="window.self.location=\'./frmModale.php?affModale=84-3&idPrd=' .$idPrd. '\';" />';
|
|
}
|
|
echo '</span>';
|
|
|
|
// -----------------------------------------------------
|
|
// Déplacements dans le recordset : flèches
|
|
// -----------------------------------------------------
|
|
echo '<div style="display: flex; justify-content: center; align-items: center; cursor:pointer" >';
|
|
echo '<i class="fad fa-right fa-4x" style="font-size:2rem !important" onClick="nextArt();" ></i>';
|
|
echo '<span style="color:blue">Suivant</span>';
|
|
echo '</div>';
|
|
|
|
// -----------------------------------------------------
|
|
// Nom article
|
|
// -----------------------------------------------------
|
|
$title='Nom article';
|
|
echo '<span style=" color:black; text-align:left;" title="' .$title. '" >';
|
|
echo '  Nom : ';
|
|
echo '<input type="text" id="nomPrd size="4" class="inputWebmaster" style="font-size:1.1rem; font-weight:bold;" name="nomPrd" value="' .$nomPrd. '" onChange="updatePrd();" >';
|
|
echo '</span>';
|
|
|
|
// -----------------------------------------------------
|
|
// Référence
|
|
// -----------------------------------------------------
|
|
$title='Référence';
|
|
echo '<span style="color:black; ; text-align:left;" title="' .$title. '" >';
|
|
if ($_SESSION['affRef']==1) {
|
|
echo '  Référence : ';
|
|
echo '<input type="text" class="inputWebmaster" size="8" style="font-size:1rem; padding:2px;" name="refPrd" id="refPrd" value="' .$refPrd. '" onChange="updatePrd();" >';
|
|
}
|
|
echo '</span>';
|
|
|
|
// -----------------------------------------------------
|
|
// delete
|
|
// -----------------------------------------------------
|
|
echo '<span class="activation" style="margin:10px;" >';
|
|
echo '    ';
|
|
echo '<span title="Supprimer / désactiver un article" >';
|
|
echo '<i class="fad fa-trash-alt" style="color:red; fill:red; cursor:pointer;" onClick="window.self.location=\'./frmModale.php?affModale=84-2&idPrd=' .$idPrd. '\';"></i>';
|
|
echo '</span>';
|
|
echo '</span>';
|
|
echo '</div>';
|
|
|
|
// -----------------------------------------------------
|
|
// Afficher sous-onglets
|
|
// -----------------------------------------------------
|
|
$title='';
|
|
echo '<div id="menuOnglets" style="grid-column:1 /span 2; display:flex; width:100%; flex-wrap:wrap; justify-content: space-evenly;" class="flexToColumn">';
|
|
require_once("./catalog/articles/sousOnglets.php");
|
|
echo $sousOnglets;
|
|
echo '</div>';
|
|
|
|
// -----------------------------------------------------
|
|
// Afficher chaque page de caracteristiquesDet
|
|
// -----------------------------------------------------
|
|
echo '<div class="conteneurArticle" style="display:flex; flex-direction:column; flex-wrap:wrap; grid-column:1 /span 2;width:100%; padding:0px; margin:0px;" >';
|
|
switch ($affOngArt) {
|
|
// description
|
|
case 1:
|
|
$src="./catalog/articles/art.description.php";
|
|
break;
|
|
|
|
// caracteristiques principales
|
|
case 2:
|
|
$src="./catalog/articles/art.caracteristiquesPpales.php";
|
|
break;
|
|
|
|
// prix
|
|
case 3:
|
|
$src="./catalog/articles/art.prix.php";
|
|
break;
|
|
|
|
// caracteristiques detailles
|
|
case 4:
|
|
$src="./catalog/articles/art.caracteristiquesDet.php";
|
|
break;
|
|
|
|
// caracteristiques dynamiques
|
|
case 5:
|
|
$src="./catalog/articles/art.caracteristiquesDyn.php";
|
|
break;
|
|
|
|
// notice
|
|
case 6:
|
|
$src="./catalog/articles/art.notice.php";
|
|
break;
|
|
|
|
default:
|
|
$src="./catalog/articles/art.description.php";
|
|
break;
|
|
}
|
|
include ($src);
|
|
echo '</div>';
|
|
echo '</div>'; // zoneForm
|
|
|
|
echo '</form>';
|
|
?>
|