Skip to content

Commit

Permalink
Qual: Uniformize code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 30, 2012
1 parent 2a90f17 commit 52b522e
Show file tree
Hide file tree
Showing 24 changed files with 106 additions and 255 deletions.
4 changes: 2 additions & 2 deletions htdocs/adherents/card_subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
$thirdparty=new Societe($db);
$thirdparty->fetch(GETPOST("socid"));
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->nom).'</div>';
$mesg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'</div>';
}
}

Expand Down Expand Up @@ -949,7 +949,7 @@
print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
print ' <em>('.$langs->trans("ChequeMaker").')</em>';
print '</td>';
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(empty($_POST['chqemetteur'])?$facture->client->nom:$_POST['chqemetteur']).'"></td></tr>';
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(empty($_POST['chqemetteur'])?$facture->client->name:$_POST['chqemetteur']).'"></td></tr>';

print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
print ' <em>('.$langs->trans("ChequeBank").')</em>';
Expand Down
6 changes: 3 additions & 3 deletions htdocs/adherents/cartes/carte.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
$arrayofmembers=array();

// requete en prenant que les adherents a jour de cotisation
$sql = "SELECT d.rowid, d.prenom, d.nom, d.login, d.societe, d.datefin,";
$sql = "SELECT d.rowid, d.prenom as firstname, d.nom as lastname, d.login, d.societe, d.datefin,";
$sql.= " d.adresse, d.cp, d.ville, d.naiss, d.email, d.photo,";
$sql.= " t.libelle as type,";
$sql.= " p.libelle as pays";
Expand All @@ -81,8 +81,8 @@

