Qual: Make module system more simple.

Change to prepare adding left menu entries by modules
This commit is contained in:
Laurent Destailleur 2011-04-06 14:26:43 +00:00
parent a33988dc14
commit e05f0caf60
8 changed files with 230 additions and 244 deletions

View File

@ -46,9 +46,8 @@ class DaoContactDefault extends Contact
/** /**
* Lecture des donnees dans la base * Lecture des donnees dans la base
* @param id Element id * @param id Element id
* @param action Type of action
*/ */
function fetch($id='', $action='') function fetch($id)
{ {
$result = parent::fetch($id); $result = parent::fetch($id);

View File

@ -40,10 +40,12 @@ $langs->load("other");
$langs->load("commercial"); $langs->load("commercial");
$errors = array(); $errors = array();
$socid = GETPOST("socid");
$action = GETPOST('action');
// Security check // Security check
$id = isset($_GET["id"])?$_GET["id"]:''; $socid = GETPOST("socid");
$id = GETPOST("id");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$object = new Contact($db); $object = new Contact($db);
@ -54,8 +56,7 @@ $canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
if (! empty($canvas)) if (! empty($canvas))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
$objcanvas = new Canvas($db); $objcanvas = new Canvas($db,$action);
$objcanvas->getCanvas('contact','contactcard',$canvas); $objcanvas->getCanvas('contact','contactcard',$canvas);
// Security check // Security check
@ -72,20 +73,21 @@ else
* Actions * Actions
*/ */
// If canvas is defined, because on url, or because contact was created with canvas feature on, // If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
// we use the canvas feature. // If canvas actions are not defined, we use standard feature.
// If canvas is not defined, we use standard feature. if (method_exists($objcanvas->control,'doActions'))
if (! empty($canvas))
{ {
// ----------------------------------------- // -----------------------------------------
// When used with CANVAS // When used with CANVAS
// ----------------------------------------- // -----------------------------------------
// Load data control
$objcanvas->doActions($id); $objcanvas->doActions($id);
} }
else else
{ {
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
// Creation utilisateur depuis contact // Creation utilisateur depuis contact
if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
{ {
@ -286,16 +288,18 @@ if ($socid > 0)
$objsoc->fetch($socid); $objsoc->fetch($socid);
} }
if (! empty($canvas)) if (! empty($objcanvas->template_dir))
{ {
// ----------------------------------------- // -----------------------------------------
// When used with CANVAS // 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 // Assign _POST data to objcanvas->object->xxx
$objcanvas->assign_post(); $objcanvas->assign_post();
@ -314,17 +318,14 @@ if (! empty($canvas))
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors); dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
// Display canvas // Display canvas
$objcanvas->display_canvas(); $objcanvas->display_canvas('create');
} }
else if (GETPOST("id") && GETPOST("action") == 'edit') else if ($action == 'edit')
{ {
/* /*
* Mode edition * Mode edition
*/ */
// Set action type
$objcanvas->setAction(GETPOST("action"));
// Fetch object // Fetch object
$result=$objcanvas->fetch($id); $result=$objcanvas->fetch($id);
if ($result > 0) if ($result > 0)
@ -342,19 +343,18 @@ if (! empty($canvas))
$objcanvas->assign_values(); $objcanvas->assign_values();
// Display canvas // Display canvas
$objcanvas->display_canvas(); $objcanvas->display_canvas('edit');
} }
else else
{ {
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors); dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
} }
} }
else
if (GETPOST("id") && GETPOST("action") != 'edit')
{ {
// Set action type /*
$objcanvas->setAction('view'); * Mode view
*/
// Fetch object // Fetch object
$result=$objcanvas->fetch($id); $result=$objcanvas->fetch($id);
if ($result > 0) if ($result > 0)
@ -375,7 +375,7 @@ if (! empty($canvas))
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors); dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
// Display canvas // Display canvas
$objcanvas->display_canvas(); $objcanvas->display_canvas('view');
print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object); print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object);

View File

