public function insert_sales_all(Request $request)
 {
     $salesMain = new salesLoadMain();
     $salesMain->total = $request->input('total');
     //$salesMain->customer_id = $request->input('customer');
     $salesMain->sale_date = $request->input('saledate');
     $salesMain->load_main_id = $request->input('loadid');
     $salesMain->discount = $request->input('fdiscount');
     $salesMain->remarks = $request->input('remarks');
     $salesMain->save();
     $id = $salesMain->id;
     $data = $request->input('items');
     foreach ($data as $d) {
         $item = new salesLoadItem();
         $item->sales_load_main_id = $id;
         $item->product_id = $d['product'];
         $item->quantity = $d['qty'];
         $item->total = $d['amount'];
         $item->free = $d['free'];
         $item->discount = $d['discount'];
         $item->market_return = $d['mreturn'];
         $item->good_return = $d['greturn'];
         $item->exchange = $d['exchange'];
         $item->sold = $d['sold'];
         $item->save();
         $tbid = $d['tblid'];
         $loadItem = loadItem::find($tbid);
         $loadItem->available_qty = $loadItem->available_qty - $d['qty'];
         $loadItem->save();
     }
 }
 public function unloadall(Request $request)
 {
     $vehicle = vehicle::find($request->input('vehicleId'));
     $vehicle->status = 'AVAILABLE';
     $vehicle->save();
     $loadMain = loadMain::find($request->input('loadMainId'));
     $loadMain->status = 'UNLOADED';
     $loadMain->unload_date = $request->input('uDate');
     $loadMain->save();
     for ($i = 0; $i < $request->input('countInfo'); $i++) {
         $loadItem = loadItem::find($request->input('loadItemId' . $i));
         $loadItem->unload_qty = $request->input('unload' . $i);
         $loadItem->unload_remarks = $request->input('remarks' . $i);
         $loadItem->save();
         $stock = stock::find($request->input('stock' . $i));
         $avb = $stock->available + $request->input('unload' . $i);
         $stock->available = $avb;
         $stock->save();
     }
 }