Esempio n. 1
0
 /**
  * Simpan Departement
  * (New Departement)
  *
  * @return mixed
  */
 public function save()
 {
     $this->departement->name = Input::get('name');
     $this->departement->info = Input::get('info');
     $this->departement->uuid = uniqid('New_');
     $this->departement->createby_id = Auth::user()->id;
     $this->departement->lastupdateby_id = Auth::user()->id;
     $this->departement->created_at = new Carbon();
     $this->departement->updated_at = new Carbon();
     $saved = $this->departement->save() ? true : false;
     return Response::json(array('success' => $saved, 'results' => $this->departement->toArray()))->setCallback();
 }
 /**
  * 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->aDept !== null) {
             if ($this->aDept->isModified() || $this->aDept->isNew()) {
                 $affectedRows += $this->aDept->save($con);
             }
             $this->setDept($this->aDept);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Dept();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Dept'])) {
         $model->attributes = $_POST['Dept'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Esempio n. 4
0
 public function actionCreate()
 {
     $this->hasPrivilege(Acl::ACTION_CREATE);
     $this->pageTitle = Lang::t('Add ' . $this->resourceLabel);
     $model = new Dept();
     $model_class_name = $model->getClassName();
     if (isset($_POST[$model_class_name])) {
         $model->attributes = $_POST[$model_class_name];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Lang::t('Department saved successfully. Now create the contact person.'));
             $this->redirect(Yii::app()->createUrl('users/default/create', array('dept_id' => $model->id, Controller::GET_PARAM_RETURN_URL => $this->createUrl('view', array('id' => $model->id)))));
         }
     }
     $this->render('default/create', array('model' => $model));
 }
 static function create($vars, &$errors)
 {
     return Dept::save(0, $vars, $errors);
 }
Esempio n. 6
0
 /**
  * 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->aDept !== null) {
             if ($this->aDept->isModified() || $this->aDept->isNew()) {
                 $affectedRows += $this->aDept->save($con);
             }
             $this->setDept($this->aDept);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->sectionsScheduledForDeletion !== null) {
             if (!$this->sectionsScheduledForDeletion->isEmpty()) {
                 SectionQuery::create()->filterByPrimaryKeys($this->sectionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->sectionsScheduledForDeletion = null;
             }
         }
         if ($this->collSections !== null) {
             foreach ($this->collSections as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Esempio n. 7
0
 /**
  * Handler for add new dept
  */
 public function actionAddDept()
 {
     $user = $_REQUEST['user'][0];
     $sum = $_REQUEST['sum'][0];
     $comment = $_REQUEST['comment'][0];
     $date = $_REQUEST['date'][0];
     $time = $_REQUEST['time'][0];
     $attributs = array();
     if ($user != '') {
         $attributs['user_id'] = $user;
     }
     if ($sum != '') {
         $attributs['sum'] = $sum;
     }
     if ($comment != '') {
         $attributs['comment'] = $comment;
     }
     if ($date != '' && $time != '') {
         $attributs['comment'] = $date . ' ' . $time;
     }
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
         $attributs['id'] = $id;
     }
     $dept = new Dept($attributs);
     $dept->save();
     $id = $dept->getId();
     $this->showResponse(array('status' => true, 'id' => $id));
 }