LocaleoScript.php 24.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

/**
 * Copyright Maarch since 2008 under licence GPLv3.
 * See LICENCE.txt file at the root folder for more details.
 * This file is part of Maarch software.
 *
 */

/**
 * @brief Localeo Script
 * @author dev@maarch.org
 */

chdir('../../..');

require 'vendor/autoload.php';

LocaleoScript::sendContact($argv);
LocaleoScript::updateContact($argv);
21
22
23
LocaleoScript::sendResource($argv);
LocaleoScript::sendAttachment($argv);
LocaleoScript::closeResource($argv);
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

class LocaleoScript
{
    const MAPPING_CONTACT = [
        'civility'          => 'civility',
        'company'           => 'company',
        'firstname'         => 'firstname',
        'familyName'        => 'lastname',
        'email'             => 'email',
        'phone'             => 'phone',
        'num'               => 'address_number',
        'street'            => 'address_street',
        'ZC'                => 'address_postcode',
        'additionalAddress' => 'address_additional1',
        'city'              => 'address_town',
        'country'           => 'address_country',
        'externalId'        => 'id'
    ];

    public static function sendContact(array $args)
    {
        $customId = null;
        if (!empty($args[1]) && $args[1] == '--customId' && !empty($args[2])) {
            $customId = $args[2];
        }

        $configuration = LocaleoScript::getXmlLoaded(['path' => 'bin/external/localeo/config.xml', 'customId' => $customId]);
        if (empty($configuration)) {
52
            self::writeLog(['message' => "[ERROR] [SEND_CONTACT] File bin/external/localeo/config.xml does not exist"]);
53
54
            exit();
        } elseif (empty($configuration->apiKey) || empty($configuration->appName) || empty($configuration->sendContact)) {
55
            self::writeLog(['message' => "[ERROR] [SEND_CONTACT] File bin/external/localeo/config.xml is not filled enough"]);
56
57
58
59
60
61
62
63
64
65
            return;
        }
        if ((string)$configuration->sendContact->enabled == 'false') {
            return;
        }

        $apiKey = (string)$configuration->apiKey;
        $appName = (string)$configuration->appName;
        $url = (string)$configuration->sendContact->url;
        if (empty($url)) {
66
            self::writeLog(['message' => "[ERROR] [SEND_CONTACT] File bin/external/localeo/config.xml url is empty"]);
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
            return;
        }

        $dataToMerge = [];
        if (!empty($configuration->sendContact->data)) {
            foreach ($configuration->sendContact->data as $value) {
                $dataToMerge[(string)$value->key] = (string)$value->value;
            }
        }

        \SrcCore\models\DatabasePDO::reset();
        new \SrcCore\models\DatabasePDO(['customId' => $customId]);

        $contacts = \Contact\models\ContactModel::get([
            'select'    => ['*'],
            'where'     => ['enabled = ?', "external_id->>'localeoId' is null"],
            'data'      => [true]
        ]);

        foreach ($contacts as $contact) {
            $body = [];
            foreach (self::MAPPING_CONTACT as $key => $value) {
                $body[$key] = $contact[$value] ?? '';
            }
            $body = array_merge($body, $dataToMerge);

93
            $response = \SrcCore\models\CurlModel::exec([
94
95
96
97
98
99
100
101
                'url'       => $url,
                'method'    => 'NO-METHOD',
                'headers'   => ["Api-Key: {$apiKey}", "appName: {$appName}"],
                'body'      => ['citoyen' => json_encode($body)],
                'noLogs'    => true
            ]);

            if (!empty($response['errors'])) {
102
                self::writeLog(['message' => "[ERROR] [SEND_CONTACT] Contact {$contact['id']} : curl call failed"]);
103
104
105
                self::writeLog(['message' => $response['errors']]);
                continue;
            } elseif (empty($response['response']['id'])) {
106
                self::writeLog(['message' => "[ERROR] [SEND_CONTACT] Contact {$contact['id']} : id is missing"]);
107
108
109
110
111
112
113
114
                self::writeLog(['message' => json_encode($response['response'])]);
                continue;
            }

            $externalId = json_decode($contact['external_id'], true);
            $externalId['localeoId'] = $response['response']['id'];
            \Contact\models\ContactModel::update(['set' => ['external_id' => json_encode($externalId)], 'where' => ['id = ?'], 'data' => [$contact['id']]]);

115
            self::writeLog(['message' => "[SUCCESS] [SEND_CONTACT] Contact {$contact['id']} : successfully sent to localeo"]);
116
117
118
119
120
121
122
123
124
125
126
127
        }
    }

