diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php
index 468c0aef28f..da67110193e 100644
--- a/htdocs/core/class/canvas.class.php
+++ b/htdocs/core/class/canvas.class.php
@@ -41,18 +41,16 @@ class Canvas
/**
* Constructor.
* @param DB Database handler
- * @param user User
*/
- function Canvas($DB,$user)
+ function Canvas($DB)
{
$this->db = $DB;
- $this->user = $user;
}
/**
* Load canvas
- * @param $element Element of canvas
- * @param $canvas Name of canvas
+ * @param element Element of canvas
+ * @param canvas Name of canvas
*/
function load_canvas($element,$canvas)
{
@@ -81,7 +79,7 @@ class Canvas
$this->template_dir = DOL_DOCUMENT_ROOT.'/'.$part1.'/canvas/'.$part2.'/tpl/';
include_once($filecanvas);
- $this->object = new $classname($this->db,0,$this->user);
+ $this->object = new $classname($this->db);
$this->smarty = $this->object->smarty;
return $this->object;
@@ -94,16 +92,19 @@ class Canvas
}
/**
- * \brief Fetch object values
+ * Fetch object values
+ * @param id Element id
+ * @param action Type of action
*/
- function fetch($id,$ref='',$action='')
+ function fetch($id,$action='')
{
- $ret = $this->object->fetch($id,$ref,$action);
+ $ret = $this->object->fetch($id,$action);
return $ret;
}
/**
- * \brief Assign templates values
+ * Assign templates values
+ * @param action Type of action
*/
function assign_values($action='')
{
@@ -124,7 +125,7 @@ class Canvas
}
/**
- * \brief Display canvas
+ * Display canvas
*/
function display_canvas()
{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index de370470497..d3d43c12a17 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -251,8 +251,7 @@ class Form
return $this->textwithtooltip($text,$htmltext,2,$direction,$img);
}
-
-
+
/**
* \brief Return combo list of activated countries, into language of user
* \param selected Id or Code or Label of preselected country
@@ -261,9 +260,23 @@ class Form
* \TODO trier liste sur noms apres traduction plutot que avant
*/
function select_pays($selected='',$htmlname='pays_id',$htmloption='')
+ {
+ print $this->select_country($selected,$htmlname,$htmloption);
+ }
+
+ /**
+ * \brief Return combo list of activated countries, into language of user
+ * \param selected Id or Code or Label of preselected country
+ * \param htmlname Name of html select object
+ * \param htmloption Options html on select object
+ * \TODO trier liste sur noms apres traduction plutot que avant
+ */
+ function select_country($selected='',$htmlname='pays_id',$htmloption='')
{
global $conf,$langs;
$langs->load("dict");
+
+ $out='';
$sql = "SELECT rowid, code, libelle, active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
@@ -274,7 +287,7 @@ class Form
$resql=$this->db->query($sql);
if ($resql)
{
- print '';
+ $out.= '';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
@@ -287,27 +300,27 @@ class Form
($selected == $obj->rowid || $selected == $obj->code || $selected == $obj->libelle) )
{
$foundselected=true;
- print '';
+ $out.= ' ';
}
else
{
- print ' ';
+ $out.= ' ';
}
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
- if ($obj->code) { print $obj->code . ' - '; }
- print ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:' '));
- print ' ';
+ if ($obj->code) { $out.= $obj->code . ' - '; }
+ $out.= ($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:' '));
+ $out.= '';
$i++;
}
}
- print ' ';
- return 0;
+ $out.= ' ';
}
else
{
dol_print_error($this->db);
- return 1;
}
+
+ return $out;
}
@@ -746,8 +759,7 @@ class Form
return -1;
}
}
-
-
+
/**
* \brief Return select list of users
* \param selected Id user preselected
@@ -759,6 +771,21 @@ class Form
* \param enableonly Array list of users id to be enabled. All other must be disabled
*/
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='')
+ {
+ print select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly);
+ }
+
+ /**
+ * \brief Return select list of users
+ * \param selected Id user preselected
+ * \param htmlname Field name in form
+ * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
+ * \param exclude Array list of users id to exclude
+ * \param disabled If select list must be disabled
+ * \param include Array list of users id to include
+ * \param enableonly Array list of users id to be enabled. All other must be disabled
+ */
+ function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='')
{
global $conf;
@@ -766,6 +793,8 @@ class Form
if (is_array($exclude)) $excludeUsers = implode("','",$exclude);
// Permettre l'inclusion d'utilisateurs
if (is_array($include)) $includeUsers = implode("','",$include);
+
+ $out='';
// On recherche les utilisateurs
$sql = "SELECT u.rowid, u.name, u.firstname, u.login, u.admin";
@@ -779,8 +808,8 @@ class Form
$resql=$this->db->query($sql);
if ($resql)
{
- print '';
- if ($show_empty) print ' '."\n";
+ $out.= '';
+ if ($show_empty) $out.= ' '."\n";
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
@@ -793,29 +822,31 @@ class Form
if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && $selected == $obj->rowid))
{
- print '';
+ $out.= ' ';
}
else
{
- print ' ';
+ $out.= ' ';
}
- print $obj->name.($obj->name && $obj->firstname?' ':'').$obj->firstname;
- //if ($obj->admin) print ' *';
- if ($conf->global->MAIN_SHOW_LOGIN) print ' ('.$obj->login.')';
- print ' ';
+ $out.= $obj->name.($obj->name && $obj->firstname?' ':'').$obj->firstname;
+ //if ($obj->admin) $out.= ' *';
+ if ($conf->global->MAIN_SHOW_LOGIN) $out.= ' ('.$obj->login.')';
+ $out.= '';
$i++;
}
}
- print ' ';
+ $out.= ' ';
}
else
{
dol_print_error($this->db);
}
+
+ return $out;
}
diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php
index a34729304a0..0bb21f1c57c 100644
--- a/htdocs/core/class/html.formadmin.class.php
+++ b/htdocs/core/class/html.formadmin.class.php
@@ -44,8 +44,7 @@ class FormAdmin
return 1;
}
-
-
+
/**
* \brief Retourne la liste deroulante des langues disponibles
* \param selected Langue pre-selectionnee
@@ -55,23 +54,38 @@ class FormAdmin
* \param showempty Add empty value
*/
function select_lang($selected='',$htmlname='lang_id',$showauto=0,$filter=0,$showempty=0)
+ {
+ print $this->select_language($selected,$htmlname,$showauto,$filter,$showempty);
+ }
+
+ /**
+ * \brief Retourne la liste deroulante des langues disponibles
+ * \param selected Langue pre-selectionnee
+ * \param htmlname Nom de la zone select
+ * \param showauto Affiche choix auto
+ * \param filter Array of keys to exclude in list
+ * \param showempty Add empty value
+ */
+ function select_language($selected='',$htmlname='lang_id',$showauto=0,$filter=0,$showempty=0)
{
global $langs;
$langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT,12);
+
+ $out='';
- print '';
+ $out.= '';
if ($showempty)
{
- print ' ';
+ $out.= ' ';
}
if ($showauto)
{
- print ''.$langs->trans("AutoDetectLang").' ';
+ $out.= ''.$langs->trans("AutoDetectLang").' ';
}
asort($langs_available);
@@ -82,19 +96,21 @@ class FormAdmin
{
if ( ! array_key_exists($key, $filter))
{
- print ''.$value.' ';
+ $out.= ''.$value.' ';
}
}
else if ($selected == $key)
{
- print ''.$value.' ';
+ $out.= ''.$value.' ';
}
else
{
- print ''.$value.' ';
+ $out.= ''.$value.' ';
}
}
- print ' ';
+ $out.= ' ';
+
+ return $out;
}
/**
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 23ca735993f..97cf9fa4be5 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -174,8 +174,7 @@ class FormCompany
print '
';
print '';
}
-
-
+
/**
* \brief Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne.
* \remarks Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays.
@@ -187,12 +186,29 @@ class FormCompany
* \param departement_id Id of department
*/
function select_departement($selected='',$pays_code=0, $htmlname='departement_id')
+ {
+ print $this->select_state($selected,$pays_code, $htmlname);
+ }
+
+ /**
+ * \brief Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne.
+ * \remarks Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays.
+ * \remarks La cle de la liste est le code (il peut y avoir plusieurs entree pour
+ * un code donnee mais dans ce cas, le champ pays differe).
+ * Ainsi les liens avec les departements se font sur un departement independemment de son nom.
+ * \param selected Code state preselected
+ * \param pays_code 0=list for all countries, otherwise country code or country rowid to show
+ * \param departement_id Id of department
+ */
+ function select_state($selected='',$pays_code=0, $htmlname='departement_id')
{
global $conf,$langs,$user;
dol_syslog("FormCompany::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG);
$langs->load("dict");
+
+ $out='';
// On recherche les departements/cantons/province active d'une region et pays actif
$sql = "SELECT d.rowid, d.code_departement as code , d.nom, d.active, p.libelle as libelle_pays, p.code as code_pays FROM";
@@ -207,8 +223,8 @@ class FormCompany
$result=$this->db->query($sql);
if ($result)
{
- print '';
- if ($pays_code) print ' ';
+ $out.= '';
+ if ($pays_code) $out.= ' ';
$num = $this->db->num_rows($result);
$i = 0;
dol_syslog("FormCompany::select_departement num=$num",LOG_DEBUG);
@@ -220,7 +236,7 @@ class FormCompany
$obj = $this->db->fetch_object($result);
if ($obj->code == '0') // Le code peut etre une chaine
{
- print ' ';
+ $out.= ' ';
}
else {
if (! $pays || $pays != $obj->libelle_pays)
@@ -228,33 +244,35 @@ class FormCompany
// Affiche la rupture si on est en mode liste multipays
if (! $pays_code && $obj->code_pays)
{
- print '----- '.$obj->libelle_pays." ----- \n";
+ $out.= '----- '.$obj->libelle_pays." ----- \n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->rowid)
{
- print '';
+ $out.= ' ';
}
else
{
- print ' ';
+ $out.= ' ';
}
- // Si traduction existe, on l'utilise, sinon on prend le libell� par d�faut
- print $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->nom!='-'?$obj->nom:''));
- print ' ';
+ // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
+ $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->nom!='-'?$obj->nom:''));
+ $out.= '';
}
$i++;
}
}
- print ' ';
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ $out.= ' ';
+ if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{
dol_print_error($this->db);
}
+
+ return $out;
}
@@ -318,17 +336,28 @@ class FormCompany
dol_print_error($this->db);
}
}
-
-
+
/**
* \brief Retourne la liste deroulante des civilite actives
* \param selected civilite pre-selectionnee
* \param htmlname Name of HTML select combo field
*/
function select_civilite($selected='',$htmlname='civilite_id')
+ {
+ print $this->select_civility($selected,$htmlname);
+ }
+
+ /**
+ * \brief Retourne la liste deroulante des civilite actives
+ * \param selected civilite pre-selectionnee
+ * \param htmlname Name of HTML select combo field
+ */
+ function select_civility($selected='',$htmlname='civilite_id')
{
global $conf,$langs,$user;
$langs->load("dict");
+
+ $out='';
$sql = "SELECT rowid, code, civilite, active FROM ".MAIN_DB_PREFIX."c_civilite";
$sql.= " WHERE active = 1";
@@ -337,8 +366,8 @@ class FormCompany
$resql=$this->db->query($sql);
if ($resql)
{
- print '';
- print ' ';
+ $out.= '';
+ $out.= ' ';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
@@ -348,28 +377,29 @@ class FormCompany
$obj = $this->db->fetch_object($resql);
if ($selected == $obj->code)
{
- print '';
+ $out.= ' ';
}
else
{
- print ' ';
+ $out.= ' ';
}
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
- print ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
- print ' ';
+ $out.= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
+ $out.= '';
$i++;
}
}
- print ' ';
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ $out.= ' ';
+ if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{
dol_print_error($this->db);
}
+
+ return $out;
}
-
-
+
/**
* \brief Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
* \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
@@ -377,9 +407,22 @@ class FormCompany
* \param pays_code 0=liste tous pays confondus, sinon code du pays a afficher
*/
function select_forme_juridique($selected='',$pays_code=0)
+ {
+ print $this->select_juridicalstatus($selected,$pays_code);
+ }
+
+ /**
+ * \brief Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
+ * \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
+ * \param selected Code forme juridique a pre-selectionne
+ * \param pays_code 0=liste tous pays confondus, sinon code du pays a afficher
+ */
+ function select_juridicalstatus($selected='',$pays_code=0)
{
global $conf,$langs,$user;
$langs->load("dict");
+
+ $out='';
// On recherche les formes juridiques actives des pays actifs
$sql = "SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as libelle_pays, p.code as code_pays";
@@ -393,9 +436,9 @@ class FormCompany
$result=$this->db->query($sql);
if ($result)
{
- print '';
- print '
';
- if ($pays_code) print ' ';
+ $out.= '';
+ $out.= '';
+ if ($pays_code) $out.= ' ';
$num = $this->db->num_rows($result);
$i = 0;
if ($num)
@@ -405,41 +448,43 @@ class FormCompany
{
$obj = $this->db->fetch_object($result);
if ($obj->code == 0) {
- print ' ';
+ $out.= ' ';
}
else {
if (! $pays || $pays != $obj->libelle_pays) {
// Affiche la rupture si on est en mode liste multipays
if (! $pays_code && $obj->code_pays) {
- print '----- '.$obj->libelle_pays." ----- \n";
+ $out.= '----- '.$obj->libelle_pays." ----- \n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->code)
{
- print '';
+ $out.= ' ';
}
else
{
- print ' ';
+ $out.= ' ';
}
// Si translation exists, we use it, otherwise we use default label in database
- print $obj->code . ' - ';
- print ($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code?$langs->trans("JuridicalStatus".$obj->code):($obj->nom!='-'?$obj->nom:'')); // $obj->nom is alreay in output charset (converted by database driver)
- print ' ';
+ $out.= $obj->code . ' - ';
+ $out.= ($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code?$langs->trans("JuridicalStatus".$obj->code):($obj->nom!='-'?$obj->nom:'')); // $obj->nom is alreay in output charset (converted by database driver)
+ $out.= '';
}
$i++;
}
}
- print ' ';
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- print '
';
+ $out.= ' ';
+ if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ $out.= '
';
}
else
{
dol_print_error($this->db);
}
+
+ return $out;
}
diff --git a/htdocs/societe/canvas/default/thirdparty.default.class.php b/htdocs/societe/canvas/default/thirdparty.default.class.php
index 943e5c47a12..640c1dec174 100644
--- a/htdocs/societe/canvas/default/thirdparty.default.class.php
+++ b/htdocs/societe/canvas/default/thirdparty.default.class.php
@@ -35,15 +35,13 @@ class ThirdPartyDefault extends Societe
var $tpl = array();
/**
- * \brief Constructeur de la classe
- * \param DB Handler acces base de donnees
- * \param id Id produit (0 par defaut)
+ * Constructeur de la classe
+ * @param DB Handler acces base de donnees
*/
- function ThirdPartyDefault($DB=0, $id=0, $user=0)
+ function ThirdPartyDefault($DB)
{
$this->db = $DB;
- $this->id = $id ;
- $this->user = $user;
+
$this->smarty = 0;
$this->module = "societe";
$this->canvas = "default";
@@ -60,10 +58,10 @@ class ThirdPartyDefault extends Societe
}
/**
- * \brief Lecture des donnees dans la base
- * \param id Product id
+ * Lecture des donnees dans la base
+ * @param id Product id
*/
- function fetch($id='', $ref='', $action='')
+ function fetch($id='', $action='')
{
$result = parent::fetch($id);
@@ -76,71 +74,102 @@ class ThirdPartyDefault extends Societe
*/
function assign_values($action='')
{
- global $langs;
+ global $conf, $langs, $user, $mysoc;
+ global $form, $formadmin, $formcompany;
parent::assign_values($action);
- $form = new Form($db);
+ $this->tpl['profid1'] = $this->siren;
+ $this->tpl['profid2'] = $this->siret;
+ $this->tpl['profid3'] = $this->ape;
+ $this->tpl['profid4'] = $this->idprof4;
+
+ if ($action == 'create')
+ {
+ 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);
+ $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2);
}
- }
-
- $this->tpl['profid1'] = $this->siren;
- $this->tpl['profid2'] = $this->siret;
- $this->tpl['profid3'] = $this->ape;
- $this->tpl['profid4'] = $this->idprof4;
- 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)
+ for ($i=1; $i<=4; $i++)
{
- $s.=''.$langs->trans("VATIntraCheck").' ';
- $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
+ $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);
}
- else
+
+ // TVA intra
+ if ($this->tva_intra)
{
- $this->tpl['tva_intra'] = $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').' ';
+ $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");
}
- }
- 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");
}
}
/**
- * \brief Fetch datas list
+ * Fetch datas list
*/
function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
diff --git a/htdocs/societe/canvas/default/tpl/create.tpl.php b/htdocs/societe/canvas/default/tpl/create.tpl.php
index 4a17dcd09d3..01769dee2fb 100644
--- a/htdocs/societe/canvas/default/tpl/create.tpl.php
+++ b/htdocs/societe/canvas/default/tpl/create.tpl.php
@@ -21,5 +21,175 @@
+
\ No newline at end of file
diff --git a/htdocs/societe/canvas/default/tpl/view.tpl.php b/htdocs/societe/canvas/default/tpl/view.tpl.php
index da25e66a3ca..a43ec8e7f3d 100644
--- a/htdocs/societe/canvas/default/tpl/view.tpl.php
+++ b/htdocs/societe/canvas/default/tpl/view.tpl.php
@@ -117,12 +117,12 @@ for ($i=1; $i<=4; $i++) {
else echo ' ('.$langs->trans("ErrorWrongValue").') ';
}
echo '';
- if ($i==2 || $i==4) echo '';
+ if ($i==2 || $i==4) echo ' ';
} else {
if ($i==1 || $i==3) echo '';
echo ' ';
echo ' ';
- if ($i==2 || $i==4) echo ' ';
+ if ($i==2 || $i==4) echo ' ';
}
}
?>
diff --git a/htdocs/societe/canvas/individual/thirdparty.individual.class.php b/htdocs/societe/canvas/individual/thirdparty.individual.class.php
index 8a74ebed042..5753dee41e2 100644
--- a/htdocs/societe/canvas/individual/thirdparty.individual.class.php
+++ b/htdocs/societe/canvas/individual/thirdparty.individual.class.php
@@ -39,11 +39,10 @@ class ThirdPartyIndividual extends Societe
* \param DB Handler acces base de donnees
* \param id Id produit (0 par defaut)
*/
- function ThirdPartyIndividual($DB=0, $id=0, $user=0)
+ function ThirdPartyIndividual($DB)
{
$this->db = $DB;
- $this->id = $id ;
- $this->user = $user;
+
$this->smarty = 0;
$this->module = "societe";
$this->canvas = "individual";
@@ -60,10 +59,11 @@ class ThirdPartyIndividual extends Societe
}
/**
- * \brief Lecture des donnees dans la base
- * \param id Product id
+ * Lecture des donnees dans la base
+ * @param id Element id
+ * @param action Type of action
*/
- function fetch($id='', $ref='', $action='')
+ function fetch($id='', $action='')
{
$result = parent::fetch($id);
@@ -76,18 +76,24 @@ class ThirdPartyIndividual extends Societe
*/
function assign_values($action='')
{
- global $langs;
+ global $conf, $langs, $user, $mysoc;
+ global $form, $formadmin, $formcompany;
parent::assign_values($action);
$form = new Form($db);
+ if ($action == 'create')
+ {
+ $this->tpl['select_civility'] = $formcompany->select_civility($contact->civilite_id);
+ }
+
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("DeleteAnIndividual"),$langs->trans("ConfirmDeleteIndividual"),"confirm_delete",'',0,2);
+ $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->id,$langs->trans("DeleteAnIndividual"),$langs->trans("ConfirmDeleteIndividual"),"confirm_delete",'',0,2);
}
}
}
diff --git a/htdocs/societe/canvas/individual/tpl/create.tpl.php b/htdocs/societe/canvas/individual/tpl/create.tpl.php
index 4a17dcd09d3..74aca92e605 100644
--- a/htdocs/societe/canvas/individual/tpl/create.tpl.php
+++ b/htdocs/societe/canvas/individual/tpl/create.tpl.php
@@ -21,5 +21,144 @@
+" method="POST" name="formsoc">
+
+
+
+
+
+code_auto || $modCodeFournisseur->code_auto) { ?>
+
+
+
+
+
\ No newline at end of file
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index fd261e47c4c..4e5067945e5 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -2042,7 +2042,7 @@ class Societe extends CommonObject
$errmesg = $this->db->lasterror();
}
}
-
+
/**
* \brief Retourne le formulaire de saisie d'un identifiant professionnel (siren, siret, etc...)
* \param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
@@ -2050,6 +2050,17 @@ class Societe extends CommonObject
* \param preselected Default value to show
*/
function show_input_id_prof($idprof,$htmlname,$preselected)
+ {
+ print $this->get_input_id_prof($idprof, $htmlname, $preselected);
+ }
+
+ /**
+ * \brief Retourne le formulaire de saisie d'un identifiant professionnel (siren, siret, etc...)
+ * \param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
+ * \param htmlname Nom de la zone input
+ * \param preselected Default value to show
+ */
+ function get_input_id_prof($idprof,$htmlname,$preselected)
{
global $langs;
@@ -2067,7 +2078,9 @@ class Societe extends CommonObject
if (! $selected && $idprof==3) $selected=$this->ape;
if (! $selected && $idprof==4) $selected=$this->idprof4;
- print ' ';
+ $out = ' ';
+
+ return $out;
}
/**
@@ -2139,16 +2152,109 @@ class Societe extends CommonObject
*/
function assign_values($action='')
{
- global $conf,$langs,$user;
- global $formcompany;
-
- $form = new Form($db);
+ global $conf, $langs, $user, $mysoc;
+ global $form, $formadmin, $formcompany;
foreach($this as $key => $value)
{
$this->tpl[$key] = $value;
}
+ if ($action == 'create')
+ {
+ // Load object modCodeTiers
+ $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;
+ $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;
+
+ // TODO create a function
+ $this->tpl['select_customertype'] = '';
+ $this->tpl['select_customertype'].= 'client==2?' selected="true"':'').'>'.$langs->trans('Prospect').' ';
+ $this->tpl['select_customertype'].= 'client==3?' selected="true"':'').'>'.$langs->trans('ProspectCustomer').' ';
+ $this->tpl['select_customertype'].= 'client==1?' selected="true"':'').'>'.$langs->trans('Customer').' ';
+ $this->tpl['select_customertype'].= 'client==0?' selected="true"':'').'>'.$langs->trans('NorProspectNorCustomer').' ';
+ $this->tpl['select_customertype'].= ' ';
+
+ // Customer
+ $this->tpl['customercode'] = $this->code_client;
+ if ($modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this,0);
+ $s=$modCodeClient->getToolTip($langs,$this,0);
+ $this->tpl['help_customercode'] = $form->textwithpicto('',$s,1);
+
+ // Supplier
+ $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->fournisseur,1);
+ $this->tpl['suppliercode'] = $this->code_fournisseur;
+ if ($modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this,1);
+ $s=$modCodeFournisseur->getToolTip($langs,$this,1);
+ $this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1);
+ $this->LoadSupplierCateg();
+ $this->tpl['suppliercategory'] = $this->SupplierCategories;
+ $this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->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->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->pays_id) $this->tpl['select_state'] = $formcompany->select_state($this->departement_id,$this->pays_code);
+ else $this->tpl['select_state'] = $countrynotdefined;
+
+ // Language
+ if ($conf->global->MAIN_MULTILANGS) $this->tpl['select_lang'] = $formadmin->select_language(($this->default_lang?$this->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
+
+ // VAT
+ $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value',1,1); // Assujeti par defaut en creation
+
+ // Select users
+ $this->tpl['select_users'] = $form->select_dolusers($this->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',0,1);
+ $this->tpl['localtax'].= ' '.$langs->trans("LocalTax2IsUsedES").' ';
+ $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',0,1);
+ $this->tpl['localtax'].= ' ';
+ }
+ elseif($mysoc->localtax1_assuj=="1")
+ {
+ $this->tpl['localtax'].= ''.$langs->trans("LocalTax1IsUsedES").' ';
+ $this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',0,1);
+ $this->tpl['localtax'].= ' ';
+ }
+ elseif($mysoc->localtax2_assuj=="1")
+ {
+ $this->tpl['localtax'].= ' '.$langs->trans("LocalTax2IsUsedES").' ';
+ $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',0,1);
+ $this->tpl['localtax'].= ' ';
+ }
+ }
+
+ }
+
if ($action == 'view')
{
$this->tpl['showrefnav'] = $form->showrefnav($this,'socid','',($user->societe_id?0:1),'rowid','nom');
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index f1567d9d1f6..47d33b16173 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -50,9 +50,21 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid);
-// Initialization Company Object
-$soc = new Societe($db);
+// For canvas usage
+if (empty($_GET["canvas"]))
+{
+ $_GET["canvas"] = 'default';
+ if ($_REQUEST["private"]==1) $_GET["canvas"] = 'individual';
+}
+// Initialization Company Object
+$socstatic = new Societe($db);
+
+// Initialization Company Canvas
+if (!empty($socid)) $socstatic->getCanvas($socid);
+$canvas = (!empty($socstatic->canvas)?$socstatic->canvas:$_GET["canvas"]);
+$soc = new Canvas($db);
+$soc->load_canvas('thirdparty@societe',$canvas);
/*
* Actions
@@ -85,85 +97,85 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
if ($_REQUEST["private"] == 1)
{
- $soc->particulier = $_REQUEST["private"];
+ $soc->object->particulier = $_REQUEST["private"];
- $soc->nom = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]);
- $soc->nom_particulier = $_POST["nom"];
- $soc->prenom = $_POST["prenom"];
- $soc->civilite_id = $_POST["civilite_id"];
- $soc->canvas = 'individual';
+ $soc->object->nom = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]);
+ $soc->object->nom_particulier = $_POST["nom"];
+ $soc->object->prenom = $_POST["prenom"];
+ $soc->object->civilite_id = $_POST["civilite_id"];
}
else
{
- $soc->nom = $_POST["nom"];
+ $soc->object->nom = $_POST["nom"];
}
- $soc->address = $_POST["adresse"];
- $soc->adresse = $_POST["adresse"]; // TODO obsolete
- $soc->cp = $_POST["cp"];
- $soc->ville = $_POST["ville"];
- $soc->pays_id = $_POST["pays_id"];
- $soc->departement_id = $_POST["departement_id"];
- $soc->tel = $_POST["tel"];
- $soc->fax = $_POST["fax"];
- $soc->email = trim($_POST["email"]);
- $soc->url = $_POST["url"];
- $soc->siren = $_POST["idprof1"];
- $soc->siret = $_POST["idprof2"];
- $soc->ape = $_POST["idprof3"];
- $soc->idprof4 = $_POST["idprof4"];
- $soc->prefix_comm = $_POST["prefix_comm"];
- $soc->code_client = $_POST["code_client"];
- $soc->code_fournisseur = $_POST["code_fournisseur"];
- $soc->capital = $_POST["capital"];
- $soc->gencod = $_POST["gencod"];
+ $soc->object->address = $_POST["adresse"];
+ $soc->object->adresse = $_POST["adresse"]; // TODO obsolete
+ $soc->object->cp = $_POST["cp"];
+ $soc->object->ville = $_POST["ville"];
+ $soc->object->pays_id = $_POST["pays_id"];
+ $soc->object->departement_id = $_POST["departement_id"];
+ $soc->object->tel = $_POST["tel"];
+ $soc->object->fax = $_POST["fax"];
+ $soc->object->email = trim($_POST["email"]);
+ $soc->object->url = $_POST["url"];
+ $soc->object->siren = $_POST["idprof1"];
+ $soc->object->siret = $_POST["idprof2"];
+ $soc->object->ape = $_POST["idprof3"];
+ $soc->object->idprof4 = $_POST["idprof4"];
+ $soc->object->prefix_comm = $_POST["prefix_comm"];
+ $soc->object->code_client = $_POST["code_client"];
+ $soc->object->code_fournisseur = $_POST["code_fournisseur"];
+ $soc->object->capital = $_POST["capital"];
+ $soc->object->gencod = $_POST["gencod"];
+ $soc->object->canvas = $_GET["canvas"];
- $soc->tva_assuj = $_POST["assujtva_value"];
+ $soc->object->tva_assuj = $_POST["assujtva_value"];
// Local Taxes
- $soc->localtax1_assuj = $_POST["localtax1assuj_value"];
- $soc->localtax2_assuj = $_POST["localtax2assuj_value"];
+ $soc->object->localtax1_assuj = $_POST["localtax1assuj_value"];
+ $soc->object->localtax2_assuj = $_POST["localtax2assuj_value"];
- $soc->tva_intra = $_POST["tva_intra"];
+ $soc->object->tva_intra = $_POST["tva_intra"];
- $soc->forme_juridique_code = $_POST["forme_juridique_code"];
- $soc->effectif_id = $_POST["effectif_id"];
+ $soc->object->forme_juridique_code = $_POST["forme_juridique_code"];
+ $soc->object->effectif_id = $_POST["effectif_id"];
if ($_REQUEST["private"] == 1)
{
- $soc->typent_id = 8; // TODO predict another method if the field "special" change of rowid
+ $soc->object->typent_id = 8; // TODO predict another method if the field "special" change of rowid
}
else
{
- $soc->typent_id = $_POST["typent_id"];
+ $soc->object->typent_id = $_POST["typent_id"];
}
- $soc->client = $_POST["client"];
- $soc->fournisseur = $_POST["fournisseur"];
- $soc->fournisseur_categorie = $_POST["fournisseur_categorie"];
+ $soc->object->client = $_POST["client"];
+ $soc->object->fournisseur = $_POST["fournisseur"];
+ $soc->object->fournisseur_categorie = $_POST["fournisseur_categorie"];
- $soc->commercial_id = $_POST["commercial_id"];
- $soc->default_lang = $_POST["default_lang"];
+ $soc->object->commercial_id = $_POST["commercial_id"];
+ $soc->object->default_lang = $_POST["default_lang"];
// Check parameters
if (empty($_POST["cancel"]))
{
- if (! empty($soc->email) && ! isValidEMail($soc->email))
+ if (! empty($soc->object->email) && ! isValidEMail($soc->object->email))
{
$error = 1;
$langs->load("errors");
- $soc->error = $langs->trans("ErrorBadEMail",$soc->email);
+ $soc->object->error = $langs->trans("ErrorBadEMail",$soc->object->email);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
- if (! empty($soc->url) && ! isValidUrl($soc->url))
+ if (! empty($soc->object->url) && ! isValidUrl($soc->object->url))
{
$error = 1;
$langs->load("errors");
- $soc->error = $langs->trans("ErrorBadUrl",$soc->url);
+ $soc->object->error = $langs->trans("ErrorBadUrl",$soc->object->url);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
- if ($soc->fournisseur && ! $conf->fournisseur->enabled)
+ if ($soc->object->fournisseur && ! $conf->fournisseur->enabled)
{
$error = 1;
$langs->load("errors");
- $soc->error = $langs->trans("ErrorSupplierModuleNotEnabled");
+ $soc->object->error = $langs->trans("ErrorSupplierModuleNotEnabled");
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
}
}
@@ -174,27 +186,27 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
{
$db->begin();
- if (empty($soc->client)) $soc->code_client='';
- if (empty($soc->fournisseur)) $soc->code_fournisseur='';
+ if (empty($soc->object->client)) $soc->object->code_client='';
+ if (empty($soc->object->fournisseur)) $soc->object->code_fournisseur='';
- $result = $soc->create($user);
+ $result = $soc->object->create($user);
if ($result >= 0)
{
- if ($soc->particulier)
+ if ($soc->object->particulier)
{
dol_syslog("This thirdparty is a personal people",LOG_DEBUG);
$contact=new Contact($db);
- $contact->civilite_id = $soc->civilite_id;
- $contact->name=$soc->nom_particulier;
- $contact->firstname=$soc->prenom;
- $contact->address=$soc->address;
- $contact->cp=$soc->cp;
- $contact->ville=$soc->ville;
- $contact->fk_pays=$soc->fk_pays;
- $contact->socid=$soc->id; // fk_soc
+ $contact->civilite_id = $soc->object->civilite_id;
+ $contact->name=$soc->object->nom_particulier;
+ $contact->firstname=$soc->object->prenom;
+ $contact->address=$soc->object->address;
+ $contact->cp=$soc->object->cp;
+ $contact->ville=$soc->object->ville;
+ $contact->fk_pays=$soc->object->fk_pays;
+ $contact->socid=$soc->object->id; // fk_soc
$contact->status=1;
- $contact->email=$soc->email;
+ $contact->email=$soc->object->email;
$contact->priv=0;
$result=$contact->create($user);
@@ -202,28 +214,28 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
}
else
{
- $mesg=$soc->error;
+ $mesg=$soc->object->error;
}
if ($result >= 0)
{
$db->commit();
- if ( $soc->client == 1 )
+ if ( $soc->object->client == 1 )
{
- Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id);
+ Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->object->id);
return;
}
else
{
- if ( $soc->fournisseur == 1 )
+ if ( $soc->object->fournisseur == 1 )
{
- Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id);
+ Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->object->id);
return;
}
else
{
- Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$soc->id);
+ Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$soc->object->id);
return;
}
}
@@ -234,7 +246,7 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
$db->rollback();
$langs->load("errors");
- $mesg=$langs->trans($soc->error);
+ $mesg=$langs->trans($soc->object->error);
$_GET["action"]='create';
}
}
@@ -247,15 +259,16 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
exit;
}
- $oldsoc=new Societe($db);
+ $oldsoc = new Canvas($db);
+ $oldsoc->load_canvas('thirdparty@societe',$canvas);
$result=$oldsoc->fetch($socid);
// To not set code if third party is not concerned. But if it had values, we keep them.
- if (empty($soc->client) && empty($oldsoc->code_client)) $soc->code_client='';
- if (empty($soc->fournisseur)&& empty($oldsoc->code_fournisseur)) $soc->code_fournisseur='';
+ if (empty($soc->object->client) && empty($oldsoc->code_client)) $soc->object->code_client='';
+ if (empty($soc->object->fournisseur)&& empty($oldsoc->code_fournisseur)) $soc->object->code_fournisseur='';
//var_dump($soc);exit;
- $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable());
+ $result = $soc->object->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable());
if ($result >= 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
@@ -263,10 +276,10 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
}
else
{
- $soc->id = $socid;
+ $soc->object->id = $socid;
$reload = 0;
- $mesg = $soc->error;
+ $mesg = $soc->object->error;
$_GET["action"]= "edit";
}
}
@@ -354,9 +367,6 @@ $formfile = new FormFile($db);
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
-$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
-
-
if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
$_GET["action"] == 'create' || $_POST["action"] == 'create')
{
@@ -365,77 +375,59 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
*/
if ($user->rights->societe->creer)
{
- // Load object modCodeTiers
- $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;
- $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;
-
/*
* Company Fact creation mode
*/
- if ($_GET["type"]=='f') { $soc->fournisseur=1; }
- if ($_GET["type"]=='c') { $soc->client=1; }
- if ($_GET["type"]=='p') { $soc->client=2; }
- if ($_GET["type"]=='cp') { $soc->client=3; }
- if ($_REQUEST["private"]==1) { $soc->particulier=1; }
+ if ($_GET["type"]=='f') { $soc->object->fournisseur=1; }
+ if ($_GET["type"]=='c') { $soc->object->client=1; }
+ if ($_GET["type"]=='p') { $soc->object->client=2; }
+ if ($_GET["type"]=='cp') { $soc->object->client=3; }
+ if ($_REQUEST["private"]==1) { $soc->object->particulier=1; }
- $soc->nom=$_POST["nom"];
- $soc->prenom=$_POST["prenom"];
- $soc->particulier=$_REQUEST["private"];
- $soc->prefix_comm=$_POST["prefix_comm"];
- $soc->client=$_POST["client"]?$_POST["client"]:$soc->client;
- $soc->code_client=$_POST["code_client"];
- $soc->fournisseur=$_POST["fournisseur"]?$_POST["fournisseur"]:$soc->fournisseur;
- $soc->code_fournisseur=$_POST["code_fournisseur"];
- $soc->adresse=$_POST["adresse"];
- $soc->address=$_POST["adresse"]; // TODO obsolete
- $soc->cp=$_POST["cp"];
- $soc->ville=$_POST["ville"];
- $soc->departement_id=$_POST["departement_id"];
- $soc->tel=$_POST["tel"];
- $soc->fax=$_POST["fax"];
- $soc->email=$_POST["email"];
- $soc->url=$_POST["url"];
- $soc->capital=$_POST["capital"];
- $soc->gencod=$_POST["gencod"];
- $soc->siren=$_POST["idprof1"];
- $soc->siret=$_POST["idprof2"];
- $soc->ape=$_POST["idprof3"];
- $soc->idprof4=$_POST["idprof4"];
- $soc->typent_id=($_POST["typent_id"]&&!$_POST["cleartype"])?$_POST["typent_id"]:($_REQUEST["private"]?'TE_PRIVATE':'');
- $soc->effectif_id=($_POST["effectif_id"]&&!$_POST["cleartype"])?$_POST["effectif_id_id"]:($_REQUEST["private"]?'EF1-5':'');
+ $soc->object->nom=$_POST["nom"];
+ $soc->object->prenom=$_POST["prenom"];
+ $soc->object->particulier=$_REQUEST["private"];
+ $soc->object->prefix_comm=$_POST["prefix_comm"];
+ $soc->object->client=$_POST["client"]?$_POST["client"]:$soc->object->client;
+ $soc->object->code_client=$_POST["code_client"];
+ $soc->object->fournisseur=$_POST["fournisseur"]?$_POST["fournisseur"]:$soc->object->fournisseur;
+ $soc->object->code_fournisseur=$_POST["code_fournisseur"];
+ $soc->object->adresse=$_POST["adresse"];
+ $soc->object->address=$_POST["adresse"]; // TODO obsolete
+ $soc->object->cp=$_POST["cp"];
+ $soc->object->ville=$_POST["ville"];
+ $soc->object->departement_id=$_POST["departement_id"];
+ $soc->object->tel=$_POST["tel"];
+ $soc->object->fax=$_POST["fax"];
+ $soc->object->email=$_POST["email"];
+ $soc->object->url=$_POST["url"];
+ $soc->object->capital=$_POST["capital"];
+ $soc->object->gencod=$_POST["gencod"];
+ $soc->object->siren=$_POST["idprof1"];
+ $soc->object->siret=$_POST["idprof2"];
+ $soc->object->ape=$_POST["idprof3"];
+ $soc->object->idprof4=$_POST["idprof4"];
+ $soc->object->typent_id=($_POST["typent_id"]&&!$_POST["cleartype"])?$_POST["typent_id"]:($_REQUEST["private"]?'TE_PRIVATE':'');
+ $soc->object->effectif_id=($_POST["effectif_id"]&&!$_POST["cleartype"])?$_POST["effectif_id_id"]:($_REQUEST["private"]?'EF1-5':'');
- $soc->tva_assuj = $_POST["assujtva_value"];
+ $soc->object->tva_assuj = $_POST["assujtva_value"];
//Local Taxes
- $soc->localtax1_assuj = $_POST["localtax1assuj_value"];
- $soc->localtax2_assuj = $_POST["localtax2assuj_value"];
+ $soc->object->localtax1_assuj = $_POST["localtax1assuj_value"];
+ $soc->object->localtax2_assuj = $_POST["localtax2assuj_value"];
- $soc->tva_intra=$_POST["tva_intra"];
+ $soc->object->tva_intra=$_POST["tva_intra"];
- $soc->commercial_id=$_POST["commercial_id"];
- $soc->default_lang=$_POST["default_lang"];
+ $soc->object->commercial_id=$_POST["commercial_id"];
+ $soc->object->default_lang=$_POST["default_lang"];
// We set pays_id, pays_code and label for the selected country
- $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
- if ($soc->pays_id)
+ $soc->object->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
+ if ($soc->object->pays_id)
{
$sql = "SELECT code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
- $sql.= " WHERE rowid = ".$soc->pays_id;
+ $sql.= " WHERE rowid = ".$soc->object->pays_id;
$resql=$db->query($sql);
if ($resql)
{
@@ -445,8 +437,8 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
{
dol_print_error($db);
}
- $soc->pays_code=$obj->code;
- $soc->pays=$obj->libelle;
+ $soc->object->pays_code=$obj->code;
+ $soc->object->pays=$obj->libelle;
}
print_fiche_titre($langs->trans("NewCompany"));
@@ -486,285 +478,12 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
print " \n";
}
- dol_htmloutput_errors($soc->error,$soc->errors);
-
- print '';
-
- print ' ';
- print ' ';
- print ' ';
- print ' ';
- if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ' ';
-
- print '';
-
- // Name, firstname
- if ($soc->particulier)
- {
- print ''.$langs->trans('LastName').' ';
- print ''.$langs->trans('Prefix').' ';
- print ''.$langs->trans('FirstName').' ';
- print ' ';
- print ''.$langs->trans("UserTitle").' ';
- print $formcompany->select_civilite($contact->civilite_id).' ';
- print ' ';
- }
- else
- {
- print ''.$langs->trans('Name').' ';
- print ''.$langs->trans('Prefix').' ';
- }
-
- // Prospect/Customer
- print ''.$langs->trans('ProspectCustomer').' ';
- print 'client==2?' selected="true"':'').'>'.$langs->trans('Prospect').' ';
- print 'client==3?' selected="true"':'').'>'.$langs->trans('ProspectCustomer').' ';
- print 'client==1?' selected="true"':'').'>'.$langs->trans('Customer').' ';
- print 'client==0?' selected="true"':'').'>'.$langs->trans('NorProspectNorCustomer').' ';
- print ' ';
-
- print ''.$langs->trans('CustomerCode').' ';
- print '';
-
- print ' ';
-
- // Supplier
- print '';
- print ''.$langs->trans('Supplier').' ';
- print $form->selectyesno("fournisseur",$soc->fournisseur,1);
- print ' ';
- print ''.$langs->trans('SupplierCode').' ';
- print '';
-
- print ' ';
-
- // Category
- if ($soc->fournisseur)
- {
- $load = $soc->LoadSupplierCateg();
- if ( $load == 0)
- {
- if (sizeof($soc->SupplierCategories) > 0)
- {
- print '';
- print ''.$langs->trans('SupplierCategory').' ';
- print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1);
- print ' ';
- }
- }
- }
-
- // Barcode
- if ($conf->global->MAIN_MODULE_BARCODE)
- {
- print ''.$langs->trans('Gencod').' ';
- print $soc->gencod;
- print ' ';
- }
-
- // Address
- print ''.$langs->trans('Address').' ';
- print $soc->address;
- print ' ';
-
- // Zip / Town
- print ''.$langs->trans('Zip').' ';
- if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' ';
- print ' ';
- print ''.$langs->trans('Town').' ';
-
- // Country
- print ''.$langs->trans('Country').' ';
- $form->select_pays($soc->pays_id,'pays_id');
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- print ' ';
-
- // State
- print ''.$langs->trans('State').' ';
- if ($soc->pays_id)
- {
- $formcompany->select_departement($soc->departement_id,$soc->pays_code);
- }
- else
- {
- print $countrynotdefined;
- }
- print ' ';
-
- // Phone / Fax
- print ''.$langs->trans('Phone').' ';
- print ''.$langs->trans('Fax').' ';
-
- print ''.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').' ';
- print ''.$langs->trans('Web').' ';
-
- print ''.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).' ';
-
-
- print '';
- // IdProf1 (SIREN for France)
- $idprof=$langs->transcountry('ProfId1',$soc->pays_code);
- if ($idprof!='-')
- {
- print ''.$idprof.' ';
- $soc->show_input_id_prof(1,'idprof1',$soc->siren);
- print ' ';
- }
- else print ' ';
- // IdProf2 (SIRET for France)
- $idprof=$langs->transcountry('ProfId2',$soc->pays_code);
- if ($idprof!='-')
- {
- print ''.$idprof.' ';
- $soc->show_input_id_prof(2,'idprof2',$soc->siret);
- print ' ';
- }
- else print ' ';
- print ' ';
- print '';
- // IdProf3 (APE for France)
- $idprof=$langs->transcountry('ProfId3',$soc->pays_code);
- if ($idprof!='-')
- {
- print ''.$idprof.' ';
- $soc->show_input_id_prof(3,'idprof3',$soc->ape);
- print ' ';
- }
- else print ' ';
- // IdProf4 (NU for France)
- $idprof=$langs->transcountry('ProfId4',$soc->pays_code);
- if ($idprof!='-')
- {
- print ''.$idprof.' ';
- $soc->show_input_id_prof(4,'idprof4',$soc->idprof4);
- print ' ';
- }
- else print ' ';
- print ' ';
-
- // Legal Form
- print ''.$langs->trans('JuridicalStatus').' ';
- print '';
- if ($soc->pays_id)
- {
- $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
- }
- else
- {
- print $countrynotdefined;
- }
- print ' ';
-
- print ''.$langs->trans("Type").' '."\n";
- print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id);
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- print ' ';
- print ''.$langs->trans("Staff").' ';
- print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- print ' ';
-
- if ($conf->global->MAIN_MULTILANGS)
- {
- print ''.$langs->trans("DefaultLang").' '."\n";
- $formadmin->select_lang(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
- print ' ';
- print ' ';
- }
-
- // Assujeti TVA
- $html = new Form($db);
- print ''.$langs->trans('VATIsUsed').' ';
- print '';
- print $html->selectyesno('assujtva_value',1,1); // Assujeti par defaut en creation
- print ' ';
- print ''.$langs->trans('VATIntra').' ';
- print '';
- $s =' ';
- $s.=' ';
- if ($conf->use_javascript_ajax)
- {
- $s.=''.$langs->trans("VATIntraCheck").' ';
- print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
- }
- else
- {
- print $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').' ';
- }
- print ' ';
-
- print ' ';
-
- // Code TVA
- if ($conf->use_javascript_ajax)
- {
- print "\n";
- print '';
- print "\n";
- }
-
- // Local Taxes
- if($mysoc->pays_code=='ES')
- {
- if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
- {
- print ''.$langs->trans("LocalTax1IsUsedES").' ';
- print $html->selectyesno('localtax1assuj_value',0,1);
- print ' '.$langs->trans("LocalTax2IsUsedES").' ';
- print $html->selectyesno('localtax2assuj_value',0,1);
- print ' ';
-
- }
- elseif($mysoc->localtax1_assuj=="1")
- {
- print ''.$langs->trans("LocalTax1IsUsedES").' ';
- print $html->selectyesno('localtax1assuj_value',0,1);
- print ' ';
- }
- elseif($mysoc->localtax2_assuj=="1")
- {
- print ' '.$langs->trans("LocalTax2IsUsedES").' ';
- print $html->selectyesno('localtax2assuj_value',0,1);
- print ' ';
- }
- }
-
- if ($user->rights->societe->client->voir)
- {
- // Assign a Name
- print ' ';
- print ''.$langs->trans("AllocateCommercial").' ';
- print '';
- $form->select_users($soc->commercial_id,'commercial_id',1);
- print ' ';
- }
-
-
-
- print '';
- print ' ';
- print ' '."\n";
-
- print '
'."\n";
- print ' '."\n";
+ dol_htmloutput_errors($soc->object->error,$soc->object->errors);
+
+ // Assign values
+ $soc->assign_values('create');
+ // Display canvas
+ $soc->display_canvas();
}
}
@@ -1160,15 +879,6 @@ else
* Company Fact Sheet mode visu
*/
- // Call canvas
- //if (empty($_GET["canvas"])) $_GET["canvas"]='default';
-
- $socstatic = new Societe($db);
- $socstatic->getCanvas($socid);
-
- $soc = new Canvas($db,$user);
- $soc->load_canvas('thirdparty@societe',$socstatic->canvas);
-
$soc->id = $socid;
$result=$soc->fetch($socid);
if ($result < 0)
@@ -1181,7 +891,9 @@ else
dol_fiche_head($head, 'company', $langs->trans("ThirdParty"),0,'company');
- $soc->assign_values('view');
+ // Assign values
+ $soc->assign_values('view');
+ // Display canvas
$soc->display_canvas();
/*