Blame view

controllers/StatisticsController.php 1.44 KB
1ac35977   Alexey Boroda   -Staistics started
1
2
3
4
  <?php

      

      namespace artweb\artbox\ecommerce\controllers;

      

c130fad8   Alexey Boroda   -Yml fix
5
6
7
8
9
      use artweb\artbox\ecommerce\models\Label;

      use artweb\artbox\ecommerce\models\Order;

      use yii\db\Query;

      use yii\helpers\ArrayHelper;

      use yii\helpers\VarDumper;

1ac35977   Alexey Boroda   -Staistics started
10
11
      use yii\web\Controller;

      

1ac35977   Alexey Boroda   -Staistics started
12
13
      class StatisticsController extends Controller

      {

c130fad8   Alexey Boroda   -Yml fix
14
          public function actionIndex($date_range = NULL, $label = NULL)

1ac35977   Alexey Boroda   -Staistics started
15
          {

c130fad8   Alexey Boroda   -Yml fix
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
              /**

               * 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,

                  ]

              );

1ac35977   Alexey Boroda   -Staistics started
51
52
          }

      }