// List of values to scan for a replacement
$substitutionarray = array (
'%PRENOM%'=>$objp->prenom,
'%NOM%'=>$objp->nom,
'%PRENOM%'=>$objp->firstname,
'%NOM%'=>$objp->lastname,
'%LOGIN%'=>$objp->login,
'%SERVEUR%'=>"http://".$_SERVER["SERVER_NAME"]."/",
'%SOCIETE%'=>$objp->societe,
Expand Down
42 changes: 24 additions & 18 deletions htdocs/adherents/class/adherent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,10 @@ function update($user,$notrigger=0,$nosyncuser=0,$nosyncuserpass=0,$nosyncthirdp
if ($result >= 0)
{
$luser->civilite_id=$this->civilite_id;
$luser->prenom=$this->prenom;
$luser->nom=$this->nom;
$luser->firstname=$this->firstname;
$luser->lastname=$this->lastname;
$luser->prenom=$this->firstname; // deprecated
$luser->nom=$this->lastname; // deprecated
$luser->login=$this->user_login;
$luser->pass=$this->pass;
$luser->societe_id=$this->societe;
Expand Down Expand Up @@ -1000,19 +1002,19 @@ function fetch($rowid,$ref='',$fk_soc='')
$this->ref = $obj->rowid;
$this->id = $obj->rowid;
$this->civilite_id = $obj->civilite;
$this->prenom = $obj->firstname;
$this->prenom = $obj->firstname; // deprecated
$this->firstname = $obj->firstname;
$this->nom = $obj->lastname;
$this->nom = $obj->lastname; // deprecated
$this->lastname = $obj->lastname;
$this->login = $obj->login;
$this->pass = $obj->pass;
$this->societe = $obj->societe;
$this->fk_soc = $obj->fk_soc;
$this->adresse = $obj->address; // TODO deprecated
$this->adresse = $obj->address; // deprecated
$this->address = $obj->address;
$this->cp = $obj->zip; // TODO deprecated
$this->cp = $obj->zip; // deprecated
$this->zip = $obj->zip;
$this->ville = $obj->town; // TODO deprecated
$this->ville = $obj->town; // deprecated
$this->town = $obj->town;

$this->state_id = $obj->fk_departement;
Expand Down Expand Up @@ -1427,7 +1429,7 @@ function add_to_spip()
{
$mdpass=dol_hash($this->pass);
$htpass=crypt($this->pass,makesalt());
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->prenom." ".$this->nom."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->firstname." ".$this->lastname."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";

$mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT);

Expand Down Expand Up @@ -1683,12 +1685,16 @@ function del_to_mailman($listes='')
* @param Translate $langs Language object for translation of civility
* @param int $option 0=No option, 1=Add civility
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname
* @param int $maxlen Maximum length
* @return string String with full name
*/
function getFullName($langs,$option=0,$nameorder=-1)
function getFullName($langs,$option=0,$nameorder=-1,$maxlen=0)
{
global $conf;

if (empty($this->lastname)) $this->lastname=($this->name?$this->name:$this->nom);
if (empty($this->firstname)) $this->firstname=($this->firstname?$this->firstname:$this->prenom);

$ret='';
if ($option && $this->civilite_id)
{
Expand All @@ -1701,17 +1707,17 @@ function getFullName($langs,$option=0,$nameorder=-1)

if ($nameorder)
{
if ($this->prenom) $ret.=$this->prenom;
if ($this->prenom && $this->nom) $ret.=' ';
if ($this->nom) $ret.=$this->nom;
$ret.=$this->firstname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->lastname;
}
else
{
if ($this->nom) $ret.=$this->nom;
if ($this->prenom && $this->nom) $ret.=' ';
if ($this->prenom) $ret.=$this->prenom;
$ret.=$this->lastname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->firstname;
}
return trim($ret);
return dol_trunc($ret,$maxlen);
}


Expand Down Expand Up @@ -1983,8 +1989,8 @@ function initAsSpecimen()
$this->id=0;
$this->specimen=1;
$this->civilite_id = 0;
$this->nom = 'DOLIBARR';
$this->prenom = 'SPECIMEN';
$this->lastname = 'DOLIBARR';
$this->firstname = 'SPECIMEN';
$this->login='dolibspec';
$this->pass='dolibspec';
$this->societe = 'Societe ABC';
Expand Down
6 changes: 4 additions & 2 deletions htdocs/adherents/cotisations.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
if ($msg) print $msg.'<br>';

// Liste des cotisations
$sql = "SELECT d.rowid, d.login, d.prenom, d.nom, d.societe,";
$sql = "SELECT d.rowid, d.login, d.prenom as firstname, d.nom as lastname, d.societe,";
$sql.= " c.rowid as crowid, c.cotisation,";
$sql.= " c.dateadh,";
$sql.= " c.datef,";
Expand Down Expand Up @@ -123,7 +123,9 @@
$cotisation->ref=$objp->crowid;
$cotisation->id=$objp->crowid;

$adherent->ref=trim($objp->prenom.' '.$objp->nom);
$adherent->lastname=$objp->lastname;
$adherent->firstname=$objp->firstname;
$adherent->ref=$adherent->getFullName($langs);
$adherent->id=$objp->rowid;
$adherent->login=$objp->login;

Expand Down
4 changes: 2 additions & 2 deletions htdocs/adherents/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@
print '</tr>';

// Nom
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$member->nom.'&nbsp;</td>';
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$member->lastname.'&nbsp;</td>';
print '</tr>';

// Prenom
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$member->prenom.'&nbsp;</td>';
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$member->firstname.'&nbsp;</td>';
print '</tr>';

// Status
Expand Down
30 changes: 17 additions & 13 deletions htdocs/adherents/fiche.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
$thirdparty=new Societe($db);
$thirdparty->fetch($_POST["socid"]);
$error++;
$errmsg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->nom).'</div>';
$errmsg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'</div>';
}
}

Expand Down Expand Up @@ -223,8 +223,10 @@

// Change values
$object->civilite_id = trim($_POST["civilite_id"]);
$object->prenom = trim($_POST["prenom"]);
$object->nom = trim($_POST["nom"]);
$object->prenom = trim($_POST["prenom"]); // deprecated
$object->nom = trim($_POST["nom"]); // deprecated
$object->firstname = trim($_POST["prenom"]);
$object->lastname = trim($_POST["nom"]);
$object->login = trim($_POST["login"]);
$object->pass = trim($_POST["pass"]);

Expand Down Expand Up @@ -380,8 +382,10 @@
$socid=$_POST["socid"];

$object->civilite_id = $civilite_id;
$object->prenom = $prenom;
$object->nom = $nom;
$object->prenom = $prenom; // deprecated
$object->nom = $nom; // deprecated
$object->firstname = $prenom;
$object->lastname = $nom;
$object->societe = $societe;
$object->adresse = $address; // deprecated
$object->address = $address;
Expand Down Expand Up @@ -692,11 +696,11 @@
print '</tr>';

// Lastname
print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" value="'.(isset($_POST["nom"])?$_POST["nom"]:$object->nom).'" size="40"></td>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" value="'.(isset($_POST["nom"])?$_POST["nom"]:$object->lastname).'" size="40"></td>';
print '</tr>';

// Firstname
print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.(isset($_POST["prenom"])?$_POST["prenom"]:$object->prenom).'"></td>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.(isset($_POST["prenom"])?$_POST["prenom"]:$object->firstname).'"></td>';
print '</tr>';

// Password
Expand Down Expand Up @@ -923,11 +927,11 @@
print '</tr>';

// Name
print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" size="40" value="'.(isset($_POST["nom"])?$_POST["nom"]:$object->nom).'"></td>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" size="40" value="'.(isset($_POST["nom"])?$_POST["nom"]:$object->lastname).'"></td>';
print '</tr>';

// Firstname
print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.(isset($_POST["prenom"])?$_POST["prenom"]:$object->prenom).'"></td>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.(isset($_POST["prenom"])?$_POST["prenom"]:$object->firstname).'"></td>';
print '</tr>';

// Password
Expand Down Expand Up @@ -1074,9 +1078,9 @@
{
// Full firstname and name separated with a dot : firstname.name
include_once(DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php');
$login=dol_buildlogin($object->nom,$object->prenom);
$login=dol_buildlogin($object->lastname,$object->firstname);
}
if (empty($login)) $login=strtolower(substr($object->prenom, 0, 4)) . strtolower(substr($object->nom, 0, 4));
if (empty($login)) $login=strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4));