    public static function updateContact(array $args)
    {
        $customId = null;
        if (!empty($args[1]) && $args[1] == '--customId' && !empty($args[2])) {
            $customId = $args[2];
        }

        $configuration = LocaleoScript::getXmlLoaded(['path' => 'bin/external/localeo/config.xml', 'customId' => $customId]);
        if (empty($configuration)) {
128
            self::writeLog(['message' => "[ERROR] [UPDATE_CONTACT] File bin/external/localeo/config.xml does not exist"]);
129
130
            exit();
        } elseif (empty($configuration->apiKey) || empty($configuration->appName) || empty($configuration->updateContact)) {
131
            self::writeLog(['message' => "[ERROR] [UPDATE_CONTACT] File bin/external/localeo/config.xml is not filled enough"]);
132
133
134
135
136
137
138
139
140
141
            return;
        }
        if ((string)$configuration->updateContact->enabled == 'false') {
            return;
        }

        $apiKey = (string)$configuration->apiKey;
        $appName = (string)$configuration->appName;
        $url = (string)$configuration->updateContact->url;
        if (empty($url)) {
142
            self::writeLog(['message' => "[ERROR] [UPDATE_CONTACT] File bin/external/localeo/config.xml url is empty"]);
143
144
145
            return;
        }

146
147
148
149
150
151
152
        if (!file_exists('bin/external/localeo/updateContact.timestamp')) {
            $file = fopen('bin/external/localeo/updateContact.timestamp', 'w');
            fwrite($file, time());
            fclose($file);
            return;
        }

153
154
155
156
157
158
159
160
161
162
        $dataToMerge = [];
        if (!empty($configuration->updateContact->data)) {
            foreach ($configuration->updateContact->data as $value) {
                $dataToMerge[(string)$value->key] = (string)$value->value;
            }
        }

        \SrcCore\models\DatabasePDO::reset();
        new \SrcCore\models\DatabasePDO(['customId' => $customId]);

163
        $time = file_get_contents('bin/external/localeo/updateContact.timestamp');
164
165
166

        $contacts = \Contact\models\ContactModel::get([
            'select'    => ['*'],
167
168
            'where'     => ['enabled = ?', "external_id->>'localeoId' is not null", 'modification_date > ?'],
            'data'      => [true, date('Y-m-d H:i:s', $time)]
169
170
        ]);

171
172
173
174
        $file = fopen('bin/external/localeo/updateContact.timestamp', 'w');
        fwrite($file, time());
        fclose($file);

175
176
177
178
179
180
181
182
183
184
        foreach ($contacts as $contact) {
            $externalId = json_decode($contact['external_id'], true);

            $body = [];
            foreach (self::MAPPING_CONTACT as $key => $value) {
                $body[$key] = $contact[$value] ?? '';
            }
            $body['id'] = $externalId['localeoId'];
            $body = array_merge($body, $dataToMerge);

185
            $response = \SrcCore\models\CurlModel::exec([
186
187
188
189
190
191
192
193
                'url'       => $url,
                'method'    => 'NO-METHOD',
                'headers'   => ["Api-Key: {$apiKey}", "appName: {$appName}"],
                'body'      => ['citoyen' => json_encode($body)],
                'noLogs'    => true
            ]);

            if (!empty($response['errors'])) {
194
                self::writeLog(['message' => "[ERROR] [UPDATE_CONTACT] Contact {$contact['id']} : curl call failed"]);
195
196
197
                self::writeLog(['message' => $response['errors']]);
                continue;
            } elseif (empty($response['response']['id'])) {
198
                self::writeLog(['message' => "[ERROR] [UPDATE_CONTACT] Contact {$contact['id']} : id is missing"]);
199
200
201
202
                self::writeLog(['message' => json_encode($response['response'])]);
                continue;
            }

203
            self::writeLog(['message' => "[SUCCESS] [UPDATE_CONTACT] Contact {$contact['id']} : successfully sent to localeo"]);
204
205
206
        }
    }

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
    public static function sendResource(array $args)
    {
        $customId = null;
        if (!empty($args[1]) && $args[1] == '--customId' && !empty($args[2])) {
            $customId = $args[2];
        }

        $configuration = LocaleoScript::getXmlLoaded(['path' => 'bin/external/localeo/config.xml', 'customId' => $customId]);
        if (empty($configuration)) {
            self::writeLog(['message' => "[ERROR] [SEND_RESOURCE] File bin/external/localeo/config.xml does not exist"]);
            exit();
        } elseif (empty($configuration->apiKey) || empty($configuration->appName) || empty($configuration->sendResource)) {
            self::writeLog(['message' => "[ERROR] [SEND_RESOURCE] File bin/external/localeo/config.xml is not filled enough"]);
            return;
        }
        if ((string)$configuration->sendResource->enabled == 'false') {
            return;
        }

        $apiKey = (string)$configuration->apiKey;
        $appName = (string)$configuration->appName;
        $url = (string)$configuration->sendResource->url;
        if (empty($url)) {
            self::writeLog(['message' => "[ERROR] [SEND_RESOURCE] File bin/external/localeo/config.xml url is empty"]);
            return;
        }

        $dataToMerge = [];
        if (!empty($configuration->sendResource->data)) {
            foreach ($configuration->sendResource->data as $value) {
                $dataToMerge[(string)$value->key] = (string)$value->value;
            }
        }

        \SrcCore\models\DatabasePDO::reset();
        new \SrcCore\models\DatabasePDO(['customId' => $customId]);

        $resources = \Resource\models\ResModel::get([
            'select'    => ['res_id', 'subject', 'format', 'path', 'filename', 'docserver_id', 'external_id'],
            'where'     => ["external_id->>'localeoId' is null", 'category_id = ?'],
            'data'      => ['incoming']
        ]);

        foreach ($resources as $resource) {
            $contact = \Resource\models\ResourceContactModel::get([
                'select'    => ['item_id'],
                'where'     => ['res_id = ?', 'type = ?', 'mode = ?'],
                'data'      => [$resource['res_id'], 'contact', 'sender'],
                'limit'     => 1
            ]);
            if (empty($contact[0])) {
                self::writeLog(['message' => "[INFO] [SEND_RESOURCE] Resource {$resource['res_id']} : Has no sender"]);
                continue;
            }
            $contact = \Contact\models\ContactModel::getById(['id' => $contact[0]['item_id'], 'select' => ['external_id', 'id']]);
            $contactExternalId = json_decode($contact['external_id'], true);
            if (empty($contactExternalId['localeoId'])) {
                self::writeLog(['message' => "[WARNING] [SEND_RESOURCE] Resource {$resource['res_id']} : Sender is not linked to localeo"]);
                continue;
            }

            $body = [];

            if (!empty($resource['filename'])) {
                $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $resource['docserver_id'], 'select' => ['path_template']]);
                $path = $docserver['path_template'] . str_replace('#', '/', $resource['path']) . $resource['filename'];
                if (!is_file($path)) {
                    self::writeLog(['message' => "[ERROR] [SEND_RESOURCE] Resource {$resource['res_id']} : File is missing"]);
                    continue;
                }

                $body['filename'] = \SrcCore\models\CurlModel::makeCurlFile(['path' => $path]);
            }

            $requete = [
                'subject'       => $resource['subject'],
                'externalId'    => $resource['res_id']
            ];
            $requete = array_merge($requete, $dataToMerge);

            $citoyen = ['id' => $contactExternalId['localeoId'], 'externalId' => $contact['id']];

            $body['requete'] = json_encode($requete);
            $body['citoyen'] = json_encode($citoyen);

292
            $response = \SrcCore\models\CurlModel::exec([
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
                'url'       => $url,
                'method'    => 'NO-METHOD',
                'headers'   => ["Api-Key: {$apiKey}", "appName: {$appName}"],
                'body'      => $body,
                'noLogs'    => true
            ]);

            if (!empty($response['errors'])) {
                self::writeLog(['message' => "[ERROR] [SEND_RESOURCE] Resource {$resource['res_id']} : curl call failed"]);
                self::writeLog(['message' => $response['errors']]);
                continue;
            } elseif (empty($response['response']['id'])) {
                self::writeLog(['message' => "[ERROR] [SEND_RESOURCE] Resource {$resource['res_id']} : id is missing"]);
                self::writeLog(['message' => json_encode($response['response'])]);
                continue;
            }

            $externalId = json_decode($resource['external_id'], true);
            $externalId['localeoId'] = $response['response']['id'];
            \Resource\models\ResModel::update(['set' => ['external_id' => json_encode($externalId)], 'where' => ['res_id = ?'], 'data' => [$resource['res_id']]]);

