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';
79 $contactdefault =
new Contact($this->db);
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']);