Exemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Pasien();
     $model->scenario = 'baru';
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Pasien'])) {
         $model->attributes = $_POST['Pasien'];
         $model->setAttribute('BIAYA_REGISTRASI', '5000');
         $model->setAttribute('TANGGAL_REGISTRASI', date('Y-m-d H:i:s'));
         if ($model->save()) {
             Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             $this->redirect(array('view', 'id' => $model->ID_PASIEN));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 2
0
 public function actionIndex()
 {
     $id = Yii::app()->user->idUser;
     $model = User::model()->findByPk($id);
     // if(isset($_POST['User']))
     // {
     // 	$model->attributes=$_POST['User'];
     // 	// $new_password = $_POST['User']['NEW_PASSWORD'];
     // 	// $repeat_password = $_POST['User']['REPEAT_PASSWORD'];
     // 	if ($model->validate()) {
     // 		// if ($model->cekPassword($new_password,$repeat_password)) {
     // 			// $model->setAttribute('PASSWORD',$_POST['User']['NEW_PASSWORD']);
     // 			if ($model->save()) {
     //                    Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Perubahan data telah berhasil disimpan.'));
     // 				$this->redirect(array('index'));
     //                }
     //                // else
     //                    // Yii::app()->user->setFlash('info', MyFormatter::alertError('<strong>Error!</strong> Password gagal diubah.'));
     // 		}
     // 		// else {
     //                   // Yii::app()->user->setFlash('info', MyFormatter::alertError('<strong>Error!</strong> Password tidak cocok.'));
     //               // }
     // 	// }
     // 	// if($model->save()) {
     // 	// 	Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Perubahan data telah berhasil disimpan.'));
     // 	// 	$this->redirect(array('index','id'=>$model->ID_USER));
     // 	// }
     // }
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         //$model->STATUS = 1;
         if ($model->save()) {
             Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Perubahan data telah berhasil disimpan.'));
             $this->redirect(array('index'));
         }
     }
     $this->render('index', array('model' => $model));
 }
Exemplo n.º 3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     //inisialisasi model Order
     $order = new Order('search');
     $order->unsetAttributes();
     // clear any default values
     if (isset($_GET['Order'])) {
         $order->attributes = $_GET['Order'];
     }
     $orderbaru = new Order('baru');
     $orderbaru->RESEP = 1;
     $orderbaru->orderdetail = new OrderDetail('baru');
     //inisialisasi model OrderDetail
     $order_detail = new OrderDetail();
     //inisialisasi model Pelanggan
     $pelanggan = new Pasien('search');
     $pelanggan->unsetAttributes();
     // clear any default values
     if (isset($_GET['Pasien'])) {
         $pelanggan->attributes = $_GET['Pasien'];
     }
     $newpl = new Pasien('baru');
     $newpl->ID_LAYANAN = 1;
     if (isset($_POST['Pasien'])) {
         $newpl->attributes = $_POST['Pasien'];
         $newpl->BIAYA_REGISTRASI = 5000;
         $newpl->TANGGAL_REGISTRASI = date('Y-m-d H:i:s');
         if ($newpl->save()) {
             Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             $this->redirect(array('/site'));
         }
     }
     if (isset($_POST['Order'])) {
         $orderbaru->attributes = $_POST['Order'];
         $orderbaru->TANGGAL_ORDER = date('Y-m-d H:i:s');
         $orderbaru->USER_PEMBUAT = Yii::app()->user->nama;
         if ($orderbaru->validate()) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 if (!$orderbaru->save()) {
                     throw new Exception();
                 }
                 $subtotal = 0;
                 foreach ($_POST['OrderDetail'] as $kd => $detail) {
                     if (!empty($detail['JUMLAH'])) {
                         $od = new OrderDetail('baru');
                         $od->ID_ITEM = $kd;
                         $od->KODE_ORDER = $orderbaru->KODE_ORDER;
                         //proses harga by resep
                         $od->HARGA = Item::getHargaByResep($kd, $orderbaru->RESEP);
                         $od->JUMLAH = $detail['JUMLAH'];
                         $od->DISKON = $detail['DISKON'];
                         //$od->DISKON = Barang::getDiskonById($kd);
                         //update stok barang
                         Item::updateStokItem($kd, $detail['JUMLAH']);
                         $subtotal += $od->JUMLAH * $od->HARGA;
                         if (!$od->save()) {
                             throw new Exception();
                         }
                     }
                 }
                 $transaction->commit();
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             } catch (Exception $ex) {
                 $transaction->rollback();
                 echo $ex->getMessage();
                 exit;
             }
         }
     }
     // $dataProvider=new CActiveDataProvider('Pasien',array(
     // 	'pagination'=>false,
     // ));
     $this->render('create', array('order' => $order, 'order_detail' => $order_detail, 'pelanggan' => $pelanggan, 'pelanggan_baru' => $newpl, 'orderbaru' => $orderbaru));
 }
Exemplo n.º 4
0
 public function actionIndex()
 {
     if (!WebUser::isGuest() && WebUser::isAdmin()) {
         $this->render('index');
     } elseif (!WebUser::isGuest() && WebUser::isKasir()) {
         //inisialisasi model Order
         $order = new Order('search');
         $order->unsetAttributes();
         // clear any default values
         if (isset($_GET['Order'])) {
             $order->attributes = $_GET['Order'];
         }
         $orderbaru = new Order('baru');
         $orderbaru->RESEP = 1;
         $orderbaru->orderdetail = new OrderDetail('baru');
         //inisialisasi model OrderDetail
         $order_detail = new OrderDetail();
         //inisialisasi model Pelanggan
         $pelanggan = new Pasien('search');
         $pelanggan->unsetAttributes();
         // clear any default values
         if (isset($_GET['Pasien'])) {
             $pelanggan->attributes = $_GET['Pasien'];
         }
         $newpl = new Pasien('baru');
         // $newpl->ID_LAYANAN = 1;
         if (isset($_POST['Pasien'])) {
             $newpl->attributes = $_POST['Pasien'];
             //$newpl->BIAYA_REGISTRASI = 5000;
             $newpl->TANGGAL_REGISTRASI = date('Y-m-d H:i:s');
             if ($newpl->save()) {
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/site'));
             }
         }
         if (isset($_POST['Order'])) {
             //var_dump($_POST['Order']);
             //die();
             $orderbaru->attributes = $_POST['Order'];
             $orderbaru->TANGGAL_ORDER = date('Y-m-d H:i:s');
             $orderbaru->USER_PEMBUAT = Yii::app()->user->nama;
             if ($orderbaru->save()) {
                 $subtotal = 0;
                 foreach ($_POST['OrderDetail'] as $detail) {
                     //var_dump($_POST['OrderDetail']);
                     //die();
                     $od = new OrderDetail('baru');
                     $od->ID_ITEM = $detail['ID_ITEM'];
                     $od->KODE_ORDER = $orderbaru->KODE_ORDER;
                     //proses harga by resep
                     $od->HARGA = Item::getHargaByResep($detail['ID_ITEM'], $orderbaru->RESEP);
                     $od->JUMLAH = $detail['JUMLAH'];
                     $od->DISKON = $detail['DISKON'];
                     $od->save();
                     Item::updateStokItem($detail['ID_ITEM'], $detail['JUMLAH']);
                     $subtotal += $od->JUMLAH * $od->HARGA;
                 }
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             }
             // if ($orderbaru->validate()) {
             //     $transaction = Yii::app()->db->beginTransaction();
             //     try {
             //         if (!$orderbaru->save())
             //             throw new Exception;
             //         $subtotal = 0;
             //         foreach ($_POST['OrderDetail'] as $kd => $detail) {
             //             if (!empty($detail['JUMLAH'])) {
             //                 $od = new OrderDetail('baru');
             //              $od->ID_ITEM = $kd;
             //              $od->KODE_ORDER = $orderbaru->KODE_ORDER;
             //              //proses harga by resep
             //              $od->HARGA = Item::getHargaByResep($kd, $orderbaru->RESEP);
             //              $od->JUMLAH = $detail['JUMLAH'];
             //              //$od->DISKON = $detail['DISKON'];
             //              //$od->DISKON = Barang::getDiskonById($kd);
             //              //var_dump($_POST['OrderDetail']);
             // 	//die();
             //              //update stok barang
             //              Item::updateStokItem($kd, $detail['JUMLAH']);
             //              $subtotal += $od->JUMLAH * $od->HARGA;
             //                 if (!$od->save())
             //                     throw new Exception;
             //             }
             //         }
             //         $transaction->commit();
             //         Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             //         $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             //     } catch (Exception $ex) {
             //         $transaction->rollback();
             //         echo $ex->getMessage(); exit();
             //     }
             // }
         }
         $criteria = new CDbCriteria();
         $criteria->order = 'TANGGAL_REGISTRASI DESC';
         $dataProvider = new CActiveDataProvider('Pasien', array('criteria' => $criteria, 'pagination' => false));
         $pasien_today = Pasien::listRegisterToday();
         $this->render('index3', array('dataProvider' => $dataProvider, 'order' => $order, 'order_detail' => $order_detail, 'pelanggan' => $pelanggan, 'pelanggan_baru' => $newpl, 'orderbaru' => $orderbaru, 'pasien_today' => $pasien_today));
     } else {
         $this->redirect(array('login'));
     }
 }
Exemplo n.º 5
0
 public function actionStep($id)
 {
     DetilItem::model()->updateByPk($id, array('STATUS_PEMBAYARAN' => DetilItem::STATUS_LUNAS, 'TANGGAL_PEMBAYARAN' => date('Y-m-d')));
     $item = DetilItem::model()->findByPk($id);
     Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Sukses!</strong> Data telah berhasil disimpan.'));
     //$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
     $this->redirect(array('view', 'id' => $item->ID_ITEM));
 }