示例#1
0
 public function checkStandardSalaryNow()
 {
     $c = new CDbCriteria();
     $c->compare('year', $this->year);
     $c->compare('city_id', $this->city_id);
     $count = count(PayrollBasedSalaries::model()->findAll($c));
     return $count == 0 ? true : false;
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return PayrollBasedSalaries the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = PayrollBasedSalaries::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function newSalary($id)
 {
     $employee = $this->loadModel($id);
     $base = PayrollBasedSalaries::model()->findByAttributes(array('year' => date('Y'), 'city_id' => $employee->city_area_id, 'department_id' => $employee->department_id, 'section_id' => $employee->section_id, 'position_id' => $employee->position_id, 'level_id' => $employee->level_id, 'grade_id' => $employee->grade_id));
     if (!isset($base)) {
         $base = PayrollBasedSalaries::model()->findByAttributes(array('year' => date('Y')));
     }
     $salary = new PayrollEmployeeSalary();
     $salary->employee_id = $id;
     $salary->salary_id = $base->id;
     $salary->basic_salary = 0;
     $salary->save();
 }