Qual: Make module system more simple.
Change to prepare adding left menu entries by modules
This commit is contained in:
parent
a33988dc14
commit
e05f0caf60
@ -46,9 +46,8 @@ class DaoContactDefault extends Contact
|
||||
/**
|
||||
* Lecture des donnees dans la base
|
||||
* @param id Element id
|
||||
* @param action Type of action
|
||||
*/
|
||||
function fetch($id='', $action='')
|
||||
function fetch($id)
|
||||
{
|
||||
$result = parent::fetch($id);
|
||||
|
||||
|
||||
@ -40,10 +40,12 @@ $langs->load("other");
|
||||
$langs->load("commercial");
|
||||
|
||||
$errors = array();
|
||||
$socid = GETPOST("socid");
|
||||
|
||||
$action = GETPOST('action');
|
||||
|
||||
// Security check
|
||||
$id = isset($_GET["id"])?$_GET["id"]:'';
|
||||
$socid = GETPOST("socid");
|
||||
$id = GETPOST("id");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
|
||||
$object = new Contact($db);
|
||||
@ -54,8 +56,7 @@ $canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
|
||||
if (! empty($canvas))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
|
||||
$objcanvas = new Canvas($db);
|
||||
|
||||
$objcanvas = new Canvas($db,$action);
|
||||
$objcanvas->getCanvas('contact','contactcard',$canvas);
|
||||
|
||||
// Security check
|
||||
@ -72,20 +73,21 @@ else
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// If canvas is defined, because on url, or because contact was created with canvas feature on,
|
||||
// we use the canvas feature.
|
||||
// If canvas is not defined, we use standard feature.
|
||||
if (! empty($canvas))
|
||||
// If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
|
||||
// If canvas actions are not defined, we use standard feature.
|
||||
if (method_exists($objcanvas->control,'doActions'))
|
||||
{
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
|
||||
// Load data control
|
||||
$objcanvas->doActions($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// -----------------------------------------
|
||||
// When used in standard mode
|
||||
// -----------------------------------------
|
||||
|
||||
// Creation utilisateur depuis contact
|
||||
if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
|
||||
{
|
||||
@ -286,16 +288,18 @@ if ($socid > 0)
|
||||
$objsoc->fetch($socid);
|
||||
}
|
||||
|
||||
if (! empty($canvas))
|
||||
if (! empty($objcanvas->template_dir))
|
||||
{
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
//$objcanvas->doOutput($socid);
|
||||
|
||||
if (GETPOST("action") == 'create')
|
||||
if ($action == 'create')
|
||||
{
|
||||
// Set action type to objcanvas->action
|
||||
$objcanvas->setAction(GETPOST("action"));
|
||||
/*
|
||||
* Mode creation
|
||||
*/
|
||||
|
||||
// Assign _POST data to objcanvas->object->xxx
|
||||
$objcanvas->assign_post();
|
||||
@ -314,17 +318,14 @@ if (! empty($canvas))
|
||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||
|
||||
// Display canvas
|
||||
$objcanvas->display_canvas();
|
||||
$objcanvas->display_canvas('create');
|
||||
}
|
||||
else if (GETPOST("id") && GETPOST("action") == 'edit')
|
||||
else if ($action == 'edit')
|
||||
{
|
||||
/*
|
||||
* Mode edition
|
||||
*/
|
||||
|
||||
// Set action type
|
||||
$objcanvas->setAction(GETPOST("action"));
|
||||
|
||||
// Fetch object
|
||||
$result=$objcanvas->fetch($id);
|
||||
if ($result > 0)
|
||||
@ -342,19 +343,18 @@ if (! empty($canvas))
|
||||
$objcanvas->assign_values();
|
||||
|
||||
// Display canvas
|
||||
$objcanvas->display_canvas();
|
||||
$objcanvas->display_canvas('edit');
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST("id") && GETPOST("action") != 'edit')
|
||||
else
|
||||
{
|
||||
// Set action type
|
||||
$objcanvas->setAction('view');
|
||||
|
||||
/*
|
||||
* Mode view
|
||||
*/
|
||||
// Fetch object
|
||||
$result=$objcanvas->fetch($id);
|
||||
if ($result > 0)
|
||||
@ -375,7 +375,7 @@ if (! empty($canvas))
|
||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||
|
||||
// Display canvas
|
||||
$objcanvas->display_canvas();
|
||||
$objcanvas->display_canvas('view');
|
||||
|
||||
print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object);
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -19,103 +20,60 @@
|
||||
/**
|
||||
* \file htdocs/core/class/canvas.class.php
|
||||
* \ingroup core
|
||||
* \brief Fichier de la classe de gestion des canvas
|
||||
* \brief File of class to manage canvas
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \class Canvas
|
||||
* \brief Classe de la gestion des canvas
|
||||
* \brief Class to manage canvas
|
||||
*/
|
||||
|
||||
class Canvas
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
var $errors;
|
||||
var $errors=array();
|
||||
|
||||
var $card;
|
||||
var $canvas;
|
||||
var $object;
|
||||
var $control;
|
||||
var $module;
|
||||
var $targetmodule;
|
||||
var $aliasmodule; // for compatibility
|
||||
var $aliastargetmodule; // for compatibility
|
||||
var $targetmodule; // Module built into dolibarr replaced by canvas (ex: thirdparty, contact, ...)
|
||||
var $aliasmodule; // Module that provide the canvas
|
||||
var $template_dir; // Directory with all core and external templates files
|
||||
var $action;
|
||||
var $smarty;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param DB Database handler
|
||||
* @param DB Database handler
|
||||
* @param action Action ('create', 'view', 'edit')
|
||||
*/
|
||||
function Canvas($DB)
|
||||
function Canvas($DB,$action='view')
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->action = $action;
|
||||
if ($this->action == 'add') $this->action='create';
|
||||
if ($this->action == 'update') $this->action='edit';
|
||||
if (empty($this->action)) $this->action='view';
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set action type
|
||||
* @deprecated Kept for backward compatibility
|
||||
*/
|
||||
function setAction($action='view')
|
||||
{
|
||||
return $this->action = $action;
|
||||
}
|
||||
function setAction($action='view')
|
||||
{
|
||||
return $this->action = $action;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the title of card
|
||||
*/
|
||||
function getTitle()
|
||||
{
|
||||
return $this->control->getTitle($this->action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the head of card (tabs)
|
||||
*/
|
||||
function showHead()
|
||||
{
|
||||
return $this->control->showHead($this->action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigne les valeurs POST dans l'objet
|
||||
*/
|
||||
function assign_post()
|
||||
{
|
||||
return $this->control->assign_post();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute actions
|
||||
* @param Id of object (may be empty for creation)
|
||||
*/
|
||||
function doActions($id)
|
||||
{
|
||||
$out = $this->control->doActions($id);
|
||||
|
||||
$this->errors = ($this->control->errors?$this->control->errors:$this->control->object->errors);
|
||||
$this->error = ($this->control->error?$this->control->error:$this->control->object->error);
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch object values
|
||||
* @param id Element id
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
return $this->control->object->fetch($id, $this->action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get card and canvas type
|
||||
* @param module Name of target module (product, thirdparty, ...)
|
||||
* Initialize properties like ->control, ->control->object, ->template_dir
|
||||
* @param module Name of target module (thirdparty, ...)
|
||||
* @param card Type of card (ex: card, info, ...)
|
||||
* @param canvas Name of canvas (ex: mycanvas@mymodule)
|
||||
*/
|
||||
@ -125,72 +83,100 @@ class Canvas
|
||||
|
||||
$error='';
|
||||
$this->card = $card;
|
||||
$this->canvas = $canvas;
|
||||
$childmodule = $this->aliasmodule = $module;
|
||||
$targetmodule = $this->targetmodule = $module;
|
||||
|
||||
// Define this->canvas, this->targetmodule, this->aliasmodule, targetmodule, childmodule
|
||||
$this->canvas = $canvas;
|
||||
$this->targetmodule = $this->aliasmodule = $module;
|
||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
|
||||
{
|
||||
$childmodule = $this->aliasmodule = $regs[2];
|
||||
$this->canvas = $regs[1];
|
||||
$this->canvas = $regs[1];
|
||||
$this->aliasmodule = $regs[2];
|
||||
}
|
||||
|
||||
$targetmodule = $this->targetmodule;
|
||||
$childmodule = $this->aliasmodule;
|
||||
// For compatibility
|
||||
if ($childmodule == 'thirdparty') { $childmodule = $this->aliasmodule = 'societe'; }
|
||||
if ($targetmodule == 'thirdparty') { $targetmodule = 'societe'; }
|
||||
if ($childmodule == 'contact') { $childmodule = 'societe'; }
|
||||
if ($targetmodule == 'contact') { $targetmodule = 'societe'; }
|
||||
if ($targetmodule == 'thirdparty') { $targetmodule = 'societe'; }
|
||||
if ($childmodule == 'thirdparty') { $childmodule = 'societe'; $this->aliasmodule = 'societe'; }
|
||||
if ($targetmodule == 'contact') { $targetmodule = 'societe'; }
|
||||
if ($childmodule == 'contact') { $childmodule = 'societe'; }
|
||||
|
||||
|
||||
//print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>';
|
||||
//print 'this->aliasmodule='.$this->aliasmodule.' this->targetmodule='.$this->targetmodule.'<br>';
|
||||
//print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>';
|
||||
/*print 'canvas='.$this->canvas.'<br>';
|
||||
print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>';
|
||||
print 'this->aliasmodule='.$this->aliasmodule.' this->targetmodule='.$this->targetmodule.'<br>';
|
||||
print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>';
|
||||
*/
|
||||
|
||||
if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden();
|
||||
|
||||
$modelclassfile = dol_buildpath('/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/dao_'.$this->targetmodule.'_'.$this->canvas.'.class.php');
|
||||
|
||||
$controlclassfile = dol_buildpath('/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php');
|
||||
|
||||
if (file_exists($modelclassfile) && file_exists($controlclassfile))
|
||||
if (file_exists($controlclassfile))
|
||||
{
|
||||
// Include dataservice class (model)
|
||||
require_once($modelclassfile);
|
||||
// Include actions class (controller)
|
||||
require_once($controlclassfile);
|
||||
|
||||
// Include actions class (controller)
|
||||
require_once($controlclassfile);
|
||||
|
||||
// Include specific library
|
||||
$libfile = dol_buildpath('/'.$this->aliasmodule.'/lib/'.$this->aliasmodule.'.lib.php');
|
||||
if (file_exists($libfile)) require_once($libfile);
|
||||
|
||||
// Instantiate actions class (controller)
|
||||
$controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas);
|
||||
$this->control = new $controlclassname($this->db);
|
||||
|
||||
// Instantiate dataservice class (model)
|
||||
$modelclassname = 'Dao'.ucfirst($this->targetmodule).ucfirst($this->canvas);
|
||||
$this->control->object = new $modelclassname($this->db);
|
||||
|
||||
// Canvas
|
||||
$this->control->canvas = $canvas;
|
||||
|
||||
// Template dir
|
||||
$this->template_dir = dol_buildpath('/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/tpl/');
|
||||
|
||||
// Need smarty
|
||||
$this->smarty = $this->control->smarty;
|
||||
}
|
||||
else
|
||||
{
|
||||
//print 'access ko';
|
||||
accessforbidden();
|
||||
// Instantiate actions class (controller)
|
||||
$controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas);
|
||||
$this->control = new $controlclassname($this->db);
|
||||
}
|
||||
|
||||
// TODO Dao should be declared and used by controller or templates when required only
|
||||
$modelclassfile = dol_buildpath('/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/dao_'.$this->targetmodule.'_'.$this->canvas.'.class.php');
|
||||
if (file_exists($modelclassfile))
|
||||
{
|
||||
// Include dataservice class (model)
|
||||
require_once($modelclassfile);
|
||||
|
||||
// Instantiate dataservice class (model)
|
||||
$modelclassname = 'Dao'.ucfirst($this->targetmodule).ucfirst($this->canvas);
|
||||
$this->control->object = new $modelclassname($this->db);
|
||||
}
|
||||
|
||||
// Include specific library
|
||||
// FIXME Specific libraries must be included by files that need them only, so by actions and/or dao files.
|
||||
$libfile = dol_buildpath('/'.$this->aliasmodule.'/lib/'.$this->aliasmodule.'.lib.php');
|
||||
if (file_exists($libfile)) require_once($libfile);
|
||||
|
||||
// Template dir
|
||||
$this->template_dir = dol_buildpath('/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/tpl/');
|
||||
if (! is_dir($this->template_dir))
|
||||
{
|
||||
$this->template_dir='';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute actions
|
||||
* @param Id of object (may be empty for creation)
|
||||
*/
|
||||
function doActions($id)
|
||||
{
|
||||
$out='';
|
||||
|
||||
// If function to do actions is overwritten, we use new one
|
||||
if (method_exists($this->control,'doActions'))
|
||||
{
|
||||
$out = $this->control->doActions($id);
|
||||
|
||||
$this->errors = ($this->control->errors?$this->control->errors:$this->control->object->errors);
|
||||
$this->error = ($this->control->error?$this->control->error:$this->control->object->error);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch object values
|
||||
* @param id Element id
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
return $this->control->object->fetch($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permissions of a user to show a page and an object. Check read permission
|
||||
* Check permissions of a user to show a page and an object. Check read permission.
|
||||
* If $_REQUEST['action'] defined, we also check write permission.
|
||||
* @param user User to check
|
||||
* @param features Features to check (in most cases, it's module name)
|
||||
@ -203,45 +189,60 @@ class Canvas
|
||||
*/
|
||||
function restrictedArea($user, $features='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
|
||||
{
|
||||
return $this->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
|
||||
// If function to check permission is overwritten, we use new one
|
||||
if (method_exists($this->control,'restrictedArea')) return $this->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
|
||||
else return restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Return the title of card
|
||||
* // FIXME An output function is stored inside an action class. Must change this.
|
||||
*/
|
||||
function getTitle()
|
||||
{
|
||||
if (method_exists($this->control,'getTitle')) return $this->control->getTitle($this->action);
|
||||
else return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the head of card (tabs)
|
||||
* // FIXME An output function is stored inside an action class. Must change this.
|
||||
*/
|
||||
function showHead()
|
||||
{
|
||||
if (method_exists($this->control,'showHead')) return $this->control->showHead($this->action);
|
||||
else return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigne les valeurs POST dans l'objet
|
||||
* // FIXME This is useless. POST is already visible from everywhere.
|
||||
*/
|
||||
function assign_post()
|
||||
{
|
||||
if (method_exists($this->control,'assign_post')) $this->control->assign_post();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared method for canvas to assign values of templates
|
||||
* @param action Type of action
|
||||
*/
|
||||
function assign_values()
|
||||
{
|
||||
/*if (!empty($this->smarty))
|
||||
{
|
||||
global $smarty;
|
||||
|
||||
$this->control->assign_smarty_values($smarty, $this->action);
|
||||
$smarty->template_dir = $this->template_dir;
|
||||
}
|
||||
else
|
||||
{*/
|
||||
$this->control->assign_values($this->action);
|
||||
/*}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Display canvas
|
||||
* Display canvas
|
||||
* @param mode 'create', 'view', 'edit'
|
||||
*/
|
||||
function display_canvas()
|
||||
function display_canvas($mode='view')
|
||||
{
|
||||
global $conf, $langs, $user, $canvas;
|
||||
|
||||
/*if (!empty($this->smarty))
|
||||
{
|
||||
global $smarty;
|
||||
|
||||
$smarty->display($this->action.'.tpl');
|
||||
}
|
||||
else
|
||||
{*/
|
||||
include($this->template_dir.$this->card.'_'.$this->action.'.tpl.php'); // Include native PHP template
|
||||
/*}*/
|
||||
//print $this->template_dir.$this->card.'_'.$mode.'.tpl.php';exit;
|
||||
include($this->template_dir.$this->card.'_'.$mode.'.tpl.php'); // Include native PHP template
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1240,7 +1240,8 @@ class CommonObject
|
||||
|
||||
/**
|
||||
* Load type of canvas of an object
|
||||
* @param id element id
|
||||
* @param id Record id
|
||||
* @param ref Record ref
|
||||
*/
|
||||
function getCanvas($id=0,$ref='')
|
||||
{
|
||||
|
||||
@ -72,7 +72,7 @@ class ActionsCardCommon
|
||||
{
|
||||
$this->tpl[$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
@ -110,7 +110,7 @@ class ActionsCardCommon
|
||||
})
|
||||
</script>'."\n";
|
||||
}
|
||||
|
||||
|
||||
// Load object modCodeClient
|
||||
$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
|
||||
@ -138,11 +138,11 @@ class ActionsCardCommon
|
||||
$this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
|
||||
$s=$modCodeClient->getToolTip($langs,$this->object,0);
|
||||
$this->tpl['help_customercode'] = $form->textwithpicto('',$s,1);
|
||||
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
$this->tpl['supplier_enabled'] = 1;
|
||||
|
||||
|
||||
// Load object modCodeFournisseur
|
||||
$module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
|
||||
if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
@ -155,7 +155,7 @@ class ActionsCardCommon
|
||||
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
|
||||
// We verified if the tag prefix is used
|
||||
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
|
||||
|
||||
|
||||
// Supplier
|
||||
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1);
|
||||
$this->tpl['suppliercode'] = $this->object->code_fournisseur;
|
||||
@ -163,7 +163,7 @@ class ActionsCardCommon
|
||||
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
|
||||
$s=$modCodeFournisseur->getToolTip($langs,$this->object,1);
|
||||
$this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1);
|
||||
|
||||
|
||||
$this->object->LoadSupplierCateg();
|
||||
$this->tpl['suppliercategory'] = $this->object->SupplierCategories;
|
||||
$this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1);
|
||||
@ -588,7 +588,7 @@ class ActionsCardCommon
|
||||
}
|
||||
|
||||
$oldsoccanvas = new Canvas($this->db);
|
||||
$oldsoccanvas->getCanvas('thirdparty','card',$this->canvas);
|
||||
$oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
|
||||
$result=$oldsoccanvas->fetch($socid);
|
||||
|
||||
// To not set code if third party is not concerned. But if it had values, we keep them.
|
||||
|
||||
@ -46,9 +46,8 @@ class DaoThirdPartyDefault extends Societe
|
||||
/**
|
||||
* Lecture des donnees dans la base
|
||||
* @param id Element id
|
||||
* @param action Type of action
|
||||
*/
|
||||
function fetch($id='', $action='')
|
||||
function fetch($id)
|
||||
{
|
||||
$result = parent::fetch($id);
|
||||
|
||||
|
||||
@ -44,9 +44,8 @@ class DaoThirdPartyIndividual extends Societe
|
||||
/**
|
||||
* Lecture des donnees dans la base
|
||||
* @param id Element id
|
||||
* @param action Type of action
|
||||
*/
|
||||
function fetch($id='', $action='')
|
||||
function fetch($id)
|
||||
{
|
||||
$result = parent::fetch($id);
|
||||
|
||||
|
||||
@ -44,7 +44,10 @@ $langs->load("banks");
|
||||
$langs->load("users");
|
||||
if ($conf->notification->enabled) $langs->load("mails");
|
||||
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
$action = GETPOST('action');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
|
||||
$soc = new Societe($db);
|
||||
@ -55,12 +58,10 @@ $canvas = (!empty($soc->canvas)?$soc->canvas:GETPOST("canvas"));
|
||||
if (! empty($canvas))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
|
||||
$soccanvas = new Canvas($db);
|
||||
|
||||
$soccanvas->getCanvas('thirdparty','card',$canvas);
|
||||
|
||||
$objcanvas = new Canvas($db,$action);
|
||||
$objcanvas->getCanvas('thirdparty','card',$canvas);
|
||||
// Security check
|
||||
$result = $soccanvas->restrictedArea($user, 'societe', $socid);
|
||||
$result = $objcanvas->restrictedArea($user, 'societe', $socid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -74,17 +75,14 @@ else
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// If canvas is defined, because on url, or because company was created with canvas feature on,
|
||||
// we use the canvas feature.
|
||||
// If canvas is not defined, we use standard feature.
|
||||
if (! empty($canvas))
|
||||
// If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
|
||||
// If canvas actions are not defined, we use standard feature.
|
||||
if (method_exists($objcanvas->control,'doActions'))
|
||||
{
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
|
||||
// Load data control
|
||||
$soccanvas->doActions($socid);
|
||||
$objcanvas->doActions($socid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -283,7 +281,6 @@ else
|
||||
else
|
||||
{
|
||||
$soc->id = $socid;
|
||||
$reload = 0;
|
||||
|
||||
$mesg = $soc->error;
|
||||
$_GET["action"]= "edit";
|
||||
@ -304,7 +301,6 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
$reload = 0;
|
||||
$langs->load("errors");
|
||||
$mesg=$langs->trans($soc->error);
|
||||
$_GET["action"]='';
|
||||
@ -371,67 +367,61 @@ $formcompany = new FormCompany($db);
|
||||
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
|
||||
|
||||
if (! empty($canvas))
|
||||
if (! empty($objcanvas->template_dir))
|
||||
{
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || GETPOST("action") == 'create')
|
||||
if ($action == 'create')
|
||||
{
|
||||
/*
|
||||
* Mode creation
|
||||
*/
|
||||
|
||||
// Set action type
|
||||
$soccanvas->setAction(GETPOST("action"));
|
||||
|
||||
// Card header
|
||||
$title = $soccanvas->getTitle();
|
||||
print_fiche_titre($title);
|
||||
/*
|
||||
* Mode creation
|
||||
*/
|
||||
|
||||
// Assign _POST data
|
||||
$soccanvas->assign_post();
|
||||
$objcanvas->assign_post();
|
||||
|
||||
// Assign template values
|
||||
$soccanvas->assign_values();
|
||||
$objcanvas->assign_values();
|
||||
|
||||
// Card header
|
||||
$title = $objcanvas->getTitle();
|
||||
print_fiche_titre($title);
|
||||
|
||||
// Show errors
|
||||
dol_htmloutput_errors($soccanvas->error,$soccanvas->errors);
|
||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||
|
||||
// Display canvas
|
||||
$soccanvas->display_canvas();
|
||||
$objcanvas->display_canvas('create');
|
||||
}
|
||||
elseif (GETPOST("action") == 'edit')
|
||||
elseif ($action == 'edit')
|
||||
{
|
||||
/*
|
||||
* Mode edition
|
||||
*/
|
||||
|
||||
// Set action type
|
||||
$soccanvas->setAction(GETPOST("action"));
|
||||
|
||||
// Card header
|
||||
$title = $soccanvas->getTitle();
|
||||
$title = $objcanvas->getTitle();
|
||||
print_fiche_titre($title);
|
||||
|
||||
if ($reload || ! $_POST["nom"])
|
||||
if (! $_POST["nom"])
|
||||
{
|
||||
//Reload object
|
||||
$soccanvas->fetch($socid);
|
||||
$objcanvas->fetch($socid);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assign _POST data
|
||||
$soccanvas->assign_post();
|
||||
$objcanvas->assign_post();
|
||||
}
|
||||
|
||||
dol_htmloutput_errors($soccanvas->error,$soccanvas->errors);
|
||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||
|
||||
// Assign values
|
||||
$soccanvas->assign_values();
|
||||
$objcanvas->assign_values();
|
||||
|
||||
// Display canvas
|
||||
$soccanvas->display_canvas();
|
||||
$objcanvas->display_canvas('edit');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -439,21 +429,18 @@ if (! empty($canvas))
|
||||
* Mode view
|
||||
*/
|
||||
|
||||
// Set action type
|
||||
$soccanvas->setAction('view');
|
||||
|
||||
// Fetch object
|
||||
$result=$soccanvas->fetch($socid);
|
||||
$result=$objcanvas->fetch($socid);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Card header
|
||||
$soccanvas->showHead();
|
||||
$objcanvas->showHead();
|
||||
|
||||
// Assign values
|
||||
$soccanvas->assign_values();
|
||||
$objcanvas->assign_values();
|
||||
|
||||
// Display canvas
|
||||
$soccanvas->display_canvas();
|
||||
$objcanvas->display_canvas('view');
|
||||
|
||||
|
||||
print '<table width="100%"><tr><td valign="top" width="50%">';
|
||||
@ -469,7 +456,7 @@ if (! empty($canvas))
|
||||
|
||||
$var=true;
|
||||
|
||||
$somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$soccanvas->control->object->default_lang);
|
||||
$somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang);
|
||||
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
@ -477,19 +464,19 @@ if (! empty($canvas))
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Subsidiaries list
|
||||
$result=show_subsidiaries($conf,$langs,$db,$soccanvas->control->object);
|
||||
$result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object);
|
||||
|
||||
// Contacts list
|
||||
$result=show_contacts($conf,$langs,$db,$soccanvas->control->object);
|
||||
$result=show_contacts($conf,$langs,$db,$objcanvas->control->object);
|
||||
|
||||
// Projects list
|
||||
$result=show_projects($conf,$langs,$db,$soccanvas->control->object);
|
||||
$result=show_projects($conf,$langs,$db,$objcanvas->control->object);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_htmloutput_errors($soccanvas->error,$soccanvas->errors);
|
||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -499,7 +486,7 @@ else
|
||||
// -----------------------------------------
|
||||
// When used in standard mode
|
||||
// -----------------------------------------
|
||||
if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || GETPOST('action') == 'create')
|
||||
if (GETPOST('action') == 'create')
|
||||
{
|
||||
/*
|
||||
* Creation
|
||||
@ -762,7 +749,7 @@ else
|
||||
print '</td></tr>';
|
||||
|
||||
// State
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
||||
if ($soc->pays_id)
|
||||
@ -775,7 +762,7 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Phone / Fax
|
||||
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
||||
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
|
||||
@ -978,7 +965,7 @@ else
|
||||
$prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
|
||||
}
|
||||
|
||||
if ($reload || ! $_POST["nom"])
|
||||
if (! $_POST["nom"])
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->id = $socid;
|
||||
@ -1187,13 +1174,13 @@ else
|
||||
print '</td></tr>';
|
||||
|
||||
// State
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
||||
$formcompany->select_departement($soc->departement_id,$soc->pays_code);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Phone / Fax
|
||||
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
||||
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
|
||||
@ -1606,7 +1593,7 @@ else
|
||||
}
|
||||
|
||||
// Ban
|
||||
if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT))
|
||||
if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT))
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
@ -1622,9 +1609,9 @@ else
|
||||
print $soc->display_rib();
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Parent company
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY))
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY))
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
@ -1649,7 +1636,7 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Commercial
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
@ -1769,7 +1756,7 @@ else
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Subsidiaries list
|
||||
$result=show_subsidiaries($conf,$langs,$db,$soc);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user