1 | <?php |
||
16 | use Yii; |
||
17 | |||
18 | class DashboardItem extends Menu |
||
19 | { |
||
20 | protected ClientWithCounters $clientWithCounters; |
||
|
|||
21 | |||
22 | public function __construct(ClientWithCounters $clientWithCounters, $config = []) |
||
23 | { |
||
24 | $this->clientWithCounters = $clientWithCounters; |
||
25 | parent::__construct($config); |
||
26 | } |
||
27 | |||
28 | public function items() |
||
29 | { |
||
30 | $items = []; |
||
31 | if (Yii::$app->user->can('bill.read')) { |
||
32 | $items['bill'] = [ |
||
33 | 'label' => $this->render('dashboardBillItem', $this->clientWithCounters->getWidgetData('bill')), |
||
34 | 'encode' => false, |
||
35 | ]; |
||
36 | } |
||
37 | if (Yii::$app->user->can('manage')) { |
||
38 | $items['tariff'] = [ |
||
39 | 'label' => $this->render('dashboardTariffItem', array_merge($this->clientWithCounters->getWidgetData('tariff'), [ |
||
40 | 'route' => Url::toRoute('@plan/index'), |
||
41 | ])), |
||
42 | 'encode' => false, |
||
49 |