diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php
index 1fb05192f44..037870b5b05 100644
--- a/htdocs/core/class/canvas.class.php
+++ b/htdocs/core/class/canvas.class.php
@@ -31,7 +31,12 @@
class Canvas
{
+ var $card;
var $canvas;
+ var $module;
+ var $object;
+ var $control;
+ var $aliasmodule; // for compatibility
var $template_dir; // Directory with all core and external templates files
var $action;
var $smarty;
@@ -46,43 +51,103 @@ class Canvas
{
$this->db = $DB;
}
+
+ /**
+ * Return the title of card
+ */
+ function getTitle()
+ {
+ return $this->control->getTitle($this->action);
+ }
+
+ /**
+ * Assigne les valeurs POST dans l'objet
+ */
+ function assign_post()
+ {
+ return $this->control->assign_post();
+ }
+
+ /**
+ * Fetch object values
+ * @param id Element id
+ */
+ function fetch($id)
+ {
+ return $this->control->object->fetch($id, $this->action);
+ }
/**
* Load canvas
- * @param element Element of canvas
- * @param canvas Name of canvas
+ * @param card Type of card
+ * @param canvas Name of canvas (ex: default@mymodule)
*/
- function load_canvas($element,$canvas)
+ function load_canvas($card,$canvas)
{
global $langs;
- $part1=$part3=$element;
- $part2=$canvas;
-
- // For compatibility
- if (preg_match('/^([^@]+)@([^@]+)$/i',$element,$regs))
- {
- $part1=$regs[2];
- $part3=$regs[1];
- }
+ $this->card = $card;
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
{
- $part1=$regs[2];
- $part2=$regs[1];
+ $this->aliasmodule = $this->module = $regs[2];
+ $this->canvas = $regs[1];
+
+ // For compatibility
+ if ($this->module == 'thirdparty') $this->aliasmodule = 'societe';
+ }
+ else
+ {
+ $this->error = $langs->trans('CanvasIsInvalid');
+ return 0;
}
- if (file_exists(DOL_DOCUMENT_ROOT.'/'.$part1.'/canvas/'.$part2.'/'.$part3.'.'.$part2.'.class.php'))
+ if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->module.'.'.$this->canvas.'.class.php'))
{
- $filecanvas = DOL_DOCUMENT_ROOT.'/'.$part1.'/canvas/'.$part2.'/'.$part3.'.'.$part2.'.class.php';
- $classname = ucfirst($part3).ucfirst($part2);
- $this->template_dir = DOL_DOCUMENT_ROOT.'/'.$part1.'/canvas/'.$part2.'/tpl/';
+ // Include model class
+ $modelclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->module.'.'.$this->canvas.'.class.php';
+ include_once($modelclassfile);
+
+ // Include common controller class
+ $controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->card.'.common.class.php';
+ include_once($controlclassfile);
+
+ // Template dir
+ $this->template_dir = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/tpl/';
+ }
+ else
+ {
+ $this->error = $langs->trans('CanvasIsInvalid');
+ return 0;
+ }
+ }
+
+ /**
+ * Load type of action
+ * @param action Type of action
+ */
+ function load_control($action)
+ {
+ global $langs;
+
+ $this->action = $action;
- include_once($filecanvas);
- $this->object = new $classname($this->db);
+ if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php'))
+ {
+ // Include canvas controller class
+ $controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php';
+ include_once($controlclassfile);
+
+ // Instantiate canvas controller class
+ $controlclassname = ucfirst($this->card).ucfirst($this->canvas);
+ $this->control = new $controlclassname($this->db);
+
+ // Instantiate model class
+ $modelclassname = ucfirst($this->module).ucfirst($this->canvas);
+ $this->control->object = new $modelclassname($this->db);
+
+ // Need smarty
$this->smarty = $this->object->smarty;
-
- return $this->object;
}
else
{
@@ -91,37 +156,22 @@ class Canvas
}
}
- /**
- * Fetch object values
- * @param id Element id
- * @param action Type of action
- */
- function fetch($id,$action='')
- {
- $this->action = $action;
-
- $ret = $this->object->fetch($id,$action);
- return $ret;
- }
-
/**
* Assign templates values
* @param action Type of action
*/
- function assign_values($action='')
+ function assign_values()
{
- $this->action = $action;
-
if (!empty($this->smarty))
{
global $smarty;
- $this->object->assign_smarty_values($smarty, $this->action);
+ $this->control->assign_smarty_values($smarty, $this->action);
$smarty->template_dir = $this->template_dir;
}
else
{
- $this->object->assign_values($this->action);
+ $this->control->assign_values($this->action);
}
}
@@ -141,7 +191,7 @@ class Canvas
}
else
{
- include($this->template_dir.$this->action.'.tpl.php');
+ include($this->template_dir.$this->card.'_'.$this->action.'.tpl.php');
}
}
diff --git a/htdocs/societe/canvas/card.common.class.php b/htdocs/societe/canvas/card.common.class.php
new file mode 100644
index 00000000000..41384875796
--- /dev/null
+++ b/htdocs/societe/canvas/card.common.class.php
@@ -0,0 +1,407 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * \file htdocs/societe/canvas/card.common.class.php
+ * \ingroup thirparty
+ * \brief Fichier de la classe Thirdparty card controller (common)
+ * \version $Id$
+ */
+
+/**
+ * \class CardCommon
+ * \brief Classe permettant la gestion des tiers par defaut
+ */
+class CardCommon
+{
+ //! Numero d'erreur Plage 1280-1535
+ var $errno = 0;
+ //! Template container
+ var $tpl = array();
+ //! Object container
+ var $object;
+
+ /**
+ * Constructeur de la classe
+ * @param DB Handler acces base de donnees
+ */
+ function CardCommon($DB)
+ {
+ $this->db = $DB;
+ }
+
+ /**
+ * Assigne les valeurs par defaut pour le canvas
+ * @param action Type of template
+ */
+ function assign_values($action='')
+ {
+ global $conf, $langs, $user, $mysoc, $canvas;
+ global $form, $formadmin, $formcompany;
+
+ if ($_GET["type"]=='f') { $this->object->fournisseur=1; }
+ if ($_GET["type"]=='c') { $this->object->client=1; }
+ if ($_GET["type"]=='p') { $this->object->client=2; }
+ if ($_GET["type"]=='cp') { $this->object->client=3; }
+ if ($_REQUEST["private"]==1) { $this->object->particulier=1; }
+
+ foreach($this->object as $key => $value)
+ {
+ $this->tpl[$key] = $value;
+ }
+
+ if ($action == 'create' || $action == 'edit')
+ {
+ // Chargement ajax
+ $this->tpl['ajax_select_thirdpartytype'] = $this->ajax_selectThirdPartyType($canvas);
+ $this->tpl['ajax_select_country'] = $this->ajax_selectCountry($action,$canvas);
+
+ // Load object modCodeClient
+ $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
+ if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
+ if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
+ {
+ $module = substr($module, 0, dol_strlen($module)-4);
+ }
+ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
+ $modCodeClient = new $module;
+ $this->tpl['auto_customercode'] = $modCodeClient->code_auto;
+ // We verified if the tag prefix is used
+ if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
+
+ // Load object modCodeFournisseur
+ $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
+ if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
+ if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
+ {
+ $module = substr($module, 0, dol_strlen($module)-4);
+ }
+ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
+ $modCodeFournisseur = new $module;
+ $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();
+
+ // TODO create a function
+ $this->tpl['select_customertype'] = '';
+
+ // Customer
+ $this->tpl['customercode'] = $this->object->code_client;
+ if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object,0);
+ $this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
+ $s=$modCodeClient->getToolTip($langs,$this->object,0);
+ $this->tpl['help_customercode'] = $form->textwithpicto('',$s,1);
+
+ // Supplier
+ $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1);
+ $this->tpl['suppliercode'] = $this->object->code_fournisseur;
+ if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1);
+ $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);
+
+ if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) $this->tpl['autofilltownfromzip'] = '';
+
+ // Country
+ $this->tpl['select_country'] = $form->select_country($this->object->pays_id,'pays_id');
+ $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
+
+ if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+
+ // State
+ if ($this->object->pays_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->departement_id,$this->object->pays_code);
+ else $this->tpl['select_state'] = $countrynotdefined;
+
+ // Language
+ if ($conf->global->MAIN_MULTILANGS) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang?$this->object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
+
+ // VAT
+ $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value',$this->tpl['tva_assuj'],1); // Assujeti par defaut en creation
+
+ // Select users
+ $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id,'commercial_id',1);
+
+ // Local Tax
+ // TODO mettre dans une classe propre au pays
+ if($mysoc->pays_code=='ES')
+ {
+ $this->tpl['localtax'] = '';
+
+ if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
+ {
+ $this->tpl['localtax'].= '
| '.$langs->trans("LocalTax1IsUsedES").' | ';
+ $this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
+ $this->tpl['localtax'].= ' | '.$langs->trans("LocalTax2IsUsedES").' | ';
+ $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
+ $this->tpl['localtax'].= ' |
';
+ }
+ elseif($mysoc->localtax1_assuj=="1")
+ {
+ $this->tpl['localtax'].= '| '.$langs->trans("LocalTax1IsUsedES").' | ';
+ $this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
+ $this->tpl['localtax'].= ' |
';
+ }
+ elseif($mysoc->localtax2_assuj=="1")
+ {
+ $this->tpl['localtax'].= '
| '.$langs->trans("LocalTax2IsUsedES").' | ';
+ $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
+ $this->tpl['localtax'].= ' |
';
+ }
+ }
+
+ }
+
+ if ($action == 'view')
+ {
+ $this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom');
+
+ $this->tpl['checkcustomercode'] = $this->object->check_codeclient();
+ $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur();
+ $this->tpl['address'] = dol_nl2br($this->object->address);
+
+ $img=picto_from_langcode($this->pays_code);
+ if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->pays,$langs->trans("CountryIsInEEC"),1,0);
+ $this->tpl['country'] = ($img?$img.' ':'').$this->pays;
+
+ $this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL');
+ $this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX');
+ $this->tpl['email'] = dol_print_email($this->object->email,0,$this->object->id,'AC_EMAIL');
+ $this->tpl['url'] = dol_print_url($this->object->url);
+
+ $this->tpl['tva_assuj'] = yn($this->object->tva_assuj);
+
+ // Third party type
+ $arr = $formcompany->typent_array(1);
+ $this->tpl['typent'] = $arr[$this->object->typent_code];
+
+ if ($conf->global->MAIN_MULTILANGS)
+ {
+ require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
+ //$s=picto_from_langcode($this->default_lang);
+ //print ($s?$s.' ':'');
+ $langs->load("languages");
+ $this->tpl['default_lang'] = ($this->default_lang?$langs->trans('Language_'.$this->object->default_lang):'');
+ }
+
+ $this->tpl['image_edit'] = img_edit();
+
+ $this->tpl['display_rib'] = $this->object->display_rib();
+
+ // Sales representatives
+ // TODO move in business class
+ $sql = "SELECT count(sc.rowid) as nb";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE sc.fk_soc =".$this->object->id;
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $obj = $this->db->fetch_object($resql);
+ $this->tpl['sales_representatives'] = $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected");
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+
+ // Linked member
+ if ($conf->adherent->enabled)
+ {
+ $langs->load("members");
+ $adh=new Adherent($this->db);
+ $result=$adh->fetch('','',$this->object->id);
+ if ($result > 0)
+ {
+ $adh->ref=$adh->getFullName($langs);
+ $this->tpl['linked_member'] = $adh->getNomUrl(1);
+ }
+ else
+ {
+ $this->tpl['linked_member'] = $langs->trans("UserNotLinkedToMember");
+ }
+ }
+
+ // Local Tax
+ // TODO mettre dans une classe propre au pays
+ if($mysoc->pays_code=='ES')
+ {
+ $this->tpl['localtax'] = '';
+
+ if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
+ {
+ $this->tpl['localtax'].= '
| '.$langs->trans("LocalTax1IsUsedES").' | ';
+ $this->tpl['localtax'].= ''.yn($this->object->localtax1_assuj).' | ';
+ $this->tpl['localtax'].= ''.$langs->trans("LocalTax2IsUsedES").' | ';
+ $this->tpl['localtax'].= ''.yn($this->object->localtax2_assuj).' |
';
+ }
+ elseif($mysoc->localtax1_assuj=="1")
+ {
+ $this->tpl['localtax'].= '| '.$langs->trans("LocalTax1IsUsedES").' | ';
+ $this->tpl['localtax'].= ''.yn($this->object->localtax1_assuj).' |
';
+ }
+ elseif($mysoc->localtax2_assuj=="1")
+ {
+ $this->tpl['localtax'].= '| '.$langs->trans("LocalTax2IsUsedES").' | ';
+ $this->tpl['localtax'].= ''.yn($this->object->localtax2_assuj).' |
';
+ }
+ }
+ }
+ }
+
+ /**
+ * Assigne les valeurs POST dans l'objet
+ */
+ function assign_post()
+ {
+ global $langs, $mysoc;
+
+ $this->object->id = $_POST["socid"];
+ $this->object->nom = $_POST["nom"];
+ $this->object->prefix_comm = $_POST["prefix_comm"];
+ $this->object->client = $_POST["client"];
+ $this->object->code_client = $_POST["code_client"];
+ $this->object->fournisseur = $_POST["fournisseur"];
+ $this->object->code_fournisseur = $_POST["code_fournisseur"];
+ $this->object->adresse = $_POST["adresse"]; // TODO obsolete
+ $this->object->address = $_POST["adresse"];
+ $this->object->cp = $_POST["cp"];
+ $this->object->ville = $_POST["ville"];
+ $this->object->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
+ $this->object->departement_id = $_POST["departement_id"];
+ $this->object->tel = $_POST["tel"];
+ $this->object->fax = $_POST["fax"];
+ $this->object->email = $_POST["email"];
+ $this->object->url = $_POST["url"];
+ $this->object->capital = $_POST["capital"];
+ $this->object->siren = $_POST["idprof1"];
+ $this->object->siret = $_POST["idprof2"];
+ $this->object->ape = $_POST["idprof3"];
+ $this->object->idprof4 = $_POST["idprof4"];
+ $this->object->typent_id = $_POST["typent_id"];
+ $this->object->effectif_id = $_POST["effectif_id"];
+ $this->object->gencod = $_POST["gencod"];
+ $this->object->forme_juridique_code = $_POST["forme_juridique_code"];
+ $this->object->default_lang = $_POST["default_lang"];
+ $this->object->commercial_id = $_POST["commercial_id"];
+
+ $this->object->tva_assuj = $_POST["assujtva_value"]?$_POST["assujtva_value"]:1;
+ $this->object->tva_intra = $_POST["tva_intra"];
+
+ //Local Taxes
+ $this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
+ $this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
+
+ // We set pays_id, and pays_code label of the chosen country
+ // TODO move in business class
+ if ($this->object->pays_id)
+ {
+ $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->pays_id;
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+ $this->object->pays_code = $obj->code;
+ $this->object->pays = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
+ }
+ }
+
+ /**
+ *
+ */
+ function ajax_selectThirdPartyType($canvas)
+ {
+ global $conf, $langs;
+
+ $out='';
+
+ if ($conf->use_javascript_ajax)
+ {
+ $out.= "\n".''."\n";
+
+ $out.= "
\n";
+ $out.= $langs->trans("ThirdPartyType").': ';
+ $out.= ' '.$langs->trans("Company/Fundation");
+ $out.= ' ';
+ $out.= ' '.$langs->trans("Individual");
+ $out.= ' ('.$langs->trans("ToCreateContactWithSameName").')';
+ $out.= "
\n";
+ $out.= "
\n";
+ }
+
+ return $out;
+ }
+
+ /**
+ *
+ */
+ function ajax_selectCountry($action,$canvas)
+ {
+ global $conf;
+
+ $out='';
+
+ if ($conf->use_javascript_ajax)
+ {
+ $out.= "\n".''."\n";
+ }
+
+ return $out;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/htdocs/societe/canvas/default/card.default.class.php b/htdocs/societe/canvas/default/card.default.class.php
new file mode 100644
index 00000000000..e69b4f71409
--- /dev/null
+++ b/htdocs/societe/canvas/default/card.default.class.php
@@ -0,0 +1,159 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * \file htdocs/societe/canvas/default/card.default.class.php
+ * \ingroup thirparty
+ * \brief Fichier de la classe Thirdparty card controller (default canvas)
+ * \version $Id$
+ */
+
+/**
+ * \class ThirdPartyCardDefault
+ * \brief Classe permettant la gestion des tiers par defaut
+ */
+class CardDefault extends CardCommon
+{
+ /**
+ * Constructeur de la classe
+ * @param DB Handler acces base de donnees
+ */
+ function CardDefault($DB)
+ {
+ $this->db = $DB;
+ }
+
+ /**
+ * Return the title of card
+ */
+ function getTitle($action)
+ {
+ global $langs;
+
+ $out='';
+
+ if ($action == 'view') $out.= $langs->trans("ThirdParty");
+ if ($action == 'edit') $out.= $langs->trans("EditCompany");
+ if ($action == 'create') $out.= $langs->trans("NewCompany");
+
+ return $out;
+ }
+
+ /**
+ * Assign custom values for canvas
+ * @param action Type of action
+ */
+ function assign_values($action='')
+ {
+ global $conf, $langs, $user, $mysoc;
+ global $form, $formadmin, $formcompany;
+
+ parent::assign_values($action);
+
+ $this->tpl['profid1'] = $this->object->siren;
+ $this->tpl['profid2'] = $this->object->siret;
+ $this->tpl['profid3'] = $this->object->ape;
+ $this->tpl['profid4'] = $this->object->idprof4;
+
+ if ($action == 'create' || $action == 'edit')
+ {
+ for ($i=1; $i<=4; $i++)
+ {
+ $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]);
+ }
+
+ // Type
+ $this->tpl['select_companytype'] = $form->selectarray("typent_id",$formcompany->typent_array(0), $this->object->typent_id);
+
+ // Juridical Status
+ $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code,$this->object->pays_code);
+
+ // Workforce
+ $this->tpl['select_workforce'] = $form->selectarray("effectif_id",$formcompany->effectif_array(0), $this->object->effectif_id);
+
+ // VAT intra
+ $s ='';
+ $s.=' ';
+ if ($conf->use_javascript_ajax)
+ {
+ $s.=''.$langs->trans("VATIntraCheck").'';
+ $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
+ }
+ else
+ {
+ $this->tpl['tva_intra'] = $s.'object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'';
+ }
+
+ }
+
+ if ($action == 'view')
+ {
+ // Confirm delete third party
+ if ($_GET["action"] == 'delete')
+ {
+ $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++)
+ {
+ $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['urlprofid'.$i] = $this->object->id_prof_url($i,$this->object);
+ }
+
+ // TVA intra
+ if ($this->tva_intra)
+ {
+ $s='';
+ $s.=$this->object->tva_intra;
+ $s.='';
+ $s.=' ';
+ if ($conf->use_javascript_ajax)
+ {
+ $s.=''.$langs->trans("VATIntraCheck").'';
+ $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
+ }
+ else
+ {
+ $this->tpl['tva_intra'] = $s.'object->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'';
+ }
+ }
+ else
+ {
+ $this->tpl['tva_intra'] = ' ';
+ }
+
+ // Parent company
+ if ($this->object->parent)
+ {
+ $socm = new Societe($this->db);
+ $socm->fetch($this->object->parent);
+ $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":"");
+ $this->tpl['parent_company'].= $socm->ville?' - '.$socm->ville:'';
+ }
+ else
+ {
+ $this->tpl['parent_company'] = $langs->trans("NoParentCompany");
+ }
+ }
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/htdocs/societe/canvas/default/thirdparty.default.class.php b/htdocs/societe/canvas/default/thirdparty.default.class.php
index ccbaaa1dbcc..13261e33daa 100644
--- a/htdocs/societe/canvas/default/thirdparty.default.class.php
+++ b/htdocs/societe/canvas/default/thirdparty.default.class.php
@@ -31,8 +31,6 @@ class ThirdPartyDefault extends Societe
{
//! Numero d'erreur Plage 1280-1535
var $errno = 0;
- //! Template container
- var $tpl = array();
/**
* Constructeur de la classe
@@ -40,32 +38,13 @@ class ThirdPartyDefault extends Societe
*/
function ThirdPartyDefault($DB)
{
- $this->db = $DB;
-
- $this->smarty = 0;
- $this->module = "societe";
- $this->canvas = "default";
- $this->name = "default";
- $this->definition = "Canvas des tiers (défaut)";
- $this->fieldListName = "thirdparty_default";
- }
-
- function getTitle($action)
- {
- global $langs;
-
- $out='';
-
- if ($action == 'view') $out.= $langs->trans("ThirdParty");
- if ($action == 'edit') $out.= $langs->trans("EditCompany");
- if ($action == 'create') $out.= $langs->trans("NewCompany");
-
- return $out;
+ $this->db = $DB;
}
/**
* Lecture des donnees dans la base
- * @param id Product id
+ * @param id Product id
+ * @param action Type of action
*/
function fetch($id='', $action='')
{
@@ -74,106 +53,6 @@ class ThirdPartyDefault extends Societe
return $result;
}
- /**
- * Assign custom values for canvas
- * @param action Type of action
- */
- function assign_values($action='')
- {
- global $conf, $langs, $user, $mysoc;
- global $form, $formadmin, $formcompany;
-
- parent::assign_values($action);
-
- $this->tpl['profid1'] = $this->siren;
- $this->tpl['profid2'] = $this->siret;
- $this->tpl['profid3'] = $this->ape;
- $this->tpl['profid4'] = $this->idprof4;
-
- if ($action == 'create' || $action == 'edit')
- {
- for ($i=1; $i<=4; $i++)
- {
- $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->pays_code);
- $this->tpl['showprofid'.$i] = $this->get_input_id_prof($i,'idprof'.$i,$this->tpl['profid'.$i]);
- }
-
- // Type
- $this->tpl['select_companytype'] = $form->selectarray("typent_id",$formcompany->typent_array(0), $this->typent_id);
-
- // Juridical Status
- $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->forme_juridique_code,$this->pays_code);
-
- // Workforce
- $this->tpl['select_workforce'] = $form->selectarray("effectif_id",$formcompany->effectif_array(0), $this->effectif_id);
-
- // VAT intra
- $s ='';
- $s.=' ';
- if ($conf->use_javascript_ajax)
- {
- $s.=''.$langs->trans("VATIntraCheck").'';
- $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
- }
- else
- {
- $this->tpl['tva_intra'] = $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'';
- }
-
- }
-
- if ($action == 'view')
- {
- // Confirm delete third party
- if ($_GET["action"] == 'delete')
- {
- $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2);
- }
-
- for ($i=1; $i<=4; $i++)
- {
- $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->pays_code);
- $this->tpl['checkprofid'.$i] = $this->id_prof_check($i,$this);
- $this->tpl['urlprofid'.$i] = $this->id_prof_url($i,$this);
- }
-
- // TVA intra
- if ($this->tva_intra)
- {
- $s='';
- $s.=$this->tva_intra;
- $s.='';
- $s.=' ';
- if ($conf->use_javascript_ajax)
- {
- $s.=''.$langs->trans("VATIntraCheck").'';
- $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
- }
- else
- {
- $this->tpl['tva_intra'] = $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'';
- }
- }
- else
- {
- $this->tpl['tva_intra'] = ' ';
- }
-
- // Parent company
- if ($this->parent)
- {
- $socm = new Societe($this->db);
- $socm->fetch($this->parent);
- $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":"");
- $this->tpl['parent_company'].= $socm->ville?' - '.$socm->ville:'';
- }
- else
- {
- $this->tpl['parent_company'] = $langs->trans("NoParentCompany");
- }
- }
- }
-
/**
* Fetch datas list
*/
diff --git a/htdocs/societe/canvas/default/tpl/create.tpl.php b/htdocs/societe/canvas/default/tpl/card_create.tpl.php
similarity index 63%
rename from htdocs/societe/canvas/default/tpl/create.tpl.php
rename to htdocs/societe/canvas/default/tpl/card_create.tpl.php
index 1026cdd0eba..7cc8ffd7475 100644
--- a/htdocs/societe/canvas/default/tpl/create.tpl.php
+++ b/htdocs/societe/canvas/default/tpl/card_create.tpl.php
@@ -21,16 +21,16 @@
-object->tpl['ajax_select_thirdpartytype']; ?>
-object->tpl['ajax_select_country']; ?>
+control->tpl['ajax_select_thirdpartytype']; ?>
+control->tpl['ajax_select_country']; ?>