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

Comarch   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 20
dl 0
loc 32
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 22 3
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