            self::writeLog(['message' => "[SUCCESS] [SEND_RESOURCE] Resource {$resource['res_id']} : successfully sent to localeo"]);
        }
    }

    public static function sendAttachment(array $args)
    {
        $customId = null;
        if (!empty($args[1]) && $args[1] == '--customId' && !empty($args[2])) {
            $customId = $args[2];
        }

        $configuration = LocaleoScript::getXmlLoaded(['path' => 'bin/external/localeo/config.xml', 'customId' => $customId]);
        if (empty($configuration)) {
            self::writeLog(['message' => "[ERROR] [SEND_ATTACHMENT] File bin/external/localeo/config.xml does not exist"]);
            exit();
        } elseif (empty($configuration->apiKey) || empty($configuration->appName) || empty($configuration->sendAttachment)) {
            self::writeLog(['message' => "[ERROR] [SEND_ATTACHMENT] File bin/external/localeo/config.xml is not filled enough"]);
            return;
        }
        if ((string)$configuration->sendAttachment->enabled == 'false') {
            return;
        }

        $apiKey = (string)$configuration->apiKey;
        $appName = (string)$configuration->appName;
        $url = (string)$configuration->sendAttachment->url;
        if (empty($url)) {
            self::writeLog(['message' => "[ERROR] [SEND_ATTACHMENT] File bin/external/localeo/config.xml url is empty"]);
            return;
        }

        $dataToMerge = [];
        if (!empty($configuration->sendAttachment->data)) {
            foreach ($configuration->sendAttachment->data as $value) {
                $dataToMerge[(string)$value->key] = (string)$value->value;
            }
        }

        \SrcCore\models\DatabasePDO::reset();
        new \SrcCore\models\DatabasePDO(['customId' => $customId]);

        $attachments = \SrcCore\models\DatabaseModel::select([
            'select'    => [
                'res_attachments.res_id', 'res_attachments.res_id_master', 'res_attachments.title', 'res_attachments.format', 'res_attachments.path', 'res_attachments.filename',
                'res_attachments.docserver_id', 'res_attachments.external_id', "res_letterbox.external_id->>'localeoId' as \"localeoId\""
            ],
            'table'     => ['res_attachments, res_letterbox'],
            'where'     => [
                'res_attachments.res_id_master = res_letterbox.res_id', "res_letterbox.external_id->>'localeoId' is not null",
                "res_attachments.external_id->>'localeoId' is null", 'res_attachments.status not in (?)'
            ],
365
            'data'      => [['DEL', 'OBS']]
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
        ]);

        foreach ($attachments as $attachment) {
            $contact = \Resource\models\ResourceContactModel::get([
                'select'    => ['item_id'],
                'where'     => ['res_id = ?', 'type = ?', 'mode = ?'],
                'data'      => [$attachment['res_id_master'], 'contact', 'sender'],
                'limit'     => 1
            ]);
            if (empty($contact[0])) {
                self::writeLog(['message' => "[INFO] [SEND_ATTACHMENT] Resource {$attachment['res_id_master']} : Has no sender"]);
                continue;
            }
            $contact = \Contact\models\ContactModel::getById(['id' => $contact[0]['item_id'], 'select' => ['external_id', 'id']]);
            $contactExternalId = json_decode($contact['external_id'], true);
            if (empty($contactExternalId['localeoId'])) {
                self::writeLog(['message' => "[WARNING] [SEND_ATTACHMENT] Resource {$attachment['res_id_master']} : Sender is not linked to localeo"]);
                continue;
            }

            $body = [];

            $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $attachment['docserver_id'], 'select' => ['path_template']]);
            $path = $docserver['path_template'] . str_replace('#', '/', $attachment['path']) . $attachment['filename'];
            if (!is_file($path)) {
                self::writeLog(['message' => "[ERROR] [SEND_ATTACHMENT] Attachment {$attachment['res_id']} : File is missing"]);
                continue;
            }
            $body['filename'] = \SrcCore\models\CurlModel::makeCurlFile(['path' => $path]);

            $requete = [
                'subject'       => $attachment['title'],
                'externalId'    => $attachment['res_id'],
                'parentQueryId' => $attachment['localeoId'],
            ];
            $requete = array_merge($requete, $dataToMerge);

            $citoyen = ['id' => $contactExternalId['localeoId'], 'externalId' => $contact['id']];

            $body['requete'] = json_encode($requete);
            $body['citoyen'] = json_encode($citoyen);

