예제 #1
0
 /**
  * Store a payment notes
  * 
  * 1. Check transaction
  * 2. Check input
  * 3. Store Payment
  * 4. Check response
  * 5. Generate view
  * @param id
  * @return object view
  */
 public function store($id = null)
 {
     //1. Check transaction
     if (Input::has('transaction_id')) {
         $saleid = Input::get('transaction_id');
     } else {
         \App::abort(404);
     }
     $APISale = new APISale();
     $prev_sale = $APISale->getShow($saleid);
     if ($prev_sale['status'] != 'success') {
         $this->errors = $prev_sale['message'];
         return $this->generateRedirectRoute('shop.pay.create');
     }
     $sale = $prev_sale['data'];
     //2. Check input
     $inputPayment = Input::only('method', 'destination', 'account_name', 'account_number');
     $inputPayment['id'] = '';
     $inputPayment['amount'] = $sale['bills'];
     $inputPayment['ondate'] = date('Y-m-d H:i:s', strtotime(Input::get('ondate')));
     $sale['payment'] = $inputPayment;
     $sale['status'] = 'paid';
     //3. Store Payment
     $result = $APISale->postData($sale);
     //4. Check response
     if ($result['status'] != 'success') {
         $this->errors = $result['message'];
     } else {
         $mail = new APISendMail();
         $mail->paidorder($result['data'], $this->balininfo());
     }
     //5. Generate view
     $this->page_attributes->success = ['title' => 'Pesanan sudah divalidasi. ', 'action' => route('report.product.sale.detail', ['id' => $saleid]), 'actionTitle' => 'Klik disini untuk melihat Invoice barang.'];
     return $this->generateRedirectRoute('admin.dashboard', ['tab' => 'toko']);
 }
 /**
  * Store a delivered order
  * 
  * 1. Check transaction
  * 2. Check input
  * 3. Store transaction
  * 4. Check response
  * 5. Generate view
  * @param id
  * @return object view
  */
 public function store($id = null)
 {
     //1. Check transaction
     if (Input::has('transaction_id')) {
         $saleid = Input::get('transaction_id');
     } else {
         \App::abort(404);
     }
     $APISale = new APISale();
     $prev_sale = $APISale->getShow($saleid);
     if ($prev_sale['status'] != 'success') {
         $this->errors = $prev_sale['message'];
         return $this->generateRedirectRoute('shop.shipping.create');
     }
     $sale = $prev_sale['data'];
     //2. Check input
     $sale['status'] = 'delivered';
     $sale['notes'] = 'Diterima Oleh ' . Input::get('notes');
     //3. Store Transction
     $result = $APISale->postData($sale);
     //4. Check response
     if ($result['status'] != 'success') {
         $this->errors = $result['message'];
     } else {
         $mail = new APISendMail();
         $mail->deliveredorder($result['data'], $this->balininfo());
     }
     //5. Generate view
     $this->page_attributes->success = ['title' => 'Pesanan sudah diterima pembeli. ', 'action' => route('report.product.sale.detail', ['id' => $saleid]), 'actionTitle' => 'Klik disini untuk melihat Invoice barang.'];
     return $this->generateRedirectRoute('admin.dashboard', ['tab' => 'toko']);
 }
 /**
  * resend sale
  * 
  * @return redirect
  */
 public function sale($id = 0, $status = '')
 {
     $APISale = new APISale();
     $result = $APISale->getShow($id);
     if ($result['status'] != 'success') {
         $this->errors = $result['message'];
     }
     $type = 'Email';
     $mail = new APISendMail();
     switch ($status) {
         case 'wait':
             $mail->invoice($result['data'], $this->balininfo());
             $type = 'Invoice';
             break;
         case 'paid':
             $mail->paidorder($result['data'], $this->balininfo());
             $type = 'Validasi Pembayaran';
             break;
         case 'shipping':
             $mail->shippingorder($result['data'], $this->balininfo());
             $type = 'Nota Pengiriman';
             break;
         case 'delivered':
             $mail->deliveredorder($result['data'], $this->balininfo());
             $type = 'Konfirmasi Pesanan Delivered';
             break;
         case 'canceled':
             $mail->cancelorder($result['data'], $this->balininfo());
             $type = 'Konfirmasi Pembatalan Pesanan';
             break;
         case 'abandoned':
             $mail->abandoned($result['data'], $this->balininfo());
             $type = 'Email Pengingat';
             break;
         default:
             $this->errors = 'Status tidak valid';
             break;
     }
     $this->page_attributes->success = $type . " sudah di kirim ";
     $from = Input::get('from');
     if ($from != null) {
         return Redirect::to($from)->with('msg', 'Email pengingat berhasil dikirim.')->with('msg-type', 'success');
     }
     return $this->generateRedirectRoute('report.product.sale', ['id' => $id]);
 }
 public function show($id)
 {
     //1. Get data from API
     $APISale = new APISale();
     $sale = $APISale->getShow($id);
     //2. Check return status
     if ($sale['status'] != 'success') {
         $this->errors = $sale['message'];
         return $this->generateRedirectRoute('report.product.cancel');
     }
     $this->page_attributes->subtitle = $sale['data']['ref_number'];
     $this->page_attributes->data = ['sale' => $sale];
     //3. Generate breadcrumb
     $breadcrumb = ['Laporan Transaksi Batal' => route('report.product.cancel'), $sale['data']['ref_number'] => route('report.product.cancel.detail', ['id' => $id])];
     $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, $breadcrumb);
     //4. Generate view
     $this->page_attributes->source = $this->page_attributes->source . 'show';
     return $this->generateView();
 }
 /**
  * Store a packing transaction
  * 
  * 1. Check transaction
  * 2. Check input
  * 3. Store transaction
  * 4. Check response
  * 5. Generate view
  * @param id
  * @return object view
  */
 public function store($id = null)
 {
     //1. Check transaction
     if (Input::has('transaction_id')) {
         $saleid = Input::get('transaction_id');
     } else {
         \App::abort(404);
     }
     $APISale = new APISale();
     $prev_sale = $APISale->getShow($saleid);
     $sale = $prev_sale['data'];
     //2. Check input
     $sale['status'] = 'packed';
     //3. Store transaction
     $result = $APISale->postData($sale);
     //4. Check response
     if ($result['status'] != 'success') {
         $this->errors = $result['message'];
     }
     //5. Generate view
     //5. Generate view
     $this->page_attributes->success = ['title' => 'Pesanan sudah dipacking! ', 'action' => route('report.product.sale.detail', ['id' => $saleid]), 'actionTitle' => 'Klik disini untuk melihat Invoice barang.'];
     return $this->generateRedirectRoute('admin.dashboard', ['tab' => 'toko']);
 }