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 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'position'=>15),
94 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>20),
95 'fk_soc' =>array(
'type'=>
'integer',
'label'=>
'ThirdParty',
'enabled'=>1,
'visible'=>1,
'position'=>25,
'searchall'=>1),
96 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>3,
'notnull'=>1,
'position'=>30,
'index'=>1),
97 'ref_ext' =>array(
'type'=>
'varchar(255)',
'label'=>
'Ref ext',
'enabled'=>1,
'visible'=>3,
'position'=>35),
98 'civility' =>array(
'type'=>
'varchar(6)',
'label'=>
'Civility',
'enabled'=>1,
'visible'=>3,
'position'=>40),
99 'lastname' =>array(
'type'=>
'varchar(50)',
'label'=>
'Lastname',
'enabled'=>1,
'visible'=>1,
'position'=>45,
'showoncombobox'=>1,
'searchall'=>1),
100 'firstname' =>array(
'type'=>
'varchar(50)',
'label'=>
'Firstname',
'enabled'=>1,
'visible'=>1,
'position'=>50,
'showoncombobox'=>1,
'searchall'=>1),
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'=>
'text',
'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 'birthday' =>array(
'type'=>
'date',
'label'=>
'Birthday',
'enabled'=>1,
'visible'=>3,
'position'=>80),
107 'poste' =>array(
'type'=>
'varchar(80)',
'label'=>
'PostOrFunction',
'enabled'=>1,
'visible'=>-1,
'position'=>85),
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'=>
'Fk stcommcontact',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>220),
117 'fk_prospectlevel' =>array(
'type'=>
'varchar(12)',
'label'=>
'ProspectLevel',
'enabled'=>1,
'visible'=>-1,
'position'=>255),
118 'no_email' =>array(
'type'=>
'smallint(6)',
'label'=>
'No_Email',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>180),
119 'fk_user_creat' =>array(
'type'=>
'integer',
'label'=>
'UserAuthor',
'enabled'=>1,
'visible'=>3,
'position'=>185),
120 'fk_user_modif' =>array(
'type'=>
'integer',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>3,
'position'=>190),
121 'note_private' =>array(
'type'=>
'text',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>3,
'position'=>195,
'searchall'=>1),
122 'note_public' =>array(
'type'=>
'text',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>3,
'position'=>200,
'searchall'=>1),
123 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>3,
'position'=>205),
124 'canvas' =>array(
'type'=>
'varchar(32)',
'label'=>
'Canvas',
'enabled'=>1,
'visible'=>3,
'position'=>210),
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;
174 public $socialnetworks;
229 public $phone_mobile;
243 public $default_lang;
245 public $ref_facturation;
247 public $ref_commande;
262 public $roles = null;
264 public $cacheprospectstatus = array();
265 public $fk_prospectlevel;
267 public $statut_commercial;
268 public $stcomm_picto;
277 global $conf, $langs;
282 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
283 $this->
fields[
'rowid'][
'visible'] = 0;
285 if (empty($conf->mailing->enabled)) {
286 $this->
fields[
'no_email'][
'enabled'] = 0;
289 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
290 $this->
fields[
'fk_soc'][
'enabled'] = 0;
291 $this->
fields[
'fk_soc'][
'searchall'] = 0;
294 if (empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
295 $this->field[
'fk_stcommcontact'][
'enabled'] = 0;
296 $this->field[
'fk_prospectcontactlevel'][
'enabled'] = 0;
300 foreach ($this->
fields as $key => $val) {
301 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
302 unset($this->
fields[$key]);
336 $sql =
"SELECT count(sp.rowid) as nb";
337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
338 if (!$user->rights->societe->client->voir && !$user->socid)
340 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
341 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
342 $sql .=
" WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
345 $sql .=
' '.$clause.
' sp.entity IN ('.
getEntity($this->element).
')';
346 $sql .=
" AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id.
"))";
347 if ($user->socid > 0) $sql .=
" AND sp.fk_soc = ".$user->socid;
352 while ($obj = $this->
db->fetch_object(
$resql))
354 $this->nb[
"contacts"] = $obj->nb;
360 $this->error = $this->
db->lasterror();
373 global $conf, $langs;
381 $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->
name);
382 $this->firstname = trim($this->firstname);
384 if (empty($this->socid)) $this->socid = 0;
385 if (empty($this->priv)) $this->priv = 0;
388 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
390 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"socpeople (";
393 $sql .=
", lastname";
394 $sql .=
", firstname";
395 $sql .=
", fk_user_creat";
397 $sql .=
", fk_stcommcontact";
402 $sql .=
", import_key";
403 $sql .=
") VALUES (";
404 $sql .=
"'".$this->db->idate($now).
"',";
405 if ($this->socid > 0) $sql .=
" ".$this->db->escape($this->socid).
",";
406 else $sql .=
"null,";
407 $sql .=
"'".$this->db->escape($this->lastname).
"',";
408 $sql .=
"'".$this->db->escape($this->firstname).
"',";
409 $sql .=
" ".($user->id > 0 ?
"'".$this->db->escape($user->id).
"'" :
"null").
",";
410 $sql .=
" ".$this->db->escape($this->priv).
",";
412 $sql .=
" ".$this->db->escape($this->
statut).
",";
413 $sql .=
" ".(!empty($this->canvas) ?
"'".$this->db->escape($this->canvas).
"'" :
"null").
",";
414 $sql .=
" ".$this->db->escape($this->entity).
",";
415 $sql .=
"'".$this->db->escape($this->ref_ext).
"',";
416 $sql .=
" ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
419 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
423 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"socpeople");
427 $result = $this->
update($this->
id, $user, 1,
'add');
431 $this->error = $this->
db->lasterror();
441 $this->error = $this->
db->lasterror();
449 if ($result < 0) { $error++; }
458 $this->
db->rollback();
459 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
463 $this->error = $this->
db->lasterror();
465 $this->
db->rollback();
466 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
481 public function update($id, $user = null, $notrigger = 0, $action =
'update', $nosyncuser = 0)
483 global $conf, $langs, $hookmanager;
489 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
492 $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname);
493 $this->firstname = trim($this->firstname);
494 $this->email = trim($this->email);
495 $this->phone_pro = trim($this->phone_pro);
496 $this->phone_perso = trim($this->phone_perso);
497 $this->phone_mobile = trim($this->phone_mobile);
498 $this->jabberid = trim($this->jabberid);
499 $this->skype = trim($this->skype);
500 $this->photo = trim($this->photo);
501 $this->fax = trim($this->fax);
502 $this->zip = (empty($this->zip) ?
'' : trim($this->zip));
503 $this->town = (empty($this->town) ?
'' : trim($this->town));
505 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
507 if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id;
510 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET ";
511 if ($this->socid > 0) $sql .=
" fk_soc='".$this->db->escape($this->socid).
"',";
512 elseif ($this->socid == -1) $sql .=
" fk_soc=null,";
513 $sql .=
" civility='".$this->db->escape($this->civility_code).
"'";
514 $sql .=
", lastname='".$this->db->escape($this->lastname).
"'";
515 $sql .=
", firstname='".$this->db->escape($this->firstname).
"'";
516 $sql .=
", address='".$this->db->escape($this->address).
"'";
517 $sql .=
", zip='".$this->db->escape($this->zip).
"'";
518 $sql .=
", town='".$this->db->escape($this->town).
"'";
519 $sql .=
", fk_pays=".($this->country_id > 0 ? $this->country_id :
'NULL');
520 $sql .=
", fk_departement=".($this->state_id > 0 ? $this->state_id :
'NULL');
521 $sql .=
", poste='".$this->db->escape($this->poste).
"'";
522 $sql .=
", fax='".$this->db->escape($this->fax).
"'";
523 $sql .=
", email='".$this->db->escape($this->email).
"'";
524 $sql .=
", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks)).
"'";
525 $sql .=
", photo='".$this->db->escape($this->photo).
"'";
526 $sql .=
", birthday=".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
527 $sql .=
", note_private = ".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
528 $sql .=
", note_public = ".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
529 $sql .=
", phone = ".(isset($this->phone_pro) ?
"'".$this->db->escape($this->phone_pro).
"'" :
"null");
530 $sql .=
", phone_perso = ".(isset($this->phone_perso) ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
531 $sql .=
", phone_mobile = ".(isset($this->phone_mobile) ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
532 $sql .=
", priv = '".$this->db->escape($this->priv).
"'";
533 $sql .=
", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel).
"'";
534 if (isset($this->stcomm_id))
536 $sql .=
", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id :
"0");
538 $sql .=
", statut = ".$this->db->escape($this->
statut);
539 $sql .=
", fk_user_modif=".($user->id > 0 ?
"'".$this->db->escape($user->id).
"'" :
"NULL");
540 $sql .=
", default_lang=".($this->default_lang ?
"'".$this->db->escape($this->default_lang).
"'" :
"NULL");
541 $sql .=
", entity = ".$this->db->escape($this->entity);
542 $sql .=
" WHERE rowid=".$this->db->escape($id);
544 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
545 $result = $this->
db->query($sql);
548 unset($this->country_code);
549 unset($this->country);
550 unset($this->state_code);
573 if (!$error && $this->user_id > 0)
576 $tmpobj =
new User($this->
db);
577 $tmpobj->fetch($this->user_id);
578 $usermustbemodified = 0;
579 if ($tmpobj->office_phone != $this->phone_pro)
581 $tmpobj->office_phone = $this->phone_pro;
582 $usermustbemodified++;
584 if ($tmpobj->office_fax != $this->fax)
586 $tmpobj->office_fax = $this->fax;
587 $usermustbemodified++;
589 if ($tmpobj->address != $this->address)
591 $tmpobj->address = $this->address;
592 $usermustbemodified++;
594 if ($tmpobj->town != $this->town)
596 $tmpobj->town = $this->town;
597 $usermustbemodified++;
599 if ($tmpobj->zip != $this->zip)
601 $tmpobj->zip = $this->zip;
602 $usermustbemodified++;
604 if ($tmpobj->zip != $this->zip)
606 $tmpobj->state_id = $this->state_id;
607 $usermustbemodified++;
609 if ($tmpobj->country_id != $this->country_id)
611 $tmpobj->country_id = $this->country_id;
612 $usermustbemodified++;
614 if ($tmpobj->email != $this->email)
616 $tmpobj->email = $this->email;
617 $usermustbemodified++;
619 if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks)))
621 $tmpobj->socialnetworks = $this->socialnetworks;
622 $usermustbemodified++;
644 if ($usermustbemodified)
646 $result = $tmpobj->update($user, 0, 1, 1, 1);
647 if ($result < 0) { $error++; }
651 if (!$error && !$notrigger)
655 if ($result < 0) { $error++; }
664 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
665 $this->
db->rollback();
669 $this->error = $this->
db->lasterror().
' sql='.$sql;
670 $this->
db->rollback();
692 if ($mode == 0) $dn = $conf->global->LDAP_KEY_CONTACTS.
"=".$info[$conf->global->LDAP_KEY_CONTACTS].
",".$conf->global->LDAP_CONTACT_DN;
693 elseif ($mode == 1) $dn = $conf->global->LDAP_CONTACT_DN;
694 elseif ($mode == 2) $dn = $conf->global->LDAP_KEY_CONTACTS.
"=".$info[$conf->global->LDAP_KEY_CONTACTS];
709 global $conf, $langs;
714 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_CONTACT_OBJECT_CLASS);
719 if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
720 if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
721 if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
723 if ($this->poste) $info[
"title"] = $this->poste;
724 if ($this->socid > 0)
727 $soc->fetch($this->socid);
729 $info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name;
730 if ($soc->client == 1) $info[
"businessCategory"] =
"Customers";
731 if ($soc->client == 2) $info[
"businessCategory"] =
"Prospects";
732 if ($soc->fournisseur == 1) $info[
"businessCategory"] =
"Suppliers";
734 if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
735 if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
736 if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
737 if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
738 if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
739 if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
740 if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
741 if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
742 if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
743 if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
744 if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
746 if ($conf->global->LDAP_SERVER_TYPE ==
'egroupware')
748 $info[
"objectclass"][4] =
"phpgwContact";
750 $info[
'uidnumber'] = $this->id;
752 $info[
'phpgwTz'] = 0;
753 $info[
'phpgwMailType'] =
'INTERNET';
754 $info[
'phpgwMailHomeType'] =
'INTERNET';
756 $info[
"phpgwContactTypeId"] =
'n';
757 $info[
"phpgwContactCatId"] = 0;
758 $info[
"phpgwContactAccess"] =
"public";
762 $this->egroupware_id = 1;
765 $info[
"phpgwContactOwner"] = $this->egroupware_id;
767 if ($this->email) $info[
"rfc822Mailbox"] = $this->email;
768 if ($this->phone_mobile) $info[
"phpgwCellTelephoneNumber"] = $this->phone_mobile;
793 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople SET";
794 $sql .=
" birthday=".($this->birthday ?
"'".$this->db->idate($this->birthday).
"'" :
"null");
795 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
796 if ($user) $sql .=
", fk_user_modif=".$user->id;
797 $sql .=
" WHERE rowid=".$this->db->escape($id);
799 dol_syslog(get_class($this).
"::update_perso this->birthday=".$this->birthday.
" -", LOG_DEBUG);
804 $this->error = $this->
db->lasterror();
808 if (!empty($this->birthday_alert)) {
810 $sql_check =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user_alert WHERE type=1 AND fk_contact=".$this->
db->escape($id).
" AND fk_user=".$user->id;
811 $result_check = $this->
db->query($sql_check);
812 if (!$result_check || ($this->
db->num_rows($result_check) < 1)) {
814 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"user_alert(type,fk_contact,fk_user) ";
815 $sql .=
"VALUES (1,".$this->db->escape($id).
",".$user->id.
")";
816 $result = $this->
db->query($sql);
819 $this->error = $this->
db->lasterror();
825 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"user_alert ";
826 $sql .=
"WHERE type=1 AND fk_contact=".$this->db->escape($id).
" AND fk_user=".$user->id;
827 $result = $this->
db->query($sql);
830 $this->error = $this->
db->lasterror();
834 if (!$error && !$notrigger) {
837 if ($result < 0) { $error++; }
845 dol_syslog(get_class($this).
"::update Error ".$this->error, LOG_ERR);
846 $this->
db->rollback();
862 public function fetch($id, $user = null, $ref_ext =
'', $email =
'', $loadalsoroles = 0)
866 dol_syslog(get_class($this).
"::fetch id=".$id.
" ref_ext=".$ref_ext.
" email=".$email, LOG_DEBUG);
868 if (empty($id) && empty($ref_ext) && empty($email))
870 $this->error =
'BadParameter';
874 $langs->loadLangs(array(
"dict",
"companies"));
876 $sql =
"SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,";
877 $sql .=
" c.address, c.statut, c.zip, c.town,";
878 $sql .=
" c.fk_pays as country_id,";
879 $sql .=
" c.fk_departement as state_id,";
880 $sql .=
" c.birthday,";
881 $sql .=
" c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
882 $sql .=
" c.socialnetworks,";
884 $sql .=
" c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
885 $sql .=
" c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,";
886 $sql .=
" c.import_key,";
887 $sql .=
" c.datec as date_creation, c.tms as date_modification,";
888 $sql .=
" co.label as country, co.code as country_code,";
889 $sql .=
" d.nom as state, d.code_departement as state_code,";
890 $sql .=
" u.rowid as user_id, u.login as user_login,";
891 $sql .=
" s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
892 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
893 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON c.fk_pays = co.rowid";
894 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as d ON c.fk_departement = d.rowid";
895 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON c.rowid = u.fk_socpeople";
896 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
897 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
898 if ($id) $sql .=
" WHERE c.rowid = ".((int) $id);
900 $sql .=
" WHERE c.entity IN (".getEntity($this->element).
")";
902 $sql .=
" AND c.ref_ext = '".$this->db->escape($ref_ext).
"'";
905 $sql .=
" AND c.email = '".$this->db->escape($email).
"'";
915 $this->error =
'Fetch found several records. Rename one of contact to avoid duplicate.';
921 $obj = $this->
db->fetch_object(
$resql);
923 $this->
id = $obj->rowid;
924 $this->entity = $obj->entity;
925 $this->ref = $obj->rowid;
926 $this->ref_ext = $obj->ref_ext;
928 $this->civility_code = $obj->civility_code;
929 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
931 $this->lastname = $obj->lastname;
932 $this->firstname = $obj->firstname;
933 $this->address = $obj->address;
934 $this->zip = $obj->zip;
935 $this->town = $obj->town;
937 $this->date_creation = $this->
db->jdate($obj->date_creation);
938 $this->date_modification = $this->
db->jdate($obj->date_modification);
940 $this->state_id = $obj->state_id;
941 $this->state_code = $obj->state_code;
942 $this->state = $obj->state;
944 $this->country_id = $obj->country_id;
945 $this->country_code = $obj->country_id ? $obj->country_code :
'';
946 $this->country = $obj->country_id ? ($langs->trans(
'Country'.$obj->country_code) !=
'Country'.$obj->country_code ? $langs->transnoentities(
'Country'.$obj->country_code) : $obj->country) :
'';
948 $this->socid = $obj->fk_soc;
949 $this->socname = $obj->socname;
950 $this->poste = $obj->poste;
951 $this->
statut = $obj->statut;
953 $this->fk_prospectlevel = $obj->fk_prospectcontactlevel;
955 $transcode = $langs->trans(
'StatusProspect'.$obj->fk_stcommcontact);
956 $libelle = ($transcode !=
'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm);
957 $this->stcomm_id = $obj->fk_stcommcontact;
958 $this->statut_commercial = $libelle;
959 $this->stcomm_picto = $obj->stcomm_picto;
961 $this->phone_pro = trim($obj->phone);
962 $this->fax = trim($obj->fax);
963 $this->phone_perso = trim($obj->phone_perso);
964 $this->phone_mobile = trim($obj->phone_mobile);
966 $this->email = $obj->email;
967 $this->socialnetworks = (array) json_decode($obj->socialnetworks,
true);
968 $this->photo = $obj->photo;
969 $this->priv = $obj->priv;
970 $this->mail = $obj->email;
972 $this->birthday = $this->
db->jdate($obj->birthday);
973 $this->
note = $obj->note_private;
974 $this->note_private = $obj->note_private;
975 $this->note_public = $obj->note_public;
976 $this->default_lang = $obj->default_lang;
977 $this->user_id = $obj->user_id;
978 $this->user_login = $obj->user_login;
979 $this->canvas = $obj->canvas;
981 $this->import_key = $obj->import_key;
987 $sql =
"SELECT u.rowid ";
988 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
989 $sql .=
" WHERE u.fk_socpeople = ".$this->id;
996 $uobj = $this->
db->fetch_object(
$resql);
998 $this->user_id = $uobj->rowid;
1002 $this->error = $this->
db->error();
1013 $sql =
"SELECT fk_user";
1014 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_alert";
1015 $sql .=
" WHERE fk_user = ".$user->id.
" AND fk_contact = ".$this->
db->escape($id);
1022 $obj = $this->
db->fetch_object(
$resql);
1024 $this->birthday_alert = 1;
1028 $this->error = $this->
db->error();
1034 if ($loadalsoroles) {
1036 if ($resultRole < 0) {
1043 $this->error = $langs->trans(
"RecordNotFound");
1047 $this->error = $this->
db->error();
1062 unset($this->gender);
1064 if (in_array($this->civility_id, array(
'MR')) || in_array($this->civility_code, array(
'MR')))
1066 $this->gender =
'man';
1067 } elseif (in_array($this->civility_id, array(
'MME',
'MLE')) || in_array($this->civility_code, array(
'MME',
'MLE')))
1069 $this->gender =
'woman';
1087 $sql =
"SELECT tc.element, count(ec.rowid) as nb";
1088 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1089 $sql .=
" WHERE ec.fk_c_type_contact = tc.rowid";
1090 $sql .=
" AND fk_socpeople = ".$this->id;
1091 $sql .=
" AND tc.source = 'external'";
1092 $sql .=
" GROUP BY tc.element";
1094 dol_syslog(get_class($this).
"::load_ref_elements", LOG_DEBUG);
1099 while ($obj = $this->
db->fetch_object(
$resql))
1103 if ($obj->element ==
'facture') $this->ref_facturation = $obj->nb;
1104 elseif ($obj->element ==
'contrat') $this->ref_contrat = $obj->nb;
1105 elseif ($obj->element ==
'commande') $this->ref_commande = $obj->nb;
1106 elseif ($obj->element ==
'propal') $this->ref_propal = $obj->nb;
1112 $this->error = $this->
db->lasterror();
1123 public function delete($notrigger = 0)
1125 global $conf, $langs, $user;
1134 $sql =
"SELECT ec.rowid";
1135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact ec,";
1136 $sql .=
" ".MAIN_DB_PREFIX.
"c_type_contact tc";
1137 $sql .=
" WHERE ec.fk_socpeople=".$this->id;
1138 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
1139 $sql .=
" AND tc.source='external'";
1144 $num = $this->
db->num_rows(
$resql);
1147 while ($i < $num && !$error)
1149 $obj = $this->
db->fetch_object(
$resql);
1151 $sqldel =
"DELETE FROM ".MAIN_DB_PREFIX.
"element_contact";
1152 $sqldel .=
" WHERE rowid = ".$obj->rowid;
1154 $result = $this->
db->query($sqldel);
1158 $this->error = $this->
db->error().
' sql='.$sqldel;
1165 $this->error = $this->
db->error().
' sql='.$sql;
1172 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople = ".$this->id;
1178 $this->error .= $this->
db->lasterror();
1186 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_contact WHERE fk_socpeople = ".$this->id;
1192 $this->error .= $this->
db->lasterror();
1199 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"socpeople";
1200 $sql .=
" WHERE rowid=".$this->id;
1202 $result = $this->
db->query($sql);
1206 $this->error = $this->
db->error().
' sql='.$sql;
1214 if ($result < 0) $error++;
1217 if (!$error && !$notrigger)
1220 $result = $this->
call_trigger(
'CONTACT_DELETE', $user);
1221 if ($result < 0) { $error++; }
1227 $this->
db->commit();
1230 $this->
db->rollback();
1245 $sql =
"SELECT c.rowid, c.datec as datec, c.fk_user_creat,";
1246 $sql .=
" c.tms as tms, c.fk_user_modif";
1247 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
1248 $sql .=
" WHERE c.rowid = ".$this->db->escape($id);
1255 $obj = $this->
db->fetch_object(
$resql);
1257 $this->
id = $obj->rowid;
1259 if ($obj->fk_user_creat) {
1260 $cuser =
new User($this->
db);
1261 $cuser->fetch($obj->fk_user_creat);
1262 $this->user_creation = $cuser;
1265 if ($obj->fk_user_modif) {
1266 $muser =
new User($this->
db);
1267 $muser->fetch($obj->fk_user_modif);
1268 $this->user_modification = $muser;
1271 $this->date_creation = $this->
db->jdate($obj->datec);
1272 $this->date_modification = $this->
db->jdate($obj->tms);
1288 $sql =
"SELECT count(mc.email) as nb";
1289 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"mailing as m";
1290 $sql .=
" WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email).
"' ";
1291 $sql .=
" AND m.entity IN (".getEntity($this->element).
") AND mc.statut NOT IN (-1,0)";
1296 $obj = $this->
db->fetch_object(
$resql);
1302 $this->error = $this->
db->error();
1319 public function getNomUrl($withpicto = 0, $option =
'', $maxlen = 0, $moreparam =
'', $save_lastsearch_value = -1, $notooltip = 0)
1321 global $conf, $langs, $hookmanager;
1323 $result =
''; $label =
'';
1325 if (!empty($this->photo) && class_exists(
'Form'))
1327 $label .=
'<div class="photointooltip">';
1329 $label .=
'</div><div style="clear: both;"></div>';
1332 $label .=
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Contact").
'</u>';
1333 $label .=
' '.$this->getLibStatut(4);
1334 $label .=
'<br><b>'.$langs->trans(
"Name").
':</b> '.$this->
getFullName($langs);
1336 if (!empty($this->poste)) $label .=
'<br><b>'.$langs->trans(
"Poste").
':</b> '.$this->poste;
1337 $label .=
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
1338 $phonelist = array();
1339 $country_code = empty($this->country_code) ?
'': $this->country_code;
1340 if ($this->phone_pro) $phonelist[] =
dol_print_phone($this->phone_pro, $country_code, $this->
id, 0,
'',
' ',
'phone');
1341 if ($this->phone_mobile) $phonelist[] =
dol_print_phone($this->phone_mobile, $country_code, $this->
id, 0,
'',
' ',
'mobile');
1342 if ($this->phone_perso) $phonelist[] =
dol_print_phone($this->phone_perso, $country_code, $this->
id, 0,
'',
' ',
'phone');
1343 $label .=
'<br><b>'.$langs->trans(
"Phone").
':</b> '.implode(
' ', $phonelist);
1344 $label .=
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
1346 $url = DOL_URL_ROOT.
'/contact/card.php?id='.$this->id;
1348 if ($option !==
'nolink')
1351 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1352 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/',
$_SERVER[
"PHP_SELF"])) $add_save_lastsearch_values = 1;
1353 if ($add_save_lastsearch_values) $url .=
'&save_lastsearch_values=1';
1359 if (empty($notooltip)) {
1360 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
1362 $label = $langs->trans(
"ShowContact");
1363 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1365 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1366 $linkclose .=
' class="classfortooltip"';
1376 $linkstart =
'<a href="'.$url.
'"';
1377 $linkstart .= $linkclose.
'>';
1380 if ($option ==
'xxx')
1382 $linkstart =
'<a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$this->
id.$moreparam.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
1386 $result .= $linkstart;
1387 if ($withpicto) $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);
1389 $result .= $linkend;
1392 $hookmanager->initHooks(array(
'contactdao'));
1393 $parameters = array(
'id'=>$this->
id,
'getnomurl'=>$result);
1394 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1395 if ($reshook > 0) $result = $hookmanager->resPrint;
1396 else $result .= $hookmanager->resPrint;
1410 $code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite :
'')));
1411 if (empty($code))
return '';
1413 $langs->load(
"dict");
1414 return $langs->getLabelFromKey($this->
db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
1441 $labelStatus = array(
1442 0 =>
'ActivityCeased',
1445 5 =>
'ActivityCeased',
1447 $labelStatusShort = array(
1448 0 =>
'ActivityCeased',
1451 5 =>
'ActivityCeased',
1454 $statusType =
'status4';
1455 if ($status == 0 || $status == 5) $statusType =
'status5';
1457 $label = $langs->trans($labelStatus[$status]);
1458 $labelshort = $langs->trans($labelStatusShort[$status]);
1460 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
1475 if ($status ==
'1')
return $langs->trans(
'ContactPrivate');
1476 else return $langs->trans(
'ContactPublic');
1491 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe ORDER BY rowid LIMIT 1";
1494 $obj = $this->
db->fetch_object(
$resql);
1495 if ($obj) $socid = $obj->rowid;
1501 $this->specimen = 1;
1502 $this->lastname =
'DOLIBARR';
1503 $this->firstname =
'SPECIMEN';
1504 $this->address =
'21 jump street';
1505 $this->zip =
'99999';
1506 $this->town =
'MyTown';
1507 $this->country_id = 1;
1508 $this->country_code =
'FR';
1509 $this->country =
'France';
1510 $this->email =
'specimen@specimen.com';
1511 $this->socialnetworks = array(
1512 'skype' =>
'tom.hanson',
1514 $this->phone_pro =
'0909090901';
1515 $this->phone_perso =
'0909090902';
1516 $this->phone_mobile =
'0909090903';
1517 $this->fax =
'0909090909';
1519 $this->note_public =
'This is a comment (public)';
1520 $this->note_private =
'This is a comment (private)';
1522 $this->socid = $socid;
1535 global $conf, $langs, $user;
1540 if ($this->
statut == $status)
return 0;
1541 else $this->
statut = $status;
1546 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"socpeople";
1547 $sql .=
" SET statut = ".$this->statut;
1548 $sql .=
" WHERE rowid = ".$this->id;
1549 $result = $this->
db->query($sql);
1551 dol_syslog(get_class($this).
"::setstatus", LOG_DEBUG);
1555 $result = $this->
call_trigger(
'CONTACT_ENABLEDISABLE', $user);
1556 if ($result < 0) { $error++; }
1562 $this->
db->rollback();
1565 $this->
db->commit();
1583 if (!is_array($categories)) {
1584 $categories = array($categories);
1588 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1590 $existing = $c->containing($this->
id, Categorie::TYPE_CONTACT,
'id');
1593 if (is_array($existing)) {
1594 $to_del = array_diff($existing, $categories);
1595 $to_add = array_diff($categories, $existing);
1598 $to_add = $categories;
1602 foreach ($to_del as $del) {
1603 if ($c->fetch($del) > 0) {
1604 $c->del_type($this, Categorie::TYPE_CONTACT);
1607 foreach ($to_add as $add) {
1608 if ($c->fetch($add) > 0) {
1609 $c->add_type($this, Categorie::TYPE_CONTACT);
1627 'socpeople',
'societe_contacts'
1646 $sql =
"SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle as label, sc.rowid as contactroleid, sc.fk_soc as socid";
1647 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_contacts as sc, ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1648 $sql .=
" WHERE tc.rowid = sc.fk_c_type_contact";
1649 $sql .=
" AND tc.source = 'external' AND tc.active=1";
1650 $sql .=
" AND sc.fk_socpeople = ".$this->id;
1651 $sql .=
" AND sc.entity IN (".getEntity(
'societe').
')';
1655 $this->roles = array();
1657 $num = $this->
db->num_rows(
$resql);
1659 while ($obj = $this->
db->fetch_object(
$resql)) {
1660 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
1661 $libelle_element = $langs->trans(
'ContactDefault_'.$obj->element);
1662 $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));
1667 $this->error = $this->
db->lasterror();
1668 $this->errors[] = $this->
db->lasterror();
1671 if (empty($error)) {
1689 if ($element ==
'action') {
1690 $element =
'agenda';
1693 $sql =
"SELECT sc.fk_socpeople as id, sc.fk_c_type_contact";
1694 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
1695 $sql .=
", ".MAIN_DB_PREFIX.
"societe_contacts sc";
1696 $sql .=
" WHERE sc.fk_soc =".$this->socid;
1697 $sql .=
" AND sc.fk_c_type_contact=tc.rowid";
1698 $sql .=
" AND tc.element='".$this->db->escape($element).
"'";
1699 $sql .=
" AND tc.active=1";
1705 $num = $this->
db->num_rows(
$resql);
1709 $obj = $this->
db->fetch_object(
$resql);
1710 $tab[] = array(
'fk_socpeople'=>$obj->id,
'type_contact'=>$obj->fk_c_type_contact);
1717 $this->error = $this->
db->error();
1736 if (!isset($this->roles))
return;
1740 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_contacts WHERE fk_socpeople=".((int) $this->
id).
" AND entity IN (".
getEntity(
"societe_contact").
")";
1742 $result = $this->
db->query($sql);
1744 $this->errors[] = $this->
db->lasterror().
' sql='.$sql;
1747 if (count($this->roles) > 0) {
1748 foreach ($this->roles as $keyRoles => $valRoles) {
1750 if (is_array($valRoles)) {
1751 $idrole = $valRoles[
'id'];
1753 $idrole = $valRoles;
1757 if (is_array($valRoles)) {
1758 $socid = $valRoles[
'socid'];
1760 $socid = $this->socid;
1764 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_contacts";
1765 $sql .=
" (entity,";
1766 $sql .=
"date_creation,";
1768 $sql .=
"fk_c_type_contact,";
1769 $sql .=
"fk_socpeople) ";
1770 $sql .=
" VALUES (".$conf->entity.
",";
1771 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
1772 $sql .= $socid.
", ";
1773 $sql .= $idrole.
" , ";
1777 $result = $this->
db->query($sql);
1780 $this->errors[] = $this->
db->lasterror().
' sql='.$sql;
1787 if (empty($error)) {
1788 $this->
db->commit();
1791 $this->error = implode(
' ', $this->errors);
1792 $this->
db->rollback();
1807 $sql =
"SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX.
"c_stcommcontact";
1808 if ($active >= 0) $sql .=
" WHERE active = ".$active;
1810 $num = $this->
db->num_rows(
$resql);
1814 $obj = $this->
db->fetch_object(
$resql);
1815 $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);
1841 $lib = $langs->trans(
"ProspectLevel".$fk_prospectlevel);
1843 if ($lib == $langs->trans(
"ProspectLevel".$fk_prospectlevel))
1845 $lib = $langs->getLabelFromKey($this->
db, $fk_prospectlevel,
'c_prospectlevel',
'code',
'label');
1860 return $this->
update($this->
id, $user);
1872 return $this->
libProspCommStatut($this->stcomm_id, $mode, $label, $this->stcomm_picto);
1891 $langs->load(
'customers');
1895 if ($statut ==
'-1' || $statut ==
'ST_NO')
return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
1896 elseif ($statut ==
'0' || $statut ==
'ST_NEVER')
return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
1897 elseif ($statut ==
'1' || $statut ==
'ST_TODO')
return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
1898 elseif ($statut ==
'2' || $statut ==
'ST_PEND')
return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
1899 elseif ($statut ==
'3' || $statut ==
'ST_DONE')
return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
1901 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);
1906 if ($statut ==
'-1' || $statut ==
'ST_NO')
return img_action($langs->trans(
"StatusProspect-1"), -1, $picto);
1907 elseif ($statut ==
'0' || $statut ==
'ST_NEVER')
return img_action($langs->trans(
"StatusProspect0"), 0, $picto);
1908 elseif ($statut ==
'1' || $statut ==
'ST_TODO')
return img_action($langs->trans(
"StatusProspect1"), 1, $picto);
1909 elseif ($statut ==
'2' || $statut ==
'ST_PEND')
return img_action($langs->trans(
"StatusProspect2"), 2, $picto);
1910 elseif ($statut ==
'3' || $statut ==
'ST_DONE')
return img_action($langs->trans(
"StatusProspect3"), 3, $picto);
1912 return img_action(($langs->trans(
"StatusProspect".$statut) !=
"StatusProspect".$statut) ? $langs->trans(
"StatusProspect".$statut) : $label, 0, $picto);
1917 if ($statut ==
'-1' || $statut ==
'ST_NO')
return img_action($langs->trans(
"StatusProspect-1"), -1, $picto).
' '.$langs->trans(
"StatusProspect-1");
1918 elseif ($statut ==
'0' || $statut ==
'ST_NEVER')
return img_action($langs->trans(
"StatusProspect0"), 0, $picto).
' '.$langs->trans(
"StatusProspect0");
1919 elseif ($statut ==
'1' || $statut ==
'ST_TODO')
return img_action($langs->trans(
"StatusProspect1"), 1, $picto).
' '.$langs->trans(
"StatusProspect1");
1920 elseif ($statut ==
'2' || $statut ==
'ST_PEND')
return img_action($langs->trans(
"StatusProspect2"), 2, $picto).
' '.$langs->trans(
"StatusProspect2");
1921 elseif ($statut ==
'3' || $statut ==
'ST_DONE')
return img_action($langs->trans(
"StatusProspect3"), 3, $picto).
' '.$langs->trans(
"StatusProspect3");
1923 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);
1927 return "Error, mode/status not found";
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
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.
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ=" ", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
img_action($titlealt, $numaction, $picto= '')
Show logo action.
insertExtraFields($trigger= '', $userused=null)
Add/Update all extra fields values for the current object.
Class to manage third parties objects (customers, suppliers, prospects...)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
deleteExtraFields()
Delete all extra fields values for the current object.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
call_trigger($triggerName, $user)
Call trigger based on this instance.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $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.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
if(!empty($search_group)) natural_search(array("g.nom"g note
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...