Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = NationalHolidays::find()->where(['is_status' => 0]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['national_holiday_id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['national_holiday_id' => $this->national_holiday_id, 'national_holiday_date' => $this->dbDateSearch($this->national_holiday_date), 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'is_status' => $this->is_status]);
     $query->andFilterWhere(['like', 'national_holiday_name', $this->national_holiday_name])->andFilterWhere(['like', 'national_holiday_remarks', $this->national_holiday_remarks]);
     unset($_SESSION['exportData']);
     $_SESSION['exportData'] = $dataProvider;
     return $dataProvider;
 }
Exemplo n.º 2
0
 public function actionIndex()
 {
     $this->layout = 'homePage';
     if (\Yii::$app->user->isGuest) {
         return $this->redirect(['site/login']);
     } else {
         $isStudent = Yii::$app->session->get('stu_id');
         $isEmployee = Yii::$app->session->get('emp_id');
         $holidayData = \app\models\NationalHolidays::find()->andWhere(['is_status' => 0])->asArray()->all();
         if (isset($isStudent)) {
             $payFees = Yii::$app->db->createCommand("SELECT SUM(fees_pay_tran_amount) FROM fees_payment_transaction WHERE fees_pay_tran_stu_id=" . Yii::$app->session->get('stu_id') . " AND is_status=0")->queryScalar();
             $currentFeesData = \app\modules\fees\models\FeesPaymentTransaction::getUnpaidTotal($isStudent);
             return $this->render('stu-dashboard', ['holidayData' => $holidayData, 'currentFeesData' => $currentFeesData, 'payFees' => $payFees]);
         } else {
             if (isset($isEmployee)) {
                 return $this->render('emp-dashboard', ['holidayData' => $holidayData]);
             } else {
                 return $this->render('user-dashboard');
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getNationalHolidays()
 {
     return $this->hasMany(NationalHolidays::className(), ['updated_by' => 'user_id']);
 }
 /**
  * Finds the NationalHolidays model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return NationalHolidays the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = NationalHolidays::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }