header('Content-Type: text/html; charset=utf-8');
$path = "./";
$path_images = "./";
$id = "";
$type_piece = "";
if(isset($_GET["id"]) && $_GET["id"] != "")
$id = $_GET["id"];
if(isset($_GET["type_piece"]) && $_GET["type_piece"] != "")
$type_piece = $_GET["type_piece"];
$titre = "";
$mode_emploi = "";
$commentaire_long = "";
$ref_constructeur = "";
$ref_walker = "";
$ref_j = "";
$ref_bosal = "";
$ref_eec = "";
$ref_as = "";
$ref_bm = "";
$ref_klarius = "";
$ref_catspipes = "";
$prix = "";
$modele_fiche = "";
$cylindree_fiche = "";
$commentaires = "";
$stock = "";
$photo = "";
$marque_fiche = "";
$type = "";
$position = "";
$brake_system = "";
$ref_OE = "";
$ref_BORG_BECK = "";
$ref_BREMBO = "";
$ref_COMLINE = "";
$ref_DELPHI = "";
$ref_FERODO = "";
$ref_FIRSTLINE = "";
$ref_GSF = "";
$ref_MINTEX = "";
$ref_QH = "";
$ref_TRW = "";
$ref_TWR = "";
$P1_hauteur = "";
$P1_largeur = "";
$P1_epaisseur = "";
$P2_hauteur = "";
$P2_largeur = "";
$P2_epaisseur = "";
$query = "SELECT * FROM pieces WHERE id=?";
if($type_piece == "plaquettes-de-frein")
$query = "SELECT * FROM pieces p, freins f WHERE p.id=? AND p.id = f.id_ref";
$stmt = $conn->prepare($query);
$stmt->bind_param('s',$id);
$stmt->execute();
$result = $stmt->get_result();
while ($tableau=$result->fetch_assoc()){
$ref = $tableau['ref'];
$montant_reprise = $tableau['montant_reprise'];
$ref_constructeur = $tableau['ref_constructeur'];
if(trim($ref_constructeur) == "-")
$ref_constructeur = "";
$ref_constructeur = str_replace("/", "
", $ref_constructeur);
$ref_constructeur = str_replace("\n", "
", $ref_constructeur);
if(strlen($ref_constructeur) != 7)
$ref_constructeur = str_replace(" ", "
", $ref_constructeur);
$ref_walker = $tableau['ref_walker'];
if(trim($ref_walker) == "-")
$ref_walker = "";
$ref_bosal = $tableau['ref_bosal'];
if(trim($ref_bosal) == "-")
$ref_bosal = "";
$ref_eec = $tableau['ref_eec'];
if(trim($ref_eec) == "-")
$ref_eec = "";
$ref_eec_affiche = $ref_eec;
$ref_klarius = $tableau['ref_klarius'];
if(trim($ref_klarius) == "-")
$ref_klarius = "";
$ref_as = $tableau['ref_as'];
if(trim($ref_as) == "-")
$ref_as = "";
$ref_as_affiche = $ref_as;
$ref_bm = $tableau['ref_bm'];
if(trim($ref_bm) == "-")
$ref_bm = "";
$ref_j = $tableau['ref_jmj'];
if(trim($ref_j) == "-")
$ref_j = "";
$type_piece = $tableau['type_piece'];
$type = $tableau['type_piece'];
$titre = $tableau['titre'];
$commentaire_long = $tableau['commentaire_long'];
$mode_emploi = $tableau['mode_emploi'];
if($ref_bm == ""){
if(substr($ref, 0 ,2) == "AV")
$ref_bm = str_replace("AV", "7", $ref);
if(substr($ref, 0 ,2) == "AR")
$ref_bm = str_replace("AR", "5", $ref);
if(substr($ref, 0 ,2) == "PP")
$ref_bm = $ref;
}
$ref_bm = str_replace("BM", "", $ref_bm);
$ref_bm = str_replace("H", "", $ref_bm);
$ref_bm_vide = trim($ref_bm);
if(trim($ref_bm) != ""){
//if(substr($ref_bm,0,2) != "BM" && $type_piece!="Tuyau de pression FAP")
// $ref_bm = "BM".$ref_bm;
$ref_bm_ok = "";
$tableau_ref_bm = explode("
", $ref_bm);
$tableau_ref_bm = array_unique($tableau_ref_bm);
foreach ($tableau_ref_bm as $value) {
$value = trim($value);
if(substr($value, 0, 2) == "PP")
$ref_bm_ok = $ref_bm_ok."
".$value;
if(substr($value, 0, 1) == "5")
$ref_bm_ok = $ref_bm_ok."
BM".$value;
if(substr($value, 0, 1) == "7")
$ref_bm_ok = $ref_bm_ok."
BM".$value;
if(substr($value, 0, 1) == "8")
$ref_bm_ok = $ref_bm_ok."
BM".$value."
BM".$value."H";
if(substr($value, 0, 1) == "9")
$ref_bm_ok = $ref_bm_ok."
BM".$value."
BM".$value."H";
if(substr($value, 0, 1) == "1" || substr($value, 0, 1) == "3")
$ref_bm_ok = $ref_bm_ok."
BM".$value."
BM".$value."H";
}
$ref_bm = $ref_bm_ok."
".$ref_bm_vide;
if(substr($ref_bm, 0, 4) == "
")
$ref_bm = substr($ref_bm, 4, strlen($ref_bm)-4);
/*
if(!strstr("H",$ref_bm) && $type_piece!="Tuyau de pression FAP")
$ref_bm = $ref_bm."
".$ref_bm."H";
if(strstr("H",$ref_bm) && $type_piece!="Tuyau de pression FAP")
$ref_bm = substr($ref_bm, 0, 7)."
".$ref_bm;
*/
}
$ref_bm_affiche = $ref_bm;
$ref_catspipes = $tableau['ref_catspipes'];
if(trim($ref_catspipes) == "-")
$ref_catspipes = "";
$prix = round($tableau['prix_vente_TTC']+$add_prix,2);
$modele_fiche = $tableau['modele'];
$cylindree_fiche = $tableau['cylindree'];
$commentaires = ($tableau['commentaires']);
$stock = $tableau['stock'];
$id_produit = $tableau['id'];
//Si on est en mode vacances, on ne change pas le stock indiqué dans la base des pièces
if($actif != "on"){
// ************* DEBUT GESTION DU STOCK *****************
$conn_ovh = mysqli_connect("e-catalyseur.fr","webadmin","@1Bracadabra","catalyseur_db");
$query_stock = "SELECT stock FROM stock WHERE ref='".$ref."' LIMIT 1";
$result_stock = mysqli_query($conn_ovh, $query_stock);
$tableau_stock = mysqli_fetch_assoc($result_stock);
$stock_courant = $tableau_stock['stock'];
if($stock_courant > 0){
$stock = "OUI";
$stock_express = "long";
if($actif == "off")
$stock_express = $stock;
}
//Cherche toutes les références possibles
if($stock != "oui" || $stock != "OUI"){
$query_could_be = "SELECT ref_meca, ref_bm, ref_eec, ref_as, ref_cats, ref_jmj FROM could_be WHERE ref_meca='".$ref."' OR ref_bm='".$ref."' OR ref_eec='".$ref."' OR ref_as='".$ref."' OR ref_cats='".$ref."' OR ref_jmj='".$ref."' LIMIT 1";
$result_could_be = mysqli_query($conn_ovh, $query_could_be);
$tableau_could_be = mysqli_fetch_assoc($result_could_be);
$ref_meca = $tableau_could_be['ref_meca'];
$query_stock_meca = "SELECT stock FROM stock WHERE ref='".$ref_meca."'";
$result_stock_meca = mysqli_query($conn_ovh, $query_stock_meca);
$tableau_stock_meca = mysqli_fetch_assoc($result_stock_meca);
$stock_meca = $tableau_stock_meca['stock'];
if($stock_meca > 0){
$stock = "OUI";
$stock_express = "long";
if($actif == "off")
$stock_express = $stock;
} else {
$ref_bm = $tableau_could_be['ref_bm'];
$query_stock_bm = "SELECT stock FROM stock WHERE ref='".$ref_bm."'";
$result_stock_bm = mysqli_query($conn_ovh, $query_stock_bm);
$tableau_stock_bm = mysqli_fetch_assoc($result_stock_bm);
$stock_bm = $tableau_stock_bm['stock'];
if($stock_bm > 0){
$stock = "OUI";
$stock_express = "long";
if($actif == "off")
$stock_express = $stock;
} else {
$ref_eec = $tableau_could_be['ref_eec'];
$query_stock_eec = "SELECT stock FROM stock WHERE ref='".$ref_eec."'";
$result_stock_eec = mysqli_query($conn_ovh, $query_stock_eec);
$tableau_stock_eec = mysqli_fetch_assoc($result_stock_eec);
$stock_eec = $tableau_stock_eec['stock'];
if($stock_eec > 0){
$stock = "OUI";
$stock_express = "long";
if($actif == "off")
$stock_express = $stock;
} else {
$ref_as = $tableau_could_be['ref_as'];
$query_stock_as = "SELECT stock FROM stock WHERE ref='".$ref_as."'";
$result_stock_as = mysqli_query($conn_ovh, $query_stock_as);
$tableau_stock_as = mysqli_fetch_assoc($result_stock_as);
$stock_as = $tableau_stock_as['stock'];
if($stock_as > 0){
$stock = "OUI";
$stock_express = "long";
if($actif == "off")
$stock_express = $stock;
} else {
$ref_cats = $tableau_could_be['ref_cats'];
$query_stock_cats = "SELECT stock FROM stock WHERE ref='".$ref_cats."'";
$result_stock_cats = mysqli_query($conn_ovh, $query_stock_cats);
$tableau_stock_cats = mysqli_fetch_assoc($result_stock_cats);
$stock_cats = $tableau_stock_cats['stock'];
if($stock_cats > 0){
$stock = "OUI";
$stock_express = "long";
if($actif == "off")
$stock_express = $stock;
} else {
$ref_jmj = $tableau_could_be['ref_jmj'];
$query_stock_jmj = "SELECT stock FROM stock WHERE ref='".$ref_jmj."'";
$result_stock_jmj = mysqli_query($conn_ovh, $query_stock_jmj);
$tableau_stock_jmj = mysqli_fetch_assoc($result_stock_jmj);
$stock_jmj = $tableau_stock_jmj['stock'];
if($stock_jmj > 0){
$stock = "OUI";
$stock_express = "long";
if($actif == "off")
$stock_express = $stock;
}
}
}
}
}
}
}
mysqli_close($conn_ovh);
// ************* FIN GESTION DU STOCK *****************
}
$photo = $tableau['photo'];
$marque_fiche = $tableau['marque'];
$position = $tableau['position'];
$brake_system = $tableau['brake_system'];
$ref_OE = $tableau['ref_OE'];
$ref_BORG_BECK = $tableau['ref_BORG_BECK'];
$ref_BREMBO = $tableau['ref_BREMBO'];
$ref_COMLINE = $tableau['ref_COMLINE'];
$ref_DELPHI = $tableau['ref_DELPHI'];
$ref_FERODO = $tableau['ref_FERODO'];
$ref_FIRSTLINE = $tableau['ref_FIRSTLINE'];
$ref_GSF = $tableau['ref_GSF'];
$ref_MINTEX = $tableau['ref_MINTEX'];
$ref_QH = $tableau['ref_QH'];
$ref_TRW = $tableau['ref_TRW'];
$ref_TWR = $tableau['ref_TWR'];
$P1_hauteur = $tableau['P1_hauteur'];
$P1_largeur = $tableau['P1_largeur'];
$P1_epaisseur = $tableau['P1_epaisseur'];
$P2_hauteur = $tableau['P2_hauteur'];
$P2_largeur = $tableau['P2_largeur'];
$P2_epaisseur = $tableau['P2_epaisseur'];
}
include(dirname(__FILE__)."/_cybercite/function.php");
//Traitement / redirection des pages non rewrite
if(preg_match("#\/fiche_produit\.php#",$_SERVER['REQUEST_URI'])) {
$url = "/";
//construction de l'url
if($type_piece != "") $url .= $type_piece."_";
if($marque_fiche != "") $url .= $marque_fiche;
if($marque_fiche != "" && $modele_fiche) $url .= "_";
if($modele_fiche != "") $url .= $modele_fiche;
if(($modele_fiche != "" && $cylindree_fiche != "") || ($marque_fiche != "" && $cylindree_fiche != "")) $url .= "_";
if($cylindree_fiche == "") $url .= '0.0_';
elseif($cylindree_fiche != "") $url .= $cylindree_fiche;
if(($marque_fiche != "" || $modele_fiche != "") && ($type_piece != "" || $cylindree_fiche != "" || $type_piece != "")) $url .= "_";
if($ref != "") $url .= strtoupper($ref)."_";
if($id != "") $url .= $id;
$gcil = $_GET['gclid'];
$url .= ".html";
$url = cleanUrlMeca($url);
if($gcil){
$url .="?gclid=$gcil";
}
//echo $url;
header("Status: 301 Moved Permanently", false, 301);
header("Location: ".$url);
exit();
}
$type_fiche = (str_replace(" essence", "", (str_replace(" diesel", "", $type))));
if($type_fiche == "Catalyseurs")
$type_fiche = "Catalyseur (pot catalytique)";
if($type_fiche == "Filtres à particules")
$type_fiche = "Filtre à particules (FAP)";
if($type_fiche == "Filtres à particules")
$type_fiche = "Filtre à particules (FAP)";
if($type_fiche == "Sondes Lambda")
$type_fiche = "Sonde Lambda";
if($type_fiche == "Produits")
$type_fiche = "".$titre;
$key_words = "";
if(trim($ref_constructeur ?? '') != "")
$key_words = $key_words.", OE, ".str_replace("
", ", ", $ref_constructeur);
if(trim($ref_walker ?? '') != "")
$key_words = $key_words.", Walker, ".str_replace("
", ", ", $ref_walker);
if(trim($ref_bosal ?? '') != "")
$key_words = $key_words.", Bosal, ".str_replace("
", ", ", $ref_bosal);
if(trim($ref_eec_affiche ?? '') != "")
$key_words = $key_words.", EEC, ".str_replace("
", ", ", $ref_eec_affiche);
if(trim($ref_klarius ?? '') != "")
$key_words = $key_words.", KLARIUS, ".str_replace("
", ", ", $ref_klarius);
if(trim($ref_as_affiche ?? '') != "")
$key_words = $key_words.", AS, ".str_replace("
", ", ", $ref_as_affiche);
if(trim($ref_bm_affiche ?? '') != "")
$key_words = $key_words.", BM, BM CATALYSTS, ".str_replace("
", ", ", $ref_bm_affiche);
if(trim($ref_OE ?? '') != "");
$key_words = $key_words.", OE, ".str_replace("
", ", ", $ref_OE);
if(trim($ref_BORG_BECK ?? '') != "")
$key_words = $key_words.", BORG BECK, ".str_replace("
", ", ", $ref_BORG_BECK);
if(trim($ref_BREMBO ?? '') != "")
$key_words = $key_words.", BREMBO, ".str_replace("
", ", ", $ref_BREMBO);
if(trim($ref_COMLINE ?? '') != "")
$key_words = $key_words.", COMLINE, ".str_replace("
", ", ", $ref_COMLINE);
if(trim($ref_DELPHI ?? '') != "")
$key_words = $key_words.", DELPHI, ".str_replace("
", ", ", $ref_DELPHI);
if(trim($ref_FERODO ?? '') != "")
$key_words = $key_words.", FERODO, ".str_replace("
", ", ", $ref_FERODO);
if(trim($ref_FIRSTLINE ?? '') != "")
$key_words = $key_words.", FIRSTLINE, ".str_replace("
", ", ", $ref_FIRSTLINE);
if(trim($ref_GSF ?? '') != "")
$key_words = $key_words.", GSF, ".str_replace("
", ", ", $ref_GSF);
if(trim($ref_MINTEX ?? '') != "")
$key_words = $key_words.", MINTEX, ".str_replace("
", ", ", $ref_MINTEX);
if(trim($ref_QH ?? '') != "")
$key_words = $key_words.", TRW, ".str_replace("
", ", ", $ref_QH);
if(trim($ref_TWR ?? '') != "")
$key_words = $key_words.", TWR, ".str_replace("
", ", ", $ref_TWR);
$title_affiche = $type_fiche." pour ".$marque_fiche." ".$modele_fiche." ".$cylindree_fiche;
if(strpos($tableau['type_piece'], "essence"))
$title_affiche = $title_affiche." (Essence)";
if(strpos($tableau['type_piece'], "diesel"))
$title_affiche = $title_affiche." (Diesel)";
$title_affiche = $title_affiche." - référence : ".$ref;
$title_affiche_2 = $type_fiche." pour ".$marque_fiche." ".$modele_fiche." ".$cylindree_fiche;
if(strpos($type, "essence"))
$title_affiche_2 = $title_affiche_2." (Essence)";
if(strpos($type, "diesel"))
$title_affiche_2 = $title_affiche_2." (Diesel)";
$title_affiche_2 = $title_affiche_2."- référence : ".$ref;
$url_image = $path_images."images/";
if($type == "Plaquettes de frein")
$url_image = $url_image."freins";
else if($type == "Produits")
$url_image = $url_image."produits_entretien";
else if((substr($type, 0, 10) == "Silencieux" || substr($type, 0, 4) == "Pack") && substr($photo, 0, 1) != "7")
$url_image = $url_image."silencieux";
else
$url_image = $url_image."catalyseurs/grandes";
if(!strpos($photo, "etscompany") && !strpos($photo, "ttmcompany")){
$nom_image = "";
if(file_exists($url_image."/".$photo.".jpg"))
$nom_image = $photo.".jpg";
else if(file_exists($url_image."/".$photo."H.jpg"))
$nom_image = $photo."H.jpg";
else if(file_exists($url_image."/".$photo.".gif"))
$nom_image = $photo.".gif";
else if(file_exists($url_image."/".$photo.".png"))
$nom_image = $photo.".png";
else if(file_exists($url_image."/".$photo.".bmp"))
$nom_image = $photo.".bmp";
else if(file_exists($path_images."images/catalyseurs/".$photo.".jpg")) {
$nom_image = $path_images."images/catalyseurs/".$photo.".jpg";
$grande = false;
}
else
$nom_image = "apercu_indisponible.jpg";
if($grande)
$nom_image = $url_image."/".$nom_image;
}else{
$nom_image = $photo;
}
if($nom_image == "./images/catalyseurs/grandes/apercu_indisponible.jpg" && (substr($ref,0,1) == "E" || substr($ref,0,1) == "D" || substr($ref,0,2) == "PP" || substr($ref,0,2) == "AV" || substr($ref,0,2) == "AR" || substr($ref,0,1) == "3" || substr($ref,0,1) == "1")) {
$img_bm = str_replace("E","9",$ref);
$img_bm = str_replace("D","8",$img_bm);
$img_bm = str_replace("AV","7",$img_bm);
$img_bm = str_replace("AR","5",$img_bm);
$img_bm = str_replace("PP","",$img_bm);
$img_bm = "https://bmcats.com/app/themes/bmcatalysts/catimages/".$img_bm.".jpg";
$jsonimg = $img_bm;
} else {
$jsonimg = $nom_image;
}
?>
|