29 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
45 $this->
name = preg_replace(
'/^Interface/i',
'', get_class($this));
46 $this->family =
"agenda";
47 $this->
description =
"Triggers of this module auto link contact to company.";
49 $this->version = self::VERSION_DOLIBARR;
50 $this->picto =
'company';
70 if ($action ===
'PROPAL_CREATE' || $action ===
'ORDER_CREATE' || $action ===
'BILL_CREATE'
71 || $action ===
'ORDER_SUPPLIER_CREATE' || $action ===
'BILL_SUPPLIER_CREATE' || $action ===
'PROPOSAL_SUPPLIER_CREATE'
72 || $action ===
'CONTRACT_CREATE' || $action ===
'FICHINTER_CREATE' || $action ===
'PROJECT_CREATE' || $action ===
'TICKET_CREATE') {
73 dol_syslog(
"Trigger '".$this->
name.
"' for action '".$action.
"' launched by ".__FILE__.
". id=".$object->id);
75 $socid = (property_exists($object,
'socid') ? $object->socid : $object->fk_soc);
77 if (!empty($socid) && $socid > 0) {
78 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
80 $contactdefault->socid = $socid;
83 if (method_exists($contactdefault,
'getContactRoles')) {
84 $TContact = $contactdefault->getContactRoles($object->element);
87 if (is_array($TContact) && !empty($TContact)) {
88 $TContactAlreadyLinked = array();
90 if ($object->id > 0) {
91 $TContactAlreadyLinked = array_merge($object->liste_contact(-1,
'external'), $object->liste_contact(-1,
'internal'));
94 foreach ($TContact as $i => $infos) {
95 foreach ($TContactAlreadyLinked as $contactData) {
96 if ($contactData[
'id'] == $infos[
'fk_socpeople'] && $contactData[
'fk_c_type_contact'] == $infos[
'type_contact']) {
103 foreach ($TContact as $infos) {
104 $res = $object->add_contact($infos[
'fk_socpeople'], $infos[
'type_contact']);
111 setEventMessages($langs->trans(
'ContactAddedAutomatically', $nb),
null,
'mesgs');
Class to stock current configuration.
Class that all the triggers must extend.
Class to manage translations.
Class to manage Dolibarr users.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.