Example #1
0
 public function save()
 {
     if (Request::ajax()) {
         $data = new Kategori();
         $data->cat_nama = Input::get("kategori");
         $data->save();
         return "berhasil";
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Kategori();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Kategori'])) {
         $model->attributes = $_POST['Kategori'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validasi = Validator::make(Input::all(), Kategori::$rules, Kategori::$pesan);
     if ($validasi->fails()) {
         return Redirect::back()->withInput()->withErrors($validasi);
     } else {
         $kategori = new Kategori();
         $kategori->nm_kategori = Input::get('nama');
         $kategori->save();
         Session::flash('pesan', "<div class='alert alert-info'>\n\t\t\t\tData Kategori Berhasil disimpan</div>");
         return Redirect::to('admin/kategori');
     }
 }
Example #4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Kategori();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Kategori'])) {
         $model->attributes = $_POST['Kategori'];
         if ($model->save()) {
             Yii::app()->user->setFlash('info', MyFormatter::alertInfo('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             $this->redirect(array('view', 'id' => $model->ID_KATEGORI));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validasi = Validator::make($input, Kategori::$rules, Kategori::$pesan);
     if ($validasi->fails()) {
         return Redirect::back()->withInput()->withErrors($validasi);
     } else {
         $kategori = new Kategori();
         $kategori->nm_kategori = Input::get('nama');
         if (Input::hasFile('icon')) {
             $file = Input::file('icon');
             $filename = str_random(5) . '-' . $file->getClientOriginalName();
             $destinationPath = 'uploads/icon/';
             $file->move($destinationPath, $filename);
             $kategori->icon = $filename;
         }
         $kategori->save();
         Session::flash('pesan', "<hr><div class='alert alert-info'>\n\t\t\t\tData Berhasil disimpan</div>");
         return Redirect::to('kategori');
     }
 }
Example #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 corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aKategori !== null) {
             if ($this->aKategori->isModified() || $this->aKategori->isNew()) {
                 $affectedRows += $this->aKategori->save($con);
             }
             $this->setKategori($this->aKategori);
         }
         if ($this->aKemasan !== null) {
             if ($this->aKemasan->isModified() || $this->aKemasan->isNew()) {
                 $affectedRows += $this->aKemasan->save($con);
             }
             $this->setKemasan($this->aKemasan);
         }
         if ($this->aProdusen !== null) {
             if ($this->aProdusen->isModified() || $this->aProdusen->isNew()) {
                 $affectedRows += $this->aProdusen->save($con);
             }
             $this->setProdusen($this->aProdusen);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->detailBarangMasuksScheduledForDeletion !== null) {
             if (!$this->detailBarangMasuksScheduledForDeletion->isEmpty()) {
                 DetailBarangMasukQuery::create()->filterByPrimaryKeys($this->detailBarangMasuksScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->detailBarangMasuksScheduledForDeletion = null;
             }
         }
         if ($this->collDetailBarangMasuks !== null) {
             foreach ($this->collDetailBarangMasuks as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->detailTransaksisScheduledForDeletion !== null) {
             if (!$this->detailTransaksisScheduledForDeletion->isEmpty()) {
                 DetailTransaksiQuery::create()->filterByPrimaryKeys($this->detailTransaksisScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->detailTransaksisScheduledForDeletion = null;
             }
         }
         if ($this->collDetailTransaksis !== null) {
             foreach ($this->collDetailTransaksis as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->hargasScheduledForDeletion !== null) {
             if (!$this->hargasScheduledForDeletion->isEmpty()) {
                 HargaQuery::create()->filterByPrimaryKeys($this->hargasScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->hargasScheduledForDeletion = null;
             }
         }
         if ($this->collHargas !== null) {
             foreach ($this->collHargas as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->linkBarangRaksScheduledForDeletion !== null) {
             if (!$this->linkBarangRaksScheduledForDeletion->isEmpty()) {
                 LinkBarangRakQuery::create()->filterByPrimaryKeys($this->linkBarangRaksScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->linkBarangRaksScheduledForDeletion = null;
             }
         }
         if ($this->collLinkBarangRaks !== null) {
             foreach ($this->collLinkBarangRaks as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->logBarangsScheduledForDeletion !== null) {
             if (!$this->logBarangsScheduledForDeletion->isEmpty()) {
                 LogBarangQuery::create()->filterByPrimaryKeys($this->logBarangsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->logBarangsScheduledForDeletion = null;
             }
         }
         if ($this->collLogBarangs !== null) {
             foreach ($this->collLogBarangs as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }