Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
provider.php
1<?php
3
6
13{
14 private const TYPE = 'cashbox';
15
16 private const CASHBOX_HANDLERS = [
17 Sale\Cashbox\CashboxOrangeData::class,
18 Sale\Cashbox\CashboxCheckbox::class,
19 Sale\Cashbox\CashboxBusinessRu::class,
20 Sale\Cashbox\CashboxBusinessRuV5::class,
21 Sale\Cashbox\CashboxOrangeDataFfd12::class,
22 ];
23
25 private $check;
26
28 private $cashboxHandler;
29
30 public function __construct(Sale\Cashbox\AbstractCheck $check)
31 {
32 $this->check = $check;
33
34 $cashboxId = $check->getField('CASHBOX_ID');
35 $this->cashboxHandler = Sale\Cashbox\Manager::getObjectById($cashboxId);
36 }
37
41 public static function getCode(): string
42 {
43 return self::TYPE;
44 }
45
46 protected function needProvideData(): bool
47 {
48 $cashboxHandlerCode = $this->cashboxHandler::getCode();
49
50 $isCashboxHandlerExists = (bool)array_filter(
51 self::CASHBOX_HANDLERS,
52 static function ($cashboxHandler) use ($cashboxHandlerCode) {
53 return $cashboxHandlerCode === $cashboxHandler::getCode();
54 }
55 );
56
57 return $isCashboxHandlerExists && $this->check->getField('STATUS') === 'Y';
58 }
59
63 protected function getProviderData(): array
64 {
65 $checkData = $this->getCheckData();
66 return [
67 'cashbox' => $this->cashboxHandler::getCode(),
68 'date_time' => $checkData['date_time'],
69 ];
70 }
71
75 private function getCheckData(): array
76 {
77 $dateTime = $this->check->getField('DATE_PRINT_END');
78 if (!($dateTime instanceof Main\Type\DateTime))
79 {
80 $dateTime = new Main\Type\DateTime();
81 }
82
83 return [
84 'date_time' => $dateTime->format('Y-m-d H:i:s'),
85 ];
86 }
87}
__construct(Sale\Cashbox\AbstractCheck $check)
Definition provider.php:30