echo Yii::t('teachersportal', 'Position'); ?> </strong></td> <td><?php $pos = EmployeePositions::model()->findByAttributes(array('id' => $employee->employee_position_id)); if ($pos != NULL) { echo $pos->name; } ?> </td> <td ><strong><?php echo Yii::t('teachersportal', 'Grade'); ?> </strong></td> <td><?php $grd = EmployeeGrades::model()->findByAttributes(array('id' => $employee->employee_grade_id)); if ($grd != NULL) { echo $grd->name; } ?> </td> </tr> <tr> <td><strong><?php echo Yii::t('teachersportal', 'Date of Birth'); ?> </strong></td> <td><?php if ($employee->date_of_birth) { if ($settings != NULL) {
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = EmployeeGrades::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
echo ucfirst($posts->name); } else { echo '-'; } ?> </td> </tr> <tr> <td class="listbx_subhdng"><?php echo Yii::t('employees', '<strong>Grade</strong>'); ?> </td> <td class="subhdng_nrmal"> <?php $posts = EmployeeGrades::model()->findByAttributes(array('id' => $model->employee_grade_id)); if ($posts != null) { echo ucfirst($posts->name); } else { echo '-'; } ?> </td> </tr> <tr> <td class="listbx_subhdng odd"><?php echo Yii::t('employees', '<strong>Job Title</strong>'); ?>
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $settings = UserSettings::model()->findByAttributes(array('user_id' => Yii::app()->user->id)); if ($settings != NULL) { $date1 = date($settings->displaydate, strtotime($model->joining_date)); $date2 = date($settings->displaydate, strtotime($model->date_of_birth)); } $model->joining_date = $date1; $model->date_of_birth = $date2; if (isset($_POST['Employees'])) { $old_model = $model->attributes; // For activity feed $model->attributes = $_POST['Employees']; if ($model->joining_date) { $model->joining_date = date('Y-m-d', strtotime($model->joining_date)); } if ($model->date_of_birth) { $model->date_of_birth = date('Y-m-d', strtotime($model->date_of_birth)); } if ($file = CUploadedFile::getInstance($model, 'photo_data')) { $model->photo_file_name = $file->name; $model->photo_content_type = $file->type; $model->photo_file_size = $file->size; $model->photo_data = file_get_contents($file->tempName); } if ($model->save()) { // Saving to activity feed $results = array_diff_assoc($_POST['Employees'], $old_model); // To get the fields that are modified. //print_r($old_model);echo '<br/><br/>';print_r($_POST['Students']);echo '<br/><br/>';print_r($results);echo '<br/><br/>'.count($results);echo '<br/><br/>'; foreach ($results as $key => $value) { if ($key != 'updated_at') { if ($key == 'gender') { if ($value == 'F') { $value = 'Female'; } else { $value = 'Male'; } if ($old_model[$key] == 'F') { $old_model[$key] = 'Female'; } else { $old_model[$key] = 'Male'; } } elseif ($key == 'employee_category_id') { $value = EmployeeCategories::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeeCategories::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($old_model_value->name); } elseif ($key == 'employee_position_id') { $value = EmployeePositions::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeePositions::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($old_model_value->name); } elseif ($key == 'employee_department_id') { $value = EmployeeDepartments::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeeDepartments::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($old_model_value->name); } elseif ($key == 'employee_grade_id') { $value = EmployeeGrades::model()->findByAttributes(array('id' => $value)); $value = ucfirst($value->name); $old_model_value = EmployeeGrades::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = ucfirst($old_model_value->name); } elseif ($key == 'nationality_id' or $key == 'country_id') { $value = Countries::model()->findByAttributes(array('id' => $value)); $value = $value->name; $old_model_value = Countries::model()->findByAttributes(array('id' => $old_model[$key])); $old_model[$key] = $old_model_value->name; } //echo $key.'-'.$model->getAttributeLabel($key).'-'.$value.'-'.$old_model[$key].'<br/>'; //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value) ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '24', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->middle_name) . ' ' . ucfirst($model->last_name), $model->getAttributeLabel($key), $old_model[$key], $value); } } //END saving to activity feed $this->redirect(array('update2', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }
?> <a href="<?php echo Yii::app()->request->getUrl() . '&Employees[employee_position_id]='; ?> "></a></li> <?php } ?> <?php if (isset($_REQUEST['Employees']['employee_grade_id']) and $_REQUEST['Employees']['employee_grade_id'] != NULL) { $j++; ?> <li>Grade : <?php echo EmployeeGrades::model()->findByAttributes(array('id' => $_REQUEST['Employees']['employee_grade_id']))->name; ?> <a href="<?php echo Yii::app()->request->getUrl() . '&Employees[employee_grade_id]='; ?> "></a></li> <?php } ?> <?php if (isset($_REQUEST['Employees']['gender']) and $_REQUEST['Employees']['gender'] != NULL) { $j++; if ($_REQUEST['Employees']['gender'] == 'M') {
?> </td> <td><?php echo $form->dropDownList($model, 'employee_category_id', CHtml::listData(EmployeeCategories::model()->findAll(), 'id', 'name'), array('empty' => 'Select Department')); ?> <?php echo $form->error($model, 'employee_category_id'); ?> </td> <td valign="middle"> </td> <td><?php echo $form->labelEx($model, Yii::t('employees', 'employee_grade_id')); ?> </td> <td valign="middle"><?php echo $form->dropDownList($model, 'employee_grade_id', CHtml::listData(EmployeeGrades::model()->findAll(), 'id', 'name'), array('empty' => 'Select Department')); ?> <?php echo $form->error($model, 'employee_grade_id'); ?> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td valign="middle"><?php