Works on canvas integration in third party module

This commit is contained in:
Regis Houssin 2010-09-01 20:51:10 +00:00
parent 889226b499
commit af96971a31
11 changed files with 838 additions and 583 deletions

View File

@ -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()
{

View File

@ -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 '<select id="select'.$htmlname.'" class="flat selectpays" name="'.$htmlname.'" '.$htmloption.'>';
$out.= '<select id="select'.$htmlname.'" class="flat selectpays" name="'.$htmlname.'" '.$htmloption.'>';
$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 '<option value="'.$obj->rowid.'" selected="true">';
$out.= '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
$out.= '<option value="'.$obj->rowid.'">';
}
// 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:'&nbsp;'));
print '</option>';
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:'&nbsp;'));
$out.= '</option>';
$i++;
}
}
print '</select>';
return 0;
$out.= '</select>';
}
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 '<select class="flat" name="'.$htmlname.'"'.($disabled?' disabled="true"':'').'>';
if ($show_empty) print '<option value="-1"'.($id==-1?' selected="true"':'').'>&nbsp;</option>'."\n";
$out.= '<select class="flat" name="'.$htmlname.'"'.($disabled?' disabled="true"':'').'>';
if ($show_empty) $out.= '<option value="-1"'.($id==-1?' selected="true"':'').'>&nbsp;</option>'."\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 '<option value="'.$obj->rowid.'"';
if ($disableline) print ' disabled="true"';
print ' selected="true">';
$out.= '<option value="'.$obj->rowid.'"';
if ($disableline) $out.= ' disabled="true"';
$out.= ' selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'"';
if ($disableline) print ' disabled="true"';
print '>';
$out.= '<option value="'.$obj->rowid.'"';
if ($disableline) $out.= ' disabled="true"';
$out.= '>';
}
print $obj->name.($obj->name && $obj->firstname?' ':'').$obj->firstname;
//if ($obj->admin) print ' *';
if ($conf->global->MAIN_SHOW_LOGIN) print ' ('.$obj->login.')';
print '</option>';
$out.= $obj->name.($obj->name && $obj->firstname?' ':'').$obj->firstname;
//if ($obj->admin) $out.= ' *';
if ($conf->global->MAIN_SHOW_LOGIN) $out.= ' ('.$obj->login.')';
$out.= '</option>';
$i++;
}
}
print '</select>';
$out.= '</select>';
}
else
{
dol_print_error($this->db);
}
return $out;
}

View File

