Ejemplo n.º 1
0
 /**
  * view data order / detail data order
  */
 public function actionView($id)
 {
     /* untuk cek login admin */
     IsAuth::Admin();
     /* panggil function loadModel() 
      * dan ditampung ke $dataOrder */
     $dataOrder = $this->loadModel($id);
     /* find data confirmpayment berdasarkan order_code */
     $dataConfirmPayment = ConfirmPayment::model()->findByAttributes(array('order_code' => $dataOrder->order_code));
     /* find data alamat pengiriman berdasarkan id_address */
     $dataShippingAddress = AddressBook::model()->findByPk($dataOrder->address_book_id);
     /* panggil model Orderdetail dan function search */
     $model = new Orderdetail('search');
     /* clear any default values */
     $model->unsetAttributes();
     /* set select data order_detail berdasarkan order_code */
     $model->order_code = $dataOrder->order_code;
     /* render ke file views/orders/view */
     $this->render('view', array('model' => $dataOrder, 'ordet' => $model, 'dataPayment' => $dataConfirmPayment, 'shippingAddress' => $dataShippingAddress));
 }
Ejemplo n.º 2
0
 public function actionOrders($id = '')
 {
     IsAuth::Customer();
     /* untuk konfirmasi pembayaran */
     if (isset($_GET['confirm'])) {
         /* panggil model Confirmpayment */
         $model = new ConfirmPayment();
         /* jika data Confirmpayment dikirim dengan method POST */
         if (isset($_POST['ConfirmPayment'])) {
             /* set value field */
             $order_code = $_POST['ConfirmPayment']['nomerPemesanan'];
             $model->attributes = $_POST['ConfirmPayment'];
             $model->order_code = $_POST['ConfirmPayment']['nomerPemesanan'];
             $model->text_detail .= $_POST['ConfirmPayment']['bankAsal'] . '#';
             $model->text_detail .= $_POST['ConfirmPayment']['pemilikRekAsal'] . '#';
             $model->text_detail .= $_POST['ConfirmPayment']['bankTujuan'] . '#';
             $model->text_detail .= $_POST['ConfirmPayment']['nominalTransfer'];
             /* jika data confirmpayment disimpan */
             if ($model->save()) {
                 /* find data order by attributes berdasarkan order code */
                 $modelOrder = Order::model()->findByAttributes(array('order_code' => $order_code));
                 /* set field payment_status menjadi 1 
                  * yg artinya telah pembayaran telah dikonfirmasi */
                 $modelOrder->payment_status = 1;
                 /* simpan perubahan */
                 $modelOrder->save();
                 /* setFlash untuk informasi sukses konfirmasi pesanan */
                 Yii::app()->user->setFlash('success', "Your order with order code #" . $order_code . " has been confirmed...");
                 /* direct ke halaman orders */
                 $this->redirect(array('orders'));
                 return;
             }
         }
         /* render ke file account/confirmasi_payment */
         $this->render('confirm_payment', array('model' => $model));
         return;
     }
     /* untuk halaman list data pesanan */
     if (empty($id)) {
         /* panggil model Order dan function search */
         $model = new Order('search');
         // hapus default values pada attributes
         $model->unsetAttributes();
         $model->customer_id = Yii::app()->user->customerId;
         /* jika data order dikirim view get */
         if (isset($_GET['Order'])) {
             /* set attributes untuk pencarian */
             $model->attributes = $_GET['Order'];
         }
         /* render ke file account/list_orders */
         $this->render('list_orders', array('model' => $model));
         return;
     }
     /* untuk detail order */
     if (!empty($id)) {
         /* join query untuk mendapatkan detail order */
         $dataOrderDetail = Yii::app()->db->createCommand()->select('order.*,orderdetail.*,product.*')->from('order')->join('orderdetail', 'orderdetail.order_id = order.order_id')->join('product', 'product.product_id = orderdetail.product_id')->where('order.order_id=:order_id', array(':order_id' => $id))->queryAll();
         /* join query untuk mendapatkan data order 
          * dan customer/pelanggan */
         $dataOrder = Yii::app()->db->createCommand()->select('order.*,customer.customer_name')->from('order')->join('customer', 'order.customer_id = customer.customer_id')->where('order.order_id=:order_id', array(':order_id' => $id))->queryRow();
         /* render ke file account/detail_order */
         $this->render('detail_order', array('dataOrder' => $dataOrder, 'orderDetail' => $dataOrderDetail, 'subtotal' => '', 'grandtotal' => ''));
         return;
     }
 }