/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EmpAddress::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_address_id' => $this->emp_address_id, 'emp_cadd_city' => $this->emp_cadd_city, 'emp_cadd_state' => $this->emp_cadd_state, 'emp_cadd_country' => $this->emp_cadd_country, 'emp_cadd_pincode' => $this->emp_cadd_pincode, 'emp_padd_city' => $this->emp_padd_city, 'emp_padd_state' => $this->emp_padd_state, 'emp_padd_country' => $this->emp_padd_country, 'emp_padd_pincode' => $this->emp_padd_pincode]); $query->andFilterWhere(['like', 'emp_cadd', $this->emp_cadd])->andFilterWhere(['like', 'emp_cadd_house_no', $this->emp_cadd_house_no])->andFilterWhere(['like', 'emp_cadd_phone_no', $this->emp_cadd_phone_no])->andFilterWhere(['like', 'emp_padd', $this->emp_padd])->andFilterWhere(['like', 'emp_padd_house_no', $this->emp_padd_house_no])->andFilterWhere(['like', 'emp_padd_phone_no', $this->emp_padd_phone_no]); 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); }
if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)) { $add_c = "<br/>" . City::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)->city_name . ", "; } else { $add_c = ''; } if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_state)) { $add_s = State::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_state)->state_name . ", "; } else { $add_s = ''; } if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)) { $add_co = Country::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)->country_name; } else { $add_co = ''; } echo "<td class='text-center'>" . EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd . " " . $add_c . " " . $add_s . " " . $add_co . "</td>"; } else { echo "<td> </td>"; } } else { if ($s == 'emp_joining_date') { $jdate = EmpInfo::findOne($sd['emp_master_emp_info_id'])->{$s}; echo "<td class='text-center'>" . date('d-m-Y', strtotime($jdate)) . "</td>"; } else { if ($s == 'emp_dob') { $bdate = EmpInfo::findOne($sd['emp_master_emp_info_id'])->{$s}; echo "<td class='text-center'>" . date('d-m-Y', strtotime($bdate)) . "</td>"; } else { echo "<td class='text-center'>" . EmpInfo::findOne($sd['emp_master_emp_info_id'])->{$s} . "</td>"; } }
if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)) { $add_c = "<br/>" . City::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)->city_name . ", "; } else { $add_c = ''; } if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_cadd_state)) { $add_s = State::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_state)->state_name . ", "; } else { $add_s = ''; } if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)) { $add_co = Country::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)->country_name; } else { $add_co = ''; } echo "<td style='align:center; valign:'middle';'>" . EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd . " " . $add_c . " " . $add_s . " " . $add_co . "</td>"; } else { echo "<td > </td>"; } } else { if ($s == 'emp_joining_date') { $jdate = EmpInfo::findOne($sd['emp_master_emp_info_id'])->{$s}; echo "<td style='text-align:center;width:250px;'>" . date('d-m-Y', strtotime($jdate)) . "</td>"; } else { if ($s == 'emp_dob') { $bdate = EmpInfo::findOne($sd['emp_master_emp_info_id'])->{$s}; echo "<td style='text-align:center;width:250px;'>" . date('d-m-Y', strtotime($bdate)) . "</td>"; } else { if ($s == 'emp_email_id') { echo "<td style='text-align:center;width:250px;'>" . Empinfo::findOne($sd['emp_master_emp_info_id'])->{$s} . "</td>"; } else {
/** * Finds the EmpAddress model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return EmpAddress the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = EmpAddress::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getEmpMasterEmpAddress() { return $this->hasOne(EmpAddress::className(), ['emp_address_id' => 'emp_master_emp_address_id']); }
/** * Updates an existing EmpMaster model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($empid, $tab) { $model = $this->findModel($empid); $info = EmpInfo::findOne($model->emp_master_emp_info_id); $address = EmpAddress::findOne($model->emp_master_emp_address_id); $emp_docs = new EmpDocs(); if ($tab == 'personal') { if ($info->load(Yii::$app->request->post()) && Yii::$app->request->isAjax) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($info); } if ($model->load(Yii::$app->request->post()) && Yii::$app->request->isAjax) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post()) || $info->load(Yii::$app->request->post())) { $model->attributes = $_POST['EmpMaster']; $info->attributes = $_POST['EmpInfo']; if (empty($_POST['EmpInfo']['emp_email_id'])) { $info->emp_email_id = NULL; } else { $info->emp_email_id = $_POST['EmpInfo']['emp_email_id']; } $info->emp_dob = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_dob']); $info->emp_joining_date = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_joining_date']); $model->updated_by = Yii::$app->getid->getId(); $model->updated_at = new \yii\db\Expression('NOW()'); if ($model->save() && $info->save()) { return $this->redirect(['view', 'id' => $model->emp_master_id, '#' => "personal"]); } else { return $this->render('emp_personal_info', ['model' => $model, 'info' => $info]); } } else { return $this->render('emp_personal_info', ['model' => $model, 'info' => $info]); } } else { if ($tab == 'address') { if ($address->load(Yii::$app->request->post())) { $address->attributes = $_POST['EmpAddress']; $model->updated_by = Yii::$app->getid->getId(); $model->updated_at = new \yii\db\Expression('NOW()'); if ($address->save()) { return $this->redirect(['view', 'id' => $model->emp_master_id, '#' => "address"]); } else { return $this->render('emp_address', ['model' => $model, 'info' => $info, 'address' => $address]); } } else { return $this->render('emp_address', ['model' => $model, 'info' => $info, 'address' => $address]); } } else { if ($tab == 'guardians') { if ($info->load(Yii::$app->request->post())) { $info->attributes = $_POST['EmpInfo']; if (empty($_POST['EmpInfo']['emp_guardian_email_id'])) { $info->emp_guardian_email_id = NULL; } $model->updated_by = Yii::$app->getid->getId(); $model->updated_at = new \yii\db\Expression('NOW()'); if ($info->save(false) && $model->save()) { return $this->redirect(['view', 'id' => $model->emp_master_id, '#' => "guardians"]); } else { return $this->render('emp_guardians', ['model' => $model, 'info' => $info]); } } else { return $this->render('emp_guardians', ['model' => $model, 'info' => $info]); } } else { if ($tab == 'otherinfo') { if ($info->load(Yii::$app->request->post())) { $info->attributes = $_POST['EmpInfo']; $model->updated_by = Yii::$app->getid->getId(); $model->updated_at = new \yii\db\Expression('NOW()'); if (empty($_POST['EmpInfo']['emp_attendance_card_id'])) { $info->emp_attendance_card_id = NULL; } if ($info->save() && $model->save()) { return $this->redirect(['view', 'id' => $model->emp_master_id, '#' => "otherinfo"]); } else { return $this->render('emp_otherinfo', ['model' => $model, 'info' => $info]); } } else { return $this->render('emp_otherinfo', ['model' => $model, 'info' => $info]); } } else { return $this->render('update', ['model' => $model, 'info' => $info]); } } } } }
} else { echo "<td> </td></tr>"; } } else { if ($s == 'emp_category_name') { echo "<tr><td class='label'>Category Name </td>"; if ($sd['emp_master_category_id'] != 0) { echo "<td>" . Category::findOne($sd['emp_master_category_id'])->emp_category_name . "</td></tr>"; } else { echo "<td> </td></tr>"; } } else { if ($s == 'city') { echo "<tr><td class='label'>City</td>"; if ($sd['emp_master_emp_address_id'] != 0) { $add = EmpAddress::findOne($sd['emp_master_emp_address_id']); if ($add->emp_cadd_city != null) { echo "<td>" . City::findOne($add->emp_cadd_city)->city_name . "</td></tr>"; } else { echo "<td> </td></tr>"; } } else { echo "<td> </td></tr>"; } } else { if ($s == 'emp_guardian_mobile_no') { echo "<tr><td class='label'>Guardian No </td>"; echo "<td>" . $sd[$s] . "</td></tr>"; } else { if ($s == 'emp_bloodgroup') { echo "<tr><td class='label'>Blood Group</td><td>" . $sd[$s] . "</td></tr>";