New: Add option MAIN_FIRST_TO_UPPER

This commit is contained in:
Laurent Destailleur 2011-05-02 18:21:57 +00:00
parent 10b536603a
commit 703fddb94e
4 changed files with 65 additions and 50 deletions

View File

@ -5,6 +5,8 @@ $Id$
***** ChangeLog for 3.1 compared to 3.0 ***** ***** ChangeLog for 3.1 compared to 3.0 *****
For users: For users:
- New: Add option MAIN_FIRST_TO_UPPER to force upper case of first
letters for names and firstname.
- New: Can filter of payment type in bank transaction list. - New: Can filter of payment type in bank transaction list.
- New: Status is visible into user list. - New: Status is visible into user list.
- New: Support BSB code for bank account in australia. - New: Support BSB code for bank account in australia.

View File

@ -383,6 +383,10 @@ class Adherent extends CommonObject
dol_syslog("Adherent::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass.", email=".$this->email); dol_syslog("Adherent::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass.", email=".$this->email);
// Clean parameters
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->nom=ucwords(trim($this->nom));
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->prenom=ucwords(trim($this->prenom));
// Check parameters // Check parameters
if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
{ {

View File

@ -109,6 +109,9 @@ class Contact extends CommonObject
// Clean parameters // Clean parameters
$this->name=trim($this->name); $this->name=trim($this->name);
$this->firstname=trim($this->firstname);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname);
if (! $this->socid) $this->socid = 0; if (! $this->socid) $this->socid = 0;
if (! $this->priv) $this->priv = 0; if (! $this->priv) $this->priv = 0;
@ -116,6 +119,7 @@ class Contact extends CommonObject
$sql.= " datec"; $sql.= " datec";
$sql.= ", fk_soc"; $sql.= ", fk_soc";
$sql.= ", name"; $sql.= ", name";
$sql.= ", firstname";
$sql.= ", fk_user_creat"; $sql.= ", fk_user_creat";
$sql.= ", priv"; $sql.= ", priv";
$sql.= ", canvas"; $sql.= ", canvas";
@ -125,6 +129,7 @@ class Contact extends CommonObject
if ($this->socid > 0) $sql.= " ".$this->socid.","; if ($this->socid > 0) $sql.= " ".$this->socid.",";
else $sql.= "null,"; else $sql.= "null,";
$sql.= "'".$this->db->escape($this->name)."',"; $sql.= "'".$this->db->escape($this->name)."',";
$sql.= "'".$this->db->escape($this->firstname)."',";
$sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").","; $sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").",";
$sql.= " ".$this->priv.","; $sql.= " ".$this->priv.",";
$sql.= " ".($this->canvas?"'".$this->canvas."'":"null").","; $sql.= " ".($this->canvas?"'".$this->canvas."'":"null").",";

View File