@ -1,5 +1,6 @@
<?php <?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 * 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 * it under the terms of the GNU General Public License as published by
@ -19,46 +20,49 @@
/** /**
* \file htdocs/core/class/canvas.class.php * \file htdocs/core/class/canvas.class.php
* \ingroup core * \ingroup core
* \brief Fichier de la classe de gestion des canvas * \brief File of class to manage canvas
* \version $Id$ * \version $Id$
*/ */
/** /**
* \class Canvas * \class Canvas
* \brief Classe de la gestion des canvas * \brief Class to manage canvas
*/ */
class Canvas class Canvas
{ {
var $db; var $db;
var $error; var $error;
var $errors; var $errors=array();
var $card; var $card;
var $canvas; var $canvas;
var $object; var $object;
var $control; var $control;
var $module; var $module;
var $targetmodule; var $targetmodule; // Module built into dolibarr replaced by canvas (ex: thirdparty, contact, ...)
var $aliasmodule; // for compatibility var $aliasmodule; // Module that provide the canvas
var $aliastargetmodule; // for compatibility
var $template_dir; // Directory with all core and external templates files var $template_dir; // Directory with all core and external templates files
var $action; var $action;
var $smarty;
/** /**
* Constructor. * 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->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 * Set action type
* @deprecated Kept for backward compatibility
*/ */
function setAction($action='view') function setAction($action='view')
{ {
@ -66,28 +70,80 @@ class Canvas
} }
/**
* Return the title of card
*/
function getTitle()
{
return $this->control->getTitle($this->action);
}
/** /**
* Return the head of card (tabs) * 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)
*/ */
function showHead() function getCanvas($module,$card,$canvas)
{ {
return $this->control->showHead($this->action); global $conf, $langs;
$error='';
$this->card = $card;
// Define this->canvas, this->targetmodule, this->aliasmodule, targetmodule, childmodule
$this->canvas = $canvas;
$this->targetmodule = $this->aliasmodule = $module;
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
{
$this->canvas = $regs[1];
$this->aliasmodule = $regs[2];
}
$targetmodule = $this->targetmodule;
$childmodule = $this->aliasmodule;
// For compatibility
if ($targetmodule == 'thirdparty') { $targetmodule = 'societe'; }
if ($childmodule == 'thirdparty') { $childmodule = 'societe'; $this->aliasmodule = 'societe'; }
if ($targetmodule == 'contact') { $targetmodule = 'societe'; }
if ($childmodule == 'contact') { $childmodule = 'societe'; }
/*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();
$controlclassfile = dol_buildpath('/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php');
if (file_exists($controlclassfile))
{
// Include actions class (controller)
require_once($controlclassfile);
// 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
* Assigne les valeurs POST dans l'objet $modelclassfile = dol_buildpath('/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/dao_'.$this->targetmodule.'_'.$this->canvas.'.class.php');
*/ if (file_exists($modelclassfile))
function assign_post()
{ {
return $this->control->assign_post(); // 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;
} }
/** /**
@ -95,11 +151,17 @@ class Canvas
* @param Id of object (may be empty for creation) * @param Id of object (may be empty for creation)
*/ */
function doActions($id) 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); $out = $this->control->doActions($id);
$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);
}
return $out; return $out;
} }
@ -110,87 +172,11 @@ class Canvas
*/ */
function fetch($id) function fetch($id)
{ {
return $this->control->object->fetch($id, $this->action); return $this->control->object->fetch($id);
} }
/** /**
* Get card and canvas type * Check permissions of a user to show a page and an object. Check read permission.
* @param module Name of target module (product, thirdparty, ...)
* @param card Type of card (ex: card, info, ...)
* @param canvas Name of canvas (ex: mycanvas@mymodule)
*/
function getCanvas($module,$card,$canvas)
{
global $conf, $langs;
$error='';
$this->card = $card;
$this->canvas = $canvas;
$childmodule = $this->aliasmodule = $module;
$targetmodule = $this->targetmodule = $module;
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
{
$childmodule = $this->aliasmodule = $regs[2];
$this->canvas = $regs[1];
}
// For compatibility
if ($childmodule == 'thirdparty') { $childmodule = $this->aliasmodule = 'societe'; }
if ($targetmodule == 'thirdparty') { $targetmodule = 'societe'; }
if ($childmodule == 'contact') { $childmodule = 'societe'; }
if ($targetmodule == 'contact') { $targetmodule = '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>';
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))
{
// Include dataservice class (model)
require_once($modelclassfile);
// 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();
}
return 1;
}
/**
* Check permissions of a user to show a page and an object. Check read permission
* If $_REQUEST['action'] defined, we also check write permission. * If $_REQUEST['action'] defined, we also check write permission.
* @param user User to check * @param user User to check
* @param features Features to check (in most cases, it's module name) * @param features Features to check (in most cases, it's module name)
@ -203,7 +189,39 @@ class Canvas
*/ */
function restrictedArea($user, $features='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') 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();
} }
/** /**
@ -212,36 +230,19 @@ class Canvas
*/ */
function assign_values() 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); $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; global $conf, $langs, $user, $canvas;
/*if (!empty($this->smarty)) //print $this->template_dir.$this->card.'_'.$mode.'.tpl.php';exit;
{ include($this->template_dir.$this->card.'_'.$mode.'.tpl.php'); // Include native PHP template
global $smarty;
$smarty->display($this->action.'.tpl');
}
else
{*/
include($this->template_dir.$this->card.'_'.$this->action.'.tpl.php'); // Include native PHP template
/*}*/
} }
} }

