81 if (!isModEnabled(
'agenda')) {
86 if (preg_match(
'/^ACTION_/', $action)) {
90 $key =
'MAIN_AGENDA_ACTIONAUTO_'.$action;
99 $langs->load(
"agenda");
101 if (empty(
$object->actiontypecode)) {
102 $object->actiontypecode =
'AC_OTH_AUTO';
106 if ($action ==
'COMPANY_CREATE') {
107 '@phan-var-force Societe $object';
109 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
111 if (empty(
$object->actionmsg2)) {
112 if (empty(
$object->context[
'actionmsg2'])) {
113 $object->actionmsg2 = $langs->transnoentities(
"NewCompanyToDolibarr",
$object->name);
118 if (empty(
$object->actionmsg)) {
119 $object->actionmsg = $langs->transnoentities(
"NewCompanyToDolibarr",
$object->name);
124 } elseif ($action ==
'COMPANY_MODIFY') {
125 '@phan-var-force Societe $object';
127 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
129 if (empty(
$object->actionmsg2)) {
130 if (empty(
$object->context[
'actionmsg2'])) {
131 $object->actionmsg2 = $langs->transnoentities(
"COMPANY_MODIFYInDolibarr",
$object->name);
136 if (empty(
$object->actionmsg)) {
137 $object->actionmsg = $langs->transnoentities(
"COMPANY_MODIFYInDolibarr",
$object->name);
141 if (!empty(
$object->context[
'mergefromname'])) {
147 } elseif ($action ==
'COMPANY_SENTBYMAIL') {
148 '@phan-var-force Societe $object';
150 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
152 if (empty(
$object->actionmsg2)) {
153 if (empty(
$object->context[
'actionmsg2'])) {
154 dol_syslog(
'Trigger called with property actionmsg2 and context[actionmsg2] on object not defined', LOG_ERR);
162 } elseif ($action ==
'CONTACT_CREATE') {
163 '@phan-var-force Contact $object';
165 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
167 if (empty(
$object->actionmsg2)) {
168 if (empty(
$object->context[
'actionmsg2'])) {
169 $object->actionmsg2 = $langs->transnoentities(
"CONTACT_CREATEInDolibarr",
$object->getFullName($langs));
174 if (empty(
$object->actionmsg)) {
175 $object->actionmsg = $langs->transnoentities(
"CONTACT_CREATEInDolibarr",
$object->getFullName($langs));
180 } elseif ($action ==
'CONTACT_MODIFY') {
181 '@phan-var-force Contrat $object';
183 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
185 if (empty(
$object->actionmsg2)) {
186 if (empty(
$object->context[
'actionmsg2'])) {
187 $object->actionmsg2 = $langs->transnoentities(
"CONTACT_MODIFYInDolibarr",
$object->name);
192 if (empty(
$object->actionmsg)) {
193 $object->actionmsg = $langs->transnoentities(
"CONTACT_MODIFYInDolibarr",
$object->name);
198 } elseif ($action ==
'CONTRACT_VALIDATE') {
199 '@phan-var-force Contrat $object';
201 $langs->loadLangs(array(
"agenda",
"other",
"contracts"));
203 if (empty(
$object->actionmsg2)) {
204 if (empty(
$object->context[
'actionmsg2'])) {
210 if (empty(
$object->actionmsg)) {
215 } elseif ($action ==
'CONTRACT_SENTBYMAIL') {
216 '@phan-var-force Contrat $object';
218 $langs->loadLangs(array(
"agenda",
"other",
"contracts"));
220 if (empty(
$object->actionmsg2)) {
221 if (empty(
$object->context[
'actionmsg2'])) {
222 $object->actionmsg2 = $langs->transnoentities(
"ContractSentByEMail",
$object->ref);
227 if (empty(
$object->actionmsg)) {
228 $object->actionmsg = $langs->transnoentities(
"ContractSentByEMail",
$object->ref);
233 } elseif ($action ==
'PROPAL_VALIDATE') {
234 '@phan-var-force Propal $object';
236 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
238 if (empty(
$object->actionmsg2)) {
239 if (empty(
$object->context[
'actionmsg2'])) {
245 if (empty(
$object->actionmsg)) {
250 } elseif ($action ==
'PROPAL_MODIFY') {
251 '@phan-var-force Propal $object';
253 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
255 if (empty(
$object->actionmsg2)) {
256 if (empty(
$object->context[
'actionmsg2'])) {
262 if (empty(
$object->actionmsg)) {
267 } elseif ($action ==
'PROPAL_SENTBYMAIL') {
268 '@phan-var-force Propal $object';
270 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
272 if (empty(
$object->actionmsg2)) {
273 if (empty(
$object->context[
'actionmsg2'])) {
274 $object->actionmsg2 = $langs->transnoentities(
"ProposalSentByEMail",
$object->ref);
279 if (empty(
$object->actionmsg)) {
280 $object->actionmsg = $langs->transnoentities(
"ProposalSentByEMail",
$object->ref);
285 } elseif ($action ==
'PROPAL_CLOSE_SIGNED') {
286 '@phan-var-force Propal $object';
288 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
290 if (empty(
$object->actionmsg2)) {
291 if (empty(
$object->context[
'actionmsg2'])) {
292 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedSignedInDolibarr",
$object->ref);
297 if (empty(
$object->actionmsg)) {
298 $object->actionmsg = $langs->transnoentities(
"PropalClosedSignedInDolibarr",
$object->ref);
302 } elseif ($action ==
'PROPAL_CLASSIFY_BILLED') {
303 '@phan-var-force Propal $object';
305 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
307 if (empty(
$object->actionmsg2)) {
308 if (empty(
$object->context[
'actionmsg2'])) {
309 $object->actionmsg2 = $langs->transnoentities(
"PropalClassifiedBilledInDolibarr",
$object->ref);
314 if (empty(
$object->actionmsg)) {
315 $object->actionmsg = $langs->transnoentities(
"PropalClassifiedBilledInDolibarr",
$object->ref);
319 } elseif ($action ==
'PROPAL_CLOSE_REFUSED') {
320 '@phan-var-force Propal $object';
322 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
324 if (empty(
$object->actionmsg2)) {
325 if (empty(
$object->context[
'actionmsg2'])) {
326 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedRefusedInDolibarr",
$object->ref);
331 if (empty(
$object->actionmsg)) {
332 $object->actionmsg = $langs->transnoentities(
"PropalClosedRefusedInDolibarr",
$object->ref);
336 } elseif ($action ==
'ORDER_VALIDATE') {
337 '@phan-var-force Commande $object';
339 $langs->loadLangs(array(
"agenda",
"orders"));
341 if (empty(
$object->actionmsg2)) {
342 if (empty(
$object->context[
'actionmsg2'])) {
348 if (empty(
$object->actionmsg)) {
353 } elseif ($action ==
'ORDER_CLOSE') {
354 '@phan-var-force Commande $object';
356 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
358 if (empty(
$object->actionmsg2)) {
359 if (empty(
$object->context[
'actionmsg2'])) {
360 $object->actionmsg2 = $langs->transnoentities(
"OrderDeliveredInDolibarr",
$object->ref);
365 if (empty(
$object->actionmsg)) {
366 $object->actionmsg = $langs->transnoentities(
"OrderDeliveredInDolibarr",
$object->ref);
370 } elseif ($action ==
'ORDER_CLASSIFY_BILLED') {
371 '@phan-var-force Commande $object';
373 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
375 if (empty(
$object->actionmsg2)) {
376 if (empty(
$object->context[
'actionmsg2'])) {
377 $object->actionmsg2 = $langs->transnoentities(
"OrderBilledInDolibarr",
$object->ref);
382 if (empty(
$object->actionmsg)) {
383 $object->actionmsg = $langs->transnoentities(
"OrderBilledInDolibarr",
$object->ref);
387 } elseif ($action ==
'ORDER_CANCEL') {
388 '@phan-var-force Commande $object';
390 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
392 if (empty(
$object->actionmsg2)) {
393 if (empty(
$object->context[
'actionmsg2'])) {
394 $object->actionmsg2 = $langs->transnoentities(
"OrderCanceledInDolibarr",
$object->ref);
399 if (empty(
$object->actionmsg)) {
400 $object->actionmsg = $langs->transnoentities(
"OrderCanceledInDolibarr",
$object->ref);
404 } elseif ($action ==
'ORDER_SENTBYMAIL') {
405 '@phan-var-force Commande $object';
407 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
409 if (empty(
$object->actionmsg2)) {
410 if (empty(
$object->context[
'actionmsg2'])) {
411 $object->actionmsg2 = $langs->transnoentities(
"OrderSentByEMail",
$object->ref);
416 if (empty(
$object->actionmsg)) {
417 $object->actionmsg = $langs->transnoentities(
"OrderSentByEMail",
$object->ref);
422 } elseif ($action ==
'BILL_VALIDATE') {
423 '@phan-var-force Facture $object';
425 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
427 if (empty(
$object->actionmsg2)) {
428 if (empty(
$object->context[
'actionmsg2'])) {
434 if (empty(
$object->actionmsg)) {
439 } elseif ($action ==
'BILL_UNVALIDATE') {
440 '@phan-var-force Facture $object';
442 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
444 if (empty(
$object->actionmsg2)) {
445 if (empty(
$object->context[
'actionmsg2'])) {
446 $object->actionmsg2 = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr",
$object->ref);
451 if (empty(
$object->actionmsg)) {
452 $object->actionmsg = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr",
$object->ref);
456 } elseif ($action ==
'BILL_SENTBYMAIL') {
457 '@phan-var-force Facture $object';
459 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
461 if (empty(
$object->actionmsg2)) {
462 if (empty(
$object->context[
'actionmsg2'])) {
463 $object->actionmsg2 = $langs->transnoentities(
"InvoiceSentByEMail",
$object->ref);
468 if (empty(
$object->actionmsg)) {
469 $object->actionmsg = $langs->transnoentities(
"InvoiceSentByEMail",
$object->ref);
474 } elseif ($action ==
'BILL_PAYED') {
475 '@phan-var-force Facture $object';
477 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
480 if (empty(
$object->actionmsg2)) {
481 if (empty(
$object->context[
'actionmsg2'])) {
482 $object->actionmsg2 = $langs->transnoentities(
"InvoicePaidInDolibarr",
$object->ref);
487 if (empty(
$object->actionmsg)) {
488 $object->actionmsg = $langs->transnoentities(
"InvoicePaidInDolibarr",
$object->ref);
492 } elseif ($action ==
'BILL_CANCEL') {
493 '@phan-var-force Facture $object';
495 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
497 if (empty(
$object->actionmsg2)) {
498 if (empty(
$object->context[
'actionmsg2'])) {
499 $object->actionmsg2 = $langs->transnoentities(
"InvoiceCanceledInDolibarr",
$object->ref);
504 if (empty(
$object->actionmsg)) {
505 $object->actionmsg = $langs->transnoentities(
"InvoiceCanceledInDolibarr",
$object->ref);
509 } elseif ($action ==
'FICHINTER_CREATE') {
510 '@phan-var-force Fichinter $object';
512 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
514 if (empty(
$object->actionmsg2)) {
515 if (empty(
$object->context[
'actionmsg2'])) {
516 $object->actionmsg2 = $langs->transnoentities(
"InterventionCreatedInDolibarr",
$object->ref);
521 if (empty(
$object->actionmsg)) {
522 $object->actionmsg = $langs->transnoentities(
"InterventionCreatedInDolibarr",
$object->ref);
528 } elseif ($action ==
'FICHINTER_VALIDATE') {
529 '@phan-var-force Fichinter $object';
531 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
533 if (empty(
$object->actionmsg2)) {
534 if (empty(
$object->context[
'actionmsg2'])) {
540 if (empty(
$object->actionmsg)) {
547 } elseif ($action ==
'FICHINTER_MODIFY') {
548 '@phan-var-force Fichinter $object';
550 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
552 if (empty(
$object->actionmsg2)) {
553 if (empty(
$object->context[
'actionmsg2'])) {
554 $object->actionmsg2 = $langs->transnoentities(
"InterventionModifiedInDolibarr",
$object->ref);
559 if (empty(
$object->actionmsg)) {
560 $object->actionmsg = $langs->transnoentities(
"InterventionModifiedInDolibarr",
$object->ref);
566 } elseif ($action ==
'FICHINTER_SENTBYMAIL') {
567 '@phan-var-force Fichinter $object';
569 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
571 if (empty(
$object->actionmsg2)) {
572 if (empty(
$object->context[
'actionmsg2'])) {
573 $object->actionmsg2 = $langs->transnoentities(
"InterventionSentByEMail",
$object->ref);
578 if (empty(
$object->actionmsg)) {
579 $object->actionmsg = $langs->transnoentities(
"InterventionSentByEMail",
$object->ref);
584 } elseif ($action ==
'FICHINTER_CLASSIFY_BILLED') {
585 '@phan-var-force Fichinter $object';
587 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
589 if (empty(
$object->actionmsg2)) {
590 if (empty(
$object->context[
'actionmsg2'])) {
591 $object->actionmsg2 = $langs->transnoentities(
"InterventionClassifiedBilledInDolibarr",
$object->ref);
596 if (empty(
$object->actionmsg)) {
597 $object->actionmsg = $langs->transnoentities(
"InterventionClassifiedBilledInDolibarr",
$object->ref);
601 } elseif ($action ==
'FICHINTER_CLASSIFY_UNBILLED') {
602 '@phan-var-force Fichinter $object';
604 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
606 if (empty(
$object->actionmsg2)) {
607 if (empty(
$object->context[
'actionmsg2'])) {
608 $object->actionmsg2 = $langs->transnoentities(
"InterventionClassifiedUnbilledInDolibarr",
$object->ref);
613 if (empty(
$object->actionmsg)) {
614 $object->actionmsg = $langs->transnoentities(
"InterventionClassifiedUnbilledInDolibarr",
$object->ref);
618 } elseif ($action ==
'FICHINTER_CLOSE') {
619 '@phan-var-force Fichinter $object';
621 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
623 if (empty(
$object->actionmsg2)) {
624 if (empty(
$object->context[
'actionmsg2'])) {
625 $object->actionmsg2 = $langs->transnoentities(
"InterventionClosedInDolibarr",
$object->ref);
630 if (empty(
$object->actionmsg)) {
631 $object->actionmsg = $langs->transnoentities(
"InterventionClosedInDolibarr",
$object->ref);
637 } elseif ($action ==
'FICHINTER_DELETE') {
638 '@phan-var-force Fichinter $object';
640 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
642 if (empty(
$object->actionmsg2)) {
643 if (empty(
$object->context[
'actionmsg2'])) {
644 $object->actionmsg2 = $langs->transnoentities(
"InterventionDeletedInDolibarr",
$object->ref);
649 if (empty(
$object->actionmsg)) {
650 $object->actionmsg = $langs->transnoentities(
"InterventionDeletedInDolibarr",
$object->ref);
656 } elseif ($action ==
'SHIPPING_VALIDATE') {
657 '@phan-var-force Expedition $object';
659 $langs->loadLangs(array(
"agenda",
"other",
"sendings"));
661 if (empty(
$object->actionmsg2)) {
662 if (empty(
$object->context[
'actionmsg2'])) {
668 if (empty(
$object->actionmsg)) {
674 } elseif ($action ==
'SHIPPING_SENTBYMAIL') {
675 '@phan-var-force Expedition $object';
677 $langs->loadLangs(array(
"agenda",
"other",
"sendings"));
679 if (empty(
$object->actionmsg2)) {
680 if (empty(
$object->context[
'actionmsg2'])) {
681 $object->actionmsg2 = $langs->transnoentities(
"ShippingSentByEMail",
$object->ref);
686 if (empty(
$object->actionmsg)) {
687 $object->actionmsg = $langs->transnoentities(
"ShippingSentByEMail",
$object->ref);
692 } elseif ($action ==
'RECEPTION_VALIDATE') {
693 '@phan-var-force Reception $object';
694 $langs->load(
"agenda");
695 $langs->load(
"other");
696 $langs->load(
"receptions");
698 if (empty(
$object->actionmsg2)) {
699 if (empty(
$object->context[
'actionmsg2'])) {
705 if (empty(
$object->actionmsg)) {
711 } elseif ($action ==
'RECEPTION_SENTBYMAIL') {
712 '@phan-var-force Reception $object';
713 $langs->load(
"agenda");
714 $langs->load(
"other");
715 $langs->load(
"receptions");
717 if (empty(
$object->actionmsg2)) {
718 if (empty(
$object->context[
'actionmsg2'])) {
719 $object->actionmsg2 = $langs->transnoentities(
"ReceptionSentByEMail",
$object->ref);
724 if (empty(
$object->actionmsg)) {
725 $object->actionmsg = $langs->transnoentities(
"ReceptionSentByEMail",
$object->ref);
730 } elseif ($action ==
'PROPOSAL_SUPPLIER_VALIDATE') {
731 '@phan-var-force SupplierProposal $object';
733 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
735 if (empty(
$object->actionmsg2)) {
736 if (empty(
$object->context[
'actionmsg2'])) {
742 if (empty(
$object->actionmsg)) {
747 } elseif ($action ==
'PROPOSAL_SUPPLIER_SENTBYMAIL') {
748 '@phan-var-force SupplierProposal $object';
750 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
752 if (empty(
$object->actionmsg2)) {
753 if (empty(
$object->context[
'actionmsg2'])) {
754 $object->actionmsg2 = $langs->transnoentities(
"ProposalSentByEMail",
$object->ref);
759 if (empty(
$object->actionmsg)) {
760 $object->actionmsg = $langs->transnoentities(
"ProposalSentByEMail",
$object->ref);
765 } elseif ($action ==
'PROPOSAL_SUPPLIER_CLOSE_SIGNED') {
766 '@phan-var-force SupplierProposal $object';
768 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
770 if (empty(
$object->actionmsg2)) {
771 if (empty(
$object->context[
'actionmsg2'])) {
772 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedSignedInDolibarr",
$object->ref);
777 if (empty(
$object->actionmsg)) {
778 $object->actionmsg = $langs->transnoentities(
"PropalClosedSignedInDolibarr",
$object->ref);
782 } elseif ($action ==
'PROPOSAL_SUPPLIER_CLOSE_REFUSED') {
783 '@phan-var-force SupplierProposal $object';
785 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
787 if (empty(
$object->actionmsg2)) {
788 if (empty(
$object->context[
'actionmsg2'])) {
789 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedRefusedInDolibarr",
$object->ref);
794 if (empty(
$object->actionmsg)) {
795 $object->actionmsg = $langs->transnoentities(
"PropalClosedRefusedInDolibarr",
$object->ref);
799 } elseif ($action ==
'ORDER_SUPPLIER_CREATE') {
800 '@phan-var-force CommandeFournisseur $object';
802 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
804 if (empty(
$object->actionmsg2)) {
805 if (empty(
$object->context[
'actionmsg2'])) {
811 if (empty(
$object->actionmsg)) {
816 } elseif ($action ==
'ORDER_SUPPLIER_VALIDATE') {
817 '@phan-var-force CommandeFournisseur $object';
819 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
821 if (empty(
$object->actionmsg2)) {
822 if (empty(
$object->context[
'actionmsg2'])) {
828 if (empty(
$object->actionmsg)) {
833 } elseif ($action ==
'ORDER_SUPPLIER_APPROVE') {
834 '@phan-var-force CommandeFournisseur $object';
836 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
838 if (empty(
$object->actionmsg2)) {
839 if (empty(
$object->context[
'actionmsg2'])) {
840 $object->actionmsg2 = $langs->transnoentities(
"OrderApprovedInDolibarr",
$object->ref);
845 if (empty(
$object->actionmsg)) {
846 $object->actionmsg = $langs->transnoentities(
"OrderApprovedInDolibarr",
$object->ref);
850 } elseif ($action ==
'ORDER_SUPPLIER_REFUSE') {
851 '@phan-var-force CommandeFournisseur $object';
853 $langs->loadLangs(array(
"agenda",
"other",
"orders",
"main"));
855 if (empty(
$object->actionmsg2)) {
856 if (empty(
$object->context[
'actionmsg2'])) {
857 $object->actionmsg2 = $langs->transnoentities(
"OrderRefusedInDolibarr",
$object->ref);
862 if (empty(
$object->actionmsg)) {
863 $object->actionmsg = $langs->transnoentities(
"OrderRefusedInDolibarr",
$object->ref);
866 if (!empty(
$object->refuse_note)) {
868 $object->actionmsg .= $langs->trans(
"Reason") .
': '.$object->refuse_note;
872 } elseif ($action ==
'ORDER_SUPPLIER_CANCEL') {
873 '@phan-var-force CommandeFournisseur $object';
875 $langs->loadLangs(array(
"agenda",
"other",
"orders",
"main"));
877 if (empty(
$object->actionmsg2)) {
878 if (empty(
$object->context[
'actionmsg2'])) {
879 $object->actionmsg2 = $langs->transnoentities(
"OrderCanceledInDolibarr",
$object->ref);
884 if (empty(
$object->actionmsg)) {
885 $object->actionmsg = $langs->transnoentities(
"OrderCanceledInDolibarr",
$object->ref);
888 if (!empty(
$object->cancel_note)) {
890 $object->actionmsg .= $langs->trans(
"Reason") .
': '.$object->cancel_note;
894 } elseif ($action ==
'ORDER_SUPPLIER_SUBMIT') {
895 '@phan-var-force CommandeFournisseur $object';
897 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
899 if (empty(
$object->actionmsg2)) {
900 if (empty(
$object->context[
'actionmsg2'])) {
901 $object->actionmsg2 = $langs->transnoentities(
"SupplierOrderSubmitedInDolibarr", (
$object->newref ?:
$object->ref),
$object->getInputMethod());
906 if (empty(
$object->actionmsg)) {
910 if (!empty(
$object->context[
'comments'])) {
912 $object->actionmsg .= $langs->trans(
"Comment") .
': '.$object->context[
'comments'];
916 } elseif ($action ==
'ORDER_SUPPLIER_RECEIVE') {
917 '@phan-var-force CommandeFournisseur $object';
919 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
921 if (empty(
$object->actionmsg2)) {
922 if (empty(
$object->context[
'actionmsg2'])) {
928 if (empty(
$object->actionmsg)) {
933 } elseif ($action ==
'ORDER_SUPPLIER_SENTBYMAIL') {
934 '@phan-var-force CommandeFournisseur $object';
936 $langs->loadLangs(array(
"agenda",
"other",
"bills",
"orders"));
938 if (empty(
$object->actionmsg2)) {
939 if (empty(
$object->context[
'actionmsg2'])) {
940 $object->actionmsg2 = $langs->transnoentities(
"SupplierOrderSentByEMail",
$object->ref);
945 if (empty(
$object->actionmsg)) {
946 $object->actionmsg = $langs->transnoentities(
"SupplierOrderSentByEMail",
$object->ref);
951 } elseif ($action ==
'ORDER_SUPPLIER_CLASSIFY_BILLED') {
952 '@phan-var-force CommandeFournisseur $object';
954 $langs->loadLangs(array(
"agenda",
"other",
"bills",
"orders"));
956 if (empty(
$object->actionmsg2)) {
957 if (empty(
$object->context[
'actionmsg2'])) {
958 $object->actionmsg2 = $langs->transnoentities(
"SupplierOrderClassifiedBilled",
$object->ref);
963 if (empty(
$object->actionmsg)) {
964 $object->actionmsg = $langs->transnoentities(
"SupplierOrderClassifiedBilled",
$object->ref);
968 } elseif ($action ==
'BILL_SUPPLIER_CREATE') {
969 '@phan-var-force FactureFournisseur $object';
971 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
973 if (empty(
$object->actionmsg2)) {
974 if (empty(
$object->context[
'actionmsg2'])) {
980 if (empty(
$object->actionmsg)) {
985 } elseif ($action ==
'BILL_SUPPLIER_VALIDATE') {
986 '@phan-var-force FactureFournisseur $object';
988 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
990 if (empty(
$object->actionmsg2)) {
991 if (empty(
$object->context[
'actionmsg2'])) {
997 if (empty(
$object->actionmsg)) {
1002 } elseif ($action ==
'BILL_SUPPLIER_UNVALIDATE') {
1003 '@phan-var-force FactureFournisseur $object';
1005 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
1007 if (empty(
$object->actionmsg2)) {
1008 if (empty(
$object->context[
'actionmsg2'])) {
1009 $object->actionmsg2 = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr",
$object->ref);
1014 if (empty(
$object->actionmsg)) {
1015 $object->actionmsg = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr",
$object->ref);
1019 } elseif ($action ==
'BILL_SUPPLIER_SENTBYMAIL') {
1020 '@phan-var-force FactureFournisseur $object';
1022 $langs->loadLangs(array(
"agenda",
"other",
"bills",
"orders"));
1024 if (empty(
$object->actionmsg2)) {
1025 if (empty(
$object->context[
'actionmsg2'])) {
1026 $object->actionmsg2 = $langs->transnoentities(
"SupplierInvoiceSentByEMail",
$object->ref);
1031 if (empty(
$object->actionmsg)) {
1032 $object->actionmsg = $langs->transnoentities(
"SupplierInvoiceSentByEMail",
$object->ref);
1037 } elseif ($action ==
'BILL_SUPPLIER_PAYED') {
1038 '@phan-var-force FactureFournisseur $object';
1040 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
1042 if (empty(
$object->actionmsg2)) {
1043 if (empty(
$object->context[
'actionmsg2'])) {
1044 $object->actionmsg2 = $langs->transnoentities(
"InvoicePaidInDolibarr",
$object->ref);
1049 if (empty(
$object->actionmsg)) {
1050 $object->actionmsg = $langs->transnoentities(
"InvoicePaidInDolibarr",
$object->ref);
1054 } elseif ($action ==
'BILL_SUPPLIER_CANCELED') {
1056 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
1058 if (empty(
$object->actionmsg2)) {
1059 if (empty(
$object->context[
'actionmsg2'])) {
1060 $object->actionmsg2 = $langs->transnoentities(
"InvoiceCanceledInDolibarr",
$object->ref);
1065 if (empty(
$object->actionmsg)) {
1066 $object->actionmsg = $langs->transnoentities(
"InvoiceCanceledInDolibarr",
$object->ref);
1070 } elseif ($action ==
'MEMBER_VALIDATE') {
1071 '@phan-var-force Adherent $object';
1074 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1076 if (empty(
$object->actionmsg2)) {
1077 if (empty(
$object->context[
'actionmsg2'])) {
1078 $object->actionmsg2 = $langs->transnoentities(
"MemberValidatedInDolibarr",
$object->getFullName($langs));
1083 if (empty(
$object->actionmsg)) {
1084 $object->actionmsg = $langs->transnoentities(
"MemberValidatedInDolibarr",
$object->getFullName($langs));
1085 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.
$object->getFullName($langs);
1086 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->type;
1090 } elseif ($action ==
'MEMBER_MODIFY') {
1091 '@phan-var-force Adherent $object';
1093 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1095 if (empty(
$object->actionmsg2)) {
1096 if (empty(
$object->context[
'actionmsg2'])) {
1097 $object->actionmsg2 = $langs->transnoentities(
"MemberModifiedInDolibarr",
$object->getFullName($langs));
1102 if (empty(
$object->actionmsg)) {
1103 $object->actionmsg = $langs->transnoentities(
"MemberModifiedInDolibarr",
$object->getFullName($langs));
1104 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.
$object->getFullName($langs);
1105 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->type;
1109 } elseif ($action ==
'MEMBER_SUBSCRIPTION_CREATE') {
1110 '@phan-var-force Subscription $object';
1112 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1114 $member = (isset(
$object->context[
'member']) ?
$object->context[
'member'] :
null);
1115 if (!is_object($member)) {
1116 dol_syslog(
"Execute a trigger MEMBER_SUBSCRIPTION_CREATE with context key 'member' not an object");
1117 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1119 $member->fetch(
$object->fk_adherent);
1122 if (empty(
$object->actionmsg2)) {
1123 if (empty(
$object->context[
'actionmsg2'])) {
1124 $object->actionmsg2 = $langs->transnoentities(
"MemberSubscriptionAddedInDolibarr",
$object->id, $member->getFullName($langs));
1129 if (empty(
$object->actionmsg)) {
1130 $object->actionmsg = $langs->transnoentities(
"MemberSubscriptionAddedInDolibarr",
$object->id, $member->getFullName($langs));
1131 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$member->getFullName($langs);
1132 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->fk_type;
1133 $object->actionmsg .=
"\n".$langs->transnoentities(
"Amount").
': '.
$object->amount;
1141 } elseif ($action ==
'MEMBER_SUBSCRIPTION_MODIFY') {
1142 '@phan-var-force Subscription $object';
1144 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1146 $member =
$object->context[
'member'];
1147 if (!is_object($member)) {
1148 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1150 $member->fetch(
$object->fk_adherent);
1153 if (empty(
$object->actionmsg2)) {
1154 if (empty(
$object->context[
'actionmsg2'])) {
1155 $object->actionmsg2 = $langs->transnoentities(
"MemberSubscriptionModifiedInDolibarr",
$object->id, $member->getFullName($langs));
1160 if (empty(
$object->actionmsg)) {
1161 $object->actionmsg = $langs->transnoentities(
"MemberSubscriptionModifiedInDolibarr",
$object->id, $member->getFullName($langs));
1162 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$member->getFullName($langs);
1163 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->fk_type;
1164 $object->actionmsg .=
"\n".$langs->transnoentities(
"Amount").
': '.
$object->amount;
1172 } elseif ($action ==
'MEMBER_SUBSCRIPTION_DELETE') {
1173 '@phan-var-force Subscription $object';
1175 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1177 $member =
$object->context[
'member'];
1178 if (!is_object($member)) {
1179 dol_syslog(
"Execute a trigger MEMBER_SUBSCRIPTION_CREATE with context key 'member' not an object");
1180 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
1182 $member->fetch(
$object->fk_adherent);
1185 if (empty(
$object->actionmsg2)) {
1186 if (empty(
$object->context[
'actionmsg2'])) {
1187 $object->actionmsg2 = $langs->transnoentities(
"MemberSubscriptionDeletedInDolibarr",
$object->ref, $member->getFullName($langs));
1192 if (empty(
$object->actionmsg)) {
1193 $object->actionmsg = $langs->transnoentities(
"MemberSubscriptionDeletedInDolibarr",
$object->ref, $member->getFullName($langs));
1194 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$member->getFullName($langs);
1195 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->fk_type;
1196 $object->actionmsg .=
"\n".$langs->transnoentities(
"Amount").
': '.
$object->amount;
1204 } elseif ($action ==
'MEMBER_RESILIATE') {
1205 '@phan-var-force Adherent $object';
1207 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1209 if (empty(
$object->actionmsg2)) {
1210 if (empty(
$object->context[
'actionmsg2'])) {
1211 $object->actionmsg2 = $langs->transnoentities(
"MemberResiliatedInDolibarr",
$object->getFullName($langs));
1216 if (empty(
$object->actionmsg)) {
1217 $object->actionmsg = $langs->transnoentities(
"MemberResiliatedInDolibarr",
$object->getFullName($langs));
1218 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.
$object->getFullName($langs);
1219 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->type;
1223 } elseif ($action ==
'MEMBER_DELETE') {
1224 '@phan-var-force Adherent $object';
1226 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1228 if (empty(
$object->actionmsg2)) {
1229 if (empty(
$object->context[
'actionmsg2'])) {
1230 $object->actionmsg2 = $langs->transnoentities(
"MemberDeletedInDolibarr",
$object->getFullName($langs));
1235 if (empty(
$object->actionmsg)) {
1236 $object->actionmsg = $langs->transnoentities(
"MemberDeletedInDolibarr",
$object->getFullName($langs));
1237 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.
$object->getFullName($langs);
1238 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->type;
1242 } elseif ($action ==
'MEMBER_EXCLUDE') {
1243 '@phan-var-force Adherent $object';
1245 $langs->loadLangs(array(
"agenda",
"other",
"members"));
1247 if (empty(
$object->actionmsg2)) {
1248 if (empty(
$object->context[
'actionmsg2'])) {
1249 $object->actionmsg2 = $langs->transnoentities(
"MemberExcludedInDolibarr",
$object->getFullName($langs));
1254 if (empty(
$object->actionmsg)) {
1255 $object->actionmsg = $langs->transnoentities(
"MemberExcludedInDolibarr",
$object->getFullName($langs));
1256 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.
$object->getFullName($langs);
1257 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.
$object->type;
1261 } elseif ($action ==
'PROJECT_CREATE') {
1262 '@phan-var-force Project $object';
1265 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1267 if (empty(
$object->actionmsg2)) {
1268 if (empty(
$object->context[
'actionmsg2'])) {
1269 $object->actionmsg2 = $langs->transnoentities(
"ProjectCreatedInDolibarr",
$object->ref);
1274 if (empty(
$object->actionmsg)) {
1275 $object->actionmsg = $langs->transnoentities(
"ProjectCreatedInDolibarr",
$object->ref);
1276 $object->actionmsg .=
"\n".$langs->transnoentities(
"Project").
': '.
$object->ref;
1280 } elseif ($action ==
'PROJECT_VALIDATE') {
1281 '@phan-var-force Project $object';
1283 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1285 if (empty(
$object->actionmsg2)) {
1286 if (empty(
$object->context[
'actionmsg2'])) {
1287 $object->actionmsg2 = $langs->transnoentities(
"ProjectValidatedInDolibarr",
$object->ref);
1292 if (empty(
$object->actionmsg)) {
1293 $object->actionmsg = $langs->transnoentities(
"ProjectValidatedInDolibarr",
$object->ref);
1294 $object->actionmsg .=
"\n".$langs->transnoentities(
"Project").
': '.
$object->ref;
1298 } elseif ($action ==
'PROJECT_MODIFY') {
1299 '@phan-var-force Project $object';
1301 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1303 if (empty(
$object->actionmsg2)) {
1304 if (empty(
$object->context[
'actionmsg2'])) {
1305 $object->actionmsg2 = $langs->transnoentities(
"ProjectModifiedInDolibarr",
$object->ref);
1310 if (empty(
$object->actionmsg)) {
1311 $object->actionmsg = $langs->transnoentities(
"ProjectModifiedInDolibarr",
$object->ref);
1316 $object->actionmsg .=
"\n".$langs->transnoentitiesnoconv(
"OpportunityStatus").
': '.
$object->oldcopy->opp_status.
' -> '.
$object->opp_status;
1320 } elseif ($action ==
'PROJECT_SENTBYMAIL') {
1321 '@phan-var-force Project $object';
1323 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1325 if (empty(
$object->actionmsg2)) {
1326 if (empty(
$object->context[
'actionmsg2'])) {
1327 $object->actionmsg2 = $langs->transnoentities(
"ProjectSentByEMail",
$object->ref);
1332 if (empty(
$object->actionmsg)) {
1333 $object->actionmsg = $langs->transnoentities(
"ProjectSentByEMail",
$object->ref);
1338 } elseif ($action ==
'PROJECT_DELETE') {
1339 '@phan-var-force Project $object';
1341 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1343 if (empty(
$object->actionmsg2)) {
1344 $object->actionmsg2 = $langs->transnoentities(
"ProjectDeletedInDolibarr",
$object->ref);
1346 $object->actionmsg = $langs->transnoentities(
"ProjectDeletedInDolibarr",
$object->ref);
1349 } elseif ($action ==
'PROJECT_CLOSE') {
1351 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1353 if (empty(
$object->actionmsg2)) {
1354 if (empty(
$object->context[
'actionmsg2'])) {
1355 $object->actionmsg2 = $langs->transnoentities(
"ProjectClosedInDolibarr",
$object->ref);
1360 if (empty(
$object->actionmsg)) {
1361 $object->actionmsg = $langs->transnoentities(
"ProjectClosedInDolibarr",
$object->ref);
1365 } elseif ($action ==
'TASK_CREATE') {
1366 '@phan-var-force Task $object';
1369 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1371 if (empty(
$object->actionmsg2)) {
1372 if (empty(
$object->context[
'actionmsg2'])) {
1373 $object->actionmsg2 = $langs->transnoentities(
"TaskCreatedInDolibarr",
$object->ref);
1378 if (empty(
$object->actionmsg)) {
1379 $object->actionmsg = $langs->transnoentities(
"TaskCreatedInDolibarr",
$object->ref);
1380 $object->actionmsg .=
"\n".$langs->transnoentities(
"Task").
': '.
$object->ref;
1384 } elseif ($action ==
'TASK_MODIFY') {
1385 '@phan-var-force Task $object';
1387 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1389 if (empty(
$object->actionmsg2)) {
1390 if (empty(
$object->context[
'actionmsg2'])) {
1391 $object->actionmsg2 = $langs->transnoentities(
"TaskModifiedInDolibarr",
$object->ref);
1396 if (empty(
$object->actionmsg)) {
1397 $object->actionmsg = $langs->transnoentities(
"TaskModifieddInDolibarr",
$object->ref);
1398 $object->actionmsg .=
"\n".$langs->transnoentities(
"Task").
': '.
$object->ref;
1402 } elseif ($action ==
'TASK_DELETE') {
1403 '@phan-var-force Task $object';
1405 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1407 if (empty(
$object->actionmsg2)) {
1408 if (empty(
$object->context[
'actionmsg2'])) {
1409 $object->actionmsg2 = $langs->transnoentities(
"TaskDeletedInDolibarr",
$object->ref);
1414 if (empty(
$object->actionmsg)) {
1415 $object->actionmsg = $langs->transnoentities(
"TaskDeletedInDolibarr",
$object->ref);
1416 $object->actionmsg .=
"\n".$langs->transnoentities(
"Task").
': '.
$object->ref;
1420 } elseif ($action ==
'TICKET_ASSIGNED') {
1421 '@phan-var-force Ticket $object';
1423 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
1425 if (empty(
$object->actionmsg2)) {
1426 if (empty(
$object->context[
'actionmsg2'])) {
1427 $object->actionmsg2 = $langs->transnoentities(
"TICKET_ASSIGNEDInDolibarr",
$object->ref);
1432 if (empty(
$object->actionmsg)) {
1433 $object->actionmsg = $langs->transnoentities(
"TICKET_ASSIGNEDInDolibarr",
$object->ref);
1436 if (
$object->oldcopy->fk_user_assign > 0) {
1437 $tmpuser =
new User($this->db);
1438 $tmpuser->fetch(
$object->oldcopy->fk_user_assign);
1439 $object->actionmsg .=
"\n".$langs->transnoentities(
"OldUser").
': '.$tmpuser->getFullName($langs);
1441 $object->actionmsg .=
"\n".$langs->transnoentities(
"OldUser").
': '.$langs->trans(
"None");
1443 if (
$object->fk_user_assign > 0) {
1444 $tmpuser =
new User($this->db);
1445 $tmpuser->fetch(
$object->fk_user_assign);
1446 $object->actionmsg .=
"\n".$langs->transnoentities(
"NewUser").
': '.$tmpuser->getFullName($langs);
1448 $object->actionmsg .=
"\n".$langs->transnoentities(
"NewUser").
': '.$langs->trans(
"None");
1460 if (!empty(
$object->context[
'actionmsg']) && empty(
$object->actionmsg)) {
1463 if (!empty(
$object->context[
'actionmsg2']) && empty(
$object->actionmsg2)) {
1468 if (empty(
$object->actionmsg2)) {
1470 $langs->loadLangs(array(
"agenda",
"other"));
1471 if ($langs->transnoentities($action.
"InDolibarr", (empty(
$object->newref) ?
$object->ref :
$object->newref)) != $action.
"InDolibarr") {
1474 $tmp = explode(
'_', $action);
1475 $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp) - 1].
"InDolibarr", (empty(
$object->newref) ?
$object->ref :
$object->newref));
1478 if (empty(
$object->actionmsg)) {
1480 $langs->loadLangs(array(
"agenda",
"other"));
1481 if ($langs->transnoentities($action.
"InDolibarr", (empty(
$object->newref) ?
$object->ref :
$object->newref)) != $action.
"InDolibarr") {
1484 $tmp = explode(
'_', $action);
1485 $object->actionmsg = $langs->transnoentities($tmp[count($tmp) - 1].
"InDolibarr", (empty(
$object->newref) ?
$object->ref :
$object->newref));
1487 if (isModEnabled(
'multicompany') && property_exists(
$object,
'entity') &&
$object->entity > 1) {
1488 $object->actionmsg .=
' ('.$langs->trans(
"Entity").
' '.
$object->entity.
')';
1493 if (!empty(
$object->context[
'actionmsgmore'])) {
1496 if (!empty(
$object->context[
'actionmsg2more'])) {
1507 if (empty(
$object->trackid)) {
1509 if (preg_match(
'/^COMPANY_/', $action)) {
1510 $object->trackid =
'thi'.$object->id;
1511 } elseif (preg_match(
'/^CONTACT_/', $action)) {
1512 $object->trackid =
'ctc'.$object->id;
1513 } elseif (preg_match(
'/^CONTRACT_/', $action)) {
1514 $object->trackid =
'con'.$object->id;
1515 } elseif (preg_match(
'/^PROPAL_/', $action)) {
1516 $object->trackid =
'pro'.$object->id;
1517 } elseif (preg_match(
'/^ORDER_/', $action)) {
1518 $object->trackid =
'ord'.$object->id;
1519 } elseif (preg_match(
'/^BILL_/', $action)) {
1520 $object->trackid =
'inv'.$object->id;
1521 } elseif (preg_match(
'/^FICHINTER_/', $action)) {
1522 $object->trackid =
'int'.$object->id;
1523 } elseif (preg_match(
'/^SHIPPING_/', $action)) {
1524 $object->trackid =
'shi'.$object->id;
1525 } elseif (preg_match(
'/^RECEPTION_/', $action)) {
1526 $object->trackid =
'rec'.$object->id;
1527 } elseif (preg_match(
'/^PROPOSAL_SUPPLIER/', $action)) {
1528 $object->trackid =
'spr'.$object->id;
1529 } elseif (preg_match(
'/^ORDER_SUPPLIER_/', $action)) {
1530 $object->trackid =
'sor'.$object->id;
1531 } elseif (preg_match(
'/^BILL_SUPPLIER_/', $action)) {
1532 $object->trackid =
'sin'.$object->id;
1533 } elseif (preg_match(
'/^MEMBER_SUBSCRIPTION_/', $action)) {
1534 $object->trackid =
'sub'.$object->id;
1535 } elseif (preg_match(
'/^MEMBER_/', $action)) {
1536 $object->trackid =
'mem'.$object->id;
1537 } elseif (preg_match(
'/^PARTNERSHIP_/', $action)) {
1538 $object->trackid =
'pship'.$object->id;
1539 } elseif (preg_match(
'/^PROJECT_/', $action)) {
1540 $object->trackid =
'proj'.$object->id;
1541 } elseif (preg_match(
'/^TASK_/', $action)) {
1542 $object->trackid =
'tas'.$object->id;
1543 } elseif (preg_match(
'/^TICKET_/', $action)) {
1544 $object->trackid =
'tic'.$object->id;
1545 } elseif (preg_match(
'/^USER_/', $action)) {
1546 $object->trackid =
'use'.$object->id;
1552 dol_syslog(
"Trigger '".$this->
name.
"' for action '".$action.
"' launched by ".__FILE__.
". id=".
$object->id);
1557 if (isset($_SESSION[
'listofnames-'.
$object->trackid])) {
1558 $attachments = $_SESSION[
'listofnames-'.$object->trackid];
1559 if ($attachments && strpos($action,
'SENTBYMAIL')) {
1564 $societeforactionid = 0;
1565 $contactforactionid = 0;
1568 if (is_array(
$object->sendtoid)) {
1569 if (count(
$object->sendtoid) == 1) {
1570 $contactforactionid = reset(
$object->sendtoid);
1574 $contactforactionid =
$object->sendtoid;
1579 $societeforactionid =
$object->socid;
1581 $societeforactionid =
$object->fk_soc;
1582 } elseif (isset(
$object->thirdparty) && isset(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
1583 $societeforactionid =
$object->thirdparty->id;
1586 $projectid = isset(
$object->fk_project) ?
$object->fk_project : 0;
1587 if (
$object->element ==
'project') {
1588 '@phan-var-force Project $object';
1593 $elementtype =
$object->element;
1594 $elementmodule = (empty(
$object->module) ?
'' :
$object->module);
1595 if (
$object->element ==
'subscription') {
1596 '@phan-var-force Subscription $object';
1597 $elementid =
$object->fk_adherent;
1598 $elementtype =
'member';
1603 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1605 $actioncomm->type_code =
$object->actiontypecode;
1606 $actioncomm->code =
'AC_'.$action;
1607 $actioncomm->label =
$object->actionmsg2;
1608 $actioncomm->note_private =
$object->actionmsg;
1609 $actioncomm->fk_project = $projectid;
1610 $actioncomm->datep = $now;
1611 $actioncomm->datef = $now;
1612 $actioncomm->durationp = 0;
1613 $actioncomm->percentage = -1;
1614 $actioncomm->socid = $societeforactionid;
1615 $actioncomm->contact_id = $contactforactionid;
1616 $actioncomm->authorid = $user->id;
1617 $actioncomm->userownerid = $user->id;
1619 if (!property_exists(
$object,
'email_fields_no_propagate_in_actioncomm') || empty(
$object->email_fields_no_propagate_in_actioncomm)) {
1620 '@phan-var-force ActionComm $object';
1621 $actioncomm->datep = empty(
$object->email_date) ? $now :
$object->email_date;
1622 $actioncomm->datef = empty(
$object->email_date) ? $now :
$object->email_date;
1623 $actioncomm->email_msgid = empty(
$object->email_msgid) ? null :
$object->email_msgid;
1624 $actioncomm->email_from = empty(
$object->email_from) ? null :
$object->email_from;
1625 $actioncomm->email_sender = empty(
$object->email_sender) ? null :
$object->email_sender;
1626 $actioncomm->email_to = empty(
$object->email_to) ? null :
$object->email_to;
1627 $actioncomm->email_tocc = empty(
$object->email_tocc) ? null :
$object->email_tocc;
1628 $actioncomm->email_tobcc = empty(
$object->email_tobcc) ? null :
$object->email_tobcc;
1629 $actioncomm->email_subject = empty(
$object->email_subject) ? null :
$object->email_subject;
1630 $actioncomm->errors_to = empty(
$object->errors_to) ? null :
$object->errors_to;
1635 if (!in_array($elementtype, array(
'societe',
'contact',
'project'))) {
1636 $actioncomm->fk_element = $elementid;
1637 $actioncomm->elementtype = $elementtype.($elementmodule ?
'@'.$elementmodule :
'');
1641 if (property_exists(
$object,
'attachedfiles') && is_array(
$object->attachedfiles) && count(
$object->attachedfiles) > 0) {
1643 $actioncomm->attachedfiles =
$object->attachedfiles;
1646 if (property_exists(
$object,
'sendtouserid') && is_array(
$object->sendtouserid) && count(
$object->sendtouserid) > 0) {
1648 $actioncomm->userassigned =
$object->sendtouserid;
1651 if (property_exists(
$object,
'sendtoid') && is_array(
$object->sendtoid) && count(
$object->sendtoid) > 0) {
1653 foreach (
$object->sendtoid as $val) {
1654 $actioncomm->socpeopleassigned[$val] = $val;
1658 $ret = $actioncomm->create($user);
1662 if (property_exists(
$object,
'attachedfiles') && is_array(
$object->attachedfiles) && array_key_exists(
'paths',
$object->attachedfiles) && count(
$object->attachedfiles[
'paths']) > 0) {
1666 $destdir = $tmpelems[
'dir_output'].
'/'.$ret;
1669 foreach (
$object->attachedfiles[
'paths'] as $key => $filespath) {
1670 $srcfile = $filespath;
1672 $destfile = $destdir.
'/'.
$object->attachedfiles[
'names'][$key];
1674 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1682 unset(
$object->context[
'actionmsg']);
1683 unset(
$object->context[
'actionmsg2']);
1686 unset(
$object->actiontypecode);
1689 $_SESSION[
'LAST_ACTION_CREATED'] = $ret;
1692 $this->error =
"Failed to insert event : ".$actioncomm->error.
" ".implode(
',', $actioncomm->errors);
1693 $this->errors = $actioncomm->errors;
1695 dol_syslog(
"interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);