Esempio n. 1
0
 public function payment(Request $request)
 {
     $rules = array('no_invoice' => 'required', 'account_name' => 'required', 'bank_account' => 'required', 'bank_name' => 'required', 'admin_account' => 'required', 'total_transfer' => 'required', 'transfer_date' => 'required');
     $validator = Validator::make($request->all(), $rules);
     if (!$validator->fails()) {
         $order = Order::where('no_invoice', $request->no_invoice)->first();
         if (!is_null($order)) {
             $payment = new PaymentConfirmation();
             $payment->no_invoice = $order->no_invoice;
             $payment->account_name = $request->account_name;
             $payment->bank_account = $request->bank_account;
             $payment->bank_name = $request->bank_name;
             $payment->admin_account = $request->admin_account;
             $payment->total_transfer = $request->total_transfer;
             $payment->transfer_date = $request->transfer_date;
             $payment->order_id = $order->id;
             $payment->save();
             $order->order_status = "Telah Dibayar";
             $order->save();
             $orderdetail = OrderDetail::where('order_id', $order->id)->get();
             foreach ($orderdetail as $detail) {
                 $product = Product::where('id', $detail->product_id)->first();
                 $product->sold += $detail->quantity;
                 $product->save();
             }
             return redirect('konfirmasi_pembayaran')->with('success', 'Konfirmasi berhasil .Kami akan mengecek pembayaran Anda');
         } else {
             return redirect('konfirmasi_pembayaran')->with('failed', 'Maaf no invoice tidak terdaftar');
         }
     } else {
         return redirect('konfirmasi_pembayaran')->with('failed', 'Silahkan isi form sesuai yang disediakan');
     }
 }
 public function payment_list()
 {
     $this->data['css_assets'] = Assets::load('css', ['admin_bootstrap', 'admin_css', 'font-awesome', 'skins', 'dataTables_css']);
     $this->data['js_assets'] = Assets::load('js', ['jquery', 'admin_js', 'admin_bootstrap-js', 'slimscroll', 'fastclick', 'dataTables_js', 'dataTables_bootsjs']);
     $this->data['title'] = 'SayourShop | Pembayaran';
     $this->data['payment'] = PaymentConfirmation::orderBy('created_at', 'desc')->get();
     return view('admin_layout')->with('data', $this->data)->nest('content', 'admin/transaction/payment', array('data' => $this->data));
 }
Esempio n. 3
0
 public function delete($id)
 {
     $product = Product::find($id);
     $category = Category::where('id', $product->category_id)->first();
     $inOrder = OrderDetail::where('product_id', $id)->where('review', null)->get();
     $reviews = Reviews::where('product_id', $id)->get();
     $subcategory = Subcategory::where('id', $product->subcategory_id)->first();
     if (!$product) {
         return redirect('master/produk/list')->with('error', 'Data tidak ada');
     } else {
         $image = unserialize($product->image);
         $path = base_path() . '/storage/photo_product/';
         if (count($inOrder) > 0) {
             $product->status = 'unactive';
             if ($product->save()) {
                 return redirect('master/produk/list')->with('success', 'Produk tidak bisa di hapus karena masih dalam order, produk sementara di non aktifkan');
             } else {
                 return redirect('master/produk/list')->with('error', '404');
             }
         } elseif (count($inOrder) == 0) {
             if ($product->delete()) {
                 foreach ($reviews as $review) {
                     $reviews->delete();
                 }
                 foreach ($inOrder as $order_product) {
                     foreach ($order_product as $orders) {
                         $PaymentConfirmation = PaymentConfirmation::where('order_id', $orders->id)->first();
                         $PaymentConfirmation->delete();
                     }
                     $orders = Order::where('id', $order_product->order_id)->get();
                     $orders->delete();
                 }
                 $total_product = $category->total_product - 1;
                 $category->total_product = $total_product;
                 $category->save();
                 $total_subcategory = $subcategory->total_product - 1;
                 $subcategory->total_product = $total_subcategory;
                 $subcategory->save();
                 if (!$image == NULL) {
                     foreach ($image as $image) {
                         File::delete($path . $image);
                     }
                 }
                 return redirect('master/produk/list')->with('success', 'Produk ' . $product->name . ' Berhasil Dihapus');
             } else {
                 return redirect('master/produk/list')->with('error', '404');
             }
         }
     }
 }