@ -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 '<select class="flat" name="'.$htmlname.'">';
$out.= '<select class="flat" name="'.$htmlname.'">';
if ($showempty)
{
print '<option value=""';
if ($selected == '') print ' selected="true"';
print '>&nbsp;</option>';
$out.= '<option value=""';
if ($selected == '') $out.= ' selected="true"';
$out.= '>&nbsp;</option>';
}
if ($showauto)
{
print '<option value="auto"';
if ($selected == 'auto') print ' selected="true"';
print '>'.$langs->trans("AutoDetectLang").'</option>';
$out.= '<option value="auto"';
if ($selected == 'auto') $out.= ' selected="true"';
$out.= '>'.$langs->trans("AutoDetectLang").'</option>';
}
asort($langs_available);
@ -82,19 +96,21 @@ class FormAdmin
{
if ( ! array_key_exists($key, $filter))
{
print '<option value="'.$key.'">'.$value.'</option>';
$out.= '<option value="'.$key.'">'.$value.'</option>';
}
}
else if ($selected == $key)
{
print '<option value="'.$key.'" selected="true">'.$value.'</option>';
$out.= '<option value="'.$key.'" selected="true">'.$value.'</option>';
}
else
{
print '<option value="'.$key.'">'.$value.'</option>';
$out.= '<option value="'.$key.'">'.$value.'</option>';
}
}
print '</select>';
$out.= '</select>';
return $out;
}
/**

View File

@ -174,8 +174,7 @@ class FormCompany
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
/**
* \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 '<select class="flat" name="'.$htmlname.'">';
if ($pays_code) print '<option value="0">&nbsp;</option>';
$out.= '<select class="flat" name="'.$htmlname.'">';
if ($pays_code) $out.= '<option value="0">&nbsp;</option>';
$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 '<option value="0">&nbsp;</option>';
$out.= '<option value="0">&nbsp;</option>';
}
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 '<option value="-1" disabled="true">----- '.$obj->libelle_pays." -----</option>\n";
$out.= '<option value="-1" disabled="true">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">';
$out.= '<option value="'.$obj->rowid.'" selected="true">';
}
else
{
print '<option value="'.$obj->rowid.'">';
$out.= '<option value="'.$obj->rowid.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libell<EFBFBD> par d<>faut
print $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->nom!='-'?$obj->nom:''));
print '</option>';
// 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.= '</option>';
}
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
$out.= '</select>';
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 '<select class="flat" name="'.$htmlname.'">';
print '<option value="">&nbsp;</option>';
$out.= '<select class="flat" name="'.$htmlname.'">';
$out.= '<option value="">&nbsp;</option>';
$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 '<option value="'.$obj->code.'" selected="true">';
$out.= '<option value="'.$obj->code.'" selected="true">';
}
else
{
print '<option value="'.$obj->code.'">';
$out.= '<option value="'.$obj->code.'">';
}
// 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 '</option>';
$out.= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:''));
$out.= '</option>';
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
$out.= '</select>';
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 '<div id="particulier2" class="visible">';
print '<select class="flat" name="forme_juridique_code">';
if ($pays_code) print '<option value="0">&nbsp;</option>';
$out.= '<div id="particulier2" class="visible">';
$out.= '<select class="flat" name="forme_juridique_code">';
if ($pays_code) $out.= '<option value="0">&nbsp;</option>';
$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 '<option value="0">&nbsp;</option>';
$out.= '<option value="0">&nbsp;</option>';
}
else {
if (! $pays || $pays != $obj->libelle_pays) {
// Affiche la rupture si on est en mode liste multipays
if (! $pays_code && $obj->code_pays) {
print '<option value="0">----- '.$obj->libelle_pays." -----</option>\n";
$out.= '<option value="0">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
}
if ($selected > 0 && $selected == $obj->code)
{
print '<option value="'.$obj->code.'" selected="true">';
$out.= '<option value="'.$obj->code.'" selected="true">';
}
else
{
print '<option value="'.$obj->code.'">';
$out.= '<option value="'.$obj->code.'">';
}
// 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 '</option>';
$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.= '</option>';
}
$i++;
}
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</div>';
$out.= '</select>';
if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
$out.= '</div>';
}
else
{
dol_print_error($this->db);
}
return $out;
}

View File

@ -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 ='<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->tva_intra.'">';
$s.=' ';
if ($conf->use_javascript_ajax)
{
$s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
}
else
{
$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
}
}
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.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->tva_intra.'">';
$s.=' &nbsp; ';
if ($conf->use_javascript_ajax)
for ($i=1; $i<=4; $i++)
{
$s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$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.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
$s='';
$s.=$this->tva_intra;
$s.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->tva_intra.'">';
$s.=' &nbsp; ';
if ($conf->use_javascript_ajax)
{
$s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
}
else
{
$this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
}
}
else
{
$this->tpl['tva_intra'] = '&nbsp;';
}
// 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'] = '&nbsp;';
}
// 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)
{

View File

@ -21,5 +21,175 @@
<!-- BEGIN PHP TEMPLATE -->
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
<input type="hidden" name="action" value="add">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="cleartype" value="0">
<input type="hidden" name="private" value="<?php echo $this->object->tpl['particulier']; ?>">
<?php if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) { ?>
<input type="hidden" name="code_auto" value="1">
<?php } ?>
<table class="border" width="100%">
<tr>
<td><span class="fieldrequired"><?php echo $langs->trans('Name'); ?></span></td>
<td><input type="text" size="30" maxlength="60" name="nom" value="<?php echo $this->object->tpl['nom']; ?>"></td>
<td><?php echo $langs->trans('Prefix'); ?></td>
<td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->object->tpl['prefix_comm']; ?>"></td>
</tr>
<tr>
<td width="25%"><span class="fieldrequired"><?php echo $langs->trans('ProspectCustomer'); ?></span></td>
<td width="25%"><?php echo $this->object->tpl['select_customertype']; ?></td>
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
<td width="25%">
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_client" size="16" value="<?php echo $this->object->tpl['customercode']; ?>" maxlength="15"></td>
<td><?php echo $this->object->tpl['help_customercode']; ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
<td><?php echo $this->object->tpl['yn_supplier']; ?></td>
<td><?php echo $langs->trans('SupplierCode'); ?></td>
<td>
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->object->tpl['suppliercode']; ?>" maxlength="15"></td>
<td><?php echo $this->object->tpl['help_suppliercode']; ?></td>
</tr>
</table>
</td>
</tr>
<?php
if ($this->object->tpl['fournisseur']) {
if (sizeof($this->object->tpl['suppliercategory']) > 0) { ?>
<tr>
<td><?php echo $langs->trans('SupplierCategory'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_suppliercategory']; ?></td>
</tr>
<?php } }?>
<?php if ($conf->global->MAIN_MODULE_BARCODE) { ?>
<tr>
<td><?php echo $langs->trans('Gencod'); ?></td>
<td colspan="3"><input type="text" name="gencod" value="<?php echo $this->object->tpl['gencod']; ?>"></td>
</tr>
<?php } ?>
<tr>
<td valign="top"><?php echo $langs->trans('Address'); ?></td>
<td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft"><?php echo $this->object->tpl['address']; ?></textarea></td>
</tr>
<tr>
<td><?php echo $langs->trans('Zip'); ?></td>
<td><input size="6" type="text" name="cp" value="<?php echo $this->object->tpl['cp']; ?>"><?php echo $this->object->tpl['autofilltownfromzip']; ?></td>
<td><?php echo $langs->trans('Town'); ?></td>
<td><input type="text" name="ville" value="<?php echo $this->object->tpl['ville']; ?>"></td>
</tr>
<tr>
<td width="25%"><?php echo $langs->trans('Country'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_country']; echo $this->object->tpl['info_admin']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('State'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_state']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('Phone'); ?></td>
<td><input type="text" name="tel" value="<?php echo $this->object->tpl['tel']; ?>"></td>
<td><?php echo $langs->trans('Fax'); ?></td>
<td><input type="text" name="fax" value="<?php echo $this->object->tpl['fax']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':''); ?></td>
<td><input type="text" name="email" size="32" value="<?php echo $this->object->tpl['email']; ?>"></td>
<td><?php echo $langs->trans('Web'); ?></td>
<td><input type="text" name="url" size="32" value="<?php echo $this->object->tpl['url']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans('Capital'); ?></td>
<td colspan="3"><input type="text" name="capital" size="10" value="<?php echo $this->object->tpl['capital']; ?>"> <?php echo $langs->trans("Currency".$conf->monnaie); ?></td>
</tr>
<?php
for ($i=1; $i<=4; $i++) {
if ($this->object->tpl['langprofid'.$i]!='-') {
if ($i==1 || $i==3) echo '<tr>';
echo '<td>'.$this->object->tpl['langprofid'.$i].'</td>';
echo '<td>'.$this->object->tpl['showprofid'.$i].'</td>';
if ($i==2 || $i==4) echo '</tr>';
} else {
if ($i==1 || $i==3) echo '<tr>';
echo '<td>&nbsp;</td>';
echo '<td>&nbsp;</td>';
if ($i==2 || $i==4) echo '</tr>';
}
}
?>
<tr>
<td><?php echo $langs->trans('JuridicalStatus'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_juridicalstatus']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Type"); ?></td>
<td><?php echo $this->object->tpl['select_companytype']; echo $this->object->tpl['info_admin']; ?></td>
<td><?php echo $langs->trans("Staff"); ?></td>
<td><?php echo $this->object->tpl['select_workforce']; echo $this->object->tpl['info_admin']; ?></td>
</tr>
<?php if ($conf->global->MAIN_MULTILANGS) { ?>
<tr>
<td><?php echo $langs->trans("DefaultLang"); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_lang']; ?></td>
</tr>
<?php } ?>
<?php if ($conf->use_javascript_ajax) { ?>
<script language="JavaScript" type="text/javascript">
function CheckVAT(a) {
newpopup('<?php echo DOL_URL_ROOT; ?>/societe/checkvat/checkVatPopup.php?vatNumber='+a,'<?php echo dol_escape_js($langs->trans("VATIntraCheckableOnEUSite")); ?>',500,260);
}
</script>
<?php } ?>
<tr>
<td><?php echo $langs->trans('VATIsUsed'); ?></td>
<td><?php echo $this->object->tpl['yn_assujtva']; ?></td>
<td nowrap="nowrap"><?php echo $langs->trans('VATIntra'); ?></td>
<td nowrap="nowrap"><?php echo $this->object->tpl['tva_intra']; ?></td>
</tr>
<?php if(!empty($this->object->tpl['localtax'])) echo $this->object->tpl['localtax']; ?>
<?php if ($user->rights->societe->client->voir) { ?>
<tr>
<td><?php echo $langs->trans("AllocateCommercial"); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_users']; ?></td>
</tr>
<?php } ?>
<tr>
<td colspan="4" align="center"><input type="submit" class="button" value="<?php echo $langs->trans('AddThirdParty'); ?>"></td>
</tr>
</table>
</form>
<!-- END PHP TEMPLATE -->

View File

@ -117,12 +117,12 @@ for ($i=1; $i<=4; $i++) {
else echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
}
echo '</td>';
if ($i==2 || $i==4) echo '<tr>';
if ($i==2 || $i==4) echo '</tr>';
} else {
if ($i==1 || $i==3) echo '<tr>';
echo '<td>&nbsp;</td>';
echo '<td>&nbsp;</td>';
if ($i==2 || $i==4) echo '<tr>';
if ($i==2 || $i==4) echo '</tr>';
}
}
?>

View File

@ -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);
}
}
}

View File

@ -21,5 +21,144 @@
<!-- BEGIN PHP TEMPLATE -->
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
<input type="hidden" name="action" value="add">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="cleartype" value="0">
<input type="hidden" name="private" value="<?php echo $this->object->tpl['particulier']; ?>">
<?php if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) { ?>
<input type="hidden" name="code_auto" value="1">
<?php } ?>
<table class="border" width="100%">
<tr>
<td><span class="fieldrequired"><?php echo $langs->trans('LastName'); ?></span></td>
<td><input type="text" size="30" maxlength="60" name="nom" value="<?php echo $this->object->tpl['nom']; ?>"></td>
<td><?php echo $langs->trans('Prefix'); ?></td>
<td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->object->tpl['prefix_comm']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans('FirstName'); ?></td>
<td><input type="text" size="30" name="prenom" value="<?php echo $this->object->tpl['firstname']; ?>"></td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td><?php echo $langs->trans("UserTitle"); ?></td>
<td><?php echo $this->object->tpl['select_civility']; ?></td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="25%"><span class="fieldrequired"><?php echo $langs->trans('ProspectCustomer'); ?></span></td>
<td width="25%"><?php echo $this->object->tpl['select_customertype']; ?></td>
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
<td width="25%">
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_client" size="16" value="<?php echo $this->object->tpl['customercode']; ?>" maxlength="15"></td>
<td><?php echo $this->object->tpl['help_customercode']; ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
<td><?php echo $this->object->tpl['yn_supplier']; ?></td>
<td><?php echo $langs->trans('SupplierCode'); ?></td>
<td>
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->object->tpl['suppliercode']; ?>" maxlength="15"></td>
<td><?php echo $this->object->tpl['help_suppliercode']; ?></td>
</tr>
</table>
</td>
</tr>
<?php
if ($this->object->tpl['fournisseur']) {
if (sizeof($this->object->tpl['suppliercategory']) > 0) { ?>
<tr>
<td><?php echo $langs->trans('SupplierCategory'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_suppliercategory']; ?></td>
</tr>
<?php } }?>
<?php if ($conf->global->MAIN_MODULE_BARCODE) { ?>
<tr>
<td><?php echo $langs->trans('Gencod'); ?></td>
<td colspan="3"><input type="text" name="gencod" value="<?php echo $this->object->tpl['gencod']; ?>"></td>
</tr>
<?php } ?>
<tr>
<td valign="top"><?php echo $langs->trans('Address'); ?></td>
<td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft"><?php echo $this->object->tpl['address']; ?></textarea></td>
</tr>
<tr>
<td><?php echo $langs->trans('Zip'); ?></td>
<td><input size="6" type="text" name="cp" value="<?php echo $this->object->tpl['cp']; ?>"><?php echo $this->object->tpl['autofilltownfromzip']; ?></td>
<td><?php echo $langs->trans('Town'); ?></td>
<td><input type="text" name="ville" value="<?php echo $this->object->tpl['ville']; ?>"></td>
</tr>
<tr>
<td width="25%"><?php echo $langs->trans('Country'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_country']; echo $this->object->tpl['info_admin']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('State'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_state']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('Phone'); ?></td>
<td><input type="text" name="tel" value="<?php echo $this->object->tpl['tel']; ?>"></td>
<td><?php echo $langs->trans('Fax'); ?></td>
<td><input type="text" name="fax" value="<?php echo $this->object->tpl['fax']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':''); ?></td>
<td><input type="text" name="email" size="32" value="<?php echo $this->object->tpl['email']; ?>"></td>
<td><?php echo $langs->trans('Web'); ?></td>
<td><input type="text" name="url" size="32" value="<?php echo $this->object->tpl['url']; ?>"></td>
</tr>
<?php if ($conf->global->MAIN_MULTILANGS) { ?>
<tr>
<td><?php echo $langs->trans("DefaultLang"); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_lang']; ?></td>
</tr>
<?php } ?>
<tr>
<td><?php echo $langs->trans('VATIsUsed'); ?></td>
<td colspan="3"><?php echo $this->object->tpl['yn_assujtva']; ?></td>
</tr>
<?php if(!empty($this->object->tpl['localtax'])) echo $this->object->tpl['localtax']; ?>
<?php if ($user->rights->societe->client->voir) { ?>
<tr>
<td><?php echo $langs->trans("AllocateCommercial"); ?></td>
<td colspan="3"><?php echo $this->object->tpl['select_users']; ?></td>
</tr>
<?php } ?>
<tr>
<td colspan="4" align="center"><input type="submit" class="button" value="<?php echo $langs->trans('AddThirdParty'); ?>"></td>
</tr>
</table>
</form>
<!-- END PHP TEMPLATE -->

View File

@ -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 '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">';
$out = '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">';
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'] = '<select class="flat" name="client">';
$this->tpl['select_customertype'].= '<option value="2"'.($this->client==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>';
$this->tpl['select_customertype'].= '<option value="3"'.($this->client==3?' selected="true"':'').'>'.$langs->trans('ProspectCustomer').'</option>';
$this->tpl['select_customertype'].= '<option value="1"'.($this->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>';
$this->tpl['select_customertype'].= '<option value="0"'.($this->client==0?' selected="true"':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
$this->tpl['select_customertype'].= '</select>';
// 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'] = '<input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(\''.DOL_URL_ROOT.'\',cp.value,ville,pays_id,departement_id)">';
// 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'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',0,1);
$this->tpl['localtax'].= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',0,1);
$this->tpl['localtax'].= '</td></tr>';
}
elseif($mysoc->localtax1_assuj=="1")
{
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',0,1);
$this->tpl['localtax'].= '</td><tr>';
}
elseif($mysoc->localtax2_assuj=="1")
{
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',0,1);
$this->tpl['localtax'].= '</td><tr>';
}
}
}
if ($action == 'view')
{
$this->tpl['showrefnav'] = $form->showrefnav($this,'socid','',($user->societe_id?0:1),'rowid','nom');

View File

@ -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 "<br>\n";
}
dol_htmloutput_errors($soc->error,$soc->errors);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="cleartype" value="0">';
print '<input type="hidden" name="private" value='.$soc->particulier.'>';
if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">';
print '<table class="border" width="100%">';
// Name, firstname
if ($soc->particulier)
{
print '<tr><td><span class="fieldrequired">'.$langs->trans('LastName').'</span></td><td><input type="text" size="30" maxlength="60" name="nom" value="'.$soc->nom.'"></td>';
print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$soc->prefix_comm.'"></td></tr>';
print '<tr><td>'.$langs->trans('FirstName').'</td><td><input type="text" size="30" name="prenom" value="'.$soc->firstname.'"></td>';
print '<td colspan=2>&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
print $formcompany->select_civilite($contact->civilite_id).'</td>';
print '<td colspan=2>&nbsp;</td></tr>';
}
else
{
print '<tr><td><span class="fieldrequired">'.$langs->trans('Name').'</span></td><td><input type="text" size="30" maxlength="60" name="nom" value="'.$soc->nom.'"></td>';
print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$soc->prefix_comm.'"></td></tr>';
}
// Prospect/Customer
print '<tr><td width="25%"><span class="fieldrequired">'.$langs->trans('ProspectCustomer').'</span></td><td width="25%"><select class="flat" name="client">';
print '<option value="2"'.($soc->client==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>';
print '<option value="3"'.($soc->client==3?' selected="true"':'').'>'.$langs->trans('ProspectCustomer').'</option>';
print '<option value="1"'.($soc->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>';
print '<option value="0"'.($soc->client==0?' selected="true"':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
print '</select></td>';
print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
print '<table class="nobordernopadding"><tr><td>';
$tmpcode=$soc->code_client;
if ($modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0);
print '<input type="text" name="code_client" size="16" value="'.$tmpcode.'" maxlength="15">';
print '</td><td>';
$s=$modCodeClient->getToolTip($langs,$soc,0);
print $form->textwithpicto('',$s,1);
print '</td></tr></table>';
print '</td></tr>';
// Supplier
print '<tr>';
print '<td><span class="fieldrequired">'.$langs->trans('Supplier').'</span></td><td>';
print $form->selectyesno("fournisseur",$soc->fournisseur,1);
print '</td>';
print '<td>'.$langs->trans('SupplierCode').'</td><td>';
print '<table class="nobordernopadding"><tr><td>';
$tmpcode=$soc->code_fournisseur;
if ($modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1);
print '<input type="text" name="code_fournisseur" size="16" value="'.$tmpcode.'" maxlength="15">';
print '</td><td>';
$s=$modCodeFournisseur->getToolTip($langs,$soc,1);
print $form->textwithpicto('',$s,1);
print '</td></tr></table>';
print '</td></tr>';
// Category
if ($soc->fournisseur)
{
$load = $soc->LoadSupplierCateg();
if ( $load == 0)
{
if (sizeof($soc->SupplierCategories) > 0)
{
print '<tr>';
print '<td>'.$langs->trans('SupplierCategory').'</td><td colspan="3">';
print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1);
print '</td></tr>';
}
}
}
// Barcode
if ($conf->global->MAIN_MODULE_BARCODE)
{
print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="3"><input type="text" name="gencod">';
print $soc->gencod;
print '</textarea></td></tr>';
}
// Address
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
print $soc->address;
print '</textarea></td></tr>';
// Zip / Town
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'">';
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(\''.DOL_URL_ROOT.'\',cp.value,ville,pays_id,departement_id)">';
print '</td>';
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
// Country
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
$form->select_pays($soc->pays_id,'pays_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>';
// State
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
if ($soc->pays_id)
{
$formcompany->select_departement($soc->departement_id,$soc->pays_code);
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
// Phone / Fax
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
print '<tr><td>'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').'</td><td><input type="text" name="email" size="32" value="'.$soc->email.'"></td>';
print '<td>'.$langs->trans('Web').'</td><td><input type="text" name="url" size="32" value="'.$soc->url.'"></td></tr>';
print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr>';
// IdProf1 (SIREN for France)
$idprof=$langs->transcountry('ProfId1',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(1,'idprof1',$soc->siren);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
// IdProf2 (SIRET for France)
$idprof=$langs->transcountry('ProfId2',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(2,'idprof2',$soc->siret);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
print '</tr>';
print '<tr>';
// IdProf3 (APE for France)
$idprof=$langs->transcountry('ProfId3',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(3,'idprof3',$soc->ape);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
// IdProf4 (NU for France)
$idprof=$langs->transcountry('ProfId4',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(4,'idprof4',$soc->idprof4);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
print '</tr>';
// Legal Form
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td>';
print '<td colspan="3">';
if ($soc->pays_id)
{
$formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("Type").'</td><td>'."\n";
print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td>';
print '<td>'.$langs->trans("Staff").'</td><td>';
print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>';
if ($conf->global->MAIN_MULTILANGS)
{
print '<tr><td>'.$langs->trans("DefaultLang").'</td><td colspan="3">'."\n";
$formadmin->select_lang(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
print '</td>';
print '</tr>';
}
// Assujeti TVA
$html = new Form($db);
print '<tr><td>'.$langs->trans('VATIsUsed').'</td>';
print '<td>';
print $html->selectyesno('assujtva_value',1,1); // Assujeti par defaut en creation
print '</td>';
print '<td nowrap="nowrap">'.$langs->trans('VATIntra').'</td>';
print '<td nowrap="nowrap">';
$s ='<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$soc->tva_intra.'">';
$s.=' ';
if ($conf->use_javascript_ajax)
{
$s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
}
else
{
print $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
}
print '</td>';
print '</tr>';
// Code TVA
if ($conf->use_javascript_ajax)
{
print "\n";
print '<script language="JavaScript" type="text/javascript">';
print "function CheckVAT(a) {\n";
print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,230);\n";
print "}\n";
print '</script>';
print "\n";
}
// Local Taxes
if($mysoc->pays_code=='ES')
{
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
{
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
print $html->selectyesno('localtax1assuj_value',0,1);
print '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
print $html->selectyesno('localtax2assuj_value',0,1);
print '</td></tr>';
}
elseif($mysoc->localtax1_assuj=="1")
{
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
print $html->selectyesno('localtax1assuj_value',0,1);
print '</td><tr>';
}
elseif($mysoc->localtax2_assuj=="1")
{
print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
print $html->selectyesno('localtax2assuj_value',0,1);
print '</td><tr>';
}
}
if ($user->rights->societe->client->voir)
{
// Assign a Name
print '<tr>';
print '<td>'.$langs->trans("AllocateCommercial").'</td>';
print '<td colspan="3">';
$form->select_users($soc->commercial_id,'commercial_id',1);
print '</td></tr>';
}
print '<tr><td colspan="4" align="center">';
print '<input type="submit" class="button" value="'.$langs->trans('AddThirdParty').'">';
print '</td></tr>'."\n";
print '</table>'."\n";
print '</form>'."\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();
/*