79 if (!isModEnabled(
'agenda')) {
84 if (preg_match(
'/^ACTION_/', $action)) {
88 $key =
'MAIN_AGENDA_ACTIONAUTO_'.$action;
97 $langs->load(
"agenda");
99 if (empty($object->actiontypecode)) {
100 $object->actiontypecode =
'AC_OTH_AUTO';
104 if ($action ==
'COMPANY_CREATE') {
106 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
108 if (empty($object->actionmsg2)) {
109 $object->actionmsg2 = $langs->transnoentities(
"NewCompanyToDolibarr", $object->name);
111 $object->actionmsg = $langs->transnoentities(
"NewCompanyToDolibarr", $object->name);
113 $object->sendtoid = 0;
114 $object->socid = $object->id;
115 } elseif ($action ==
'COMPANY_MODIFY') {
117 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
119 if (empty($object->actionmsg2)) {
120 $object->actionmsg2 = $langs->transnoentities(
"COMPANY_MODIFYInDolibarr", $object->name);
122 $object->actionmsg = $langs->transnoentities(
"COMPANY_MODIFYInDolibarr", $object->name);
124 if (!empty($object->context[
'mergefromname'])) {
125 $object->actionmsg =
dol_concatdesc($object->actionmsg, $langs->trans(
"DataFromWasMerged", $object->context[
'mergefromname']));
128 $object->sendtoid = 0;
129 $object->socid = $object->id;
130 } elseif ($action ==
'COMPANY_SENTBYMAIL') {
132 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
134 if (empty($object->actionmsg2)) {
135 dol_syslog(
'Trigger called with property actionmsg2 on object not defined', LOG_ERR);
140 } elseif ($action ==
'CONTACT_CREATE') {
142 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
144 if (empty($object->actionmsg2)) {
145 $object->actionmsg2 = $langs->transnoentities(
"CONTACT_CREATEInDolibarr", $object->getFullName($langs));
147 $object->actionmsg = $langs->transnoentities(
"CONTACT_CREATEInDolibarr", $object->getFullName($langs));
149 $object->sendtoid = array($object->id => $object->id);
150 $object->socid = $object->socid;
151 } elseif ($action ==
'CONTACT_MODIFY') {
153 $langs->loadLangs(array(
"agenda",
"other",
"companies"));
155 if (empty($object->actionmsg2)) {
156 $object->actionmsg2 = $langs->transnoentities(
"CONTACT_MODIFYInDolibarr", $object->name);
158 $object->actionmsg = $langs->transnoentities(
"CONTACT_MODIFYInDolibarr", $object->name);
160 $object->sendtoid = array($object->id => $object->id);
161 $object->socid = $object->socid;
162 } elseif ($action ==
'CONTRACT_VALIDATE') {
164 $langs->loadLangs(array(
"agenda",
"other",
"contracts"));
166 if (empty($object->actionmsg2)) {
167 $object->actionmsg2 = $langs->transnoentities(
"ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
169 $object->actionmsg = $langs->transnoentities(
"ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
171 $object->sendtoid = 0;
172 } elseif ($action ==
'CONTRACT_SENTBYMAIL') {
174 $langs->loadLangs(array(
"agenda",
"other",
"contracts"));
176 if (empty($object->actionmsg2)) {
177 $object->actionmsg2 = $langs->transnoentities(
"ContractSentByEMail", $object->ref);
179 if (empty($object->actionmsg)) {
180 $object->actionmsg = $langs->transnoentities(
"ContractSentByEMail", $object->ref);
185 } elseif ($action ==
'PROPAL_VALIDATE') {
187 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
189 if (empty($object->actionmsg2)) {
190 $object->actionmsg2 = $langs->transnoentities(
"PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
192 $object->actionmsg = $langs->transnoentities(
"PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
194 $object->sendtoid = 0;
195 } elseif ($action ==
'PROPAL_MODIFY') {
197 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
199 if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities(
"PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
200 $object->actionmsg = $langs->transnoentities(
"PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
202 $object->sendtoid = 0;
203 } elseif ($action ==
'PROPAL_SENTBYMAIL') {
205 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
207 if (empty($object->actionmsg2)) {
208 $object->actionmsg2 = $langs->transnoentities(
"ProposalSentByEMail", $object->ref);
210 if (empty($object->actionmsg)) {
211 $object->actionmsg = $langs->transnoentities(
"ProposalSentByEMail", $object->ref);
216 } elseif ($action ==
'PROPAL_CLOSE_SIGNED') {
218 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
220 if (empty($object->actionmsg2)) {
221 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedSignedInDolibarr", $object->ref);
223 $object->actionmsg = $langs->transnoentities(
"PropalClosedSignedInDolibarr", $object->ref);
225 $object->sendtoid = 0;
226 } elseif ($action ==
'PROPAL_CLASSIFY_BILLED') {
228 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
230 if (empty($object->actionmsg2)) {
231 $object->actionmsg2 = $langs->transnoentities(
"PropalClassifiedBilledInDolibarr", $object->ref);
233 $object->actionmsg = $langs->transnoentities(
"PropalClassifiedBilledInDolibarr", $object->ref);
235 $object->sendtoid = 0;
236 } elseif ($action ==
'PROPAL_CLOSE_REFUSED') {
238 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
240 if (empty($object->actionmsg2)) {
241 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedRefusedInDolibarr", $object->ref);
243 $object->actionmsg = $langs->transnoentities(
"PropalClosedRefusedInDolibarr", $object->ref);
245 $object->sendtoid = 0;
246 } elseif ($action ==
'ORDER_VALIDATE') {
248 $langs->loadLangs(array(
"agenda",
"orders"));
250 if (empty($object->actionmsg2)) {
251 $object->actionmsg2 = $langs->transnoentities(
"OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
253 $object->actionmsg = $langs->transnoentities(
"OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
255 $object->sendtoid = 0;
256 } elseif ($action ==
'ORDER_CLOSE') {
258 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
260 if (empty($object->actionmsg2)) {
261 $object->actionmsg2 = $langs->transnoentities(
"OrderDeliveredInDolibarr", $object->ref);
263 $object->actionmsg = $langs->transnoentities(
"OrderDeliveredInDolibarr", $object->ref);
265 $object->sendtoid = 0;
266 } elseif ($action ==
'ORDER_CLASSIFY_BILLED') {
268 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
270 if (empty($object->actionmsg2)) {
271 $object->actionmsg2 = $langs->transnoentities(
"OrderBilledInDolibarr", $object->ref);
273 $object->actionmsg = $langs->transnoentities(
"OrderBilledInDolibarr", $object->ref);
275 $object->sendtoid = 0;
276 } elseif ($action ==
'ORDER_CANCEL') {
278 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
280 if (empty($object->actionmsg2)) {
281 $object->actionmsg2 = $langs->transnoentities(
"OrderCanceledInDolibarr", $object->ref);
283 $object->actionmsg = $langs->transnoentities(
"OrderCanceledInDolibarr", $object->ref);
285 $object->sendtoid = 0;
286 } elseif ($action ==
'ORDER_SENTBYMAIL') {
288 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
290 if (empty($object->actionmsg2)) {
291 $object->actionmsg2 = $langs->transnoentities(
"OrderSentByEMail", $object->ref);
293 if (empty($object->actionmsg)) {
294 $object->actionmsg = $langs->transnoentities(
"OrderSentByEMail", $object->ref);
299 } elseif ($action ==
'BILL_VALIDATE') {
301 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
303 if (empty($object->actionmsg2)) {
304 $object->actionmsg2 = $langs->transnoentities(
"InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
306 $object->actionmsg = $langs->transnoentities(
"InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
308 $object->sendtoid = 0;
309 } elseif ($action ==
'BILL_UNVALIDATE') {
311 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
313 if (empty($object->actionmsg2)) {
314 $object->actionmsg2 = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr", $object->ref);
316 $object->actionmsg = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr", $object->ref);
318 $object->sendtoid = 0;
319 } elseif ($action ==
'BILL_SENTBYMAIL') {
321 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
323 if (empty($object->actionmsg2)) {
324 $object->actionmsg2 = $langs->transnoentities(
"InvoiceSentByEMail", $object->ref);
326 if (empty($object->actionmsg)) {
327 $object->actionmsg = $langs->transnoentities(
"InvoiceSentByEMail", $object->ref);
332 } elseif ($action ==
'BILL_PAYED') {
334 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
337 $object->actionmsg2 = $langs->transnoentities(
"InvoicePaidInDolibarr", $object->ref);
338 $object->actionmsg = $langs->transnoentities(
"InvoicePaidInDolibarr", $object->ref);
340 $object->sendtoid = 0;
341 } elseif ($action ==
'BILL_CANCEL') {
343 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
345 if (empty($object->actionmsg2)) {
346 $object->actionmsg2 = $langs->transnoentities(
"InvoiceCanceledInDolibarr", $object->ref);
348 $object->actionmsg = $langs->transnoentities(
"InvoiceCanceledInDolibarr", $object->ref);
350 $object->sendtoid = 0;
351 } elseif ($action ==
'FICHINTER_CREATE') {
353 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
355 if (empty($object->actionmsg2)) {
356 $object->actionmsg2 = $langs->transnoentities(
"InterventionCreatedInDolibarr", $object->ref);
358 $object->actionmsg = $langs->transnoentities(
"InterventionCreatedInDolibarr", $object->ref);
360 $object->sendtoid = 0;
361 $object->fk_element = 0;
362 $object->elementtype =
'';
363 } elseif ($action ==
'FICHINTER_VALIDATE') {
365 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
367 if (empty($object->actionmsg2)) {
368 $object->actionmsg2 = $langs->transnoentities(
"InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
370 $object->actionmsg = $langs->transnoentities(
"InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
372 $object->sendtoid = 0;
373 $object->fk_element = 0;
374 $object->elementtype =
'';
375 } elseif ($action ==
'FICHINTER_MODIFY') {
377 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
379 if (empty($object->actionmsg2)) {
380 $object->actionmsg2 = $langs->transnoentities(
"InterventionModifiedInDolibarr", $object->ref);
382 $object->actionmsg = $langs->transnoentities(
"InterventionModifiedInDolibarr", $object->ref);
384 $object->sendtoid = 0;
385 $object->fk_element = 0;
386 $object->elementtype =
'';
387 } elseif ($action ==
'FICHINTER_SENTBYMAIL') {
389 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
391 if (empty($object->actionmsg2)) {
392 $object->actionmsg2 = $langs->transnoentities(
"InterventionSentByEMail", $object->ref);
394 if (empty($object->actionmsg)) {
395 $object->actionmsg = $langs->transnoentities(
"InterventionSentByEMail", $object->ref);
400 } elseif ($action ==
'FICHINTER_CLASSIFY_BILLED') {
402 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
404 if (empty($object->actionmsg2)) {
405 $object->actionmsg2 = $langs->transnoentities(
"InterventionClassifiedBilledInDolibarr", $object->ref);
407 $object->actionmsg = $langs->transnoentities(
"InterventionClassifiedBilledInDolibarr", $object->ref);
409 $object->sendtoid = 0;
410 } elseif ($action ==
'FICHINTER_CLASSIFY_UNBILLED') {
412 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
414 if (empty($object->actionmsg2)) {
415 $object->actionmsg2 = $langs->transnoentities(
"InterventionClassifiedUnbilledInDolibarr", $object->ref);
417 $object->actionmsg = $langs->transnoentities(
"InterventionClassifiedUnbilledInDolibarr", $object->ref);
419 $object->sendtoid = 0;
420 } elseif ($action ==
'FICHINTER_DELETE') {
422 $langs->loadLangs(array(
"agenda",
"other",
"interventions"));
424 if (empty($object->actionmsg2)) {
425 $object->actionmsg2 = $langs->transnoentities(
"InterventionDeletedInDolibarr", $object->ref);
427 $object->actionmsg = $langs->transnoentities(
"InterventionDeletedInDolibarr", $object->ref);
429 $object->sendtoid = 0;
430 $object->fk_element = 0;
431 $object->elementtype =
'';
432 } elseif ($action ==
'SHIPPING_VALIDATE') {
434 $langs->loadLangs(array(
"agenda",
"other",
"sendings"));
436 if (empty($object->actionmsg2)) {
437 $object->actionmsg2 = $langs->transnoentities(
"ShippingValidated", ($object->newref ? $object->newref : $object->ref));
439 if (empty($object->actionmsg)) {
440 $object->actionmsg = $langs->transnoentities(
"ShippingValidated", ($object->newref ? $object->newref : $object->ref));
445 } elseif ($action ==
'SHIPPING_SENTBYMAIL') {
447 $langs->loadLangs(array(
"agenda",
"other",
"sendings"));
449 if (empty($object->actionmsg2)) {
450 $object->actionmsg2 = $langs->transnoentities(
"ShippingSentByEMail", $object->ref);
452 if (empty($object->actionmsg)) {
453 $object->actionmsg = $langs->transnoentities(
"ShippingSentByEMail", $object->ref);
458 } elseif ($action ==
'RECEPTION_VALIDATE') {
459 $langs->load(
"agenda");
460 $langs->load(
"other");
461 $langs->load(
"receptions");
463 if (empty($object->actionmsg2)) {
464 $object->actionmsg2 = $langs->transnoentities(
"ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
466 if (empty($object->actionmsg)) {
467 $object->actionmsg = $langs->transnoentities(
"ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
472 } elseif ($action ==
'RECEPTION_SENTBYMAIL') {
473 $langs->load(
"agenda");
474 $langs->load(
"other");
475 $langs->load(
"receptions");
477 if (empty($object->actionmsg2)) {
478 $object->actionmsg2 = $langs->transnoentities(
"ReceptionSentByEMail", $object->ref);
480 if (empty($object->actionmsg)) {
481 $object->actionmsg = $langs->transnoentities(
"ReceptionSentByEMail", $object->ref);
486 } elseif ($action ==
'PROPOSAL_SUPPLIER_VALIDATE') {
488 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
490 if (empty($object->actionmsg2)) {
491 $object->actionmsg2 = $langs->transnoentities(
"PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
493 $object->actionmsg = $langs->transnoentities(
"PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
495 $object->sendtoid = 0;
496 } elseif ($action ==
'PROPOSAL_SUPPLIER_SENTBYMAIL') {
498 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
500 if (empty($object->actionmsg2)) {
501 $object->actionmsg2 = $langs->transnoentities(
"ProposalSentByEMail", $object->ref);
503 if (empty($object->actionmsg)) {
504 $object->actionmsg = $langs->transnoentities(
"ProposalSentByEMail", $object->ref);
509 } elseif ($action ==
'PROPOSAL_SUPPLIER_CLOSE_SIGNED') {
511 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
513 if (empty($object->actionmsg2)) {
514 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedSignedInDolibarr", $object->ref);
516 $object->actionmsg = $langs->transnoentities(
"PropalClosedSignedInDolibarr", $object->ref);
518 $object->sendtoid = 0;
519 } elseif ($action ==
'PROPOSAL_SUPPLIER_CLOSE_REFUSED') {
521 $langs->loadLangs(array(
"agenda",
"other",
"propal"));
523 if (empty($object->actionmsg2)) {
524 $object->actionmsg2 = $langs->transnoentities(
"PropalClosedRefusedInDolibarr", $object->ref);
526 $object->actionmsg = $langs->transnoentities(
"PropalClosedRefusedInDolibarr", $object->ref);
528 $object->sendtoid = 0;
529 } elseif ($action ==
'ORDER_SUPPLIER_CREATE') {
531 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
533 if (empty($object->actionmsg2)) {
534 $object->actionmsg2 = $langs->transnoentities(
"OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
536 $object->actionmsg = $langs->transnoentities(
"OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
538 $object->sendtoid = 0;
539 } elseif ($action ==
'ORDER_SUPPLIER_VALIDATE') {
541 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
543 if (empty($object->actionmsg2)) {
544 $object->actionmsg2 = $langs->transnoentities(
"OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
546 $object->actionmsg = $langs->transnoentities(
"OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
548 $object->sendtoid = 0;
549 } elseif ($action ==
'ORDER_SUPPLIER_APPROVE') {
551 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
553 if (empty($object->actionmsg2)) {
554 $object->actionmsg2 = $langs->transnoentities(
"OrderApprovedInDolibarr", $object->ref);
556 $object->actionmsg = $langs->transnoentities(
"OrderApprovedInDolibarr", $object->ref);
558 $object->sendtoid = 0;
559 } elseif ($action ==
'ORDER_SUPPLIER_REFUSE') {
561 $langs->loadLangs(array(
"agenda",
"other",
"orders",
"main"));
563 if (empty($object->actionmsg2)) {
564 $object->actionmsg2 = $langs->transnoentities(
"OrderRefusedInDolibarr", $object->ref);
566 $object->actionmsg = $langs->transnoentities(
"OrderRefusedInDolibarr", $object->ref);
568 if (!empty($object->refuse_note)) {
569 $object->actionmsg .=
'<br>';
570 $object->actionmsg .= $langs->trans(
"Reason") .
': '.$object->refuse_note;
573 $object->sendtoid = 0;
574 } elseif ($action ==
'ORDER_SUPPLIER_CANCEL') {
576 $langs->loadLangs(array(
"agenda",
"other",
"orders",
"main"));
578 if (empty($object->actionmsg2)) {
579 $object->actionmsg2 = $langs->transnoentities(
"OrderCanceledInDolibarr", $object->ref);
581 $object->actionmsg = $langs->transnoentities(
"OrderCanceledInDolibarr", $object->ref);
583 if (!empty($object->cancel_note)) {
584 $object->actionmsg .=
'<br>';
585 $object->actionmsg .= $langs->trans(
"Reason") .
': '.$object->cancel_note;
588 $object->sendtoid = 0;
589 } elseif ($action ==
'ORDER_SUPPLIER_SUBMIT') {
591 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
593 if (empty($object->actionmsg2)) {
594 $object->actionmsg2 = $langs->transnoentities(
"SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
596 $object->actionmsg = $langs->transnoentities(
"SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
598 if (!empty($object->context[
'comments'])) {
599 $object->actionmsg .=
'<br>';
600 $object->actionmsg .= $langs->trans(
"Comment") .
': '.$object->context[
'comments'];
603 $object->sendtoid = 0;
604 } elseif ($action ==
'ORDER_SUPPLIER_RECEIVE') {
606 $langs->loadLangs(array(
"agenda",
"other",
"orders"));
608 if (empty($object->actionmsg2)) {
609 $object->actionmsg2 = $langs->transnoentities(
"SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
611 $object->actionmsg = $langs->transnoentities(
"SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
613 $object->sendtoid = 0;
614 } elseif ($action ==
'ORDER_SUPPLIER_SENTBYMAIL') {
616 $langs->loadLangs(array(
"agenda",
"other",
"bills",
"orders"));
618 if (empty($object->actionmsg2)) {
619 $object->actionmsg2 = $langs->transnoentities(
"SupplierOrderSentByEMail", $object->ref);
621 if (empty($object->actionmsg)) {
622 $object->actionmsg = $langs->transnoentities(
"SupplierOrderSentByEMail", $object->ref);
627 } elseif ($action ==
'ORDER_SUPPLIER_CLASSIFY_BILLED') {
629 $langs->loadLangs(array(
"agenda",
"other",
"bills",
"orders"));
631 if (empty($object->actionmsg2)) {
632 $object->actionmsg2 = $langs->transnoentities(
"SupplierOrderClassifiedBilled", $object->ref);
634 if (empty($object->actionmsg)) {
635 $object->actionmsg = $langs->transnoentities(
"SupplierOrderClassifiedBilled", $object->ref);
638 $object->sendtoid = 0;
639 } elseif ($action ==
'BILL_SUPPLIER_VALIDATE') {
641 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
643 if (empty($object->actionmsg2)) {
644 $object->actionmsg2 = $langs->transnoentities(
"InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
646 $object->actionmsg = $langs->transnoentities(
"InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
648 $object->sendtoid = 0;
649 } elseif ($action ==
'BILL_SUPPLIER_UNVALIDATE') {
651 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
653 if (empty($object->actionmsg2)) {
654 $object->actionmsg2 = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr", $object->ref);
656 $object->actionmsg = $langs->transnoentities(
"InvoiceBackToDraftInDolibarr", $object->ref);
658 $object->sendtoid = 0;
659 } elseif ($action ==
'BILL_SUPPLIER_SENTBYMAIL') {
661 $langs->loadLangs(array(
"agenda",
"other",
"bills",
"orders"));
663 if (empty($object->actionmsg2)) {
664 $object->actionmsg2 = $langs->transnoentities(
"SupplierInvoiceSentByEMail", $object->ref);
666 if (empty($object->actionmsg)) {
667 $object->actionmsg = $langs->transnoentities(
"SupplierInvoiceSentByEMail", $object->ref);
672 } elseif ($action ==
'BILL_SUPPLIER_PAYED') {
674 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
676 if (empty($object->actionmsg2)) {
677 $object->actionmsg2 = $langs->transnoentities(
"InvoicePaidInDolibarr", $object->ref);
679 $object->actionmsg = $langs->transnoentities(
"InvoicePaidInDolibarr", $object->ref);
681 $object->sendtoid = 0;
682 } elseif ($action ==
'BILL_SUPPLIER_CANCELED') {
684 $langs->loadLangs(array(
"agenda",
"other",
"bills"));
686 if (empty($object->actionmsg2)) {
687 $object->actionmsg2 = $langs->transnoentities(
"InvoiceCanceledInDolibarr", $object->ref);
689 $object->actionmsg = $langs->transnoentities(
"InvoiceCanceledInDolibarr", $object->ref);
691 $object->sendtoid = 0;
692 } elseif ($action ==
'MEMBER_VALIDATE') {
695 $langs->loadLangs(array(
"agenda",
"other",
"members"));
697 if (empty($object->actionmsg2)) {
698 $object->actionmsg2 = $langs->transnoentities(
"MemberValidatedInDolibarr", $object->getFullName($langs));
700 $object->actionmsg = $langs->transnoentities(
"MemberValidatedInDolibarr", $object->getFullName($langs));
701 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$object->getFullName($langs);
702 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->type;
704 $object->sendtoid = 0;
705 } elseif ($action ==
'MEMBER_MODIFY') {
707 $langs->loadLangs(array(
"agenda",
"other",
"members"));
709 if (empty($object->actionmsg2)) {
710 $object->actionmsg2 = $langs->transnoentities(
"MemberModifiedInDolibarr", $object->getFullName($langs));
712 $object->actionmsg = $langs->transnoentities(
"MemberModifiedInDolibarr", $object->getFullName($langs));
713 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$object->getFullName($langs);
714 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->type;
716 $object->sendtoid = 0;
717 } elseif ($action ==
'MEMBER_SUBSCRIPTION_CREATE') {
719 $langs->loadLangs(array(
"agenda",
"other",
"members"));
721 $member = (isset($this->context[
'member']) ? $this->context[
'member'] :
null);
722 if (!is_object($member)) {
723 dol_syslog(
"Execute a trigger MEMBER_SUBSCRIPTION_CREATE with context key 'member' not an object");
724 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
726 $member->fetch($object->fk_adherent);
729 if (empty($object->actionmsg2)) {
730 $object->actionmsg2 = $langs->transnoentities(
"MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
732 $object->actionmsg = $langs->transnoentities(
"MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
733 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$member->getFullName($langs);
734 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->fk_type;
735 $object->actionmsg .=
"\n".$langs->transnoentities(
"Amount").
': '.$object->amount;
736 $object->actionmsg .=
"\n".$langs->transnoentities(
"Period").
': '.
dol_print_date($object->dateh,
'day').
' - '.
dol_print_date($object->datef,
'day');
738 $object->sendtoid = 0;
739 if (isset($object->fk_soc) && $object->fk_soc > 0) {
740 $object->socid = $object->fk_soc;
742 } elseif ($action ==
'MEMBER_SUBSCRIPTION_MODIFY') {
744 $langs->loadLangs(array(
"agenda",
"other",
"members"));
746 $member = $this->context[
'member'];
747 if (!is_object($member)) {
748 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
750 $member->fetch($object->fk_adherent);
753 if (empty($object->actionmsg2)) {
754 $object->actionmsg2 = $langs->transnoentities(
"MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
756 $object->actionmsg = $langs->transnoentities(
"MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
757 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$member->getFullName($langs);
758 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->fk_type;
759 $object->actionmsg .=
"\n".$langs->transnoentities(
"Amount").
': '.$object->amount;
760 $object->actionmsg .=
"\n".$langs->transnoentities(
"Period").
': '.
dol_print_date($object->dateh,
'day').
' - '.
dol_print_date($object->datef,
'day');
762 $object->sendtoid = 0;
763 if ($object->fk_soc > 0) {
764 $object->socid = $object->fk_soc;
766 } elseif ($action ==
'MEMBER_SUBSCRIPTION_DELETE') {
768 $langs->loadLangs(array(
"agenda",
"other",
"members"));
770 $member = $this->context[
'member'];
771 if (!is_object($member)) {
772 dol_syslog(
"Execute a trigger MEMBER_SUBSCRIPTION_CREATE with context key 'member' not an object");
773 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
775 $member->fetch($object->fk_adherent);
778 $object->actionmsg = $langs->transnoentities(
"MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs));
779 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$member->getFullName($langs);
780 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->fk_type;
781 $object->actionmsg .=
"\n".$langs->transnoentities(
"Amount").
': '.$object->amount;
782 $object->actionmsg .=
"\n".$langs->transnoentities(
"Period").
': '.
dol_print_date($object->dateh,
'day').
' - '.
dol_print_date($object->datef,
'day');
783 if (empty($object->actionmsg2)) {
784 $object->actionmsg2 = $langs->transnoentities(
"MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs));
787 $object->sendtoid = 0;
788 if (isset($object->fk_soc) && $object->fk_soc > 0) {
789 $object->socid = $object->fk_soc;
791 } elseif ($action ==
'MEMBER_RESILIATE') {
793 $langs->loadLangs(array(
"agenda",
"other",
"members"));
795 if (empty($object->actionmsg2)) {
796 $object->actionmsg2 = $langs->transnoentities(
"MemberResiliatedInDolibarr", $object->getFullName($langs));
798 $object->actionmsg = $langs->transnoentities(
"MemberResiliatedInDolibarr", $object->getFullName($langs));
799 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$object->getFullName($langs);
800 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->type;
802 $object->sendtoid = 0;
803 } elseif ($action ==
'MEMBER_DELETE') {
805 $langs->loadLangs(array(
"agenda",
"other",
"members"));
807 if (empty($object->actionmsg2)) {
808 $object->actionmsg2 = $langs->transnoentities(
"MemberDeletedInDolibarr", $object->getFullName($langs));
810 $object->actionmsg = $langs->transnoentities(
"MemberDeletedInDolibarr", $object->getFullName($langs));
811 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$object->getFullName($langs);
812 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->type;
814 $object->sendtoid = 0;
815 } elseif ($action ==
'MEMBER_EXCLUDE') {
817 $langs->loadLangs(array(
"agenda",
"other",
"members"));
819 if (empty($object->actionmsg2)) {
820 $object->actionmsg2 = $langs->transnoentities(
"MemberExcludedInDolibarr", $object->getFullName($langs));
822 $object->actionmsg = $langs->transnoentities(
"MemberExcludedInDolibarr", $object->getFullName($langs));
823 $object->actionmsg .=
"\n".$langs->transnoentities(
"Member").
': '.$object->getFullName($langs);
824 $object->actionmsg .=
"\n".$langs->transnoentities(
"Type").
': '.$object->type;
826 $object->sendtoid = 0;
827 } elseif ($action ==
'PROJECT_CREATE') {
830 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
832 if (empty($object->actionmsg2)) {
833 $object->actionmsg2 = $langs->transnoentities(
"ProjectCreatedInDolibarr", $object->ref);
835 $object->actionmsg = $langs->transnoentities(
"ProjectCreatedInDolibarr", $object->ref);
836 $object->actionmsg .=
"\n".$langs->transnoentities(
"Project").
': '.$object->ref;
838 $object->sendtoid = 0;
839 } elseif ($action ==
'PROJECT_VALIDATE') {
841 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
843 if (empty($object->actionmsg2)) {
844 $object->actionmsg2 = $langs->transnoentities(
"ProjectValidatedInDolibarr", $object->ref);
846 $object->actionmsg = $langs->transnoentities(
"ProjectValidatedInDolibarr", $object->ref);
847 $object->actionmsg .=
"\n".$langs->transnoentities(
"Project").
': '.$object->ref;
849 $object->sendtoid = 0;
850 } elseif ($action ==
'PROJECT_MODIFY') {
852 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
854 if (empty($object->actionmsg2)) {
855 $object->actionmsg2 = $langs->transnoentities(
"ProjectModifiedInDolibarr", $object->ref);
857 $object->actionmsg = $langs->transnoentities(
"ProjectModifiedInDolibarr", $object->ref);
859 if (!empty($object->usage_opportunity) && is_object($object->oldcopy) && $object->opp_status != $object->oldcopy->opp_status) {
860 $object->actionmsg .=
"\n".$langs->transnoentitiesnoconv(
"OpportunityStatus").
': '.$object->oldcopy->opp_status.
' -> '.$object->opp_status;
863 $object->sendtoid = 0;
864 } elseif ($action ==
'PROJECT_SENTBYMAIL') {
866 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
868 if (empty($object->actionmsg2)) {
869 $object->actionmsg2 = $langs->transnoentities(
"ProjectSentByEMail", $object->ref);
871 if (empty($object->actionmsg)) {
872 $object->actionmsg = $langs->transnoentities(
"ProjectSentByEMail", $object->ref);
877 } elseif ($action ==
'PROJECT_CLOSE') {
879 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
881 if (empty($object->actionmsg2)) {
882 $object->actionmsg2 = $langs->transnoentities(
"ProjectClosedInDolibarr", $object->ref);
884 $object->actionmsg = $langs->transnoentities(
"ProjectClosedInDolibarr", $object->ref);
886 $object->sendtoid = 0;
887 } elseif ($action ==
'TASK_CREATE') {
890 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
892 if (empty($object->actionmsg2)) {
893 $object->actionmsg2 = $langs->transnoentities(
"TaskCreatedInDolibarr", $object->ref);
895 $object->actionmsg = $langs->transnoentities(
"TaskCreatedInDolibarr", $object->ref);
896 $object->actionmsg .=
"\n".$langs->transnoentities(
"Task").
': '.$object->ref;
898 $object->sendtoid = 0;
899 } elseif ($action ==
'TASK_MODIFY') {
901 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
903 if (empty($object->actionmsg2)) {
904 $object->actionmsg2 = $langs->transnoentities(
"TaskModifiedInDolibarr", $object->ref);
906 $object->actionmsg = $langs->transnoentities(
"TaskModifieddInDolibarr", $object->ref);
907 $object->actionmsg .=
"\n".$langs->transnoentities(
"Task").
': '.$object->ref;
909 $object->sendtoid = 0;
910 } elseif ($action ==
'TASK_DELETE') {
912 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
914 if (empty($object->actionmsg2)) {
915 $object->actionmsg2 = $langs->transnoentities(
"TaskDeletedInDolibarr", $object->ref);
917 $object->actionmsg = $langs->transnoentities(
"TaskDeletedInDolibarr", $object->ref);
918 $object->actionmsg .=
"\n".$langs->transnoentities(
"Task").
': '.$object->ref;
920 $object->sendtoid = 0;
921 } elseif ($action ==
'TICKET_ASSIGNED') {
923 $langs->loadLangs(array(
"agenda",
"other",
"projects"));
925 if (empty($object->actionmsg2)) {
926 $object->actionmsg2 = $langs->transnoentities(
"TICKET_ASSIGNEDInDolibarr", $object->ref);
928 $object->actionmsg = $langs->transnoentities(
"TICKET_ASSIGNEDInDolibarr", $object->ref);
929 if ($object->oldcopy->fk_user_assign > 0) {
930 $tmpuser =
new User($this->db);
931 $tmpuser->fetch($object->oldcopy->fk_user_assign);
932 $object->actionmsg .=
"\n".$langs->transnoentities(
"OldUser").
': '.$tmpuser->getFullName($langs);
934 $object->actionmsg .=
"\n".$langs->transnoentities(
"OldUser").
': '.$langs->trans(
"None");
936 if ($object->fk_user_assign > 0) {
937 $tmpuser =
new User($this->db);
938 $tmpuser->fetch($object->fk_user_assign);
939 $object->actionmsg .=
"\n".$langs->transnoentities(
"NewUser").
': '.$tmpuser->getFullName($langs);
941 $object->actionmsg .=
"\n".$langs->transnoentities(
"NewUser").
': '.$langs->trans(
"None");
943 $object->sendtoid = 0;
951 if (empty($object->actionmsg2)) {
952 $langs->loadLangs(array(
"agenda",
"other"));
953 if ($langs->transnoentities($action.
"InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action.
"InDolibarr") {
954 $object->actionmsg2 = $langs->transnoentities($action.
"InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
956 $tmp = explode(
'_', $action);
957 $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp) - 1].
"InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
960 if (empty($object->actionmsg)) {
961 $langs->loadLangs(array(
"agenda",
"other"));
962 if ($langs->transnoentities($action.
"InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action.
"InDolibarr") {
963 $object->actionmsg = $langs->transnoentities($action.
"InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
965 $tmp = explode(
'_', $action);
966 $object->actionmsg = $langs->transnoentities($tmp[count($tmp) - 1].
"InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
968 if (isModEnabled(
'multicompany') && property_exists($object,
'entity') && $object->entity > 1) {
969 $object->actionmsg .=
' ('.$langs->trans(
"Entity").
' '.$object->entity.
')';
973 if (!isset($object->sendtoid) || !is_array($object->sendtoid)) {
974 $object->sendtoid = 0;
980 if (empty($object->trackid)) {
982 if (preg_match(
'/^COMPANY_/', $action)) {
983 $object->trackid =
'thi'.$object->id;
984 } elseif (preg_match(
'/^CONTACT_/', $action)) {
985 $object->trackid =
'ctc'.$object->id;
986 } elseif (preg_match(
'/^CONTRACT_/', $action)) {
987 $object->trackid =
'con'.$object->id;
988 } elseif (preg_match(
'/^PROPAL_/', $action)) {
989 $object->trackid =
'pro'.$object->id;
990 } elseif (preg_match(
'/^ORDER_/', $action)) {
991 $object->trackid =
'ord'.$object->id;
992 } elseif (preg_match(
'/^BILL_/', $action)) {
993 $object->trackid =
'inv'.$object->id;
994 } elseif (preg_match(
'/^FICHINTER_/', $action)) {
995 $object->trackid =
'int'.$object->id;
996 } elseif (preg_match(
'/^SHIPPING_/', $action)) {
997 $object->trackid =
'shi'.$object->id;
998 } elseif (preg_match(
'/^RECEPTION_/', $action)) {
999 $object->trackid =
'rec'.$object->id;
1000 } elseif (preg_match(
'/^PROPOSAL_SUPPLIER/', $action)) {
1001 $object->trackid =
'spr'.$object->id;
1002 } elseif (preg_match(
'/^ORDER_SUPPLIER_/', $action)) {
1003 $object->trackid =
'sor'.$object->id;
1004 } elseif (preg_match(
'/^BILL_SUPPLIER_/', $action)) {
1005 $object->trackid =
'sin'.$object->id;
1006 } elseif (preg_match(
'/^MEMBER_SUBSCRIPTION_/', $action)) {
1007 $object->trackid =
'sub'.$object->id;
1008 } elseif (preg_match(
'/^MEMBER_/', $action)) {
1009 $object->trackid =
'mem'.$object->id;
1010 } elseif (preg_match(
'/^PARTNERSHIP_/', $action)) {
1011 $object->trackid =
'pship'.$object->id;
1012 } elseif (preg_match(
'/^PROJECT_/', $action)) {
1013 $object->trackid =
'proj'.$object->id;
1014 } elseif (preg_match(
'/^TASK_/', $action)) {
1015 $object->trackid =
'tas'.$object->id;
1016 } elseif (preg_match(
'/^TICKET_/', $action)) {
1017 $object->trackid =
'tic'.$object->id;
1018 } elseif (preg_match(
'/^USER_/', $action)) {
1019 $object->trackid =
'use'.$object->id;
1021 $object->trackid =
'';
1033 dol_syslog(
"Trigger '".$this->
name.
"' for action '".$action.
"' launched by ".__FILE__.
". id=".$object->id);
1038 if (isset($_SESSION[
'listofnames-'.$object->trackid])) {
1039 $attachs = $_SESSION[
'listofnames-'.$object->trackid];
1040 if ($attachs && strpos($action,
'SENTBYMAIL')) {
1041 $object->actionmsg =
dol_concatdesc($object->actionmsg,
"\n".$langs->transnoentities(
"AttachedFiles").
': '.$attachs);
1044 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
1045 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1046 $contactforaction =
new Contact($this->db);
1047 $societeforaction =
new Societe($this->db);
1050 if (is_array($object->sendtoid)) {
1051 if (count($object->sendtoid) == 1) {
1052 $contactforaction->fetch(reset($object->sendtoid));
1055 if ($object->sendtoid > 0) {
1056 $contactforaction->fetch($object->sendtoid);
1060 if (isset($object->socid) && $object->socid > 0) {
1061 $societeforaction->fetch($object->socid);
1062 } elseif (isset($object->fk_soc) && $object->fk_soc > 0) {
1063 $societeforaction->fetch($object->fk_soc);
1064 } elseif (isset($object->thirdparty) && isset($object->thirdparty->id) && $object->thirdparty->id > 0) {
1065 $societeforaction = $object->thirdparty;
1068 $projectid = isset($object->fk_project) ? $object->fk_project : 0;
1069 if ($object->element ==
'project') {
1070 $projectid = $object->id;
1073 $elementid = $object->id;
1074 $elementtype = $object->element;
1075 $elementmodule = (empty($object->module) ?
'' : $object->module);
1076 if ($object->element ==
'subscription') {
1077 $elementid = $object->fk_adherent;
1078 $elementtype =
'member';
1083 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1085 $actioncomm->type_code = $object->actiontypecode;
1086 $actioncomm->code =
'AC_'.$action;
1087 $actioncomm->label = $object->actionmsg2;
1088 $actioncomm->note_private = $object->actionmsg;
1089 $actioncomm->fk_project = $projectid;
1090 $actioncomm->datep = $now;
1091 $actioncomm->datef = $now;
1092 $actioncomm->durationp = 0;
1093 $actioncomm->percentage = -1;
1094 $actioncomm->socid = $societeforaction->id;
1095 $actioncomm->contact_id = $contactforaction->id;
1096 $actioncomm->authorid = $user->id;
1097 $actioncomm->userownerid = $user->id;
1099 if (!property_exists($object,
'email_fields_no_propagate_in_actioncomm') || empty($object->email_fields_no_propagate_in_actioncomm)) {
1100 $actioncomm->email_msgid = empty($object->email_msgid) ? null : $object->email_msgid;
1101 $actioncomm->email_from = empty($object->email_from) ? null : $object->email_from;
1102 $actioncomm->email_sender = empty($object->email_sender) ? null : $object->email_sender;
1103 $actioncomm->email_to = empty($object->email_to) ? null : $object->email_to;
1104 $actioncomm->email_tocc = empty($object->email_tocc) ? null : $object->email_tocc;
1105 $actioncomm->email_tobcc = empty($object->email_tobcc) ? null : $object->email_tobcc;
1106 $actioncomm->email_subject = empty($object->email_subject) ? null : $object->email_subject;
1107 $actioncomm->errors_to = empty($object->errors_to) ? null : $object->errors_to;
1112 if (!in_array($elementtype, array(
'societe',
'contact',
'project'))) {
1113 $actioncomm->fk_element = $elementid;
1114 $actioncomm->elementtype = $elementtype.($elementmodule ?
'@'.$elementmodule :
'');
1117 if (property_exists($object,
'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles) > 0) {
1118 $actioncomm->attachedfiles = $object->attachedfiles;
1120 if (property_exists($object,
'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid) > 0) {
1121 $actioncomm->userassigned = $object->sendtouserid;
1123 if (property_exists($object,
'sendtoid') && is_array($object->sendtoid) && count($object->sendtoid) > 0) {
1124 foreach ($object->sendtoid as $val) {
1125 $actioncomm->socpeopleassigned[$val] = $val;
1129 $ret = $actioncomm->create($user);
1131 if ($ret > 0 && !empty($conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO)) {
1132 if (property_exists($object,
'attachedfiles') && is_array($object->attachedfiles) && array_key_exists(
'paths', $object->attachedfiles) && count($object->attachedfiles[
'paths']) > 0) {
1133 foreach ($object->attachedfiles[
'paths'] as $key => $filespath) {
1134 $srcfile = $filespath;
1135 $destdir = $conf->agenda->dir_output.
'/'.$ret;
1136 $destfile = $destdir.
'/'.$object->attachedfiles[
'names'][$key];
1138 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1145 unset($object->actionmsg);
1146 unset($object->actionmsg2);
1147 unset($object->actiontypecode);
1150 $_SESSION[
'LAST_ACTION_CREATED'] = $ret;
1153 $this->error =
"Failed to insert event : ".$actioncomm->error.
" ".join(
',', $actioncomm->errors);
1154 $this->errors = $actioncomm->errors;
1156 dol_syslog(
"interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);