public function searchApplicationOfRoom($params, $id) { $query = Application::find(); $query->joinWith(['user', 'reasonApplication']); if (Yii::$app->user->can('manager')) { $query->where(['manager' => $id]); $query->andwhere('reason_application.type_id != -11'); //Ko xem cac don xin chuyen tien $query->orderBy = ['manager_readed' => SORT_ASC, 'from_date' => SORT_DESC]; } if (Yii::$app->user->can('hrm')) { //$query->andWhere(['manager_ok'=>1]); $query->orderBy = ['hrm_readed' => SORT_ASC, 'from_date' => SORT_DESC]; } if (Yii::$app->user->can('director')) { $query = Application::find(); $query->joinWith(['user', 'reasonApplication']); $query->where(['manager' => $id]); } $dataProvider = new ActiveDataProvider(['query' => $query]); $this->from_date = Yii::$app->request->get('from_date'); $this->to_date = Yii::$app->request->get('to_date'); $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(['id' => $this->id, 'user_id' => $this->user_id, 'from_hour' => $this->from_hour, 'to_hour' => $this->to_hour, 'hours_off' => $this->hours_off, 'deleted' => $this->deleted, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'type' => $this->type, 'reason' => $this->reason, 'calculate_date_off' => $this->calculate_date_off, 'manager_readed' => $this->manager_readed, 'hrm_readed' => $this->hrm_readed]); //--- Manager //Accept if ($this->manager_ok != -1) { $query->andFilterWhere(['manager_ok' => $this->manager_ok]); } else { $query->andFilterWhere(['manager_readed' => -1]); } //---- HRM //Accept if ($this->hrm_ok != -1) { $query->andFilterWhere(['hrm_ok' => $this->hrm_ok]); } else { $query->andFilterWhere(['hrm_readed' => -1]); } //--- Date if ($this->from_date != '') { $query->andWhere("from_date >= '" . $this->from_date . "' "); } if ($this->to_date != '') { $query->andWhere("to_date <= '" . $this->to_date . "' "); } $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'user_info.full_name', $this->full_name])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
public function actionLeaveUser() { if (!Yii::$app->request->isAjax) { throw new NotFoundHttpException('The requested page does not exist.'); } $year = Yii::$app->request->post('year'); $searchModel = new ApplicationSearch(); $query = Application::find(); //$query->joinWith(['user','reasonApplication']); $query->where(array('application.user_id' => Yii::$app->user->id)); $query->andWhere('year(from_date) = ' . $year); $query->andWhere(['reason' => 13]); // reason leave is annual leave $query->andWhere(['manager_ok' => 1, 'hrm_ok' => 1]); $dataProvider = new ActiveDataProvider(['query' => $query]); $total = 0; foreach ($dataProvider->getModels() as $model) { $total += $model->hours_off; } return $this->renderAjax('leaves-ajax', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'total' => $total]); }
public function actionOvertimeOfStaffDetail() { $user_id = Yii::$app->request->post('user_id'); $reason_id = Yii::$app->request->post('reason_id'); $from_date = Yii::$app->request->post('from_date'); $to_date = Yii::$app->request->post('to_date'); $view = Yii::$app->request->post('view'); $query = Application::find(); $query->where(['user_id' => $user_id, 'reason' => $reason_id, 'manager_ok' => 1, 'hrm_ok' => 1]); if ($from_date != '') { $query->andWhere('from_date >= "' . $from_date . '" '); } if ($to_date != '') { $query->andWhere('to_date <= "' . $to_date . '" '); } $dataProvider = new ActiveDataProvider(['query' => $query]); if ($view == 2) { return $this->renderAjax('vacation-of-staff-detail2', ['dataProvider' => $dataProvider]); } else { if ($view == 1) { return $this->renderAjax('vacation-of-staff-detail', ['dataProvider' => $dataProvider]); } } }
<div class="wrap"> <?php NavBar::begin(['brandLabel' => 'VIETBINH', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-default navbar-fixed-top']]); $menuItems = [['label' => 'Home', 'url' => ['/site/index']]]; //menu danh cho administrator if (Yii::$app->user->can('admin')) { $menuItems[] = ['label' => 'User', 'url' => ['user/index'], 'items' => [['label' => 'Permission', 'url' => ['/admin/permission']], ['label' => 'Route', 'url' => ['/admin/route']], ['label' => 'Role', 'url' => ['/admin/role']], ['label' => 'Assignment', 'url' => ['/admin/assignment']], ['label' => 'Menu', 'url' => ['/admin/menu']]]]; } //menu danh cho nguoi quan ly nhan su if (Yii::$app->user->can('hrm')) { $hrmNeedToReed = \backend\models\Application::find()->where(['hrm_readed' => -1, 'manager_ok' => 1])->count(); $menuItems[] = ['label' => 'Human Resource Management <span class="badge">' . $hrmNeedToReed . '</span>', 'items' => [['label' => 'Assignment', 'url' => ['/admin/assignment']], ['label' => 'Staff List', 'url' => ['/user-info/index']], ['label' => 'Quota', 'url' => ['/user-date/index']], ['label' => 'Leave/OT Application Request', 'url' => ['/application/application-of-room', 'id' => Yii::$app->user->id]], ['label' => 'Vacation Report', 'url' => ['/report/vacation-of-staff']], ['label' => 'Overtime Report', 'url' => ['/report/overtime-of-staff']]]]; } //menu danh cho truong phong if (Yii::$app->user->can('manager')) { $managerNeedToRead = \backend\models\Application::find()->joinWith('user')->where(['manager_readed' => -1, 'manager' => Yii::$app->user->id])->count(); $menuItems[] = ['label' => 'Manager <span class="badge">' . $managerNeedToRead . '</span>', 'items' => [['label' => 'Staff List', 'url' => ['/user-info/index']], ['label' => 'Leave/OT Application Request', 'url' => ['/application/application-of-room', 'id' => Yii::$app->user->id]]]]; } //menu danh cho nhan vien if (Yii::$app->user->can('staff')) { $menuItems[] = ['label' => 'Form', 'items' => [['label' => 'Leave Application', 'url' => ['/application/application-of-type', 'id' => 0]], ['label' => 'OT Compensation', 'url' => ['/application/application-of-type', 'id' => -1]], ['label' => 'Overtime', 'url' => ['/application/application-of-type', 'id' => 1]], ['label' => 'OT by cash request', 'url' => ['/application/application-of-type', 'id' => -11, 'user_id' => Yii::$app->user->id]]]]; $menuItems[] = ['label' => 'Report', 'items' => [['label' => 'Leave Application', 'url' => ['/application/index']], ['label' => 'Leave and OT Summary', 'url' => ['/report/leave-and-overtime']]]]; } if (Yii::$app->user->isGuest) { $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { $menuItems[] = ['items' => [['label' => 'Change Password', 'url' => ['/site/change-password']], ['label' => 'Log out', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]], 'label' => 'Hello ' . Yii::$app->user->identity->username . '!']; } echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems, 'encodeLabels' => false]); NavBar::end(); ?>