30require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
42 public $element =
'societeaccount';
47 public $table_element =
'societe_account';
52 public $picto =
'lock';
99 public $fields = array(
100 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'visible' => -2,
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
'Id',),
101 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'visible' => 0,
'enabled' => 1,
'position' => 5,
'default' => 1),
102 'login' => array(
'type' =>
'varchar(64)',
'label' =>
'Login',
'visible' => 1,
'enabled' => 1,
'notnull' => 1,
'position' => 10,
'showoncombobox' => 1,
'autofocusoncreate' => 1),
103 'pass_encoding' => array(
'type' =>
'varchar(24)',
'label' =>
'PassEncoding',
'visible' => 0,
'enabled' => 1,
'position' => 30),
104 'pass_crypted' => array(
'type' =>
'password',
'label' =>
'Password',
'visible' => -1,
'enabled' => 1,
'position' => 31,
'notnull' => 1),
105 'pass_temp' => array(
'type' =>
'varchar(128)',
'label' =>
'Temp',
'visible' => 0,
'enabled' => 0,
'position' => 32,
'notnull' => -1,),
106 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'visible' => 1,
'enabled' => 1,
'position' => 40,
'notnull' => -1,
'index' => 1,
'picto' =>
'company',
'css' =>
'maxwidth300 widthcentpercentminusxx'),
107 'site' => array(
'type' =>
'varchar(128)',
'label' =>
'WebsiteTypeLabel',
'visible' => 0,
'enabled' => 0,
'position' => 41,
'notnull' => 1,
'default' =>
'',
'help' =>
'Name of the website or service if this is account on an external website or service',
'csslist' =>
'tdoverflowmax150',
'arrayofkeyval' => array()),
108 'fk_website' => array(
'type' =>
'integer:Website:website/class/website.class.php',
'label' =>
'WebSite',
'visible' => 0,
'enabled' => 0,
'position' => 42,
'notnull' => -1,
'index' => 1,
'picto' =>
'website',
'css' =>
'maxwidth300 widthcentpercentminusxx'),
109 'site_account' => array(
'type' =>
'varchar(128)',
'label' =>
'ExternalSiteAccount',
'visible' => 0,
'enabled' => 1,
'position' => 44,
'help' =>
'A key to identify the account on external web site if this is an account on an external website'),
110 'key_account' => array(
'type' =>
'varchar(128)',
'label' =>
'KeyAccount',
'visible' => 0,
'enabled' => 1,
'position' => 48,
'notnull' => 0,
'index' => 1,
'searchall' => 1,
'comment' =>
'The id of third party in the external web site (for site_account if site_account defined)',),
111 'date_last_login' => array(
'type' =>
'datetime',
'label' =>
'LastConnexion',
'visible' => 2,
'enabled' => 1,
'position' => 50,
'notnull' => 0,),
112 'date_previous_login' => array(
'type' =>
'datetime',
'label' =>
'PreviousConnexion',
'visible' => 2,
'enabled' => 1,
'position' => 51,
'notnull' => 0,),
113 'date_last_reset_password' => array(
'type' =>
'datetime',
'label' =>
'PreviousResetPassword',
'visible' => 0,
'enabled' => 1,
'position' => 53,
'notnull' => 0,),
115 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'visible' => -1,
'enabled' => 1,
'position' => 46,
'notnull' => -1,),
116 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'visible' => -2,
'enabled' => 1,
'position' => 500,
'notnull' => 1,),
117 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'visible' => -2,
'enabled' => 1,
'position' => 500,
'notnull' => 1,),
118 'fk_user_creat' => array(
'type' =>
'integer',
'label' =>
'UserAuthor',
'visible' => -2,
'enabled' => 1,
'position' => 500,
'notnull' => 1,),
119 'fk_user_modif' => array(
'type' =>
'integer',
'label' =>
'UserModif',
'visible' => -2,
'enabled' => 1,
'position' => 500,
'notnull' => -1,),
120 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'visible' => -2,
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'index' => 1,),
121 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'visible' => 1,
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
'index' => 1,
'default' => 1,
'arrayofkeyval' => array(
'1' =>
'Active',
'0' =>
'Disabled')),
136 public $pass_encoding;
137 public $pass_crypted;
146 public $site_account;
151 public $date_last_login;
153 public $date_last_reset_password;
154 public $date_previous_login;
155 public $note_private;
160 public $fk_user_creat;
165 public $fk_user_modif;
177 const STATUS_ENABLED = 1;
178 const STATUS_DISABLED = 0;
192 $this->ismultientitymanaged = 0;
195 $this->fields[
'rowid'][
'visible'] = 0;
199 $site_type_list = array();
201 if (isModEnabled(
'webportal')) {
202 $this->fields[
'site'][
'visible'] = 1;
203 $this->fields[
'site'][
'enabled'] = 1;
204 $site_type_list[
'dolibarr_portal'] = $langs->trans(
'WebsiteTypeDolibarrPortal');
207 if (isModEnabled(
'website')) {
208 $this->fields[
'fk_website'][
'visible'] = 1;
209 $this->fields[
'fk_website'][
'enabled'] = 1;
210 $this->fields[
'site'][
'visible'] = 1;
211 $this->fields[
'site'][
'enabled'] = 1;
212 $site_type_list[
'dolibarr_website'] = $langs->trans(
'WebsiteTypeDolibarrWebsite');
215 $this->fields[
'site'][
'arrayofkeyval'] = $site_type_list;
239 global $hookmanager, $langs;
256 $object->ref =
"copy_of_".$object->ref;
260 $object->context[
'createfromclone'] =
'createfromclone';
261 $result =
$object->createCommon($user);
265 $this->errors =
$object->errors;
268 unset(
$object->context[
'createfromclone']);
275 $this->db->rollback();
287 public function fetch($id, $ref =
null)
290 if ($result > 0 && !empty($this->table_element_line)) {
303 $this->lines = array();
307 return count($this->lines) ? 1 : 0;
322 $sql =
"SELECT sa.key_account as key_account, sa.entity";
323 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as sa";
324 $sql .=
" WHERE sa.fk_soc = ".((int) $id);
325 $sql .=
" AND sa.entity IN (".getEntity(
'societe').
")";
326 $sql .=
" AND sa.site = '".$this->db->escape($site).
"' AND sa.status = ".((int) $status);
327 $sql .=
" AND sa.key_account IS NOT NULL AND sa.key_account <> ''";
328 $sql .=
" AND (sa.site_account = '' OR sa.site_account IS NULL OR sa.site_account = '".$this->db->escape($site_account).
"')";
329 $sql .=
" ORDER BY sa.site_account DESC";
331 dol_syslog(get_class($this).
"::getCustomerAccount Try to find the first system customer id for ".$site.
" of thirdparty id=".$id.
" (example: cus_.... for stripe)", LOG_DEBUG);
332 $result = $this->db->query($sql);
334 if ($this->db->num_rows($result)) {
335 $obj = $this->db->fetch_object($result);
336 $key = $obj->key_account;
360 $sql =
"SELECT sa.fk_soc as fk_soc, sa.key_account, sa.entity";
361 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as sa";
362 $sql .=
" WHERE sa.key_account = '".$this->db->escape($id).
"'";
363 $sql .=
" AND sa.entity IN (".getEntity(
'societe').
")";
364 $sql .=
" AND sa.site = '".$this->db->escape($site).
"' AND sa.status = ".((int) $status);
365 $sql .=
" AND sa.fk_soc > 0";
367 dol_syslog(get_class($this).
"::getCustomerAccount Try to find the first thirdparty id for ".$site.
" for external id=".$id, LOG_DEBUG);
368 $result = $this->db->query($sql);
370 if ($this->db->num_rows($result)) {
371 $obj = $this->db->fetch_object($result);
372 $socid = $obj->fk_soc;
398 public function delete(
User $user, $notrigger = 0)
411 global $langs, $user;
413 $langs->loadLangs([
'companies, commercial',
'website']);
416 $option = $params[
'option'] ??
'';
418 $datas[
'picto'] =
'<u>'.$langs->trans(
"WebsiteAccount").
'</u>';
419 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
434 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
436 global $db, $conf, $langs;
437 global $dolibarr_main_authentication, $dolibarr_main_demo;
440 if (!empty($conf->dol_no_mouse_hover)) {
446 $this->
ref = $this->login;
448 $label =
'<u>'.$langs->trans(
"WebsiteAccount").
'</u>';
450 $label .=
'<b>'.$langs->trans(
'Login').
':</b> '.$this->ref;
453 $url = DOL_URL_ROOT.
'/website/websiteaccount_card.php?id='.$this->id;
455 if ($option !=
'nolink') {
457 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
458 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
459 $add_save_lastsearch_values = 1;
461 if ($add_save_lastsearch_values) {
462 $url .=
'&save_lastsearch_values=1';
467 $classfortooltip =
'classfortooltip';
472 'objecttype' => $this->element,
475 $classfortooltip =
'classforajaxtooltip';
476 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
480 if (empty($notooltip)) {
482 $label = $langs->trans(
"WebsiteAccount");
483 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
485 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
486 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
488 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
491 $linkstart =
'<a href="'.$url.
'"';
492 $linkstart .= $linkclose.
'>';
495 $result .= $linkstart;
497 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') : $dataparams.
' class="'.(($withpicto != 2) ?
'paddingright ' :
'').$classfortooltip.
'"'), 0, 0, $notooltip ? 0 : 1);
499 if ($withpicto != 2) {
500 $result .= $this->ref;
529 if (is_null($status)) {
533 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
536 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
537 $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
538 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
539 $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
542 $statusType =
'status4';
544 if ($status == self::STATUS_DISABLED) {
545 $statusType =
'status6';
548 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
559 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
560 $sql .=
' fk_user_creat, fk_user_modif';
561 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
562 $sql .=
' WHERE t.rowid = '.((int) $id);
563 $result = $this->db->query($sql);
565 if ($this->db->num_rows($result)) {
566 $obj = $this->db->fetch_object($result);
567 $this->
id = $obj->rowid;
569 $this->user_creation_id = $obj->fk_user_creat;
570 $this->user_modification_id = $obj->fk_user_modif;
571 $this->date_creation = $this->db->jdate($obj->datec);
572 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
575 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage Dolibarr database access.
Class for SocieteAccount.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetch($id, $ref=null)
Load object in memory from the database.
info($id)
Charge les information d'ordre info dans l'objet commande.
getLibStatut($mode=0)
Return the label of a given status.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
getTooltipContentArray($params)
getTooltipContentArray
fetchLines()
Load object lines in memory from the database.
createFromClone(User $user, $fromid)
Clone and object into another one.
__construct(DoliDB $db)
Constructor.
update(User $user, $notrigger=0)
Update object into database.
getCustomerAccount($id, $site, $status=0, $site_account='')
Try to find the external customer id of a thirdparty for another site/system.
LibStatut($status, $mode=0)
Return the status.
getThirdPartyID($id, $site, $status=0)
Try to find the thirdparty id from an another site/system external id.
create(User $user, $notrigger=0)
Create object into database.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.