/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EmpInfo::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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_info_id' => $this->emp_info_id, 'emp_dob' => $this->emp_dob, 'emp_joining_date' => $this->emp_joining_date, 'emp_mobile_no' => $this->emp_mobile_no, 'emp_experience_year' => $this->emp_experience_year, 'emp_experience_month' => $this->emp_experience_month, 'emp_guardian_mobile_no' => $this->emp_guardian_mobile_no, 'emp_info_emp_master_id' => $this->emp_info_emp_master_id]); $query->andFilterWhere(['like', 'emp_unique_id', $this->emp_unique_id])->andFilterWhere(['like', 'emp_attendance_card_id', $this->emp_attendance_card_id])->andFilterWhere(['like', 'emp_title', $this->emp_title])->andFilterWhere(['like', 'emp_first_name', $this->emp_first_name])->andFilterWhere(['like', 'emp_middle_name', $this->emp_middle_name])->andFilterWhere(['like', 'emp_last_name', $this->emp_last_name])->andFilterWhere(['like', 'emp_name_alias', $this->emp_name_alias])->andFilterWhere(['like', 'emp_mother_name', $this->emp_mother_name])->andFilterWhere(['like', 'emp_gender', $this->emp_gender])->andFilterWhere(['like', 'emp_religion', $this->emp_religion])->andFilterWhere(['like', 'emp_bloodgroup', $this->emp_bloodgroup])->andFilterWhere(['like', 'emp_birthplace', $this->emp_birthplace])->andFilterWhere(['like', 'emp_email_id', $this->emp_email_id])->andFilterWhere(['like', 'emp_maritalstatus', $this->emp_maritalstatus])->andFilterWhere(['like', 'emp_photo', $this->emp_photo])->andFilterWhere(['like', 'emp_languages', $this->emp_languages])->andFilterWhere(['like', 'emp_bankaccount_no', $this->emp_bankaccount_no])->andFilterWhere(['like', 'emp_qualification', $this->emp_qualification])->andFilterWhere(['like', 'emp_specialization', $this->emp_specialization])->andFilterWhere(['like', 'emp_hobbies', $this->emp_hobbies])->andFilterWhere(['like', 'emp_reference', $this->emp_reference])->andFilterWhere(['like', 'emp_guardian_name', $this->emp_guardian_name])->andFilterWhere(['like', 'emp_guardian_relation', $this->emp_guardian_relation])->andFilterWhere(['like', 'emp_guardian_qualification', $this->emp_guardian_qualification])->andFilterWhere(['like', 'emp_guardian_occupation', $this->emp_guardian_occupation])->andFilterWhere(['like', 'emp_guardian_income', $this->emp_guardian_income])->andFilterWhere(['like', 'emp_guardian_homeadd', $this->emp_guardian_homeadd])->andFilterWhere(['like', 'emp_guardian_officeadd', $this->emp_guardian_officeadd])->andFilterWhere(['like', 'emp_guardian_phone_no', $this->emp_guardian_phone_no])->andFilterWhere(['like', 'emp_guardian_email_id', $this->emp_guardian_email_id]); return $dataProvider; }
public function actionEmployeeProfilePdf($eid) { $nationality = $empAdd = []; $empMaster = EmpMaster::findOne($eid); $empDocs = EmpDocs::find()->where(['emp_docs_emp_master_id' => $eid])->join('join', 'document_category dc', 'dc.doc_category_id = emp_docs_category_id AND dc.is_status <> 2')->all(); $empInfo = EmpInfo::find()->where(['emp_info_emp_master_id' => $eid])->one(); if ($empMaster->emp_master_nationality_id !== null) { $nationality = Nationality::findOne($empMaster->emp_master_nationality_id)->nationality_name; } if ($empMaster->emp_master_emp_address_id !== null) { $empAdd = EmpAddress::findOne($empMaster->emp_master_emp_address_id); } $html = $this->renderPartial('/emp-master/empprofilepdf', ['empDocs' => $empDocs, 'empMaster' => $empMaster, 'empInfo' => $empInfo, 'nationality' => $nationality, 'empAdd' => $empAdd]); $fName = $empInfo->emp_first_name . "_" . $empInfo->emp_last_name . "_" . date('Ymd_His'); return Yii::$app->pdf->exportData(Yii::t('emp', 'Employee Profile'), $fName, $html); }
/** * Creates a new EmpMaster model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new EmpMaster(); $info = new EmpInfo(); $user = new User(); $address = new EmpAddress(); $auth_assign = new AuthAssignment(); $empUniqueId = EmpInfo::find()->max('emp_unique_id'); $empno = null; if (empty($empUniqueId)) { $empno = $info->emp_unique_id = 1; } else { $chkId = EmpInfo::find()->where(['emp_unique_id' => $empUniqueId])->exists(); if ($chkId) { $empno = $empUniqueId + 1; } else { $empno = $empUniqueId; } } if ($model->load(Yii::$app->request->post()) && $info->load(Yii::$app->request->post())) { if (Yii::$app->request->isAjax) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($info); } if (Yii::$app->request->isAjax) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($model); } $model->attributes = $_POST['EmpMaster']; $info->attributes = $_POST['EmpInfo']; $info->emp_dob = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_dob']); $info->emp_joining_date = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_joining_date']); $info->emp_unique_id = $empno; if (empty($_POST['EmpInfo']['emp_email_id'])) { $info->emp_email_id = NULL; } else { $info->emp_email_id = strtolower($info->emp_email_id); } $user->user_login_id = \app\models\Organization::find()->one()->org_emp_prefix . $info->emp_unique_id; $user->user_password = md5($user->user_login_id . $user->user_login_id); $user->user_type = "E"; $user->created_by = Yii::$app->getid->getId(); $user->created_at = new \yii\db\Expression('NOW()'); if ($info->save(false)) { $user->save(false); $address->save(false); } $model->emp_master_emp_address_id = $address->emp_address_id; $model->emp_master_emp_info_id = $info->emp_info_id; $model->emp_master_user_id = $user->user_id; $model->created_by = Yii::$app->getid->getId(); $model->created_at = new \yii\db\Expression('NOW()'); $model->save(false); $emp_info = EmpInfo::findOne($model->emp_master_emp_info_id); $emp_info->emp_info_emp_master_id = $model->emp_master_id; $emp_info->save(false); $auth_assign->item_name = 'Employee'; $auth_assign->user_id = $user->user_id; $auth_assign->created_at = date_format(date_create(), 'U'); $auth_assign->save(false); if ($model->save(false)) { return $this->redirect(['view', 'id' => $model->emp_master_id]); } else { return $this->render('create', ['model' => $model, 'info' => $info, 'user' => $user, 'empno' => $empno]); } } else { return $this->render('create', ['model' => $model, 'info' => $info, 'user' => $user, 'empno' => $empno]); } }