36require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/commonsocialnetworks.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
52 public $element =
'contact';
57 public $table_element =
'socpeople';
62 public $picto =
'contact';
92 public $fields = array(
93 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -2,
'noteditable' => 1,
'notnull' => 1,
'index' => 1,
'position' => 1,
'comment' =>
'Id',
'css' =>
'left'),
94 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => 3,
'notnull' => 1,
'position' => 30,
'index' => 1),
95 'ref_ext' => array(
'type' =>
'varchar(255)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 3,
'position' => 35),
96 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => 3,
'position' => 40),
97 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'position' => 45,
'showoncombobox' => 1,
'searchall' => 1),
98 'name_alias' => array(
'type' =>
'varchar(255)',
'label' =>
'Name alias',
'enabled' => 1,
'visible' => -1,
'position' => 46,
'searchall' => 1),
99 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'position' => 50,
'showoncombobox' => 1,
'searchall' => 1),
100 'poste' => array(
'type' =>
'varchar(80)',
'label' =>
'PostOrFunction',
'enabled' => 1,
'visible' => -1,
'position' => 52),
101 'address' => array(
'type' =>
'varchar(255)',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 55),
102 'zip' => array(
'type' =>
'varchar(25)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 60),
103 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 65),
104 'fk_departement' => array(
'type' =>
'integer',
'label' =>
'Fk departement',
'enabled' => 1,
'visible' => 3,
'position' => 70),
105 'fk_pays' => array(
'type' =>
'integer',
'label' =>
'Fk pays',
'enabled' => 1,
'visible' => 3,
'position' => 75),
106 'fk_soc' => array(
'type' =>
'integer',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => 1,
'position' => 77,
'searchall' => 1),
107 'birthday' => array(
'type' =>
'date',
'label' =>
'Birthday',
'enabled' => 1,
'visible' => -1,
'position' => 80),
108 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => 1,
'position' => 90,
'searchall' => 1),
109 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'PhonePerso',
'enabled' => 1,
'visible' => -1,
'position' => 95,
'searchall' => 1),
110 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'PhoneMobile',
'enabled' => 1,
'visible' => 1,
'position' => 100,
'searchall' => 1),
111 'fax' => array(
'type' =>
'varchar(30)',
'label' =>
'Fax',
'enabled' => 1,
'visible' => -1,
'position' => 105,
'searchall' => 1),
112 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => 1,
'position' => 110,
'searchall' => 1),
113 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'SocialNetworks',
'enabled' => 1,
'visible' => 3,
'position' => 115),
114 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => 3,
'position' => 170),
115 'priv' => array(
'type' =>
'smallint(6)',
'label' =>
'ContactVisibility',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 175),
116 'fk_stcommcontact' => array(
'type' =>
'integer',
'label' =>
'ProspectStatus',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 220),
117 'fk_prospectcontactlevel' => array(
'type' =>
'varchar(12)',
'label' =>
'ProspectLevel',
'enabled' => 1,
'visible' => -1,
'position' => 255),
119 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 3,
'position' => 195,
'searchall' => 1),
120 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 3,
'position' => 200,
'searchall' => 1),
121 'default_lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Default lang',
'enabled' => 1,
'visible' => 3,
'position' => 205),
122 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => 3,
'position' => 210),
123 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 300),
124 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 305),
125 'fk_user_creat' => array(
'type' =>
'integer',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => 3,
'position' => 310),
126 'fk_user_modif' => array(
'type' =>
'integer',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => 3,
'position' => 315),
127 'statut' => array(
'type' =>
'tinyint(4)',
'label' =>
'Status',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 500),
128 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -1,
'position' => 1000),
132 public $civility_code;
148 public $birthday_alert;
251 public $socialnetworks;
271 public $phone_mobile;
292 public $default_lang;
297 public $ref_facturation;
307 public $ref_commande;
338 public $cacheprospectstatus = array();
343 public $fk_prospectlevel;
347 public $statut_commercial;
352 public $stcomm_picto;
364 $this->ismultientitymanaged = 1;
365 $this->isextrafieldmanaged = 1;
367 if (!isModEnabled(
'mailing')) {
368 $this->fields[
'no_email'][
'enabled'] = 0;
372 $this->fields[
'fk_soc'][
'enabled'] = 0;
373 $this->fields[
'fk_soc'][
'searchall'] = 0;
378 $this->fields[
'fk_stcommcontact'][
'enabled'] = 0;
379 $this->fields[
'fk_prospectcontactlevel'][
'enabled'] = 0;
383 foreach ($this->fields as $key => $val) {
384 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
385 unset($this->fields[$key]);
412 global $user, $hookmanager;
417 $sql =
"SELECT count(sp.rowid) as nb";
418 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
419 if (!$user->hasRight(
'societe',
'client',
'voir')) {
420 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
421 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
422 $sql .=
" WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
425 $sql .=
" ".$clause.
" sp.entity IN (".
getEntity($this->element).
")";
426 $sql .=
" AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat = ".((int) $user->id).
"))";
427 if ($user->socid > 0) {
428 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
431 if (is_object($hookmanager)) {
432 $parameters = array();
433 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
434 $sql .= $hookmanager->resPrint;
437 $resql = $this->db->query($sql);
439 while ($obj = $this->db->fetch_object($resql)) {
440 $this->nb[
"contacts"] = $obj->nb;
442 $this->db->free($resql);
446 $this->error = $this->db->lasterror();
458 public function create($user, $notrigger = 0)
468 $this->name_alias = trim($this->name_alias);
469 $this->lastname = $this->lastname ? trim($this->lastname) : trim($this->
name);
470 $this->firstname = trim($this->firstname);
472 if (empty($this->socid)) {
475 if (empty($this->priv)) {
478 if (empty($this->
statut)) {
482 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
484 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"socpeople (";
487 $sql .=
", name_alias";
488 $sql .=
", lastname";
489 $sql .=
", firstname";
490 $sql .=
", fk_user_creat";
492 $sql .=
", fk_stcommcontact";
497 $sql .=
", import_key";
498 $sql .=
") VALUES (";
499 $sql .=
"'".$this->db->idate($now).
"',";
500 if ($this->socid > 0) {
501 $sql .=
" ".((int) $this->socid).
",";
505 $sql .=
"'".$this->db->escape($this->name_alias).
"',";
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 = (empty($this->ref_ext) ?
'' : trim($this->ref_ext));
587 $this->name_alias = trim($this->name_alias);
588 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
589 $this->firstname = trim($this->firstname);
590 $this->email = trim($this->email);
591 $this->phone_pro = trim($this->phone_pro);
592 $this->phone_perso = trim($this->phone_perso);
593 $this->phone_mobile = trim($this->phone_mobile);
594 $this->photo = trim($this->photo);
595 $this->fax = trim($this->fax);
596 $this->zip = (empty($this->zip) ?
'' : trim($this->zip));
597 $this->town = (empty($this->town) ?
'' : trim($this->town));
598 $this->country_id = (empty($this->country_id) || $this->country_id < 0) ? 0 : $this->country_id;
599 if (empty($this->
statut)) {
602 if (empty($this->civility_code) && !is_numeric($this->civility_id)) {
603 $this->civility_code = $this->civility_id;
609 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
610 if ($this->socid > 0) {
611 $sql .=
" fk_soc = ".((int) $this->socid).
",";
612 } elseif ($this->socid == -1) {
613 $sql .=
" fk_soc = NULL,";
615 $sql .=
" civility='".$this->db->escape($this->civility_code).
"'";
616 $sql .=
", name_alias='".$this->db->escape($this->name_alias).
"'";
617 $sql .=
", lastname='".$this->db->escape($this->lastname).
"'";
618 $sql .=
", firstname='".$this->db->escape($this->firstname).
"'";
619 $sql .=
", address='".$this->db->escape($this->address).
"'";
620 $sql .=
", zip='".$this->db->escape($this->zip).
"'";
621 $sql .=
", town='".$this->db->escape($this->town).
"'";
622 $sql .=
", ref_ext = ".(!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"NULL");
623 $sql .=
", fk_pays=".($this->country_id > 0 ? $this->country_id :
'NULL');
624 $sql .=
", fk_departement=".($this->state_id > 0 ? $this->state_id :
'NULL');
625 $sql .=
", poste='".$this->db->escape($this->poste).
"'";
626 $sql .=
", fax='".$this->db->escape($this->fax).
"'";
627 $sql .=
", email='".$this->db->escape($this->email).
"'";
628 $sql .=
", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks)).
"'";
629 $sql .=
", photo='".$this->db->escape($this->photo).
"'";
630 $sql .=
", birthday=".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
631 $sql .=
", note_private = ".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"NULL");
632 $sql .=
", note_public = ".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"NULL");
633 $sql .=
", phone = ".(isset($this->phone_pro) ?
"'".$this->db->escape($this->phone_pro).
"'" :
"NULL");
634 $sql .=
", phone_perso = ".(isset($this->phone_perso) ?
"'".$this->db->escape($this->phone_perso).
"'" :
"NULL");
635 $sql .=
", phone_mobile = ".(isset($this->phone_mobile) ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"NULL");
636 $sql .=
", priv = '".$this->db->escape($this->priv).
"'";
637 $sql .=
", fk_prospectlevel = '".$this->db->escape($this->fk_prospectlevel).
"'";
638 if (isset($this->stcomm_id)) {
639 $sql .=
", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id :
"0");
641 $sql .=
", statut = ".((int) $this->
statut);
642 $sql .=
", fk_user_modif=".($user->id > 0 ?
"'".$this->db->escape($user->id).
"'" :
"NULL");
643 $sql .=
", default_lang=".($this->default_lang ?
"'".$this->db->escape($this->default_lang).
"'" :
"NULL");
644 $sql .=
", entity = ".((int) $this->entity);
645 $sql .=
" WHERE rowid = ".((int) $id);
647 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
648 $result = $this->db->query($sql);
650 unset($this->country_code);
651 unset($this->country);
652 unset($this->state_code);
672 if (!$error && $this->user_id > 0) {
674 $tmpobj =
new User($this->db);
675 $tmpobj->fetch($this->user_id);
676 $usermustbemodified = 0;
677 if ($tmpobj->office_phone != $this->phone_pro) {
678 $tmpobj->office_phone = $this->phone_pro;
679 $usermustbemodified++;
681 if ($tmpobj->office_fax != $this->fax) {
682 $tmpobj->office_fax = $this->fax;
683 $usermustbemodified++;
685 if ($tmpobj->address != $this->address) {
686 $tmpobj->address = $this->address;
687 $usermustbemodified++;
689 if ($tmpobj->town != $this->town) {
690 $tmpobj->town = $this->town;
691 $usermustbemodified++;
693 if ($tmpobj->zip != $this->zip) {
694 $tmpobj->zip = $this->zip;
695 $usermustbemodified++;
697 if ($tmpobj->zip != $this->zip) {
698 $tmpobj->state_id = $this->state_id;
699 $usermustbemodified++;
701 if ($tmpobj->country_id != $this->country_id) {
702 $tmpobj->country_id = $this->country_id;
703 $usermustbemodified++;
705 if ($tmpobj->email != $this->email) {
706 $tmpobj->email = $this->email;
707 $usermustbemodified++;
709 if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) {
710 $tmpobj->socialnetworks = $this->socialnetworks;
711 $usermustbemodified++;
713 if ($usermustbemodified) {
714 $result = $tmpobj->update($user, 0, 1, 1, 1);
721 if (!$error && !$notrigger) {
734 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
735 $this->db->rollback();
739 $this->error = $this->db->lasterror().
' sql='.$sql;
740 $this->db->rollback();
764 } elseif ($mode == 1) {
766 } elseif ($mode == 2) {
783 global $conf, $langs;
804 $info[
"title"] = $this->poste;
806 if ($this->socid > 0) {
808 $soc->fetch($this->socid);
811 if ($soc->client == 1) {
812 $info[
"businessCategory"] =
"Customers";
814 if ($soc->client == 2) {
815 $info[
"businessCategory"] =
"Prospects";
817 if ($soc->fournisseur == 1) {
818 $info[
"businessCategory"] =
"Suppliers";
853 $info[
"objectclass"][4] =
"phpgwContact";
855 $info[
'uidnumber'] = $this->id;
857 $info[
'phpgwTz'] = 0;
858 $info[
'phpgwMailType'] =
'INTERNET';
859 $info[
'phpgwMailHomeType'] =
'INTERNET';
861 $info[
"phpgwContactTypeId"] =
'n';
862 $info[
"phpgwContactCatId"] = 0;
863 $info[
"phpgwContactAccess"] =
"public";
871 $info[
"phpgwContactOwner"] = 1;
874 $info[
"rfc822Mailbox"] = $this->email;
876 if ($this->phone_mobile) {
877 $info[
"phpgwCellTelephoneNumber"] = $this->phone_mobile;
903 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
904 $sql .=
" birthday = ".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
905 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
907 $sql .=
", fk_user_modif = ".((int) $user->id);
909 $sql .=
" WHERE rowid = ".((int) $id);
911 dol_syslog(get_class($this).
"::update_perso this->birthday=".$this->birthday.
" -", LOG_DEBUG);
912 $resql = $this->db->query($sql);
915 $this->error = $this->db->lasterror();
920 if (!empty($this->birthday_alert)) {
922 $sql_check =
"SELECT rowid FROM " . MAIN_DB_PREFIX .
"user_alert WHERE type = 1 AND fk_contact = " . ((int) $id) .
" AND fk_user = " . ((int) $user->id);
923 $result_check = $this->db->query($sql_check);
924 if (!$result_check || ($this->db->num_rows($result_check) < 1)) {
926 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"user_alert(type, fk_contact, fk_user) ";
927 $sql .=
"VALUES (1," . ((int) $id) .
"," . ((int) $user->id) .
")";
928 $result = $this->db->query($sql);
931 $this->error = $this->db->lasterror();
937 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"user_alert ";
938 $sql .=
"WHERE type=1 AND fk_contact=" . ((int) $id) .
" AND fk_user=" . ((int) $user->id);
939 $result = $this->db->query($sql);
942 $this->error = $this->db->lasterror();
947 if (!$error && !$notrigger) {
960 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
961 $this->db->rollback();
978 public function fetch($id, $user =
null, $ref_ext =
'', $email =
'', $loadalsoroles = 0, $socid = 0)
982 dol_syslog(get_class($this).
"::fetch id=".$id.
" ref_ext=".$ref_ext.
" email=".$email, LOG_DEBUG);
984 if (empty($id) && empty($ref_ext) && empty($email)) {
985 $this->error =
'BadParameter';
989 $langs->loadLangs(array(
"dict",
"companies"));
991 $sql =
"SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.name_alias, c.lastname, c.firstname,";
992 $sql .=
" c.address, c.statut, c.zip, c.town,";
993 $sql .=
" c.fk_pays as country_id,";
994 $sql .=
" c.fk_departement as state_id,";
995 $sql .=
" c.birthday,";
996 $sql .=
" c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
997 $sql .=
" c.socialnetworks,";
999 $sql .=
" c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
1000 $sql .=
" c.fk_prospectlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,";
1001 $sql .=
" c.import_key,";
1002 $sql .=
" c.datec as date_creation, c.tms as date_modification,";
1003 $sql .=
" co.label as country, co.code as country_code,";
1004 $sql .=
" d.nom as state, d.code_departement as state_code,";
1005 $sql .=
" u.rowid as user_id, u.login as user_login,";
1006 $sql .=
" s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
1007 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1008 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON c.fk_pays = co.rowid";
1009 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as d ON c.fk_departement = d.rowid";
1010 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON c.rowid = u.fk_socpeople";
1011 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
1012 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
1014 $sql .=
" WHERE c.rowid = ".((int) $id);
1016 $sql .=
" WHERE c.entity IN (".getEntity($this->element).
")";
1018 $sql .=
" AND c.ref_ext = '".$this->db->escape($ref_ext).
"'";
1021 $sql .=
" AND c.email = '".$this->db->escape($email).
"'";
1024 $sql .=
" AND c.fk_soc = ".((int) $socid);
1028 $resql = $this->db->query($sql);
1030 $num = $this->db->num_rows($resql);
1032 $this->error =
'Fetch found several records. Rename one of contact to avoid duplicate.';
1037 $obj = $this->db->fetch_object($resql);
1039 $this->
id = $obj->rowid;
1040 $this->entity = $obj->entity;
1041 $this->
ref = $obj->rowid;
1042 $this->ref_ext = $obj->ref_ext;
1044 $this->civility_code = $obj->civility_code;
1045 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1047 $this->name_alias = $obj->name_alias;
1048 $this->lastname = $obj->lastname;
1049 $this->firstname = $obj->firstname;
1050 $this->address = $obj->address;
1051 $this->zip = $obj->zip;
1052 $this->town = $obj->town;
1054 $this->date_creation = $this->db->jdate($obj->date_creation);
1055 $this->date_modification = $this->db->jdate($obj->date_modification);
1057 $this->state_id = $obj->state_id;
1058 $this->state_code = $obj->state_code;
1059 $this->state = $obj->state;
1061 $this->country_id = $obj->country_id;
1062 $this->country_code = $obj->country_id ? $obj->country_code :
'';
1063 $this->country = $obj->country_id ? ($langs->trans(
'Country'.$obj->country_code) !=
'Country'.$obj->country_code ? $langs->transnoentities(
'Country'.$obj->country_code) : $obj->country) :
'';
1065 $this->fk_soc = $obj->fk_soc;
1066 $this->socid = $obj->fk_soc;
1067 $this->socname = $obj->socname;
1068 $this->poste = $obj->poste;
1069 $this->
statut = $obj->statut;
1071 $this->fk_prospectlevel = $obj->fk_prospectlevel;
1073 $transcode = $langs->trans(
'StatusProspect'.$obj->fk_stcommcontact);
1074 $libelle = ($transcode !=
'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm);
1075 $this->stcomm_id = $obj->fk_stcommcontact;
1076 $this->statut_commercial = $libelle;
1077 $this->stcomm_picto = $obj->stcomm_picto;
1079 $this->phone_pro = trim($obj->phone);
1080 $this->fax = trim($obj->fax);
1081 $this->phone_perso = trim($obj->phone_perso);
1082 $this->phone_mobile = trim($obj->phone_mobile);
1084 $this->email = $obj->email;
1085 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1086 $this->photo = $obj->photo;
1087 $this->priv = $obj->priv;
1088 $this->mail = $obj->email;
1090 $this->birthday = $this->db->jdate($obj->birthday);
1091 $this->note = $obj->note_private;
1092 $this->note_private = $obj->note_private;
1093 $this->note_public = $obj->note_public;
1094 $this->default_lang = $obj->default_lang;
1095 $this->user_id = $obj->user_id;
1096 $this->user_login = $obj->user_login;
1097 $this->canvas = $obj->canvas;
1099 $this->import_key = $obj->import_key;
1105 $sql =
"SELECT u.rowid ";
1106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
1107 $sql .=
" WHERE u.fk_socpeople = ".((int) $this->
id);
1109 $resql = $this->db->query($sql);
1111 if ($this->db->num_rows($resql)) {
1112 $uobj = $this->db->fetch_object($resql);
1114 $this->user_id = $uobj->rowid;
1116 $this->db->free($resql);
1118 $this->error = $this->db->error();
1128 $sql =
"SELECT fk_user";
1129 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_alert";
1130 $sql .=
" WHERE fk_user = ".((int) $user->id).
" AND fk_contact = ".((int) $id);
1132 $resql = $this->db->query($sql);
1134 if ($this->db->num_rows($resql)) {
1135 $obj = $this->db->fetch_object($resql);
1137 $this->birthday_alert = 1;
1139 $this->db->free($resql);
1141 $this->error = $this->db->error();
1147 if ($loadalsoroles) {
1149 if ($resultRole < 0) {
1156 $this->error = $langs->trans(
"RecordNotFound");
1160 $this->error = $this->db->error();
1178 public function findNearest($id = 0, $lastname =
'', $firstname =
'', $ref_ext =
'', $email =
'', $ref_alias =
'', $socid = 0)
1190 $tmpcontact =
new Contact($this->db);
1191 $result = $tmpcontact->fetch($id,
null, $ref_ext, $email, 0, $socid);
1206 unset($this->gender);
1208 if (in_array($this->civility_id, array(
'MR')) || in_array($this->civility_code, array(
'MR'))) {
1209 $this->gender =
'man';
1210 } elseif (in_array($this->civility_id, array(
'MME',
'MLE')) || in_array($this->civility_code, array(
'MME',
'MLE'))) {
1211 $this->gender =
'woman';
1229 $sql =
"SELECT tc.element, count(ec.rowid) as nb";
1230 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1231 $sql .=
" WHERE ec.fk_c_type_contact = tc.rowid";
1232 $sql .=
" AND fk_socpeople = ".((int) $this->
id);
1233 $sql .=
" AND tc.source = 'external'";
1234 $sql .=
" GROUP BY tc.element";
1236 dol_syslog(get_class($this).
"::load_ref_elements", LOG_DEBUG);
1238 $resql = $this->db->query($sql);
1240 while ($obj = $this->db->fetch_object($resql)) {
1242 if ($obj->element ==
'facture') {
1243 $this->ref_facturation = $obj->nb;
1244 } elseif ($obj->element ==
'contrat') {
1245 $this->ref_contrat = $obj->nb;
1246 } elseif ($obj->element ==
'commande') {
1247 $this->ref_commande = $obj->nb;
1248 } elseif ($obj->element ==
'propal') {
1249 $this->ref_propal = $obj->nb;
1253 $this->db->free($resql);
1256 $this->error = $this->db->lasterror();
1268 public function delete($user, $notrigger = 0)
1274 if (!$error && !$notrigger) {
1276 $result = $this->
call_trigger(
'CONTACT_DELETE', $user);
1285 $sql =
"SELECT ec.rowid";
1286 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact ec,";
1287 $sql .=
" ".MAIN_DB_PREFIX.
"c_type_contact tc";
1288 $sql .=
" WHERE ec.fk_socpeople=".((int) $this->
id);
1289 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
1290 $sql .=
" AND tc.source='external'";
1292 $resql = $this->db->query($sql);
1294 $num = $this->db->num_rows($resql);
1297 while ($i < $num && !$error) {
1298 $obj = $this->db->fetch_object($resql);
1300 $sqldel =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_contact";
1301 $sqldel .=
" WHERE rowid = ".((int) $obj->rowid);
1303 $result = $this->db->query($sqldel);
1306 $this->error = $this->db->error().
' sql='.$sqldel;
1313 $this->error = $this->db->error().
' sql='.$sql;
1319 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople = ".((int) $this->
id);
1321 $resql = $this->db->query($sql);
1324 $this->error .= $this->db->lasterror();
1331 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"notify_def WHERE fk_contact = ".((int) $this->
id);
1333 $resql = $this->db->query($sql);
1336 $this->error .= $this->db->lasterror();
1343 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_contact WHERE fk_socpeople = ".((int) $this->
id);
1345 $resql = $this->db->query($sql);
1348 $this->error .= $this->db->lasterror();
1354 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"socpeople";
1355 $sql .=
" WHERE rowid = ".((int) $this->
id);
1357 $result = $this->db->query($sql);
1360 $this->error = $this->db->error().
' sql='.$sql;
1374 $this->db->commit();
1377 $this->db->rollback();
1392 $sql =
"SELECT c.rowid, c.datec as datec, c.fk_user_creat,";
1393 $sql .=
" c.tms as tms, c.fk_user_modif";
1394 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1395 $sql .=
" WHERE c.rowid = ".((int) $id);
1397 $resql = $this->db->query($sql);
1399 if ($this->db->num_rows($resql)) {
1400 $obj = $this->db->fetch_object($resql);
1402 $this->
id = $obj->rowid;
1404 $this->user_creation_id = $obj->fk_user_creat;
1405 $this->user_modification_id = $obj->fk_user_modif;
1406 $this->date_creation = $this->db->jdate($obj->datec);
1407 $this->date_modification = $this->db->jdate($obj->tms);
1410 $this->db->free($resql);
1412 print $this->db->error();
1423 $sql =
"SELECT count(mc.email) as nb";
1424 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"mailing as m";
1425 $sql .=
" WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email).
"' ";
1426 $sql .=
" AND m.entity IN (".getEntity($this->element).
") AND mc.statut NOT IN (-1,0)";
1428 $resql = $this->db->query($sql);
1430 $obj = $this->db->fetch_object($resql);
1433 $this->db->free($resql);
1436 $this->error = $this->db->error();
1449 global $conf, $langs, $user;
1454 return [
'optimize' => $langs->trans(
"ShowContact")];
1456 if (!empty($this->photo) && class_exists(
'Form')) {
1457 $photo =
'<div class="photointooltip floatright">';
1458 $photo .=
Form::showphoto(
'contact', $this, 0, 40, 0,
'photoref',
'mini', 0);
1460 $datas[
'photo'] = $photo;
1463 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Contact").
'</u> ' . $this->
getLibStatut(4);
1464 $datas[
'name'] =
'<br><b>'.$langs->trans(
"Name").
':</b> '.$this->
getFullName($langs);
1466 if (!empty($this->poste)) {
1467 $datas[
'job'] =
'<br><b>'.$langs->trans(
"Poste").
':</b> '.$this->poste;
1469 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
1470 $phonelist = array();
1471 $country_code = empty($this->country_code) ?
'' : $this->country_code;
1472 if ($this->phone_pro) {
1473 $phonelist[] =
dol_print_phone($this->phone_pro, $country_code, $this->
id, 0,
'',
' ',
'phone');
1475 if ($this->phone_mobile) {
1476 $phonelist[] =
dol_print_phone($this->phone_mobile, $country_code, $this->
id, 0,
'',
' ',
'mobile');
1478 if ($this->phone_perso) {
1479 $phonelist[] =
dol_print_phone($this->phone_perso, $country_code, $this->
id, 0,
'',
' ',
'phone');
1481 $datas[
'phonelist'] =
'<br><b>'.$langs->trans(
"Phone").
':</b> '.implode(
' ', $phonelist);
1482 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
1500 public function getNomUrl($withpicto = 0, $option =
'', $maxlen = 0, $moreparam =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1502 global $conf, $langs, $hookmanager;
1504 if (!empty($conf->dol_no_mouse_hover)) {
1511 'objecttype' => $this->element,
1512 'option' => $option,
1514 $classfortooltip =
'classfortooltip';
1517 $classfortooltip =
'classforajaxtooltip';
1518 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1524 $url = DOL_URL_ROOT.
'/contact/card.php?id='.$this->id;
1526 if ($option !==
'nolink') {
1528 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1529 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1530 $add_save_lastsearch_values = 1;
1532 if ($url && $add_save_lastsearch_values) {
1533 $url .=
'&save_lastsearch_values=1';
1540 if (empty($notooltip)) {
1542 $label = $langs->trans(
"ShowContact");
1543 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1545 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1546 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1548 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1551 if ($option ==
'nolink' || empty($url)) {
1552 $linkstart =
'<span';
1554 $linkstart =
'<a href="'.$url.
'"';
1556 $linkstart .= $linkclose.
'>';
1557 if ($option ==
'nolink' || empty($url)) {
1558 $linkend =
'</span>';
1563 $result .= $linkstart;
1566 if ($withpicto < 0) {
1567 $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>';
1568 if ($withpicto != 2 && $withpicto != -2) {
1572 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="pictofixedwidth valignmiddle"' :
'') :
'class="'.(($withpicto != 2) ?
'pictofixedwidth valignmiddle' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1575 if ($withpicto != 2 && $withpicto != -2) {
1579 $result .= $linkend;
1582 $hookmanager->initHooks(array(
'contactdao'));
1583 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1584 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1586 $result = $hookmanager->resPrint;
1588 $result .= $hookmanager->resPrint;
1603 $code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite :
'')));
1608 $langs->load(
"dict");
1609 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
1636 $labelStatus = array(
1637 0 =>
'ActivityCeased',
1640 5 =>
'ActivityCeased',
1642 $labelStatusShort = array(
1643 0 =>
'ActivityCeased',
1646 5 =>
'ActivityCeased',
1649 $statusType =
'status4';
1650 if ($status == 0 || $status == 5) {
1651 $statusType =
'status5';
1654 $label = $langs->transnoentitiesnoconv($labelStatus[$status]);
1655 $labelshort = $langs->transnoentitiesnoconv($labelStatusShort[$status]);
1657 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1672 if ($status ==
'1') {
1673 return $langs->trans(
'ContactPrivate');
1675 return $langs->trans(
'ContactPublic');
1691 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe ORDER BY rowid LIMIT 1";
1692 $resql = $this->db->query($sql);
1694 $obj = $this->db->fetch_object($resql);
1696 $socid = $obj->rowid;
1703 $this->specimen = 1;
1704 $this->lastname =
'DOLIBARR';
1705 $this->firstname =
'SPECIMEN';
1706 $this->address =
'21 jump street';
1707 $this->zip =
'99999';
1708 $this->town =
'MyTown';
1709 $this->country_id = 1;
1710 $this->country_code =
'FR';
1711 $this->country =
'France';
1712 $this->email =
'specimen@specimen.com';
1713 $this->socialnetworks = array(
1714 'skype' =>
'tom.hanson',
1715 'twitter' =>
'tomhanson',
1716 'linkedin' =>
'tomhanson',
1718 $this->phone_pro =
'0909090901';
1719 $this->phone_perso =
'0909090902';
1720 $this->phone_mobile =
'0909090903';
1721 $this->fax =
'0909090909';
1723 $this->note_public =
'This is a comment (public)';
1724 $this->note_private =
'This is a comment (private)';
1726 $this->socid = $socid;
1740 global $conf, $langs, $user;
1745 if ($this->
statut == $status) {
1754 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople";
1755 $sql .=
" SET statut = ".((int) $this->
statut);
1756 $sql .=
", fk_user_modif = ".((int) $user->id);
1757 $sql .=
" WHERE rowid = ".((int) $this->
id);
1758 $result = $this->db->query($sql);
1760 dol_syslog(get_class($this).
"::setstatus", LOG_DEBUG);
1763 $result = $this->
call_trigger(
'CONTACT_ENABLEDISABLE', $user);
1771 $this->db->rollback();
1774 $this->db->commit();
1791 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1792 return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT);
1806 'socpeople',
'societe_contacts'
1825 $sql =
"SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle as label, sc.rowid as contactroleid, sc.fk_soc as socid";
1826 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_contacts as sc, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1827 $sql .=
" WHERE tc.rowid = sc.fk_c_type_contact";
1828 $sql .=
" AND tc.source = 'external' AND tc.active=1";
1829 $sql .=
" AND sc.fk_socpeople = ".((int) $this->
id);
1830 $sql .=
" AND sc.entity IN (".getEntity(
'societe').
')';
1832 $resql = $this->db->query($sql);
1834 $this->roles = array();
1836 $num = $this->db->num_rows($resql);
1838 while ($obj = $this->db->fetch_object($resql)) {
1839 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
1840 $libelle_element = $langs->trans(
'ContactDefault_'.$obj->element);
1841 $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));
1846 $this->error = $this->db->lasterror();
1847 $this->errors[] = $this->db->lasterror();
1850 if (empty($error)) {
1868 if ($element ==
'action') {
1869 $element =
'agenda';
1872 $sql =
"SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
1873 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
1874 $sql .=
", ".MAIN_DB_PREFIX.
"societe_contacts sc";
1875 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"socpeople sp";
1876 $sql .=
" ON sc.fk_socpeople = sp.rowid AND sp.statut = 1";
1877 $sql .=
" WHERE sc.fk_soc =".((int) $this->socid);
1878 $sql .=
" AND sc.fk_c_type_contact=tc.rowid";
1879 $sql .=
" AND tc.element = '".$this->db->escape($element).
"'";
1880 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1881 $sql .=
" AND tc.active = 1";
1884 $resql = $this->db->query($sql);
1886 $num = $this->db->num_rows($resql);
1889 $obj = $this->db->fetch_object($resql);
1890 $tab[] = array(
'fk_socpeople' => $obj->id,
'type_contact' => $obj->fk_c_type_contact);
1897 $this->error = $this->db->error();
1916 if (!isset($this->roles)) {
1922 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople=".((int) $this->
id).
" AND entity IN (".
getEntity(
"contact").
")";
1924 $result = $this->db->query($sql);
1926 $this->errors[] = $this->db->lasterror().
' sql='.$sql;
1929 if (count($this->roles) > 0) {
1930 foreach ($this->roles as $keyRoles => $valRoles) {
1931 if (empty($valRoles)) {
1935 if (is_array($valRoles)) {
1936 $idrole = $valRoles[
'id'];
1938 $idrole = $valRoles;
1942 if (is_array($valRoles)) {
1943 $socid = $valRoles[
'socid'];
1945 $socid = $this->socid;
1949 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_contacts";
1950 $sql .=
" (entity,";
1951 $sql .=
"date_creation,";
1953 $sql .=
"fk_c_type_contact,";
1954 $sql .=
"fk_socpeople) ";
1955 $sql .=
" VALUES (".$conf->entity.
",";
1956 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
1957 $sql .= $socid.
", ";
1958 $sql .= $idrole.
" , ";
1962 $result = $this->db->query($sql);
1964 $this->errors[] = $this->db->lasterror().
' sql='.$sql;
1971 if (empty($error)) {
1972 $this->db->commit();
1975 $this->error = implode(
' ', $this->errors);
1976 $this->db->rollback();
1991 $sql =
"SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX.
"c_stcommcontact";
1993 $sql .=
" WHERE active = ".((int) $active);
1995 $resql = $this->db->query($sql);
1996 $num = $this->db->num_rows($resql);
1999 $obj = $this->db->fetch_object($resql);
2000 $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);
2026 $lib = $langs->trans(
"ProspectLevel".$fk_prospectlevel);
2028 if ($lib ==
"ProspectLevel".$fk_prospectlevel) {
2029 $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel,
'c_prospectlevel',
'code',
'label');
2044 return $this->
update($this->
id, $user);
2056 return $this->
libProspCommStatut($this->stcomm_id, $mode, $label, $this->stcomm_picto);
2075 $langs->load(
'customers');
2078 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2079 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
2080 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2081 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
2082 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2083 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
2084 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2085 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
2086 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2087 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2089 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);
2093 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2094 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto);
2095 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2096 return img_action($langs->trans(
"StatusProspect0"), 0, $picto);
2097 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2098 return img_action($langs->trans(
"StatusProspect1"), 1, $picto);
2099 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2100 return img_action($langs->trans(
"StatusProspect2"), 2, $picto);
2101 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2102 return img_action($langs->trans(
"StatusProspect3"), 3, $picto);
2104 return img_action(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label, 0, $picto);
2108 if ($statut ==
'-1' || $statut ==
'ST_NO') {
2109 return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
2110 } elseif ($statut ==
'0' || $statut ==
'ST_NEVER') {
2111 return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
2112 } elseif ($statut ==
'1' || $statut ==
'ST_TODO') {
2113 return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
2114 } elseif ($statut ==
'2' || $statut ==
'ST_PEND') {
2115 return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
2116 } elseif ($statut ==
'3' || $statut ==
'ST_DONE') {
2117 return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
2119 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);
2123 return "Error, mode/status not found";
2142 $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).
"'";
2143 $resql = $this->db->query($sql);
2145 $obj = $this->db->fetch_object($resql);
2146 $noemail = $obj->nb;
2147 if (empty($noemail)) {
2148 $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()).
"')";
2149 $resql = $this->db->query($sql);
2152 $this->error = $this->db->lasterror();
2153 $this->errors[] = $this->error;
2158 $this->error = $this->db->lasterror();
2159 $this->errors[] = $this->error;
2162 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = '".$this->db->escape($this->email).
"' AND entity IN (".
getEntity(
'mailing', 0).
")";
2163 $resql = $this->db->query($sql);
2166 $this->error = $this->db->lasterror();
2167 $this->errors[] = $this->error;
2171 if (empty($error)) {
2172 $this->no_email = $no_email;
2173 $this->db->commit();
2176 $this->db->rollback();
2193 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing').
") AND email = '".$this->db->escape($this->email).
"'";
2194 $resql = $this->db->query($sql);
2196 $obj = $this->db->fetch_object($resql);
2197 $this->no_email = $obj->nb;
2200 $this->error = $this->db->lasterror();
2201 $this->errors[] = $this->error;
2218 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2220 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2221 $return .=
'<div class="info-box info-box-sm">';
2222 $return .=
'<span class="info-box-icon bg-infobox-action">';
2224 if (property_exists($this,
'photo') && !is_null($this->photo)) {
2225 $return .=
Form::showphoto(
'contact', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
2229 $return .=
'</span>';
2230 $return .=
'<div class="info-box-content">';
2231 $return .=
'<div class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(0) : $this->ref).
'</div>';
2232 if ($selected >= 0) {
2233 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2235 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
2236 $return .=
'<div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
2246 if (method_exists($this,
'getLibStatut')) {
2247 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
2249 $return .=
'</div>';
2250 $return .=
'</div>';
2251 $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
Support class for thirdparties, contacts, members, users or resources.
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='')
Format phone numbers according to country.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs=null, $mode=0, $extralangcode='')
Return a formatted address (part address/zip/town/state) according to country rules.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut