public function save() { $resultArray = array(); $jobTitle = $this->getValue('jobTitle'); $jobDescription = $this->getValue('jobDescription'); $note = $this->getValue('note'); $jobSpec = $this->getValue('jobSpec'); $jobSpecUpdate = $this->getValue('jobSpecUpdate'); if (!empty($this->jobTitleId)) { $jobTitleObj = $this->getJobTitleService()->getJobTitleById($this->jobTitleId); $attachment = $jobTitleObj->getJobSpecificationAttachment(); if (!empty($attachment) && $jobSpecUpdate != self::CONTRACT_KEEP) { $attachment->delete(); } $resultArray['messageType'] = 'success'; $resultArray['message'] = __(TopLevelMessages::UPDATE_SUCCESS); } else { $jobTitleObj = new JobTitle(); $resultArray['messageType'] = 'success'; $resultArray['message'] = __(TopLevelMessages::SAVE_SUCCESS); } $jobTitleObj->setJobTitleName($jobTitle); $jobTitleObj->setJobDescription($jobDescription); $jobTitleObj->setNote($note); if (!empty($jobSpec)) { $jobTitleObj->setJobSpecificationAttachment($this->__getJobSpecAttachmentObj()); } else { $jobTitleObj->setJobSpecificationAttachment(null); } $jobTitleObj->save(); return $resultArray; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new JobTitle(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['JobTitle'])) { $model->attributes = $_POST['JobTitle']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->job_title_id)); } } $this->render('create', array('model' => $model)); }
$employeeInfo = $employee->getEmployeeInfoById($employeeId); return View::make('admin.jobtitlenew', ['employeeInfo' => $employeeInfo]); })); //CREATE: new JobTitle Route::post('/admin/jobtitle/new', array('as' => 'adminProcessNewJobTitle', 'uses' => function () { //return 'Save New Job Title'; $data = Input::all(); $rules = array('job_title_name' => 'required'); $validator = Validator::make($data, $rules); if ($validator->fails()) { $messages = $validator->messages(); return Redirect::to('/admin/jobtitle/new')->withErrors($validator); } else { $JobTitle = new JobTitle(); $JobTitle->name = trim(ucwords($data['job_title_name'])); if ($JobTitle->save()) { $message = 'Created Successfully.'; return Redirect::to('/admin/jobtitle/new')->with('message', $message); } } })); //UPDATE: EXISTING DEPARTMENT Route::get('/admin/jobtitle/edit/{id}', array('as' => 'adminEditJobTitle', 'uses' => function ($id) { $id = (int) $id; $employeeId = Session::get('userEmployeeId'); $userId = Session::get('userId'); $employee = new Employee(); $employeeInfo = $employee->getEmployeeInfoById($employeeId); //return 'Update Department'; return View::make('admin.jobtitleedit', array('id' => $id, 'employeeInfo' => $employeeInfo)); }));