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_prospectcontactlevel' =>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;
211 public $socialnetworks;
266 public $phone_mobile;
280 public $default_lang;
285 public $ref_facturation;
295 public $ref_commande;
326 public $cacheprospectstatus = array();
327 public $fk_prospectlevel;
329 public $statut_commercial;
334 public $stcomm_picto;
344 global $conf, $langs;
349 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
350 $this->fields[
'rowid'][
'visible'] = 0;
353 $this->fields[
'no_email'][
'enabled'] = 0;
356 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
357 $this->fields[
'fk_soc'][
'enabled'] = 0;
358 $this->fields[
'fk_soc'][
'searchall'] = 0;
361 if (empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
362 $this->fields[
'fk_stcommcontact'][
'enabled'] = 0;
363 $this->fields[
'fk_prospectcontactlevel'][
'enabled'] = 0;
367 foreach ($this->fields as $key => $val) {
368 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
369 unset($this->fields[$key]);
398 global $user, $hookmanager;
403 $sql =
"SELECT count(sp.rowid) as nb";
404 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
405 if (empty($user->rights->societe->client->voir) && !$user->socid) {
406 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
407 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
408 $sql .=
" WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
411 $sql .=
" ".$clause.
" sp.entity IN (".
getEntity($this->element).
")";
412 $sql .=
" AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat = ".((int) $user->id).
"))";
413 if ($user->socid > 0) {
414 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
417 if (is_object($hookmanager)) {
418 $parameters = array();
419 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
420 $sql .= $hookmanager->resPrint;
425 while ($obj = $this->
db->fetch_object(
$resql)) {
426 $this->nb[
"contacts"] = $obj->nb;
432 $this->error = $this->
db->lasterror();
444 public function create($user, $notrigger = 0)
454 $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->
name);
455 $this->firstname = trim($this->firstname);
457 if (empty($this->socid)) {
460 if (empty($this->priv)) {
463 if (empty($this->statut)) {
467 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
469 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"socpeople (";
472 $sql .=
", lastname";
473 $sql .=
", firstname";
474 $sql .=
", fk_user_creat";
476 $sql .=
", fk_stcommcontact";
481 $sql .=
", import_key";
482 $sql .=
") VALUES (";
483 $sql .=
"'".$this->db->idate($now).
"',";
484 if ($this->socid > 0) {
485 $sql .=
" ".((int) $this->socid).
",";
489 $sql .=
"'".$this->db->escape($this->lastname).
"',";
490 $sql .=
"'".$this->db->escape($this->firstname).
"',";
491 $sql .=
" ".($user->id > 0 ? ((int) $user->id) :
"null").
",";
492 $sql .=
" ".((int) $this->priv).
",";
494 $sql .=
" ".((int) $this->statut).
",";
495 $sql .=
" ".(!empty($this->canvas) ?
"'".$this->db->escape($this->canvas).
"'" :
"null").
",";
496 $sql .=
" ".((int) $this->entity).
",";
497 $sql .=
"'".$this->db->escape($this->ref_ext).
"',";
498 $sql .=
" ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
501 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
504 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"socpeople");
507 $result = $this->
update($this->
id, $user, 1,
'add');
510 $this->error = $this->
db->lasterror();
518 $this->error = $this->
db->lasterror();
522 if (!$error && !$notrigger) {
535 $this->
db->rollback();
536 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
540 $this->error = $this->
db->lasterror();
542 $this->
db->rollback();
543 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
558 public function update($id, $user =
null, $notrigger = 0, $action =
'update', $nosyncuser = 0)
560 global $conf, $langs, $hookmanager;
566 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
569 $this->ref_ext = trim($this->ref_ext);
570 $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname);
571 $this->firstname = trim($this->firstname);
572 $this->email = trim($this->email);
573 $this->phone_pro = trim($this->phone_pro);
574 $this->phone_perso = trim($this->phone_perso);
575 $this->phone_mobile = trim($this->phone_mobile);
576 $this->photo = trim($this->photo);
577 $this->fax = trim($this->fax);
578 $this->zip = (empty($this->zip) ?
'' : trim($this->zip));
579 $this->town = (empty($this->town) ?
'' : trim($this->town));
580 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
581 if (empty($this->statut)) {
584 if (empty($this->civility_code) && !is_numeric($this->civility_id)) {
585 $this->civility_code = $this->civility_id;
590 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
591 if ($this->socid > 0) {
592 $sql .=
" fk_soc = ".((int) $this->socid).
",";
593 } elseif ($this->socid == -1) {
594 $sql .=
" fk_soc = NULL,";
596 $sql .=
" civility='".$this->db->escape($this->civility_code).
"'";
597 $sql .=
", lastname='".$this->db->escape($this->lastname).
"'";
598 $sql .=
", firstname='".$this->db->escape($this->firstname).
"'";
599 $sql .=
", address='".$this->db->escape($this->address).
"'";
600 $sql .=
", zip='".$this->db->escape($this->zip).
"'";
601 $sql .=
", town='".$this->db->escape($this->town).
"'";
602 $sql .=
", ref_ext = ".(!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"NULL");
603 $sql .=
", fk_pays=".($this->country_id > 0 ? $this->country_id :
'NULL');
604 $sql .=
", fk_departement=".($this->state_id > 0 ? $this->state_id :
'NULL');
605 $sql .=
", poste='".$this->db->escape($this->poste).
"'";
606 $sql .=
", fax='".$this->db->escape($this->fax).
"'";
607 $sql .=
", email='".$this->db->escape($this->email).
"'";
608 $sql .=
", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks)).
"'";
609 $sql .=
", photo='".$this->db->escape($this->photo).
"'";
610 $sql .=
", birthday=".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
611 $sql .=
", note_private = ".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"NULL");
612 $sql .=
", note_public = ".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"NULL");
613 $sql .=
", phone = ".(isset($this->phone_pro) ?
"'".$this->db->escape($this->phone_pro).
"'" :
"NULL");
614 $sql .=
", phone_perso = ".(isset($this->phone_perso) ?
"'".$this->db->escape($this->phone_perso).
"'" :
"NULL");
615 $sql .=
", phone_mobile = ".(isset($this->phone_mobile) ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"NULL");
616 $sql .=
", priv = '".$this->db->escape($this->priv).
"'";
617 $sql .=
", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel).
"'";
618 if (isset($this->stcomm_id)) {
619 $sql .=
", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id :
"0");
621 $sql .=
", statut = ".((int) $this->statut);
622 $sql .=
", fk_user_modif=".($user->id > 0 ?
"'".$this->db->escape($user->id).
"'" :
"NULL");
623 $sql .=
", default_lang=".($this->default_lang ?
"'".$this->db->escape($this->default_lang).
"'" :
"NULL");
624 $sql .=
", entity = ".((int) $this->entity);
625 $sql .=
" WHERE rowid = ".((int) $id);
627 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
628 $result = $this->
db->query($sql);
630 unset($this->country_code);
631 unset($this->country);
632 unset($this->state_code);
652 if (!$error && $this->user_id > 0) {
654 $tmpobj =
new User($this->
db);
655 $tmpobj->fetch($this->user_id);
656 $usermustbemodified = 0;
657 if ($tmpobj->office_phone != $this->phone_pro) {
658 $tmpobj->office_phone = $this->phone_pro;
659 $usermustbemodified++;
661 if ($tmpobj->office_fax != $this->fax) {
662 $tmpobj->office_fax = $this->fax;
663 $usermustbemodified++;
665 if ($tmpobj->address != $this->address) {
666 $tmpobj->address = $this->address;
667 $usermustbemodified++;
669 if ($tmpobj->town != $this->town) {
670 $tmpobj->town = $this->town;
671 $usermustbemodified++;
673 if ($tmpobj->zip != $this->zip) {
674 $tmpobj->zip = $this->zip;
675 $usermustbemodified++;
677 if ($tmpobj->zip != $this->zip) {
678 $tmpobj->state_id = $this->state_id;
679 $usermustbemodified++;
681 if ($tmpobj->country_id != $this->country_id) {
682 $tmpobj->country_id = $this->country_id;
683 $usermustbemodified++;
685 if ($tmpobj->email != $this->email) {
686 $tmpobj->email = $this->email;
687 $usermustbemodified++;
689 if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) {
690 $tmpobj->socialnetworks = $this->socialnetworks;
691 $usermustbemodified++;
709 if ($usermustbemodified) {
710 $result = $tmpobj->update($user, 0, 1, 1, 1);
717 if (!$error && !$notrigger) {
730 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
731 $this->
db->rollback();
735 $this->error = $this->
db->lasterror().
' sql='.$sql;
736 $this->
db->rollback();
759 $dn = $conf->global->LDAP_KEY_CONTACTS.
"=".$info[$conf->global->LDAP_KEY_CONTACTS].
",".$conf->global->LDAP_CONTACT_DN;
760 } elseif ($mode == 1) {
761 $dn = $conf->global->LDAP_CONTACT_DN;
762 } elseif ($mode == 2) {
763 $dn = $conf->global->LDAP_KEY_CONTACTS.
"=".$info[$conf->global->LDAP_KEY_CONTACTS];
779 global $conf, $langs;
784 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_CONTACT_OBJECT_CLASS);
789 if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) {
790 $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
792 if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) {
793 $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
795 if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) {
796 $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
800 $info[
"title"] = $this->poste;
802 if ($this->socid > 0) {
804 $soc->fetch($this->socid);
806 $info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name;
807 if ($soc->client == 1) {
808 $info[
"businessCategory"] =
"Customers";
810 if ($soc->client == 2) {
811 $info[
"businessCategory"] =
"Prospects";
813 if ($soc->fournisseur == 1) {
814 $info[
"businessCategory"] =
"Suppliers";
817 if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) {
818 $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
820 if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) {
821 $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
823 if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) {
824 $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
826 if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) {
827 $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
829 if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) {
830 $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
832 if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) {
833 $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
835 if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) {
836 $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
838 if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) {
839 $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
841 if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) {
842 $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
844 if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) {
845 $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
847 if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) {
848 $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
851 if ($conf->global->LDAP_SERVER_TYPE ==
'egroupware') {
852 $info[
"objectclass"][4] =
"phpgwContact";
854 $info[
'uidnumber'] = $this->id;
856 $info[
'phpgwTz'] = 0;
857 $info[
'phpgwMailType'] =
'INTERNET';
858 $info[
'phpgwMailHomeType'] =
'INTERNET';
860 $info[
"phpgwContactTypeId"] =
'n';
861 $info[
"phpgwContactCatId"] = 0;
862 $info[
"phpgwContactAccess"] =
"public";
865 $this->egroupware_id = 1;
868 $info[
"phpgwContactOwner"] = $this->egroupware_id;
871 $info[
"rfc822Mailbox"] = $this->email;
873 if ($this->phone_mobile) {
874 $info[
"phpgwCellTelephoneNumber"] = $this->phone_mobile;
900 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
901 $sql .=
" birthday = ".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
902 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
904 $sql .=
", fk_user_modif = ".((int) $user->id);
906 $sql .=
" WHERE rowid = ".((int) $id);
908 dol_syslog(get_class($this).
"::update_perso this->birthday=".$this->birthday.
" -", LOG_DEBUG);
912 $this->error = $this->
db->lasterror();
917 if (!empty($this->birthday_alert)) {
919 $sql_check =
"SELECT rowid FROM " . MAIN_DB_PREFIX .
"user_alert WHERE type = 1 AND fk_contact = " . ((int) $id) .
" AND fk_user = " . ((int) $user->id);
920 $result_check = $this->
db->query($sql_check);
921 if (!$result_check || ($this->
db->num_rows($result_check) < 1)) {
923 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"user_alert(type, fk_contact, fk_user) ";
924 $sql .=
"VALUES (1," . ((int) $id) .
"," . ((int) $user->id) .
")";
925 $result = $this->
db->query($sql);
928 $this->error = $this->
db->lasterror();
934 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"user_alert ";
935 $sql .=
"WHERE type=1 AND fk_contact=" . ((int) $id) .
" AND fk_user=" . ((int) $user->id);
936 $result = $this->
db->query($sql);
939 $this->error = $this->
db->lasterror();
944 if (!$error && !$notrigger) {
957 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
958 $this->
db->rollback();
974 public function fetch($id, $user =
null, $ref_ext =
'', $email =
'', $loadalsoroles = 0)
978 dol_syslog(get_class($this).
"::fetch id=".$id.
" ref_ext=".$ref_ext.
" email=".$email, LOG_DEBUG);
980 if (empty($id) && empty($ref_ext) && empty($email)) {
981 $this->error =
'BadParameter';
985 $langs->loadLangs(array(
"dict",
"companies"));
987 $sql =
"SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,";
988 $sql .=
" c.address, c.statut, c.zip, c.town,";
989 $sql .=
" c.fk_pays as country_id,";
990 $sql .=
" c.fk_departement as state_id,";
991 $sql .=
" c.birthday,";
992 $sql .=
" c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
993 $sql .=
" c.socialnetworks,";
995 $sql .=
" c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
996 $sql .=
" c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,";
997 $sql .=
" c.import_key,";
998 $sql .=
" c.datec as date_creation, c.tms as date_modification,";
999 $sql .=
" co.label as country, co.code as country_code,";
1000 $sql .=
" d.nom as state, d.code_departement as state_code,";
1001 $sql .=
" u.rowid as user_id, u.login as user_login,";
1002 $sql .=
" s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
1003 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1004 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON c.fk_pays = co.rowid";
1005 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as d ON c.fk_departement = d.rowid";
1006 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON c.rowid = u.fk_socpeople";
1007 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
1008 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
1010 $sql .=
" WHERE c.rowid = ".((int) $id);
1012 $sql .=
" WHERE c.entity IN (".getEntity($this->element).
")";
1014 $sql .=
" AND c.ref_ext = '".$this->db->escape($ref_ext).
"'";
1017 $sql .=
" AND c.email = '".$this->db->escape($email).
"'";
1023 $num = $this->
db->num_rows(
$resql);
1025 $this->error =
'Fetch found several records. Rename one of contact to avoid duplicate.';
1030 $obj = $this->
db->fetch_object(
$resql);
1032 $this->
id = $obj->rowid;
1033 $this->entity = $obj->entity;
1034 $this->
ref = $obj->rowid;
1035 $this->ref_ext = $obj->ref_ext;
1037 $this->civility_code = $obj->civility_code;
1038 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1040 $this->lastname = $obj->lastname;
1041 $this->firstname = $obj->firstname;
1042 $this->address = $obj->address;
1043 $this->zip = $obj->zip;
1044 $this->town = $obj->town;
1046 $this->date_creation = $this->
db->jdate($obj->date_creation);
1047 $this->date_modification = $this->
db->jdate($obj->date_modification);
1049 $this->state_id = $obj->state_id;
1050 $this->state_code = $obj->state_code;
1051 $this->state = $obj->state;
1053 $this->country_id = $obj->country_id;
1054 $this->country_code = $obj->country_id ? $obj->country_code :
'';
1055 $this->country = $obj->country_id ? ($langs->trans(
'Country'.$obj->country_code) !=
'Country'.$obj->country_code ? $langs->transnoentities(
'Country'.$obj->country_code) : $obj->country) :
'';
1057 $this->fk_soc = $obj->fk_soc;
1058 $this->socid = $obj->fk_soc;
1059 $this->socname = $obj->socname;
1060 $this->poste = $obj->poste;
1061 $this->statut = $obj->statut;
1063 $this->fk_prospectlevel = $obj->fk_prospectcontactlevel;
1065 $transcode = $langs->trans(
'StatusProspect'.$obj->fk_stcommcontact);
1066 $libelle = ($transcode !=
'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm);
1067 $this->stcomm_id = $obj->fk_stcommcontact;
1068 $this->statut_commercial = $libelle;
1069 $this->stcomm_picto = $obj->stcomm_picto;
1071 $this->phone_pro = trim($obj->phone);
1072 $this->fax = trim($obj->fax);
1073 $this->phone_perso = trim($obj->phone_perso);
1074 $this->phone_mobile = trim($obj->phone_mobile);
1076 $this->email = $obj->email;
1077 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1078 $this->photo = $obj->photo;
1079 $this->priv = $obj->priv;
1080 $this->mail = $obj->email;
1082 $this->birthday = $this->
db->jdate($obj->birthday);
1083 $this->note = $obj->note_private;
1084 $this->note_private = $obj->note_private;
1085 $this->note_public = $obj->note_public;
1086 $this->default_lang = $obj->default_lang;
1087 $this->user_id = $obj->user_id;
1088 $this->user_login = $obj->user_login;
1089 $this->canvas = $obj->canvas;
1091 $this->import_key = $obj->import_key;
1097 $sql =
"SELECT u.rowid ";
1098 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
1099 $sql .=
" WHERE u.fk_socpeople = ".((int) $this->
id);
1104 $uobj = $this->
db->fetch_object(
$resql);
1106 $this->user_id = $uobj->rowid;
1110 $this->error = $this->
db->error();
1120 $sql =
"SELECT fk_user";
1121 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_alert";
1122 $sql .=
" WHERE fk_user = ".((int) $user->id).
" AND fk_contact = ".((int) $id);
1127 $obj = $this->
db->fetch_object(
$resql);
1129 $this->birthday_alert = 1;
1133 $this->error = $this->
db->error();
1139 if ($loadalsoroles) {
1141 if ($resultRole < 0) {
1148 $this->error = $langs->trans(
"RecordNotFound");
1152 $this->error = $this->
db->error();
1167 unset($this->gender);
1169 if (in_array($this->civility_id, array(
'MR')) || in_array($this->civility_code, array(
'MR'))) {
1170 $this->gender =
'man';
1171 } elseif (in_array($this->civility_id, array(
'MME',
'MLE')) || in_array($this->civility_code, array(
'MME',
'MLE'))) {
1172 $this->gender =
'woman';
1190 $sql =
"SELECT tc.element, count(ec.rowid) as nb";
1191 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1192 $sql .=
" WHERE ec.fk_c_type_contact = tc.rowid";
1193 $sql .=
" AND fk_socpeople = ".((int) $this->
id);
1194 $sql .=
" AND tc.source = 'external'";
1195 $sql .=
" GROUP BY tc.element";
1197 dol_syslog(get_class($this).
"::load_ref_elements", LOG_DEBUG);
1201 while ($obj = $this->
db->fetch_object(
$resql)) {
1203 if ($obj->element ==
'facture') {
1204 $this->ref_facturation = $obj->nb;
1205 } elseif ($obj->element ==
'contrat') {
1206 $this->ref_contrat = $obj->nb;
1207 } elseif ($obj->element ==
'commande') {
1208 $this->ref_commande = $obj->nb;
1209 } elseif ($obj->element ==
'propal') {
1210 $this->ref_propal = $obj->nb;
1217 $this->error = $this->
db->lasterror();
1229 public function delete($notrigger = 0)
1231 global $conf, $langs, $user;
1237 if (!$error && !$notrigger) {
1239 $result = $this->
call_trigger(
'CONTACT_DELETE', $user);
1248 $sql =
"SELECT ec.rowid";
1249 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact ec,";
1250 $sql .=
" ".MAIN_DB_PREFIX.
"c_type_contact tc";
1251 $sql .=
" WHERE ec.fk_socpeople=".((int) $this->
id);
1252 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
1253 $sql .=
" AND tc.source='external'";
1257 $num = $this->
db->num_rows(
$resql);
1260 while ($i < $num && !$error) {
1261 $obj = $this->
db->fetch_object(
$resql);
1263 $sqldel =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_contact";
1264 $sqldel .=
" WHERE rowid = ".((int) $obj->rowid);
1266 $result = $this->
db->query($sqldel);
1269 $this->error = $this->
db->error().
' sql='.$sqldel;
1276 $this->error = $this->
db->error().
' sql='.$sql;
1282 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople = ".((int) $this->
id);
1287 $this->error .= $this->
db->lasterror();
1294 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople = ".((int) $this->
id);
1299 $this->error .= $this->
db->lasterror();
1306 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_contact WHERE fk_socpeople = ".((int) $this->
id);
1311 $this->error .= $this->
db->lasterror();
1317 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"socpeople";
1318 $sql .=
" WHERE rowid = ".((int) $this->
id);
1320 $result = $this->
db->query($sql);
1323 $this->error = $this->
db->error().
' sql='.$sql;
1337 $this->
db->commit();
1340 $this->
db->rollback();
1355 $sql =
"SELECT c.rowid, c.datec as datec, c.fk_user_creat,";
1356 $sql .=
" c.tms as tms, c.fk_user_modif";
1357 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1358 $sql .=
" WHERE c.rowid = ".((int) $id);
1363 $obj = $this->
db->fetch_object(
$resql);
1365 $this->
id = $obj->rowid;
1367 if ($obj->fk_user_creat) {
1368 $cuser =
new User($this->
db);
1369 $cuser->fetch($obj->fk_user_creat);
1370 $this->user_creation = $cuser;
1373 if ($obj->fk_user_modif) {
1374 $muser =
new User($this->
db);
1375 $muser->fetch($obj->fk_user_modif);
1376 $this->user_modification = $muser;
1379 $this->date_creation = $this->
db->jdate($obj->datec);
1380 $this->date_modification = $this->
db->jdate($obj->tms);
1385 print $this->
db->error();
1396 $sql =
"SELECT count(mc.email) as nb";
1397 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"mailing as m";
1398 $sql .=
" WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email).
"' ";
1399 $sql .=
" AND m.entity IN (".getEntity($this->element).
") AND mc.statut NOT IN (-1,0)";
1403 $obj = $this->
db->fetch_object(
$resql);
1409 $this->error = $this->
db->error();
1427 public function getNomUrl($withpicto = 0, $option =
'', $maxlen = 0, $moreparam =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1429 global $conf, $langs, $hookmanager;
1431 $result =
''; $label =
'';
1432 if (!empty($this->photo) && class_exists(
'Form')) {
1433 $label .=
'<div class="photointooltip floatright">';
1434 $label .=
Form::showphoto(
'contact', $this, 0, 40, 0,
'photoref',
'mini', 0);
1439 $label .=
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Contact").
'</u>';
1440 $label .=
' '.$this->getLibStatut(4);
1441 $label .=
'<br><b>'.$langs->trans(
"Name").
':</b> '.$this->
getFullName($langs);
1443 if (!empty($this->poste)) {
1444 $label .=
'<br><b>'.$langs->trans(
"Poste").
':</b> '.$this->poste;
1446 $label .=
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
1447 $phonelist = array();
1448 $country_code = empty($this->country_code) ?
'': $this->country_code;
1449 if ($this->phone_pro) {
1450 $phonelist[] =
dol_print_phone($this->phone_pro, $country_code, $this->
id, 0,
'',
' ',
'phone');
1452 if ($this->phone_mobile) {
1453 $phonelist[] =
dol_print_phone($this->phone_mobile, $country_code, $this->
id, 0,
'',
' ',
'mobile');
1455 if ($this->phone_perso) {
1456 $phonelist[] =
dol_print_phone($this->phone_perso, $country_code, $this->
id, 0,
'',
' ',
'phone');
1458 $label .=
'<br><b>'.$langs->trans(
"Phone").
':</b> '.implode(
' ', $phonelist);
1459 $label .=
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
1461 $url = DOL_URL_ROOT.
'/contact/card.php?id='.$this->id;
1463 if ($option !==
'nolink') {
1465 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1466 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1467 $add_save_lastsearch_values = 1;
1469 if ($add_save_lastsearch_values) {
1470 $url .=
'&save_lastsearch_values=1';
1477 if (empty($notooltip)) {
1478 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1479 $label = $langs->trans(
"ShowContact");
1480 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1482 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1483 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1486 $linkstart =
'<a href="'.$url.
'"';
1487 $linkstart .= $linkclose.
'>';
1490 if ($option ==
'xxx') {
1491 $linkstart =
'<a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$this->
id.$moreparam.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
1495 $result .= $linkstart;
1497 if ($withpicto < 0) {
1498 $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>';
1500 $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);
1503 if ($withpicto != 2 && $withpicto != -2) {
1506 $result .= $linkend;
1509 $hookmanager->initHooks(array(
'contactdao'));
1510 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1511 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1513 $result = $hookmanager->resPrint;
1515 $result .= $hookmanager->resPrint;
1530 $code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite :
'')));
1535 $langs->load(
"dict");
1536 return $langs->getLabelFromKey($this->
db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
1547 return $this->
LibStatut($this->statut, $mode);
1563 $labelStatus = array(
1564 0 =>
'ActivityCeased',
1567 5 =>
'ActivityCeased',
1569 $labelStatusShort = array(
1570 0 =>
'ActivityCeased',
1573 5 =>
'ActivityCeased',
1576 $statusType =
'status4';
1577 if ($status == 0 || $status == 5) {
1578 $statusType =
'status5';
1581 $label = $langs->transnoentitiesnoconv($labelStatus[$status]);
1582 $labelshort = $langs->transnoentitiesnoconv($labelStatusShort[$status]);
1584 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1599 if ($status ==
'1') {
1600 return $langs->trans(
'ContactPrivate');
1602 return $langs->trans(
'ContactPublic');
1618 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe ORDER BY rowid LIMIT 1";
1621 $obj = $this->
db->fetch_object(
$resql);
1623 $socid = $obj->rowid;
1630 $this->specimen = 1;
1631 $this->lastname =
'DOLIBARR';
1632 $this->firstname =
'SPECIMEN';
1633 $this->address =
'21 jump street';
1634 $this->zip =
'99999';
1635 $this->town =
'MyTown';
1636 $this->country_id = 1;
1637 $this->country_code =
'FR';
1638 $this->country =
'France';
1639 $this->email =
'specimen@specimen.com';
1640 $this->socialnetworks = array(
1641 'skype' =>
'tom.hanson',
1643 $this->phone_pro =
'0909090901';
1644 $this->phone_perso =
'0909090902';
1645 $this->phone_mobile =
'0909090903';
1646 $this->fax =
'0909090909';
1648 $this->note_public =
'This is a comment (public)';
1649 $this->note_private =
'This is a comment (private)';
1651 $this->socid = $socid;
1664 global $conf, $langs, $user;
1669 if ($this->statut == $status) {
1672 $this->statut = $status;
1678 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople";
1679 $sql .=
" SET statut = ".((int) $this->statut);
1680 $sql .=
", fk_user_modif = ".((int) $user->id);
1681 $sql .=
" WHERE rowid = ".((int) $this->
id);
1682 $result = $this->
db->query($sql);
1684 dol_syslog(get_class($this).
"::setstatus", LOG_DEBUG);
1687 $result = $this->
call_trigger(
'CONTACT_ENABLEDISABLE', $user);
1695 $this->
db->rollback();
1698 $this->
db->commit();
1715 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1716 return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT);
1730 'socpeople',
'societe_contacts'
1749 $sql =
"SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle as label, sc.rowid as contactroleid, sc.fk_soc as socid";
1750 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_contacts as sc, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1751 $sql .=
" WHERE tc.rowid = sc.fk_c_type_contact";
1752 $sql .=
" AND tc.source = 'external' AND tc.active=1";
1753 $sql .=
" AND sc.fk_socpeople = ".((int) $this->
id);
1754 $sql .=
" AND sc.entity IN (".getEntity(
'societe').
')';
1758 $this->roles = array();
1760 $num = $this->
db->num_rows(
$resql);
1762 while ($obj = $this->
db->fetch_object(
$resql)) {
1763 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
1764 $libelle_element = $langs->trans(
'ContactDefault_'.$obj->element);
1765 $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));
1770 $this->error = $this->
db->lasterror();
1771 $this->errors[] = $this->
db->lasterror();
1774 if (empty($error)) {
1792 if ($element ==
'action') {
1793 $element =
'agenda';
1796 $sql =
"SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
1797 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
1798 $sql .=
", ".MAIN_DB_PREFIX.
"societe_contacts sc";
1799 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"socpeople sp";
1800 $sql .=
" ON sc.fk_socpeople = sp.rowid AND sp.statut = 1";
1801 $sql .=
" WHERE sc.fk_soc =".((int) $this->socid);
1802 $sql .=
" AND sc.fk_c_type_contact=tc.rowid";
1803 $sql .=
" AND tc.element = '".$this->db->escape($element).
"'";
1804 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1805 $sql .=
" AND tc.active = 1";
1810 $num = $this->
db->num_rows(
$resql);
1813 $obj = $this->
db->fetch_object(
$resql);
1814 $tab[] = array(
'fk_socpeople'=>$obj->id,
'type_contact'=>$obj->fk_c_type_contact);
1821 $this->error = $this->
db->error();
1840 if (!isset($this->roles)) {
1846 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople=".((int) $this->
id).
" AND entity IN (".
getEntity(
"contact").
")";
1848 $result = $this->
db->query($sql);
1850 $this->errors[] = $this->
db->lasterror().
' sql='.$sql;
1853 if (count($this->roles) > 0) {
1854 foreach ($this->roles as $keyRoles => $valRoles) {
1856 if (is_array($valRoles)) {
1857 $idrole = $valRoles[
'id'];
1859 $idrole = $valRoles;
1863 if (is_array($valRoles)) {
1864 $socid = $valRoles[
'socid'];
1866 $socid = $this->socid;
1870 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_contacts";
1871 $sql .=
" (entity,";
1872 $sql .=
"date_creation,";
1874 $sql .=
"fk_c_type_contact,";
1875 $sql .=
"fk_socpeople) ";
1876 $sql .=
" VALUES (".$conf->entity.
",";
1877 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
1878 $sql .= $socid.
", ";
1879 $sql .= $idrole.
" , ";
1883 $result = $this->
db->query($sql);
1885 $this->errors[] = $this->
db->lasterror().
' sql='.$sql;
1892 if (empty($error)) {
1893 $this->
db->commit();
1896 $this->error = implode(
' ', $this->errors);
1897 $this->
db->rollback();
1912 $sql =
"SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX.
"c_stcommcontact";
1914 $sql .=
" WHERE active = ".((int) $active);
1917 $num = $this->
db->num_rows(
$resql);
1920 $obj = $this->
db->fetch_object(
$resql);
1921 $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);
1947 $lib = $langs->trans(
"ProspectLevel".$fk_prospectlevel);
1949 if ($lib == $langs->trans(
"ProspectLevel".$fk_prospectlevel)) {
1950 $lib = $langs->getLabelFromKey($this->
db, $fk_prospectlevel,
'c_prospectlevel',
'code',
'label');
1965 return $this->
update($this->
id, $user);
1977 return $this->
libProspCommStatut($this->stcomm_id, $mode, $label, $this->stcomm_picto);
1996 $langs->load(
'customers');
1999 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2000 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
2001 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2002 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
2003 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2004 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
2005 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2006 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
2007 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2008 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2010 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);
2014 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2015 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto);
2016 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2017 return img_action($langs->trans(
"StatusProspect0"), 0, $picto);
2018 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2019 return img_action($langs->trans(
"StatusProspect1"), 1, $picto);
2020 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2021 return img_action($langs->trans(
"StatusProspect2"), 2, $picto);
2022 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2023 return img_action($langs->trans(
"StatusProspect3"), 3, $picto);
2025 return img_action(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label, 0, $picto);
2029 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2030 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
2031 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2032 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
2033 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2034 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
2035 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2036 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
2037 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2038 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2040 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);
2044 return "Error, mode/status not found";
2063 $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).
"'";
2066 $obj = $this->
db->fetch_object(
$resql);
2067 $noemail = $obj->nb;
2068 if (empty($noemail)) {
2069 $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()).
"')";
2073 $this->error = $this->
db->lasterror();
2074 $this->errors[] = $this->error;
2079 $this->error = $this->
db->lasterror();
2080 $this->errors[] = $this->error;
2083 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = '".$this->
db->escape($this->email).
"' AND entity IN (".
getEntity(
'mailing', 0).
")";
2087 $this->error = $this->
db->lasterror();
2088 $this->errors[] = $this->error;
2092 if (empty($error)) {
2093 $this->no_email = $no_email;
2094 $this->
db->commit();
2097 $this->
db->rollback();
2114 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing').
") AND email = '".$this->
db->escape($this->email).
"'";
2117 $obj = $this->
db->fetch_object(
$resql);
2118 $this->no_email = $obj->nb;
2121 $this->error = $this->
db->lasterror();
2122 $this->errors[] = $this->error;
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 $db, $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.