コード例 #1
0
ファイル: ReportController.php プロジェクト: ncuong/lifeguard
 public function actionLeaveAndOvertime()
 {
     $searchModel = new UserDateSearch();
     $dataProvider = $searchModel->searchUser(Yii::$app->request->queryParams, Yii::$app->user->id);
     //$dataProvider = Application::find()->where(['user_id'=>Yii::$app->user->id]);
     $query = Application::find();
     $query->joinWith(['user', 'reasonApplication']);
     $query->where(array('application.user_id' => Yii::$app->user->id, 'manager_ok' => 1, 'hrm_ok' => 1));
     $query->andWhere('type_id = 1 OR type_id = -1 OR type_id = -11');
     $query->orderBy(['from_date' => SORT_DESC]);
     $dataProviderUserTimeOver = new ActiveDataProvider(['query' => $query]);
     $totalTimeOverWork = 0;
     $totalTimeLeaveOfTimeOver = 0;
     $totalTimeMoney = 0;
     foreach ($dataProviderUserTimeOver->getModels() as $model) {
         if ($model->reasonApplication->type_id == 1) {
             $totalTimeOverWork += $model->hours_off;
         } else {
             if ($model->reasonApplication->type_id == -1) {
                 $totalTimeLeaveOfTimeOver += $model->hours_off;
             } else {
                 if ($model->reasonApplication->type_id == -11) {
                     $totalTimeMoney += $model->hours_off;
                 }
             }
         }
     }
     return $this->render('leave-and-overtime', ['dataProvider' => $dataProvider, 'dataUserTimeOver' => $dataProviderUserTimeOver, 'totalTimeOverWork' => $totalTimeOverWork, 'totalTimeLeaveOfTimeOver' => $totalTimeLeaveOfTimeOver, 'totalTimeMoney' => $totalTimeMoney, 'totalRemainTime' => $totalTimeOverWork - $totalTimeLeaveOfTimeOver - $totalTimeMoney]);
 }
コード例 #2
0
 /**
  * Lists all UserDate models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new UserDateSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }