/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new LeaveRequest(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['LeaveRequest'])) { $model->attributes = $_POST['LeaveRequest']; $model->employee_id = getUser()->employee_id; $model->status = 'request'; if ($_POST['action'] == 'draft') { $model->status = 'draft'; } if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new LeaveRequest(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['LeaveRequest'])) { $model->attributes = $_POST['LeaveRequest']; $model->status = 'draft'; if ($_POST['command'] == 'save') { $model->approval_by_hr = 'approved'; $model->approval_by_hr_time = date('Y-m-d H:i:s'); $model->status = 'approved'; } if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Modify Overlap leave request * @param LeaveRequest $leaveRequest * @return boolean */ public function xmodifyOverlapLeaveRequest(LeaveRequest $leaveRequest, $leaveList, $leavePeriod = null) { try { $nextLeavePeriod = false; $nextLeaveRequest = false; if ($leavePeriod == null) { $leavePeriod = Doctrine::getTable('LeavePeriod')->find($leaveRequest->getLeavePeriodId()); } foreach ($leaveList as $leave) { if ($leave->getLeaveDate() > $leavePeriod->getEndDate()) { if (!$nextLeavePeriod instanceof LeavePeriod) { $leavePeriodService = new LeavePeriodService(); $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao()); $nextLeavePeriod = $leavePeriodService->createNextLeavePeriod($leave->getLeaveDate()); $nextLeaveRequest = new LeaveRequest(); $idGenService = new IDGeneratorService(); $idGenService->setEntity($leaveRequest); $nextLeaveRequest->setLeaveRequestId($idGenService->getNextID()); $nextLeaveRequest->setLeaveTypeId($leaveRequest->getLeaveTypeId()); $nextLeaveRequest->setDateApplied($leaveRequest->getDateApplied()); $nextLeaveRequest->setLeavePeriodId($nextLeavePeriod->getLeavePeriodId()); $nextLeaveRequest->setLeaveTypeName($leaveRequest->getLeaveTypeName()); $nextLeaveRequest->setEmpNumber($leaveRequest->getEmpNumber()); $nextLeaveRequest->setLeaveComments($leaveRequest->getLeaveComments()); $nextLeaveRequest->save(); } $q = Doctrine_Query::create()->update('Leave l')->set('l.leave_request_id=', $nextLeaveRequest->getLeaveRequestId())->where('l.leave_id = ?', $leave->getLeaveId()); $q->execute(); } } return true; } catch (Exception $e) { throw new DaoException($e->getMessage()); } }