34require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/commonsocialnetworks.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
50 public $element =
'contact';
55 public $table_element =
'socpeople';
61 public $ismultientitymanaged = 1;
66 public $isextrafieldmanaged = 1;
71 public $picto =
'contact';
101 public $fields = array(
102 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'noteditable'=>1,
'notnull'=> 1,
'index'=>1,
'position'=>1,
'comment'=>
'Id',
'css'=>
'left'),
103 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>3,
'notnull'=>1,
'position'=>30,
'index'=>1),
104 'ref_ext' =>array(
'type'=>
'varchar(255)',
'label'=>
'Ref ext',
'enabled'=>1,
'visible'=>3,
'position'=>35),
105 'civility' =>array(
'type'=>
'varchar(6)',
'label'=>
'Civility',
'enabled'=>1,
'visible'=>3,
'position'=>40),
106 'lastname' =>array(
'type'=>
'varchar(50)',
'label'=>
'Lastname',
'enabled'=>1,
'visible'=>1,
'position'=>45,
'showoncombobox'=>1,
'searchall'=>1),
107 'firstname' =>array(
'type'=>
'varchar(50)',
'label'=>
'Firstname',
'enabled'=>1,
'visible'=>1,
'position'=>50,
'showoncombobox'=>1,
'searchall'=>1),
108 'poste' =>array(
'type'=>
'varchar(80)',
'label'=>
'PostOrFunction',
'enabled'=>1,
'visible'=>-1,
'position'=>52),
109 'address' =>array(
'type'=>
'varchar(255)',
'label'=>
'Address',
'enabled'=>1,
'visible'=>-1,
'position'=>55),
110 'zip' =>array(
'type'=>
'varchar(25)',
'label'=>
'Zip',
'enabled'=>1,
'visible'=>1,
'position'=>60),
111 'town' =>array(
'type'=>
'varchar(50)',
'label'=>
'Town',
'enabled'=>1,
'visible'=>-1,
'position'=>65),
112 'fk_departement' =>array(
'type'=>
'integer',
'label'=>
'Fk departement',
'enabled'=>1,
'visible'=>3,
'position'=>70),
113 'fk_pays' =>array(
'type'=>
'integer',
'label'=>
'Fk pays',
'enabled'=>1,
'visible'=>3,
'position'=>75),
114 'fk_soc' =>array(
'type'=>
'integer',
'label'=>
'ThirdParty',
'enabled'=>1,
'visible'=>1,
'position'=>77,
'searchall'=>1),
115 'birthday' =>array(
'type'=>
'date',
'label'=>
'Birthday',
'enabled'=>1,
'visible'=>-1,
'position'=>80),
116 'phone' =>array(
'type'=>
'varchar(30)',
'label'=>
'Phone',
'enabled'=>1,
'visible'=>1,
'position'=>90,
'searchall'=>1),
117 'phone_perso' =>array(
'type'=>
'varchar(30)',
'label'=>
'PhonePerso',
'enabled'=>1,
'visible'=>-1,
'position'=>95,
'searchall'=>1),
118 'phone_mobile' =>array(
'type'=>
'varchar(30)',
'label'=>
'PhoneMobile',
'enabled'=>1,
'visible'=>1,
'position'=>100,
'searchall'=>1),
119 'fax' =>array(
'type'=>
'varchar(30)',
'label'=>
'Fax',
'enabled'=>1,
'visible'=>-1,
'position'=>105,
'searchall'=>1),
120 'email' =>array(
'type'=>
'varchar(255)',
'label'=>
'Email',
'enabled'=>1,
'visible'=>1,
'position'=>110,
'searchall'=>1),
121 'socialnetworks' =>array(
'type'=>
'text',
'label'=>
'SocialNetworks',
'enabled'=>1,
'visible'=>3,
'position'=>115),
122 'photo' =>array(
'type'=>
'varchar(255)',
'label'=>
'Photo',
'enabled'=>1,
'visible'=>3,
'position'=>170),
123 'priv' =>array(
'type'=>
'smallint(6)',
'label'=>
'ContactVisibility',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>175),
124 'fk_stcommcontact' =>array(
'type'=>
'integer',
'label'=>
'ProspectStatus',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>220),
125 'fk_prospectcontactlevel' =>array(
'type'=>
'varchar(12)',
'label'=>
'ProspectLevel',
'enabled'=>1,
'visible'=>-1,
'position'=>255),
127 'note_private' =>array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>3,
'position'=>195,
'searchall'=>1),
128 'note_public' =>array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>3,
'position'=>200,
'searchall'=>1),
129 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>3,
'position'=>205),
130 'canvas' =>array(
'type'=>
'varchar(32)',
'label'=>
'Canvas',
'enabled'=>1,
'visible'=>3,
'position'=>210),
131 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'position'=>300),
132 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>305),
133 'fk_user_creat' =>array(
'type'=>
'integer',
'label'=>
'UserAuthor',
'enabled'=>1,
'visible'=>3,
'position'=>310),
134 'fk_user_modif' =>array(
'type'=>
'integer',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>3,
'position'=>315),
135 'statut' =>array(
'type'=>
'tinyint(4)',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>500),
136 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-1,
'position'=>1000),
140 public $civility_code;
151 public $egroupware_id;
156 public $birthday_alert;
254 public $socialnetworks;
274 public $phone_mobile;
295 public $default_lang;
300 public $ref_facturation;
310 public $ref_commande;
341 public $cacheprospectstatus = array();
346 public $fk_prospectlevel;
350 public $statut_commercial;
355 public $stcomm_picto;
368 if (!isModEnabled(
'mailing')) {
369 $this->fields[
'no_email'][
'enabled'] = 0;
373 $this->fields[
'fk_soc'][
'enabled'] = 0;
374 $this->fields[
'fk_soc'][
'searchall'] = 0;
379 $this->fields[
'fk_stcommcontact'][
'enabled'] = 0;
380 $this->fields[
'fk_prospectcontactlevel'][
'enabled'] = 0;
384 foreach ($this->fields as $key => $val) {
385 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
386 unset($this->fields[$key]);
415 global $user, $hookmanager;
420 $sql =
"SELECT count(sp.rowid) as nb";
421 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
422 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
423 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
424 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
425 $sql .=
" WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
428 $sql .=
" ".$clause.
" sp.entity IN (".
getEntity($this->element).
")";
429 $sql .=
" AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat = ".((int) $user->id).
"))";
430 if ($user->socid > 0) {
431 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
434 if (is_object($hookmanager)) {
435 $parameters = array();
436 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
437 $sql .= $hookmanager->resPrint;
440 $resql = $this->db->query($sql);
442 while ($obj = $this->db->fetch_object($resql)) {
443 $this->nb[
"contacts"] = $obj->nb;
445 $this->db->free($resql);
449 $this->error = $this->db->lasterror();
461 public function create($user, $notrigger = 0)
471 $this->lastname = $this->lastname ? trim($this->lastname) : trim($this->
name);
472 $this->firstname = trim($this->firstname);
474 if (empty($this->socid)) {
477 if (empty($this->priv)) {
480 if (empty($this->
statut)) {
484 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
486 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"socpeople (";
489 $sql .=
", lastname";
490 $sql .=
", firstname";
491 $sql .=
", fk_user_creat";
493 $sql .=
", fk_stcommcontact";
498 $sql .=
", import_key";
499 $sql .=
") VALUES (";
500 $sql .=
"'".$this->db->idate($now).
"',";
501 if ($this->socid > 0) {
502 $sql .=
" ".((int) $this->socid).
",";
506 $sql .=
"'".$this->db->escape($this->lastname).
"',";
507 $sql .=
"'".$this->db->escape($this->firstname).
"',";
508 $sql .=
" ".($user->id > 0 ? ((int) $user->id) :
"null").
",";
509 $sql .=
" ".((int) $this->priv).
",";
511 $sql .=
" ".((int) $this->
statut).
",";
512 $sql .=
" ".(!empty($this->canvas) ?
"'".$this->db->escape($this->canvas).
"'" :
"null").
",";
513 $sql .=
" ".((int) $this->entity).
",";
514 $sql .=
"'".$this->db->escape($this->ref_ext).
"',";
515 $sql .=
" ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
518 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
519 $resql = $this->db->query($sql);
521 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"socpeople");
524 $result = $this->
update($this->
id, $user, 1,
'add');
527 $this->error = $this->db->lasterror();
535 $this->error = $this->db->lasterror();
539 if (!$error && !$notrigger) {
552 $this->db->rollback();
553 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
557 $this->error = $this->db->lasterror();
559 $this->db->rollback();
560 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
575 public function update($id, $user =
null, $notrigger = 0, $action =
'update', $nosyncuser = 0)
583 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
586 $this->ref_ext = trim($this->ref_ext);
587 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
588 $this->firstname = trim($this->firstname);
589 $this->email = trim($this->email);
590 $this->phone_pro = trim($this->phone_pro);
591 $this->phone_perso = trim($this->phone_perso);
592 $this->phone_mobile = trim($this->phone_mobile);
593 $this->photo = trim($this->photo);
594 $this->fax = trim($this->fax);
595 $this->zip = (empty($this->zip) ?
'' : trim($this->zip));
596 $this->town = (empty($this->town) ?
'' : trim($this->town));
597 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
598 if (empty($this->
statut)) {
601 if (empty($this->civility_code) && !is_numeric($this->civility_id)) {
602 $this->civility_code = $this->civility_id;
608 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
609 if ($this->socid > 0) {
610 $sql .=
" fk_soc = ".((int) $this->socid).
",";
611 } elseif ($this->socid == -1) {
612 $sql .=
" fk_soc = NULL,";
614 $sql .=
" civility='".$this->db->escape($this->civility_code).
"'";
615 $sql .=
", lastname='".$this->db->escape($this->lastname).
"'";
616 $sql .=
", firstname='".$this->db->escape($this->firstname).
"'";
617 $sql .=
", address='".$this->db->escape($this->address).
"'";
618 $sql .=
", zip='".$this->db->escape($this->zip).
"'";
619 $sql .=
", town='".$this->db->escape($this->town).
"'";
620 $sql .=
", ref_ext = ".(!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"NULL");
621 $sql .=
", fk_pays=".($this->country_id > 0 ? $this->country_id :
'NULL');
622 $sql .=
", fk_departement=".($this->state_id > 0 ? $this->state_id :
'NULL');
623 $sql .=
", poste='".$this->db->escape($this->poste).
"'";
624 $sql .=
", fax='".$this->db->escape($this->fax).
"'";
625 $sql .=
", email='".$this->db->escape($this->email).
"'";
626 $sql .=
", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks)).
"'";
627 $sql .=
", photo='".$this->db->escape($this->photo).
"'";
628 $sql .=
", birthday=".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
629 $sql .=
", note_private = ".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"NULL");
630 $sql .=
", note_public = ".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"NULL");
631 $sql .=
", phone = ".(isset($this->phone_pro) ?
"'".$this->db->escape($this->phone_pro).
"'" :
"NULL");
632 $sql .=
", phone_perso = ".(isset($this->phone_perso) ?
"'".$this->db->escape($this->phone_perso).
"'" :
"NULL");
633 $sql .=
", phone_mobile = ".(isset($this->phone_mobile) ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"NULL");
634 $sql .=
", priv = '".$this->db->escape($this->priv).
"'";
635 $sql .=
", fk_prospectlevel = '".$this->db->escape($this->fk_prospectlevel).
"'";
636 if (isset($this->stcomm_id)) {
637 $sql .=
", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id :
"0");
639 $sql .=
", statut = ".((int) $this->
statut);
640 $sql .=
", fk_user_modif=".($user->id > 0 ?
"'".$this->db->escape($user->id).
"'" :
"NULL");
641 $sql .=
", default_lang=".($this->default_lang ?
"'".$this->db->escape($this->default_lang).
"'" :
"NULL");
642 $sql .=
", entity = ".((int) $this->entity);
643 $sql .=
" WHERE rowid = ".((int) $id);
645 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
646 $result = $this->db->query($sql);
648 unset($this->country_code);
649 unset($this->country);
650 unset($this->state_code);
670 if (!$error && $this->user_id > 0) {
672 $tmpobj =
new User($this->db);
673 $tmpobj->fetch($this->user_id);
674 $usermustbemodified = 0;
675 if ($tmpobj->office_phone != $this->phone_pro) {
676 $tmpobj->office_phone = $this->phone_pro;
677 $usermustbemodified++;
679 if ($tmpobj->office_fax != $this->fax) {
680 $tmpobj->office_fax = $this->fax;
681 $usermustbemodified++;
683 if ($tmpobj->address != $this->address) {
684 $tmpobj->address = $this->address;
685 $usermustbemodified++;
687 if ($tmpobj->town != $this->town) {
688 $tmpobj->town = $this->town;
689 $usermustbemodified++;
691 if ($tmpobj->zip != $this->zip) {
692 $tmpobj->zip = $this->zip;
693 $usermustbemodified++;
695 if ($tmpobj->zip != $this->zip) {
696 $tmpobj->state_id = $this->state_id;
697 $usermustbemodified++;
699 if ($tmpobj->country_id != $this->country_id) {
700 $tmpobj->country_id = $this->country_id;
701 $usermustbemodified++;
703 if ($tmpobj->email != $this->email) {
704 $tmpobj->email = $this->email;
705 $usermustbemodified++;
707 if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) {
708 $tmpobj->socialnetworks = $this->socialnetworks;
709 $usermustbemodified++;
711 if ($usermustbemodified) {
712 $result = $tmpobj->update($user, 0, 1, 1, 1);
719 if (!$error && !$notrigger) {
732 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
733 $this->db->rollback();
737 $this->error = $this->db->lasterror().
' sql='.$sql;
738 $this->db->rollback();
762 } elseif ($mode == 1) {
763 $dn = $conf->global->LDAP_CONTACT_DN;
764 } elseif ($mode == 2) {
781 global $conf, $langs;
802 $info[
"title"] = $this->poste;
804 if ($this->socid > 0) {
806 $soc->fetch($this->socid);
809 if ($soc->client == 1) {
810 $info[
"businessCategory"] =
"Customers";
812 if ($soc->client == 2) {
813 $info[
"businessCategory"] =
"Prospects";
815 if ($soc->fournisseur == 1) {
816 $info[
"businessCategory"] =
"Suppliers";
851 $info[
"objectclass"][4] =
"phpgwContact";
853 $info[
'uidnumber'] = $this->id;
855 $info[
'phpgwTz'] = 0;
856 $info[
'phpgwMailType'] =
'INTERNET';
857 $info[
'phpgwMailHomeType'] =
'INTERNET';
859 $info[
"phpgwContactTypeId"] =
'n';
860 $info[
"phpgwContactCatId"] = 0;
861 $info[
"phpgwContactAccess"] =
"public";
864 $this->egroupware_id = 1;
867 $info[
"phpgwContactOwner"] = $this->egroupware_id;
870 $info[
"rfc822Mailbox"] = $this->email;
872 if ($this->phone_mobile) {
873 $info[
"phpgwCellTelephoneNumber"] = $this->phone_mobile;
899 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
900 $sql .=
" birthday = ".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
901 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
903 $sql .=
", fk_user_modif = ".((int) $user->id);
905 $sql .=
" WHERE rowid = ".((int) $id);
907 dol_syslog(get_class($this).
"::update_perso this->birthday=".$this->birthday.
" -", LOG_DEBUG);
908 $resql = $this->db->query($sql);
911 $this->error = $this->db->lasterror();
916 if (!empty($this->birthday_alert)) {
918 $sql_check =
"SELECT rowid FROM " . MAIN_DB_PREFIX .
"user_alert WHERE type = 1 AND fk_contact = " . ((int) $id) .
" AND fk_user = " . ((int) $user->id);
919 $result_check = $this->db->query($sql_check);
920 if (!$result_check || ($this->db->num_rows($result_check) < 1)) {
922 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"user_alert(type, fk_contact, fk_user) ";
923 $sql .=
"VALUES (1," . ((int) $id) .
"," . ((int) $user->id) .
")";
924 $result = $this->db->query($sql);
927 $this->error = $this->db->lasterror();
933 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"user_alert ";
934 $sql .=
"WHERE type=1 AND fk_contact=" . ((int) $id) .
" AND fk_user=" . ((int) $user->id);
935 $result = $this->db->query($sql);
938 $this->error = $this->db->lasterror();
943 if (!$error && !$notrigger) {
956 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
957 $this->db->rollback();
973 public function fetch($id, $user =
null, $ref_ext =
'', $email =
'', $loadalsoroles = 0)
977 dol_syslog(get_class($this).
"::fetch id=".$id.
" ref_ext=".$ref_ext.
" email=".$email, LOG_DEBUG);
979 if (empty($id) && empty($ref_ext) && empty($email)) {
980 $this->error =
'BadParameter';
984 $langs->loadLangs(array(
"dict",
"companies"));
986 $sql =
"SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,";
987 $sql .=
" c.address, c.statut, c.zip, c.town,";
988 $sql .=
" c.fk_pays as country_id,";
989 $sql .=
" c.fk_departement as state_id,";
990 $sql .=
" c.birthday,";
991 $sql .=
" c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
992 $sql .=
" c.socialnetworks,";
994 $sql .=
" c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
995 $sql .=
" c.fk_prospectlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,";
996 $sql .=
" c.import_key,";
997 $sql .=
" c.datec as date_creation, c.tms as date_modification,";
998 $sql .=
" co.label as country, co.code as country_code,";
999 $sql .=
" d.nom as state, d.code_departement as state_code,";
1000 $sql .=
" u.rowid as user_id, u.login as user_login,";
1001 $sql .=
" s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
1002 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1003 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON c.fk_pays = co.rowid";
1004 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as d ON c.fk_departement = d.rowid";
1005 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON c.rowid = u.fk_socpeople";
1006 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
1007 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
1009 $sql .=
" WHERE c.rowid = ".((int) $id);
1011 $sql .=
" WHERE c.entity IN (".getEntity($this->element).
")";
1013 $sql .=
" AND c.ref_ext = '".$this->db->escape($ref_ext).
"'";
1016 $sql .=
" AND c.email = '".$this->db->escape($email).
"'";
1020 $resql = $this->db->query($sql);
1022 $num = $this->db->num_rows($resql);
1024 $this->error =
'Fetch found several records. Rename one of contact to avoid duplicate.';
1029 $obj = $this->db->fetch_object($resql);
1031 $this->
id = $obj->rowid;
1032 $this->entity = $obj->entity;
1033 $this->
ref = $obj->rowid;
1034 $this->ref_ext = $obj->ref_ext;
1036 $this->civility_code = $obj->civility_code;
1037 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1039 $this->lastname = $obj->lastname;
1040 $this->firstname = $obj->firstname;
1041 $this->address = $obj->address;
1042 $this->zip = $obj->zip;
1043 $this->town = $obj->town;
1045 $this->date_creation = $this->db->jdate($obj->date_creation);
1046 $this->date_modification = $this->db->jdate($obj->date_modification);
1048 $this->state_id = $obj->state_id;
1049 $this->state_code = $obj->state_code;
1050 $this->state = $obj->state;
1052 $this->country_id = $obj->country_id;
1053 $this->country_code = $obj->country_id ? $obj->country_code :
'';
1054 $this->country = $obj->country_id ? ($langs->trans(
'Country'.$obj->country_code) !=
'Country'.$obj->country_code ? $langs->transnoentities(
'Country'.$obj->country_code) : $obj->country) :
'';
1056 $this->fk_soc = $obj->fk_soc;
1057 $this->socid = $obj->fk_soc;
1058 $this->socname = $obj->socname;
1059 $this->poste = $obj->poste;
1060 $this->
statut = $obj->statut;
1062 $this->fk_prospectlevel = $obj->fk_prospectlevel;
1064 $transcode = $langs->trans(
'StatusProspect'.$obj->fk_stcommcontact);
1065 $libelle = ($transcode !=
'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm);
1066 $this->stcomm_id = $obj->fk_stcommcontact;
1067 $this->statut_commercial = $libelle;
1068 $this->stcomm_picto = $obj->stcomm_picto;
1070 $this->phone_pro = trim($obj->phone);
1071 $this->fax = trim($obj->fax);
1072 $this->phone_perso = trim($obj->phone_perso);
1073 $this->phone_mobile = trim($obj->phone_mobile);
1075 $this->email = $obj->email;
1076 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1077 $this->photo = $obj->photo;
1078 $this->priv = $obj->priv;
1079 $this->mail = $obj->email;
1081 $this->birthday = $this->db->jdate($obj->birthday);
1082 $this->note = $obj->note_private;
1083 $this->note_private = $obj->note_private;
1084 $this->note_public = $obj->note_public;
1085 $this->default_lang = $obj->default_lang;
1086 $this->user_id = $obj->user_id;
1087 $this->user_login = $obj->user_login;
1088 $this->canvas = $obj->canvas;
1090 $this->import_key = $obj->import_key;
1096 $sql =
"SELECT u.rowid ";
1097 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
1098 $sql .=
" WHERE u.fk_socpeople = ".((int) $this->
id);
1100 $resql = $this->db->query($sql);
1102 if ($this->db->num_rows($resql)) {
1103 $uobj = $this->db->fetch_object($resql);
1105 $this->user_id = $uobj->rowid;
1107 $this->db->free($resql);
1109 $this->error = $this->db->error();
1119 $sql =
"SELECT fk_user";
1120 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_alert";
1121 $sql .=
" WHERE fk_user = ".((int) $user->id).
" AND fk_contact = ".((int) $id);
1123 $resql = $this->db->query($sql);
1125 if ($this->db->num_rows($resql)) {
1126 $obj = $this->db->fetch_object($resql);
1128 $this->birthday_alert = 1;
1130 $this->db->free($resql);
1132 $this->error = $this->db->error();
1138 if ($loadalsoroles) {
1140 if ($resultRole < 0) {
1147 $this->error = $langs->trans(
"RecordNotFound");
1151 $this->error = $this->db->error();
1166 unset($this->gender);
1168 if (in_array($this->civility_id, array(
'MR')) || in_array($this->civility_code, array(
'MR'))) {
1169 $this->gender =
'man';
1170 } elseif (in_array($this->civility_id, array(
'MME',
'MLE')) || in_array($this->civility_code, array(
'MME',
'MLE'))) {
1171 $this->gender =
'woman';
1189 $sql =
"SELECT tc.element, count(ec.rowid) as nb";
1190 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1191 $sql .=
" WHERE ec.fk_c_type_contact = tc.rowid";
1192 $sql .=
" AND fk_socpeople = ".((int) $this->
id);
1193 $sql .=
" AND tc.source = 'external'";
1194 $sql .=
" GROUP BY tc.element";
1196 dol_syslog(get_class($this).
"::load_ref_elements", LOG_DEBUG);
1198 $resql = $this->db->query($sql);
1200 while ($obj = $this->db->fetch_object($resql)) {
1202 if ($obj->element ==
'facture') {
1203 $this->ref_facturation = $obj->nb;
1204 } elseif ($obj->element ==
'contrat') {
1205 $this->ref_contrat = $obj->nb;
1206 } elseif ($obj->element ==
'commande') {
1207 $this->ref_commande = $obj->nb;
1208 } elseif ($obj->element ==
'propal') {
1209 $this->ref_propal = $obj->nb;
1213 $this->db->free($resql);
1216 $this->error = $this->db->lasterror();
1228 public function delete($user, $notrigger = 0)
1234 if (!$error && !$notrigger) {
1236 $result = $this->
call_trigger(
'CONTACT_DELETE', $user);
1245 $sql =
"SELECT ec.rowid";
1246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact ec,";
1247 $sql .=
" ".MAIN_DB_PREFIX.
"c_type_contact tc";
1248 $sql .=
" WHERE ec.fk_socpeople=".((int) $this->
id);
1249 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
1250 $sql .=
" AND tc.source='external'";
1252 $resql = $this->db->query($sql);
1254 $num = $this->db->num_rows($resql);
1257 while ($i < $num && !$error) {
1258 $obj = $this->db->fetch_object($resql);
1260 $sqldel =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_contact";
1261 $sqldel .=
" WHERE rowid = ".((int) $obj->rowid);
1263 $result = $this->db->query($sqldel);
1266 $this->error = $this->db->error().
' sql='.$sqldel;
1273 $this->error = $this->db->error().
' sql='.$sql;
1279 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople = ".((int) $this->
id);
1281 $resql = $this->db->query($sql);
1284 $this->error .= $this->db->lasterror();
1291 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_contact WHERE fk_socpeople = ".((int) $this->
id);
1293 $resql = $this->db->query($sql);
1296 $this->error .= $this->db->lasterror();
1302 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"socpeople";
1303 $sql .=
" WHERE rowid = ".((int) $this->
id);
1305 $result = $this->db->query($sql);
1308 $this->error = $this->db->error().
' sql='.$sql;
1322 $this->db->commit();
1325 $this->db->rollback();
1340 $sql =
"SELECT c.rowid, c.datec as datec, c.fk_user_creat,";
1341 $sql .=
" c.tms as tms, c.fk_user_modif";
1342 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1343 $sql .=
" WHERE c.rowid = ".((int) $id);
1345 $resql = $this->db->query($sql);
1347 if ($this->db->num_rows($resql)) {
1348 $obj = $this->db->fetch_object($resql);
1350 $this->
id = $obj->rowid;
1352 $this->user_creation_id = $obj->fk_user_creat;
1353 $this->user_modification_id = $obj->fk_user_modif;
1354 $this->date_creation = $this->db->jdate($obj->datec);
1355 $this->date_modification = $this->db->jdate($obj->tms);
1358 $this->db->free($resql);
1360 print $this->db->error();
1371 $sql =
"SELECT count(mc.email) as nb";
1372 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"mailing as m";
1373 $sql .=
" WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email).
"' ";
1374 $sql .=
" AND m.entity IN (".getEntity($this->element).
") AND mc.statut NOT IN (-1,0)";
1376 $resql = $this->db->query($sql);
1378 $obj = $this->db->fetch_object($resql);
1381 $this->db->free($resql);
1384 $this->error = $this->db->error();
1397 global $conf, $langs, $user;
1402 return [
'optimize' => $langs->trans(
"ShowContact")];
1404 if (!empty($this->photo) && class_exists(
'Form')) {
1405 $photo =
'<div class="photointooltip floatright">';
1406 $photo .=
Form::showphoto(
'contact', $this, 0, 40, 0,
'photoref',
'mini', 0);
1408 $datas[
'photo'] = $photo;
1411 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Contact").
'</u> ' . $this->
getLibStatut(4);
1412 $datas[
'name'] =
'<br><b>'.$langs->trans(
"Name").
':</b> '.$this->
getFullName($langs);
1414 if (!empty($this->poste)) {
1415 $datas[
'job'] =
'<br><b>'.$langs->trans(
"Poste").
':</b> '.$this->poste;
1417 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
1418 $phonelist = array();
1419 $country_code = empty($this->country_code) ?
'' : $this->country_code;
1420 if ($this->phone_pro) {
1421 $phonelist[] =
dol_print_phone($this->phone_pro, $country_code, $this->
id, 0,
'',
' ',
'phone');
1423 if ($this->phone_mobile) {
1424 $phonelist[] =
dol_print_phone($this->phone_mobile, $country_code, $this->
id, 0,
'',
' ',
'mobile');
1426 if ($this->phone_perso) {
1427 $phonelist[] =
dol_print_phone($this->phone_perso, $country_code, $this->
id, 0,
'',
' ',
'phone');
1429 $datas[
'phonelist'] =
'<br><b>'.$langs->trans(
"Phone").
':</b> '.implode(
' ', $phonelist);
1430 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
1448 public function getNomUrl($withpicto = 0, $option =
'', $maxlen = 0, $moreparam =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1450 global $conf, $langs, $hookmanager;
1452 if (!empty($conf->dol_no_mouse_hover)) {
1459 'objecttype' => $this->element,
1460 'option' => $option,
1462 $classfortooltip =
'classfortooltip';
1465 $classfortooltip =
'classforajaxtooltip';
1466 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1472 $url = DOL_URL_ROOT.
'/contact/card.php?id='.$this->id;
1474 if ($option !==
'nolink') {
1476 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1477 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1478 $add_save_lastsearch_values = 1;
1480 if ($url && $add_save_lastsearch_values) {
1481 $url .=
'&save_lastsearch_values=1';
1488 if (empty($notooltip)) {
1490 $label = $langs->trans(
"ShowContact");
1491 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1493 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1494 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1496 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1499 if ($option ==
'nolink' || empty($url)) {
1500 $linkstart =
'<span';
1502 $linkstart =
'<a href="'.$url.
'"';
1504 $linkstart .= $linkclose.
'>';
1505 if ($option ==
'nolink' || empty($url)) {
1506 $linkend =
'</span>';
1511 $result .= $linkstart;
1514 if ($withpicto < 0) {
1515 $result .=
'<!-- picto photo contact --><span class="nopadding userimg'.($morecss ?
' '.$morecss :
'').
'">'.
Form::showphoto(
'contact', $this, 0, 0, 0,
'userphoto'.($withpicto == -3 ?
'small' :
''),
'mini', 0, 1).
'</span>';
1516 if ($withpicto != 2 && $withpicto != -2) {
1520 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="pictofixedwidth"' :
'') :
'class="'.(($withpicto != 2) ?
'pictofixedwidth ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1523 if ($withpicto != 2 && $withpicto != -2) {
1527 $result .= $linkend;
1530 $hookmanager->initHooks(array(
'contactdao'));
1531 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1532 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1534 $result = $hookmanager->resPrint;
1536 $result .= $hookmanager->resPrint;
1551 $code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite :
'')));
1556 $langs->load(
"dict");
1557 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
1584 $labelStatus = array(
1585 0 =>
'ActivityCeased',
1588 5 =>
'ActivityCeased',
1590 $labelStatusShort = array(
1591 0 =>
'ActivityCeased',
1594 5 =>
'ActivityCeased',
1597 $statusType =
'status4';
1598 if ($status == 0 || $status == 5) {
1599 $statusType =
'status5';
1602 $label = $langs->transnoentitiesnoconv($labelStatus[$status]);
1603 $labelshort = $langs->transnoentitiesnoconv($labelStatusShort[$status]);
1605 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1620 if ($status ==
'1') {
1621 return $langs->trans(
'ContactPrivate');
1623 return $langs->trans(
'ContactPublic');
1639 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe ORDER BY rowid LIMIT 1";
1640 $resql = $this->db->query($sql);
1642 $obj = $this->db->fetch_object($resql);
1644 $socid = $obj->rowid;
1651 $this->specimen = 1;
1652 $this->lastname =
'DOLIBARR';
1653 $this->firstname =
'SPECIMEN';
1654 $this->address =
'21 jump street';
1655 $this->zip =
'99999';
1656 $this->town =
'MyTown';
1657 $this->country_id = 1;
1658 $this->country_code =
'FR';
1659 $this->country =
'France';
1660 $this->email =
'specimen@specimen.com';
1661 $this->socialnetworks = array(
1662 'skype' =>
'tom.hanson',
1663 'twitter' =>
'tomhanson',
1664 'linkedin' =>
'tomhanson',
1666 $this->phone_pro =
'0909090901';
1667 $this->phone_perso =
'0909090902';
1668 $this->phone_mobile =
'0909090903';
1669 $this->fax =
'0909090909';
1671 $this->note_public =
'This is a comment (public)';
1672 $this->note_private =
'This is a comment (private)';
1674 $this->socid = $socid;
1687 global $conf, $langs, $user;
1692 if ($this->
statut == $status) {
1701 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople";
1702 $sql .=
" SET statut = ".((int) $this->
statut);
1703 $sql .=
", fk_user_modif = ".((int) $user->id);
1704 $sql .=
" WHERE rowid = ".((int) $this->
id);
1705 $result = $this->db->query($sql);
1707 dol_syslog(get_class($this).
"::setstatus", LOG_DEBUG);
1710 $result = $this->
call_trigger(
'CONTACT_ENABLEDISABLE', $user);
1718 $this->db->rollback();
1721 $this->db->commit();
1738 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1739 return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT);
1753 'socpeople',
'societe_contacts'
1772 $sql =
"SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle as label, sc.rowid as contactroleid, sc.fk_soc as socid";
1773 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_contacts as sc, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1774 $sql .=
" WHERE tc.rowid = sc.fk_c_type_contact";
1775 $sql .=
" AND tc.source = 'external' AND tc.active=1";
1776 $sql .=
" AND sc.fk_socpeople = ".((int) $this->
id);
1777 $sql .=
" AND sc.entity IN (".getEntity(
'societe').
')';
1779 $resql = $this->db->query($sql);
1781 $this->roles = array();
1783 $num = $this->db->num_rows($resql);
1785 while ($obj = $this->db->fetch_object($resql)) {
1786 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
1787 $libelle_element = $langs->trans(
'ContactDefault_'.$obj->element);
1788 $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));
1793 $this->error = $this->db->lasterror();
1794 $this->errors[] = $this->db->lasterror();
1797 if (empty($error)) {
1815 if ($element ==
'action') {
1816 $element =
'agenda';
1819 $sql =
"SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
1820 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
1821 $sql .=
", ".MAIN_DB_PREFIX.
"societe_contacts sc";
1822 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"socpeople sp";
1823 $sql .=
" ON sc.fk_socpeople = sp.rowid AND sp.statut = 1";
1824 $sql .=
" WHERE sc.fk_soc =".((int) $this->socid);
1825 $sql .=
" AND sc.fk_c_type_contact=tc.rowid";
1826 $sql .=
" AND tc.element = '".$this->db->escape($element).
"'";
1827 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1828 $sql .=
" AND tc.active = 1";
1831 $resql = $this->db->query($sql);
1833 $num = $this->db->num_rows($resql);
1836 $obj = $this->db->fetch_object($resql);
1837 $tab[] = array(
'fk_socpeople'=>$obj->id,
'type_contact'=>$obj->fk_c_type_contact);
1844 $this->error = $this->db->error();
1863 if (!isset($this->roles)) {
1869 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople=".((int) $this->
id).
" AND entity IN (".
getEntity(
"contact").
")";
1871 $result = $this->db->query($sql);
1873 $this->errors[] = $this->db->lasterror().
' sql='.$sql;
1876 if (count($this->roles) > 0) {
1877 foreach ($this->roles as $keyRoles => $valRoles) {
1879 if (is_array($valRoles)) {
1880 $idrole = $valRoles[
'id'];
1882 $idrole = $valRoles;
1886 if (is_array($valRoles)) {
1887 $socid = $valRoles[
'socid'];
1889 $socid = $this->socid;
1893 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_contacts";
1894 $sql .=
" (entity,";
1895 $sql .=
"date_creation,";
1897 $sql .=
"fk_c_type_contact,";
1898 $sql .=
"fk_socpeople) ";
1899 $sql .=
" VALUES (".$conf->entity.
",";
1900 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
1901 $sql .= $socid.
", ";
1902 $sql .= $idrole.
" , ";
1906 $result = $this->db->query($sql);
1908 $this->errors[] = $this->db->lasterror().
' sql='.$sql;
1915 if (empty($error)) {
1916 $this->db->commit();
1919 $this->error = implode(
' ', $this->errors);
1920 $this->db->rollback();
1935 $sql =
"SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX.
"c_stcommcontact";
1937 $sql .=
" WHERE active = ".((int) $active);
1939 $resql = $this->db->query($sql);
1940 $num = $this->db->num_rows($resql);
1943 $obj = $this->db->fetch_object($resql);
1944 $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);
1970 $lib = $langs->trans(
"ProspectLevel".$fk_prospectlevel);
1972 if ($lib ==
"ProspectLevel".$fk_prospectlevel) {
1973 $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel,
'c_prospectlevel',
'code',
'label');
1988 return $this->
update($this->
id, $user);
2000 return $this->
libProspCommStatut($this->stcomm_id, $mode, $label, $this->stcomm_picto);
2019 $langs->load(
'customers');
2022 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2023 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
2024 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2025 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
2026 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2027 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
2028 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2029 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
2030 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2031 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2033 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);
2037 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2038 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto);
2039 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2040 return img_action($langs->trans(
"StatusProspect0"), 0, $picto);
2041 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2042 return img_action($langs->trans(
"StatusProspect1"), 1, $picto);
2043 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2044 return img_action($langs->trans(
"StatusProspect2"), 2, $picto);
2045 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2046 return img_action($langs->trans(
"StatusProspect3"), 3, $picto);
2048 return img_action(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label, 0, $picto);
2052 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2053 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
2054 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2055 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
2056 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2057 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
2058 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2059 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
2060 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2061 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2063 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);
2067 return "Error, mode/status not found";
2086 $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).
"'";
2087 $resql = $this->db->query($sql);
2089 $obj = $this->db->fetch_object($resql);
2090 $noemail = $obj->nb;
2091 if (empty($noemail)) {
2092 $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()).
"')";
2093 $resql = $this->db->query($sql);
2096 $this->error = $this->db->lasterror();
2097 $this->errors[] = $this->error;
2102 $this->error = $this->db->lasterror();
2103 $this->errors[] = $this->error;
2106 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = '".$this->db->escape($this->email).
"' AND entity IN (".
getEntity(
'mailing', 0).
")";
2107 $resql = $this->db->query($sql);
2110 $this->error = $this->db->lasterror();
2111 $this->errors[] = $this->error;
2115 if (empty($error)) {
2116 $this->no_email = $no_email;
2117 $this->db->commit();
2120 $this->db->rollback();
2137 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing').
") AND email = '".$this->db->escape($this->email).
"'";
2138 $resql = $this->db->query($sql);
2140 $obj = $this->db->fetch_object($resql);
2141 $this->no_email = $obj->nb;
2144 $this->error = $this->db->lasterror();
2145 $this->errors[] = $this->error;
2162 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2164 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2165 $return .=
'<div class="info-box info-box-sm">';
2166 $return .=
'<span class="info-box-icon bg-infobox-action">';
2168 if (property_exists($this,
'photo') && !is_null($this->photo)) {
2169 $return.=
Form::showphoto(
'contact', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
2173 $return .=
'</span>';
2174 $return .=
'<div class="info-box-content">';
2175 $return .=
'<div class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</div>';
2176 if ($selected >= 0) {
2177 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2179 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
2180 $return .=
'<div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
2190 if (method_exists($this,
'getLibStatut')) {
2191 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
2193 $return .=
'</div>';
2194 $return .=
'</div>';
2195 $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...
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.
trait CommonPeople
Superclass for thirdparties, contacts, members or users.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
trait CommonSocialNetworks
Superclass for social networks.
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.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e e e e e statut
$conf db name
Only used if Module[ID]Name translation string is not found.