function modifier($id, $lang, $ref, $prix, $ecotaxe, $promo, $prix2, $rubrique, $nouveaute, $perso, $poids, $stock, $tva, $ligne, $titre, $chapo, $description, $postscriptum, $urlsuiv, $urlreecrite)
{
    $produit = new Produit();
    $produitdesc = new Produitdesc();
    $produit->charger($ref);
    $res = $produitdesc->charger($produit->id, $lang);
    if (!$res) {
        CacheBase::getCache()->reset_cache();
        $temp = new Produitdesc();
        $temp->produit = $produit->id;
        $temp->lang = $lang;
        $lastid = $temp->add();
        $produitdesc = new Produitdesc();
        $produitdesc->charger_id($lastid);
    }
    $prix = str_replace(",", ".", $prix);
    $produit->datemodif = date("Y-m-d H:i:s");
    $produit->prix = $prix;
    $produit->prix2 = $prix2;
    $produit->ecotaxe = $ecotaxe;
    if ($produit->rubrique != $rubrique) {
        $param_old = Produitdesc::calculer_clef_url_reecrite($produit->id, $produit->rubrique);
        $param_new = Produitdesc::calculer_clef_url_reecrite($produit->id, $rubrique);
        $reecriture = new Reecriture();
        $query_reec = "select * from {$reecriture->table} where param='&{$param_old}' and lang={$lang} and actif=1";
        $resul_reec = $reecriture->query($query_reec);
        while ($row_reec = $reecriture->fetch_object($resul_reec)) {
            $tmpreec = new Reecriture();
            $tmpreec->charger_id($row_reec->id);
            $tmpreec->param = "&{$param_new}";
            $tmpreec->maj();
        }
        $produit->rubrique = $rubrique;
        $produit->classement = $produit->prochain_classement();
    }
    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);
    $produitdesc->chapo = $chapo;
    $produitdesc->description = $description;
    $produitdesc->postscriptum = $postscriptum;
    $produitdesc->titre = $titre;
    $produitdesc->chapo = str_replace("\n", "<br />", $produitdesc->chapo);
    $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 (${$var2} == "c" && ${$var} != "") {
            foreach (${$var} as $selectval) {
                if ($selectval != "") {
                    $caracval->produit = $produit->id;
                    $caracval->caracteristique = $row->caracteristique;
                    $caracval->caracdisp = $selectval;
                    $caracval->add();
                }
            }
        } else {
            if (${$var} != "") {
                $caracval->produit = $produit->id;
                $caracval->caracteristique = $row->caracteristique;
                $caracval->valeur = ${$var};
                $caracval->add();
            }
        }
    }
    $produit->maj();
    $produitdesc->maj();
    $produitdesc->reecrire($urlreecrite);
    $rubdeclinaison = new Rubdeclinaison();
    $declinaisondesc = new Declinaisondesc();
    $declidisp = new Declidisp();
    $declidispdesc = new Declidispdesc();
    $query = "select * from {$rubdeclinaison->table} where rubrique='" . $rubrique . "'";
    $resul = mysql_query($query);
    $nb = 0;
    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)) {
            $var = "stock" . $row2->id;
            $var2 = "surplus" . $row2->id;
            global ${$var}, ${$var2};
            $stock = new Stock();
            if ($stock->charger($row2->id, $produit->id) == 0) {
                $stock->declidisp = $row2->id;
                $stock->produit = $produit->id;
                $stock->valeur = ${$var};
                $stock->surplus = ${$var2};
                $stock->add();
                $nb += $stock->valeur;
            } else {
                $stock->valeur = ${$var};
                $stock->surplus = ${$var2};
                $stock->maj();
                $nb += $stock->valeur;
            }
        }
    }
    if ($nb) {
        $produit->stock = $nb;
    }
    $produit->maj();
    ActionsModules::instance()->appel_module("modprod", $produit);
    if ($urlsuiv) {
        ?>
            <script type="text/javascript">
                    window.location="parcourir.php?parent=<?php 
        echo $produit->rubrique;
        ?>
";
            </script>
            <?php 
    } else {
        ?>
            <script type="text/javascript">
                    window.location="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?ref=<?php 
        echo $produit->ref;
        ?>
&rubrique=<?php 
        echo $produit->rubrique;
        ?>
&lang=<?php 
        echo $lang;
        ?>
";
            </script>
            <?php 
    }
}
Example #2
0
        $obj->promo = $obj->promo ? 0 : 1;
        break;
    case 'nouveaute':
        $obj->nouveaute = $obj->nouveaute ? 0 : 1;
        break;
    case 'ligneprod':
    case 'lignerub':
        $obj->ligne = $obj->ligne ? 0 : 1;
        break;
    case 'lignetousrub':
    case 'lignetousprod':
        $modif = lireParam("modif", "int");
        $parent = intval(lireParam("parent", "int"));
        $obj->query("update {$obj->table} set ligne={$modif} where {$champ_parent}={$parent}");
        break;
    case 'nouveautetous':
        $modif = lireParam("modif", "int");
        $parent = intval(lireParam("parent", "int"));
        $obj->query("update {$obj->table} set nouveaute={$modif} where {$champ_parent}={$parent}");
        break;
    case 'promotous':
        $modif = lireParam("modif", "int");
        $parent = intval(lireParam("parent", "int"));
        $obj->query("update {$obj->table} set promo={$modif} where {$champ_parent}={$parent}");
        break;
    default:
        exit;
}
$obj->maj();
$objdesc->maj();
ActionsModules::instance()->appel_module($point_entree, $obj);
 public function modify($lang, $price, $price2, $ecotaxe, $promo, $category, $new, $perso, $weight, $stock, $tva, $online, $title, $chapo, $description, $postscriptum, $urlsuiv, $rewriteurl, $caracteristique, $declinaison, $images, $documents, $tab)
 {
     if ($this->id == '') {
         throw new TheliaAdminException("Product not found", TheliaAdminException::PRODUCT_NOT_FOUND);
     }
     $produitdesc = new Produitdesc($this->id, $lang);
     if ($produitdesc->id == '') {
         CacheBase::getCache()->reset_cache();
         $produitdesc->produit = $this->id;
         $produitdesc->lang = $lang;
         $produitdesc->id = $produitdesc->add();
     }
     $this->datemodif = date('Y-m-d H:i:s');
     $this->prix = self::cleanPrice($price);
     $this->prix2 = self::cleanPrice($price2);
     $this->ecotaxe = self::cleanPrice($ecotaxe);
     //  $this->rubrique = $category;
     $this->checkRewrite($category, $lang);
     $this->promo = $promo == 'on' ? 1 : 0;
     $this->nouveaute = $new == 'on' ? 1 : 0;
     $this->ligne = $online == 'on' ? 1 : 0;
     $this->perso = $perso;
     $this->poids = $weight;
     $this->checkStock($stock, $declinaison);
     $this->checkCaracteristique($caracteristique);
     $this->tva = self::cleanPrice($tva);
     $produitdesc->chapo = $chapo;
     $produitdesc->titre = $title;
     $produitdesc->postscriptum = $postscriptum;
     $produitdesc->description = $description;
     $this->maj();
     $produitdesc->maj();
     $produitdesc->reecrire($rewriteurl);
     $this->setLang($lang);
     $this->updateImage($images);
     $this->getImageFile()->ajouter("photo", array("jpg", "gif", "png", "jpeg"), "uploadimage");
     $this->updateDocuments($documents);
     $this->getDocumentFile()->ajouter("document_", array(), "uploaddocument");
     ActionsModules::instance()->appel_module("modprod", new Produit($this->ref));
     if ($urlsuiv) {
         redirige('parcourir.php?parent=' . $this->rubrique);
     } else {
         redirige('produit_modifier.php?ref=' . $this->ref . '&rubrique=' . $this->rubrique . '&tab=' . $tab . '&lang=' . $lang);
     }
 }