diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php
index a47357737a2..e8d1c93b3c9 100644
--- a/htdocs/core/class/canvas.class.php
+++ b/htdocs/core/class/canvas.class.php
@@ -31,19 +31,98 @@
class Canvas
{
+ var $canvas;
var $template_dir; // Directory with all core and external templates files
- var $errors = array(); // Array for errors
+ var $action;
+ var $smarty;
+
+ var $error;
/**
* \brief Constructor.
* \param DB Database handler
*/
- function Canvas($DB)
+ function Canvas($DB=0)
{
$this->db = $DB ;
}
+ /**
+ * \brief Load class
+ */
+ function load_canvas($object,$canvas)
+ {
+ global $langs;
+
+ if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
+ {
+ var_dump($regs);
+ $ret = DOL_DOCUMENT_ROOT.'/'.$regs[2].'/canvas/'.$regs[1].'/'.$object.'.'.$regs[1].'.class.php'; print $ret;
+ if (file_exists(DOL_DOCUMENT_ROOT.'/'.$regs[2].'/canvas/'.$regs[1].'/'.$object.'.'.$regs[1].'.class.php'))
+ {
+ $filecanvas = DOL_DOCUMENT_ROOT.'/'.$regs[2].'/canvas/'.$regs[1].'/'.$object.'.'.$regs[1].'.class.php';
+ $classname = ucfirst($object).ucfirst($regs[1]);
+ $this->template_dir = DOL_DOCUMENT_ROOT.'/'.$regs[2].'/canvas/'.$regs[1].'/tpl/';
+
+ include_once($filecanvas);
+ $this->object = new $classname($db,0,$user);
+ $this->smarty = $this->object->smarty;
+
+ return $this->object;
+ }
+ else
+ {
+ $this->error = $langs->trans('CanvasIsInvalid');
+ return 0;
+ }
+
+ }
+ else
+ {
+ $this->error = $langs->trans('BadCanvasName');
+ return 0;
+ }
+ }
+
+ /**
+ * \brief Assign values
+ */
+ function assign_values($action='')
+ {
+ $this->action = $action;
+
+ if (!empty($this->smarty))
+ {
+ global $smarty;
+
+ $smarty->assign_smarty_values($this->smarty, $this->action);
+ $smarty->template_dir = $this->template_dir;
+ }
+ else
+ {
+ $this->object->assign_values($this->action);
+ }
+
+ }
+ /**
+ * \brief Display
+ */
+ function display_canvas()
+ {
+ global $langs;
+
+ if (!empty($this->smarty))
+ {
+ global $smarty;
+
+ $this->smarty->display($this->action.'.tpl');
+ }
+ else
+ {
+ include($this->template_dir.$this->action.'.tpl.php');
+ }
+ }
}
?>
diff --git a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql
index ed6ae8f2fb1..d1fb2b05788 100755
--- a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql
+++ b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql
@@ -187,5 +187,9 @@ ALTER TABLE llx_categorie_member ADD INDEX idx_categorie_member_fk_member (fk_me
ALTER TABLE llx_categorie_member ADD CONSTRAINT fk_categorie_member_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid);
ALTER TABLE llx_categorie_member ADD CONSTRAINT fk_categorie_member_member_rowid FOREIGN KEY (fk_member) REFERENCES llx_adherent (rowid);
-UPDATE llx_product SET canvas = 'default' WHERE fk_product_type = 0 AND canvas = '';
-UPDATE llx_product SET canvas = 'service' WHERE fk_product_type = 1 AND canvas = '';
+ALTER TABLE llx_product MODIFY COLUMN canvas varchar(32) DEFAULT 'default@product';
+UPDATE llx_product SET canvas = 'default@product' WHERE fk_product_type = 0 AND (canvas = '' OR canvas = 'default');
+UPDATE llx_product SET canvas = 'service@product' WHERE fk_product_type = 1 AND (canvas = '' OR canvas = 'service');
+UPDATE llx_product SET canvas = 'livre@droitpret' WHERE canvas = 'livre';
+UPDATE llx_product SET canvas = 'livrecontrat@droitpret' WHERE canvas = 'livrecontrat';
+UPDATE llx_product SET canvas = 'livrecouverture@droitpret' WHERE canvas = 'livrecouverture';
diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql
index 81922629ec1..efd71defb31 100644
--- a/htdocs/install/mysql/tables/llx_product.sql
+++ b/htdocs/install/mysql/tables/llx_product.sql
@@ -61,7 +61,7 @@ create table llx_product
volume_units tinyint DEFAULT NULL,
stock integer, -- physical stock
pmp double(24,8) DEFAULT 0 NOT NULL,
- canvas varchar(15) DEFAULT 'default',
+ canvas varchar(32) DEFAULT 'default@product',
finished tinyint DEFAULT NULL,
hidden tinyint DEFAULT 0, -- Need permission see also hidden products
import_key varchar(14) -- import key
diff --git a/htdocs/product/canvas/default/tpl/create.tpl.php b/htdocs/product/canvas/default/tpl/create.tpl.php
index c5d3287c917..e90c2566594 100644
--- a/htdocs/product/canvas/default/tpl/create.tpl.php
+++ b/htdocs/product/canvas/default/tpl/create.tpl.php
@@ -21,7 +21,7 @@
-tpl['title']; ?>
+object->tpl['title']; ?>
| trans("SellingPrice"); ?> | --tpl['price_base_type']; ?> + | +object->tpl['price_base_type']; ?> |
| trans("MinPrice"); ?> | -+ | |
| trans("VATRate"); ?> | -tpl['tva_tx']; ?> +object->tpl['tva_tx']; ?> |