diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php index a77714bd04e..2d1dce15ee2 100644 --- a/htdocs/product/canvas/default/product.default.class.php +++ b/htdocs/product/canvas/default/product.default.class.php @@ -31,7 +31,7 @@ class ProductDefault extends Product { //! Numero d'erreur Plage 1280-1535 var $errno = 0; - + //! Template container var $tpl = array(); /** @@ -44,6 +44,7 @@ class ProductDefault extends Product $this->db = $DB; $this->id = $id ; $this->user = $user; + $this->smarty = 0; $this->module = "produit"; $this->canvas = "default"; $this->name = "default"; diff --git a/htdocs/product/canvas/default/tpl/create.tpl.php b/htdocs/product/canvas/default/tpl/create.tpl.php index 5b27644da5b..c5d3287c917 100644 --- a/htdocs/product/canvas/default/tpl/create.tpl.php +++ b/htdocs/product/canvas/default/tpl/create.tpl.php @@ -21,13 +21,18 @@ +tpl['title']; ?> + + +

+ +
" method="post"> + -tpl['title']; ?> - diff --git a/htdocs/product/canvas/service/product.service.class.php b/htdocs/product/canvas/service/product.service.class.php index d3472420b0c..53f821d0511 100644 --- a/htdocs/product/canvas/service/product.service.class.php +++ b/htdocs/product/canvas/service/product.service.class.php @@ -41,13 +41,15 @@ class ProductService extends Product */ function ProductService($DB=0, $id=0, $user=0) { - $this->db = $DB; - $this->id = $id ; - $this->user = $user; - $this->module = "service"; - $this->canvas = "service"; - $this->name = "service"; - $this->definition = "Canvas des services"; + $this->db = $DB; + $this->id = $id ; + $this->user = $user; + $this->smarty = 0; + $this->module = "service"; + $this->canvas = "service"; + $this->name = "service"; + $this->definition = "Canvas des services"; + $this->fieldListName = "product_service"; $this->next_prev_filter = "canvas='service'"; } diff --git a/htdocs/product/canvas/service/tpl/create.tpl.php b/htdocs/product/canvas/service/tpl/create.tpl.php index 3311228f162..03cea5fbfc7 100644 --- a/htdocs/product/canvas/service/tpl/create.tpl.php +++ b/htdocs/product/canvas/service/tpl/create.tpl.php @@ -23,9 +23,14 @@ tpl['title']; ?> + +

+ + " method="post"> +
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 8f758d8c279..e72d871fd86 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -113,16 +113,16 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'
'; $_GET["action"] = "create"; - $_GET["canvas"] = $product->canvas; - $_GET["type"] = $_POST["type"]; + $_GET["canvas"] = $_POST["canvas"]; + $_GET["type"] = $_POST["type"]; $error++; } if (empty($_POST["ref"])) { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
'; $_GET["action"] = "create"; - $_GET["canvas"] = $product->canvas; - $_GET["type"] = $_POST["type"]; + $_GET["canvas"] = $_POST["canvas"]; + $_GET["type"] = $_POST["type"]; $error++; } @@ -134,10 +134,10 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights } else { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
'; + $mesg='
'.$langs->trans('ErrorCanvasNotDefined').'
'; $_GET["action"] = "create"; - $_GET["canvas"] = $product->canvas; - $_GET["type"] = $_POST["type"]; + $_GET["canvas"] = $_POST["canvas"]; + $_GET["type"] = $_POST["type"]; $error++; } @@ -153,27 +153,27 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights $product->tva_tx = $_POST["tva_tx"]; // local taxes. - $product->localtax1_tx = get_localtax($product->tva_tx,1); - $product->localtax2_tx = get_localtax($product->tva_tx,2); + $product->localtax1_tx = get_localtax($product->tva_tx,1); + $product->localtax2_tx = get_localtax($product->tva_tx,2); - $product->type = $_POST["type"]; - $product->status = $_POST["statut"]; - $product->description = dol_htmlcleanlastbr($_POST["desc"]); - $product->note = dol_htmlcleanlastbr($_POST["note"]); - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0; - $product->canvas = $_POST["canvas"]; - $product->weight = $_POST["weight"]; - $product->weight_units = $_POST["weight_units"]; - $product->length = $_POST["size"]; - $product->length_units = $_POST["size_units"]; - $product->surface = $_POST["surface"]; - $product->surface_units = $_POST["surface_units"]; - $product->volume = $_POST["volume"]; - $product->volume_units = $_POST["volume_units"]; - $product->finished = $_POST["finished"]; - $product->hidden = $_POST["hidden"]=='yes'?1:0; + $product->type = $_POST["type"]; + $product->status = $_POST["statut"]; + $product->description = dol_htmlcleanlastbr($_POST["desc"]); + $product->note = dol_htmlcleanlastbr($_POST["note"]); + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0; + $product->canvas = $_POST["canvas"]; + $product->weight = $_POST["weight"]; + $product->weight_units = $_POST["weight_units"]; + $product->length = $_POST["size"]; + $product->length_units = $_POST["size_units"]; + $product->surface = $_POST["surface"]; + $product->surface_units = $_POST["surface_units"]; + $product->volume = $_POST["volume"]; + $product->volume_units = $_POST["volume_units"]; + $product->finished = $_POST["finished"]; + $product->hidden = $_POST["hidden"]=='yes'?1:0; // MultiPrix if($conf->global->PRODUIT_MULTIPRICES) @@ -220,7 +220,13 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig } else { - $product = new Product($db); + if (!empty($_POST["canvas"]) && file_exists('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php')) + { + $classname = 'Product'.ucfirst($product->canvas); + include_once('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php'); + $product = new $classname($db); + } + if ($product->fetch($_POST["id"])) { $product->ref = $_POST["ref"]; @@ -263,19 +269,6 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig $_GET["id"] = $_POST["id"]; $mesg = $langs->trans("ErrorProductBadRefOrLabel"); } - - // Specific product - if ($product->canvas <> '' && file_exists('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php') ) - { - $classname = 'Product'.ucfirst($product->canvas); - include_once('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php'); - - $product = new $classname($db); - if ($product->FetchCanvas($_POST["id"])) - { - $product->UpdateCanvas($_POST); - } - } } } } @@ -632,14 +625,38 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ { if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) { + $helpurl=''; + if (isset($_GET["type"]) && $_GET["type"] == 0) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + if (isset($_GET["type"]) && $_GET["type"] == 1) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + + llxHeader("",$helpurl,$langs->trans("CardProduct".$product->type)); + if (! isset($product)) { $filecanvas = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'; $classname = 'Product'.ucfirst($_GET["canvas"]); include_once($filecanvas); - $product = new $classname($db,0,$user); + + $template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/tpl/'; + + if ($product->smarty) + { + $product->assign_smarty_values($smarty, 'create'); + $smarty->template_dir = $template_dir; + + //$tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,''); + //$smarty->assign('tva_taux_value', $tvaarray['value']); + //$smarty->assign('tva_taux_libelle', $tvaarray['label']); + + $smarty->display($_GET["canvas"].'-create.tpl'); + } + else + { + $product->assign_values('create'); + include($template_dir.'create.tpl.php'); + } } if ($_error == 1) @@ -647,29 +664,6 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ $product = $e_product; } } - - $helpurl=''; - if (isset($_GET["type"]) && $_GET["type"] == 0) - { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - } - if (isset($_GET["type"]) && $_GET["type"] == 1) - { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - } - - llxHeader("",$helpurl,$langs->trans("CardProduct".$product->type)); - - if ($mesg) print $mesg."\n"; - - if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) - { - $template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/tpl/'; - - $product->assign_values('create'); - - include($template_dir.'create.tpl.php'); - } } /**