$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>"; } } } } } } } } } $i++; echo "</tr>"; $m++; } echo "</table>"; }
} 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 { echo "<td style='align:center; valign:'middle';'>" . EmpInfo::findOne($sd['emp_master_emp_info_id'])->{$s} . "</td>"; } } } } } } } } } } } $i++; echo "</tr>"; } echo "</table></div>";
/** * Finds the EmpInfo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return EmpInfo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = EmpInfo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionEmpPhoto($eid) { $model = $this->findModel($eid); $info = EmpInfo::findOne($model->emp_master_emp_info_id); $info->scenario = 'photo-upload'; $old_photo = $info->emp_photo; if ($info->load(Yii::$app->request->post())) { $info->attributes = $_POST['EmpInfo']; $info->emp_photo = UploadedFile::getInstance($info, 'emp_photo'); $model->updated_by = Yii::$app->getid->getId(); $model->updated_at = new \yii\db\Expression('NOW()'); if ($info->validate('emp_photo') && !empty($info->emp_photo)) { $ext = substr(strrchr($info->emp_photo, '.'), 1); $photo = $old_photo; $dir1 = Yii::getAlias('@webroot') . '/data/emp_images/'; if (file_exists($dir1 . $photo) && $photo != 'no-photo' && $photo != NULL) { unlink($dir1 . $photo); } if ($ext != null) { $newfname = $info->emp_first_name . '_' . $info->emp_unique_id . '.' . $ext; $returnResults = $info->emp_photo->saveAs(Yii::getAlias('@webroot') . '/data/emp_images/' . ($info->emp_photo = $newfname)); if ($returnResults) { $info->save(false); } } } return $this->redirect(['view', 'id' => $model->emp_master_id]); } return $this->renderAjax('photo_form', ['model' => $model, 'info' => $info]); }
/** 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]); }