@ -170,8 +170,9 @@ class Societe extends CommonObject
global $langs,$conf; global $langs,$conf;
// Clean parameters // Clean parameters
$this->name=trim($this->name); $this->name=$this->name?trim($this->name):trim($this->nom);
$this->nom=trim($this->nom); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name);
$this->nom=$this->name; // For backward compatibility
dol_syslog("Societe::create ".$this->name); dol_syslog("Societe::create ".$this->name);
@ -199,7 +200,7 @@ class Societe extends CommonObject
if ($result >= 0) if ($result >= 0)
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, datea, fk_user_creat, canvas)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, datea, fk_user_creat, canvas)";
$sql.= " VALUES ('".$this->db->escape($this->nom)."', ".$conf->entity.", '".$this->db->idate($now)."', '".$this->db->idate($now)."'"; $sql.= " VALUES ('".$this->db->escape($this->name)."', ".$conf->entity.", '".$this->db->idate($now)."', '".$this->db->idate($now)."'";
$sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null");
$sql.= ", ".($this->canvas ? "'".$this->canvas."'":"null"); $sql.= ", ".($this->canvas ? "'".$this->canvas."'":"null");
$sql.= ")"; $sql.= ")";
@ -253,7 +254,7 @@ class Societe extends CommonObject
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->nom); $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);
} }
else else
{ {
@ -282,10 +283,10 @@ class Societe extends CommonObject
$this->errors=array(); $this->errors=array();
$result = 0; $result = 0;
$this->name=trim($this->name); $this->name=$this->name?trim($this->name):trim($this->nom);
$this->nom=trim($this->nom); $this->nom=$this->name; // For backward compatibility
if (! $this->nom) if (! $this->name)
{ {
$this->errors[] = 'ErrorBadThirdPartyName'; $this->errors[] = 'ErrorBadThirdPartyName';
$result = -2; $result = -2;
@ -365,14 +366,18 @@ class Societe extends CommonObject
dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
$now=dol_now();
// Clean parameters // Clean parameters
$this->id=$id; $this->id=$id;
$this->name=$this->name?trim($this->name):trim($this->nom);
$this->nom=trim($this->nom); // TODO obsolete $this->nom=trim($this->nom); // TODO obsolete
$this->name=trim($this->name); $this->address=$this->address?trim($this->address):trim($this->adresse);
$this->adresse=trim($this->adresse); // TODO obsolete $this->adresse=$this->address; // TODO obsolete
$this->address=trim($this->address); $this->zip=$this->zip?trim($this->zip):trim($this->cp);
$this->cp=trim($this->cp); $this->cp=$this->zip; // TODO obsolete
$this->ville=trim($this->ville); $this->town=$this->town?trim($this->town):trim($this->ville);
$this->ville=$this->town; // TODO obsolete
$this->departement_id=trim($this->departement_id); $this->departement_id=trim($this->departement_id);
$this->pays_id=trim($this->pays_id); $this->pays_id=trim($this->pays_id);
$this->tel=trim($this->tel); $this->tel=trim($this->tel);
@ -429,12 +434,12 @@ class Societe extends CommonObject
dol_syslog("Societe::Update verify ok"); dol_syslog("Societe::Update verify ok");
$sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql.= " SET nom = '" . $this->db->escape($this->nom) ."'"; // Champ obligatoire $sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
$sql.= ",datea = '".$this->db->idate(mktime())."'"; $sql.= ",datea = '".$this->db->idate($now)."'";
$sql.= ",address = '" . $this->db->escape($this->address) ."'"; $sql.= ",address = '" . $this->db->escape($this->address) ."'";
$sql.= ",cp = ".($this->cp?"'".$this->cp."'":"null"); $sql.= ",cp = ".($this->zip?"'".$this->zip."'":"null");
$sql.= ",ville = ".($this->ville?"'".$this->db->escape($this->ville)."'":"null"); $sql.= ",ville = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
$sql .= ",fk_departement = '" . ($this->departement_id?$this->departement_id:'0') ."'"; $sql .= ",fk_departement = '" . ($this->departement_id?$this->departement_id:'0') ."'";
$sql .= ",fk_pays = '" . ($this->pays_id?$this->pays_id:'0') ."'"; $sql .= ",fk_pays = '" . ($this->pays_id?$this->pays_id:'0') ."'";
@ -611,19 +616,19 @@ class Societe extends CommonObject
$this->entity = $obj->entity; $this->entity = $obj->entity;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->nom = $obj->name; // TODO obsolete
$this->name = $obj->name; $this->name = $obj->name;
$this->nom = $obj->name; // TODO obsolete
$this->ref_ext = $obj->ref_ext; $this->ref_ext = $obj->ref_ext;
$this->datec = $this->db->jdate($obj->datec); $this->datec = $this->db->jdate($obj->datec);
$this->date_update = $this->db->jdate($obj->date_update); $this->date_update = $this->db->jdate($obj->date_update);
$this->adresse = $obj->address; // TODO obsolete
$this->address = $obj->address; $this->address = $obj->address;
$this->cp = $obj->zip; // TODO obsolete $this->adresse = $obj->address; // TODO obsolete
$this->zip = $obj->zip; $this->zip = $obj->zip;
$this->ville = $obj->town;// TODO obsolete $this->cp = $obj->zip; // TODO obsolete
$this->town = $obj->town; $this->town = $obj->town;
$this->ville = $obj->town;// TODO obsolete
$this->pays_id = $obj->fk_pays; // TODO obsolete $this->pays_id = $obj->fk_pays; // TODO obsolete
$this->country_id = $obj->fk_pays; $this->country_id = $obj->fk_pays;
@ -977,21 +982,20 @@ class Societe extends CommonObject
} }
/** /**
* \brief Attribut le prefix de la societe en base * Update record to set prefix
*
*/ */
function attribute_prefix() function attribute_prefix()
{ {
global $conf; global $conf;
$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."societe WHERE rowid = '".$this->id."'"; $sql = "SELECT nom as name FROM ".MAIN_DB_PREFIX."societe WHERE rowid = '".$this->id."'";
$resql=$this->db->query( $sql); $resql=$this->db->query( $sql);
if ($resql) if ($resql)
{ {
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql))
{ {
$obj=$this->db->fetch_object($resql); $obj=$this->db->fetch_object($resql);
$nom = preg_replace("/[[:punct:]]/","",$obj->nom); $nom = preg_replace("/[[:punct:]]/","",$obj->name);
$this->db->free(); $this->db->free();
$prefix = $this->genprefix($nom,4); $prefix = $this->genprefix($nom,4);
@ -1385,8 +1389,7 @@ class Societe extends CommonObject
$lien.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'">'; $lien.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'">';
$lienfin='</a>'; $lienfin='</a>';
$name=$this->name; $name=$this->name?$this->name:$this->nom;
if (empty($name)) $name=$this->nom;
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name,'company').$lienfin); if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name,'company').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';
@ -1434,7 +1437,7 @@ class Societe extends CommonObject
{ {
if (empty($this->name)) $this->name=$this->nom; if (empty($this->name)) $this->name=$this->nom;
// TODO: Tester si email non deja present dans tableau contact // TODO: Tester si email non deja present dans tableau contact
$contact_email[-1]=$langs->trans("ThirdParty").': '.dol_trunc($this->nom,16)." &lt;".$this->email."&gt;"; $contact_email[-1]=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." &lt;".$this->email."&gt;";
} }
return $contact_email; return $contact_email;
} }
@ -1452,7 +1455,7 @@ class Societe extends CommonObject
{ {
if (empty($this->name)) $this->name=$this->nom; if (empty($this->name)) $this->name=$this->nom;
// TODO: Tester si tel non deja present dans tableau contact // TODO: Tester si tel non deja present dans tableau contact
$contact_phone[-1]=$langs->trans("ThirdParty").': '.dol_trunc($this->nom,16)." &lt;".$this->tel."&gt;"; $contact_phone[-1]=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." &lt;".$this->tel."&gt;";
} }
return $contact_phone; return $contact_phone;
} }
@ -2027,7 +2030,7 @@ class Societe extends CommonObject
*/ */
function info($id) function info($id)
{ {
$sql = "SELECT s.rowid, s.nom, s.datec, s.datea,"; $sql = "SELECT s.rowid, s.nom as name, s.datec, s.datea,";
$sql.= " fk_user_creat, fk_user_modif"; $sql.= " fk_user_creat, fk_user_modif";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.rowid = ".$id; $sql.= " WHERE s.rowid = ".$id;
@ -2052,7 +2055,7 @@ class Societe extends CommonObject
$muser->fetch($obj->fk_user_modif); $muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser; $this->user_modification = $muser;
} }
$this->ref = $obj->nom; $this->ref = $obj->name;
$this->date_creation = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datea); $this->date_modification = $this->db->jdate($obj->datea);
} }
@ -2202,17 +2205,17 @@ class Societe extends CommonObject
/** /**
* Cree en base un tiers depuis l'objet adherent * Create a third party into database from a member object
* @param member Objet adherent source * @param member Object member
* @param socname Name of third to force * @param socname Name of third party to force
* @return int Si erreur <0, si ok renvoie id compte cree * @return int <0 if KO, id of created account if OK
*/ */
function create_from_member($member,$socname='') function create_from_member($member,$socname='')
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
$name = !empty($socname)?$socname:$member->societe; $name = $socname?$socname:$member->societe;
if (empty($name)) $name=trim($member->nom.' '.$member->prenom); if (empty($name)) $name=$member->getFullName($langs);
// Positionne parametres // Positionne parametres
$this->nom=$name; // TODO obsolete $this->nom=$name; // TODO obsolete
@ -2283,7 +2286,8 @@ class Societe extends CommonObject
// Initialize parameters // Initialize parameters
$this->id=0; $this->id=0;
$this->nom = 'THIRDPARTY SPECIMEN '.dol_print_date($now,'dayhourlog'); $this->name = 'THIRDPARTY SPECIMEN '.dol_print_date($now,'dayhourlog');
$this->nom = $this->name; // For backward compatibility
$this->specimen=1; $this->specimen=1;
$this->cp='99999'; $this->cp='99999';
$this->ville='MyTown'; $this->ville='MyTown';