28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $element =
'societeaccount';
45 public $table_element =
'societe_account';
50 public $ismultientitymanaged = 0;
55 public $picto =
'lock';
79 public $fields = array(
80 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'visible'=>-2,
'enabled'=>1,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
'Id',),
81 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'visible'=>0,
'enabled'=>1,
'position'=>5,
'default'=>1),
82 'login' => array(
'type'=>
'varchar(64)',
'label'=>
'Login',
'visible'=>1,
'enabled'=>1,
'notnull'=>1,
'position'=>10,
'showoncombobox'=>1),
83 'pass_encoding' => array(
'type'=>
'varchar(24)',
'label'=>
'PassEncoding',
'visible'=>0,
'enabled'=>1,
'position'=>30),
84 'pass_crypted' => array(
'type'=>
'password',
'label'=>
'Password',
'visible'=>1,
'enabled'=>1,
'position'=>31,
'notnull'=>1),
85 'pass_temp' => array(
'type'=>
'varchar(128)',
'label'=>
'Temp',
'visible'=>0,
'enabled'=>0,
'position'=>32,
'notnull'=>-1,),
86 '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'),
87 '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'),
88 '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'),
89 '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'),
90 '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)',),
91 'date_last_login' => array(
'type'=>
'datetime',
'label'=>
'LastConnexion',
'visible'=>2,
'enabled'=>1,
'position'=>50,
'notnull'=>0,),
92 'date_previous_login' => array(
'type'=>
'datetime',
'label'=>
'PreviousConnexion',
'visible'=>2,
'enabled'=>1,
'position'=>51,
'notnull'=>0,),
94 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'visible'=>-1,
'enabled'=>1,
'position'=>46,
'notnull'=>-1,),
95 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'visible'=>-2,
'enabled'=>1,
'position'=>500,
'notnull'=>1,),
96 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'visible'=>-2,
'enabled'=>1,
'position'=>500,
'notnull'=>1,),
97 'fk_user_creat' => array(
'type'=>
'integer',
'label'=>
'UserAuthor',
'visible'=>-2,
'enabled'=>1,
'position'=>500,
'notnull'=>1,),
98 'fk_user_modif' => array(
'type'=>
'integer',
'label'=>
'UserModif',
'visible'=>-2,
'enabled'=>1,
'position'=>500,
'notnull'=>-1,),
99 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'visible'=>-2,
'enabled'=>1,
'position'=>1000,
'notnull'=>-1,
'index'=>1,),
100 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'visible'=>1,
'enabled'=>1,
'position'=>1000,
'notnull'=>1,
'index'=>1,
'default'=>1,
'arrayofkeyval'=>array(
'1'=>
'Active',
'0'=>
'Disabled')),
115 public $pass_encoding;
116 public $pass_crypted;
125 public $site_account;
130 public $date_last_login;
133 public $date_previous_login;
134 public $note_private;
139 public $date_creation;
147 public $fk_user_creat;
152 public $fk_user_modif;
164 const STATUS_ENABLED = 1;
165 const STATUS_DISABLED = 0;
175 global $conf, $langs;
180 $this->fields[
'rowid'][
'visible'] = 0;
184 $site_type_list = array();
185 if (isModEnabled(
'website')) {
186 $this->fields[
'fk_website'][
'visible'] = 1;
187 $this->fields[
'fk_website'][
'enabled'] = 1;
188 $this->fields[
'site'][
'visible'] = 1;
189 $this->fields[
'site'][
'enabled'] = 1;
190 $site_type_list[
'dolibarr_website'] = $langs->trans(
'WebsiteTypeDolibarrWebsite');
192 if (isModEnabled(
'webportal')) {
193 $this->fields[
'site'][
'visible'] = 1;
194 $this->fields[
'site'][
'enabled'] = 1;
195 $site_type_list[
'dolibarr_portal'] = $langs->trans(
'WebsiteTypeDolibarrPortal');
197 $this->fields[
'site'][
'arrayofkeyval'] = $site_type_list;
221 global $hookmanager, $langs;
226 $object =
new self($this->db);
231 $object->fetchCommon($fromid);
234 unset($object->fk_user_creat);
235 unset($object->import_key);
238 $object->ref =
"copy_of_".$object->ref;
242 $object->context[
'createfromclone'] =
'createfromclone';
243 $result = $object->createCommon($user);
246 $this->error = $object->error;
247 $this->errors = $object->errors;
250 unset($object->context[
'createfromclone']);
257 $this->db->rollback();
269 public function fetch($id, $ref =
null)
272 if ($result > 0 && !empty($this->table_element_line)) {
285 $this->lines = array();
289 return count($this->lines) ? 1 : 0;
304 $sql =
"SELECT sa.key_account as key_account, sa.entity";
305 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as sa";
306 $sql .=
" WHERE sa.fk_soc = ".((int) $id);
307 $sql .=
" AND sa.entity IN (".getEntity(
'societe').
")";
308 $sql .=
" AND sa.site = '".$this->db->escape($site).
"' AND sa.status = ".((int) $status);
309 $sql .=
" AND sa.key_account IS NOT NULL AND sa.key_account <> ''";
310 $sql .=
" AND (sa.site_account = '' OR sa.site_account IS NULL OR sa.site_account = '".$this->db->escape($site_account).
"')";
311 $sql .=
" ORDER BY sa.site_account DESC";
313 dol_syslog(get_class($this).
"::getCustomerAccount Try to find the first system customer id for ".$site.
" of thirdparty id=".$id.
" (exemple: cus_.... for stripe)", LOG_DEBUG);
314 $result = $this->db->query($sql);
316 if ($this->db->num_rows($result)) {
317 $obj = $this->db->fetch_object($result);
318 $key = $obj->key_account;
342 $sql =
"SELECT sa.fk_soc as fk_soc, sa.key_account, sa.entity";
343 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as sa";
344 $sql .=
" WHERE sa.key_account = '".$this->db->escape($id).
"'";
345 $sql .=
" AND sa.entity IN (".getEntity(
'societe').
")";
346 $sql .=
" AND sa.site = '".$this->db->escape($site).
"' AND sa.status = ".((int) $status);
347 $sql .=
" AND sa.fk_soc > 0";
349 dol_syslog(get_class($this).
"::getCustomerAccount Try to find the first thirdparty id for ".$site.
" for external id=".$id, LOG_DEBUG);
350 $result = $this->db->query($sql);
352 if ($this->db->num_rows($result)) {
353 $obj = $this->db->fetch_object($result);
354 $socid = $obj->fk_soc;
380 public function delete(
User $user, $notrigger =
false)
393 global $conf, $langs, $user;
395 $langs->loadLangs([
'companies, commercial']);
398 $option = $params[
'option'] ??
'';
400 $datas[
'picto'] =
'<u>'.$langs->trans(
"WebsiteAccount").
'</u>';
401 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
416 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
418 global $db, $conf, $langs;
419 global $dolibarr_main_authentication, $dolibarr_main_demo;
422 if (!empty($conf->dol_no_mouse_hover)) {
428 $this->
ref = $this->login;
430 $label =
'<u>'.$langs->trans(
"WebsiteAccount").
'</u>';
432 $label .=
'<b>'.$langs->trans(
'Login').
':</b> '.$this->ref;
435 $url = DOL_URL_ROOT.
'/website/websiteaccount_card.php?id='.$this->id;
437 if ($option !=
'nolink') {
439 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
440 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
441 $add_save_lastsearch_values = 1;
443 if ($add_save_lastsearch_values) {
444 $url .=
'&save_lastsearch_values=1';
449 $classfortooltip =
'classfortooltip';
454 'objecttype' => $this->element,
457 $classfortooltip =
'classforajaxtooltip';
458 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
462 if (empty($notooltip)) {
464 $label = $langs->trans(
"WebsiteAccount");
465 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
467 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
468 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
470 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
473 $linkstart =
'<a href="'.$url.
'"';
474 $linkstart .= $linkclose.
'>';
477 $result .= $linkstart;
479 $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);
481 if ($withpicto != 2) {
482 $result .= $this->ref;
511 if (is_null($status)) {
515 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
518 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
519 $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
520 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
521 $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
524 $statusType =
'status4';
526 if ($status == self::STATUS_DISABLED) {
527 $statusType =
'status6';
530 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
541 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
542 $sql .=
' fk_user_creat, fk_user_modif';
543 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
544 $sql .=
' WHERE t.rowid = '.((int) $id);
545 $result = $this->db->query($sql);
547 if ($this->db->num_rows($result)) {
548 $obj = $this->db->fetch_object($result);
549 $this->
id = $obj->rowid;
551 $this->user_creation_id = $obj->fk_user_creat;
552 $this->user_modification_id = $obj->fk_user_modif;
553 $this->date_creation = $this->db->jdate($obj->datec);
554 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
557 $this->db->free($result);
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the 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.
create(User $user, $notrigger=false)
Create object into database.
fetch($id, $ref=null)
Load object in memory from the database.
info($id)
Charge les informations 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 optionaly 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.
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.
update(User $user, $notrigger=false)
Update object into database.
Class to manage Dolibarr users.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.