Mutualize common code
This commit is contained in:
parent
392d8a26a5
commit
b1e58dd454
@ -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
|
||||
*
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?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>
|
||||
*
|
||||
* 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"]))
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", $_POST["MAIN_DISABLE_ALL_MAILS"],'chaine',0,'',$conf->entity);
|
||||
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", $_POST["MAIN_MAIL_SENDMODE"],'chaine',0,'',0);
|
||||
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", $_POST["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_SMTPS_ID"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", $_POST["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_EMAIL_TLS"])) dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", $_POST["MAIN_MAIL_EMAIL_TLS"],'chaine',0,'',0);
|
||||
|
||||
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", $_POST["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_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"],'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", GETPOST("MAIN_MAIL_SENDMODE"),'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);
|
||||
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", GETPOST("MAIN_MAIL_SMTPS_ID"), '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", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',0);
|
||||
// Content parameters
|
||||
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", GETPOST("MAIN_MAIL_ERRORS_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");
|
||||
exit;
|
||||
@ -351,7 +351,7 @@ if ($action == 'edit')
|
||||
// Server
|
||||
$var=!$var;
|
||||
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 '</td><td>';
|
||||
@ -367,6 +367,7 @@ if ($action == 'edit')
|
||||
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 type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="' . $conf->global->MAIN_MAIL_SMTP_SERVER . '">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -381,7 +382,7 @@ if ($action == 'edit')
|
||||
// Port
|
||||
$var=!$var;
|
||||
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 '</td><td>';
|
||||
@ -397,6 +398,7 @@ if ($action == 'edit')
|
||||
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 type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="' . $conf->global->MAIN_MAIL_SMTP_PORT . '">';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -517,7 +519,7 @@ else
|
||||
|
||||
// Server
|
||||
$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>';
|
||||
}
|
||||
@ -528,7 +530,7 @@ else
|
||||
|
||||
// Port
|
||||
$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>';
|
||||
}
|
||||
|
||||
@ -686,42 +686,5 @@ class Don extends CommonObject
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -900,48 +900,6 @@ class Contact extends CommonObject
|
||||
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
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?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) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@ -26,10 +26,8 @@
|
||||
|
||||
|
||||
/**
|
||||
* \class CommonObject
|
||||
* \brief Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
|
||||
* Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
|
||||
*/
|
||||
|
||||
abstract class CommonObject
|
||||
{
|
||||
protected $db;
|
||||
@ -41,6 +39,49 @@ abstract class CommonObject
|
||||
// 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.
|
||||
*
|
||||
@ -72,11 +113,11 @@ abstract class CommonObject
|
||||
/**
|
||||
* Add a link between element $this->element and a contact
|
||||
*
|
||||
* @param fk_socpeople Id of contact to link
|
||||
* @param type_contact Type of contact (code or id)
|
||||
* @param source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
|
||||
* @param notrigger Disable all triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $fk_socpeople Id of contact to link
|
||||
* @param int $type_contact Type of contact (code or id)
|
||||
* @param int $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
|
||||
* @param int $notrigger Disable all triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger=0)
|
||||
{
|
||||
@ -168,10 +209,10 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update a link to contact line
|
||||
*
|
||||
* @param rowid Id of line contact-element
|
||||
* @param statut New status of link
|
||||
* @param type_contact_id Id of contact type (not modified if 0)
|
||||
* @return int <0 if KO, >= 0 if OK
|
||||
* @param int $rowid Id of line contact-element
|
||||
* @param int $statut New status of link
|
||||
* @param int $type_contact_id Id of contact type (not modified if 0)
|
||||
* @return int <0 if KO, >= 0 if OK
|
||||
*/
|
||||
function update_contact($rowid, $statut, $type_contact_id=0)
|
||||
{
|
||||
@ -195,9 +236,9 @@ abstract class CommonObject
|
||||
/**
|
||||
* Delete a link to contact line
|
||||
*
|
||||
* @param rowid Id of contact link line to delete
|
||||
* @param notrigger Disable all triggers
|
||||
* @return int >0 if OK, <0 if KO
|
||||
* @param int $rowid Id of contact link line to delete
|
||||
* @param int $notrigger Disable all triggers
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
function delete_contact($rowid, $notrigger=0)
|
||||
{
|
||||
@ -269,10 +310,10 @@ abstract class CommonObject
|
||||
/**
|
||||
* Get array of all contacts for an object
|
||||
*
|
||||
* @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 int $list 0:Return array contains all properties, 1:Return array contains just id
|
||||
* @return array Array of contacts
|
||||
* @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 int $list 0:Return array contains all properties, 1:Return array contains just id
|
||||
* @return array Array of contacts
|
||||
*/
|
||||
function liste_contact($statut=-1,$source='external',$list=0)
|
||||
{
|
||||
@ -339,8 +380,8 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update status of a contact linked to object
|
||||
*
|
||||
* @param $rowid Id of link between object and contact
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
* @param int $rowid Id of link between object and contact
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function swapContactStatus($rowid)
|
||||
{
|
||||
@ -375,10 +416,10 @@ abstract class CommonObject
|
||||
/**
|
||||
* Return array with list of possible values for type of contacts
|
||||
*
|
||||
* @param source internal, external or all if not defined
|
||||
* @param order Sort order by : code or rowid
|
||||
* @param 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)
|
||||
* @param string $source 'internal', 'external' or 'all'
|
||||
* @param string $order Sort order by : 'code' or 'rowid'
|
||||
* @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)
|
||||
*/
|
||||
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 interne suivi paiement ('internal', 'SALESREPFOLL')
|
||||
*
|
||||
* @param source 'external' or 'internal'
|
||||
* @param code 'BILLING', 'SHIPPING', 'SALESREPFOLL', ...
|
||||
* @param status limited to a certain status
|
||||
* @return array List of id for such contacts
|
||||
* @param string $source 'external' or 'internal'
|
||||
* @param string $code 'BILLING', 'SHIPPING', 'SALESREPFOLL', ...
|
||||
* @param int $status limited to a certain status
|
||||
* @return array List of id for such contacts
|
||||
*/
|
||||
function getIdContact($source,$code,$status=0)
|
||||
{
|
||||
@ -473,8 +514,8 @@ abstract class CommonObject
|
||||
/**
|
||||
* Charge le contact d'id $id dans this->contact
|
||||
*
|
||||
* @param contactid Id du contact
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $contactid Id du contact
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch_contact($contactid)
|
||||
{
|
||||
@ -488,7 +529,7 @@ abstract class CommonObject
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
@ -577,8 +618,8 @@ abstract class CommonObject
|
||||
/**
|
||||
* Charge le user d'id userid dans this->user
|
||||
*
|
||||
* @param userid Id du contact
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $userid Id du contact
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch_user($userid)
|
||||
{
|
||||
@ -589,7 +630,9 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Read linked origin object
|
||||
* Read linked origin object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function fetch_origin()
|
||||
{
|
||||
@ -607,10 +650,10 @@ abstract class CommonObject
|
||||
/**
|
||||
* Load object from specific field
|
||||
*
|
||||
* @param table Table element or element line
|
||||
* @param field Field selected
|
||||
* @param key Import key
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param string $table Table element or element line
|
||||
* @param string $field Field selected
|
||||
* @param string $key Import key
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetchObjectFrom($table,$field,$key)
|
||||
{
|
||||
@ -698,11 +741,11 @@ abstract class CommonObject
|
||||
/**
|
||||
* Load properties id_previous and id_next
|
||||
*
|
||||
* @param filter Optional filter
|
||||
* @param fieldid Name of field to use for the select MAX and MIN
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param string $filter Optional filter
|
||||
* @param int $fieldid Name of field to use for the select MAX and MIN
|
||||
* @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;
|
||||
|
||||
@ -766,9 +809,9 @@ abstract class CommonObject
|
||||
/**
|
||||
* Return list of id of contacts of project
|
||||
*
|
||||
* @param 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)
|
||||
* Array of id of third parties with at least one contact on project (if source=thirdparty)
|
||||
* @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)
|
||||
* Array of id of third parties with at least one contact on project (if source=thirdparty)
|
||||
*/
|
||||
function getListContactId($source='external')
|
||||
{
|
||||
@ -822,9 +865,9 @@ abstract class CommonObject
|
||||
/**
|
||||
* Set last model used by doc generator
|
||||
*
|
||||
* @param user User object that make change
|
||||
* @param modelpdf Modele name
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param User $user User object that make change
|
||||
* @param string $modelpdf Modele name
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
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 string $rowidorder ASC or DESC
|
||||
* @return void
|
||||
*/
|
||||
function line_order($renum=false, $rowidorder='ASC')
|
||||
{
|
||||
@ -891,7 +935,7 @@ abstract class CommonObject
|
||||
if ($nl > 0)
|
||||
{
|
||||
$rows=array();
|
||||
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
$sql.= ' AND fk_parent_line IS NULL';
|
||||
@ -928,21 +972,22 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get childrens of line
|
||||
*
|
||||
*
|
||||
* @param int $id Id of parent line
|
||||
* @return array Array with list of child lines id
|
||||
*/
|
||||
function getChildrensOfLine($id)
|
||||
{
|
||||
$rows=array();
|
||||
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
$sql.= ' AND fk_parent_line = '.$id;
|
||||
$sql.= ' ORDER BY rang ASC';
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::getChildrenOfLines sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -956,14 +1001,15 @@ abstract class CommonObject
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a line to have a lower rank
|
||||
*
|
||||
* @param int $rowid
|
||||
* @param int $rowid Id of line
|
||||
* @return void
|
||||
*/
|
||||
function line_up($rowid)
|
||||
{
|
||||
@ -979,7 +1025,8 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update a line to have a higher rank
|
||||
*
|
||||
* @param int $rowid
|
||||
* @param int $rowid Id of line
|
||||
* @return void
|
||||
*/
|
||||
function line_down($rowid)
|
||||
{
|
||||
@ -998,8 +1045,9 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update position of line (rang)
|
||||
*
|
||||
* @param int $rowid
|
||||
* @param int $rang
|
||||
* @param int $rowid Id of line
|
||||
* @param int $rang Position
|
||||
* @return void
|
||||
*/
|
||||
function updateRangOfLine($rowid,$rang)
|
||||
{
|
||||
@ -1017,6 +1065,7 @@ abstract class CommonObject
|
||||
* Update position of line with ajax (rang)
|
||||
*
|
||||
* @param array $rows Array of rows
|
||||
* @return void
|
||||
*/
|
||||
function line_ajaxorder($rows)
|
||||
{
|
||||
@ -1030,8 +1079,9 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update position of line up (rang)
|
||||
*
|
||||
* @param int $rowid
|
||||
* @param int $rang
|
||||
* @param int $rowid Id of line
|
||||
* @param int $rang Position
|
||||
* @return void
|
||||
*/
|
||||
function updateLineUp($rowid,$rang)
|
||||
{
|
||||
@ -1059,9 +1109,10 @@ abstract class CommonObject
|
||||
/**
|
||||
* Update position of line down (rang)
|
||||
*
|
||||
* @param int $rowid
|
||||
* @param int $rang
|
||||
* @param int $max
|
||||
* @param int $rowid Id of line
|
||||
* @param int $rang Position
|
||||
* @param int $max Max
|
||||
* @return void
|
||||
*/
|
||||
function updateLineDown($rowid,$rang,$max)
|
||||
{
|
||||
@ -1582,10 +1633,10 @@ abstract class CommonObject
|
||||
/**
|
||||
* Set statut of an object
|
||||
*
|
||||
* @param statut Statut to set
|
||||
* @param elementId Id of element to force (use this->id by default)
|
||||
* @param elementType Type of element to force (use ->this->element by default)
|
||||
* @return int <0 if ko, >0 if ok
|
||||
* @param int $statut Statut to set
|
||||
* @param int $elementId Id of element to force (use this->id by default)
|
||||
* @param string $elementType Type of element to force (use ->this->element by default)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function setStatut($statut,$elementId='',$elementType='')
|
||||
{
|
||||
@ -1655,7 +1706,8 @@ abstract class CommonObject
|
||||
/**
|
||||
* Get special code of line
|
||||
*
|
||||
* @param lineid Id of line
|
||||
* @param int $lineid Id of line
|
||||
* @return int Special code
|
||||
*/
|
||||
function getSpecialCode($lineid)
|
||||
{
|
||||
@ -1673,8 +1725,9 @@ abstract class CommonObject
|
||||
/**
|
||||
* Function to get extra fields of a member into $this->array_options
|
||||
*
|
||||
* @param rowid
|
||||
* @param optionsArray Array resulting of call of extrafields->fetch_name_optionals_label()
|
||||
* @param int $rowid Id of line
|
||||
* @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label()
|
||||
* @return void
|
||||
*/
|
||||
function fetch_optionals($rowid,$optionsArray='')
|
||||
{
|
||||
@ -1725,7 +1778,9 @@ abstract class CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Add/Update extra fields
|
||||
* Add/Update extra fields
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function insertExtraFields()
|
||||
{
|
||||
@ -1858,10 +1913,11 @@ abstract class CommonObject
|
||||
/**
|
||||
* List urls of elemùent
|
||||
*
|
||||
* @param unknown_type $objectid
|
||||
* @param unknown_type $objecttype
|
||||
* @param unknown_type $withpicto
|
||||
* @param unknown_type $option
|
||||
* @param int $objectid Id of record
|
||||
* @param string $objecttype Type of object
|
||||
* @param int $withpicto Picto to show
|
||||
* @param string $option More options
|
||||
* @return void
|
||||
*/
|
||||
function getElementUrl($objectid,$objecttype,$withpicto=0,$option='')
|
||||
{
|
||||
@ -1932,6 +1988,8 @@ abstract class CommonObject
|
||||
* Show linked object block
|
||||
* 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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showLinkedObjectBlock()
|
||||
{
|
||||
@ -1990,10 +2048,11 @@ abstract class CommonObject
|
||||
* 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.
|
||||
*
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param Societe $seller Object thirdparty who sell
|
||||
* @param Societe $buyer Object thirdparty who buy
|
||||
* @param HookManager $hookmanager Hook manager instance
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param Societe $seller Object thirdparty who sell
|
||||
* @param Societe $buyer Object thirdparty who buy
|
||||
* @param HookManager $hookmanager Hook manager instance
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
* 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 Societe $seller Object thirdparty who sell
|
||||
* @param Societe $buyer Object thirdparty who buy
|
||||
* @param HookManager $hookmanager Hook manager instance
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param Societe $seller Object thirdparty who sell
|
||||
* @param Societe $buyer Object thirdparty who buy
|
||||
* @param HookManager $hookmanager Hook manager instance
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
* 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 $seller Object of seller third party
|
||||
* @param $buyer Object of buyer third party
|
||||
* @param $selected Object line selected
|
||||
* @param $dateSelector 1=Show also date range input fields
|
||||
* @param string $action Action code
|
||||
* @param string $seller Object of seller third party
|
||||
* @param string $buyer Object of buyer third party
|
||||
* @param string $selected Object line selected
|
||||
* @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;
|
||||
|
||||
@ -2112,17 +2174,19 @@ abstract class CommonObject
|
||||
* 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.
|
||||
*
|
||||
* @param $action GET/POST action
|
||||
* @param $line Selected object line to output
|
||||
* @param $var Is it a an odd line
|
||||
* @param $num Number of line
|
||||
* @param $i
|
||||
* @param $dateSelector 1=Show also date range input fields
|
||||
* @param $seller Object of seller third party
|
||||
* @param $buyer Object of buyer third party
|
||||
* @param $selected Object line selected
|
||||
* @param string $action GET/POST action
|
||||
* @param array $line Selected object line to output
|
||||
* @param string $var Is it a an odd line
|
||||
* @param int $num Number of line
|
||||
* @param int $i I
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param string $seller Object of seller third party
|
||||
* @param string $buyer Object of buyer third party
|
||||
* @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 $form,$bc,$bcdd;
|
||||
@ -2150,7 +2214,7 @@ abstract class CommonObject
|
||||
{
|
||||
$this->fetch_thirdparty();
|
||||
$prod = new Product($this->db, $line->fk_product);
|
||||
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
||||
@ -2160,13 +2224,13 @@ abstract class CommonObject
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
|
||||
$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $line->product_label;
|
||||
}
|
||||
else {
|
||||
$label = $line->product_label;
|
||||
}
|
||||
|
||||
|
||||
$product_static->type=$line->fk_product_type;
|
||||
$product_static->id=$line->fk_product;
|
||||
$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).
|
||||
* 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.
|
||||
*
|
||||
* @param HookManager $hookmanager Hook manager
|
||||
* @return void
|
||||
*/
|
||||
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).
|
||||
* 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.
|
||||
* @param line
|
||||
* @param var
|
||||
*
|
||||
* @param array $line Line
|
||||
* @param string $var Var
|
||||
* @return void
|
||||
*/
|
||||
function printOriginLine($line,$var)
|
||||
{
|
||||
|
||||
@ -1705,48 +1705,6 @@ class User extends CommonObject
|
||||
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)
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user