StatisticsController.php 1.44 KB
<?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,
                ]
            );
        }
    }