/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new PayrollBasedSalaries();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['PayrollBasedSalaries'])) {
         $model->attributes = $_POST['PayrollBasedSalaries'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#2
0
 public function generateNewStandardSalaries()
 {
     if (!$this->checkStandardSalaryNow()) {
         return at('Salary standard has been generated');
     }
     $year_bef = $this->year - 1;
     $ump_bef = $this->getUMPBefore();
     if (count($ump_bef) == 0) {
         return at('Can not generate salary standard, because of UMP before not found.');
     } else {
         $salaries = $this->getStandardSalaryBefore();
         if (count($salaries) == 0) {
             return at('Can not generate salary standard, because of salary standard before not found.');
         } else {
             $inc = ($this->values - $ump_bef->values) / $ump_bef->values;
             foreach ($salaries as $salary) {
                 $model = new PayrollBasedSalaries();
                 $model->year = $this->year;
                 $model->city_id = $this->city_id;
                 $model->department_id = $salary->department_id;
                 $model->section_id = $salary->section_id;
                 $model->position_id = $salary->position_id;
                 $model->years_of_service_start = $salary->years_of_service_start;
                 $model->years_of_service_end = $salary->years_of_service_end;
                 $model->level_id = $salary->level_id;
                 $model->grade_id = $salary->grade_id;
                 $model->basic_salary_from = round((1 + $inc) * $salary->basic_salary_from, 0);
                 $model->basic_salary_to = round((1 + $inc) * $salary->basic_salary_to, 0);
                 $model->basic_salary_inc_amount = $model->basic_salary_from - $salary->basic_salary_inc_amount;
                 $model->basic_salary_inc_percentage = round($inc * 100, 2);
                 $model->save();
                 $allowances = $salary->payrollBasedAllowances;
                 foreach ($allowances as $allowance) {
                     $childmodel = new payrollBasedAllowances();
                     $childmodel->standard_id = $model->id;
                     $childmodel->allowance_id = $allowance->allowance_id;
                     $childmodel->calc_type = $allowance->calc_type;
                     $childmodel->formula = $allowance->formula;
                     $childmodel->values = $allowance->values;
                     $childmodel->save();
                 }
             }
         }
     }
     return '';
 }