dolibarr 21.0.0-beta
interface_50_modAgenda_ActionsAuto.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
6 * Copyright (C) 2014 Marcos GarcĂ­a <marcosgdf@gmail.com>
7 * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
8 * Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
9 * Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
10 * Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
11 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
34
35
40{
46 public function __construct($db)
47 {
48 $this->db = $db;
49
50 $this->name = preg_replace('/^Interface/i', '', get_class($this));
51 $this->family = "agenda";
52 $this->description = "Triggers of this module add actions in agenda according to setup made in agenda setup.";
53 $this->version = self::VERSIONS['prod'];
54 $this->picto = 'action';
55 }
56
79 public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
80 {
81 if (!isModEnabled('agenda')) {
82 return 0; // Module not active, we do nothing
83 }
84
85 // Do not log events when trigger is for creating event (infinite loop)
86 if (preg_match('/^ACTION_/', $action)) {
87 return 0;
88 }
89
90 $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
91 //var_dump($action.' - '.$key.' - '.$conf->global->$key);exit;
92
93 // Do not log events not enabled for this action
94 // GUI allow to set this option only if entry exists into table llx_c_action_trigger
95 if (!getDolGlobalString($key)) {
96 return 0;
97 }
98
99 $langs->load("agenda");
100
101 if (empty($object->actiontypecode)) {
102 $object->actiontypecode = 'AC_OTH_AUTO';
103 }
104
105 // Actions
106 if ($action == 'COMPANY_CREATE') {
107 '@phan-var-force Societe $object';
108 // Load translation files required by the page
109 $langs->loadLangs(array("agenda", "other", "companies"));
110
111 if (empty($object->actionmsg2)) {
112 if (empty($object->context['actionmsg2'])) {
113 $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
114 } else {
115 $object->actionmsg2 = $object->context['actionmsg2'];
116 }
117 }
118 if (empty($object->actionmsg)) {
119 $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
120 }
121
122 $object->sendtoid = array();
123 $object->socid = $object->id;
124 } elseif ($action == 'COMPANY_MODIFY') {
125 '@phan-var-force Societe $object';
126 // Load translation files required by the page
127 $langs->loadLangs(array("agenda", "other", "companies"));
128
129 if (empty($object->actionmsg2)) {
130 if (empty($object->context['actionmsg2'])) {
131 $object->actionmsg2 = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name);
132 } else {
133 $object->actionmsg2 = $object->context['actionmsg2'];
134 }
135 }
136 if (empty($object->actionmsg)) {
137 $object->actionmsg = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name);
138 }
139
140 // For merge event, we add a mention
141 if (!empty($object->context['mergefromname'])) {
142 $object->actionmsg = dol_concatdesc($object->actionmsg, $langs->trans("DataFromWasMerged", $object->context['mergefromname'].' (id='.$object->context['mergefromname'].')'));
143 }
144
145 $object->sendtoid = array();
146 $object->socid = $object->id;
147 } elseif ($action == 'COMPANY_SENTBYMAIL') {
148 '@phan-var-force Societe $object';
149 // Load translation files required by the page
150 $langs->loadLangs(array("agenda", "other", "orders"));
151
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);
155 } else {
156 $object->actionmsg2 = $object->context['actionmsg2'];
157 }
158 }
159
160 // Parameters $object->sendtoid defined by caller
161 //$object->sendtoid = array();
162 } elseif ($action == 'CONTACT_CREATE') {
163 '@phan-var-force Contact $object';
164 // Load translation files required by the page
165 $langs->loadLangs(array("agenda", "other", "companies"));
166
167 if (empty($object->actionmsg2)) {
168 if (empty($object->context['actionmsg2'])) {
169 $object->actionmsg2 = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs));
170 } else {
171 $object->actionmsg2 = $object->context['actionmsg2'];
172 }
173 }
174 if (empty($object->actionmsg)) {
175 $object->actionmsg = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs));
176 }
177
178 $object->sendtoid = array($object->id => $object->id);
179 // $object->socid = $object->socid;
180 } elseif ($action == 'CONTACT_MODIFY') {
181 '@phan-var-force Contrat $object';
182 // Load translation files required by the page
183 $langs->loadLangs(array("agenda", "other", "companies"));
184
185 if (empty($object->actionmsg2)) {
186 if (empty($object->context['actionmsg2'])) {
187 $object->actionmsg2 = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name);
188 } else {
189 $object->actionmsg2 = $object->context['actionmsg2'];
190 }
191 }
192 if (empty($object->actionmsg)) {
193 $object->actionmsg = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name);
194 }
195
196 $object->sendtoid = array($object->id => $object->id);
197 // $object->socid = $object->socid;
198 } elseif ($action == 'CONTRACT_VALIDATE') {
199 '@phan-var-force Contrat $object';
200 // Load translation files required by the page
201 $langs->loadLangs(array("agenda", "other", "contracts"));
202
203 if (empty($object->actionmsg2)) {
204 if (empty($object->context['actionmsg2'])) {
205 $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
206 } else {
207 $object->actionmsg2 = $object->context['actionmsg2'];
208 }
209 }
210 if (empty($object->actionmsg)) {
211 $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
212 }
213
214 $object->sendtoid = array();
215 } elseif ($action == 'CONTRACT_SENTBYMAIL') {
216 '@phan-var-force Contrat $object';
217 // Load translation files required by the page
218 $langs->loadLangs(array("agenda", "other", "contracts"));
219
220 if (empty($object->actionmsg2)) {
221 if (empty($object->context['actionmsg2'])) {
222 $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref);
223 } else {
224 $object->actionmsg2 = $object->context['actionmsg2'];
225 }
226 }
227 if (empty($object->actionmsg)) {
228 $object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref);
229 }
230
231 // Parameters $object->sendtoid defined by caller
232 //$object->sendtoid = array();
233 } elseif ($action == 'PROPAL_VALIDATE') {
234 '@phan-var-force Propal $object';
235 // Load translation files required by the page
236 $langs->loadLangs(array("agenda", "other", "propal"));
237
238 if (empty($object->actionmsg2)) {
239 if (empty($object->context['actionmsg2'])) {
240 $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
241 } else {
242 $object->actionmsg2 = $object->context['actionmsg2'];
243 }
244 }
245 if (empty($object->actionmsg)) {
246 $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
247 }
248
249 $object->sendtoid = array();
250 } elseif ($action == 'PROPAL_MODIFY') {
251 '@phan-var-force Propal $object';
252 // Load translation files required by the page
253 $langs->loadLangs(array("agenda", "other", "propal"));
254
255 if (empty($object->actionmsg2)) {
256 if (empty($object->context['actionmsg2'])) {
257 $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
258 } else {
259 $object->actionmsg2 = $object->context['actionmsg2'];
260 }
261 }
262 if (empty($object->actionmsg)) {
263 $object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref));
264 }
265
266 $object->sendtoid = array();
267 } elseif ($action == 'PROPAL_SENTBYMAIL') {
268 '@phan-var-force Propal $object';
269 // Load translation files required by the page
270 $langs->loadLangs(array("agenda", "other", "propal"));
271
272 if (empty($object->actionmsg2)) {
273 if (empty($object->context['actionmsg2'])) {
274 $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
275 } else {
276 $object->actionmsg2 = $object->context['actionmsg2'];
277 }
278 }
279 if (empty($object->actionmsg)) {
280 $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
281 }
282
283 // Parameters $object->sendtoid defined by caller
284 //$object->sendtoid = array();
285 } elseif ($action == 'PROPAL_CLOSE_SIGNED') {
286 '@phan-var-force Propal $object';
287 // Load translation files required by the page
288 $langs->loadLangs(array("agenda", "other", "propal"));
289
290 if (empty($object->actionmsg2)) {
291 if (empty($object->context['actionmsg2'])) {
292 $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
293 } else {
294 $object->actionmsg2 = $object->context['actionmsg2'];
295 }
296 }
297 if (empty($object->actionmsg)) {
298 $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
299 }
300
301 $object->sendtoid = array();
302 } elseif ($action == 'PROPAL_CLASSIFY_BILLED') {
303 '@phan-var-force Propal $object';
304 // Load translation files required by the page
305 $langs->loadLangs(array("agenda", "other", "propal"));
306
307 if (empty($object->actionmsg2)) {
308 if (empty($object->context['actionmsg2'])) {
309 $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
310 } else {
311 $object->actionmsg2 = $object->context['actionmsg2'];
312 }
313 }
314 if (empty($object->actionmsg)) {
315 $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
316 }
317
318 $object->sendtoid = array();
319 } elseif ($action == 'PROPAL_CLOSE_REFUSED') {
320 '@phan-var-force Propal $object';
321 // Load translation files required by the page
322 $langs->loadLangs(array("agenda", "other", "propal"));
323
324 if (empty($object->actionmsg2)) {
325 if (empty($object->context['actionmsg2'])) {
326 $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
327 } else {
328 $object->actionmsg2 = $object->context['actionmsg2'];
329 }
330 }
331 if (empty($object->actionmsg)) {
332 $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
333 }
334
335 $object->sendtoid = array();
336 } elseif ($action == 'ORDER_VALIDATE') {
337 '@phan-var-force Commande $object';
338 // Load translation files required by the page
339 $langs->loadLangs(array("agenda", "orders"));
340
341 if (empty($object->actionmsg2)) {
342 if (empty($object->context['actionmsg2'])) {
343 $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
344 } else {
345 $object->actionmsg2 = $object->context['actionmsg2'];
346 }
347 }
348 if (empty($object->actionmsg)) {
349 $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
350 }
351
352 $object->sendtoid = array();
353 } elseif ($action == 'ORDER_CLOSE') {
354 '@phan-var-force Commande $object';
355 // Load translation files required by the page
356 $langs->loadLangs(array("agenda", "other", "orders"));
357
358 if (empty($object->actionmsg2)) {
359 if (empty($object->context['actionmsg2'])) {
360 $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
361 } else {
362 $object->actionmsg2 = $object->context['actionmsg2'];
363 }
364 }
365 if (empty($object->actionmsg)) {
366 $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
367 }
368
369 $object->sendtoid = array();
370 } elseif ($action == 'ORDER_CLASSIFY_BILLED') {
371 '@phan-var-force Commande $object';
372 // Load translation files required by the page
373 $langs->loadLangs(array("agenda", "other", "orders"));
374
375 if (empty($object->actionmsg2)) {
376 if (empty($object->context['actionmsg2'])) {
377 $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
378 } else {
379 $object->actionmsg2 = $object->context['actionmsg2'];
380 }
381 }
382 if (empty($object->actionmsg)) {
383 $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
384 }
385
386 $object->sendtoid = array();
387 } elseif ($action == 'ORDER_CANCEL') {
388 '@phan-var-force Commande $object';
389 // Load translation files required by the page
390 $langs->loadLangs(array("agenda", "other", "orders"));
391
392 if (empty($object->actionmsg2)) {
393 if (empty($object->context['actionmsg2'])) {
394 $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
395 } else {
396 $object->actionmsg2 = $object->context['actionmsg2'];
397 }
398 }
399 if (empty($object->actionmsg)) {
400 $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
401 }
402
403 $object->sendtoid = array();
404 } elseif ($action == 'ORDER_SENTBYMAIL') {
405 '@phan-var-force Commande $object';
406 // Load translation files required by the page
407 $langs->loadLangs(array("agenda", "other", "orders"));
408
409 if (empty($object->actionmsg2)) {
410 if (empty($object->context['actionmsg2'])) {
411 $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref);
412 } else {
413 $object->actionmsg2 = $object->context['actionmsg2'];
414 }
415 }
416 if (empty($object->actionmsg)) {
417 $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref);
418 }
419
420 // Parameters $object->sendtoid defined by caller
421 //$object->sendtoid = array();
422 } elseif ($action == 'BILL_VALIDATE') {
423 '@phan-var-force Facture $object';
424 // Load translation files required by the page
425 $langs->loadLangs(array("agenda", "other", "bills"));
426
427 if (empty($object->actionmsg2)) {
428 if (empty($object->context['actionmsg2'])) {
429 $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
430 } else {
431 $object->actionmsg2 = $object->context['actionmsg2'];
432 }
433 }
434 if (empty($object->actionmsg)) {
435 $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
436 }
437
438 $object->sendtoid = array();
439 } elseif ($action == 'BILL_UNVALIDATE') {
440 '@phan-var-force Facture $object';
441 // Load translation files required by the page
442 $langs->loadLangs(array("agenda", "other", "bills"));
443
444 if (empty($object->actionmsg2)) {
445 if (empty($object->context['actionmsg2'])) {
446 $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
447 } else {
448 $object->actionmsg2 = $object->context['actionmsg2'];
449 }
450 }
451 if (empty($object->actionmsg)) {
452 $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
453 }
454
455 $object->sendtoid = array();
456 } elseif ($action == 'BILL_SENTBYMAIL') {
457 '@phan-var-force Facture $object';
458 // Load translation files required by the page
459 $langs->loadLangs(array("agenda", "other", "bills"));
460
461 if (empty($object->actionmsg2)) {
462 if (empty($object->context['actionmsg2'])) {
463 $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
464 } else {
465 $object->actionmsg2 = $object->context['actionmsg2'];
466 }
467 }
468 if (empty($object->actionmsg)) {
469 $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
470 }
471
472 // Parameters $object->sendtoid defined by caller
473 //$object->sendtoid = array();
474 } elseif ($action == 'BILL_PAYED') {
475 '@phan-var-force Facture $object';
476 // Load translation files required by the page
477 $langs->loadLangs(array("agenda", "other", "bills"));
478
479 // Values for this action can't be defined by caller.
480 if (empty($object->actionmsg2)) {
481 if (empty($object->context['actionmsg2'])) {
482 $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
483 } else {
484 $object->actionmsg2 = $object->context['actionmsg2'];
485 }
486 }
487 if (empty($object->actionmsg)) {
488 $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
489 }
490
491 $object->sendtoid = array();
492 } elseif ($action == 'BILL_CANCEL') {
493 '@phan-var-force Facture $object';
494 // Load translation files required by the page
495 $langs->loadLangs(array("agenda", "other", "bills"));
496
497 if (empty($object->actionmsg2)) {
498 if (empty($object->context['actionmsg2'])) {
499 $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
500 } else {
501 $object->actionmsg2 = $object->context['actionmsg2'];
502 }
503 }
504 if (empty($object->actionmsg)) {
505 $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
506 }
507
508 $object->sendtoid = array();
509 } elseif ($action == 'FICHINTER_CREATE') {
510 '@phan-var-force Fichinter $object';
511 // Load translation files required by the page
512 $langs->loadLangs(array("agenda", "other", "interventions"));
513
514 if (empty($object->actionmsg2)) {
515 if (empty($object->context['actionmsg2'])) {
516 $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
517 } else {
518 $object->actionmsg2 = $object->context['actionmsg2'];
519 }
520 }
521 if (empty($object->actionmsg)) {
522 $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
523 }
524
525 $object->sendtoid = array();
526 $object->fk_element = 0;
527 $object->elementtype = '';
528 } elseif ($action == 'FICHINTER_VALIDATE') {
529 '@phan-var-force Fichinter $object';
530 // Load translation files required by the page
531 $langs->loadLangs(array("agenda", "other", "interventions"));
532
533 if (empty($object->actionmsg2)) {
534 if (empty($object->context['actionmsg2'])) {
535 $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
536 } else {
537 $object->actionmsg2 = $object->context['actionmsg2'];
538 }
539 }
540 if (empty($object->actionmsg)) {
541 $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
542 }
543
544 $object->sendtoid = array();
545 $object->fk_element = 0;
546 $object->elementtype = '';
547 } elseif ($action == 'FICHINTER_MODIFY') {
548 '@phan-var-force Fichinter $object';
549 // Load translation files required by the page
550 $langs->loadLangs(array("agenda", "other", "interventions"));
551
552 if (empty($object->actionmsg2)) {
553 if (empty($object->context['actionmsg2'])) {
554 $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
555 } else {
556 $object->actionmsg2 = $object->context['actionmsg2'];
557 }
558 }
559 if (empty($object->actionmsg)) {
560 $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
561 }
562
563 $object->sendtoid = array();
564 $object->fk_element = 0;
565 $object->elementtype = '';
566 } elseif ($action == 'FICHINTER_SENTBYMAIL') {
567 '@phan-var-force Fichinter $object';
568 // Load translation files required by the page
569 $langs->loadLangs(array("agenda", "other", "interventions"));
570
571 if (empty($object->actionmsg2)) {
572 if (empty($object->context['actionmsg2'])) {
573 $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref);
574 } else {
575 $object->actionmsg2 = $object->context['actionmsg2'];
576 }
577 }
578 if (empty($object->actionmsg)) {
579 $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref);
580 }
581
582 // Parameters $object->sendtoid defined by caller
583 //$object->sendtoid = array();
584 } elseif ($action == 'FICHINTER_CLASSIFY_BILLED') {
585 '@phan-var-force Fichinter $object';
586 // Load translation files required by the page
587 $langs->loadLangs(array("agenda", "other", "interventions"));
588
589 if (empty($object->actionmsg2)) {
590 if (empty($object->context['actionmsg2'])) {
591 $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
592 } else {
593 $object->actionmsg2 = $object->context['actionmsg2'];
594 }
595 }
596 if (empty($object->actionmsg)) {
597 $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
598 }
599
600 $object->sendtoid = array();
601 } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') {
602 '@phan-var-force Fichinter $object';
603 // Load translation files required by the page
604 $langs->loadLangs(array("agenda", "other", "interventions"));
605
606 if (empty($object->actionmsg2)) {
607 if (empty($object->context['actionmsg2'])) {
608 $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
609 } else {
610 $object->actionmsg2 = $object->context['actionmsg2'];
611 }
612 }
613 if (empty($object->actionmsg)) {
614 $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
615 }
616
617 $object->sendtoid = array();
618 } elseif ($action == 'FICHINTER_CLOSE') {
619 '@phan-var-force Fichinter $object';
620 // Load translation files required by the page
621 $langs->loadLangs(array("agenda", "other", "interventions"));
622
623 if (empty($object->actionmsg2)) {
624 if (empty($object->context['actionmsg2'])) {
625 $object->actionmsg2 = $langs->transnoentities("InterventionClosedInDolibarr", $object->ref);
626 } else {
627 $object->actionmsg2 = $object->context['actionmsg2'];
628 }
629 }
630 if (empty($object->actionmsg)) {
631 $object->actionmsg = $langs->transnoentities("InterventionClosedInDolibarr", $object->ref);
632 }
633
634 $object->sendtoid = array();
635 $object->fk_element = 0;
636 $object->elementtype = '';
637 } elseif ($action == 'FICHINTER_DELETE') {
638 '@phan-var-force Fichinter $object';
639 // Load translation files required by the page
640 $langs->loadLangs(array("agenda", "other", "interventions"));
641
642 if (empty($object->actionmsg2)) {
643 if (empty($object->context['actionmsg2'])) {
644 $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
645 } else {
646 $object->actionmsg2 = $object->context['actionmsg2'];
647 }
648 }
649 if (empty($object->actionmsg)) {
650 $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
651 }
652
653 $object->sendtoid = array();
654 $object->fk_element = 0;
655 $object->elementtype = '';
656 } elseif ($action == 'SHIPPING_VALIDATE') {
657 '@phan-var-force Expedition $object';
658 // Load translation files required by the page
659 $langs->loadLangs(array("agenda", "other", "sendings"));
660
661 if (empty($object->actionmsg2)) {
662 if (empty($object->context['actionmsg2'])) {
663 $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
664 } else {
665 $object->actionmsg2 = $object->context['actionmsg2'];
666 }
667 }
668 if (empty($object->actionmsg)) {
669 $object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
670 }
671
672 // Parameters $object->sendtoid defined by caller
673 //$object->sendtoid = array();
674 } elseif ($action == 'SHIPPING_SENTBYMAIL') {
675 '@phan-var-force Expedition $object';
676 // Load translation files required by the page
677 $langs->loadLangs(array("agenda", "other", "sendings"));
678
679 if (empty($object->actionmsg2)) {
680 if (empty($object->context['actionmsg2'])) {
681 $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref);
682 } else {
683 $object->actionmsg2 = $object->context['actionmsg2'];
684 }
685 }
686 if (empty($object->actionmsg)) {
687 $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref);
688 }
689
690 // Parameters $object->sendtoid defined by caller
691 //$object->sendtoid = array();
692 } elseif ($action == 'RECEPTION_VALIDATE') {
693 '@phan-var-force Reception $object';
694 $langs->load("agenda");
695 $langs->load("other");
696 $langs->load("receptions");
697
698 if (empty($object->actionmsg2)) {
699 if (empty($object->context['actionmsg2'])) {
700 $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
701 } else {
702 $object->actionmsg2 = $object->context['actionmsg2'];
703 }
704 }
705 if (empty($object->actionmsg)) {
706 $object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
707 }
708
709 // Parameters $object->sendtoid defined by caller
710 //$object->sendtoid = array();
711 } elseif ($action == 'RECEPTION_SENTBYMAIL') {
712 '@phan-var-force Reception $object';
713 $langs->load("agenda");
714 $langs->load("other");
715 $langs->load("receptions");
716
717 if (empty($object->actionmsg2)) {
718 if (empty($object->context['actionmsg2'])) {
719 $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
720 } else {
721 $object->actionmsg2 = $object->context['actionmsg2'];
722 }
723 }
724 if (empty($object->actionmsg)) {
725 $object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
726 }
727
728 // Parameters $object->sendtoid defined by caller
729 //$object->sendtoid = array();
730 } elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') {
731 '@phan-var-force SupplierProposal $object';
732 // Load translation files required by the page
733 $langs->loadLangs(array("agenda", "other", "propal"));
734
735 if (empty($object->actionmsg2)) {
736 if (empty($object->context['actionmsg2'])) {
737 $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
738 } else {
739 $object->actionmsg2 = $object->context['actionmsg2'];
740 }
741 }
742 if (empty($object->actionmsg)) {
743 $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
744 }
745
746 $object->sendtoid = array();
747 } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') {
748 '@phan-var-force SupplierProposal $object';
749 // Load translation files required by the page
750 $langs->loadLangs(array("agenda", "other", "propal"));
751
752 if (empty($object->actionmsg2)) {
753 if (empty($object->context['actionmsg2'])) {
754 $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
755 } else {
756 $object->actionmsg2 = $object->context['actionmsg2'];
757 }
758 }
759 if (empty($object->actionmsg)) {
760 $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
761 }
762
763 // Parameters $object->sendtoid defined by caller
764 //$object->sendtoid = array();
765 } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') {
766 '@phan-var-force SupplierProposal $object';
767 // Load translation files required by the page
768 $langs->loadLangs(array("agenda", "other", "propal"));
769
770 if (empty($object->actionmsg2)) {
771 if (empty($object->context['actionmsg2'])) {
772 $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
773 } else {
774 $object->actionmsg2 = $object->context['actionmsg2'];
775 }
776 }
777 if (empty($object->actionmsg)) {
778 $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
779 }
780
781 $object->sendtoid = array();
782 } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') {
783 '@phan-var-force SupplierProposal $object';
784 // Load translation files required by the page
785 $langs->loadLangs(array("agenda", "other", "propal"));
786
787 if (empty($object->actionmsg2)) {
788 if (empty($object->context['actionmsg2'])) {
789 $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
790 } else {
791 $object->actionmsg2 = $object->context['actionmsg2'];
792 }
793 }
794 if (empty($object->actionmsg)) {
795 $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
796 }
797
798 $object->sendtoid = array();
799 } elseif ($action == 'ORDER_SUPPLIER_CREATE') {
800 '@phan-var-force CommandeFournisseur $object';
801 // Load translation files required by the page
802 $langs->loadLangs(array("agenda", "other", "orders"));
803
804 if (empty($object->actionmsg2)) {
805 if (empty($object->context['actionmsg2'])) {
806 $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
807 } else {
808 $object->actionmsg2 = $object->context['actionmsg2'];
809 }
810 }
811 if (empty($object->actionmsg)) {
812 $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
813 }
814
815 $object->sendtoid = array();
816 } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
817 '@phan-var-force CommandeFournisseur $object';
818 // Load translation files required by the page
819 $langs->loadLangs(array("agenda", "other", "orders"));
820
821 if (empty($object->actionmsg2)) {
822 if (empty($object->context['actionmsg2'])) {
823 $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
824 } else {
825 $object->actionmsg2 = $object->context['actionmsg2'];
826 }
827 }
828 if (empty($object->actionmsg)) {
829 $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
830 }
831
832 $object->sendtoid = array();
833 } elseif ($action == 'ORDER_SUPPLIER_APPROVE') {
834 '@phan-var-force CommandeFournisseur $object';
835 // Load translation files required by the page
836 $langs->loadLangs(array("agenda", "other", "orders"));
837
838 if (empty($object->actionmsg2)) {
839 if (empty($object->context['actionmsg2'])) {
840 $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
841 } else {
842 $object->actionmsg2 = $object->context['actionmsg2'];
843 }
844 }
845 if (empty($object->actionmsg)) {
846 $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
847 }
848
849 $object->sendtoid = array();
850 } elseif ($action == 'ORDER_SUPPLIER_REFUSE') {
851 '@phan-var-force CommandeFournisseur $object';
852 // Load translation files required by the page
853 $langs->loadLangs(array("agenda", "other", "orders", "main"));
854
855 if (empty($object->actionmsg2)) {
856 if (empty($object->context['actionmsg2'])) {
857 $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
858 } else {
859 $object->actionmsg2 = $object->context['actionmsg2'];
860 }
861 }
862 if (empty($object->actionmsg)) {
863 $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
864 }
865
866 if (!empty($object->refuse_note)) {
867 $object->actionmsg .= '<br>';
868 $object->actionmsg .= $langs->trans("Reason") . ': '.$object->refuse_note;
869 }
870
871 $object->sendtoid = array();
872 } elseif ($action == 'ORDER_SUPPLIER_CANCEL') {
873 '@phan-var-force CommandeFournisseur $object';
874 // Load translation files required by the page
875 $langs->loadLangs(array("agenda", "other", "orders", "main"));
876
877 if (empty($object->actionmsg2)) {
878 if (empty($object->context['actionmsg2'])) {
879 $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
880 } else {
881 $object->actionmsg2 = $object->context['actionmsg2'];
882 }
883 }
884 if (empty($object->actionmsg)) {
885 $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
886 }
887
888 if (!empty($object->cancel_note)) {
889 $object->actionmsg .= '<br>';
890 $object->actionmsg .= $langs->trans("Reason") . ': '.$object->cancel_note;
891 }
892
893 $object->sendtoid = array();
894 } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') {
895 '@phan-var-force CommandeFournisseur $object';
896 // Load translation files required by the page
897 $langs->loadLangs(array("agenda", "other", "orders"));
898
899 if (empty($object->actionmsg2)) {
900 if (empty($object->context['actionmsg2'])) {
901 $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ?: $object->ref), $object->getInputMethod());
902 } else {
903 $object->actionmsg2 = $object->context['actionmsg2'];
904 }
905 }
906 if (empty($object->actionmsg)) {
907 $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
908 }
909
910 if (!empty($object->context['comments'])) {
911 $object->actionmsg .= '<br>';
912 $object->actionmsg .= $langs->trans("Comment") . ': '.$object->context['comments'];
913 }
914
915 $object->sendtoid = array();
916 } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') {
917 '@phan-var-force CommandeFournisseur $object';
918 // Load translation files required by the page
919 $langs->loadLangs(array("agenda", "other", "orders"));
920
921 if (empty($object->actionmsg2)) {
922 if (empty($object->context['actionmsg2'])) {
923 $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
924 } else {
925 $object->actionmsg2 = $object->context['actionmsg2'];
926 }
927 }
928 if (empty($object->actionmsg)) {
929 $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
930 }
931
932 $object->sendtoid = array();
933 } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
934 '@phan-var-force CommandeFournisseur $object';
935 // Load translation files required by the page
936 $langs->loadLangs(array("agenda", "other", "bills", "orders"));
937
938 if (empty($object->actionmsg2)) {
939 if (empty($object->context['actionmsg2'])) {
940 $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
941 } else {
942 $object->actionmsg2 = $object->context['actionmsg2'];
943 }
944 }
945 if (empty($object->actionmsg)) {
946 $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
947 }
948
949 // Parameters $object->sendtoid defined by caller
950 //$object->sendtoid = array();
951 } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') {
952 '@phan-var-force CommandeFournisseur $object';
953 // Load translation files required by the page
954 $langs->loadLangs(array("agenda", "other", "bills", "orders"));
955
956 if (empty($object->actionmsg2)) {
957 if (empty($object->context['actionmsg2'])) {
958 $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
959 } else {
960 $object->actionmsg2 = $object->context['actionmsg2'];
961 }
962 }
963 if (empty($object->actionmsg)) {
964 $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
965 }
966
967 $object->sendtoid = array();
968 } elseif ($action == 'BILL_SUPPLIER_CREATE') {
969 '@phan-var-force FactureFournisseur $object';
970 // Load translation files required by the page
971 $langs->loadLangs(array("agenda", "other", "orders"));
972
973 if (empty($object->actionmsg2)) {
974 if (empty($object->context['actionmsg2'])) {
975 $object->actionmsg2 = $langs->transnoentities("InvoiceCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
976 } else {
977 $object->actionmsg2 = $object->context['actionmsg2'];
978 }
979 }
980 if (empty($object->actionmsg)) {
981 $object->actionmsg = $langs->transnoentities("InvoiceCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
982 }
983
984 $object->sendtoid = array();
985 } elseif ($action == 'BILL_SUPPLIER_VALIDATE') {
986 '@phan-var-force FactureFournisseur $object';
987 // Load translation files required by the page
988 $langs->loadLangs(array("agenda", "other", "bills"));
989
990 if (empty($object->actionmsg2)) {
991 if (empty($object->context['actionmsg2'])) {
992 $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
993 } else {
994 $object->actionmsg2 = $object->context['actionmsg2'];
995 }
996 }
997 if (empty($object->actionmsg)) {
998 $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
999 }
1000
1001 $object->sendtoid = array();
1002 } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') {
1003 '@phan-var-force FactureFournisseur $object';
1004 // Load translation files required by the page
1005 $langs->loadLangs(array("agenda", "other", "bills"));
1006
1007 if (empty($object->actionmsg2)) {
1008 if (empty($object->context['actionmsg2'])) {
1009 $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
1010 } else {
1011 $object->actionmsg2 = $object->context['actionmsg2'];
1012 }
1013 }
1014 if (empty($object->actionmsg)) {
1015 $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
1016 }
1017
1018 $object->sendtoid = array();
1019 } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') {
1020 '@phan-var-force FactureFournisseur $object';
1021 // Load translation files required by the page
1022 $langs->loadLangs(array("agenda", "other", "bills", "orders"));
1023
1024 if (empty($object->actionmsg2)) {
1025 if (empty($object->context['actionmsg2'])) {
1026 $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
1027 } else {
1028 $object->actionmsg2 = $object->context['actionmsg2'];
1029 }
1030 }
1031 if (empty($object->actionmsg)) {
1032 $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
1033 }
1034
1035 // Parameters $object->sendtoid defined by caller
1036 //$object->sendtoid = array();
1037 } elseif ($action == 'BILL_SUPPLIER_PAYED') {
1038 '@phan-var-force FactureFournisseur $object';
1039 // Load translation files required by the page
1040 $langs->loadLangs(array("agenda", "other", "bills"));
1041
1042 if (empty($object->actionmsg2)) {
1043 if (empty($object->context['actionmsg2'])) {
1044 $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
1045 } else {
1046 $object->actionmsg2 = $object->context['actionmsg2'];
1047 }
1048 }
1049 if (empty($object->actionmsg)) {
1050 $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
1051 }
1052
1053 $object->sendtoid = array();
1054 } elseif ($action == 'BILL_SUPPLIER_CANCELED') {
1055 // Load translation files required by the page
1056 $langs->loadLangs(array("agenda", "other", "bills"));
1057
1058 if (empty($object->actionmsg2)) {
1059 if (empty($object->context['actionmsg2'])) {
1060 $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
1061 } else {
1062 $object->actionmsg2 = $object->context['actionmsg2'];
1063 }
1064 }
1065 if (empty($object->actionmsg)) {
1066 $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
1067 }
1068
1069 $object->sendtoid = array();
1070 } elseif ($action == 'MEMBER_VALIDATE') {
1071 '@phan-var-force Adherent $object';
1072 // Members
1073 // Load translation files required by the page
1074 $langs->loadLangs(array("agenda", "other", "members"));
1075
1076 if (empty($object->actionmsg2)) {
1077 if (empty($object->context['actionmsg2'])) {
1078 $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
1079 } else {
1080 $object->actionmsg2 = $object->context['actionmsg2'];
1081 }
1082 }
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;
1087 }
1088
1089 $object->sendtoid = array();
1090 } elseif ($action == 'MEMBER_MODIFY') {
1091 '@phan-var-force Adherent $object';
1092 // Load translation files required by the page
1093 $langs->loadLangs(array("agenda", "other", "members"));
1094
1095 if (empty($object->actionmsg2)) {
1096 if (empty($object->context['actionmsg2'])) {
1097 $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
1098 } else {
1099 $object->actionmsg2 = $object->context['actionmsg2'];
1100 }
1101 }
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;
1106 }
1107
1108 $object->sendtoid = array();
1109 } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') {
1110 '@phan-var-force Subscription $object';
1111 // Load translation files required by the page
1112 $langs->loadLangs(array("agenda", "other", "members"));
1113
1114 $member = (isset($object->context['member']) ? $object->context['member'] : null);
1115 if (!is_object($member)) { // This should not happen
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';
1118 $member = new Adherent($this->db);
1119 $member->fetch($object->fk_adherent);
1120 }
1121
1122 if (empty($object->actionmsg2)) {
1123 if (empty($object->context['actionmsg2'])) {
1124 $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs));
1125 } else {
1126 $object->actionmsg2 = $object->context['actionmsg2'];
1127 }
1128 }
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;
1134 $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
1135 }
1136
1137 $object->sendtoid = array();
1138 if (isset($object->fk_soc) && $object->fk_soc > 0) {
1139 $object->socid = $object->fk_soc;
1140 }
1141 } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') {
1142 '@phan-var-force Subscription $object';
1143 // Load translation files required by the page
1144 $langs->loadLangs(array("agenda", "other", "members"));
1145
1146 $member = $object->context['member'];
1147 if (!is_object($member)) { // This should not happen
1148 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
1149 $member = new Adherent($this->db);
1150 $member->fetch($object->fk_adherent);
1151 }
1152
1153 if (empty($object->actionmsg2)) {
1154 if (empty($object->context['actionmsg2'])) {
1155 $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs));
1156 } else {
1157 $object->actionmsg2 = $object->context['actionmsg2'];
1158 }
1159 }
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;
1165 $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
1166 }
1167
1168 $object->sendtoid = array();
1169 if (isset($object->fk_soc) && $object->fk_soc > 0) {
1170 $object->socid = $object->fk_soc;
1171 }
1172 } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') {
1173 '@phan-var-force Subscription $object';
1174 // Load translation files required by the page
1175 $langs->loadLangs(array("agenda", "other", "members"));
1176
1177 $member = $object->context['member'];
1178 if (!is_object($member)) { // This should not happen but it happen when deleting a subscription from adherents/subscription/card.php
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';
1181 $member = new Adherent($this->db);
1182 $member->fetch($object->fk_adherent);
1183 }
1184
1185 if (empty($object->actionmsg2)) {
1186 if (empty($object->context['actionmsg2'])) {
1187 $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs));
1188 } else {
1189 $object->actionmsg2 = $object->context['actionmsg2'];
1190 }
1191 }
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;
1197 $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day');
1198 }
1199
1200 $object->sendtoid = array();
1201 if (isset($object->fk_soc) && $object->fk_soc > 0) {
1202 $object->socid = $object->fk_soc;
1203 }
1204 } elseif ($action == 'MEMBER_RESILIATE') {
1205 '@phan-var-force Adherent $object';
1206 // Load translation files required by the page
1207 $langs->loadLangs(array("agenda", "other", "members"));
1208
1209 if (empty($object->actionmsg2)) {
1210 if (empty($object->context['actionmsg2'])) {
1211 $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
1212 } else {
1213 $object->actionmsg2 = $object->context['actionmsg2'];
1214 }
1215 }
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;
1220 }
1221
1222 $object->sendtoid = array();
1223 } elseif ($action == 'MEMBER_DELETE') {
1224 '@phan-var-force Adherent $object';
1225 // Load translation files required by the page
1226 $langs->loadLangs(array("agenda", "other", "members"));
1227
1228 if (empty($object->actionmsg2)) {
1229 if (empty($object->context['actionmsg2'])) {
1230 $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
1231 } else {
1232 $object->actionmsg2 = $object->context['actionmsg2'];
1233 }
1234 }
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;
1239 }
1240
1241 $object->sendtoid = array();
1242 } elseif ($action == 'MEMBER_EXCLUDE') {
1243 '@phan-var-force Adherent $object';
1244 // Load translation files required by the page
1245 $langs->loadLangs(array("agenda", "other", "members"));
1246
1247 if (empty($object->actionmsg2)) {
1248 if (empty($object->context['actionmsg2'])) {
1249 $object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs));
1250 } else {
1251 $object->actionmsg2 = $object->context['actionmsg2'];
1252 }
1253 }
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;
1258 }
1259
1260 $object->sendtoid = array();
1261 } elseif ($action == 'PROJECT_CREATE') {
1262 '@phan-var-force Project $object';
1263 // Projects
1264 // Load translation files required by the page
1265 $langs->loadLangs(array("agenda", "other", "projects"));
1266
1267 if (empty($object->actionmsg2)) {
1268 if (empty($object->context['actionmsg2'])) {
1269 $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
1270 } else {
1271 $object->actionmsg2 = $object->context['actionmsg2'];
1272 }
1273 }
1274 if (empty($object->actionmsg)) {
1275 $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
1276 $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
1277 }
1278
1279 $object->sendtoid = array();
1280 } elseif ($action == 'PROJECT_VALIDATE') {
1281 '@phan-var-force Project $object';
1282 // Load translation files required by the page
1283 $langs->loadLangs(array("agenda", "other", "projects"));
1284
1285 if (empty($object->actionmsg2)) {
1286 if (empty($object->context['actionmsg2'])) {
1287 $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
1288 } else {
1289 $object->actionmsg2 = $object->context['actionmsg2'];
1290 }
1291 }
1292 if (empty($object->actionmsg)) {
1293 $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
1294 $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
1295 }
1296
1297 $object->sendtoid = array();
1298 } elseif ($action == 'PROJECT_MODIFY') {
1299 '@phan-var-force Project $object';
1300 // Load translation files required by the page
1301 $langs->loadLangs(array("agenda", "other", "projects"));
1302
1303 if (empty($object->actionmsg2)) {
1304 if (empty($object->context['actionmsg2'])) {
1305 $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
1306 } else {
1307 $object->actionmsg2 = $object->context['actionmsg2'];
1308 }
1309 }
1310 if (empty($object->actionmsg)) {
1311 $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
1312 }
1313
1314 //$object->actionmsg .= "\n".$langs->transnoentities("Task").': ???';
1315 if (!empty($object->usage_opportunity) && is_object($object->oldcopy) && $object->opp_status != $object->oldcopy->opp_status) {
1316 $object->actionmsg .= "\n".$langs->transnoentitiesnoconv("OpportunityStatus").': '.$object->oldcopy->opp_status.' -> '.$object->opp_status;
1317 }
1318
1319 $object->sendtoid = array();
1320 } elseif ($action == 'PROJECT_SENTBYMAIL') {
1321 '@phan-var-force Project $object';
1322 // Load translation files required by the page
1323 $langs->loadLangs(array("agenda", "other", "projects"));
1324
1325 if (empty($object->actionmsg2)) {
1326 if (empty($object->context['actionmsg2'])) {
1327 $object->actionmsg2 = $langs->transnoentities("ProjectSentByEMail", $object->ref);
1328 } else {
1329 $object->actionmsg2 = $object->context['actionmsg2'];
1330 }
1331 }
1332 if (empty($object->actionmsg)) {
1333 $object->actionmsg = $langs->transnoentities("ProjectSentByEMail", $object->ref);
1334 }
1335
1336 // Parameters $object->sendtoid defined by caller
1337 //$object->sendtoid = array();
1338 } elseif ($action == 'PROJECT_DELETE') {
1339 '@phan-var-force Project $object';
1340 // Load translation files required by the page
1341 $langs->loadLangs(array("agenda", "other", "projects"));
1342
1343 if (empty($object->actionmsg2)) {
1344 $object->actionmsg2 = $langs->transnoentities("ProjectDeletedInDolibarr", $object->ref);
1345 }
1346 $object->actionmsg = $langs->transnoentities("ProjectDeletedInDolibarr", $object->ref);
1347
1348 $object->sendtoid = array();
1349 } elseif ($action == 'PROJECT_CLOSE') {
1350 // Load translation files required by the page
1351 $langs->loadLangs(array("agenda", "other", "projects"));
1352
1353 if (empty($object->actionmsg2)) {
1354 if (empty($object->context['actionmsg2'])) {
1355 $object->actionmsg2 = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref);
1356 } else {
1357 $object->actionmsg2 = $object->context['actionmsg2'];
1358 }
1359 }
1360 if (empty($object->actionmsg)) {
1361 $object->actionmsg = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref);
1362 }
1363
1364 $object->sendtoid = array();
1365 } elseif ($action == 'TASK_CREATE') {
1366 '@phan-var-force Task $object';
1367 // Project tasks
1368 // Load translation files required by the page
1369 $langs->loadLangs(array("agenda", "other", "projects"));
1370
1371 if (empty($object->actionmsg2)) {
1372 if (empty($object->context['actionmsg2'])) {
1373 $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
1374 } else {
1375 $object->actionmsg2 = $object->context['actionmsg2'];
1376 }
1377 }
1378 if (empty($object->actionmsg)) {
1379 $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
1380 $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
1381 }
1382
1383 $object->sendtoid = array();
1384 } elseif ($action == 'TASK_MODIFY') {
1385 '@phan-var-force Task $object';
1386 // Load translation files required by the page
1387 $langs->loadLangs(array("agenda", "other", "projects"));
1388
1389 if (empty($object->actionmsg2)) {
1390 if (empty($object->context['actionmsg2'])) {
1391 $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref);
1392 } else {
1393 $object->actionmsg2 = $object->context['actionmsg2'];
1394 }
1395 }
1396 if (empty($object->actionmsg)) {
1397 $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref);
1398 $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
1399 }
1400
1401 $object->sendtoid = array();
1402 } elseif ($action == 'TASK_DELETE') {
1403 '@phan-var-force Task $object';
1404 // Load translation files required by the page
1405 $langs->loadLangs(array("agenda", "other", "projects"));
1406
1407 if (empty($object->actionmsg2)) {
1408 if (empty($object->context['actionmsg2'])) {
1409 $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
1410 } else {
1411 $object->actionmsg2 = $object->context['actionmsg2'];
1412 }
1413 }
1414 if (empty($object->actionmsg)) {
1415 $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
1416 $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
1417 }
1418
1419 $object->sendtoid = array();
1420 } elseif ($action == 'TICKET_ASSIGNED') {
1421 '@phan-var-force Ticket $object';
1422 // Load translation files required by the page
1423 $langs->loadLangs(array("agenda", "other", "projects"));
1424
1425 if (empty($object->actionmsg2)) {
1426 if (empty($object->context['actionmsg2'])) {
1427 $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
1428 } else {
1429 $object->actionmsg2 = $object->context['actionmsg2'];
1430 }
1431 }
1432 if (empty($object->actionmsg)) {
1433 $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
1434 }
1435
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);
1440 } else {
1441 $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$langs->trans("None");
1442 }
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);
1447 } else {
1448 $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None");
1449 }
1450
1451 $object->sendtoid = array();
1452 } else {
1453 // TODO Merge all previous cases into this generic one
1454 // $action = PASSWORD, BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ...
1455 // Can also be a value defined by an external module like SENTBYSMS, COMPANY_SENTBYSMS, MEMBER_SENTBYSMS, ...
1456 // Note: We are here only if getDolGlobalString('MAIN_AGENDA_ACTIONAUTO_action') is on (tested at beginning of this function).
1457 // Note that these activation key can be set in agenda setup (but only if defined into llx_c_action_trigger).
1458
1459 // If initial message not sent but found into context
1460 if (!empty($object->context['actionmsg']) && empty($object->actionmsg)) { // For description
1461 $object->actionmsg = $object->context['actionmsg'];
1462 }
1463 if (!empty($object->context['actionmsg2']) && empty($object->actionmsg2)) { // For label
1464 $object->actionmsg2 = $object->context['actionmsg2'];
1465 }
1466
1467 // Set the label and message of event
1468 if (empty($object->actionmsg2)) {
1469 // Load translation files required by the page
1470 $langs->loadLangs(array("agenda", "other"));
1471 if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key
1472 $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
1473 } else { // generic translation key
1474 $tmp = explode('_', $action);
1475 $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
1476 }
1477 }
1478 if (empty($object->actionmsg)) {
1479 // Load translation files required by the page
1480 $langs->loadLangs(array("agenda", "other"));
1481 if ($langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref)) != $action."InDolibarr") { // specific translation key
1482 $object->actionmsg = $langs->transnoentities($action."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
1483 } else { // generic translation key
1484 $tmp = explode('_', $action);
1485 $object->actionmsg = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", (empty($object->newref) ? $object->ref : $object->newref));
1486 }
1487 if (isModEnabled('multicompany') && property_exists($object, 'entity') && $object->entity > 1) {
1488 $object->actionmsg .= ' ('.$langs->trans("Entity").' '.$object->entity.')';
1489 }
1490 }
1491
1492 // Concat note with data from context
1493 if (!empty($object->context['actionmsgmore'])) { // For description
1494 $object->actionmsg = dol_concatdesc($object->actionmsg, $object->context['actionmsgmore']);
1495 }
1496 if (!empty($object->context['actionmsg2more'])) { // For label
1497 $object->actionmsg2 = dol_concatdesc($object->actionmsg2, $object->context['actionmsg2more']);
1498 }
1499
1500 if (!isset($object->sendtoid) || !is_array($object->sendtoid)) {
1501 $object->sendtoid = array();
1502 }
1503 }
1504
1505 // If trackid is not defined, we set it.
1506 // Note that it should be set by caller. This is for compatibility purpose only.
1507 if (empty($object->trackid)) {
1508 // See also similar list into emailcollector.class.php
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;
1547 } else {
1548 $object->trackid = '';
1549 }
1550 }
1551
1552 dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id);
1553
1554 // Add entry in event table
1555 $now = dol_now();
1556
1557 if (isset($_SESSION['listofnames-'.$object->trackid])) {
1558 $attachments = $_SESSION['listofnames-'.$object->trackid];
1559 if ($attachments && strpos($action, 'SENTBYMAIL')) {
1560 $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachments);
1561 }
1562 }
1563
1564 $societeforactionid = 0;
1565 $contactforactionid = 0;
1566
1567 // Set $contactforactionid
1568 if (is_array($object->sendtoid)) {
1569 if (count($object->sendtoid) == 1) {
1570 $contactforactionid = reset($object->sendtoid);
1571 }
1572 } else {
1573 if ($object->sendtoid > 0) { // @phan-suppress-current-line PhanTypeComparisonFromArray
1574 $contactforactionid = $object->sendtoid;
1575 }
1576 }
1577 // Set $societeforactionid
1578 if (isset($object->socid) && $object->socid > 0) {
1579 $societeforactionid = $object->socid;
1580 } elseif (isset($object->fk_soc) && $object->fk_soc > 0) {
1581 $societeforactionid = $object->fk_soc;
1582 } elseif (isset($object->thirdparty) && isset($object->thirdparty->id) && $object->thirdparty->id > 0) {
1583 $societeforactionid = $object->thirdparty->id;
1584 }
1585
1586 $projectid = isset($object->fk_project) ? $object->fk_project : 0;
1587 if ($object->element == 'project') {
1588 '@phan-var-force Project $object';
1589 $projectid = $object->id;
1590 }
1591
1592 $elementid = $object->id; // id of 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';
1599 }
1600 //var_dump($societeforaction);var_dump($contactforaction);var_dump($elementid);var_dump($elementtype);exit;
1601
1602 // Insertion action
1603 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
1604 $actioncomm = new ActionComm($this->db);
1605 $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
1606 $actioncomm->code = 'AC_'.$action;
1607 $actioncomm->label = $object->actionmsg2; // Label of event
1608 $actioncomm->note_private = $object->actionmsg; // Description
1609 $actioncomm->fk_project = $projectid;
1610 $actioncomm->datep = $now;
1611 $actioncomm->datef = $now;
1612 $actioncomm->durationp = 0;
1613 $actioncomm->percentage = -1; // Not applicable
1614 $actioncomm->socid = $societeforactionid;
1615 $actioncomm->contact_id = $contactforactionid; // deprecated, now managed by setting $actioncomm->socpeopleassigned later
1616 $actioncomm->authorid = $user->id; // User saving action
1617 $actioncomm->userownerid = $user->id; // Owner of action
1618 // Fields defined when action is an email (content should be into object->actionmsg to be added into event note, subject should be into object->actionmsg2 to be added into event label)
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'; // TODO: Non of the dolibarr classes has all the fields, check class type or properties (email_date)
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;
1631 }
1632
1633 // Object linked (if link is for thirdparty, contact or project, it is a recording error. We should not have links in link table
1634 // for such objects because there is already a dedicated field into table llx_actioncomm or llx_actioncomm_resources.
1635 if (!in_array($elementtype, array('societe', 'contact', 'project'))) {
1636 $actioncomm->fk_element = $elementid;
1637 $actioncomm->elementtype = $elementtype.($elementmodule ? '@'.$elementmodule : '');
1638 }
1639
1640 // @phan-suppress-next-line PhanUndeclaredProperty
1641 if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles) > 0) {
1642 // @phan-suppress-next-line PhanUndeclaredProperty
1643 $actioncomm->attachedfiles = $object->attachedfiles;
1644 }
1645 // @phan-suppress-next-line PhanUndeclaredProperty
1646 if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid) > 0) {
1647 // @phan-suppress-next-line PhanUndeclaredProperty
1648 $actioncomm->userassigned = $object->sendtouserid;
1649 }
1650 // @phan-suppress-next-line PhanUndeclaredProperty
1651 if (property_exists($object, 'sendtoid') && is_array($object->sendtoid) && count($object->sendtoid) > 0) {
1652 // @phan-suppress-next-line PhanUndeclaredProperty
1653 foreach ($object->sendtoid as $val) {
1654 $actioncomm->socpeopleassigned[$val] = $val;
1655 }
1656 }
1657
1658 $ret = $actioncomm->create($user); // User creating action
1659
1660 if ($ret > 0 && getDolGlobalString('MAIN_COPY_FILE_IN_EVENT_AUTO')) {
1661 // @phan-suppress-next-line PhanUndeclaredProperty
1662 if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) {
1663 // Note: None of the dolibarr classes seem to have an attachedfiles property
1664 // Get directory of object
1665 $tmpelems = getElementProperties($object->element.($object->module ? '@'.$object->module : ''));
1666 $destdir = $tmpelems['dir_output'].'/'.$ret;
1667
1668 // @phan-suppress-next-line PhanUndeclaredProperty
1669 foreach ($object->attachedfiles['paths'] as $key => $filespath) {
1670 $srcfile = $filespath;
1671 // @phan-suppress-next-line PhanUndeclaredProperty
1672 $destfile = $destdir.'/'.$object->attachedfiles['names'][$key];
1673 if (dol_mkdir($destdir) >= 0) {
1674 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1675 dol_copy($srcfile, $destfile);
1676 }
1677 }
1678 }
1679 }
1680
1681 // Reset value set by caller
1682 unset($object->context['actionmsg']);
1683 unset($object->context['actionmsg2']);
1684 unset($object->actionmsg);
1685 unset($object->actionmsg2);
1686 unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action.
1687
1688 if ($ret > 0) {
1689 $_SESSION['LAST_ACTION_CREATED'] = $ret;
1690 return 1;
1691 } else {
1692 $this->error = "Failed to insert event : ".$actioncomm->error." ".implode(',', $actioncomm->errors);
1693 $this->errors = $actioncomm->errors;
1694
1695 dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
1696 return -1;
1697 }
1698 }
1699}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage agenda events (actions)
Class to manage members of a foundation.
Class to stock current configuration.
Class that all triggers must inherit.
Class of triggered functions for agenda module.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarr business event is done.
Class to manage translations.
Class to manage Dolibarr users.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_now($mode='auto')
Return date for now.
getElementProperties($elementType)
Get an array with properties of an element.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152