/**
  * 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 = EmployeePositions::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #2
0
        echo $list_1->employee_number;
        ?>
</td>
					<?php 
        $dept = EmployeeDepartments::model()->findByAttributes(array('id' => $list_1->employee_department_id));
        ?>
                    <td align="center"><?php 
        if ($dept != NULL) {
            echo $dept->name;
        } else {
            echo '-';
        }
        ?>
 </td>
                    <?php 
        $pos = EmployeePositions::model()->findByAttributes(array('id' => $list_1->employee_position_id));
        ?>
                    <td align="center"><?php 
        if ($pos != NULL) {
            echo $pos->name;
        } else {
            echo '-';
        }
        ?>
 </td>
                    
                  </tr>
                     
               </tbody>
               <?php 
    }
Example #3
0
    ?>
<a href="<?php 
    echo Yii::app()->request->getUrl() . '&Employees[employee_category_id]=';
    ?>
"></a></li>
    <?php 
}
?>
    
    
    <?php 
if (isset($_REQUEST['Employees']['employee_position_id']) and $_REQUEST['Employees']['employee_position_id'] != NULL) {
    $j++;
    ?>
    <li>Position : <?php 
    echo EmployeePositions::model()->findByAttributes(array('id' => $_REQUEST['Employees']['employee_position_id']))->name;
    ?>
<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 
 /**
  * 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));
 }
Example #5
0
?>
</td>
    <td><?php 
echo $form->dropDownList($model, 'employee_department_id', CHtml::listData(EmployeeDepartments::model()->findAll(), 'id', 'name'), array('empty' => 'Select Department'));
?>
		<?php 
echo $form->error($model, 'employee_department_id');
?>
</td>
    <td valign="middle">&nbsp;</td>
    <td valign="middle"><?php 
echo $form->labelEx($model, Yii::t('employees', 'employee_position_id'));
?>
</td>
    <td valign="middle"><?php 
echo $form->dropDownList($model, 'employee_position_id', CHtml::listData(EmployeePositions::model()->findAll(), 'id', 'name'), array('empty' => 'Select Postition'));
?>
		<?php 
echo $form->error($model, 'employee_position_id');
?>
</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle"><?php