Exemplo n.º 1
0
 public function actionCreateExisting($id)
 {
     $model = new Jual();
     $model2 = new Obat();
     $model3 = new ListPenjualan();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Obat'])) {
         $model->tgltrans = date('Y-m-d');
         $model->save();
         $model3->id_jual = $id;
         $id_obat = $_POST['Obat']['id_obat'];
         $result_nama = Yii::app()->db->createCommand("SELECT nama FROM obat WHERE `id_obat`= '{$id_obat}'")->queryAll();
         $nama = $result_nama["0"]["nama"];
         $result_harga_satuan = Yii::app()->db->createCommand("SELECT hargajual FROM obat WHERE `id_obat`= '{$id_obat}'")->queryAll();
         $harga_satuan = $result_harga_satuan["0"]["hargajual"];
         $total_harga = $_POST['Obat']['jumlah'] * $harga_satuan;
         $model3->nama_obat = $nama;
         $model3->qty = $_POST['Obat']['jumlah'];
         $model3->harga_satuan = $harga_satuan;
         $model3->total = $total_harga;
         $model3->id_obat = $id_obat;
         if ($model3->save()) {
             $this->redirect(array('createExisting', 'id' => $id));
         }
     }
     $this->render('createExisting', array('model' => $model, 'model2' => $model2, 'id' => $id));
 }
Exemplo n.º 2
0
 public function actionCreateKeteranganExisting($id, $keterangan)
 {
     $model = new Jual();
     $model2 = new Obat();
     $model3 = new ListPenjualan();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Obat'])) {
         if ($_POST['Obat']['jumlah'] == 0) {
             $this->redirect(array('CreateKeteranganExisting', 'id' => $id, 'keterangan' => $keterangan));
         }
         $model3->id_jual = $id;
         $id_obat = $_POST['Obat']['id_obat'];
         $result_nama = Yii::app()->db->createCommand("SELECT nama FROM obat WHERE `id_obat`= '{$id_obat}'")->queryAll();
         $nama = $result_nama["0"]["nama"];
         $result_harga_satuan = Yii::app()->db->createCommand("SELECT hargajual FROM obat WHERE `id_obat`= '{$id_obat}'")->queryAll();
         $harga_satuan = $result_harga_satuan["0"]["hargajual"];
         $total_harga = $_POST['Obat']['jumlah'] * $harga_satuan;
         $model3->nama_obat = $nama;
         $model3->qty = $_POST['Obat']['jumlah'];
         $model3->harga_satuan = $harga_satuan;
         $model3->total = $total_harga;
         $model3->id_obat = $id_obat;
         $model3->keterangan = $keterangan;
         if ($model3->save()) {
             $connection_delete = Yii::app()->db;
         }
         $connection_delete->createCommand("DELETE FROM dummy_list_obat WHERE id_obat='{$id_obat}'")->execute();
         $this->redirect(array('CreateKeteranganExisting', 'id' => $id, 'keterangan' => $keterangan));
     }
     $this->render('createKeteranganExisting', array('model' => $model, 'model2' => $model2, 'id' => $id, 'keterangan' => $keterangan));
 }
Exemplo n.º 3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ListPenjualan::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }