Passed
Branch develop (5cbde9)
by
unknown
26:38
created

InterfaceActionsAuto::runTrigger()   F

Complexity

Conditions 198
Paths > 20000

Size

Total Lines 877
Code Lines 447

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 198
eloc 447
c 0
b 0
f 0
nc 4561922
nop 5
dl 0
loc 877
rs 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) 2005-2017	Laurent Destailleur 	<[email protected]>
3
 * Copyright (C) 2009-2017	Regis Houssin		<[email protected]>
4
 * Copyright (C) 2011-2014	Juanjo Menent		<[email protected]>
5
 * Copyright (C) 2013		Cedric GROSS			<[email protected]>
6
 * Copyright (C) 2014		Marcos García		<[email protected]>
7
 * Copyright (C) 2015		Bahfir Abbes			<[email protected]>
8
 *
9
 * This program is free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
/**
24
 *	\file       htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
25
 *  \ingroup    agenda
26
 *  \brief      Trigger file for agenda module
27
 */
28
29
require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
30
31
32
/**
33
 *  Class of triggered functions for agenda module
34
 */
35
class InterfaceActionsAuto extends DolibarrTriggers
36
{
37
	public $family = 'agenda';
38
	public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup.";
39
40
	/**
41
	 * Version of the trigger
42
	 * @var string
43
	 */
44
	public $version = self::VERSION_DOLIBARR;
45
46
	/**
47
	 * @var string Image of the trigger
48
	 */
49
	public $picto = 'action';
50
51
	/**
52
	 * Function called when a Dolibarrr business event is done.
53
	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
54
	 *
55
	 * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database:
56
	 *      $object->actiontypecode (translation action code: AC_OTH, ...)
57
	 *      $object->actionmsg (note, long text)
58
	 *      $object->actionmsg2 (label, short text)
59
	 *      $object->sendtoid (id of contact or array of ids)
60
	 *      $object->socid (id of thirdparty)
61
	 *      $object->fk_project
62
	 *      $object->fk_element
63
	 *      $object->elementtype
64
	 *
65
	 * @param string		$action		Event action code
66
	 * @param Object		$object     Object
67
	 * @param User		    $user       Object user
68
	 * @param Translate 	$langs      Object langs
69
	 * @param conf		    $conf       Object conf
70
	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
71
	 */
72
	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
73
	{
74
        if (empty($conf->agenda->enabled)) return 0;     // Module not active, we do nothing
1 ignored issue
show
Bug introduced by
The property agenda does not seem to exist on Conf.
Loading history...
75
76
		$key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
77
78
		// Do not log events not enabled for this action
79
		if (empty($conf->global->$key)) {
80
			return 0;
81
		}
82
83
		$langs->load("agenda");
84
85
		if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
86
87
		// Actions
88
		if ($action == 'COMPANY_CREATE')
89
        {
90
            // Load translation files required by the page
91
            $langs->loadLangs(array("agenda","other","companies"));
92
93
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr", $object->name);
94
            $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr", $object->name);
95
            if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
96
97
			$object->sendtoid=0;
98
			$object->socid=$object->id;
99
        }
100
        elseif ($action == 'COMPANY_SENTBYMAIL')
101
        {
102
            // Load translation files required by the page
103
            $langs->loadLangs(array("agenda","other","orders"));
104
105
            if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
106
107
            // Parameters $object->sendtoid defined by caller
108
            //$object->sendtoid=0;
109
		}
110
        elseif ($action == 'CONTRACT_VALIDATE')
111
        {
112
            // Load translation files required by the page
113
            $langs->loadLangs(array("agenda","other","contracts"));
114
115
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
116
            $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
117
118
            $object->sendtoid=0;
119
		}
120
		elseif ($action == 'CONTRACT_SENTBYMAIL')
121
		{
122
			// Load translation files required by the page
123
            $langs->loadLangs(array("agenda","other","contracts"));
124
125
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail", $object->ref);
126
			if (empty($object->actionmsg))
127
			{
128
				$object->actionmsg=$langs->transnoentities("ContractSentByEMail", $object->ref);
129
			}
130
131
			// Parameters $object->sendtoid defined by caller
132
			//$object->sendtoid=0;
133
		}
134
		elseif ($action == 'PROPAL_VALIDATE')
135
        {
136
            // Load translation files required by the page
137
            $langs->loadLangs(array("agenda","other","propal"));
138
139
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
140
            $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
141
142
			$object->sendtoid=0;
143
		}
144
        elseif ($action == 'PROPAL_SENTBYMAIL')
145
        {
146
            // Load translation files required by the page
147
            $langs->loadLangs(array("agenda","other","propal"));
148
149
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail", $object->ref);
150
            if (empty($object->actionmsg))
151
            {
152
                $object->actionmsg=$langs->transnoentities("ProposalSentByEMail", $object->ref);
153
            }
154
155
            // Parameters $object->sendtoid defined by caller
156
            //$object->sendtoid=0;
157
		}
158
		elseif ($action == 'PROPAL_CLOSE_SIGNED')
159
        {
160
            // Load translation files required by the page
161
            $langs->loadLangs(array("agenda","other","propal"));
162
163
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
164
            $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
165
166
			$object->sendtoid=0;
167
		}
168
		elseif ($action == 'PROPAL_CLASSIFY_BILLED')
169
        {
170
            // Load translation files required by the page
171
            $langs->loadLangs(array("agenda","other","propal"));
172
173
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
174
            $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
175
176
			$object->sendtoid=0;
177
		}
178
		elseif ($action == 'PROPAL_CLOSE_REFUSED')
179
        {
180
            // Load translation files required by the page
181
            $langs->loadLangs(array("agenda","other","propal"));
182
183
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
184
            $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
185
186
			$object->sendtoid=0;
187
		}
188
		elseif ($action == 'ORDER_VALIDATE')
189
        {
190
            // Load translation files required by the page
191
            $langs->loadLangs(array("agenda","orders"));
192
193
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
194
            $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
195
196
			$object->sendtoid=0;
197
		}
198
		elseif ($action == 'ORDER_CLOSE')
199
        {
200
            // Load translation files required by the page
201
            $langs->loadLangs(array("agenda","other","orders"));
202
203
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
204
            $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
205
206
			$object->sendtoid=0;
207
		}
208
		elseif ($action == 'ORDER_CLASSIFY_BILLED')
209
        {
210
            // Load translation files required by the page
211
            $langs->loadLangs(array("agenda","other","orders"));
212
213
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr", $object->ref);
214
            $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr", $object->ref);
215
216
			$object->sendtoid=0;
217
		}
218
		elseif ($action == 'ORDER_CANCEL')
219
        {
220
            // Load translation files required by the page
221
            $langs->loadLangs(array("agenda","other","orders"));
222
223
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
224
            $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
225
226
			$object->sendtoid=0;
227
		}
228
		elseif ($action == 'ORDER_SENTBYMAIL')
229
        {
230
            // Load translation files required by the page
231
            $langs->loadLangs(array("agenda","other","orders"));
232
233
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail", $object->ref);
234
            if (empty($object->actionmsg))
235
            {
236
                $object->actionmsg=$langs->transnoentities("OrderSentByEMail", $object->ref);
237
            }
238
239
            // Parameters $object->sendtoid defined by caller
240
            //$object->sendtoid=0;
241
		}
242
		elseif ($action == 'BILL_VALIDATE')
243
        {
244
            // Load translation files required by the page
245
            $langs->loadLangs(array("agenda","other","bills"));
246
247
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
248
            $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
249
250
			$object->sendtoid=0;
251
		}
252
		elseif ($action == 'BILL_UNVALIDATE')
253
        {
254
           // Load translation files required by the page
255
            $langs->loadLangs(array("agenda","other","bills"));
256
257
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
258
            $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
259
260
			$object->sendtoid=0;
261
		}
262
        elseif ($action == 'BILL_SENTBYMAIL')
263
        {
264
            // Load translation files required by the page
265
            $langs->loadLangs(array("agenda","other","bills"));
266
267
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail", $object->ref);
268
            if (empty($object->actionmsg))
269
            {
270
                $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail", $object->ref);
271
            }
272
273
            // Parameters $object->sendtoid defined by caller
274
            //$object->sendtoid=0;
275
		}
276
		elseif ($action == 'BILL_PAYED')
277
        {
278
            // Load translation files required by the page
279
            $langs->loadLangs(array("agenda","other","bills"));
280
281
            // Values for this action can't be defined by caller.
282
            $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
283
            $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
284
285
            $object->sendtoid=0;
286
		}
287
		elseif ($action == 'BILL_CANCEL')
288
        {
289
            // Load translation files required by the page
290
            $langs->loadLangs(array("agenda","other","bills"));
291
292
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
293
            $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
294
295
            $object->sendtoid=0;
296
		}
297
		elseif ($action == 'FICHINTER_CREATE')
298
        {
299
            // Load translation files required by the page
300
            $langs->loadLangs(array("agenda","other","interventions"));
301
302
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
303
            $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
304
305
            $object->sendtoid=0;
306
			$object->fk_element=0;
307
			$object->elementtype='';
308
		}
309
		elseif ($action == 'FICHINTER_VALIDATE')
310
        {
311
            // Load translation files required by the page
312
            $langs->loadLangs(array("agenda","other","interventions"));
313
314
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
315
            $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
316
317
            $object->sendtoid=0;
318
			$object->fk_element=0;
319
			$object->elementtype='';
320
		}
321
		elseif ($action == 'FICHINTER_MODIFY')
322
        {
323
            // Load translation files required by the page
324
            $langs->loadLangs(array("agenda","other","interventions"));
325
326
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
327
            $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
328
329
            $object->sendtoid=0;
330
			$object->fk_element=0;
331
			$object->elementtype='';
332
		}
333
		elseif ($action == 'FICHINTER_SENTBYMAIL')
334
        {
335
            // Load translation files required by the page
336
            $langs->loadLangs(array("agenda","other","interventions"));
337
338
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail", $object->ref);
339
            if (empty($object->actionmsg))
340
            {
341
            	$object->actionmsg=$langs->transnoentities("InterventionSentByEMail", $object->ref);
342
            }
343
344
            // Parameters $object->sendtoid defined by caller
345
            //$object->sendtoid=0;
346
        }
347
        elseif ($action == 'FICHINTER_CLASSIFY_BILLED')
348
        {
349
            // Load translation files required by the page
350
            $langs->loadLangs(array("agenda","other","interventions"));
351
352
           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
353
           	$object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
354
355
            $object->sendtoid=0;
356
        }
357
	    elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED')
358
        {
359
            // Load translation files required by the page
360
            $langs->loadLangs(array("agenda","other","interventions"));
361
362
           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
363
           	$object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
364
365
            $object->sendtoid=0;
366
        }
367
        elseif ($action == 'FICHINTER_DELETE')
368
        {
369
            // Load translation files required by the page
370
            $langs->loadLangs(array("agenda","other","interventions"));
371
372
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
373
            $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
374
375
            $object->sendtoid=0;
376
			$object->fk_element=0;
377
			$object->elementtype='';
378
		}
379
        elseif ($action == 'SHIPPING_VALIDATE')
380
        {
381
            // Load translation files required by the page
382
            $langs->loadLangs(array("agenda","other","sendings"));
383
384
        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated", ($object->newref?$object->newref:$object->ref));
385
        	if (empty($object->actionmsg))
386
        	{
387
        		$object->actionmsg=$langs->transnoentities("ShippingValidated", ($object->newref?$object->newref:$object->ref));
388
        	}
389
390
        	// Parameters $object->sendtoid defined by caller
391
        	//$object->sendtoid=0;
392
        }
393
		elseif ($action == 'SHIPPING_SENTBYMAIL')
394
        {
395
            // Load translation files required by the page
396
            $langs->loadLangs(array("agenda","other","sendings"));
397
398
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail", $object->ref);
399
            if (empty($object->actionmsg))
400
            {
401
                $object->actionmsg=$langs->transnoentities("ShippingSentByEMail", $object->ref);
402
            }
403
404
            // Parameters $object->sendtoid defined by caller
405
            //$object->sendtoid=0;
406
		} elseif ($action == 'RECEPTION_VALIDATE')
407
        {
408
            $langs->load("agenda");
409
            $langs->load("other");
410
        	$langs->load("receptions");
411
412
        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated", ($object->newref?$object->newref:$object->ref));
413
        	if (empty($object->actionmsg))
414
        	{
415
        		$object->actionmsg=$langs->transnoentities("ReceptionValidated", ($object->newref?$object->newref:$object->ref));
416
        	}
417
418
        	// Parameters $object->sendtoid defined by caller
419
        	//$object->sendtoid=0;
420
        }
421
		elseif ($action == 'RECEPTION_SENTBYMAIL')
422
        {
423
            $langs->load("agenda");
424
            $langs->load("other");
425
            $langs->load("receptions");
426
427
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail", $object->ref);
428
            if (empty($object->actionmsg))
429
            {
430
                $object->actionmsg=$langs->transnoentities("ReceptionSentByEMail", $object->ref);
431
            }
432
433
            // Parameters $object->sendtoid defined by caller
434
            //$object->sendtoid=0;
435
		}
436
		elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE')
437
		{
438
			// Load translation files required by the page
439
            $langs->loadLangs(array("agenda","other","propal"));
440
441
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
442
			$object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
443
444
			$object->sendtoid=0;
445
		}
446
		elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL')
447
		{
448
			// Load translation files required by the page
449
            $langs->loadLangs(array("agenda","other","propal"));
450
451
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail", $object->ref);
452
			if (empty($object->actionmsg))
453
			{
454
				$object->actionmsg=$langs->transnoentities("ProposalSentByEMail", $object->ref);
455
			}
456
457
			// Parameters $object->sendtoid defined by caller
458
			//$object->sendtoid=0;
459
		}
460
		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED')
461
		{
462
			// Load translation files required by the page
463
            $langs->loadLangs(array("agenda","other","propal"));
464
465
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
466
			$object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
467
468
			$object->sendtoid=0;
469
		}
470
		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED')
471
		{
472
			// Load translation files required by the page
473
            $langs->loadLangs(array("agenda","other","propal"));
474
475
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
476
			$object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
477
478
			$object->sendtoid=0;
479
		}
480
		elseif ($action == 'ORDER_SUPPLIER_CREATE')
481
        {
482
            // Load translation files required by the page
483
            $langs->loadLangs(array("agenda","other","orders"));
484
485
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr", ($object->newref?$object->newref:$object->ref));
486
            $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr", ($object->newref?$object->newref:$object->ref));
487
488
            $object->sendtoid=0;
489
		}
490
		elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
491
        {
492
            // Load translation files required by the page
493
            $langs->loadLangs(array("agenda","other","orders"));
494
495
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
496
            $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
497
498
            $object->sendtoid=0;
499
		}
500
		elseif ($action == 'ORDER_SUPPLIER_APPROVE')
501
		{
502
            // Load translation files required by the page
503
            $langs->loadLangs(array("agenda","other","orders"));
504
505
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
506
			$object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
507
508
			$object->sendtoid=0;
509
		}
510
		elseif ($action == 'ORDER_SUPPLIER_REFUSE')
511
		{
512
            // Load translation files required by the page
513
            $langs->loadLangs(array("agenda","other","orders"));
514
515
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
516
			$object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
517
518
			$object->sendtoid=0;
519
		}
520
		elseif ($action == 'ORDER_SUPPLIER_SUBMIT')
521
        {
522
            // Load translation files required by the page
523
            $langs->loadLangs(array("agenda","other","orders"));
524
525
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref?$object->newref:$object->ref));
526
            $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref?$object->newref:$object->ref));
527
528
            $object->sendtoid=0;
529
		}
530
		elseif ($action == 'ORDER_SUPPLIER_RECEIVE')
531
        {
532
            // Load translation files required by the page
533
            $langs->loadLangs(array("agenda","other","orders"));
534
535
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref?$object->newref:$object->ref));
536
            $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref?$object->newref:$object->ref));
537
538
            $object->sendtoid=0;
539
		}
540
		elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
541
        {
542
            // Load translation files required by the page
543
            $langs->loadLangs(array("agenda","other","bills","orders"));
544
545
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
546
            if (empty($object->actionmsg))
547
            {
548
                $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
549
            }
550
551
            // Parameters $object->sendtoid defined by caller
552
            //$object->sendtoid=0;
553
        }
554
		elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED')
555
        {
556
            // Load translation files required by the page
557
            $langs->loadLangs(array("agenda","other","bills","orders"));
558
559
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
560
            if (empty($object->actionmsg))
561
            {
562
                $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
563
            }
564
565
            $object->sendtoid=0;
566
        }
567
		elseif ($action == 'BILL_SUPPLIER_VALIDATE')
568
        {
569
            // Load translation files required by the page
570
            $langs->loadLangs(array("agenda","other","bills"));
571
572
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
573
            $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref?$object->newref:$object->ref));
574
575
            $object->sendtoid=0;
576
		}
577
		elseif ($action == 'BILL_SUPPLIER_UNVALIDATE')
578
        {
579
            // Load translation files required by the page
580
            $langs->loadLangs(array("agenda","other","bills"));
581
582
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
583
            $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
584
585
            $object->sendtoid=0;
586
		}
587
        elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL')
588
        {
589
            // Load translation files required by the page
590
            $langs->loadLangs(array("agenda","other","bills","orders"));
591
592
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
593
            if (empty($object->actionmsg))
594
            {
595
                $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
596
            }
597
598
            // Parameters $object->sendtoid defined by caller
599
            //$object->sendtoid=0;
600
        }
601
		elseif ($action == 'BILL_SUPPLIER_PAYED')
602
        {
603
            // Load translation files required by the page
604
            $langs->loadLangs(array("agenda","other","bills"));
605
606
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
607
            $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
608
609
			$object->sendtoid=0;
610
		}
611
		elseif ($action == 'BILL_SUPPLIER_CANCELED')
612
        {
613
            // Load translation files required by the page
614
            $langs->loadLangs(array("agenda","other","bills"));
615
616
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
617
            $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
618
619
			$object->sendtoid=0;
620
		}
621
622
        // Members
623
        elseif ($action == 'MEMBER_VALIDATE')
624
        {
625
            // Load translation files required by the page
626
            $langs->loadLangs(array("agenda","other","members"));
627
628
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
629
            $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
630
            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
631
            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
632
633
			$object->sendtoid=0;
634
        }
635
		elseif ($action == 'MEMBER_MODIFY')
636
        {
637
            // Load translation files required by the page
638
            $langs->loadLangs(array("agenda","other","members"));
639
640
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
641
            $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
642
            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
643
            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
644
645
            $object->sendtoid=0;
646
		}
647
        elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE')
648
        {
649
            // Load translation files required by the page
650
            $langs->loadLangs(array("agenda","other","members"));
651
652
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs));
653
            $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs));
654
            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
655
            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
656
            $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
657
            $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
658
659
			$object->sendtoid=0;
660
			if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
661
        }
662
        elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY')
663
        {
664
        	// Load translation files required by the page
665
            $langs->loadLangs(array("agenda","other","members"));
666
667
        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs));
668
        	$object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs));
669
        	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
670
        	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
671
        	$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
672
        	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
673
674
        	$object->sendtoid=0;
675
        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
676
        }
677
        elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE')
678
        {
679
        	// Load translation files required by the page
680
            $langs->loadLangs(array("agenda","other","members"));
681
682
        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs));
683
        	$object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs));
684
        	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
685
        	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
686
        	$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
687
        	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
688
689
        	$object->sendtoid=0;
690
        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
691
        }
692
        elseif ($action == 'MEMBER_RESILIATE')
693
        {
694
            // Load translation files required by the page
695
            $langs->loadLangs(array("agenda","other","members"));
696
697
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
698
            $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
699
            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
700
            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
701
702
			$object->sendtoid=0;
703
        }
704
        elseif ($action == 'MEMBER_DELETE')
705
        {
706
            // Load translation files required by the page
707
            $langs->loadLangs(array("agenda","other","members"));
708
709
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
710
            $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
711
            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
712
            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
713
714
			$object->sendtoid=0;
715
        }
716
717
        // Projects
718
        elseif ($action == 'PROJECT_CREATE')
719
        {
720
            // Load translation files required by the page
721
            $langs->loadLangs(array("agenda","other","projects"));
722
723
        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
724
        	$object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
725
        	$object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
726
727
        	$object->sendtoid=0;
728
        }
729
        elseif($action == 'PROJECT_VALIDATE')
730
        {
731
            // Load translation files required by the page
732
            $langs->loadLangs(array("agenda","other","projects"));
733
734
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
735
            $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
736
            $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
737
738
            $object->sendtoid=0;
739
        }
740
        elseif($action == 'PROJECT_MODIFY')
741
        {
742
            // Load translation files required by the page
743
            $langs->loadLangs(array("agenda","other","projects"));
744
745
            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
746
            $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
747
            $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
748
749
            $object->sendtoid=0;
750
        }
751
752
		// Project tasks
753
		elseif($action == 'TASK_CREATE')
