public function actionIndex()
 {
     $empDesignWise = [];
     if (Yii::$app->session->get('stu_id')) {
         return $this->redirect(['/employee/emp-master/index']);
     }
     //Department wise employee display
     $empDepWise = (new \yii\db\Query())->select(["CONCAT(dp.emp_department_name, ' (', COUNT( emp_master_id ), ')') AS '0'", 'COUNT(emp_master_id) AS "1"'])->from('emp_master em')->join('JOIN', 'emp_department dp', 'dp.emp_department_id = em.emp_master_department_id')->where(['em.is_status' => '0', 'dp.is_status' => '0'])->groupBy('em.emp_master_department_id')->all();
     //Recently added student list
     $empRecent = (new \yii\db\Query())->select(['em.emp_master_id', 'emp_unique_id', "CONCAT(ei.emp_first_name, ' ', ei.emp_last_name) AS 'emp_name'", 'dp.emp_department_name', 'DATE_FORMAT(em.created_at, "%d-%m-%Y") AS cDate'])->from('emp_master em')->join('JOIN', 'emp_info ei', 'ei.emp_info_emp_master_id = em.emp_master_id')->join('JOIN', 'emp_department dp', 'dp.emp_department_id = em.emp_master_department_id')->where(['em.is_status' => '0'])->orderBy('emp_master_id DESC')->limit(10)->all();
     /**
      * @Start Designation wise employee display
      */
     $empDesignWise = (new \yii\db\Query())->select(["CONCAT(ds.emp_designation_name, ' (', COUNT( emp_master_id ), ')') AS '0'", 'COUNT(emp_master_id) AS "1"'])->from('emp_master em')->join('JOIN', 'emp_designation ds', 'ds.emp_designation_id = em.emp_master_designation_id')->where(['em.is_status' => '0'])->groupBy('emp_master_designation_id')->all();
     $empDesignWiseNull = EmpMaster::find()->where(['is_status' => 0, 'emp_master_designation_id' => NULL])->count();
     if (!empty($empDesignWiseNull)) {
         $empDesignWise[] = ['name' => 'Not Set (' . $empDesignWiseNull . ')', 'y' => $empDesignWiseNull, 'sliced' => true, 'selected' => true, 'color' => '#F45B5B'];
     }
     return $this->render('index', ['empDepWise' => $empDepWise, 'empRecent' => $empRecent, 'empDesignWise' => $empDesignWise]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = EmpMaster::find()->where(['is_status' => 0]);
     $query->joinWith(['empMasterEmpInfo', 'empMasterUser']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['enableMultiSort' => true], 'sort' => ['defaultOrder' => ['emp_master_id' => SORT_DESC]]]);
     $dataProvider->sort->attributes['emp_unique_id'] = ['asc' => ['emp_info.emp_unique_id' => SORT_ASC], 'desc' => ['emp_info.emp_unique_id' => SORT_DESC]];
     $dataProvider->sort->attributes['emp_first_name'] = ['asc' => ['emp_info.emp_first_name' => SORT_ASC], 'desc' => ['emp_info.emp_first_name' => SORT_DESC]];
     $dataProvider->sort->attributes['emp_middle_name'] = ['asc' => ['emp_middle_name' => SORT_ASC], 'desc' => ['emp_middle_name' => SORT_DESC]];
     $dataProvider->sort->attributes['emp_last_name'] = ['asc' => ['emp_last_name' => SORT_ASC], 'desc' => ['emp_last_name' => SORT_DESC]];
     $dataProvider->sort->attributes['user_login_id'] = ['asc' => ['users.user_login_id' => SORT_ASC], 'desc' => ['users.user_login_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(['emp_master_id' => $this->emp_master_id, 'emp_master_emp_info_id' => $this->emp_master_emp_info_id, 'emp_master_user_id' => $this->emp_master_user_id, 'emp_master_department_id' => $this->emp_master_department_id, 'emp_master_designation_id' => $this->emp_master_designation_id, 'emp_master_category_id' => $this->emp_master_category_id, 'emp_master_nationality_id' => $this->emp_master_nationality_id, 'emp_master_emp_address_id' => $this->emp_master_emp_address_id, 'emp_master_status_id' => $this->emp_master_status_id, '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', 'emp_info.emp_first_name', $this->emp_first_name])->andFilterWhere(['like', 'emp_info.emp_last_name', $this->emp_last_name])->andFilterWhere(['like', 'emp_info.emp_middle_name', $this->emp_middle_name])->andFilterWhere(['like', 'users.user_login_id', $this->user_login_id])->andFilterWhere(['like', 'emp_info.emp_unique_id', $this->emp_unique_id]);
     unset($_SESSION['exportData']);
     $_SESSION['exportData'] = $dataProvider;
     return $dataProvider;
 }
Exemple #3
0
 public function actionLogin()
 {
     $this->checkInstallation();
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     $login = new \app\models\LoginDetails();
     if ($model->load(Yii::$app->request->post())) {
         $log = \app\models\User::find()->where(['user_login_id' => $_POST['LoginForm']['username'], 'is_block' => 0])->one();
         if (empty($log)) {
             \Yii::$app->session->setFlash('loginError', '<i class="fa fa-warning"></i><b> Incorrect username or password. !</b>');
             return $this->render('login', ['model' => $model]);
         }
         $login->login_user_id = $log['user_id'];
         $loginuser = $login->login_user_id;
         $emplogin = EmpMaster::find()->andWhere(['emp_master_user_id' => $loginuser])->one();
         $studlogin = StuMaster::find()->andWhere(['stu_master_user_id' => $loginuser])->one();
         if ($studlogin) {
             \Yii::$app->session->set('stu_id', $studlogin->stu_master_id);
         } else {
             if ($emplogin) {
                 \Yii::$app->session->set('emp_id', $emplogin->emp_master_id);
             } else {
                 if (!$emplogin && !$studlogin) {
                     \Yii::$app->session->set('admin_user', $loginuser);
                 } else {
                     \Yii::$app->session->setFlash('loginError', '<i class="fa fa-warning"></i><b> These Login credentials are Blocked/Deactive by Admin</b>');
                     return $this->render('login', ['model' => $model]);
                 }
             }
         }
         $login->login_status = 1;
         $login->login_at = new \yii\db\Expression('NOW()');
         $login->user_ip_address = $_SERVER['REMOTE_ADDR'];
         $login->save(false);
         if ($model->login()) {
             if (!isset(Yii::$app->request->cookies['language'])) {
                 return $this->redirect(['language']);
             } else {
                 return $this->goBack();
             }
         } else {
             return $this->render('login', ['model' => $model]);
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
 /** Use for update employee login user details.
  *  @param integer $id the ID of the model to be update.
  */
 public function actionUpdateemploginid($id)
 {
     $model = $this->findModel($id);
     $emp_data = EmpMaster::find()->where(['emp_master_user_id' => $id])->one();
     $emp_info = EmpInfo::findOne($emp_data->emp_master_emp_info_id)->emp_first_name;
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->user_login_id = $_POST['User']['user_login_id'];
         \Yii::$app->session->setFlash('resetemploginid', "<i class='glyphicon glyphicon-info-sign'></i> " . $emp_info . "'s Login id is Reset");
         if ($model->save()) {
             \Yii::$app->session->setFlash('resetemploginid', "<i class='glyphicon glyphicon-info-sign'></i> " . $emp_info . "'s Login id is Reset");
             return $this->redirect(['resetemploginid']);
         }
     }
     return $this->render('updateemploginid', ['model' => $model]);
 }
Exemple #5
0
        <div class="icon">
            <i class="fa fa-toggle-on" style="font-size: 60px;"></i>
        </div>
	<?php 
echo Html::a('More Info <i class="fa fa-arrow-circle-right"></i>', ['/report/employee/empinforeport'], ['class' => 'small-box-footer']);
?>
    </div>
</div>

<!---Start Count Deactive Employee--->
<div class="col-lg-3 col-xs-6">
    <!-- small box -->
    <div class="small-box bg-red">
        <div class="inner">
            <h3><?php 
echo \app\modules\employee\models\EmpMaster::find()->where(['is_status' => 1])->count();
?>
</h3>
            <p>Deactive Employee</p>
        </div>
        <div class="icon">
           <i class="fa fa-toggle-off" style="font-size: 60px;"></i>
        </div>
	    <?php 
echo Html::a('More Info <i class="fa fa-arrow-circle-right"></i>', ['/report/employee/empinforeport'], ['class' => 'small-box-footer']);
?>
    </div>
</div>

</div>