Mutualize common code

This commit is contained in:
Laurent Destailleur 2012-02-01 13:21:39 +01:00
parent 392d8a26a5
commit b1e58dd454
7 changed files with 197 additions and 289 deletions

View File

@ -1679,48 +1679,6 @@ class Adherent extends CommonObject
} }
} }
/**
* Return full name (civility+' '+name+' '+lastname)
*
* @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,$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)
{
if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' ';
else $ret.=$this->civilite_id.' ';
}
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION);
if ($nameorder)
{
$ret.=$this->firstname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->lastname;
}
else
{
$ret.=$this->lastname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->firstname;
}
return dol_trunc($ret,$maxlen);
}
/** /**
* Return label of a civility of a contact * Return label of a civility of a contact
* *

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2009-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -52,18 +52,18 @@ $action=GETPOST('action');
if ($action == 'update' && empty($_POST["cancel"])) if ($action == 'update' && empty($_POST["cancel"]))
{ {
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", $_POST["MAIN_DISABLE_ALL_MAILS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity);
// Send mode parameters
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", $_POST["MAIN_MAIL_SENDMODE"],'chaine',0,'',0); dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',0);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", $_POST["MAIN_MAIL_SMTP_PORT"],'chaine',0,'',0); if (isset($_POST["MAIN_MAIL_SMTP_PORT"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',0);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", $_POST["MAIN_MAIL_SMTP_SERVER"],'chaine',0,'',0); if (isset($_POST["MAIN_MAIL_SMTP_SERVER"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_SMTPS_ID"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", $_POST["MAIN_MAIL_SMTPS_ID"],'chaine',0,'',0); if (isset($_POST["MAIN_MAIL_SMTPS_ID"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_SMTPS_PW"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", $_POST["MAIN_MAIL_SMTPS_PW"],'chaine',0,'',0); if (isset($_POST["MAIN_MAIL_SMTPS_PW"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_EMAIL_TLS"])) dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", $_POST["MAIN_MAIL_EMAIL_TLS"],'chaine',0,'',0); if (isset($_POST["MAIN_MAIL_EMAIL_TLS"])) dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',0);
// Content parameters
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", $_POST["MAIN_MAIL_EMAIL_FROM"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", $_POST["MAIN_MAIL_ERRORS_TO"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity);
Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit; exit;
@ -351,7 +351,7 @@ if ($action == 'edit')
// Server // Server
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
if (! $conf->use_javascript_ajax && $linuxlike && ($conf->global->MAIN_MAIL_SENDMODE == 'mail' || $conf->global->MAIN_MAIL_SENDMODE == 'simplemail')) if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
{ {
print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
print '</td><td>'; print '</td><td>';
@ -367,6 +367,7 @@ if ($action == 'edit')
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
{ {
print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" size="18" value="' . $conf->global->MAIN_MAIL_SMTP_SERVER . '">'; print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" size="18" value="' . $conf->global->MAIN_MAIL_SMTP_SERVER . '">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="' . $conf->global->MAIN_MAIL_SMTP_SERVER . '">';
} }
else else
{ {
@ -381,7 +382,7 @@ if ($action == 'edit')
// Port // Port
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
if (! $conf->use_javascript_ajax && $linuxlike && ($conf->global->MAIN_MAIL_SENDMODE == 'mail' || $conf->global->MAIN_MAIL_SENDMODE == 'simplemail')) if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
{ {
print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
print '</td><td>'; print '</td><td>';
@ -397,6 +398,7 @@ if ($action == 'edit')
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
{ {
print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="' . $conf->global->MAIN_MAIL_SMTP_PORT . '">'; print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="' . $conf->global->MAIN_MAIL_SMTP_PORT . '">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="' . $conf->global->MAIN_MAIL_SMTP_PORT . '">';
} }
else else
{ {
@ -517,7 +519,7 @@ else
// Server // Server
$var=!$var; $var=!$var;
if ($linuxlike && ($conf->global->MAIN_MAIL_SENDMODE == 'mail' || $conf->global->MAIN_MAIL_SENDMODE == 'simplemail')) if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
{ {
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
} }
@ -528,7 +530,7 @@ else
// Port // Port
$var=!$var; $var=!$var;
if ($linuxlike && ($conf->global->MAIN_MAIL_SENDMODE == 'mail' || $conf->global->MAIN_MAIL_SENDMODE == 'simplemail')) if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
{ {
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
} }

View File

@ -686,42 +686,5 @@ class Don extends CommonObject
return $result; return $result;
} }
/**
* Return full name (civility+' '+name+' '+lastname)
*
* @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
* @return string String with full name
*/
function getFullName($langs,$option=0,$nameorder=-1)
{
global $conf;
$ret='';
if ($option && $this->civilite_id)
{
if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' ';
else $ret.=$this->civilite_id.' ';
}
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION);
if ($nameorder)
{
if ($this->prenom) $ret.=$this->prenom;
if ($this->prenom && $this->nom) $ret.=' ';
if ($this->nom) $ret.=$this->nom;
}
else
{
if ($this->nom) $ret.=$this->nom;
if ($this->prenom && $this->nom) $ret.=' ';
if ($this->prenom) $ret.=$this->prenom;
}
return trim($ret);
}
} }
?> ?>