754
		{
755
            // Load translation files required by the page
756
            $langs->loadLangs(array("agenda","other","projects"));
757
758
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
759
			$object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
760
			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
761
762
			$object->sendtoid=0;
763
		}
764
		elseif($action == 'TASK_MODIFY')
765
		{
766
            // Load translation files required by the page
767
            $langs->loadLangs(array("agenda","other","projects"));
768
769
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr", $object->ref);
770
			$object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr", $object->ref);
771
			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
772
773
			$object->sendtoid=0;
774
		}
775
		elseif($action == 'TASK_DELETE')
776
		{
777
            // Load translation files required by the page
778
            $langs->loadLangs(array("agenda","other","projects"));
779
780
			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
781
			$object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
782
			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
783
784
			$object->sendtoid=0;
785
		}
786
		elseif($action == 'TICKET_ASSIGNED')
787
		{
788
		    // Load translation files required by the page
789
		    $langs->loadLangs(array("agenda","other","projects"));
790
791
		    if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
792
		    $object->actionmsg=$langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
793
		    if ($object->oldcopy->fk_user_assign > 0)
794
		    {
795
		      $tmpuser=new User($this->db);
796
		      $tmpuser->fetch($object->oldcopy->fk_user_assign);
797
		      $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs);
798
		    }
799
		    else
800
		    {
801
		        $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$langs->trans("None");
802
		    }
803
		    if ($object->fk_user_assign > 0)
804
		    {
805
		        $tmpuser=new User($this->db);
806
		        $tmpuser->fetch($object->fk_user_assign);
807
		        $object->actionmsg.="\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs);
808
		    }
809
		    else
810
		    {
811
		        $object->actionmsg.="\n".$langs->transnoentities("NewUser").': '.$langs->trans("None");
812
		    }
813
		    $object->sendtoid=0;
814
		}
815
		// TODO Merge all previous cases into this generic one
816
		else	// $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ...
817
		{
818
		    // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). Key can be set in agenda setup if defined into c_action_trigger
819
		    // Load translation files required by the page
820
            $langs->loadLangs(array("agenda","other"));
821
822
		    if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr", $object->ref);
823
		    if (empty($object->actionmsg))  $object->actionmsg=$langs->transnoentities($action."InDolibarr", $object->ref);
824
825
		    $object->sendtoid=0;
826
		}
827
828
		$object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
829
830
		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
831
832
        // Add entry in event table
833
		$now=dol_now();
834
835
		if (isset($_SESSION['listofnames-'.$object->trackid]))
836
		{
837
			$attachs=$_SESSION['listofnames-'.$object->trackid];
838
			if ($attachs && strpos($action, 'SENTBYMAIL'))
839
			{
840
                $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
841
			}
842
		}
843
844
        require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
845
        require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
846
		$contactforaction=new Contact($this->db);
847
        $societeforaction=new Societe($this->db);
848
        // Set contactforaction if there is only 1 contact.
849
        if (is_array($object->sendtoid))
850
        {
851
            if (count($object->sendtoid) == 1) $contactforaction->fetch(reset($object->sendtoid));
852
        }
853
        else
854
        {
855
            if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid);
856
        }
857
        // Set societeforaction.
858
        if ($object->socid > 0)			$societeforaction->fetch($object->socid);
859
        elseif ($object->fk_soc > 0)	$societeforaction->fetch($object->fk_soc);
860
861
        $projectid = isset($object->fk_project)?$object->fk_project:0;
862
        if ($object->element == 'project') $projectid = $object->id;
863
864
        $elementid = $object->id;
865
        $elementtype = $object->element;
866
        if ($object->element == 'subscription')
867
        {
868
        	$elementid = $object->fk_adherent;
869
        	$elementtype = 'member';
870
        }
871
        //var_dump($societeforaction);var_dump($contactforaction);exit;
872
873
		// Insertion action
874
		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
875
		$actioncomm = new ActionComm($this->db);
876
		$actioncomm->type_code   = $object->actiontypecode;		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
877
		$actioncomm->code        = 'AC_'.$action;
878
		$actioncomm->label       = $object->actionmsg2;
879
		$actioncomm->note        = $object->actionmsg;          // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg)
1 ignored issue
show
Deprecated Code introduced by
The property CommonObject::$note has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

879
		/** @scrutinizer ignore-deprecated */ $actioncomm->note        = $object->actionmsg;          // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg)
