コード例 #1
0
 public function saveCloseOrder(Request $request, $id)
 {
     $validator = Validator::make($request->all(), ['tanggal' => 'required|date', 'bayar' => 'required|numeric'], ['tanggal.required' => 'Tanggal tidak boleh kosong.', 'tanggal.bayar' => 'Input harus tanggal.', 'bayar.required' => 'Bayar tidak boleh kosong.', 'bayar.numeric' => 'Input harus angka.']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $orderTax = ['order_id' => $id, 'tax_id' => $request->get('tax_id'), 'procentage' => $request->get('tax_procentage')];
     if (OrderTax::create($orderTax)) {
         $orderBayar = ['order_id' => $id, 'karyawan_id' => Auth::check() ? Auth::user()->karyawan->id : '1', 'service_cost' => $request->get('service_cost'), 'diskon' => $request->get('diskon') != '' ? $request->get('diskon') : 0, 'bayar' => $request->get('bayar'), 'type_bayar' => $request->get('type_bayar')];
         if (OrderBayar::create($orderBayar)) {
             if ($request->get('type_bayar') == 'debit' || $request->get('type_bayar') == 'credit_card') {
                 $orderBayarBank = ['order_id' => $id, 'bank_id' => $request->get('bank_id')];
                 $orderBayarBank['tax_procentage'] = $request->get('tax_bayar_procentage');
                 OrderBayarBank::create($orderBayarBank);
             }
             $inputs = ['state' => 'Closed'];
             if ($request->get('customer_id') != "") {
                 $inputs['customer_id'] = $request->get('customer_id');
             }
             $order = Order::find($id);
             if ($order->update($inputs)) {
                 // Update Sale Account
                 Artisan::call('sale:count', ['tanggal' => $order->tanggal->format('Y-m-d')]);
                 Artisan::call('bahan:count');
                 Artisan::call('produk:count');
                 // Redirect
                 return redirect('/order/pertanggal/detail?id=' . $id)->with('succcess', 'Sukses Tutup Order');
             }
         }
     }
     return redirect()->back()->withErrors(['failed' => 'Gagal Tutup Order !!!']);
     withInput();
 }
コード例 #2
0
 public function closeTransaksi(Request $request)
 {
     \Debugbar::disable();
     $id = $request->get('id');
     $orderTax = ['order_id' => $id, 'tax_id' => $request->get('tax_id'), 'procentage' => $request->get('tax_procentage')];
     if (\App\OrderTax::create($orderTax)) {
         $orderBayar = ['order_id' => $id, 'karyawan_id' => Auth::guard('api')->check() ? Auth::guard('api')->user()->karyawan->id : '1', 'service_cost' => $request->get('service_cost'), 'diskon' => $request->get('diskon') != '' ? $request->get('diskon') : 0, 'bayar' => $request->get('bayar'), 'type_bayar' => $request->get('type_bayar')];
         if (\App\OrderBayar::create($orderBayar)) {
             if ($request->get('type_bayar') == 'debit' || $request->get('type_bayar') == 'credit_card') {
                 $orderBayarBank = ['order_id' => $id, 'bank_id' => $request->get('bank_id')];
                 $orderBayarBank['tax_procentage'] = $request->get('tax_bayar_procentage');
                 \App\OrderBayarBank::create($orderBayarBank);
             }
             $inputs = ['state' => 'Closed'];
             if ($request->get('customer_id') != "") {
                 $inputs['customer_id'] = $request->get('customer_id');
             }
             $order = \App\Order::find($id);
             if ($order->update($inputs)) {
                 // Update Sale Account
                 Artisan::call('sale:count', ['tanggal' => $order->tanggal->format('Y-m-d')]);
                 Artisan::call('bahan:count');
                 Artisan::call('produk:count');
                 return 1;
             }
         }
     }
     return 0;
 }