View File

@ -1240,7 +1240,8 @@ class CommonObject
/** /**
* Load type of canvas of an object * Load type of canvas of an object
* @param id element id * @param id Record id
* @param ref Record ref
*/ */
function getCanvas($id=0,$ref='') function getCanvas($id=0,$ref='')
{ {

View File

@ -588,7 +588,7 @@ class ActionsCardCommon
} }
$oldsoccanvas = new Canvas($this->db); $oldsoccanvas = new Canvas($this->db);
$oldsoccanvas->getCanvas('thirdparty','card',$this->canvas); $oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
$result=$oldsoccanvas->fetch($socid); $result=$oldsoccanvas->fetch($socid);
// To not set code if third party is not concerned. But if it had values, we keep them. // To not set code if third party is not concerned. But if it had values, we keep them.

View File

@ -46,9 +46,8 @@ class DaoThirdPartyDefault extends Societe
/** /**
* Lecture des donnees dans la base * Lecture des donnees dans la base
* @param id Element id * @param id Element id
* @param action Type of action
*/ */
function fetch($id='', $action='') function fetch($id)
{ {
$result = parent::fetch($id); $result = parent::fetch($id);

View File

@ -44,9 +44,8 @@ class DaoThirdPartyIndividual extends Societe
/** /**
* Lecture des donnees dans la base * Lecture des donnees dans la base
* @param id Element id * @param id Element id
* @param action Type of action
*/ */
function fetch($id='', $action='') function fetch($id)
{ {
$result = parent::fetch($id); $result = parent::fetch($id);

View File

@ -44,7 +44,10 @@ $langs->load("banks");
$langs->load("users"); $langs->load("users");
if ($conf->notification->enabled) $langs->load("mails"); 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; if ($user->societe_id) $socid=$user->societe_id;
$soc = new Societe($db); $soc = new Societe($db);
@ -55,12 +58,10 @@ $canvas = (!empty($soc->canvas)?$soc->canvas:GETPOST("canvas"));
if (! empty($canvas)) if (! empty($canvas))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
$soccanvas = new Canvas($db); $objcanvas = new Canvas($db,$action);
$objcanvas->getCanvas('thirdparty','card',$canvas);
$soccanvas->getCanvas('thirdparty','card',$canvas);
// Security check // Security check
$result = $soccanvas->restrictedArea($user, 'societe', $socid); $result = $objcanvas->restrictedArea($user, 'societe', $socid);
} }
else else
{ {
@ -74,17 +75,14 @@ else
* Actions * Actions
*/ */
// If canvas is defined, because on url, or because company was created with canvas feature on, // If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
// we use the canvas feature. // If canvas actions are not defined, we use standard feature.
// If canvas is not defined, we use standard feature. if (method_exists($objcanvas->control,'doActions'))
if (! empty($canvas))
{ {
// ----------------------------------------- // -----------------------------------------
// When used with CANVAS // When used with CANVAS
// ----------------------------------------- // -----------------------------------------
$objcanvas->doActions($socid);
// Load data control
$soccanvas->doActions($socid);
} }
else else
{ {
@ -283,7 +281,6 @@ else
else else
{ {
$soc->id = $socid; $soc->id = $socid;
$reload = 0;
$mesg = $soc->error; $mesg = $soc->error;
$_GET["action"]= "edit"; $_GET["action"]= "edit";
@ -304,7 +301,6 @@ else
} }
else else
{ {
$reload = 0;
$langs->load("errors"); $langs->load("errors");
$mesg=$langs->trans($soc->error); $mesg=$langs->trans($soc->error);
$_GET["action"]=''; $_GET["action"]='';
@ -371,67 +367,61 @@ $formcompany = new FormCompany($db);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if (! empty($canvas)) if (! empty($objcanvas->template_dir))
{ {
// ----------------------------------------- // -----------------------------------------
// When used with CANVAS // When used with CANVAS
// ----------------------------------------- // -----------------------------------------
if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || GETPOST("action") == 'create') if ($action == 'create')
{ {
/* /*
* Mode creation * Mode creation
*/ */
// Set action type
$soccanvas->setAction(GETPOST("action"));
// Card header
$title = $soccanvas->getTitle();
print_fiche_titre($title);
// Assign _POST data // Assign _POST data
$soccanvas->assign_post(); $objcanvas->assign_post();
// Assign template values // Assign template values
$soccanvas->assign_values(); $objcanvas->assign_values();
// Card header
$title = $objcanvas->getTitle();
print_fiche_titre($title);
// Show errors // Show errors
dol_htmloutput_errors($soccanvas->error,$soccanvas->errors); dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
// Display canvas // Display canvas
$soccanvas->display_canvas(); $objcanvas->display_canvas('create');
} }
elseif (GETPOST("action") == 'edit') elseif ($action == 'edit')
{ {
/* /*
* Mode edition * Mode edition
*/ */
// Set action type
$soccanvas->setAction(GETPOST("action"));
// Card header // Card header
$title = $soccanvas->getTitle(); $title = $objcanvas->getTitle();
print_fiche_titre($title); print_fiche_titre($title);
if ($reload || ! $_POST["nom"]) if (! $_POST["nom"])
{ {
//Reload object //Reload object
$soccanvas->fetch($socid); $objcanvas->fetch($socid);
} }
else else
{ {
// Assign _POST data // 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 // Assign values
$soccanvas->assign_values(); $objcanvas->assign_values();
// Display canvas // Display canvas
$soccanvas->display_canvas(); $objcanvas->display_canvas('edit');
} }
else else
{ {
@ -439,21 +429,18 @@ if (! empty($canvas))
* Mode view * Mode view
*/ */
// Set action type
$soccanvas->setAction('view');
// Fetch object // Fetch object
$result=$soccanvas->fetch($socid); $result=$objcanvas->fetch($socid);
if ($result > 0) if ($result > 0)
{ {
// Card header // Card header
$soccanvas->showHead(); $objcanvas->showHead();
// Assign values // Assign values
$soccanvas->assign_values(); $objcanvas->assign_values();
// Display canvas // Display canvas
$soccanvas->display_canvas(); $objcanvas->display_canvas('view');
print '<table width="100%"><tr><td valign="top" width="50%">'; print '<table width="100%"><tr><td valign="top" width="50%">';
@ -469,7 +456,7 @@ if (! empty($canvas))
$var=true; $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>';
print '<td></td>'; print '<td></td>';
@ -479,17 +466,17 @@ if (! empty($canvas))
print '<br>'; print '<br>';
// Subsidiaries list // Subsidiaries list
$result=show_subsidiaries($conf,$langs,$db,$soccanvas->control->object); $result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object);
// Contacts list // Contacts list
$result=show_contacts($conf,$langs,$db,$soccanvas->control->object); $result=show_contacts($conf,$langs,$db,$objcanvas->control->object);
// Projects list // Projects list
$result=show_projects($conf,$langs,$db,$soccanvas->control->object); $result=show_projects($conf,$langs,$db,$objcanvas->control->object);
} }
else 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 // When used in standard mode
// ----------------------------------------- // -----------------------------------------
if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || GETPOST('action') == 'create') if (GETPOST('action') == 'create')
{ {
/* /*
* Creation * Creation
@ -978,7 +965,7 @@ else
$prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
} }
if ($reload || ! $_POST["nom"]) if (! $_POST["nom"])
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->id = $socid; $soc->id = $socid;