View File

@ -900,48 +900,6 @@ class Contact extends CommonObject
return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : ''; return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : '';
} }
/**
* Return full name (civility+' '+name+' '+lastname)
*
* @param Translate $langs Language object for translation of civility
* @param string $option 0=No option, 1=Add civility
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname
* @return string String with full name
*/
function getFullName($langs,$option=0,$nameorder=-1)
{
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)
{
if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' ';
else $ret.=$this->civilite_id.' ';
}
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION);
if ($nameorder)
{
$ret.=$this->firstname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->lastname;
}
else
{
$ret.=$this->lastname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->firstname;
}
return trim($ret);
}
/** /**
* Retourne le libelle du statut du contact * Retourne le libelle du statut du contact
* *

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
@ -8,12 +8,12 @@
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -26,10 +26,8 @@
/** /**
* \class CommonObject * Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
* \brief Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
*/ */
abstract class CommonObject abstract class CommonObject
{ {
protected $db; protected $db;
@ -41,6 +39,49 @@ abstract class CommonObject
// No constructor as it is an abstract class // No constructor as it is an abstract class
/**
* Return full name (civility+' '+name+' '+lastname)
*
* @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,$maxlen=0)
{
global $conf;
$lastname=$this->lastname;
$firstname=$this->firstname;
if (empty($lastname)) $lastname=($this->name?$this->name:$this->nom);
if (empty($firstname)) $firstname=$this->prenom;
$ret='';
if ($option && $this->civilite_id)
{
if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' ';
else $ret.=$this->civilite_id.' ';
}
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION);
if ($nameorder)
{
$ret.=$firstname;
if ($firstname && $lastname) $ret.=' ';
$ret.=$lastname;
}
else
{
$ret.=$lastname;
if ($firstname && $lastname) $ret.=' ';
$ret.=$firstname;
}
return dol_trunc($ret,$maxlen);
}
/** /**
* Check if ref is used. * Check if ref is used.
* *
@ -72,11 +113,11 @@ abstract class CommonObject
/** /**
* Add a link between element $this->element and a contact * Add a link between element $this->element and a contact
* *
* @param fk_socpeople Id of contact to link * @param int $fk_socpeople Id of contact to link
* @param type_contact Type of contact (code or id) * @param int $type_contact Type of contact (code or id)
* @param source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) * @param int $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
* @param notrigger Disable all triggers * @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger=0) function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger=0)
{ {
@ -168,10 +209,10 @@ abstract class CommonObject
/** /**
* Update a link to contact line * Update a link to contact line
* *
* @param rowid Id of line contact-element * @param int $rowid Id of line contact-element
* @param statut New status of link * @param int $statut New status of link
* @param type_contact_id Id of contact type (not modified if 0) * @param int $type_contact_id Id of contact type (not modified if 0)
* @return int <0 if KO, >= 0 if OK * @return int <0 if KO, >= 0 if OK
*/ */
function update_contact($rowid, $statut, $type_contact_id=0) function update_contact($rowid, $statut, $type_contact_id=0)
{ {
@ -195,9 +236,9 @@ abstract class CommonObject
/** /**
* Delete a link to contact line * Delete a link to contact line
* *
* @param rowid Id of contact link line to delete * @param int $rowid Id of contact link line to delete
* @param notrigger Disable all triggers * @param int $notrigger Disable all triggers
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function delete_contact($rowid, $notrigger=0) function delete_contact($rowid, $notrigger=0)
{ {
@ -269,10 +310,10 @@ abstract class CommonObject
/** /**
* Get array of all contacts for an object * Get array of all contacts for an object
* *
* @param int $statut Status of lines to get (-1=all) * @param int $statut Status of lines to get (-1=all)
* @param string $source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) * @param string $source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user)
* @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param int $list 0:Return array contains all properties, 1:Return array contains just id
* @return array Array of contacts * @return array Array of contacts
*/ */
function liste_contact($statut=-1,$source='external',$list=0) function liste_contact($statut=-1,$source='external',$list=0)
{ {
@ -339,8 +380,8 @@ abstract class CommonObject
/** /**
* Update status of a contact linked to object * Update status of a contact linked to object
* *
* @param $rowid Id of link between object and contact * @param int $rowid Id of link between object and contact
* @return int <0 if KO, >=0 if OK * @return int <0 if KO, >=0 if OK
*/ */
function swapContactStatus($rowid) function swapContactStatus($rowid)
{ {
@ -375,10 +416,10 @@ abstract class CommonObject
/** /**
* Return array with list of possible values for type of contacts * Return array with list of possible values for type of contacts
* *
* @param source internal, external or all if not defined * @param string $source 'internal', 'external' or 'all'
* @param order Sort order by : code or rowid * @param string $order Sort order by : 'code' or 'rowid'
* @param option 0=Return array id->label, 1=Return array code->label * @param string $option 0=Return array id->label, 1=Return array code->label
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1) * @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
*/ */
function liste_type_contact($source='internal', $order='code', $option=0) function liste_type_contact($source='internal', $order='code', $option=0)
{ {
@ -423,10 +464,10 @@ abstract class CommonObject
* Example: contact client de livraison ('external', 'SHIPPING') * Example: contact client de livraison ('external', 'SHIPPING')
* Example: contact interne suivi paiement ('internal', 'SALESREPFOLL') * Example: contact interne suivi paiement ('internal', 'SALESREPFOLL')
* *
* @param source 'external' or 'internal' * @param string $source 'external' or 'internal'
* @param code 'BILLING', 'SHIPPING', 'SALESREPFOLL', ... * @param string $code 'BILLING', 'SHIPPING', 'SALESREPFOLL', ...
* @param status limited to a certain status * @param int $status limited to a certain status
* @return array List of id for such contacts * @return array List of id for such contacts
*/ */
function getIdContact($source,$code,$status=0) function getIdContact($source,$code,$status=0)
{ {
@ -473,8 +514,8 @@ abstract class CommonObject
/** /**
* Charge le contact d'id $id dans this->contact * Charge le contact d'id $id dans this->contact
* *
* @param contactid Id du contact * @param int $contactid Id du contact
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_contact($contactid) function fetch_contact($contactid)
{ {
@ -488,7 +529,7 @@ abstract class CommonObject
/** /**
* Load the third party of object from id $this->socid into this->thirdpary * Load the third party of object from id $this->socid into this->thirdpary
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_thirdparty() function fetch_thirdparty()
{ {
@ -577,8 +618,8 @@ abstract class CommonObject
/** /**
* Charge le user d'id userid dans this->user * Charge le user d'id userid dans this->user
* *
* @param userid Id du contact * @param int $userid Id du contact
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_user($userid) function fetch_user($userid)
{ {
@ -589,7 +630,9 @@ abstract class CommonObject
} }
/** /**
* Read linked origin object * Read linked origin object
*
* @return void
*/ */
function fetch_origin() function fetch_origin()
{ {
@ -607,10 +650,10 @@ abstract class CommonObject
/** /**
* Load object from specific field * Load object from specific field
* *
* @param table Table element or element line * @param string $table Table element or element line
* @param field Field selected * @param string $field Field selected
* @param key Import key * @param string $key Import key
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetchObjectFrom($table,$field,$key) function fetchObjectFrom($table,$field,$key)
{ {
@ -698,11 +741,11 @@ abstract class CommonObject
/** /**
* Load properties id_previous and id_next * Load properties id_previous and id_next
* *
* @param filter Optional filter * @param string $filter Optional filter
* @param fieldid Name of field to use for the select MAX and MIN * @param int $fieldid Name of field to use for the select MAX and MIN
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function load_previous_next_ref($filter='',$fieldid) function load_previous_next_ref($filter,$fieldid)
{ {
global $conf, $user; global $conf, $user;
@ -766,9 +809,9 @@ abstract class CommonObject
/** /**
* Return list of id of contacts of project * Return list of id of contacts of project
* *
* @param source Source of contact: external (llx_socpeople) or internal (llx_user) or thirdparty (llx_societe) * @param string $source Source of contact: external (llx_socpeople) or internal (llx_user) or thirdparty (llx_societe)
* @return array Array of id of contacts (if source=external or internal) * @return array Array of id of contacts (if source=external or internal)
* Array of id of third parties with at least one contact on project (if source=thirdparty) * Array of id of third parties with at least one contact on project (if source=thirdparty)
*/ */
function getListContactId($source='external') function getListContactId($source='external')
{ {
@ -822,9 +865,9 @@ abstract class CommonObject
/** /**
* Set last model used by doc generator * Set last model used by doc generator
* *
* @param user User object that make change * @param User $user User object that make change
* @param modelpdf Modele name * @param string $modelpdf Modele name
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setDocModel($user, $modelpdf) function setDocModel($user, $modelpdf)
{ {
@ -862,6 +905,7 @@ abstract class CommonObject
* *
* @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines. * @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines.
* @param string $rowidorder ASC or DESC * @param string $rowidorder ASC or DESC
* @return void
*/ */
function line_order($renum=false, $rowidorder='ASC') function line_order($renum=false, $rowidorder='ASC')
{ {
@ -891,7 +935,7 @@ abstract class CommonObject
if ($nl > 0) if ($nl > 0)
{ {
$rows=array(); $rows=array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql.= ' AND fk_parent_line IS NULL'; $sql.= ' AND fk_parent_line IS NULL';
@ -928,21 +972,22 @@ abstract class CommonObject
} }
} }
} }
/** /**
* Get childrens of line * Get childrens of line
* *
* @param int $id Id of parent line * @param int $id Id of parent line
* @return array Array with list of child lines id
*/ */
function getChildrensOfLine($id) function getChildrensOfLine($id)
{ {
$rows=array(); $rows=array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql.= ' AND fk_parent_line = '.$id; $sql.= ' AND fk_parent_line = '.$id;
$sql.= ' ORDER BY rang ASC'; $sql.= ' ORDER BY rang ASC';
dol_syslog(get_class($this)."::getChildrenOfLines sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::getChildrenOfLines sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -956,14 +1001,15 @@ abstract class CommonObject
$i++; $i++;
} }
} }
return $rows; return $rows;
} }
/** /**
* Update a line to have a lower rank * Update a line to have a lower rank
* *
* @param int $rowid * @param int $rowid Id of line
* @return void
*/ */
function line_up($rowid) function line_up($rowid)
{ {
@ -979,7 +1025,8 @@ abstract class CommonObject
/** /**
* Update a line to have a higher rank * Update a line to have a higher rank
* *
* @param int $rowid * @param int $rowid Id of line
* @return void
*/ */
function line_down($rowid) function line_down($rowid)
{ {
@ -998,8 +1045,9 @@ abstract class CommonObject
/** /**
* Update position of line (rang) * Update position of line (rang)
* *
* @param int $rowid * @param int $rowid Id of line
* @param int $rang * @param int $rang Position
* @return void
*/ */
function updateRangOfLine($rowid,$rang) function updateRangOfLine($rowid,$rang)
{ {
@ -1017,6 +1065,7 @@ abstract class CommonObject
* Update position of line with ajax (rang) * Update position of line with ajax (rang)
* *
* @param array $rows Array of rows * @param array $rows Array of rows
* @return void
*/ */
function line_ajaxorder($rows) function line_ajaxorder($rows)
{ {
@ -1030,8 +1079,9 @@ abstract class CommonObject
/** /**
* Update position of line up (rang) * Update position of line up (rang)
* *
* @param int $rowid * @param int $rowid Id of line
* @param int $rang * @param int $rang Position
* @return void
*/ */
function updateLineUp($rowid,$rang) function updateLineUp($rowid,$rang)
{ {
@ -1059,9 +1109,10 @@ abstract class CommonObject
/** /**
* Update position of line down (rang) * Update position of line down (rang)
* *
* @param int $rowid * @param int $rowid Id of line
* @param int $rang * @param int $rang Position
* @param int $max * @param int $max Max
* @return void
*/ */
function updateLineDown($rowid,$rang,$max) function updateLineDown($rowid,$rang,$max)
{ {
@ -1582,10 +1633,10 @@ abstract class CommonObject
/** /**
* Set statut of an object * Set statut of an object
* *
* @param statut Statut to set * @param int $statut Statut to set
* @param elementId Id of element to force (use this->id by default) * @param int $elementId Id of element to force (use this->id by default)
* @param elementType Type of element to force (use ->this->element by default) * @param string $elementType Type of element to force (use ->this->element by default)
* @return int <0 if ko, >0 if ok * @return int <0 if KO, >0 if OK
*/ */
function setStatut($statut,$elementId='',$elementType='') function setStatut($statut,$elementId='',$elementType='')
{ {
@ -1655,7 +1706,8 @@ abstract class CommonObject
/** /**
* Get special code of line * Get special code of line
* *
* @param lineid Id of line * @param int $lineid Id of line
* @return int Special code
*/ */
function getSpecialCode($lineid) function getSpecialCode($lineid)
{ {
@ -1673,8 +1725,9 @@ abstract class CommonObject
/** /**
* Function to get extra fields of a member into $this->array_options * Function to get extra fields of a member into $this->array_options
* *
* @param rowid * @param int $rowid Id of line
* @param optionsArray Array resulting of call of extrafields->fetch_name_optionals_label() * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label()
* @return void
*/ */
function fetch_optionals($rowid,$optionsArray='') function fetch_optionals($rowid,$optionsArray='')
{ {
@ -1725,7 +1778,9 @@ abstract class CommonObject
/** /**
* Add/Update extra fields * Add/Update extra fields
*
* @return void
*/ */
function insertExtraFields() function insertExtraFields()
{ {
@ -1858,10 +1913,11 @@ abstract class CommonObject
/** /**
* List urls of elemùent * List urls of elemùent
* *
* @param unknown_type $objectid * @param int $objectid Id of record
* @param unknown_type $objecttype * @param string $objecttype Type of object
* @param unknown_type $withpicto * @param int $withpicto Picto to show
* @param unknown_type $option * @param string $option More options
* @return void
*/ */
function getElementUrl($objectid,$objecttype,$withpicto=0,$option='') function getElementUrl($objectid,$objecttype,$withpicto=0,$option='')
{ {
@ -1932,6 +1988,8 @@ abstract class CommonObject
* Show linked object block * Show linked object block
* TODO Move this into html.class.php * TODO Move this into html.class.php
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
* @return void
*/ */
function showLinkedObjectBlock() function showLinkedObjectBlock()
{ {
@ -1990,10 +2048,11 @@ abstract class CommonObject
* TODO Edit templates to use global variables and include them directly in controller call * TODO Edit templates to use global variables and include them directly in controller call
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* *
* @param int $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object thirdparty who sell * @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy * @param Societe $buyer Object thirdparty who buy
* @param HookManager $hookmanager Hook manager instance * @param HookManager $hookmanager Hook manager instance
* @return void
*/ */
function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false) function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false)
{ {
@ -2009,10 +2068,11 @@ abstract class CommonObject
* TODO Edit templates to use global variables and include them directly in controller call * TODO Edit templates to use global variables and include them directly in controller call
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
* *
* @param int $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object thirdparty who sell * @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy * @param Societe $buyer Object thirdparty who buy
* @param HookManager $hookmanager Hook manager instance * @param HookManager $hookmanager Hook manager instance
* @return void
*/ */
function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false)
{ {
@ -2034,13 +2094,15 @@ abstract class CommonObject
* If lines are into a template, title must also be into a template * If lines are into a template, title must also be into a template
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
* *
* @param $action Action code * @param string $action Action code
* @param $seller Object of seller third party * @param string $seller Object of seller third party
* @param $buyer Object of buyer third party * @param string $buyer Object of buyer third party
* @param $selected Object line selected * @param string $selected Object line selected
* @param $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param HookManager $hookmanager Hookmanager
* @return void
*/ */
function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager=false) function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager=false)
{ {
global $conf,$langs; global $conf,$langs;
@ -2112,17 +2174,19 @@ abstract class CommonObject
* If lines are into a template, title must also be into a template * If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* *
* @param $action GET/POST action * @param string $action GET/POST action
* @param $line Selected object line to output * @param array $line Selected object line to output
* @param $var Is it a an odd line * @param string $var Is it a an odd line
* @param $num Number of line * @param int $num Number of line
* @param $i * @param int $i I
* @param $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param $seller Object of seller third party * @param string $seller Object of seller third party
* @param $buyer Object of buyer third party * @param string $buyer Object of buyer third party
* @param $selected Object line selected * @param string $selected Object line selected
* @param HookManager $hookmanager Hook manager
* @return void
*/ */
function printLine($action='viewline',$line,$var=true,$num=0,$i=0,$dateSelector=0,$seller,$buyer,$selected=0,$hookmanager=false) function printLine($action,$line,$var=true,$num=0,$i=0,$dateSelector=0,$seller,$buyer,$selected=0,$hookmanager=false)
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
global $form,$bc,$bcdd; global $form,$bc,$bcdd;
@ -2150,7 +2214,7 @@ abstract class CommonObject
{ {
$this->fetch_thirdparty(); $this->fetch_thirdparty();
$prod = new Product($this->db, $line->fk_product); $prod = new Product($this->db, $line->fk_product);
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
@ -2160,13 +2224,13 @@ abstract class CommonObject
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $line->product_label; $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $line->product_label;
} }
else { else {
$label = $line->product_label; $label = $line->product_label;
} }
$product_static->type=$line->fk_product_type; $product_static->type=$line->fk_product_type;
$product_static->id=$line->fk_product; $product_static->id=$line->fk_product;
$product_static->ref=$line->ref; $product_static->ref=$line->ref;
@ -2211,6 +2275,9 @@ abstract class CommonObject
* TODO Move this and previous function into output html class file (htmlline.class.php). * TODO Move this and previous function into output html class file (htmlline.class.php).
* If lines are into a template, title must also be into a template * If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
* @param HookManager $hookmanager Hook manager
* @return void
*/ */
function printOriginLinesList($hookmanager=false) function printOriginLinesList($hookmanager=false)
{ {
@ -2255,8 +2322,10 @@ abstract class CommonObject
* TODO Move this and previous function into output html class file (htmlline.class.php). * TODO Move this and previous function into output html class file (htmlline.class.php).
* If lines are into a template, title must also be into a template * If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* @param line *
* @param var * @param array $line Line
* @param string $var Var
* @return void
*/ */
function printOriginLine($line,$var) function printOriginLine($line,$var)
{ {

View File

@ -1705,48 +1705,6 @@ class User extends CommonObject
return $result; return $result;
} }
/**
* Return full name (civility+' '+name+' '+lastname)
*
* @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
* @return string String with full name
*/
function getFullName($langs,$option=0,$nameorder=-1)
{
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)
{
if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' ';
else $ret.=$this->civilite_id.' ';
}
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?1:0;
if ($nameorder)
{
$ret.=$this->firstname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->lastname;
}
else
{
$ret.=$this->lastname;
if ($this->firstname && $this->lastname) $ret.=' ';
$ret.=$this->firstname;
}
return trim($ret);
}
/** /**
* Retourne le libelle du statut d'un user (actif, inactif) * Retourne le libelle du statut d'un user (actif, inactif)
* *