StatisticsController.php
1.44 KB
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
<?php
namespace artweb\artbox\ecommerce\controllers;
use artweb\artbox\ecommerce\models\Label;
use artweb\artbox\ecommerce\models\Order;
use yii\db\Query;
use yii\helpers\ArrayHelper;
use yii\helpers\VarDumper;
use yii\web\Controller;
class StatisticsController extends Controller
{
public function actionIndex($date_range = NULL, $label = NULL)
{
/**
* Get a dates range
*/
if (!empty($date_range)) {
$arr = [];
preg_match('@(.*)\s:\s(.*)@', $date_range, $arr);
$date_from = strtotime($arr[1]);
$date_to = strtotime($arr[2]);
} else {
$date_from = 0;
$date_to = 0;
}
$labels = ArrayHelper::map(
Label::find()
->joinWith('lang')
->asArray()
->all(),
'id',
'lang.title'
);
if (!empty($label)) {
$label = Label::findOne($label);
/**
* continue here!!!
*/
}
return $this->render(
'index',
[
'labels' => $labels,
]
);
}
}