示例#1
0
 public static function userSubmitted(\GO\Users\Controller\UserController $userController, &$response, &$userModel, &$submitParams, $modifiedAttributes)
 {
     $wwModel = \GO\Base\Model\WorkingWeek::model()->findSingleByAttribute('user_id', $userModel->id);
     if (empty($wwModel)) {
         $wwModel = new \GO\Base\Model\WorkingWeek();
     }
     $wwModel->user_id = $userModel->id;
     $params = array('mo_work_hours' => $submitParams['mo_work_hours'], 'tu_work_hours' => $submitParams['tu_work_hours'], 'we_work_hours' => $submitParams['we_work_hours'], 'th_work_hours' => $submitParams['th_work_hours'], 'fr_work_hours' => $submitParams['fr_work_hours'], 'sa_work_hours' => $submitParams['sa_work_hours'], 'su_work_hours' => $submitParams['su_work_hours']);
     $wwModel->setAttributes($params);
     if (!$wwModel->save()) {
         $validationErrors = $wwModel->getValidationErrors();
         throw new \Exception(\GO::t('couldNotSaveWW', 'leavedays') . ' ' . implode(', ', $validationErrors));
     }
 }