public function sales(Request $request) { $customers = customer::all(); $loadMain = loadMain::where('status', 'ACTIVE')->where('vehicle_id', $request->input('id'))->first(); $id = $loadMain->id; $products = DB::select(DB::raw("Select A.*,\n (Select CONCAT((Select C.product_name FROM `products` C where C.id = X.pro_id),'-',X.sub_name)\n as name FROM `sub_products` X where X.id = A.sub_product_id) as sub_name,\n (Select B.price From `sub_products` B where B.id = A.sub_product_id ) as price\n\n from `load_items` A where A.load_main_id = '{$id}'")); return view('Sales.sales')->with('customers', $customers)->with('products', $products)->with('loadid', $id); }
public function reload(Request $request) { $loadMain = loadMain::where('status', 'ACTIVE')->where('vehicle_id', $request->input('id'))->first(); $load_id = $loadMain->id; $vehicle = vehicle::find($request->input('id')); $loadItems = DB::select(DB::raw("Select A.*,\n (SELECT CONCAT( (SELECT C.product_name FROM `products` C where C.id = B.pro_id), '-',B.sub_name) FROM `sub_products` B where B.id = A.sub_product_id) as pro_name,\n (Select SUM(X.available) from `stocks` X where X.sub_product_id = A.sub_product_id AND X.status = 'ACTIVE') as stock_count\n from `load_items` A where A.load_main_id ='{$load_id}'")); $products = DB::select(DB::raw("Select A.*, (Select B.product_name from products B where B.id = A.pro_id) as product_name, (Select SUM(C.available) from `stocks` C where C.sub_product_id = A.id AND C.status = 'ACTIVE' ) as available From sub_products A where A.id NOT IN (select x.sub_product_id from `load_items` x where x.load_main_id = '{$load_id}') ")); return view('LoadUnload.reload')->with('vehicle', $vehicle)->with('loadMain', $loadMain)->with('loadItems', $loadItems)->with('products', $products); }