diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index 6f7ceced553..9e8d17fa718 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon
function __construct($DB, $dirmodule, $targetmodule, $canvas, $card)
{
$this->db = $DB;
- $this->dirmodule = $dirmodule;
+ $this->dirmodule = $targetmodule;
$this->targetmodule = $targetmodule;
$this->canvas = $canvas;
$this->card = $card;
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 745d0c3d6e7..4f66bbdfc92 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -277,11 +277,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists())
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
- if (! $objcanvas->hasActions() && $id)
- {
- $object = new Societe($db);
- $object->fetch($id); // For use with "pure canvas" (canvas that contains templates only)
- }
+
$objcanvas->assign_values($action, $id); // Set value for templates
$objcanvas->display_canvas(); // Show template
}
@@ -328,8 +324,6 @@ else
/*
* Fiche en mode creation
*/
- $object->canvas=$canvas;
-
$object->fk_departement = $_POST["departement_id"];
// We set pays_id, pays_code and label for the selected country
diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php
index 5e7d4321ca4..e2a9672428a 100644
--- a/htdocs/core/class/canvas.class.php
+++ b/htdocs/core/class/canvas.class.php
@@ -32,28 +32,29 @@ class Canvas
var $db;
var $error;
var $errors=array();
-
+
var $actiontype;
var $dirmodule; // Module directory
var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...)
- var $canvas; // Name of canvas (ex: company, individual, product, service, ...)
+ var $canvas; // Name of canvas
var $card; // Tab (sub-canvas)
- var $template_dir; // Initialized by getCanvas with templates directory
- var $control; // Initialized by getCanvas with controller instance
+ var $template_dir; // Initialized by getCanvas with templates directory
+ var $control_file; // Initialized by getCanvas with controller file name
+ var $control; // Initialized by getCanvas with controller instance
+ var $object; // Initialized by getCanvas with dao instance, filled by getObject
/**
* Constructor
*
- * @param DoliDB $DB Database handler
- * @param string $actiontype Action type ('create', 'view', 'edit', 'list')
+ * @param DoliDB $DB Database handler
*/
function __construct($DB, $actiontype='view')
{
$this->db = $DB;
-
+
$this->actiontype = $actiontype;
if ($this->actiontype == 'add') $this->actiontype='create';
if ($this->actiontype == 'update') $this->actiontype='edit';
@@ -61,17 +62,19 @@ class Canvas
}
/**
- * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir
+ * Initialize properties: ->targetmodule, ->canvas, ->card
+ * and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View)
*
- * @param string $module Name of target module (thirdparty, contact, ...)
- * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page
- * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule)
- * @return void
+ * @param module Name of target module (thirdparty, contact, ...)
+ * @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page
+ * @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule)
*/
function getCanvas($module, $card, $canvas)
{
global $conf, $langs;
+ $error='';
+
// Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas
$this->targetmodule = $module;
$this->canvas = $canvas;
@@ -86,7 +89,6 @@ class Canvas
// For compatibility
if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; }
- // Control file
$controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php');
if (file_exists($controlclassfile))
{
@@ -108,29 +110,21 @@ class Canvas
//print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
';
//print ' => template_dir='.$this->template_dir.'
';
+ //print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'
';
+
+ return 1;
}
-
-
- /**
- * Return if a canvas contains an action controller
- *
- * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks)
- */
- function hasActions()
- {
- return (! is_object($this->control));
- }
-
+
/**
* Shared method for canvas to execute actions
- *
- * @param string &$action Action string
+ *
+ * @param string $action Action string
* @param int $id Object id
- * @return mixed Return return code of doActions of canvas
+ * @return void
*/
function doActions(&$action='view', $id=0)
{
- if (method_exists($this->control,'doActions'))
+ if (method_exists($this->control,'doActions'))
{
$ret = $this->control->doActions($action, $id);
return $ret;
@@ -139,8 +133,8 @@ class Canvas
/**
* Shared method for canvas to assign values for templates
- *
- * @param string &$action Action string
+ *
+ * @param string $action Action string
* @param int $id Object id
* @return void
*/
@@ -152,7 +146,7 @@ class Canvas
/**
* Return the template to display canvas (if it exists)
*
- * @return int 0=Canvas template file does not exist, 1=Canvas template file exists
+ * @return string Path to display canvas file if it exists, '' otherwise.
*/
function displayCanvasExists()
{
@@ -164,7 +158,8 @@ class Canvas
/**
* Display a canvas page. This will include the template for output.
- * Variables used by templates may have been defined or loaded before into the assign_values function.
+ * Variables used by templates may have been defined, loaded before
+ * into the assign_values function.
*
* @return void
*/
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 36b8bf3a7d0..a8d7823341a 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -298,8 +298,7 @@ class Societe extends CommonObject
$result = 0;
$this->name = trim($this->name);
- $this->nom=$this->name; // For backward compatibility
-
+
if (! $this->name)
{
$this->errors[] = 'ErrorBadThirdPartyName';
@@ -394,16 +393,11 @@ class Societe extends CommonObject
// Clean parameters
$this->id = $id;
- $this->name=$this->name?trim($this->name):trim($this->nom);
- $this->nom=trim($this->nom); // TODO obsolete
- $this->address=$this->address?trim($this->address):trim($this->adresse);
- $this->adresse=$this->address; // TODO obsolete
- $this->zip=$this->zip?trim($this->zip):trim($this->cp);
- $this->cp=$this->zip; // TODO obsolete
- $this->town=$this->town?trim($this->town):trim($this->ville);
- $this->ville=$this->town; // TODO obsolete
- $this->state_id=trim($this->state_id);
- $this->pays_id=trim($this->pays_id);
+ $this->name = trim($this->name);
+ $this->address = trim($this->address);
+ $this->zip = trim($this->zip);
+ $this->town = trim($this->town);
+ $this->state_id = trim($this->state_id);
$this->country_id = trim($this->country_id);
$this->tel = trim($this->tel);
$this->fax = trim($this->fax);
@@ -413,9 +407,6 @@ class Societe extends CommonObject
$this->fax = preg_replace("/\./","",$this->fax);
$this->email = trim($this->email);
$this->url = $this->url?clean_url($this->url,0):'';
- $this->siren=trim($this->siren); // TODO obsolete
- $this->siret=trim($this->siret); // TODO obsolete
- $this->ape=trim($this->ape); // TODO obsolete
$this->idprof1 = trim($this->idprof1);
$this->idprof2 = trim($this->idprof2);
$this->idprof3 = trim($this->idprof3);
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 66097323008..b289e334c60 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -104,7 +104,6 @@ if (empty($reshook))
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
if ($action == 'update') $object->fetch($socid);
- else $object->canvas=$canvas;
if (GETPOST("private") == 1)
{
@@ -475,13 +474,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists())
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
- if (! $objcanvas->hasActions() && $socid)
- {
- $object = new Societe($db);
- $object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only)
- }
- $objcanvas->assign_values($action, $socid); // Set value for templates
- $objcanvas->display_canvas(); // Show template
+
+ $objcanvas->assign_values($action, $socid); // Set value for templates
+ $objcanvas->display_canvas(); // Show template
}
else
{