diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php index 96b0e3dcee4..34fe98c7cf5 100644 --- a/htdocs/product/canvas/default/product.default.class.php +++ b/htdocs/product/canvas/default/product.default.class.php @@ -63,11 +63,10 @@ class ProductDefault extends Product /** * \brief Lecture des donnees dans la base * \param id Product id - * \param ref Product ref */ - function fetchCanvas($id='', $ref='', $action='') + function fetchCanvas($id='', $action='') { - $result = $this->fetch($id,$ref); + $result = $this->fetch($id); return $result; } @@ -80,8 +79,12 @@ class ProductDefault extends Product { global $conf,$html; + // Ref $this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref'); + // Label $this->tpl['label'] = $this->libelle; + // Statut + $this->tpl['status'] = $this->getLibStatut(2); if ($action == 'view') { @@ -99,9 +102,6 @@ class ProductDefault extends Product $this->tpl['accountancySellCodeKey'] = $html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancySellCodeVal'] = $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); - // Statut - $this->tpl['status'] = $this->getLibStatut(2); - // Description $this->tpl['description'] = nl2br($this->description); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index decfd635213..569f266726e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Jean Heimburger * Copyright (C) 2010 Juanjo Menent @@ -2795,6 +2795,39 @@ class Product extends CommonObject return -1; } } + + /** + * \brief Load type of canvas + * \param id product id + * \param ref product ref + */ + function getCanvas($id, $ref) + { + global $conf; + + $sql = "SELECT rowid, ref, canvas"; + $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE entity = ".$conf->entity; + if (!empty($id)) $sql.= " AND rowid = ".$id; + if (!empty($ref)) $sql.= " AND ref = '".$ref."'"; + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->canvas = $obj->canvas; + + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } /** * \brief Affecte les valeurs smarty diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 44018d1f9c6..ecbf13f41cb 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -653,7 +653,7 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ if ($mesg) print $mesg."\n"; - if ($_GET["canvas"] <> '' && file_exists('canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) + if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) { // On assigne les valeurs meme en creation car elles sont definies si // on revient en erreur @@ -844,26 +844,17 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ */ if ($_GET["id"] || $_GET["ref"]) { - $product = new Product($db); - - if ($_GET["ref"]) - { - $result = $product->fetch('',$_GET["ref"]); - $_GET["id"] = $product->id; - } - elseif ($_GET["id"]) - { - $result = $product->fetch($_GET["id"]); - } + $productstatic = new Product($db); + $result = $productstatic->getCanvas($_GET["id"],$_GET["ref"]); // Gestion des produits specifiques - if (!empty($product->canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php') ) + if (!empty($productstatic->canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$productstatic->canvas.'/product.'.$productstatic->canvas.'.class.php') ) { - $classname = 'Product'.ucfirst($product->canvas); - include_once(DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php'); + $classname = 'Product'.ucfirst($productstatic->canvas); + include_once(DOL_DOCUMENT_ROOT.'/product/canvas/'.$productstatic->canvas.'/product.'.$productstatic->canvas.'.class.php'); $product = new $classname($db); - $result = $product->fetchCanvas($_GET["id"],'',$_GET["action"]); + $result = $product->fetchCanvas($productstatic->id,'',$_GET["action"]); $template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/tpl/'; } @@ -1132,7 +1123,7 @@ print "\n
\n"; * All the "Add to" areas */ -if ($_GET["id"] && $_GET["action"] == '' && $product->status) +if ($product->id && $_GET["action"] == '' && $product->status) { $propal = New Propal($db);