예제 #1
0
 public function actionIndex()
 {
     if (isset($_GET['toggleView']) && $_GET['toggleView']) {
         if (Yii::app()->params->profile->oldActions) {
             Yii::app()->params->profile->oldActions = 0;
         } else {
             Yii::app()->params->profile->oldActions = 1;
         }
         Yii::app()->params->profile->update(array('oldActions'));
         $this->redirect(array('index'));
     }
     $model = new Actions('search');
     if (!isset(Yii::app()->params->profile->oldActions) || !Yii::app()->params->profile->oldActions) {
         if (!empty($_POST) || !empty(Yii::app()->params->profile->actionFilters)) {
             if (isset($_POST['complete'], $_POST['assignedTo'], $_POST['dateType'], $_POST['dateRange'], $_POST['orderType'], $_POST['order'], $_POST['start'], $_POST['end'])) {
                 $complete = $_POST['complete'];
                 $assignedTo = $_POST['assignedTo'];
                 $dateType = $_POST['dateType'];
                 $dateRange = $_POST['dateRange'];
                 $orderType = $_POST['orderType'];
                 $order = $_POST['order'];
                 $start = $_POST['start'];
                 $end = $_POST['end'];
                 if ($dateRange != 'range') {
                     $start = null;
                     $end = null;
                 }
                 $filters = array('complete' => $complete, 'assignedTo' => $assignedTo, 'dateType' => $dateType, 'dateRange' => $dateRange, 'orderType' => $orderType, 'order' => $order, 'start' => $start, 'end' => $end);
             } elseif (!empty(Yii::app()->params->profile->actionFilters)) {
                 $filters = json_decode(Yii::app()->params->profile->actionFilters, true);
             }
             $condition = Actions::createCondition($filters);
             $dataProvider = $model->search($condition, Actions::ACTION_INDEX_PAGE_SIZE);
             $params = $filters;
         } else {
             $dataProvider = $model->search(null, Actions::ACTION_INDEX_PAGE_SIZE);
             $params = array();
         }
         $this->render('index', array('model' => $model, 'dataProvider' => $dataProvider, 'params' => $params));
     } else {
         $this->render('oldIndex', array('model' => $model));
     }
 }