function ancien_rewrite_prod($ref, $lang = 1) { $prod = new Produit(); $prod->charger($ref); $proddesc = new Produitdesc(); if (!$proddesc->charger($prod->id, $lang)) { return ""; } $rubfinal = $prod->rubrique; if (function_exists('chemin_rub')) { $chem = chemin_rub($rubfinal); } else { $chem = chemin($rubfinal); } // 1.4.2.1 et avant if (!empty($chem)) { $rubriquedesc = new Rubriquedesc(); $listrub = ""; $rubriquedesc->charger($chem[count($chem) - 1]->rubrique, $lang); $listrub .= $rubriquedesc->titre . "_"; $rubriquedesc->charger($chem[0]->rubrique, $lang); $listrub .= $rubriquedesc->rubrique . "_"; for ($i = count($chem) - 2; $i >= 0; $i--) { $rubriquedesc->charger($chem[$i]->rubrique, $lang); $listrub .= $rubriquedesc->titre . "_"; } $listrub .= $proddesc->titre . "__" . $prod->ref . ".html"; return eregurl($listrub); } else { return ""; } }
function substitproduits($texte) { global $ref, $reforig, $motcle, $id_produit, $classement, $prixmin, $prixmax, $nouveaute, $promo, $stockmini; $tproduit = new Produit(); $tproduitdesc = new Produitdesc(); $url = ""; if ($ref) { $tproduit->charger($ref); } else { if ($id_produit) { $tproduit->charger_id($id_produit); } } if ($ref || $id_produit) { $tproduitdesc->charger($tproduit->id); $url = $tproduitdesc->getUrl(); } $texte = str_replace("#PRODUIT_URL", $url, $texte); $texte = str_replace("#PRODUIT_ID", $tproduit->id, $texte); $texte = str_replace("#PRODUIT_NOM", $tproduitdesc->titre, $texte); $texte = str_replace("#PRODUIT_CHAPO", $tproduitdesc->chapo, $texte); $texte = str_replace("#PRODUIT_DESCRIPTION", $tproduitdesc->description, $texte); $texte = str_replace("#PRODUIT_POSTSCRIPTUM", $tproduitdesc->postscriptum, $texte); $texte = str_replace("#PRODUIT_RUBRIQUE", $tproduit->rubrique, $texte); $texte = str_replace("#PRODUIT_CLASSEMENT", "{$classement}", $texte); $texte = str_replace("#PRODUIT_STOCKMINI", "{$stockmini}", $texte); $texte = str_replace("#PRODUIT_PRIXMIN", "{$prixmin}", $texte); $texte = str_replace("#PRODUIT_PRIXMAX", "{$prixmax}", $texte); $texte = str_replace("#PRODUIT_NOUVEAUTE", "{$nouveaute}", $texte); $texte = str_replace("#PRODUIT_PROMO", "{$promo}", $texte); $texte = str_replace("#PRODUIT_MOTCLE", $motcle, $texte); $texte = str_replace("#PRODUIT_REFORIG", "{$reforig}", $texte); $texte = str_replace("#PRODUIT_REF", $tproduit->ref, $texte); return $texte; }
function lister_accessoires($refproduit) { $produit = new Produit(); $produit->charger($_GET['ref']); $accessoire = new Accessoire(); $produita = new Produit(); $produitdesca = new Produitdesc(); $query = "select * from {$accessoire->table} where produit='{$produit->id}' order by classement"; $resul = $accessoire->query($query); $i = 0; while ($resul && ($row = $accessoire->fetch_object($resul))) { $produita->charger_id($row->accessoire); $produitdesca->charger($produita->id); $rubadesc = new Rubriquedesc(); $rubadesc->charger($produita->rubrique); $fond = $i++ % 2 ? "fonce" : "claire"; ?> <li class="<?php echo $fond; ?> "> <div class="cellule" style="width:260px;"><?php echo $rubadesc->titre; ?> </div> <div class="cellule" style="width:260px;"><?php echo $produitdesca->titre; ?> </div> <div class="cellule_supp"><a href="javascript:accessoire_supprimer(<?php echo $row->id; ?> )"><img src="gfx/supprimer.gif" /></a></div> </li> <?php } }
function accessoire_produit() { $produit = new Produit(); $produit->charger($_GET['ref']); $query = "select p.* from {$produit->table} p LEFT JOIN " . Produitdesc::TABLE . " pd ON p.id=pd.produit AND pd.lang='" . $_SESSION['util']->lang . "' where p.rubrique=\"" . $_GET['id_rubrique'] . "\" ORDER BY pd.titre"; $resul = $produit->query($query); while ($resul && ($row = $produit->fetch_object($resul))) { $test = new Accessoire(); if ($test->charger_uni($produit->id, $row->id)) { continue; } $produitdesc = new Produitdesc(); $produitdesc->charger($row->id); ?> <option value="<?php echo $row->id; ?> "><?php echo $produitdesc->titre; ?> </option> <?php } }
function accessoire_produit() { $produit = new Produit(); $produit->charger($_GET['ref']); $query = "select * from {$produit->table} where rubrique=\"" . $_GET['id_rubrique'] . "\""; $resul = $produit->query($query); while ($resul && ($row = $produit->fetch_object($resul))) { $test = new Accessoire(); if ($test->charger_uni($produit->id, $row->id)) { continue; } $produitdesc = new Produitdesc(); $produitdesc->charger($row->id); ?> <option value="<?php echo $row->id; ?> "><?php echo $produitdesc->titre; ?> </option> <?php } }
function boucleProduit($texte, $args, $type = 0) { global $page, $totbloc, $ref, $id_rubrique; // récupération des arguments $rubrique = lireTag($args, "rubrique", "int_list"); $rubcourante = lireTag($args, "rubcourante", "int"); $deb = lireTag($args, "deb", "int"); $num = lireTag($args, "num", "int"); $passage = lireTag($args, "passage", "int"); $ligne = lireTag($args, "ligne", "int"); $bloc = lireTag($args, "bloc", "int+-"); $nouveaute = lireTag($args, "nouveaute", "int"); $promo = lireTag($args, "promo", "int"); $reappro = lireTag($args, "reappro", "int"); $refp = lireTag($args, "ref", "string"); $id = lireTag($args, "id", "int_list"); $garantie = lireTag($args, "garantie", "int"); $motcle = lireTag($args, "motcle", "string+\\s\\'"); $classement = lireTag($args, "classement", "string"); $aleatoire = lireTag($args, "aleatoire", "int"); $prixmin = lireTag($args, "prixmin", "float"); $prixmax = lireTag($args, "prixmax", "float"); $caracteristique = lireTag($args, "caracteristique", "int+-"); $caracdisp = lireTag($args, "caracdisp", "int+-\\*"); $caracval = lireTag($args, "caracval", "string+\\s\\'\\/\\*"); $typech = lireTag($args, "typech", "string"); $declinaison = lireTag($args, "declinaison", "int+-"); $declidisp = lireTag($args, "declidisp", "int+-"); $declistockmini = lireTag($args, "declistockmini", "int"); $stockmini = lireTag($args, "stockmini", "int"); $courant = lireTag($args, "courant", "int"); $profondeur = lireTag($args, "profondeur", "int"); $exclusion = lireTag($args, "exclusion", "int_list"); $exclurub = lireTag($args, "exclurub", "int_list"); $poids = lireTag($args, "poids", "float"); $stockvide = lireTag($args, "stockvide", "int"); $forcepage = lireTag($args, "forcepage", "int"); if ($bloc) { $totbloc = $bloc; } if (!$deb) { $deb = 0; } if ($page) { $_SESSION['navig']->page = $page; } if (!$page || $page == 1) { $page = 0; } if (!$totbloc) { $totbloc = 1; } if ($page) { $deb = ($page - 1) * $totbloc * $num + $deb; } if ($forcepage != "") { if ($forcepage == 1) { $forcepage = 0; $deb = 0; } if ($forcepage) { $deb = ($forcepage - 1) * $totbloc * $num + $deb; } } $produit = new Produit(); // initialisation de variables $search = ""; $order = ""; $comptbloc = 0; $limit = ""; $pourcentage = ""; $res = ""; $virg = ""; if ($rubcourante == "1" && $rubrique != $id_rubrique) { return ""; } // preparation de la requete if ($courant == "1") { $search .= " and ref=\"{$ref}\""; } else { if ($courant == "0") { $search .= " and ref<>\"{$ref}\""; } } if ($exclusion != "") { $search .= " and {$produit->table}.id not in({$exclusion})"; } if ($exclurub != "") { $search .= " and rubrique not in({$exclurub})"; } if ($rubrique != "") { $srub = ""; if ($profondeur == "") { $profondeur = 0; } $tabrub = explode(",", $rubrique); for ($compt = 0; $compt < count($tabrub); $compt++) { $rec = arbreBoucle($tabrub[$compt], $profondeur); $rec = rtrim($rec, ","); if ($rec) { $virg = ","; } $srub .= $tabrub[$compt] . $virg . $rec . ','; } $srub = rtrim($srub, ","); $search .= " and rubrique in({$srub})"; } if ($ligne == "") { $ligne = "1"; } if ($ligne != "-1") { $search .= " and ligne=\"{$ligne}\""; } if ($id != "") { $search .= " and {$produit->table}.id in ({$id})"; } if ($nouveaute != "") { $search .= " and nouveaute=\"{$nouveaute}\""; } if ($promo != "") { $search .= " and promo=\"{$promo}\""; } if ($reappro != "") { $search .= " and reappro=\"{$reappro}\""; } if ($garantie != "") { $search .= " and garantie=\"{$garantie}\""; } if ($prixmin != "") { $search .= " and ((prix2>=\"{$prixmin}\" and promo=\"1\") or (prix>=\"{$prixmin}\" and promo=\"0\"))"; } if ($prixmax != "") { $search .= " and ((prix2<=\"{$prixmax}\" and promo=\"1\") or (prix<=\"{$prixmax}\" and promo=\"0\"))"; } if ($poids != "") { $search .= " and poids<=\"{$poids}\""; } if ($stockmini != "" && $declistockmini == "") { $search .= " and stock>=\"{$stockmini}\""; } if ("" != $stockvide) { if (0 < $stockvide) { $search .= " and stock<=\"0\""; } elseif (0 >= $stockvide) { $search .= " and stock>\"0\""; } } if ($refp != "") { $search .= " and ref=\"{$refp}\""; } if ($bloc == "-1") { $bloc = "999999999"; } if ($bloc != "" && $num != "") { $limit .= " limit {$deb},{$bloc}"; } else { if ($num != "") { $limit .= " limit {$deb},{$num}"; } } if ($aleatoire) { $order = "order by " . " RAND()"; } else { $listeClassement = explode(',', $classement); $choixClassement = array(); for ($i = 0; $i < count($listeClassement); $i++) { if ($listeClassement[$i] == "prixmin") { $choixClassement[] = "IF(promo, prix2, prix) ASC"; } else { if ($listeClassement[$i] == "prixmax") { $choixClassement[] = "IF(promo, prix2, prix) DESC"; } else { if ($listeClassement[$i] == "rubrique") { $choixClassement[] = "rubrique"; } else { if ($listeClassement[$i] == "manuel") { $choixClassement[] = "classement"; } else { if ($listeClassement[$i] == "inverse") { $choixClassement[] = "classement desc"; } else { if ($listeClassement[$i] == "date") { $choixClassement[] = "datemodif desc"; } else { if ($listeClassement[$i] == "titre") { $choixClassement[] = "titre"; } else { if ($listeClassement[$i] == "titreinverse") { $choixClassement[] = "titre desc"; } else { if ($listeClassement[$i] == "ref") { $choixClassement[] = "ref"; } else { if ($listeClassement[$i] == "promo") { $choixClassement[] = "promo desc"; } else { if ($listeClassement[$i] == "poids") { $choixClassement[] = "poids"; } } } } } } } } } } } } if (empty($choixClassement)) { $order = "order by classement"; } else { $order = "order by " . implode(',', $choixClassement); } } /* Demande de caracteristiques */ if ($caracdisp != "") { if (substr($caracteristique, -1) != "-") { $caracteristique .= "-"; } if (substr($caracdisp, -1) != "-") { $caracdisp .= "-"; } $lcaracteristique = explode("-", $caracteristique); $lcaracdisp = explode("-", $caracdisp); $i = 0; $tcaracval = new Caracval(); while ($i < count($lcaracteristique) - 1) { $caracteristique = $lcaracteristique[$i]; $caracdisp = $lcaracdisp[$i]; if ($caracdisp == "*") { $query = "select * from {$tcaracval->table} where caracteristique='{$caracteristique}' and caracdisp<>''"; } else { $query = "select * from {$tcaracval->table} where caracteristique='{$caracteristique}' and caracdisp='{$caracdisp}'"; } $liste = ""; $resul = CacheBase::getCache()->query($query); if (empty($resul)) { return; } foreach ($resul as $row) { $liste .= "'{$row->produit}',"; } $liste = rtrim($liste, ","); $i++; if ($liste != "") { $search .= " and {$produit->table}.id in({$liste})"; } else { return ""; } } } if ($caracval != "") { $i = 0; $liste = ""; $tcaracval = new Caracval(); if ($caracval == "*") { $query = "select * from {$tcaracval->table} where caracteristique='{$caracteristique}' and valeur<>''"; } else { if ($caracval == "-") { $query = "select * from {$tcaracval->table} where caracteristique='{$caracteristique}' and valeur=''"; } else { if ($typech == "like") { $query = "select * from {$tcaracval->table} where caracteristique='{$caracteristique}' and valeur like '{$caracval}'"; } else { $query = "select * from {$tcaracval->table} where caracteristique='{$caracteristique}' and valeur ='{$caracval}'"; } } } $liste = ""; $resul = CacheBase::getCache()->query($query); if ($resul == "" || count($resul) == 0) { return ""; } foreach ($resul as $row) { $liste .= "'{$row->produit}',"; } $liste = rtrim($liste, ","); $i++; if ($liste != "") { $search .= " and {$produit->table}.id in({$liste})"; } else { return ""; } } /* Demande de declinaisons */ if ($declidisp != "") { if (!strstr($declinaison, "-")) { $declinaison .= "-"; } if (!strstr($declidisp, "-")) { $declidisp .= "-"; } if (!strstr($declistockmini, "-")) { $declistockmini .= "-"; } $ldeclinaison = explode("-", $declinaison); $ldeclidisp = explode("-", $declidisp); $ldeclistockmini = explode("-", $declistockmini); $i = 0; $liste = ""; $exdecprod = new Exdecprod(); $stock = new Stock(); while ($i < count($ldeclinaison) - 1) { $declinaison = $ldeclinaison[$i]; $declidisp = $ldeclidisp[$i]; $declistockmini = $ldeclistockmini[$i]; $query = "select * from {$exdecprod->table} where declidisp='{$declidisp}'"; $resul = CacheBase::getCache()->query($query); if (count($resul) > 0) { foreach ($resul as $row) { $liste .= "'{$row->produit}',"; } } if ($liste != "") { $liste = rtrim($liste, ","); $search .= " and {$produit->table}.id not in({$liste})"; } $liste = ""; if ($declistockmini != "") { $query = "select * from {$stock->table} where declidisp='{$declidisp}' and valeur>='{$declistockmini}'"; $resul = CacheBase::getCache()->query($query); if (count($resul) > 0) { foreach ($resul as $row) { $liste .= "'{$row->produit}',"; } } if ($liste != "") { $liste = rtrim($liste, ","); $search .= " and {$produit->table}.id in({$liste})"; } else { return ""; } } $i++; } } $produit = new Produit(); $produitdesc = new Produitdesc(); if ($motcle) { $motcle = $produit->escape_string(strip_tags(trim($motcle))); $liste = ""; $query = "\n\t\t\t\tSELECT pd.produit FROM\n\t\t\t\t\t{$produitdesc->table} pd\n\t\t\t\tLEFT JOIN\n\t\t\t\t\t{$produit->table} p ON p.id=pd.produit\n\t\t\t\tWHERE\n pd.lang = " . ActionsLang::instance()->get_id_langue_courante() . "\n AND\n\t\t\t\t\tp.ref='{$motcle}'\n\t\t\t\tOR (\n\t\t\t\t\tmatch(pd.titre, pd.chapo, pd.description, pd.postscriptum) AGAINST ('{$motcle}' IN BOOLEAN MODE)\n\t\t\t\tOR\n\t\t\t\t\tpd.titre REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tpd.chapo REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tpd.description REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tpd.postscriptum REGEXP '[[:<:]]{$motcle}[[:>:]]'\n \t\t\t)\n\t\t\t"; $resul = CacheBase::getCache()->query($query); if (empty($resul)) { return ""; } foreach ($resul as $row) { $liste .= "'{$row->produit}',"; } $liste = rtrim($liste, ','); $search .= "and {$produit->table}.id in ({$liste})"; } if ($classement != "titre" && $classement != "titreinverse") { $query = "select * from {$produit->table} where 1 {$search} {$order}"; } else { if (ActionsLang::instance()->get_action_si_trad_absente() == ActionsLang::UTILISER_LANGUE_INDIQUEE) { // On retourne uniquement les produit traduites $search .= " and {$produitdesc->table}.id is not null"; } $query = "\n\t\t\t\tselect {$produit->table}.* from {$produit->table}\n\t\t\t\tleft join {$produitdesc->table} on {$produitdesc->table}.produit = {$produit->table}.id and lang=" . ActionsLang::instance()->get_id_langue_courante() . "\n\t\t\t\twhere 1 {$search} {$order}\n\t\t\t"; } $nbres = count(CacheBase::getCache()->query($query)); $query .= " {$limit}"; $resul = CacheBase::getCache()->query($query); if (empty($resul)) { return ""; } // substitutions if ($type) { return $query; } $count_query = "\n\t\t\tselect\n\t\t\t\tcount({$produit->table}.id) as totcount\n\t\t\tfrom\n\t\t\t\t{$produit->table}\n\t\t\tleft join\n\t\t\t\t{$produitdesc->table} on {$produitdesc->table}.produit = {$produit->table}.id and {$produitdesc->table}.lang=" . ActionsLang::instance()->get_id_langue_courante() . "\n\t\t\twhere\n\t\t\t\t1 {$search}\n\t\t"; $countres = CacheBase::getCache()->query($count_query); $nbproduits = $countres ? $countres[0]->totcount : 0; $compt = 0; foreach ($resul as $row) { $compt++; if ($passage != "" && $comptbloc > $passage - 1) { break; } if ($num > 0) { if ($comptbloc >= ceil($nbproduits / $num) && $bloc != "") { continue; } } if ($comptbloc == 0) { $debcourant = 0; } else { $debcourant = $num * $comptbloc; } $comptbloc++; $prodid = $row->id; $rubriquedesc = new Rubriquedesc(); $rubriquedesc->charger($row->rubrique); $produitdesc = new Produitdesc(); $produitdesc->charger($prodid); $temp = $texte; if ($row->promo == "1") { $temp = preg_replace("/\\#PROMO\\[([^]]*)\\]\\[([^]]*)\\]/", "\\1", $temp); } else { $temp = preg_replace("/\\#PROMO\\[([^]]*)\\]\\[([^]]*)\\]/", "\\2", $temp); } if ($row->nouveaute == "1") { $temp = preg_replace("/\\#NOUVEAU\\[([^]]*)\\]\\[([^]]*)\\]/", "\\1", $temp); } else { $temp = preg_replace("/\\#NOUVEAU\\[([^]]*)\\]\\[([^]]*)\\]/", "\\2", $temp); } if ($row->promo == '1' && $row->prix) { $pourcentage = round(100 * ($row->prix - $row->prix2) / $row->prix, 0); } else { $pourcentage = null; } $prixorig = $row->prix; $prix2orig = $row->prix2; $prix = $row->prix - $row->prix * $_SESSION['navig']->client->pourcentage / 100; $prix2 = $row->prix2 - $row->prix2 * $_SESSION['navig']->client->pourcentage / 100; $ecotaxe = $row->ecotaxe; $pays = new Pays(); $pays->charger($_SESSION['navig']->client->pays); $zone = new Zone(); $zone->charger($pays->zone); $prixht = $prix / (1 + $row->tva / 100); $prix2ht = $prix2 / (1 + $row->tva / 100); $prixoright = $prixorig / (1 + $row->tva / 100); $prix2oright = $prix2orig / (1 + $row->tva / 100); $ecotaxeht = $row->ecotaxe / (1 + $row->tva / 100); $prix = formatter_somme($prix); $prix2 = formatter_somme($prix2); $prixht = formatter_somme($prixht); $prix2ht = formatter_somme($prix2ht); $prixorig = formatter_somme($prixorig); $prix2orig = formatter_somme($prix2orig); $prixoright = formatter_somme($prixoright); $prix2oright = formatter_somme($prix2oright); if ($deb != "" && !$page) { $debcourant += $deb - 1; } $temp = str_replace("#NBRES_TOTAL", $nbres, $temp); $temp = str_replace("#NBRES", $nbproduits, $temp); $temp = str_replace("#REF", "{$row->ref}", $temp); $temp = str_replace("#COMPT", "{$compt}", $temp); $temp = str_replace("#DATE", substr($row->datemodif, 0, 10), $temp); $temp = str_replace("#HEURE", substr($row->datemodif, 11), $temp); $temp = str_replace("#DEBCOURANT", "{$debcourant}", $temp); $temp = str_replace("#ID", "{$prodid}", $temp); $temp = str_replace("#PRIX2ORIGHT", "{$prix2oright}", $temp); $temp = str_replace("#PRIX2ORIG", "{$prix2orig}", $temp); $temp = str_replace("#PRIXORIGHT", "{$prixoright}", $temp); $temp = str_replace("#PRIXORIG", "{$prixorig}", $temp); $temp = str_replace("#PRIX2HT", "{$prix2ht}", $temp); $temp = str_replace("#PRIX2", "{$prix2}", $temp); $temp = str_replace("#PRIXHT", "{$prixht}", $temp); $temp = str_replace("#PRIX", "{$prix}", $temp); $temp = str_replace("#PROMO", "{$row->promo}", $temp); $temp = str_replace("#TVA", "{$row->tva}", $temp); $temp = str_replace("#ECOTAXEHT", "{$ecotaxeht}", $temp); $temp = str_replace("#ECOTAXE", "{$row->ecotaxe}", $temp); $temp = str_replace("#STOCK", "{$row->stock}", $temp); $temp = str_replace("#POURCENTAGE", "{$pourcentage}", $temp); $temp = str_replace("#RUBRIQUE", "{$row->rubrique}", $temp); $temp = str_replace("#PERSO", "{$row->perso}", $temp); $temp = str_replace("#POIDS", "{$row->poids}", $temp); $temp = str_replace("#TITRE", "{$produitdesc->titre}", $temp); $temp = str_replace("#STRIPTITRE", strip_tags($produitdesc->titre), $temp); $temp = str_replace("#CHAPO", "{$produitdesc->chapo}", $temp); $temp = str_replace("#STRIPCHAPO", strip_tags($produitdesc->chapo), $temp); $temp = str_replace("#DESCRIPTION", str_replace("../", "", $produitdesc->description), $temp); $temp = str_replace("#POSTSCRIPTUM", "{$produitdesc->postscriptum}", $temp); $temp = str_replace("#STRIPDESCRIPTION", strip_tags($produitdesc->description), $temp); $temp = str_replace("#URL", $produitdesc->getUrl(), $temp); $temp = str_replace("#REWRITEURL", $produitdesc->getUrl(), $temp); $temp = str_replace("#GARANTIE", "{$row->garantie}", $temp); $temp = str_replace("#PANIERAPPEND", urlfond("panier", "action=" . "ajouter&ref=" . "{$row->ref}" . "&" . "append=1", true), $temp); $temp = str_replace("#PANIER", urlfond("panier", "action=" . "ajouter" . "&" . "ref=" . "{$row->ref}", true), $temp); $temp = str_replace("#RUBTITRE", "{$rubriquedesc->titre}", $temp); $res .= $temp; } return $res; }
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* */ /*************************************************************************************/ require_once "pre.php"; require_once "auth.php"; if (!est_autorise("acces_commandes")) { exit; } $produit = new Produit(); if ($produit->charger($ref)) { $produitdesc = new Produitdesc(); $produitdesc->charger($produit->id); $_SESSION["commande"]->nbart++; $nbart = $_SESSION["commande"]->nbart; $_SESSION["commande"]->venteprod[$nbart - 1] = new Venteprod(); $_SESSION["commande"]->venteprod[$nbart - 1]->ref = $produit->ref; $_SESSION["commande"]->venteprod[$nbart - 1]->titre = $produitdesc->titre; $_SESSION["commande"]->venteprod[$nbart - 1]->quantite = $_REQUEST["qtite"]; $_SESSION["commande"]->venteprod[$nbart - 1]->tva = $tva; $_SESSION["commande"]->venteprod[$nbart - 1]->prixu = $prixu; } else { $_SESSION["commande"]->nbart++; $nbart = $_SESSION["commande"]->nbart; $_SESSION["commande"]->venteprod[$nbart - 1] = new Venteprod(); $_SESSION["commande"]->venteprod[$nbart - 1]->ref = $ref; $_SESSION["commande"]->venteprod[$nbart - 1]->titre = $titre;
exit; } header('Content-Type: text/html; charset=utf-8'); list($modif, $id) = explode("_", lireParam("id", "string")); if (strstr($modif, "rub") !== false) { $obj = new Rubrique(); $obj->charger($id); $objdesc = new Rubriquedesc(); $objdesc->charger($obj->id); $point_entree = "modrub"; $champ_parent = "parent"; } else { $obj = new Produit(); $obj->charger_id($id); $obj->datemodif = date('Y-m-d H:i:s'); $objdesc = new Produitdesc(); $objdesc->charger($obj->id); $point_entree = "modprod"; $champ_parent = "rubrique"; } switch ($modif) { case 'prix': $obj->prix = lireParam('value', 'string'); echo $obj->prix; break; case 'prix2': $obj->prix2 = lireParam('value', 'string'); echo $obj->prix2; break; case 'stock': $obj->stock = lireParam('value', 'string');
function liste_parent($parent, $niveau, $commande, $grandParent, $debutLie = 0) { global $deco, $listePassee; $venteprod = new Venteprod(); $query = "select * from {$venteprod->table} where commande='{$commande->id}' AND parent='{$parent}'"; $resul = $venteprod->query($query); $memFin = ""; while ($resul && ($row = $venteprod->fetch_object($resul))) { $venteprod->charger($row->id); $baseIndentation = 25; $paddingIndentation = 5; //base $largeurDesignation = 399; $indentation = ""; if ($debutLie) { $indentation = "╓"; } elseif ($grandParent != 0 && $grandParent == $venteprod->id) { $indentation = "╙"; } elseif ($niveau > 0) { /*for($niv=0;$niv<$niveau;$niv++) { $indentation .= " "; }*/ $paddingIndentation += $baseIndentation * $niveau; $indentation .= "↳"; } $largeurDesignation -= $paddingIndentation; $produit = new Produit(); $produitdesc = new Produitdesc(); $produit->charger($venteprod->ref); $produitdesc->charger($produit->id); $rubrique = new Rubrique(); $rubrique->charger($produit->rubrique); $rubriquedesc = new Rubriquedesc(); $rubriquedesc->charger($rubrique->id); if ($rubriquedesc->titre != "") { $titrerub = $rubriquedesc->titre; } else { $titrerub = "//"; } if (!($deco % 2)) { $fond = "ligne_fonce_BlocDescription"; } else { $fond = "ligne_claire_BlocDescription"; } $listePassee[] = $venteprod->id; if ($grandParent != 0 && $grandParent == $venteprod->id) { $memFin = "<ul class=\"__COULEUR_FOND__\">\n\t\t\t\t<li style=\"width:" . $largeurDesignation . "px;padding-left:" . $paddingIndentation . "px\">{$indentation} {$venteprod->ref} - {$titrerub} - " . str_replace("\n", "<br />", $venteprod->titre) . "</li>\n\t\t\t\t<li style=\"width:73px;\">" . round($venteprod->prixu, 2) . "</li>\n\t\t\t\t<li style=\"width:23px;\">" . $venteprod->quantite . "</li>\n\t\t\t\t<li style=\"width:20px;\">" . round($venteprod->quantite * $venteprod->prixu, 2) . "</li>\n\t\t\t\t</ul>"; } else { $deco++; ?> <ul class="<?php echo $fond; ?> "> <li style="width:<?php echo $largeurDesignation; ?> px; padding-left:<?php echo $paddingIndentation; ?> px;"><?php echo $indentation . " " . $venteprod->ref . " - " . $titrerub; ?> - <?php echo str_replace("\n", "<br />", $venteprod->titre); ?> </li> <li style="width:73px;"><?php echo round($venteprod->prixu, 2); ?> </li> <li style="width:23px;"><?php echo $venteprod->quantite; ?> </li> <li style="width:20px;"><?php echo round($venteprod->quantite * $venteprod->prixu, 2); ?> </li> </ul> <?php } if ($grandParent != $venteprod->id) { liste_parent($venteprod->id, $niveau + 1, $commande, $parent); } } if ($memFin != "") { if (!($deco % 2)) { $fond = "ligne_fonce_BlocDescription"; } else { $fond = "ligne_claire_BlocDescription"; } $deco++; echo str_replace("__COULEUR_FOND__", $fond, $memFin); } }
function ajouter($lang, $ref, $prix, $ecotaxe, $promo, $prix2, $rubrique, $nouveaute, $perso, $poids, $stock, $tva, $ligne, $titre, $chapo, $description, $postscriptum) { $ref = str_replace(" ", "", $ref); $ref = str_replace("/", "", $ref); $ref = str_replace("+", "", $ref); $ref = str_replace(".", "-", $ref); $ref = str_replace(",", "-", $ref); $ref = str_replace(";", "-", $ref); $ref = str_replace("'", "", $ref); $ref = str_replace("\n", "", $ref); $ref = str_replace("\"", "", $ref); $produit = new Produit(); $produit->charger($ref); if ($produit->id) { redirige("produit_modifier.php?rubrique={$rubrique}&existe=1"); } $produit = new Produit(); $prix = str_replace(",", ".", $prix); $produit->ref = $ref; $produit->datemodif = date("Y-m-d H:i:s"); $produit->prix = $prix; $produit->prix2 = $prix2; if ($produit->prix2 == "") { $produit->prix2 = $prix; } $produit->ecotaxe = $ecotaxe; $produit->rubrique = $rubrique; if ($promo == "on") { $produit->promo = 1; } else { $produit->promo = 0; } if ($nouveaute == "on") { $produit->nouveaute = 1; } else { $produit->nouveaute = 0; } if ($ligne == "on") { $produit->ligne = 1; } else { $produit->ligne = 0; } $produit->perso = $perso; $produit->poids = $poids; $produit->stock = $stock; $produit->tva = str_replace(",", ".", $tva); $lastid = $produit->add(); $produit->id = $lastid; $produitdesc = new Produitdesc(); $produitdesc->chapo = $chapo; $produitdesc->description = $description; $produitdesc->postscriptum = $postscriptum; $produitdesc->produit = $lastid; $produitdesc->lang = $lang; $produitdesc->titre = $titre; $produitdesc->chapo = str_replace("\n", "<br />", $produitdesc->chapo); $produitdesc->add(); $rubcaracteristique = new Rubcaracteristique(); $caracteristiquedesc = new Caracteristiquedesc(); $caracval = new Caracval(); $query = "select * from {$rubcaracteristique->table} where rubrique='" . $produit->rubrique . "'"; $resul = mysql_query($query); while ($row = mysql_fetch_object($resul)) { $caracval = new Caracval(); $deb = "caract"; $deb2 = "typecaract"; $val = $row->caracteristique; $var = $deb . $val; $var2 = $deb2 . $val; global ${$var}; global ${$var2}; $query2 = "delete from {$caracval->table} where produit='" . $produit->id . "' and caracteristique='" . $row->caracteristique . "'"; $resul2 = mysql_query($query2); if (${$var} != "") { if (${$var2} == "c") { foreach (${$var} as $selectval) { $caracval->produit = $lastid; $caracval->caracteristique = $row->caracteristique; $caracval->caracdisp = $selectval; $caracval->add(); } } else { $caracval->produit = $lastid; $caracval->caracteristique = $row->caracteristique; $caracval->valeur = ${$var}; $caracval->add(); } } } $rubdeclinaison = new Rubdeclinaison(); $declinaisondesc = new Declinaisondesc(); $declidisp = new Declidisp(); $declidispdesc = new Declidispdesc(); $query = "select * from {$rubdeclinaison->table} where rubrique='" . $rubrique . "'"; $resul = mysql_query($query); while ($row = mysql_fetch_object($resul)) { $declinaisondesc->charger($row->declinaison); $query2 = "select * from {$declidisp->table} where declinaison='{$row->declinaison}'"; $resul2 = mysql_query($query2); $nbres = mysql_num_rows($resul2); while ($row2 = mysql_fetch_object($resul2)) { $stock = new Stock(); $stock->declidisp = $row2->id; $stock->produit = $lastid; $stock->valeur = 0; $stock->surplus = 0; $stock->add(); } } $produitdesc->reecrire(); ActionsModules::instance()->appel_module("ajoutprod", $produit); redirige($_SERVER['PHP_SELF'] . "?ref=" . $produit->ref . "&rubrique=" . $produit->rubrique . "&lang=" . $lang); }
function rewrite_prod($ref, $lang = false) { $prod = new Produit($ref, $lang); $desc = new Produitdesc($prod->id, $lang); return $desc->charger_reecriture()->url; }
function liste_produits($rubrique, $critere, $order, $alpha) { $produit = new Produit(); $produitdesc = new Produitdesc(); if ($alpha == "alpha") { $query = "select p.* from {$produit->table} p LEFT JOIN {$produitdesc->table} pd ON pd.produit = p.id and lang=" . ActionsLang::instance()->get_id_langue_courante() . " where p.rubrique=\"{$rubrique}\" order by pd.{$critere} {$order}"; } else { $query = "select * from {$produit->table} where rubrique=\"{$rubrique}\" order by {$critere} {$order}"; } $resul = $produit->query($query); $i = 0; while ($resul && ($row = $produit->fetch_object($resul))) { $produit->charger($row->ref); $produitdesc = new Produitdesc(); $produitdesc->charger($row->id); if (!$produitdesc->affichage_back_office_permis()) { continue; } $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce"); $image = new Image(); $query_image = "select * from {$image->table} where produit=\"" . $row->id . "\" order by classement limit 0,1"; $resul_image = $image->query($query_image); $row_image = $image->fetch_object($resul_image); ?> <ul class="<?php echo $fond; ?> "> <li><div class="vignette"><?php if ($row_image) { ?> <img src="../fonctions/redimlive.php?nomorig=<?php echo $row_image->fichier; ?> &type=produit&width=51&height=51&exact=1" title="<?php echo $produit->ref; ?> " /><?php } ?> </div></li> <li style="width:61px;"><span class="texte_noedit" title="<?php echo $row->ref; ?> "><?php echo substr($row->ref, 0, 9); if (strlen($row->ref) > 9) { echo " ..."; } ?> </span></li> <li style="width:225px;"><span id="titreprod_<?php echo $row->id; ?> " <?php if ($produitdesc->est_langue_courante()) { echo 'class="texte_edit"'; } ?> ><?php echo substr($produitdesc->titre, 0, 35); if (strlen($produitdesc->titre) > 35) { echo " ..."; } ?> </span></li> <li style="width:39px;"><span id="stock_<?php echo $row->id; ?> " class="texte_edit"><?php echo $row->stock; ?> </span></li> <li style="width:30px;"><span id="prix_<?php echo $row->id; ?> " class="texte_edit"><?php echo $row->prix; ?> </span></li> <li style="width:68px;"><span id="prix2_<?php echo $row->id; ?> " class="texte_edit"><?php echo $row->prix2; ?> </span></li> <li style="width:64px;"><input id="promo_<?php echo $row->id; ?> " type="checkbox" name="promo[]" class="sytle_checkbox" onchange="checkvalues('promo','<?php echo $row->id; ?> ')" <?php if ($row->promo) { ?> checked="checked" <?php } ?> /></li> <li style="width:64px;"><input type="checkbox" id="nouveaute_<?php echo $row->id; ?> " name="nouveaute[]" class="sytle_checkbox" onchange="checkvalues('nouveaute','<?php echo $row->id; ?> ')" <?php if ($row->nouveaute) { ?> checked="checked" <?php } ?> /></li> <li style="width:53px;"><input type="checkbox" id="prod_ligne_<?php echo $row->id; ?> " name="ligne[]" class="sytle_checkbox" onchange="checkvalues('ligneprod','<?php echo $row->id; ?> ')" <?php if ($row->ligne) { ?> checked="checked" <?php } ?> /></li> <li style="width:41px;"><a href="produit_modifier.php?ref=<?php echo $produit->ref; ?> &rubrique=<?php echo $produit->rubrique; ?> " class="txt_vert_11"><?php echo trad('editer', 'admin'); ?> </a></li> <li style="width:78px; text-align:center;"> <div class="bloc_classement"> <div class="classement"> <a href="produit_modifier.php?ref=<?php echo $produit->id; ?> &action=modclassement&parent=<?php echo $rubrique; ?> &type=M"><img src="gfx/up.gif" border="0" /></a> </div> <div class="classement"><span id="classementprod_<?php echo $produit->id; ?> " class="classement_edit"><?php echo $row->classement; ?> </span></div> <div class="classement"> <a href="produit_modifier.php?ref=<?php echo $produit->id; ?> &action=modclassement&parent=<?php echo $rubrique; ?> &type=D"><img src="gfx/dn.gif" border="0" /></a> </div> </div> </li> <li style="width:37px; text-align:center;"><a href="javascript:supprimer_produit('<?php echo $produit->ref; ?> ','<?php echo $rubrique; ?> ')"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li> </ul> <?php } }
$resul = mysql_query($query, $produit->link); $produitdesc = new Produitdesc(); $prodlist = ""; while ($row = mysql_fetch_object($resul)) { $prodlist .= "'{$row->id}', "; } $prodlist = substr($prodlist, 0, strlen($prodlist) - 2); $search = ""; $search .= "and titre like '%{$motcle}%' or description like '%{$motcle}%'"; $produit = new Produit(); $query = "select * from {$produitdesc->table} where 1 {$search}"; $resul = mysql_query($query, $produitdesc->link); if (mysql_num_rows($resul) && $prodlist != "") { $prodlist .= ","; } $produitdesc = new Produitdesc(); $num = 0; while ($row = mysql_fetch_object($resul)) { $num++; $prodlist .= "'{$row->produit}', "; } if (substr($prodlist, strlen($prodlist) - 2, 1) == ",") { $prodlist = substr($prodlist, 0, strlen($prodlist) - 2); } if ($num == 1) { $prodlist .= "'"; } if ($prodlist == "") { $search = "where 0"; } else { $search = " where id in ({$prodlist})";
if (!est_autorise("acces_catalogue")) { exit; } header('Content-Type: text/html; charset=utf-8'); list($modif, $id) = explode("_", lireParam('id', 'string')); if ($modif == "titrerub") { $obj = new Rubrique(); $obj->charger($id); $objdesc = new Rubriquedesc(); $objdesc->charger($obj->id); echo $objdesc->titre; } else { if ($modif == "titreprod") { $obj = new Produit(); $obj->charger_id($id); $objdesc = new Produitdesc(); $objdesc->charger($obj->id); echo $objdesc->titre; } else { if ($modif == "stock") { $obj = new Produit(); $obj->charger_id($id); echo $obj->stock; } else { if ($modif == "prix") { $obj = new Produit(); $obj->charger_id($id); echo $obj->prix; } else { if ($modif == "prix2") { $obj = new Produit();
public function getAccessoryList() { $return = array(); $query = "select * from " . Accessoire::TABLE . " where produit=" . $this->id . " order by classement"; $resul = $this->query($query); while ($resul && ($row = $this->fetch_object($resul))) { $produit = new Produit(); $produitdesc = new Produitdesc(); $produit->charger_id($row->accessoire); $produitdesc->charger($produit->id); $rubadesc = new Rubriquedesc(); $rubadesc->charger($produit->rubrique); $return[] = array("produit" => $produitdesc->titre, "rubrique" => $rubadesc->titre, "id" => $row->id); } return $return; }