/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Designation(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Designation'])) { $model->attributes = $_POST['Designation']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function store() { $designation = new Designation(); $designation->designation = Input::get('designationName'); if ($designation->save()) { return Redirect::to('/designation')->with('success', 'Successfully created a designation'); } else { $m1 = $designation->validationErrors->first('designation'); if ($m1 != 'The designation has already been taken.') { $message = "Invalid input for designation name."; Session::put('main_error', $message); } return Redirect::back()->withInput()->withErrors($this->designation->errors)->with('invalid', $message); } }
public function executeAdd(sfWebRequest $request) { if ($request->isMethod('Post')) { $department_id = $this->getRequestParameter('department_id'); if (!$department_id) { $this->getUser()->setFlash('ERROR_MESSAGE', 'Department cannot be empty, please Add New Department'); $this->redirect('Designation/list'); } else { $designation = new Designation(); $designation->setDepartmentId($this->getRequestParameter('department_id')); $designation->setTitle($this->getRequestParameter('title')); //$designation->setDescription($this->getRequestParameter('description')); $designation->setStatus(Constant::RECORD_STATUS_ACTIVE); $designation->save(); $this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::RECORD_ADDED_SUCCESSFULLY); $this->redirect('Designation/list'); } } //end if }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aDepartment !== null) { if ($this->aDepartment->isModified() || $this->aDepartment->isNew()) { $affectedRows += $this->aDepartment->save($con); } $this->setDepartment($this->aDepartment); } if ($this->aDesignation !== null) { if ($this->aDesignation->isModified() || $this->aDesignation->isNew()) { $affectedRows += $this->aDesignation->save($con); } $this->setDesignation($this->aDesignation); } if ($this->aRole !== null) { if ($this->aRole->isModified() || $this->aRole->isNew()) { $affectedRows += $this->aRole->save($con); } $this->setRole($this->aRole); } if ($this->isNew()) { $this->modifiedColumns[] = EmployeePeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = EmployeePeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += EmployeePeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collDutyRostersRelatedByEmployeeId !== null) { foreach ($this->collDutyRostersRelatedByEmployeeId as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collDutyRostersRelatedBySubstituteId !== null) { foreach ($this->collDutyRostersRelatedBySubstituteId as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collUsers !== null) { foreach ($this->collUsers as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collVisitsRelatedByDoctorId !== null) { foreach ($this->collVisitsRelatedByDoctorId as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collVisitsRelatedByWardDocId !== null) { foreach ($this->collVisitsRelatedByWardDocId as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
public function postSavedesignation() { $desig = new Designation(); $desig->name = Input::get('desig'); $desig->save(); return Response::json($desig); }