Fix: broken canvas
This commit is contained in:
parent
62a0187818
commit
d47979476f
@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon
|
|||||||
function __construct($DB, $dirmodule, $targetmodule, $canvas, $card)
|
function __construct($DB, $dirmodule, $targetmodule, $canvas, $card)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
$this->dirmodule = $dirmodule;
|
$this->dirmodule = $targetmodule;
|
||||||
$this->targetmodule = $targetmodule;
|
$this->targetmodule = $targetmodule;
|
||||||
$this->canvas = $canvas;
|
$this->canvas = $canvas;
|
||||||
$this->card = $card;
|
$this->card = $card;
|
||||||
|
|||||||
@ -277,11 +277,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists())
|
|||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// When used with CANVAS
|
// 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->assign_values($action, $id); // Set value for templates
|
||||||
$objcanvas->display_canvas(); // Show template
|
$objcanvas->display_canvas(); // Show template
|
||||||
}
|
}
|
||||||
@ -328,8 +324,6 @@ else
|
|||||||
/*
|
/*
|
||||||
* Fiche en mode creation
|
* Fiche en mode creation
|
||||||
*/
|
*/
|
||||||
$object->canvas=$canvas;
|
|
||||||
|
|
||||||
$object->fk_departement = $_POST["departement_id"];
|
$object->fk_departement = $_POST["departement_id"];
|
||||||
|
|
||||||
// We set pays_id, pays_code and label for the selected country
|
// We set pays_id, pays_code and label for the selected country
|
||||||
|
|||||||
@ -37,18 +37,19 @@ class Canvas
|
|||||||
|
|
||||||
var $dirmodule; // Module directory
|
var $dirmodule; // Module directory
|
||||||
var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...)
|
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 $card; // Tab (sub-canvas)
|
||||||
|
|
||||||
var $template_dir; // Initialized by getCanvas with templates directory
|
var $template_dir; // Initialized by getCanvas with templates directory
|
||||||
var $control; // Initialized by getCanvas with controller instance
|
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
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $DB Database handler
|
* @param DoliDB $DB Database handler
|
||||||
* @param string $actiontype Action type ('create', 'view', 'edit', 'list')
|
|
||||||
*/
|
*/
|
||||||
function __construct($DB, $actiontype='view')
|
function __construct($DB, $actiontype='view')
|
||||||
{
|
{
|
||||||
@ -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 module Name of target module (thirdparty, contact, ...)
|
||||||
* @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page
|
* @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page
|
||||||
* @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule)
|
* @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule)
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
function getCanvas($module, $card, $canvas)
|
function getCanvas($module, $card, $canvas)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$error='';
|
||||||
|
|
||||||
// Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas
|
// Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas
|
||||||
$this->targetmodule = $module;
|
$this->targetmodule = $module;
|
||||||
$this->canvas = $canvas;
|
$this->canvas = $canvas;
|
||||||
@ -86,7 +89,6 @@ class Canvas
|
|||||||
// For compatibility
|
// For compatibility
|
||||||
if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; }
|
if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; }
|
||||||
|
|
||||||
// Control file
|
|
||||||
$controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php');
|
$controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php');
|
||||||
if (file_exists($controlclassfile))
|
if (file_exists($controlclassfile))
|
||||||
{
|
{
|
||||||
@ -108,25 +110,17 @@ class Canvas
|
|||||||
|
|
||||||
//print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'<br>';
|
//print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'<br>';
|
||||||
//print ' => template_dir='.$this->template_dir.'<br>';
|
//print ' => template_dir='.$this->template_dir.'<br>';
|
||||||
}
|
//print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'<br>';
|
||||||
|
|
||||||
|
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
|
* Shared method for canvas to execute actions
|
||||||
*
|
*
|
||||||
* @param string &$action Action string
|
* @param string $action Action string
|
||||||
* @param int $id Object id
|
* @param int $id Object id
|
||||||
* @return mixed Return return code of doActions of canvas
|
* @return void
|
||||||
*/
|
*/
|
||||||
function doActions(&$action='view', $id=0)
|
function doActions(&$action='view', $id=0)
|
||||||
{
|
{
|
||||||
@ -140,7 +134,7 @@ class Canvas
|
|||||||
/**
|
/**
|
||||||
* Shared method for canvas to assign values for templates
|
* Shared method for canvas to assign values for templates
|
||||||
*
|
*
|
||||||
* @param string &$action Action string
|
* @param string $action Action string
|
||||||
* @param int $id Object id
|
* @param int $id Object id
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -152,7 +146,7 @@ class Canvas
|
|||||||
/**
|
/**
|
||||||
* Return the template to display canvas (if it exists)
|
* 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()
|
function displayCanvasExists()
|
||||||
{
|
{
|
||||||
@ -164,7 +158,8 @@ class Canvas
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a canvas page. This will include the template for output.
|
* 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
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -298,7 +298,6 @@ class Societe extends CommonObject
|
|||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$this->name = trim($this->name);
|
$this->name = trim($this->name);
|
||||||
$this->nom=$this->name; // For backward compatibility
|
|
||||||
|
|
||||||
if (! $this->name)
|
if (! $this->name)
|
||||||
{
|
{
|
||||||
@ -394,16 +393,11 @@ class Societe extends CommonObject
|
|||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name=$this->name?trim($this->name):trim($this->nom);
|
$this->name = trim($this->name);
|
||||||
$this->nom=trim($this->nom); // TODO obsolete
|
$this->address = trim($this->address);
|
||||||
$this->address=$this->address?trim($this->address):trim($this->adresse);
|
$this->zip = trim($this->zip);
|
||||||
$this->adresse=$this->address; // TODO obsolete
|
$this->town = trim($this->town);
|
||||||
$this->zip=$this->zip?trim($this->zip):trim($this->cp);
|
$this->state_id = trim($this->state_id);
|
||||||
$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->country_id = trim($this->country_id);
|
$this->country_id = trim($this->country_id);
|
||||||
$this->tel = trim($this->tel);
|
$this->tel = trim($this->tel);
|
||||||
$this->fax = trim($this->fax);
|
$this->fax = trim($this->fax);
|
||||||
@ -413,9 +407,6 @@ class Societe extends CommonObject
|
|||||||
$this->fax = preg_replace("/\./","",$this->fax);
|
$this->fax = preg_replace("/\./","",$this->fax);
|
||||||
$this->email = trim($this->email);
|
$this->email = trim($this->email);
|
||||||
$this->url = $this->url?clean_url($this->url,0):'';
|
$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->idprof1 = trim($this->idprof1);
|
||||||
$this->idprof2 = trim($this->idprof2);
|
$this->idprof2 = trim($this->idprof2);
|
||||||
$this->idprof3 = trim($this->idprof3);
|
$this->idprof3 = trim($this->idprof3);
|
||||||
|
|||||||
@ -104,7 +104,6 @@ if (empty($reshook))
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
|
|
||||||
if ($action == 'update') $object->fetch($socid);
|
if ($action == 'update') $object->fetch($socid);
|
||||||
else $object->canvas=$canvas;
|
|
||||||
|
|
||||||
if (GETPOST("private") == 1)
|
if (GETPOST("private") == 1)
|
||||||
{
|
{
|
||||||
@ -475,13 +474,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists())
|
|||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// When used with CANVAS
|
// When used with CANVAS
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
if (! $objcanvas->hasActions() && $socid)
|
|
||||||
{
|
$objcanvas->assign_values($action, $socid); // Set value for templates
|
||||||
$object = new Societe($db);
|
$objcanvas->display_canvas(); // Show template
|
||||||
$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
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user