1 | <?php |
||
2 | /** |
||
3 | * Server module for HiPanel |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hipanel-module-server |
||
6 | * @package hipanel-module-server |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | /** |
||
12 | * @see http://hiqdev.com/hipanel-module-domain |
||
13 | * @license http://hiqdev.com/hipanel-module-domain/license |
||
14 | * @copyright Copyright (c) 2015 HiQDev |
||
15 | */ |
||
16 | |||
17 | namespace hipanel\modules\server\widgets; |
||
18 | |||
19 | use hipanel\modules\server\models\Server; |
||
20 | use Yii; |
||
21 | |||
22 | class Expires extends \hipanel\widgets\Label |
||
23 | { |
||
24 | /** |
||
25 | * @var Server |
||
26 | */ |
||
27 | public $model; |
||
28 | |||
29 | public function init() |
||
30 | { |
||
31 | $expires = $this->model->expires; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
32 | $this->label = Yii::t('hipanel:server', '(not sold)'); |
||
0 ignored issues
–
show
|
|||
33 | |||
34 | if (!empty($expires)) { |
||
35 | if (strtotime($expires) < time()) { |
||
36 | $class = 'danger'; |
||
37 | } elseif (strtotime($expires) < strtotime('+5 days', time())) { |
||
38 | $class = 'warning'; |
||
39 | } elseif (strtotime($expires) < strtotime('+30 days', time())) { |
||
40 | $class = 'info'; |
||
41 | } else { |
||
42 | $class = 'default'; |
||
43 | } |
||
44 | |||
45 | $this->color = $class; |
||
0 ignored issues
–
show
|
|||
46 | $this->label = Yii::$app->formatter->asDate($expires); |
||
47 | } |
||
48 | |||
49 | parent::init(); |
||
50 | } |
||
51 | } |
||
52 |