Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
SendProcessListToScopeAdmin | n/a |
0 / 0 |
n/a |
0 / 0 |
12 | n/a |
0 / 0 |
|||
__construct | n/a |
0 / 0 |
n/a |
0 / 0 |
3 | |||||
startProcessing | n/a |
0 / 0 |
n/a |
0 / 0 |
7 | |||||
sendListToQueue | n/a |
0 / 0 |
n/a |
0 / 0 |
2 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Helper; |
4 | |
5 | /** |
6 | * @codeCoverageIgnore |
7 | */ |
8 | class SendProcessListToScopeAdmin |
9 | { |
10 | protected $scopeList; |
11 | |
12 | protected $datetime; |
13 | |
14 | protected $verbose = false; |
15 | |
16 | public function __construct($verbose = false, $scopeId = false) |
17 | { |
18 | $this->dateTime = new \DateTimeImmutable(); |
19 | if ($verbose) { |
20 | error_log("INFO: Send process list of current day to scope admin"); |
21 | $this->verbose = true; |
22 | } |
23 | if ($scopeId) { |
24 | $scope = (new \BO\Zmsdb\Scope())->readEntity($scopeId); |
25 | $this->scopeList = (new \BO\Zmsentities\Collection\ScopeList())->addEntity($scope); |
26 | } else { |
27 | $this->scopeList = (new \BO\Zmsdb\Scope())->readListWithScopeAdminEmail(1); |
28 | } |
29 | } |
30 | |
31 | public function startProcessing($commit) |
32 | { |
33 | foreach ($this->scopeList as $scope) { |
34 | if ($this->verbose) { |
35 | error_log("INFO: Processing $scope"); |
36 | } |
37 | if ($commit) { |
38 | $processList = (new \BO\Zmsdb\Process()) |
39 | ->readProcessListByScopeAndTime($scope->getId(), $this->dateTime, 1); |
40 | $processList = $processList |
41 | ->toQueueList($this->dateTime) |
42 | ->withStatus(array('confirmed', 'queued', 'reserved')) |
43 | ->withSortedArrival() |
44 | ->toProcessList(); |
45 | if (0 <= $processList->count()) { |
46 | if ($this->sendListToQueue($scope, $processList) && $this->verbose) { |
47 | error_log('INFO: Send processList to:' . $scope->getContactEmail()); |
48 | } |
49 | } else { |
50 | error_log("WARNING: Processlist empty for $scope->id"); |
51 | } |
52 | } |
53 | } |
54 | } |
55 | |
56 | protected function sendListToQueue($scope, $processList) |
57 | { |
58 | $entity = (new \BO\Zmsentities\Mail())->toScopeAdminProcessList($processList, $scope, $this->dateTime); |
59 | if (! (new \BO\Zmsdb\Mail())->writeInQueueWithDailyProcessList($scope, $entity)) { |
60 | error_log("WARNING: Mail writing in queue not successfull empty!"); |
61 | } |
62 | } |
63 | } |