Passed
Pull Request — developer (#17179)
by Mariusz
29:27 queued 10:21
created

Comarch::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 22
rs 9.6666
c 1
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
/**
4
 * Check errors while sending the message file.
5
 *
6
 * @package App
7
 *
8
 * @copyright YetiForce S.A.
9
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
10
 * @author    Mariusz Krzaczkowski <[email protected]>
11
 */
12
13
namespace App\SystemWarnings\Integrations;
14
15
/**
16
 * Check for errors while sending the message class.
17
 */
18
class Comarch extends \App\SystemWarnings\Template
19
{
20
	/** {@inheritdoc} */
21
	protected $title = 'LBL_CHECK_COMARCH_INTEGRATION_LOG';
22
23
	/**
24
	 * Checks for suspended email accounts.
25
	 *
26
	 * @return void
27
	 */
28
	public function process(): void
29
	{
30
		$data = (new \App\Db\Query())->select(['time', 'message'])->from(\App\Integrations\Comarch::LOG_TABLE_NAME)
31
			->where([
32
				'and',
33
				['error' => 1],
34
				['>=', 'time', date('Y-m-d H:i:s', strtotime('-24 hours'))]
35
			])->orderBy(['id' => SORT_DESC])
36
			->all(\App\DB::getInstance('log'));
37
		if ($data) {
38
			$this->status = 0;
39
			$this->description = \App\Language::translate('LBL_CHECK_COMARCH_INTEGRATION_LOG_DESC', 'Settings:SystemWarnings');
40
			$this->description .= '<br>' . \App\TextUtils::getHtmlTable($data, [
41
				'time' => \App\Language::translate('LBL_TIME', 'Settings:Log'),
42
				'message' => \App\Language::translate('LBL_MESSAGE', 'Settings:Comarch')
43
			]);
44
			if (\App\Security\AdminAccess::isPermitted('Log')) {
45
				$this->link = 'index.php?parent=Settings&module=Log&view=LogsViewer&type=mail';
46
				$this->linkTitle = \App\Language::translate('LBL_LOGS_VIEWER', 'Settings:Log');
47
			}
48
		} else {
49
			$this->status = 1;
50
		}
51
	}
52
}
53