Loading history...
880
		$actioncomm->fk_project  = $projectid;
881
		$actioncomm->datep       = $now;
882
		$actioncomm->datef       = $now;
883
		$actioncomm->durationp   = 0;
1 ignored issue
show
Deprecated Code introduced by
The property ActionComm::$durationp has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

883
		/** @scrutinizer ignore-deprecated */ $actioncomm->durationp   = 0;
Loading history...
884
		$actioncomm->punctual    = 1;
1 ignored issue
show
Deprecated Code introduced by
The property ActionComm::$punctual has been deprecated: Milestone is already event with end date = start date ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

884
		/** @scrutinizer ignore-deprecated */ $actioncomm->punctual    = 1;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
885
		$actioncomm->percentage  = -1;   // Not applicable
886
		$actioncomm->societe     = $societeforaction;
1 ignored issue
show
Deprecated Code introduced by
The property ActionComm::$societe has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

886
		/** @scrutinizer ignore-deprecated */ $actioncomm->societe     = $societeforaction;
Loading history...
887
		$actioncomm->contact     = $contactforaction;
1 ignored issue
show
Deprecated Code introduced by
The property ActionComm::$contact has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

887
		/** @scrutinizer ignore-deprecated */ $actioncomm->contact     = $contactforaction;
Loading history...
888
		$actioncomm->socid       = $societeforaction->id;
889
		$actioncomm->contactid   = $contactforaction->id;
890
		$actioncomm->authorid    = $user->id;   // User saving action
891
		$actioncomm->userownerid = $user->id;	// Owner of action
892
        // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label)
893
		$actioncomm->email_msgid   = $object->email_msgid;
894
		$actioncomm->email_from    = $object->email_from;
895
		$actioncomm->email_sender  = $object->email_sender;
896
		$actioncomm->email_to      = $object->email_to;
897
		$actioncomm->email_tocc    = $object->email_tocc;
898
		$actioncomm->email_tobcc   = $object->email_tobcc;
899
		$actioncomm->email_subject = $object->email_subject;
900
		$actioncomm->errors_to     = $object->errors_to;
901
902
		// Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
903
		// for such objects because there is already a dedicated field into table llx_actioncomm.
904
		if (! in_array($elementtype, array('societe','contact','project')))
905
		{
906
			$actioncomm->fk_element  = $elementid;
907
			$actioncomm->elementtype = $elementtype;
908
		}
909
910
		if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
911
			$actioncomm->attachedfiles=$object->attachedfiles;
0 ignored issues
show
Bug introduced by
The property attachedfiles does not seem to exist on ActionComm.
Loading history...
912
		}
913
		if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) {
914
			$actioncomm->userassigned=$object->sendtouserid;
915
		}
916
917
		$ret=$actioncomm->create($user);       // User creating action
918
919
		if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO)
920
		{
921
			if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths'])>0) {
922
				foreach($object->attachedfiles['paths'] as $key=>$filespath) {
923
					$srcfile = $filespath;
924
					$destdir = $conf->agenda->dir_output . '/' . $ret;
925
					$destfile = $destdir . '/' . $object->attachedfiles['names'][$key];
926
					if (dol_mkdir($destdir) >= 0) {
927
						require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
928
						dol_copy($srcfile, $destfile);
929
					}
930
				}
931
			}
932
		}
933
934
		unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode);	// When several action are called on same object, we must be sure to not reuse value of first action.
935
936
		if ($ret > 0)
937
		{
938
			$_SESSION['LAST_ACTION_CREATED'] = $ret;
939
			return 1;
940
		}
941
		else
942
		{
943
            $error ="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors);
944
            $this->error=$error;
1 ignored issue
show
Deprecated Code introduced by
The property DolibarrTriggers::$error has been deprecated: Use $this->errors ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

944
            /** @scrutinizer ignore-deprecated */ $this->error=$error;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
945
            $this->errors=$actioncomm->errors;
946
947
            dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
1 ignored issue
show
Deprecated Code introduced by
The property DolibarrTriggers::$error has been deprecated: Use $this->errors ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

947
            dol_syslog("interface_modAgenda_ActionsAuto.class.php: "./** @scrutinizer ignore-deprecated */ $this->error, LOG_ERR);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
948
            return -1;
949
		}
950
    }
951
}
952