New: Support "Department/State" field on contact card.
This commit is contained in:
parent
ec5a7dfd35
commit
e20c738264
@ -22,12 +22,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/contact/contact.class.php
|
||||
* \file htdocs/contact/class/contact.class.php
|
||||
* \ingroup societe
|
||||
* \brief File of contacts class
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||
|
||||
|
||||
@ -49,8 +48,15 @@ class Contact extends CommonObject
|
||||
var $address;
|
||||
var $cp;
|
||||
var $ville;
|
||||
|
||||
var $fk_departement; // Id of department
|
||||
var $departement_code; // Code of department
|
||||
var $departement; // Label of department
|
||||
|
||||
var $fk_pays; // Id of country
|
||||
var $pays_code; // Code of country
|
||||
var $pays; // Label of country
|
||||
|
||||
var $socid; // fk_soc
|
||||
var $status; // 0=brouillon, 1=4=actif, 5=inactif
|
||||
|
||||
@ -84,7 +90,7 @@ class Contact extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add a contact in database
|
||||
* \brief Add a contact into database
|
||||
* \param user Object user that create
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
@ -92,13 +98,15 @@ class Contact extends CommonObject
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
// Clean parameters
|
||||
$this->name=trim($this->name);
|
||||
if (! $this->socid) $this->socid = 0;
|
||||
if (! $this->priv) $this->priv = 0;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople (datec, fk_soc, name, fk_user_creat, priv)";
|
||||
$sql.= " VALUES (".$this->db->idate(mktime()).",";
|
||||
$sql.= " VALUES ('".$this->db->idate($now)."',";
|
||||
if ($this->socid > 0) $sql.= " ".$this->socid.",";
|
||||
else $sql.= "null,";
|
||||
$sql.= "'".addslashes($this->name)."',";
|
||||
@ -173,6 +181,7 @@ class Contact extends CommonObject
|
||||
$sql .= ", cp='".addslashes($this->cp)."'";
|
||||
$sql .= ", ville='".addslashes($this->ville)."'";
|
||||
$sql .= ", fk_pays=".($this->fk_pays>0?$this->fk_pays:'NULL');
|
||||
$sql .= ", fk_departement=".($this->fk_departement>0?$this->fk_departement:'NULL');
|
||||
$sql .= ", poste='".addslashes($this->poste)."'";
|
||||
$sql .= ", fax='".addslashes($this->fax)."'";
|
||||
$sql .= ", email='".addslashes($this->email)."'";
|
||||
@ -390,6 +399,7 @@ class Contact extends CommonObject
|
||||
$sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name, c.firstname,";
|
||||
$sql.= " c.address, c.cp, c.ville,";
|
||||
$sql.= " c.fk_pays, p.libelle as pays, p.code as pays_code,";
|
||||
$sql.= " c.fk_departement, d.nom as departement, d.code_departement as departement_code,";
|
||||
$sql.= " c.birthday,";
|
||||
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,";
|
||||
$sql.= " c.priv, c.note, c.default_lang,";
|
||||
@ -397,6 +407,7 @@ class Contact extends CommonObject
|
||||
$sql.= " s.nom as socname, s.address as socaddress, s.cp as soccp, s.ville as soccity, s.default_lang as socdefault_lang";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON c.fk_pays = p.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
|
||||
$sql.= " WHERE c.rowid = ". $id;
|
||||
@ -422,6 +433,11 @@ class Contact extends CommonObject
|
||||
$this->cp = $obj->cp?$obj->cp:$obj->soccp;
|
||||
$this->ville = $obj->ville?$obj->ville:$obj->soccity;
|
||||
$this->fk_pays = $obj->fk_pays;
|
||||
|
||||
$this->fk_departement = $obj->fk_departement;
|
||||
$this->departement_code = $obj->fk_departement?$obj->departement_code:'';
|
||||
$this->departement = $obj->fk_departement?$obj->departement:'';
|
||||
|
||||
$this->pays_code = $obj->fk_pays?$obj->pays_code:'';
|
||||
$this->pays = ($obj->fk_pays > 0)?$langs->transnoentities("Country".$obj->pays_code):$langs->transnoentities("SelectCountry");
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
|
||||
$langs->load("companies");
|
||||
$langs->load("users");
|
||||
|
||||
$error = array();
|
||||
$errors = array();
|
||||
$socid=$_GET["socid"]?$_GET["socid"]:$_POST["socid"];
|
||||
|
||||
// If socid provided by ajax company selector
|
||||
@ -98,6 +98,7 @@ if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
|
||||
$contact->cp = $_POST["cp"];
|
||||
$contact->ville = $_POST["ville"];
|
||||
$contact->fk_pays = $_POST["pays_id"];
|
||||
$contact->fk_departement = $_POST["departement_id"];
|
||||
$contact->email = $_POST["email"];
|
||||
$contact->phone_pro = $_POST["phone_pro"];
|
||||
$contact->phone_perso = $_POST["phone_perso"];
|
||||
@ -110,8 +111,10 @@ if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
|
||||
|
||||
if (! $_POST["name"])
|
||||
{
|
||||
array_push($error,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
||||
$_GET["action"]="create";
|
||||
array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
||||
$_GET["action"] = 'create';
|
||||
$_POST["action"] = 'create';
|
||||
$_REQUEST["action"] = 'create';
|
||||
}
|
||||
|
||||
if ($_POST["name"])
|
||||
@ -124,8 +127,10 @@ if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=array($contact->error);
|
||||
$errors=array($contact->error);
|
||||
$_GET["action"] = 'create';
|
||||
$_POST["action"] = 'create';
|
||||
$_REQUEST["action"] = 'create';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,45 +157,58 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
|
||||
|
||||
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($_POST["contactid"]);
|
||||
|
||||
$contact->oldcopy=dol_clone($contact);
|
||||
|
||||
$contact->old_name = $_POST["old_name"];
|
||||
$contact->old_firstname = $_POST["old_firstname"];
|
||||
|
||||
$contact->socid = $_POST["socid"];
|
||||
$contact->name = $_POST["name"];
|
||||
$contact->firstname = $_POST["firstname"];
|
||||
$contact->civilite_id = $_POST["civilite_id"];
|
||||
$contact->poste = $_POST["poste"];
|
||||
|
||||
$contact->address = $_POST["address"];
|
||||
$contact->cp = $_POST["cp"];
|
||||
$contact->ville = $_POST["ville"];
|
||||
$contact->fk_pays = $_POST["pays_id"];
|
||||
|
||||
$contact->email = $_POST["email"];
|
||||
$contact->phone_pro = $_POST["phone_pro"];
|
||||
$contact->phone_perso = $_POST["phone_perso"];
|
||||
$contact->phone_mobile = $_POST["phone_mobile"];
|
||||
$contact->fax = $_POST["fax"];
|
||||
$contact->jabberid = $_POST["jabberid"];
|
||||
$contact->priv = $_POST["priv"];
|
||||
|
||||
$contact->note = $_POST["note"];
|
||||
|
||||
$result = $contact->update($_POST["contactid"], $user);
|
||||
|
||||
if ($result > 0)
|
||||
if (empty($_POST["name"]))
|
||||
{
|
||||
$contact->old_name='';
|
||||
$contact->old_firstname='';
|
||||
$errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
||||
$error++;
|
||||
$_GET["action"] = 'edit';
|
||||
$_POST["action"] = 'edit';
|
||||
$_REQUEST["action"] = 'edit';
|
||||
}
|
||||
else
|
||||
|
||||
if (! sizeof($errors))
|
||||
{
|
||||
$error = $contact->error;
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($_POST["contactid"]);
|
||||
|
||||
$contact->oldcopy=dol_clone($contact);
|
||||
|
||||
$contact->old_name = $_POST["old_name"];
|
||||
$contact->old_firstname = $_POST["old_firstname"];
|
||||
|
||||
$contact->socid = $_POST["socid"];
|
||||
$contact->name = $_POST["name"];
|
||||
$contact->firstname = $_POST["firstname"];
|
||||
$contact->civilite_id = $_POST["civilite_id"];
|
||||
$contact->poste = $_POST["poste"];
|
||||
|
||||
$contact->address = $_POST["address"];
|
||||
$contact->cp = $_POST["cp"];
|
||||
$contact->ville = $_POST["ville"];
|
||||
$contact->fk_departement= $_POST["departement_id"];
|
||||
$contact->fk_pays = $_POST["pays_id"];
|
||||
|
||||
$contact->email = $_POST["email"];
|
||||
$contact->phone_pro = $_POST["phone_pro"];
|
||||
$contact->phone_perso = $_POST["phone_perso"];
|
||||
$contact->phone_mobile = $_POST["phone_mobile"];
|
||||
$contact->fax = $_POST["fax"];
|
||||
$contact->jabberid = $_POST["jabberid"];
|
||||
$contact->priv = $_POST["priv"];
|
||||
|
||||
$contact->note = $_POST["note"];
|
||||
|
||||
$result = $contact->update($_POST["contactid"], $user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$contact->old_name='';
|
||||
$contact->old_firstname='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg=$contact->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,6 +222,8 @@ llxHeader('',$langs->trans("Contacts"),'EN:Module_Third_Parties|FR:Module_Tiers|
|
||||
$form = new Form($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$objsoc = new Societe($db);
|
||||
@ -248,23 +268,40 @@ if ($user->rights->societe->contact->supprimer)
|
||||
|
||||
if ($user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($_GET["action"] == 'create')
|
||||
if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
{
|
||||
/*
|
||||
* Fiche en mode creation
|
||||
*/
|
||||
$contact->fk_departement = $_POST["departement_id"];
|
||||
|
||||
// We set pays_id, pays_code and label for the selected country
|
||||
$contact->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
if ($contact->fk_pays)
|
||||
{
|
||||
$sql = "SELECT code, libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
|
||||
$sql.= " WHERE rowid = ".$contact->fk_pays;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$contact->pays_code=$obj->code;
|
||||
$contact->pays=$obj->libelle;
|
||||
}
|
||||
|
||||
print_fiche_titre($langs->trans("AddContact"));
|
||||
|
||||
// Affiche les erreurs
|
||||
if (sizeof($error))
|
||||
{
|
||||
print "<div class='error'>";
|
||||
print join("<br>",$error);
|
||||
print "</div>\n";
|
||||
}
|
||||
dol_htmloutput_errors($mesg,$errors);
|
||||
|
||||
print '<br>';
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<form method="post" name="formsoc" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<table class="border" width="100%">';
|
||||
@ -274,10 +311,10 @@ if ($user->rights->societe->contact->creer)
|
||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="'.$contact->firstname.'"></td></tr>';
|
||||
|
||||
// Company
|
||||
if ($socid)
|
||||
if ($socid > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Company").'</td>';
|
||||
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socid.'">'.$objsoc->nom.'</a></td>';
|
||||
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id.'">'.$objsoc->nom.'</a></td>';
|
||||
print '<input type="hidden" name="socid" value="'.$objsoc->id.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -300,17 +337,32 @@ if ($user->rights->societe->contact->creer)
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE') && strlen(trim($contact->address)) == 0) $contact->address = $objsoc->address; // Predefined with third party
|
||||
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><textarea class="flat" name="address" cols="70">'.$contact->address.'</textarea></td>';
|
||||
|
||||
// Zip / Town
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE') && strlen(trim($contact->cp)) == 0) $contact->cp = $objsoc->cp; // Predefined with third party
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE') && strlen(trim($contact->ville)) == 0) $contact->ville = $objsoc->ville; // Predefined with third party
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.$contact->cp.'"> ';
|
||||
print '<input name="ville" type="text" size="20" value="'.$contact->ville.'" maxlength="80"></td></tr>';
|
||||
|
||||
// Country
|
||||
if (strlen(trim($contact->fk_pays)) == 0) $contact->fk_pays = $objsoc->pays_id; // Predefined with third party
|
||||
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
|
||||
$form->select_pays($contact->fk_pays);
|
||||
$form->select_pays($contact->fk_pays,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':'');
|
||||
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 ($contact->fk_pays)
|
||||
{
|
||||
$formcompany->select_departement($contact->fk_departement,$contact->pays_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $countrynotdefined;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Phone / Fax
|
||||
if (($objsoc->typent_code == 'TE_PRIVATE') && strlen(trim($contact->phone_pro)) == 0) $contact->phone_pro = $objsoc->tel; // Predefined with third party
|
||||
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.$contact->phone_pro.'"></td>';
|
||||
print '<td>'.$langs->trans("PhonePerso").'</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->phone_perso.'"></td></tr>';
|
||||
@ -340,24 +392,35 @@ if ($user->rights->societe->contact->creer)
|
||||
|
||||
print "</form>";
|
||||
}
|
||||
elseif ($_GET["action"] == 'edit' && $_GET["id"])
|
||||
elseif ($_REQUEST["action"] == 'edit' && $_REQUEST["id"])
|
||||
{
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*
|
||||
*/
|
||||
|
||||
// Affiche les erreurs
|
||||
if (sizeof($error))
|
||||
// We set pays_id, and pays_code label of the chosen country
|
||||
if ($contact->fk_pays)
|
||||
{
|
||||
print "<div class='error'>";
|
||||
print join("<br>",$error);
|
||||
print "</div>\n";
|
||||
$sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$contact->fk_pays;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$contact->pays_code=$obj->code;
|
||||
$contact->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
|
||||
}
|
||||
|
||||
print '<form method="post" action="fiche.php?id='.$_GET["id"].'">';
|
||||
// Affiche les erreurs
|
||||
dol_htmloutput_errors($mesg,$errors);
|
||||
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$_REQUEST["id"].'" name="formsoc">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="contactid" value="'.$contact->id.'">';
|
||||
print '<input type="hidden" name="old_name" value="'.$contact->name.'">';
|
||||
@ -370,7 +433,7 @@ if ($user->rights->societe->contact->creer)
|
||||
print '</td></tr>';
|
||||
|
||||
// Name
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Lastname").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>';
|
||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="20" maxlength="80" value="'.$contact->firstname.'"></td></tr>';
|
||||
|
||||
// Company
|
||||
@ -390,14 +453,22 @@ if ($user->rights->societe->contact->creer)
|
||||
// Address
|
||||
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><textarea class="flat" name="address" cols="70">'.$contact->address.'</textarea></td>';
|
||||
|
||||
// Zip / Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.$contact->cp.'"> ';
|
||||
print '<input name="ville" type="text" size="20" value="'.$contact->ville.'" maxlength="80"></td></tr>';
|
||||
|
||||
// Country
|
||||
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
|
||||
$form->select_pays($contact->fk_pays);
|
||||
$form->select_pays($contact->fk_pays,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':'');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Department
|
||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
||||
$formcompany->select_departement($contact->fk_departement,$contact->pays_code);
|
||||
print '</td></tr>';
|
||||
|
||||
// Phone
|
||||
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.$contact->phone_pro.'"></td>';
|
||||
print '<td>'.$langs->trans("PhonePerso").'</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->phone_perso.'"></td></tr>';
|
||||
|
||||
@ -484,7 +555,7 @@ if ($user->rights->societe->contact->creer)
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit')
|
||||
{
|
||||
$objsoc = new Societe($db);
|
||||
|
||||
@ -544,13 +615,19 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
// Address
|
||||
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($contact->address).'</td></tr>';
|
||||
|
||||
// Zip Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$contact->cp.' ';
|
||||
print $contact->ville.'</td></tr>';
|
||||
|
||||
// Country
|
||||
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
|
||||
print $contact->pays;
|
||||
print '</td></tr>';
|
||||
|
||||
// Department
|
||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$contact->departement.'</td>';
|
||||
|
||||
// Phone
|
||||
print '<tr><td>'.$langs->trans("PhonePro").'</td><td>'.dol_print_phone($contact->phone_pro,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'</td>';
|
||||
print '<td>'.$langs->trans("PhonePerso").'</td><td>'.dol_print_phone($contact->phone_perso,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'</td></tr>';
|
||||
|
||||
|
||||
@ -182,10 +182,11 @@ class FormCompany
|
||||
* \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 forme juridique a preselectionne
|
||||
* \param pays_code 0=liste tous pays confondus, sinon code du pays a afficher
|
||||
* \param selected Code forme juridique a preselectionne
|
||||
* \param pays_code 0=liste tous pays confondus, sinon code du pays a afficher
|
||||
* \param departement_id Id of department
|
||||
*/
|
||||
function select_departement($selected='',$pays_code=0)
|
||||
function select_departement($selected='',$pays_code=0, $htmlname='departement_id')
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
|
||||
@ -193,9 +194,7 @@ class FormCompany
|
||||
|
||||
$langs->load("dict");
|
||||
|
||||
$htmlname='departement_id';
|
||||
|
||||
// On recherche les d<>partements/cantons/province active d'une region et pays actif
|
||||
// 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";
|
||||
$sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid";
|
||||
|
||||
@ -11,6 +11,9 @@
|
||||
-- V4.1 UPDATE llx_projet_task set fk_user_creat=NULL WHERE fk_user_creat IS NOT NULL AND fk_user_creat NOT IN (SELECT rowid from llx_user);
|
||||
-- V4.1 UPDATE llx_projet_task set fk_user_valid=NULL WHERE fk_user_valid IS NOT NULL AND fk_user_valid NOT IN (SELECT rowid from llx_user);
|
||||
|
||||
|
||||
ALTER TABLE llx_socpeople ADD COLUMN fk_departement integer DEFAULT 0 after ville;
|
||||
|
||||
-- rename llx_product_det
|
||||
ALTER TABLE llx_product_det RENAME TO llx_product_lang;
|
||||
ALTER TABLE llx_product_lang ADD UNIQUE INDEX uk_product_lang (fk_product, lang);
|
||||
|
||||
@ -33,6 +33,7 @@ create table llx_socpeople
|
||||
address varchar(255),
|
||||
cp varchar(25),
|
||||
ville varchar(255),
|
||||
fk_departement integer DEFAULT 0,
|
||||
fk_pays integer DEFAULT 0,
|
||||
birthday date,
|
||||
poste varchar(80),
|
||||
|
||||
@ -59,13 +59,13 @@ $soc = new Societe($db);
|
||||
if ($_POST["getcustomercode"])
|
||||
{
|
||||
// We defined value code_client
|
||||
$_POST["code_client"]="aa";
|
||||
$_POST["code_client"]="Acompleter";
|
||||
}
|
||||
|
||||
if ($_POST["getsuppliercode"])
|
||||
{
|
||||
// We defined value code_fournisseur
|
||||
$_POST["code_fournisseur"]="aa";
|
||||
$_POST["code_fournisseur"]="Acompleter";
|
||||
}
|
||||
|
||||
// Add new third party
|
||||
@ -426,11 +426,13 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
$soc->commercial_id=$_POST["commercial_id"];
|
||||
$soc->default_lang=$_POST["default_lang"];
|
||||
|
||||
// We set pays_id, pays_code and libel the selected country
|
||||
// We set pays_id, pays_code and label for the selected country
|
||||
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
if ($soc->pays_id)
|
||||
{
|
||||
$sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id;
|
||||
$sql = "SELECT code, libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
|
||||
$sql.= " WHERE rowid = ".$soc->pays_id;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -551,20 +553,24 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
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',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':'');
|
||||
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)
|
||||
{
|
||||
@ -576,6 +582,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
}
|
||||
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>';
|
||||
|
||||
@ -947,28 +954,33 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
print '</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>'.$langs->trans('Country').'</td><td colspan="3">';
|
||||
$form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':'');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Department
|
||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
|
||||
$formcompany->select_departement($soc->departement_id,$soc->pays_code);
|
||||
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>';
|
||||
|
||||
// EMail / Web
|
||||
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>';
|
||||
|
||||
@ -1186,6 +1198,7 @@ else
|
||||
else print $soc->pays;
|
||||
print '</td></tr>';
|
||||
|
||||
// Department
|
||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$soc->departement.'</td>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id,'AC_TEL').'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user