Server : Apache System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64 User : vapecompany ( 2719) PHP Version : 7.4.33 Disable Function : NONE Directory : /proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Backend/ |
Upload File : |
<?php namespace App\Http\Controllers\Backend; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\Stock; use App\Models\Category; use App\Models\StockColor; use App\Models\Supplier; use App\Models\CNF; use App\Models\Brand; use App\Models\ProductModel; use App\Models\Color; use App\Models\Product; use App\Models\CompanyInfo; use App\Models\ProductImei; use Carbon\Carbon; class StockReportController extends Controller { public function __construct() { $this->middleware('admin'); } public function stockSummary(Request $request) { // if(!auth()->user()->canEvent('reports/stock_summary')) // { // return redirect('/'); // } $stocks=Stock::select('stock_colors.*','categories.*')->leftJoin('stock_colors', 'stocks.stock_id', '=', 'stock_colors.stock_id')->leftJoin('products', 'stock_colors.product_id', '=', 'products.product_id') ->leftJoin('categories', 'products.category_id', '=', 'categories.category_id') ->get()->groupby(function($d){ return $d->category_name; }); $stocks=Stock::get(); //dd($stocks[0]->details->groupby('category_id')[1][0]->category); $product = $request->get('product'); $category_id = $request->get('category'); $category = $request->get('category'); $supplier = $request->get('supplier'); $cnf = $request->get('cnf'); if($request->ajax()){ //return $request; // $start_date=$request->get('s_date') ? $request->get('s_date'):Carbon::now()->format('Y-m-d'); // $end_date=$request->get('e_date') ? $request->get('e_date'):Carbon::now()->format('Y-m-d'); // $stocks = Stock::whereBetween('stock_date', [$start_date, $end_date])->get(); // // return $request; // if($request->by_duration == 'c2'){ // $con=array(); // if($category){ // $con['products.category_id']= $category; // } // $stocks=StockColor::join('products','stock_colors.product_id','products.product_id')->where($con)->whereBetween('stock_date', [$start_date, $end_date])->get()->groupBy('stock_id'); // //return $con; // return view('backend.reports.tables.stock_summary_c2',['stocks'=>$stocks,'s_date'=>$start_date,'e_date'=>$end_date,'by_duration'=>$request->by_duration,'category_id'=>$category]); // }else if($request->by_duration == 'c3'){ // $con=array(); // if($supplier){ // $con['supplier_id']= $supplier; // } // if($cnf){ // $con['cnf_id']= $cnf; // } // $stocks=Stock::where($con)->whereBetween('stock_date', [$start_date, $end_date])->get(); // // dd($con); // return view('backend.reports.tables.stock_summary_c3',['stocks'=>$stocks,'s_date'=>$start_date,'e_date'=>$end_date,'by_duration'=>$request->by_duration,'supplier_id'=>$supplier,'cnf_id'=>$cnf]); // }else{ $categories=Category::get(); $con=array(); if($product){ $con['product_id']= $product; } if($category_id != 'all' && $category_id != null){ $con['category_id']= $category_id; } if($category){ $con['category_id']= $category; } //return $con; $stocks=Product::where($con)->get(); $colors=Color::get(); //return $stocks; return view('backend.reports.tables.stock_summary_c1',['colors'=>$colors,'stocks'=>$stocks,'by_duration'=>$request->by_duration,'category_id'=>$category_id,'product'=>$product]); //} } $categories=Category::get(); $categories=Category::get(); $suppliers=Supplier::get(); $cnfs=CNF::get(); $start_date=Carbon::now()->firstOfMonth()->format('Y-m-d'); $end_date=Carbon::now()->format('Y-m-d'); $stocks=Product::get(); $colors=Color::get(); return view('backend.reports.stock_summary',['categories'=>$categories,'colors'=>$colors, 'stocks'=>$stocks,'s_date'=>$start_date,'e_date'=>$end_date,'suppliers'=>$suppliers,'cnfs'=>$cnfs,'category_id'=>$category_id,'product'=>$product]); } public function stockIn(Request $request){ // if(!auth()->user()->canEvent('reports/stock_in')) // { // return redirect('/'); // } $product = $request->get('product'); $brand_id = $request->get('brand'); $cnf = $request->get('cnf'); $supplier = $request->get('supplier'); $suppliers=Supplier::get(); $brands=Brand::get(); $models=ProductModel::get(); if($request->ajax()){ $start_date = $request->get('s_date'); $end_date = $request->get('e_date') ? $request->get('e_date') : date('Y-m-d'); $con=array(); if($product){ $con['stock_colors.product_id']= $product; } if($brand_id){ $con['products.brand_id']= $brand_id; } if($supplier){ $con['stocks.supplier_id']= $supplier; } if($cnf){ $con['stocks.cnf_id']= $cnf; } $stocks=StockColor::join('stocks','stock_colors.stock_id','stocks.stock_id') ->join('products','stock_colors.product_id','products.product_id')->where($con)->whereBetween('stock_colors.stock_date', [$start_date, $end_date])->get()->groupBy('stock_id'); // return $con; $colors=Color::get(); return view('backend.reports.tables.stock_in',['stocks'=>$stocks,'s_date'=>$start_date,'e_date'=>$end_date,'colors'=>$colors,'product'=>$product,'brand_id'=>$brand_id,'cnf'=>$cnf,'supplier_id'=>$supplier]); } $colors=Color::get(); $start_date=Carbon::now()->firstOfMonth()->format('Y-m-d'); $end_date=Carbon::now()->format('Y-m-d'); $stocks=StockColor::join('stocks','stock_colors.stock_id','stocks.stock_id') ->join('products','stock_colors.product_id','products.product_id') ->whereBetween('stock_colors.stock_date', [$start_date, $end_date]) ->get()->groupBy('stock_id'); //dd($stocks); //$products=Product::get(); return view('backend.reports.stock_in',['stocks'=>$stocks,'s_date'=>$start_date,'e_date'=>$end_date,'colors'=>$colors,'suppliers'=>$suppliers,'brands'=>$brands,'models'=>$models,'product'=>$product,'brand_id'=>$brand_id,'cnf'=>$cnf,'supplier_id'=>$supplier]); } public function stockDoa(Request $request){ if(!auth()->user()->canEvent('reports/stock_in')) { return redirect('/'); } $product = $request->get('product'); $brand_id = $request->get('brand'); $cnf = $request->get('cnf'); $supplier = $request->get('supplier'); $suppliers=Supplier::get(); $brands=Brand::get(); $models=ProductModel::get(); if($request->ajax()){ $start_date = $request->get('s_date'); $end_date = $request->get('e_date') ? $request->get('e_date') : date('Y-m-d'); $con=array(); if($product){ $con['stock_colors.product_id']= $product; } if($brand_id){ $con['products.brand_id']= $brand_id; } if($supplier){ $con['stocks.supplier_id']= $supplier; } if($cnf){ $con['stocks.cnf_id']= $cnf; } $stocks=StockColor::join('stocks','stock_colors.stock_id','stocks.stock_id') ->join('products','stock_colors.product_id','products.product_id')->where($con)->whereBetween('stock_colors.stock_date', [$start_date, $end_date])->get()->groupBy('stock_id'); // return $con; $colors=Color::get(); return view('backend.reports.tables.stock_in',['stocks'=>$stocks,'s_date'=>$start_date,'e_date'=>$end_date,'colors'=>$colors,'product'=>$product,'brand_id'=>$brand_id,'cnf'=>$cnf,'supplier_id'=>$supplier]); } $colors=Color::get(); $start_date=Carbon::now()->firstOfMonth()->format('Y-m-d'); $end_date=Carbon::now()->format('Y-m-d'); $stocks=StockColor::join('stocks','stock_colors.stock_id','stocks.stock_id') ->join('products','stock_colors.product_id','products.product_id') ->whereBetween('stock_colors.stock_date', [$start_date, $end_date]) ->get()->groupBy('stock_id'); //dd($stocks); //$products=Product::get(); return view('backend.reports.doa',['stocks'=>$stocks,'s_date'=>$start_date,'e_date'=>$end_date,'colors'=>$colors,'suppliers'=>$suppliers,'brands'=>$brands,'models'=>$models,'product'=>$product,'brand_id'=>$brand_id,'cnf'=>$cnf,'supplier_id'=>$supplier]); } public function stockImei(Request $request){ // if(!auth()->user()->canEvent('reports/stock_imei')) // { // return redirect('/'); // } $product = $request->get('product'); $brand_id = $request->get('brand'); $cnf = $request->get('cnf'); $supplier = $request->get('supplier'); $imei = $request->get('imei'); $color = $request->get('color'); $suppliers=Supplier::get(); $brands=Brand::get(); $models=ProductModel::get(); if($request->ajax()){ $start_date = $request->get('s_date'); $end_date = $request->get('e_date') ? $request->get('e_date') : date('Y-m-d'); $con=array(); if($product){ $con['stock_colors.product_id']= $product; } if($brand_id){ $con['products.brand_id']= $brand_id; } if($supplier){ $con['stocks.supplier_id']= $supplier; } if($cnf){ $con['stocks.cnf_id']= $cnf; } if($color){ $con['product_imeis.color']= $color; } $stock_imeis=ProductImei::leftJoin('stock_colors','product_imeis.stock_color_id','stock_colors.stock_color_id') ->leftJoin('stocks','stock_colors.stock_id','stocks.stock_id') ->leftJoin('products','product_imeis.product_id','products.product_id') ->where($con) ->whereBetween('stock_colors.stock_date', [$start_date, $end_date]); if($imei){ $stock_imeis = $stock_imeis->where('imei_1',$imei)->orWhere('imei_2',$imei); } $stock_imeis=$stock_imeis->get(); // return $con; $colors=Color::get(); return view('backend.reports.tables.stock_imei_table',['stock_imeis'=>$stock_imeis,'imei'=>$imei,'s_date'=>$start_date,'e_date'=>$end_date,'colors'=>$colors,'product'=>$product,'color'=>$color,'brand_id'=>$brand_id,'cnf'=>$cnf,'supplier_id'=>$supplier]); } $colors=Color::get(); $start_date=Carbon::now()->firstOfMonth()->format('Y-m-d'); $end_date=Carbon::now()->format('Y-m-d'); $stock_imeis=ProductImei::leftJoin('stock_colors','product_imeis.stock_color_id','stock_colors.stock_color_id') ->leftJoin('stocks','stock_colors.stock_id','stocks.stock_id') ->leftJoin('products','product_imeis.product_id','products.product_id') ->whereBetween('stock_colors.stock_date', [$start_date, $end_date]) ->get(); //dd($stock_imeis); //$products=Product::get(); return view('backend.reports.stock_imei',['stock_imeis'=>$stock_imeis,'s_date'=>$start_date,'e_date'=>$end_date,'colors'=>$colors,'suppliers'=>$suppliers,'brands'=>$brands,'models'=>$models,'imei'=>$imei,'color'=>$color,'product'=>$product,'brand_id'=>$brand_id,'cnf'=>$cnf,'supplier_id'=>$supplier]); } public function stock(Request $request) { // if(!auth()->user()->canEvent('reports/stock')) // { // return redirect('/'); // } $product = $request->get('product'); $category_id = $request->get('category'); $stock_type=$request->get('stock_type'); if($request->ajax()){ $start_date=$request->get('start_date') ? $request->get('start_date'):Carbon::now()->format('Y-m-d'); $end_date=$request->get('end_date') ? $request->get('end_date'):Carbon::now()->format('Y-m-d'); $con=array(); if($product){ $con['product_id']= $product; } if($category_id != 'all'){ $con['category_id']= $category_id; } if(!empty($con)){ //$chalans= $chalans->where($con); } //$chalans=$chalans->get(); //return $con; $colors=Color::get(); $minstock=CompanyInfo::first()->minimum_stock_qty; $chalans=Product::where($con)->get(); return view('backend.reports.tables.stock_report_table',['start_date'=>$start_date,'end_date'=>$end_date,'chalans'=>$chalans,'colors'=>$colors,'product'=>$product,'category_id'=>$category_id,'minstock'=>$minstock,'stock_type'=>$stock_type]); } $start_date=Carbon::now()->firstOfMonth()->format('Y-m-d'); $end_date=Carbon::now()->format('Y-m-d'); $categories=Brand::get(); $chalans=Product::get(); $colors=Color::get(); $minstock=CompanyInfo::first()->minimum_stock_qty; return view('backend.reports.stock',['minstock'=>$minstock,'colors'=>$colors,'product'=>$product,'category_id'=>$category_id,'chalans'=>$chalans,'categories'=>$categories,'start_date'=>$start_date,'end_date'=>$end_date,'stock_type'=>$stock_type]); } }