New: Can use canvas for create only with no need to have one for edit.
This commit is contained in:
parent
b30c0bc730
commit
8d66d2da7e
@ -29,7 +29,10 @@
|
|||||||
*/
|
*/
|
||||||
class ActionsContactCardCommon
|
class ActionsContactCardCommon
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
var $targetmodule;
|
||||||
|
var $canvas;
|
||||||
|
var $card;
|
||||||
|
|
||||||
//! Numero d'erreur Plage 1280-1535
|
//! Numero d'erreur Plage 1280-1535
|
||||||
var $errno = 0;
|
var $errno = 0;
|
||||||
@ -37,20 +40,24 @@ class ActionsContactCardCommon
|
|||||||
var $tpl = array();
|
var $tpl = array();
|
||||||
//! Object container
|
//! Object container
|
||||||
var $object;
|
var $object;
|
||||||
//! Canvas
|
|
||||||
var $canvas;
|
|
||||||
//! Error string
|
//! Error string
|
||||||
var $error;
|
var $error;
|
||||||
//! Error array
|
//! Error array
|
||||||
var $errors=array();
|
var $errors=array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de la classe
|
* Constructor
|
||||||
* @param DB Handler acces base de donnees
|
* @param DB Handler acces base de donnees
|
||||||
|
* @param targmetmodule Name of directory of module where canvas is stored
|
||||||
|
* @param canvas Name of canvas
|
||||||
|
* @param card Name of tab (sub-canvas)
|
||||||
*/
|
*/
|
||||||
function ActionsContactCardCommon($DB)
|
function ActionsContactCardCommon($DB,$targetmodule,$canvas,$card)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
|
$this->targetmodule = $targetmodule;
|
||||||
|
$this->canvas = $canvas;
|
||||||
|
$this->card = $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -32,17 +32,23 @@ include_once(DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class
|
|||||||
class ActionsContactCardDefault extends ActionsContactCardCommon
|
class ActionsContactCardDefault extends ActionsContactCardCommon
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
var $targetmodule;
|
||||||
//! Canvas
|
var $canvas;
|
||||||
var $canvas;
|
var $card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de la classe
|
* Constructor
|
||||||
* @param DB Handler acces base de donnees
|
* @param DB Handler acces base de donnees
|
||||||
|
* @param targmetmodule Name of directory of module where canvas is stored
|
||||||
|
* @param canvas Name of canvas
|
||||||
|
* @param card Name of tab (sub-canvas)
|
||||||
*/
|
*/
|
||||||
function ActionsContactCardDefault($DB)
|
function ActionsContactCardDefault($DB,$targetmodule,$canvas,$card)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
|
$this->targetmodule = $targetmodule;
|
||||||
|
$this->canvas = $canvas;
|
||||||
|
$this->card = $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -151,8 +151,9 @@ else
|
|||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$object->socid = $_POST["socid"];
|
if ($canvas) $object->canvas=$canvas;
|
||||||
|
|
||||||
|
$object->socid = $_POST["socid"];
|
||||||
$object->name = $_POST["name"];
|
$object->name = $_POST["name"];
|
||||||
$object->firstname = $_POST["firstname"];
|
$object->firstname = $_POST["firstname"];
|
||||||
$object->civilite_id = $_POST["civilite_id"];
|
$object->civilite_id = $_POST["civilite_id"];
|
||||||
@ -285,7 +286,8 @@ else
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||||
|
llxHeader('',$langs->trans("ContactsAddresses"),$help_url);
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formcompany = new FormCompany($db);
|
$formcompany = new FormCompany($db);
|
||||||
@ -298,13 +300,11 @@ if ($socid > 0)
|
|||||||
$objsoc->fetch($socid);
|
$objsoc->fetch($socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($objcanvas->template_dir))
|
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||||
{
|
{
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// When used with CANVAS
|
// When used with CANVAS
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
//$objcanvas->doOutput($socid);
|
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
$objcanvas->assign_post(); // Assign POST data
|
$objcanvas->assign_post(); // Assign POST data
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class Canvas
|
|||||||
|
|
||||||
var $action;
|
var $action;
|
||||||
|
|
||||||
var $targetmodule; // Module built into dolibarr replaced by canvas (ex: thirdparty, contact, ...)
|
var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...)
|
||||||
var $canvas; // Name of canvas
|
var $canvas; // Name of canvas
|
||||||
var $card; // Tab (sub-canvas)
|
var $card; // Tab (sub-canvas)
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class Canvas
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute actions
|
* Execute actions
|
||||||
* @param Id of object (may be empty for creation)
|
* @param id Id of object (may be empty for creation)
|
||||||
*/
|
*/
|
||||||
function doActions($id)
|
function doActions($id)
|
||||||
{
|
{
|
||||||
@ -150,7 +150,7 @@ class Canvas
|
|||||||
// If function to do actions is overwritten, we use new one
|
// If function to do actions is overwritten, we use new one
|
||||||
if (method_exists($this->control,'doActions'))
|
if (method_exists($this->control,'doActions'))
|
||||||
{
|
{
|
||||||
$out = $this->control->doActions($id);
|
$out = $this->control->doActions($id,$this->targetmodule,$this->canvas,$this->card);
|
||||||
|
|
||||||
$this->errors = ($this->control->errors?$this->control->errors:$this->control->object->errors);
|
$this->errors = ($this->control->errors?$this->control->errors:$this->control->object->errors);
|
||||||
$this->error = ($this->control->error?$this->control->error:$this->control->object->error);
|
$this->error = ($this->control->error?$this->control->error:$this->control->object->error);
|
||||||
@ -189,7 +189,7 @@ class Canvas
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigne les valeurs POST dans l'objet
|
* Assign values into POST into object
|
||||||
* // TODO This should be useless. POST is already visible from everywhere.
|
* // TODO This should be useless. POST is already visible from everywhere.
|
||||||
*/
|
*/
|
||||||
function assign_post()
|
function assign_post()
|
||||||
@ -198,14 +198,28 @@ class Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared method for canvas to assign values of templates
|
* Shared method for canvas to assign values for templates
|
||||||
* @param action Type of action
|
|
||||||
*/
|
*/
|
||||||
function assign_values()
|
function assign_values()
|
||||||
{
|
{
|
||||||
if (method_exists($this->control,'assign_values')) $this->control->assign_values($this->action);
|
if (method_exists($this->control,'assign_values')) $this->control->assign_values($this->action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the template to display canvas (if it exists).
|
||||||
|
* @param mode 'create', ''='view', 'edit'
|
||||||
|
* @return string Path to display canvas file if it exists, '' otherwise.
|
||||||
|
*/
|
||||||
|
function displayCanvasExists($mode='view')
|
||||||
|
{
|
||||||
|
$newmode=$mode;
|
||||||
|
if (empty($newmode)) $newmode='view';
|
||||||
|
if (empty($this->template_dir)) return 0;
|
||||||
|
//print $this->template_dir.$this->card.'_'.$newmode.'.tpl.php';
|
||||||
|
if (file_exists($this->template_dir.$this->card.'_'.$newmode.'.tpl.php')) return 1;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display canvas
|
* Display canvas
|
||||||
* @param mode 'create', 'view', 'edit'
|
* @param mode 'create', 'view', 'edit'
|
||||||
|
|||||||
@ -30,7 +30,10 @@
|
|||||||
*/
|
*/
|
||||||
class ActionsCardCommon
|
class ActionsCardCommon
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
var $targetmodule;
|
||||||
|
var $canvas;
|
||||||
|
var $card;
|
||||||
|
|
||||||
//! Numero d'erreur Plage 1280-1535
|
//! Numero d'erreur Plage 1280-1535
|
||||||
var $errno = 0;
|
var $errno = 0;
|
||||||
@ -38,20 +41,24 @@ class ActionsCardCommon
|
|||||||
var $tpl = array();
|
var $tpl = array();
|
||||||
//! Object container
|
//! Object container
|
||||||
var $object;
|
var $object;
|
||||||
//! Canvas
|
|
||||||
var $canvas;
|
|
||||||
//! Error string
|
//! Error string
|
||||||
var $error;
|
var $error;
|
||||||
//! Error array
|
//! Error array
|
||||||
var $errors=array();
|
var $errors=array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de la classe
|
* Constructor
|
||||||
* @param DB Handler acces base de donnees
|
* @param DB Handler acces base de donnees
|
||||||
|
* @param targmetmodule Name of directory of module where canvas is stored
|
||||||
|
* @param canvas Name of canvas
|
||||||
|
* @param card Name of tab (sub-canvas)
|
||||||
*/
|
*/
|
||||||
function ActionsCardCommon($DB)
|
function ActionsCardCommon($DB,$targetmodule,$canvas,$card)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
|
$this->targetmodule = $targetmodule;
|
||||||
|
$this->canvas = $canvas;
|
||||||
|
$this->card = $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -385,7 +392,7 @@ class ActionsCardCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->tpl['title'] = $this->getTitle($action);
|
$this->tpl['title'] = $this->getTitle($action);
|
||||||
|
|
||||||
$this->tpl['error'] = get_htmloutput_errors($this->object->error,$this->object->errors);
|
$this->tpl['error'] = get_htmloutput_errors($this->object->error,$this->object->errors);
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
@ -410,7 +417,7 @@ class ActionsCardCommon
|
|||||||
</script>'."\n";
|
</script>'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'create' || $action == 'edit')
|
if ($action == 'create' || $action == 'edit')
|
||||||
{
|
{
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
|
|||||||
@ -32,17 +32,23 @@ include_once(DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php');
|
|||||||
class ActionsCardDefault extends ActionsCardCommon
|
class ActionsCardDefault extends ActionsCardCommon
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
var $targetmodule;
|
||||||
//! Canvas
|
var $canvas;
|
||||||
var $canvas;
|
var $card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de la classe
|
* Constructor
|
||||||
* @param DB Handler acces base de donnees
|
* @param DB Handler acces base de donnees
|
||||||
|
* @param targmetmodule Name of directory of module where canvas is stored
|
||||||
|
* @param canvas Name of canvas
|
||||||
|
* @param card Name of tab (sub-canvas)
|
||||||
*/
|
*/
|
||||||
function ActionsCardDefault($DB)
|
function ActionsCardDefault($DB,$targetmodule,$canvas,$card)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
|
$this->targetmodule = $targetmodule;
|
||||||
|
$this->canvas = $canvas;
|
||||||
|
$this->card = $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -31,17 +31,23 @@ include_once(DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php');
|
|||||||
class ActionsCardIndividual extends ActionsCardCommon
|
class ActionsCardIndividual extends ActionsCardCommon
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
var $targetmodule;
|
||||||
|
var $canvas;
|
||||||
|
var $card;
|
||||||
|
|
||||||
//! Canvas
|
/**
|
||||||
var $canvas;
|
* Constructor
|
||||||
|
* @param DB Handler acces base de donnees
|
||||||
/**
|
* @param targmetmodule Name of directory of module where canvas is stored
|
||||||
* Constructeur de la classe
|
* @param canvas Name of canvas
|
||||||
* @param DB Handler acces base de donnees
|
* @param card Name of tab (sub-canvas)
|
||||||
*/
|
*/
|
||||||
function ActionsCardIndividual($DB)
|
function ActionsCardIndividual($DB,$targetmodule,$canvas,$card)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
|
$this->targetmodule = $targetmodule;
|
||||||
|
$this->canvas = $canvas;
|
||||||
|
$this->card = $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,6 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
@ -124,9 +123,9 @@ else
|
|||||||
|
|
||||||
if ($action == 'update')
|
if ($action == 'update')
|
||||||
{
|
{
|
||||||
// Load properties of company
|
|
||||||
$soc->fetch($socid);
|
$soc->fetch($socid);
|
||||||
}
|
}
|
||||||
|
else if ($canvas) $soc->canvas=$canvas;
|
||||||
|
|
||||||
if ($_REQUEST["private"] == 1)
|
if ($_REQUEST["private"] == 1)
|
||||||
{
|
{
|
||||||
@ -262,7 +261,7 @@ else
|
|||||||
$url=$_SERVER["PHP_SELF"]."?socid=".$soc->id;
|
$url=$_SERVER["PHP_SELF"]."?socid=".$soc->id;
|
||||||
if (($soc->client == 1 || $soc->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id;
|
if (($soc->client == 1 || $soc->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id;
|
||||||
else if ($soc->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id;
|
else if ($soc->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id;
|
||||||
Header("Location: ".$url);
|
Header("Location: ".$url);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -386,8 +385,7 @@ $formcompany = new FormCompany($db);
|
|||||||
|
|
||||||
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||||
|
|
||||||
|
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||||
if (! empty($objcanvas->template_dir))
|
|
||||||
{
|
{
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// When used with CANVAS
|
// When used with CANVAS
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user