// Create a form array
$formquestion=array(
Expand Down Expand Up @@ -1246,11 +1250,11 @@
print '</tr>';

// Name
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$object->nom.'&nbsp;</td>';
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$object->lastname.'&nbsp;</td>';
print '</tr>';

// Firstname
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$object->prenom.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$object->firstname.'&nbsp;</td></tr>';

// Password
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
Expand Down
10 changes: 5 additions & 5 deletions htdocs/adherents/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
*/
$max=5;

$sql = "SELECT a.rowid, a.statut, a.nom, a.prenom,";
$sql = "SELECT a.rowid, a.statut, a.nom as lastname, a.prenom as firstname,";
$sql.= " a.tms as datem, datefin as date_end_subscription,";
$sql.= " ta.rowid as typeid, ta.libelle, ta.cotisation";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
Expand All @@ -229,8 +229,8 @@
$obj = $db->fetch_object($resql);
print "<tr ".$bc[$var].">";
$staticmember->id=$obj->rowid;
$staticmember->nom=$obj->nom;
$staticmember->prenom=$obj->prenom;
$staticmember->lastname=$obj->lastname;
$staticmember->firstname=$obj->firstname;
$staticmember->ref=$staticmember->getFullName($langs);
$statictype->id=$obj->typeid;
$statictype->libelle=$obj->libelle;
Expand Down Expand Up @@ -283,8 +283,8 @@
$subscriptionstatic->id=$obj->cid;
$subscriptionstatic->ref=$obj->cid;
$staticmember->id=$obj->rowid;
$staticmember->nom=$obj->nom;
$staticmember->prenom=$obj->prenom;
$staticmember->lastname=$obj->lastname;
$staticmember->firstname=$obj->firstname;
$staticmember->ref=$staticmember->getFullName($langs);
print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
print '<td>'.$staticmember->getNomUrl(1,24,'subscription').'</td>';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/adherents/ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@
print '</td></tr>';

// Nom
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$adh->nom.'&nbsp;</td>';
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$adh->lastname.'&nbsp;</td>';
print '</tr>';

// Prenom
print '<tr><td width="15%">'.$langs->trans("Firstname").'</td><td class="valeur">'.$adh->prenom.'&nbsp;</td>';
print '<tr><td width="15%">'.$langs->trans("Firstname").'</td><td class="valeur">'.$adh->firstname.'&nbsp;</td>';
print '</tr>';

// Login
Expand Down
6 changes: 3 additions & 3 deletions htdocs/adherents/liste.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

$now=dol_now();

$sql = "SELECT d.rowid, d.login, d.prenom, d.nom, d.societe, ";
$sql = "SELECT d.rowid, d.login, d.prenom as firstname, d.nom as name, d.societe, ";
$sql.= " d.datefin,";
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.cotisation";
Expand Down Expand Up @@ -258,8 +258,8 @@
// Nom
$var=!$var;
print "<tr ".$bc[$var].">";
$memberstatic->nom=$objp->nom;
$memberstatic->prenom=$objp->prenom;
$memberstatic->lastname=$objp->lastname;
$memberstatic->firstname=$objp->firstname;
if ($objp->societe != '')
{
print "<td><a href=\"fiche.php?rowid=$objp->rowid\">".img_object($langs->trans("ShowMember"),"user").' '.dol_trunc($memberstatic->getFullName($langs))." / ".dol_trunc($objp->societe,12)."</a></td>\n";
Expand Down
4 changes: 2 additions & 2 deletions htdocs/adherents/note.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@
print '</tr>';

// Lastname
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur" colspan="3">'.$adh->nom.'&nbsp;</td>';
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur" colspan="3">'.$adh->lastname.'&nbsp;</td>';
print '</tr>';

// Firstname
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur" colspan="3">'.$adh->prenom.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur" colspan="3">'.$adh->firstname.'&nbsp;</td></tr>';

// Status
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$adh->getLibStatut(4).'</td></tr>';
Expand Down
10 changes: 6 additions & 4 deletions htdocs/adherents/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@

$membertypestatic=new AdherentType($db);

$sql = "SELECT d.rowid, d.login, d.prenom, d.nom, d.societe, ";
$sql = "SELECT d.rowid, d.login, d.prenom as firstname, d.nom as lastname, d.societe, ";
$sql.= " d.datefin,";
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.cotisation";
Expand Down Expand Up @@ -486,17 +486,19 @@
$datefin=$db->jdate($objp->datefin);

$adh=new Adherent($db);
$adh->lastname=$objp->lastname;
$adh->firstname=$objp->firstname;

// Nom
$var=!$var;
print '<tr '.$bc[$var].'>';
if ($objp->societe != '')
{
print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$objp->prenom.' '.dol_trunc($objp->nom,12).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
}
else
{
print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$objp->prenom.' '.dol_trunc($objp->nom).'</a></td>'."\n";
print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
}

// Login
Expand Down Expand Up @@ -627,7 +629,7 @@
print "</td></tr>";

print '</table>';

print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; &nbsp;';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';

Expand Down
Loading

0 comments on commit 52b522e

Please sign in to comment.