/
InfoBox.php
62 lines (45 loc) · 1.43 KB
/
InfoBox.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace machour\yii2\adminlte\widgets;
use yii\base\Widget;
class InfoBox extends Widget {
public $bg = 'bg-aqua';
public $bgFill = false;
public $text = 'Text';
public $number = 0;
public $icon;
public $progress;
public $progressText;
public function run() {
echo Html::beginTag('div', ['class' => 'info-box ' . ($this->bgFill ? $this->bg : '')]);
if (!$this->icon) {
$this->icon = Html::fa('question', 'i');
}
echo Html::tag(
'span',
$this->icon,
['class' => 'info-box-icon ' . ($this->bgFill ? '' : $this->bg)]
);
echo Html::beginTag('div', ['class' => 'info-box-content']);
echo Html::tag(
'span',
$this->text,
['class' => 'info-box-text']
);
echo Html::tag(
'span',
$this->number,
['class' => 'info-box-number']
);
if ($this->progress !== null) {
echo Html::tag('div',
Html::tag('div', '', ['class' => 'progress-bar', 'style' => 'width: ' . $this->progress . '%;']),
['class' => 'progress']
);
if (!empty($this->progressText)) {
echo Html::tag('div', $this->progressText, ['class' => 'progress-description']);
}
}
echo Html::endTag('div');
echo Html::endTag('div');
}
}