Fix: The child class must do itself the include of its mother class file.

This commit is contained in:
Laurent Destailleur 2010-09-05 18:10:23 +00:00
parent c0a5c3f428
commit c02dc30b68
3 changed files with 51 additions and 53 deletions

View File

@ -32,7 +32,7 @@
class Canvas class Canvas
{ {
var $db; var $db;
var $card; var $card;
var $canvas; var $canvas;
var $object; var $object;
@ -55,7 +55,7 @@ class Canvas
{ {
$this->db = $DB; $this->db = $DB;
} }
/** /**
* Return the title of card * Return the title of card
*/ */
@ -63,7 +63,7 @@ class Canvas
{ {
return $this->control->getTitle($this->action); return $this->control->getTitle($this->action);
} }
/** /**
* Assigne les valeurs POST dans l'objet * Assigne les valeurs POST dans l'objet
*/ */
@ -71,7 +71,7 @@ class Canvas
{ {
return $this->control->assign_post(); return $this->control->assign_post();
} }
/** /**
* Set action type * Set action type
*/ */
@ -79,7 +79,7 @@ class Canvas
{ {
return $this->action = $action; return $this->action = $action;
} }
/** /**
* Load data control * Load data control
*/ */
@ -87,7 +87,7 @@ class Canvas
{ {
return $this->control->loadControl($socid); return $this->control->loadControl($socid);
} }
/** /**
* Fetch object values * Fetch object values
* @param id Element id * @param id Element id
@ -117,7 +117,7 @@ class Canvas
{ {
$childmodule = $this->aliasmodule = $this->module = $regs[2]; $childmodule = $this->aliasmodule = $this->module = $regs[2];
$this->canvas = $regs[1]; $this->canvas = $regs[1];
// For compatibility // For compatibility
if ($this->module == 'thirdparty') $childmodule = $this->aliasmodule = 'societe'; if ($this->module == 'thirdparty') $childmodule = $this->aliasmodule = 'societe';
if ($this->targetmodule == 'thirdparty') $targetmodule = $this->aliastargetmodule = 'societe'; if ($this->targetmodule == 'thirdparty') $targetmodule = $this->aliastargetmodule = 'societe';
@ -125,38 +125,34 @@ class Canvas
//print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>'; //print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>';
//print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>'; //print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>';
if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden(); if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden();
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->targetmodule.'.'.$this->canvas.'.class.php') && if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->targetmodule.'.'.$this->canvas.'.class.php') &&
file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php')) file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php'))
{ {
// Include model class // Include dataservice class (model)
$modelclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->targetmodule.'.'.$this->canvas.'.class.php'; $modelclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->targetmodule.'.'.$this->canvas.'.class.php';
include_once($modelclassfile); include_once($modelclassfile);
// Include common controller class // Include actions class (controller)
$controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliastargetmodule.'/canvas/'.$this->card.'.common.class.php';
include_once($controlclassfile);
// Include canvas controller class
$controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php'; $controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php';
include_once($controlclassfile); include_once($controlclassfile);
// Instantiate canvas controller class // Instantiate canvas controller class
$controlclassname = ucfirst($this->card).ucfirst($this->canvas); $controlclassname = ucfirst($this->card).ucfirst($this->canvas);
$this->control = new $controlclassname($this->db); $this->control = new $controlclassname($this->db);
// Instantiate model class // Instantiate model class
$modelclassname = ucfirst($this->targetmodule).ucfirst($this->canvas); $modelclassname = ucfirst($this->targetmodule).ucfirst($this->canvas);
$this->control->object = new $modelclassname($this->db); $this->control->object = new $modelclassname($this->db);
// Canvas // Canvas
$this->control->canvas = $canvas; $this->control->canvas = $canvas;
// Template dir // Template dir
$this->template_dir = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/tpl/'; $this->template_dir = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/tpl/';
// Need smarty // Need smarty
$this->smarty = $this->control->smarty; $this->smarty = $this->control->smarty;
} }
@ -164,7 +160,7 @@ class Canvas
{ {
accessforbidden(); accessforbidden();
} }
return 1; return 1;
} }

View File

@ -22,6 +22,7 @@
* \brief Fichier de la classe Thirdparty card controller (default canvas) * \brief Fichier de la classe Thirdparty card controller (default canvas)
* \version $Id$ * \version $Id$
*/ */
include_once(DOL_DOCUMENT_ROOT.'/societe/canvas/card.common.class.php');
/** /**
* \class ThirdPartyCardDefault * \class ThirdPartyCardDefault
@ -30,10 +31,10 @@
class CardDefault extends CardCommon class CardDefault extends CardCommon
{ {
var $db; var $db;
//! Canvas //! Canvas
var $canvas; var $canvas;
/** /**
* Constructeur de la classe * Constructeur de la classe
* @param DB Handler acces base de donnees * @param DB Handler acces base de donnees
@ -55,10 +56,10 @@ class CardDefault extends CardCommon
if ($action == 'view') $out.= $langs->trans("ThirdParty"); if ($action == 'view') $out.= $langs->trans("ThirdParty");
if ($action == 'edit') $out.= $langs->trans("EditCompany"); if ($action == 'edit') $out.= $langs->trans("EditCompany");
if ($action == 'create') $out.= $langs->trans("NewCompany"); if ($action == 'create') $out.= $langs->trans("NewCompany");
return $out; return $out;
} }
/** /**
* Assigne les valeurs POST dans l'objet * Assigne les valeurs POST dans l'objet
*/ */
@ -66,17 +67,17 @@ class CardDefault extends CardCommon
{ {
parent::assign_post(); parent::assign_post();
} }
/** /**
* Load data control * Load data control
*/ */
function loadControl($socid) function loadControl($socid)
{ {
$return = parent::loadControl($socid); $return = parent::loadControl($socid);
return $return; return $return;
} }
/** /**
* Assign custom values for canvas * Assign custom values for canvas
* @param action Type of action * @param action Type of action
@ -85,14 +86,14 @@ class CardDefault extends CardCommon
{ {
global $conf, $langs, $user, $mysoc; global $conf, $langs, $user, $mysoc;
global $form, $formadmin, $formcompany; global $form, $formadmin, $formcompany;
parent::assign_values($action); parent::assign_values($action);
$this->tpl['profid1'] = $this->object->siren; $this->tpl['profid1'] = $this->object->siren;
$this->tpl['profid2'] = $this->object->siret; $this->tpl['profid2'] = $this->object->siret;
$this->tpl['profid3'] = $this->object->ape; $this->tpl['profid3'] = $this->object->ape;
$this->tpl['profid4'] = $this->object->idprof4; $this->tpl['profid4'] = $this->object->idprof4;
if ($action == 'create' || $action == 'edit') if ($action == 'create' || $action == 'edit')
{ {
for ($i=1; $i<=4; $i++) for ($i=1; $i<=4; $i++)
@ -100,16 +101,16 @@ class CardDefault extends CardCommon
$this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->pays_code); $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->pays_code);
$this->tpl['showprofid'.$i] = $this->object->get_input_id_prof($i,'idprof'.$i,$this->tpl['profid'.$i]); $this->tpl['showprofid'.$i] = $this->object->get_input_id_prof($i,'idprof'.$i,$this->tpl['profid'.$i]);
} }
// Type // Type
$this->tpl['select_companytype'] = $form->selectarray("typent_id",$formcompany->typent_array(0), $this->object->typent_id); $this->tpl['select_companytype'] = $form->selectarray("typent_id",$formcompany->typent_array(0), $this->object->typent_id);
// Juridical Status // Juridical Status
$this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code,$this->object->pays_code); $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code,$this->object->pays_code);
// Workforce // Workforce
$this->tpl['select_workforce'] = $form->selectarray("effectif_id",$formcompany->effectif_array(0), $this->object->effectif_id); $this->tpl['select_workforce'] = $form->selectarray("effectif_id",$formcompany->effectif_array(0), $this->object->effectif_id);
// VAT intra // VAT intra
$s ='<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">'; $s ='<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
$s.=' '; $s.=' ';
@ -122,9 +123,9 @@ class CardDefault extends CardCommon
{ {
$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
} }
} }
if ($action == 'view') if ($action == 'view')
{ {
// Confirm delete third party // Confirm delete third party
@ -132,14 +133,14 @@ class CardDefault extends CardCommon
{ {
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2);
} }
for ($i=1; $i<=4; $i++) for ($i=1; $i<=4; $i++)
{ {
$this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->pays_code); $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->pays_code);
$this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i,$this->object); $this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i,$this->object);
$this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i,$this->object); $this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i,$this->object);
} }
// TVA intra // TVA intra
if ($this->tva_intra) if ($this->tva_intra)
{ {
@ -161,7 +162,7 @@ class CardDefault extends CardCommon
{ {
$this->tpl['tva_intra'] = '&nbsp;'; $this->tpl['tva_intra'] = '&nbsp;';
} }
// Parent company // Parent company
if ($this->object->parent) if ($this->object->parent)
{ {
@ -176,7 +177,7 @@ class CardDefault extends CardCommon
} }
} }
} }
} }
?> ?>

View File

@ -22,6 +22,7 @@
* \brief Fichier de la classe Thirdparty card controller (individual canvas) * \brief Fichier de la classe Thirdparty card controller (individual canvas)
* \version $Id$ * \version $Id$
*/ */
include_once(DOL_DOCUMENT_ROOT.'/societe/canvas/card.common.class.php');
/** /**
* \class CardIndividual * \class CardIndividual
@ -30,10 +31,10 @@
class CardIndividual extends CardCommon class CardIndividual extends CardCommon
{ {
var $db; var $db;
//! Canvas //! Canvas
var $canvas; var $canvas;
/** /**
* Constructeur de la classe * Constructeur de la classe
* @param DB Handler acces base de donnees * @param DB Handler acces base de donnees
@ -49,16 +50,16 @@ class CardIndividual extends CardCommon
function getTitle($action) function getTitle($action)
{ {
global $langs; global $langs;
$out=''; $out='';
if ($action == 'view') $out.= $langs->trans("Individual"); if ($action == 'view') $out.= $langs->trans("Individual");
if ($action == 'edit') $out.= $langs->trans("EditIndividual"); if ($action == 'edit') $out.= $langs->trans("EditIndividual");
if ($action == 'create') $out.= $langs->trans("NewIndividual"); if ($action == 'create') $out.= $langs->trans("NewIndividual");
return $out; return $out;
} }
/** /**
* Assigne les valeurs POST dans l'objet * Assigne les valeurs POST dans l'objet
*/ */
@ -66,17 +67,17 @@ class CardIndividual extends CardCommon
{ {
parent::assign_post(); parent::assign_post();
} }
/** /**
* Load data control * Load data control
*/ */
function loadControl($socid) function loadControl($socid)
{ {
$return = parent::loadControl($socid); $return = parent::loadControl($socid);
return $return; return $return;
} }
/** /**
* Assign custom values for canvas * Assign custom values for canvas
* @param action Type of action * @param action Type of action
@ -85,14 +86,14 @@ class CardIndividual extends CardCommon
{ {
global $langs; global $langs;
global $form, $formcompany; global $form, $formcompany;
parent::assign_values($action); parent::assign_values($action);
if ($action == 'create' || $action == 'edit') if ($action == 'create' || $action == 'edit')
{ {
$this->tpl['select_civility'] = $formcompany->select_civility($contact->civilite_id); $this->tpl['select_civility'] = $formcompany->select_civility($contact->civilite_id);
} }
if ($action == 'view') if ($action == 'view')
{ {
// Confirm delete third party // Confirm delete third party
@ -102,7 +103,7 @@ class CardIndividual extends CardCommon
} }
} }
} }
} }
?> ?>