コード例 #1
0
 public function saveVacation()
 {
     if ($this->data['users']->role == "admin" || $this->data['users']->role == "parent") {
         exit;
     }
     $daysList = Input::get('days');
     $currentUserVacations = vacation::where('userid', $this->data['users']->id)->where('acYear', $this->panelInit->selectAcYear)->count();
     if ($this->data['users']->role == "teacher" and count($daysList) + $currentUserVacations > $this->panelInit->settingsArray['teacherVacationDays']) {
         return $this->panelInit->apiOutput(false, "Request Vacation", "You Don't have enough balance for vacation");
     }
     if ($this->data['users']->role == "student" and count($daysList) + $currentUserVacations > $this->panelInit->settingsArray['studentVacationDays']) {
         return $this->panelInit->apiOutput(false, "Request Vacation", "You Don't have enough balance for vacation");
     }
     while (list(, $value) = each($daysList)) {
         $vacation = new vacation();
         $vacation->userid = $this->data['users']->id;
         $vacation->vacDate = $value;
         $vacation->acYear = $this->panelInit->selectAcYear;
         $vacation->role = $this->data['users']->role;
         $vacation->save();
     }
     return $this->panelInit->apiOutput(true, $this->panelInit->language['getVacation'], $this->panelInit->language['vacSubmitted']);
 }