408
            $response = \SrcCore\models\CurlModel::exec([
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
                'url'       => $url,
                'method'    => 'NO-METHOD',
                'headers'   => ["Api-Key: {$apiKey}", "appName: {$appName}"],
                'body'      => $body,
                'noLogs'    => true
            ]);

            if (!empty($response['errors'])) {
                self::writeLog(['message' => "[ERROR] [SEND_ATTACHMENT] Attachment {$attachment['res_id']} : curl call failed"]);
                self::writeLog(['message' => $response['errors']]);
                continue;
            } elseif (empty($response['response']['id'])) {
                self::writeLog(['message' => "[ERROR] [SEND_ATTACHMENT] Attachment {$attachment['res_id']} : id is missing"]);
                self::writeLog(['message' => json_encode($response['response'])]);
                continue;
            }

            $externalId = json_decode($attachment['external_id'], true);
            $externalId['localeoId'] = $response['response']['id'];
            \Attachment\models\AttachmentModel::update(['set' => ['external_id' => json_encode($externalId)], 'where' => ['res_id = ?'], 'data' => [$attachment['res_id']]]);

            self::writeLog(['message' => "[SUCCESS] [SEND_ATTACHMENT] Attachment {$attachment['res_id']} : successfully sent to localeo"]);
        }
    }

    public static function closeResource(array $args)
    {
        $customId = null;
        if (!empty($args[1]) && $args[1] == '--customId' && !empty($args[2])) {
            $customId = $args[2];
        }

        $configuration = LocaleoScript::getXmlLoaded(['path' => 'bin/external/localeo/config.xml', 'customId' => $customId]);
        if (empty($configuration)) {
            self::writeLog(['message' => "[ERROR] [CLOSE_RESOURCE] File bin/external/localeo/config.xml does not exist"]);
            exit();
        } elseif (empty($configuration->apiKey) || empty($configuration->appName) || empty($configuration->closeResource)) {
            self::writeLog(['message' => "[ERROR] [CLOSE_RESOURCE] File bin/external/localeo/config.xml is not filled enough"]);
            return;
        }
        if ((string)$configuration->closeResource->enabled == 'false') {
            return;
        }

        $apiKey = (string)$configuration->apiKey;
        $appName = (string)$configuration->appName;
        $url = (string)$configuration->closeResource->url;
        $status = (string)$configuration->closeResource->status;
        if (empty($url) || empty($status)) {
            self::writeLog(['message' => "[ERROR] [CLOSE_RESOURCE] File bin/external/localeo/config.xml url or status is empty"]);
            return;
        }

462
463
464
465
466
467
468
        if (!file_exists('bin/external/localeo/closeResource.timestamp')) {
            $file = fopen('bin/external/localeo/closeResource.timestamp', 'w');
            fwrite($file, time());
            fclose($file);
            return;
        }

469
470
471
472
473
474
475
476
477
478
        $dataToMerge = [];
        if (!empty($configuration->closeResource->data)) {
            foreach ($configuration->closeResource->data as $value) {
                $dataToMerge[(string)$value->key] = (string)$value->value;
            }
        }

        \SrcCore\models\DatabasePDO::reset();
        new \SrcCore\models\DatabasePDO(['customId' => $customId]);

479
        $time = file_get_contents('bin/external/localeo/closeResource.timestamp');
480
481

        $resources = \Resource\models\ResModel::get([
482
            'select'    => ['res_id', "external_id->>'localeoId' as \"localeoId\""],
483
484
            'where'     => ["external_id->>'localeoId' is not null", 'status = ?', 'closing_date is not null', 'closing_date > ?'],
            'data'      => [$status, date('Y-m-d H:i:s', $time)]
485
486
        ]);

487
488
489
490
        $file = fopen('bin/external/localeo/closeResource.timestamp', 'w');
        fwrite($file, time());
        fclose($file);

491
492
493
494
495
496
497
498
499
500
        foreach ($resources as $resource) {
            $body = [];

            $requete = [
                'id'    => $resource['localeoId']
            ];
            $requete = array_merge($requete, $dataToMerge);

            $body['requete'] = json_encode($requete);

501
            $response = \SrcCore\models\CurlModel::exec([
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
                'url'       => $url,
                'method'    => 'NO-METHOD',
                'headers'   => ["Api-Key: {$apiKey}", "appName: {$appName}"],
                'body'      => $body,
                'noLogs'    => true
            ]);

            if (!empty($response['errors'])) {
                self::writeLog(['message' => "[ERROR] [CLOSE_RESOURCE] Resource {$resource['res_id']} : curl call failed"]);
                self::writeLog(['message' => $response['errors']]);
                continue;
            } elseif (empty($response['response']['requete']['id']) || empty($response['response']['statut']['id'])) {
                self::writeLog(['message' => "[ERROR] [CLOSE_RESOURCE] Resource {$resource['res_id']} : bad response"]);
                self::writeLog(['message' => json_encode($response['response'])]);
                continue;
            }

            self::writeLog(['message' => "[SUCCESS] [CLOSE_RESOURCE] Resource {$resource['res_id']} : successfully closed in localeo"]);
        }
    }
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544

    public static function getXmlLoaded(array $args)
    {
        if (!empty($args['customId']) && file_exists("custom/{$args['customId']}/{$args['path']}")) {
            $path = "custom/{$args['customId']}/{$args['path']}";
        }
        if (empty($path)) {
            $path = $args['path'];
        }

        $xmlfile = null;
        if (file_exists($path)) {
            $xmlfile = simplexml_load_file($path);
        }

        return $xmlfile;
    }

    public static function writeLog(array $args)
    {
        $file = fopen('bin/external/localeo/localeoScript.log', 'a');
        fwrite($file, '[' . date('Y-m-d H:i:s') . '] ' . $args['message'] . PHP_EOL);
        fclose($file);
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568

        if (strpos($args['message'], '[ERROR]') === 0) {
            \SrcCore\controllers\LogsController::add([
                'isTech'    => true,
                'moduleId'  => 'localeo',
                'level'     => 'ERROR',
                'tableName' => '',
                'recordId'  => 'Localeo',
                'eventType' => 'Localeo',
                'eventId'   => $args['message']
            ]);
        } else {
            \SrcCore\controllers\LogsController::add([
                'isTech'    => true,
                'moduleId'  => 'localeo',
                'level'     => 'INFO',
                'tableName' => '',
                'recordId'  => 'Localeo',
                'eventType' => 'Localeo',
                'eventId'   => $args['message']
            ]);
        }

        \History\models\BatchHistoryModel::create(['info' => $args['message'], 'module_name' => 'localeo']);
569
570
    }
}