34 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
45 public $element =
'contact';
50 public $table_element =
'socpeople';
56 public $ismultientitymanaged = 1;
61 public $picto =
'contact';
91 public $fields = array(
92 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
93 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>3,
'notnull'=>1,
'position'=>30,
'index'=>1),
94 'ref_ext' =>array(
'type'=>
'varchar(255)',
'label'=>
'Ref ext',
'enabled'=>1,
'visible'=>3,
'position'=>35),
95 'civility' =>array(
'type'=>
'varchar(6)',
'label'=>
'Civility',
'enabled'=>1,
'visible'=>3,
'position'=>40),
96 'lastname' =>array(
'type'=>
'varchar(50)',
'label'=>
'Lastname',
'enabled'=>1,
'visible'=>1,
'position'=>45,
'showoncombobox'=>1,
'searchall'=>1),
97 'firstname' =>array(
'type'=>
'varchar(50)',
'label'=>
'Firstname',
'enabled'=>1,
'visible'=>1,
'position'=>50,
'showoncombobox'=>1,
'searchall'=>1),
98 'poste' =>array(
'type'=>
'varchar(80)',
'label'=>
'PostOrFunction',
'enabled'=>1,
'visible'=>-1,
'position'=>52),
99 'address' =>array(
'type'=>
'varchar(255)',
'label'=>
'Address',
'enabled'=>1,
'visible'=>-1,
'position'=>55),
100 'zip' =>array(
'type'=>
'varchar(25)',
'label'=>
'Zip',
'enabled'=>1,
'visible'=>1,
'position'=>60),
101 'town' =>array(
'type'=>
'text',
'label'=>
'Town',
'enabled'=>1,
'visible'=>-1,
'position'=>65),
102 'fk_departement' =>array(
'type'=>
'integer',
'label'=>
'Fk departement',
'enabled'=>1,
'visible'=>3,
'position'=>70),
103 'fk_pays' =>array(
'type'=>
'integer',
'label'=>
'Fk pays',
'enabled'=>1,
'visible'=>3,
'position'=>75),
104 'fk_soc' =>array(
'type'=>
'integer',
'label'=>
'ThirdParty',
'enabled'=>1,
'visible'=>1,
'position'=>77,
'searchall'=>1),
105 'birthday' =>array(
'type'=>
'date',
'label'=>
'Birthday',
'enabled'=>1,
'visible'=>3,
'position'=>80),
106 'phone' =>array(
'type'=>
'varchar(30)',
'label'=>
'Phone',
'enabled'=>1,
'visible'=>1,
'position'=>90,
'searchall'=>1),
107 'phone_perso' =>array(
'type'=>
'varchar(30)',
'label'=>
'PhonePerso',
'enabled'=>1,
'visible'=>-1,
'position'=>95,
'searchall'=>1),
108 'phone_mobile' =>array(
'type'=>
'varchar(30)',
'label'=>
'PhoneMobile',
'enabled'=>1,
'visible'=>1,
'position'=>100,
'searchall'=>1),
109 'fax' =>array(
'type'=>
'varchar(30)',
'label'=>
'Fax',
'enabled'=>1,
'visible'=>-1,
'position'=>105,
'searchall'=>1),
110 'email' =>array(
'type'=>
'varchar(255)',
'label'=>
'Email',
'enabled'=>1,
'visible'=>1,
'position'=>110,
'searchall'=>1),
111 'socialnetworks' =>array(
'type'=>
'text',
'label'=>
'SocialNetworks',
'enabled'=>1,
'visible'=>3,
'position'=>115),
112 'photo' =>array(
'type'=>
'varchar(255)',
'label'=>
'Photo',
'enabled'=>1,
'visible'=>3,
'position'=>170),
113 'priv' =>array(
'type'=>
'smallint(6)',
'label'=>
'ContactVisibility',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>175),
114 'fk_stcommcontact' =>array(
'type'=>
'integer',
'label'=>
'ProspectStatus',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>220),
115 'fk_prospectlevel' =>array(
'type'=>
'varchar(12)',
'label'=>
'ProspectLevel',
'enabled'=>1,
'visible'=>-1,
'position'=>255),
116 'no_email' =>array(
'type'=>
'smallint(6)',
'label'=>
'No_Email',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>180),
117 'note_private' =>array(
'type'=>
'text',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>3,
'position'=>195,
'searchall'=>1),
118 'note_public' =>array(
'type'=>
'text',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>3,
'position'=>200,
'searchall'=>1),
119 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>3,
'position'=>205),
120 'canvas' =>array(
'type'=>
'varchar(32)',
'label'=>
'Canvas',
'enabled'=>1,
'visible'=>3,
'position'=>210),
121 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'position'=>300),
122 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>305),
123 'fk_user_creat' =>array(
'type'=>
'integer',
'label'=>
'UserAuthor',
'enabled'=>1,
'visible'=>3,
'position'=>310),
124 'fk_user_modif' =>array(
'type'=>
'integer',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>3,
'position'=>315),
125 'statut' =>array(
'type'=>
'tinyint(4)',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>500),
126 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-1,
'position'=>1000),
130 public $civility_code;
206 public $socialnetworks;
261 public $phone_mobile;
275 public $default_lang;
280 public $ref_facturation;
290 public $ref_commande;
321 public $cacheprospectstatus = array();
322 public $fk_prospectlevel;
324 public $statut_commercial;
329 public $stcomm_picto;
339 global $conf, $langs;
344 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
345 $this->fields[
'rowid'][
'visible'] = 0;
348 $this->fields[
'no_email'][
'enabled'] = 0;
351 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
352 $this->fields[
'fk_soc'][
'enabled'] = 0;
353 $this->fields[
'fk_soc'][
'searchall'] = 0;
356 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
357 $this->fields[
'fk_stcommcontact'][
'enabled'] = 0;
358 $this->fields[
'fk_prospectlevel'][
'enabled'] = 0;
362 foreach ($this->fields as $key => $val) {
363 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
364 unset($this->fields[$key]);
393 global $user, $hookmanager;
398 $sql =
"SELECT count(sp.rowid) as nb";
399 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
400 if (empty($user->rights->societe->client->voir) && !$user->socid) {
401 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
402 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
403 $sql .=
" WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
406 $sql .=
" ".$clause.
" sp.entity IN (".
getEntity($this->element).
")";
407 $sql .=
" AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat = ".((int) $user->id).
"))";
408 if ($user->socid > 0) {
409 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
412 if (is_object($hookmanager)) {
413 $parameters = array();
414 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
415 $sql .= $hookmanager->resPrint;
420 while ($obj = $this->
db->fetch_object(
$resql)) {
421 $this->nb[
"contacts"] = $obj->nb;
427 $this->error = $this->
db->lasterror();
440 global $conf, $langs;
448 $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->
name);
449 $this->firstname = trim($this->firstname);
451 if (empty($this->socid)) {
454 if (empty($this->priv)) {
457 if (empty($this->statut)) {
461 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
463 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"socpeople (";
466 $sql .=
", lastname";
467 $sql .=
", firstname";
468 $sql .=
", fk_user_creat";
470 $sql .=
", fk_stcommcontact";
475 $sql .=
", import_key";
476 $sql .=
") VALUES (";
477 $sql .=
"'".$this->db->idate($now).
"',";
478 if ($this->socid > 0) {
479 $sql .=
" ".((int) $this->socid).
",";
483 $sql .=
"'".$this->db->escape($this->lastname).
"',";
484 $sql .=
"'".$this->db->escape($this->firstname).
"',";
485 $sql .=
" ".($user->id > 0 ? ((int) $user->id) :
"null").
",";
486 $sql .=
" ".((int) $this->priv).
",";
488 $sql .=
" ".((int) $this->statut).
",";
489 $sql .=
" ".(!empty($this->canvas) ?
"'".$this->db->escape($this->canvas).
"'" :
"null").
",";
490 $sql .=
" ".((int) $this->entity).
",";
491 $sql .=
"'".$this->db->escape($this->ref_ext).
"',";
492 $sql .=
" ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
495 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
498 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"socpeople");
501 $result = $this->
update($this->
id, $user, 1,
'add');
504 $this->error = $this->
db->lasterror();
512 $this->error = $this->
db->lasterror();
529 $this->
db->rollback();
530 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
534 $this->error = $this->
db->lasterror();
536 $this->
db->rollback();
537 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
552 public function update($id, $user =
null, $notrigger = 0, $action =
'update', $nosyncuser = 0)
554 global $conf, $langs, $hookmanager;
560 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
563 $this->ref_ext = trim($this->ref_ext);
564 $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname);
565 $this->firstname = trim($this->firstname);
566 $this->email = trim($this->email);
567 $this->phone_pro = trim($this->phone_pro);
568 $this->phone_perso = trim($this->phone_perso);
569 $this->phone_mobile = trim($this->phone_mobile);
570 $this->photo = trim($this->photo);
571 $this->fax = trim($this->fax);
572 $this->zip = (empty($this->zip) ?
'' : trim($this->zip));
573 $this->town = (empty($this->town) ?
'' : trim($this->town));
574 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
575 if (empty($this->statut)) {
578 if (empty($this->civility_code) && !is_numeric($this->civility_id)) {
579 $this->civility_code = $this->civility_id;
584 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
585 if ($this->socid > 0) {
586 $sql .=
" fk_soc = ".((int) $this->socid).
",";
587 } elseif ($this->socid == -1) {
588 $sql .=
" fk_soc = NULL,";
590 $sql .=
" civility='".$this->db->escape($this->civility_code).
"'";
591 $sql .=
", lastname='".$this->db->escape($this->lastname).
"'";
592 $sql .=
", firstname='".$this->db->escape($this->firstname).
"'";
593 $sql .=
", address='".$this->db->escape($this->address).
"'";
594 $sql .=
", zip='".$this->db->escape($this->zip).
"'";
595 $sql .=
", town='".$this->db->escape($this->town).
"'";
596 $sql .=
", ref_ext = ".(!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"NULL");
597 $sql .=
", fk_pays=".($this->country_id > 0 ? $this->country_id :
'NULL');
598 $sql .=
", fk_departement=".($this->state_id > 0 ? $this->state_id :
'NULL');
599 $sql .=
", poste='".$this->db->escape($this->poste).
"'";
600 $sql .=
", fax='".$this->db->escape($this->fax).
"'";
601 $sql .=
", email='".$this->db->escape($this->email).
"'";
602 $sql .=
", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks)).
"'";
603 $sql .=
", photo='".$this->db->escape($this->photo).
"'";
604 $sql .=
", birthday=".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
605 $sql .=
", note_private = ".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"NULL");
606 $sql .=
", note_public = ".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"NULL");
607 $sql .=
", phone = ".(isset($this->phone_pro) ?
"'".$this->db->escape($this->phone_pro).
"'" :
"NULL");
608 $sql .=
", phone_perso = ".(isset($this->phone_perso) ?
"'".$this->db->escape($this->phone_perso).
"'" :
"NULL");
609 $sql .=
", phone_mobile = ".(isset($this->phone_mobile) ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"NULL");
610 $sql .=
", priv = '".$this->db->escape($this->priv).
"'";
611 $sql .=
", fk_prospectlevel = '".$this->db->escape($this->fk_prospectlevel).
"'";
612 if (isset($this->stcomm_id)) {
613 $sql .=
", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id :
"0");
615 $sql .=
", statut = ".((int) $this->statut);
616 $sql .=
", fk_user_modif=".($user->id > 0 ?
"'".$this->db->escape($user->id).
"'" :
"NULL");
617 $sql .=
", default_lang=".($this->default_lang ?
"'".$this->db->escape($this->default_lang).
"'" :
"NULL");
618 $sql .=
", entity = ".((int) $this->entity);
619 $sql .=
" WHERE rowid = ".((int) $id);
621 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
622 $result = $this->
db->query($sql);
624 unset($this->country_code);
625 unset($this->country);
626 unset($this->state_code);
646 if (!$error && $this->user_id > 0) {
648 $tmpobj =
new User($this->
db);
649 $tmpobj->fetch($this->user_id);
650 $usermustbemodified = 0;
651 if ($tmpobj->office_phone != $this->phone_pro) {
652 $tmpobj->office_phone = $this->phone_pro;
653 $usermustbemodified++;
655 if ($tmpobj->office_fax != $this->fax) {
656 $tmpobj->office_fax = $this->fax;
657 $usermustbemodified++;
659 if ($tmpobj->address != $this->address) {
660 $tmpobj->address = $this->address;
661 $usermustbemodified++;
663 if ($tmpobj->town != $this->town) {
664 $tmpobj->town = $this->town;
665 $usermustbemodified++;
667 if ($tmpobj->zip != $this->zip) {
668 $tmpobj->zip = $this->zip;
669 $usermustbemodified++;
671 if ($tmpobj->zip != $this->zip) {
672 $tmpobj->state_id = $this->state_id;
673 $usermustbemodified++;
675 if ($tmpobj->country_id != $this->country_id) {
676 $tmpobj->country_id = $this->country_id;
677 $usermustbemodified++;
679 if ($tmpobj->email != $this->email) {
680 $tmpobj->email = $this->email;
681 $usermustbemodified++;
683 if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) {
684 $tmpobj->socialnetworks = $this->socialnetworks;
685 $usermustbemodified++;
703 if ($usermustbemodified) {
704 $result = $tmpobj->update($user, 0, 1, 1, 1);
711 if (!$error && !$notrigger) {
724 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
725 $this->
db->rollback();
729 $this->error = $this->
db->lasterror().
' sql='.$sql;
730 $this->
db->rollback();
753 $dn = $conf->global->LDAP_KEY_CONTACTS.
"=".$info[$conf->global->LDAP_KEY_CONTACTS].
",".$conf->global->LDAP_CONTACT_DN;
754 } elseif ($mode == 1) {
755 $dn = $conf->global->LDAP_CONTACT_DN;
756 } elseif ($mode == 2) {
757 $dn = $conf->global->LDAP_KEY_CONTACTS.
"=".$info[$conf->global->LDAP_KEY_CONTACTS];
773 global $conf, $langs;
778 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_CONTACT_OBJECT_CLASS);
783 if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) {
784 $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
786 if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) {
787 $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
789 if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) {
790 $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
794 $info[
"title"] = $this->poste;
796 if ($this->socid > 0) {
798 $soc->fetch($this->socid);
800 $info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name;
801 if ($soc->client == 1) {
802 $info[
"businessCategory"] =
"Customers";
804 if ($soc->client == 2) {
805 $info[
"businessCategory"] =
"Prospects";
807 if ($soc->fournisseur == 1) {
808 $info[
"businessCategory"] =
"Suppliers";
811 if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) {
812 $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
814 if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) {
815 $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
817 if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) {
818 $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
820 if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) {
821 $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
823 if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) {
824 $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
826 if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) {
827 $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
829 if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) {
830 $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
832 if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) {
833 $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
835 if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) {
836 $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
838 if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) {
839 $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
841 if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) {
842 $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
845 if ($conf->global->LDAP_SERVER_TYPE ==
'egroupware') {
846 $info[
"objectclass"][4] =
"phpgwContact";
848 $info[
'uidnumber'] = $this->id;
850 $info[
'phpgwTz'] = 0;
851 $info[
'phpgwMailType'] =
'INTERNET';
852 $info[
'phpgwMailHomeType'] =
'INTERNET';
854 $info[
"phpgwContactTypeId"] =
'n';
855 $info[
"phpgwContactCatId"] = 0;
856 $info[
"phpgwContactAccess"] =
"public";
859 $this->egroupware_id = 1;
862 $info[
"phpgwContactOwner"] = $this->egroupware_id;
865 $info[
"rfc822Mailbox"] = $this->email;
867 if ($this->phone_mobile) {
868 $info[
"phpgwCellTelephoneNumber"] = $this->phone_mobile;
894 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
895 $sql .=
" birthday = ".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
896 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
898 $sql .=
", fk_user_modif = ".((int) $user->id);
900 $sql .=
" WHERE rowid = ".((int) $id);
902 dol_syslog(get_class($this).
"::update_perso this->birthday=".$this->birthday.
" -", LOG_DEBUG);
906 $this->error = $this->
db->lasterror();
911 if (!empty($this->birthday_alert)) {
913 $sql_check =
"SELECT rowid FROM " . MAIN_DB_PREFIX .
"user_alert WHERE type = 1 AND fk_contact = " . ((int) $id) .
" AND fk_user = " . ((int) $user->id);
914 $result_check = $this->
db->query($sql_check);
915 if (!$result_check || ($this->
db->num_rows($result_check) < 1)) {
917 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"user_alert(type, fk_contact, fk_user) ";
918 $sql .=
"VALUES (1," . ((int) $id) .
"," . ((int) $user->id) .
")";
919 $result = $this->
db->query($sql);
922 $this->error = $this->
db->lasterror();
928 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"user_alert ";
929 $sql .=
"WHERE type=1 AND fk_contact=" . ((int) $id) .
" AND fk_user=" . ((int) $user->id);
930 $result = $this->
db->query($sql);
933 $this->error = $this->
db->lasterror();
938 if (!$error && !$notrigger) {
951 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
952 $this->
db->rollback();
968 public function fetch($id, $user =
null, $ref_ext =
'', $email =
'', $loadalsoroles = 0)
972 dol_syslog(get_class($this).
"::fetch id=".$id.
" ref_ext=".$ref_ext.
" email=".$email, LOG_DEBUG);
974 if (empty($id) && empty($ref_ext) && empty($email)) {
975 $this->error =
'BadParameter';
979 $langs->loadLangs(array(
"dict",
"companies"));
981 $sql =
"SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,";
982 $sql .=
" c.address, c.statut, c.zip, c.town,";
983 $sql .=
" c.fk_pays as country_id,";
984 $sql .=
" c.fk_departement as state_id,";
985 $sql .=
" c.birthday,";
986 $sql .=
" c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
987 $sql .=
" c.socialnetworks,";
989 $sql .=
" c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
990 $sql .=
" c.fk_prospectlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,";
991 $sql .=
" c.import_key,";
992 $sql .=
" c.datec as date_creation, c.tms as date_modification,";
993 $sql .=
" co.label as country, co.code as country_code,";
994 $sql .=
" d.nom as state, d.code_departement as state_code,";
995 $sql .=
" u.rowid as user_id, u.login as user_login,";
996 $sql .=
" s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
997 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
998 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON c.fk_pays = co.rowid";
999 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as d ON c.fk_departement = d.rowid";
1000 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON c.rowid = u.fk_socpeople";
1001 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
1002 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
1004 $sql .=
" WHERE c.rowid = ".((int) $id);
1006 $sql .=
" WHERE c.entity IN (".getEntity($this->element).
")";
1008 $sql .=
" AND c.ref_ext = '".$this->db->escape($ref_ext).
"'";
1011 $sql .=
" AND c.email = '".$this->db->escape($email).
"'";
1017 $num = $this->
db->num_rows(
$resql);
1019 $this->error =
'Fetch found several records. Rename one of contact to avoid duplicate.';
1024 $obj = $this->
db->fetch_object(
$resql);
1026 $this->
id = $obj->rowid;
1027 $this->entity = $obj->entity;
1028 $this->
ref = $obj->rowid;
1029 $this->ref_ext = $obj->ref_ext;
1031 $this->civility_code = $obj->civility_code;
1032 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1034 $this->lastname = $obj->lastname;
1035 $this->firstname = $obj->firstname;
1036 $this->address = $obj->address;
1037 $this->zip = $obj->zip;
1038 $this->town = $obj->town;
1040 $this->date_creation = $this->
db->jdate($obj->date_creation);
1041 $this->date_modification = $this->
db->jdate($obj->date_modification);
1043 $this->state_id = $obj->state_id;
1044 $this->state_code = $obj->state_code;
1045 $this->state = $obj->state;
1047 $this->country_id = $obj->country_id;
1048 $this->country_code = $obj->country_id ? $obj->country_code :
'';
1049 $this->country = $obj->country_id ? ($langs->trans(
'Country'.$obj->country_code) !=
'Country'.$obj->country_code ? $langs->transnoentities(
'Country'.$obj->country_code) : $obj->country) :
'';
1051 $this->fk_soc = $obj->fk_soc;
1052 $this->socid = $obj->fk_soc;
1053 $this->socname = $obj->socname;
1054 $this->poste = $obj->poste;
1055 $this->statut = $obj->statut;
1057 $this->fk_prospectlevel = $obj->fk_prospectlevel;
1059 $transcode = $langs->trans(
'StatusProspect'.$obj->fk_stcommcontact);
1060 $libelle = ($transcode !=
'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm);
1061 $this->stcomm_id = $obj->fk_stcommcontact;
1062 $this->statut_commercial = $libelle;
1063 $this->stcomm_picto = $obj->stcomm_picto;
1065 $this->phone_pro = trim($obj->phone);
1066 $this->fax = trim($obj->fax);
1067 $this->phone_perso = trim($obj->phone_perso);
1068 $this->phone_mobile = trim($obj->phone_mobile);
1070 $this->email = $obj->email;
1071 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1072 $this->photo = $obj->photo;
1073 $this->priv = $obj->priv;
1074 $this->mail = $obj->email;
1076 $this->birthday = $this->
db->jdate($obj->birthday);
1077 $this->note = $obj->note_private;
1078 $this->note_private = $obj->note_private;
1079 $this->note_public = $obj->note_public;
1080 $this->default_lang = $obj->default_lang;
1081 $this->user_id = $obj->user_id;
1082 $this->user_login = $obj->user_login;
1083 $this->canvas = $obj->canvas;
1085 $this->import_key = $obj->import_key;
1091 $sql =
"SELECT u.rowid ";
1092 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
1093 $sql .=
" WHERE u.fk_socpeople = ".((int) $this->
id);
1098 $uobj = $this->
db->fetch_object(
$resql);
1100 $this->user_id = $uobj->rowid;
1104 $this->error = $this->
db->error();
1114 $sql =
"SELECT fk_user";
1115 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_alert";
1116 $sql .=
" WHERE fk_user = ".((int) $user->id).
" AND fk_contact = ".((int) $id);
1121 $obj = $this->
db->fetch_object(
$resql);
1123 $this->birthday_alert = 1;
1127 $this->error = $this->
db->error();
1133 if ($loadalsoroles) {
1135 if ($resultRole < 0) {
1142 $this->error = $langs->trans(
"RecordNotFound");
1146 $this->error = $this->
db->error();
1161 unset($this->gender);
1163 if (in_array($this->civility_id, array(
'MR')) || in_array($this->civility_code, array(
'MR'))) {
1164 $this->gender =
'man';
1165 } elseif (in_array($this->civility_id, array(
'MME',
'MLE')) || in_array($this->civility_code, array(
'MME',
'MLE'))) {
1166 $this->gender =
'woman';
1184 $sql =
"SELECT tc.element, count(ec.rowid) as nb";
1185 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1186 $sql .=
" WHERE ec.fk_c_type_contact = tc.rowid";
1187 $sql .=
" AND fk_socpeople = ".((int) $this->
id);
1188 $sql .=
" AND tc.source = 'external'";
1189 $sql .=
" GROUP BY tc.element";
1191 dol_syslog(get_class($this).
"::load_ref_elements", LOG_DEBUG);
1195 while ($obj = $this->
db->fetch_object(
$resql)) {
1197 if ($obj->element ==
'facture') {
1198 $this->ref_facturation = $obj->nb;
1199 } elseif ($obj->element ==
'contrat') {
1200 $this->ref_contrat = $obj->nb;
1201 } elseif ($obj->element ==
'commande') {
1202 $this->ref_commande = $obj->nb;
1203 } elseif ($obj->element ==
'propal') {
1204 $this->ref_propal = $obj->nb;
1211 $this->error = $this->
db->lasterror();
1223 public function delete($notrigger = 0)
1225 global $conf, $langs, $user;
1231 if (!$error && !$notrigger) {
1233 $result = $this->
call_trigger(
'CONTACT_DELETE', $user);
1242 $sql =
"SELECT ec.rowid";
1243 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact ec,";
1244 $sql .=
" ".MAIN_DB_PREFIX.
"c_type_contact tc";
1245 $sql .=
" WHERE ec.fk_socpeople=".((int) $this->
id);
1246 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
1247 $sql .=
" AND tc.source='external'";
1251 $num = $this->
db->num_rows(
$resql);
1254 while ($i < $num && !$error) {
1255 $obj = $this->
db->fetch_object(
$resql);
1257 $sqldel =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_contact";
1258 $sqldel .=
" WHERE rowid = ".((int) $obj->rowid);
1260 $result = $this->
db->query($sqldel);
1263 $this->error = $this->
db->error().
' sql='.$sqldel;
1270 $this->error = $this->
db->error().
' sql='.$sql;
1276 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople = ".((int) $this->
id);
1281 $this->error .= $this->
db->lasterror();
1288 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople = ".((int) $this->
id);
1293 $this->error .= $this->
db->lasterror();
1300 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_contact WHERE fk_socpeople = ".((int) $this->
id);
1305 $this->error .= $this->
db->lasterror();
1311 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"socpeople";
1312 $sql .=
" WHERE rowid = ".((int) $this->
id);
1314 $result = $this->
db->query($sql);
1317 $this->error = $this->
db->error().
' sql='.$sql;
1331 $this->
db->commit();
1334 $this->
db->rollback();
1349 $sql =
"SELECT c.rowid, c.datec as datec, c.fk_user_creat,";
1350 $sql .=
" c.tms as tms, c.fk_user_modif";
1351 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1352 $sql .=
" WHERE c.rowid = ".((int) $id);
1357 $obj = $this->
db->fetch_object(
$resql);
1359 $this->
id = $obj->rowid;
1361 if ($obj->fk_user_creat) {
1362 $cuser =
new User($this->
db);
1363 $cuser->fetch($obj->fk_user_creat);
1364 $this->user_creation = $cuser;
1367 if ($obj->fk_user_modif) {
1368 $muser =
new User($this->
db);
1369 $muser->fetch($obj->fk_user_modif);
1370 $this->user_modification = $muser;
1373 $this->date_creation = $this->
db->jdate($obj->datec);
1374 $this->date_modification = $this->
db->jdate($obj->tms);
1379 print $this->
db->error();
1390 $sql =
"SELECT count(mc.email) as nb";
1391 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"mailing as m";
1392 $sql .=
" WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email).
"' ";
1393 $sql .=
" AND m.entity IN (".getEntity($this->element).
") AND mc.statut NOT IN (-1,0)";
1397 $obj = $this->
db->fetch_object(
$resql);
1403 $this->error = $this->
db->error();
1421 public function getNomUrl($withpicto = 0, $option =
'', $maxlen = 0, $moreparam =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1423 global $conf, $langs, $hookmanager;
1425 $result =
''; $label =
'';
1426 if (!empty($this->photo) && class_exists(
'Form')) {
1427 $label .=
'<div class="photointooltip floatright">';
1428 $label .=
Form::showphoto(
'contact', $this, 0, 40, 0,
'photoref',
'mini', 0);
1433 $label .=
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Contact").
'</u>';
1434 $label .=
' '.$this->getLibStatut(4);
1435 $label .=
'<br><b>'.$langs->trans(
"Name").
':</b> '.$this->
getFullName($langs);
1437 if (!empty($this->poste)) {
1438 $label .=
'<br><b>'.$langs->trans(
"Poste").
':</b> '.$this->poste;
1440 $label .=
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
1441 $phonelist = array();
1442 $country_code = empty($this->country_code) ?
'': $this->country_code;
1443 if ($this->phone_pro) {
1444 $phonelist[] =
dol_print_phone($this->phone_pro, $country_code, $this->
id, 0,
'',
' ',
'phone');
1446 if ($this->phone_mobile) {
1447 $phonelist[] =
dol_print_phone($this->phone_mobile, $country_code, $this->
id, 0,
'',
' ',
'mobile');
1449 if ($this->phone_perso) {
1450 $phonelist[] =
dol_print_phone($this->phone_perso, $country_code, $this->
id, 0,
'',
' ',
'phone');
1452 $label .=
'<br><b>'.$langs->trans(
"Phone").
':</b> '.implode(
' ', $phonelist);
1453 $label .=
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
1455 $url = DOL_URL_ROOT.
'/contact/card.php?id='.$this->id;
1457 if ($option !==
'nolink') {
1459 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1460 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1461 $add_save_lastsearch_values = 1;
1463 if ($add_save_lastsearch_values) {
1464 $url .=
'&save_lastsearch_values=1';
1471 if (empty($notooltip)) {
1472 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1473 $label = $langs->trans(
"ShowContact");
1474 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1476 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1477 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1480 $linkstart =
'<a href="'.$url.
'"';
1481 $linkstart .= $linkclose.
'>';
1484 if ($option ==
'xxx') {
1485 $linkstart =
'<a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$this->
id.$moreparam.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
1489 $result .= $linkstart;
1491 if ($withpicto < 0) {
1492 $result .=
'<!-- picto photo user --><span class="nopadding userimg'.($morecss ?
' '.$morecss :
'').
'">'.
Form::showphoto(
'contact', $this, 0, 0, 0,
'userphoto'.($withpicto == -3 ?
'small' :
''),
'mini', 0, 1).
'</span>';
1494 $result .=
img_object(($notooltip ?
'' : $label), ( $this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1497 if ($withpicto != 2 && $withpicto != -2) {
1500 $result .= $linkend;
1503 $hookmanager->initHooks(array(
'contactdao'));
1504 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1505 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1507 $result = $hookmanager->resPrint;
1509 $result .= $hookmanager->resPrint;
1524 $code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite :
'')));
1529 $langs->load(
"dict");
1530 return $langs->getLabelFromKey($this->
db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
1541 return $this->
LibStatut($this->statut, $mode);
1557 $labelStatus = array(
1558 0 =>
'ActivityCeased',
1561 5 =>
'ActivityCeased',
1563 $labelStatusShort = array(
1564 0 =>
'ActivityCeased',
1567 5 =>
'ActivityCeased',
1570 $statusType =
'status4';
1571 if ($status == 0 || $status == 5) {
1572 $statusType =
'status5';
1575 $label = $langs->transnoentitiesnoconv($labelStatus[$status]);
1576 $labelshort = $langs->transnoentitiesnoconv($labelStatusShort[$status]);
1578 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1593 if ($status ==
'1') {
1594 return $langs->trans(
'ContactPrivate');
1596 return $langs->trans(
'ContactPublic');
1612 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe ORDER BY rowid LIMIT 1";
1615 $obj = $this->
db->fetch_object(
$resql);
1617 $socid = $obj->rowid;
1624 $this->specimen = 1;
1625 $this->lastname =
'DOLIBARR';
1626 $this->firstname =
'SPECIMEN';
1627 $this->address =
'21 jump street';
1628 $this->zip =
'99999';
1629 $this->town =
'MyTown';
1630 $this->country_id = 1;
1631 $this->country_code =
'FR';
1632 $this->country =
'France';
1633 $this->email =
'specimen@specimen.com';
1634 $this->socialnetworks = array(
1635 'skype' =>
'tom.hanson',
1637 $this->phone_pro =
'0909090901';
1638 $this->phone_perso =
'0909090902';
1639 $this->phone_mobile =
'0909090903';
1640 $this->fax =
'0909090909';
1642 $this->note_public =
'This is a comment (public)';
1643 $this->note_private =
'This is a comment (private)';
1645 $this->socid = $socid;
1658 global $conf, $langs, $user;
1663 if ($this->statut == $status) {
1666 $this->statut = $status;
1672 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople";
1673 $sql .=
" SET statut = ".((int) $this->statut);
1674 $sql .=
" WHERE rowid = ".((int) $this->
id);
1675 $result = $this->
db->query($sql);
1677 dol_syslog(get_class($this).
"::setstatus", LOG_DEBUG);
1680 $result = $this->
call_trigger(
'CONTACT_ENABLEDISABLE', $user);
1688 $this->
db->rollback();
1691 $this->
db->commit();
1708 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1709 return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT);
1723 'socpeople',
'societe_contacts'
1742 $sql =
"SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle as label, sc.rowid as contactroleid, sc.fk_soc as socid";
1743 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_contacts as sc, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1744 $sql .=
" WHERE tc.rowid = sc.fk_c_type_contact";
1745 $sql .=
" AND tc.source = 'external' AND tc.active=1";
1746 $sql .=
" AND sc.fk_socpeople = ".((int) $this->
id);
1747 $sql .=
" AND sc.entity IN (".getEntity(
'societe').
')';
1751 $this->roles = array();
1753 $num = $this->
db->num_rows(
$resql);
1755 while ($obj = $this->
db->fetch_object(
$resql)) {
1756 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
1757 $libelle_element = $langs->trans(
'ContactDefault_'.$obj->element);
1758 $this->roles[$obj->contactroleid] = array(
'id'=>$obj->rowid,
'socid'=>$obj->socid,
'element'=>$obj->element,
'source'=>$obj->source,
'code'=>$obj->code,
'label'=>$libelle_element.
' - '.($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->label));
1763 $this->error = $this->
db->lasterror();
1764 $this->errors[] = $this->
db->lasterror();
1767 if (empty($error)) {
1785 if ($element ==
'action') {
1786 $element =
'agenda';
1789 $sql =
"SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
1790 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
1791 $sql .=
", ".MAIN_DB_PREFIX.
"societe_contacts sc";
1792 $sql .=
" WHERE sc.fk_soc =".((int) $this->socid);
1793 $sql .=
" AND sc.fk_c_type_contact=tc.rowid";
1794 $sql .=
" AND tc.element = '".$this->db->escape($element).
"'";
1795 $sql .=
" AND tc.active = 1";
1800 $num = $this->
db->num_rows(
$resql);
1803 $obj = $this->
db->fetch_object(
$resql);
1804 $tab[] = array(
'fk_socpeople'=>$obj->id,
'type_contact'=>$obj->fk_c_type_contact);
1811 $this->error = $this->
db->error();
1830 if (!isset($this->roles)) {
1836 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople=".((int) $this->
id).
" AND entity IN (".
getEntity(
"contact").
")";
1838 $result = $this->
db->query($sql);
1840 $this->errors[] = $this->
db->lasterror().
' sql='.$sql;
1843 if (count($this->roles) > 0) {
1844 foreach ($this->roles as $keyRoles => $valRoles) {
1846 if (is_array($valRoles)) {
1847 $idrole = $valRoles[
'id'];
1849 $idrole = $valRoles;
1853 if (is_array($valRoles)) {
1854 $socid = $valRoles[
'socid'];
1856 $socid = $this->socid;
1860 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_contacts";
1861 $sql .=
" (entity,";
1862 $sql .=
"date_creation,";
1864 $sql .=
"fk_c_type_contact,";
1865 $sql .=
"fk_socpeople) ";
1866 $sql .=
" VALUES (".$conf->entity.
",";
1867 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
1868 $sql .= $socid.
", ";
1869 $sql .= $idrole.
" , ";
1873 $result = $this->
db->query($sql);
1875 $this->errors[] = $this->
db->lasterror().
' sql='.$sql;
1882 if (empty($error)) {
1883 $this->
db->commit();
1886 $this->error = implode(
' ', $this->errors);
1887 $this->
db->rollback();
1902 $sql =
"SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX.
"c_stcommcontact";
1904 $sql .=
" WHERE active = ".((int) $active);
1907 $num = $this->
db->num_rows(
$resql);
1910 $obj = $this->
db->fetch_object(
$resql);
1911 $this->cacheprospectstatus[$obj->id] = array(
'id' => $obj->id,
'code' => $obj->code,
'label' => ($langs->trans(
"ST_".strtoupper($obj->code)) ==
"ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans(
"ST_".strtoupper($obj->code)),
'picto' => $obj->picto);
1937 $lib = $langs->trans(
"ProspectLevel".$fk_prospectlevel);
1939 if ($lib == $langs->trans(
"ProspectLevel".$fk_prospectlevel)) {
1940 $lib = $langs->getLabelFromKey($this->
db, $fk_prospectlevel,
'c_prospectlevel',
'code',
'label');
1955 return $this->
update($this->
id, $user);
1967 return $this->
libProspCommStatut($this->stcomm_id, $mode, $label, $this->stcomm_picto);
1986 $langs->load(
'customers');
1989 if ($statut ==
'-1' || $statut ==
'ST_NO') {
1990 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
1991 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
1992 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
1993 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
1994 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
1995 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
1996 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
1997 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
1998 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2000 return img_action(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label, 0, $picto).
' '.(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label);
2004 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2005 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto);
2006 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2007 return img_action($langs->trans(
"StatusProspect0"), 0, $picto);
2008 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2009 return img_action($langs->trans(
"StatusProspect1"), 1, $picto);
2010 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2011 return img_action($langs->trans(
"StatusProspect2"), 2, $picto);
2012 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2013 return img_action($langs->trans(
"StatusProspect3"), 3, $picto);
2015 return img_action(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label, 0, $picto);
2019 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2020 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
2021 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2022 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
2023 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2024 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
2025 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2026 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
2027 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2028 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2030 return img_action(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label, 0, $picto).
' '.(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label);
2034 return "Error, mode/status not found";
2053 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing', 0).
") AND email = '".$this->
db->escape($this->email).
"'";
2056 $obj = $this->
db->fetch_object(
$resql);
2057 $noemail = $obj->nb;
2058 if (empty($noemail)) {
2059 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"mailing_unsubscribe(email, entity, date_creat) VALUES ('".$this->
db->escape($this->email).
"', ".
getEntity(
'mailing', 0).
", '".$this->
db->idate(
dol_now()).
"')";
2063 $this->error = $this->
db->lasterror();
2064 $this->errors[] = $this->error;
2069 $this->error = $this->
db->lasterror();
2070 $this->errors[] = $this->error;
2073 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = '".$this->
db->escape($this->email).
"' AND entity IN (".
getEntity(
'mailing', 0).
")";
2077 $this->error = $this->
db->lasterror();
2078 $this->errors[] = $this->error;
2082 if (empty($error)) {
2083 $this->no_email = $no_email;
2084 $this->
db->commit();
2087 $this->
db->rollback();
2104 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing').
") AND email = '".$this->
db->escape($this->email).
"'";
2107 $obj = $this->
db->fetch_object(
$resql);
2108 $this->no_email = $obj->nb;
2111 $this->error = $this->
db->lasterror();
2112 $this->errors[] = $this->error;
2129 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2130 $return .=
'<div class="info-box info-box-sm">';
2131 $return .=
'<span class="info-box-icon bg-infobox-action">';
2133 if (property_exists($this,
'photo') && !is_null($this->photo)) {
2134 $return.=
Form::showphoto(
'contact', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
2138 $return .=
'</span>';
2139 $return .=
'<div class="info-box-content">';
2140 $return .=
'<div class="info-box-ref">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</div>';
2142 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
2143 $return .=
'<div class="info-box-ref opacitymedium tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
2153 if (method_exists($this,
'getLibStatut')) {
2154 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(5).
'</div>';
2156 $return .=
'</div>';
2157 $return .=
'</div>';
2158 $return .=
'</div>';
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
deleteExtraFields()
Delete all extra fields values for the current object.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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)
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $mode=0, $extralangcode='')
Return a formated address (part address/zip/town/state) according to country rules.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
img_action($titlealt, $numaction, $picto='')
Show logo action.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.