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 : /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 Barryvdh\DomPDF\Facade as PDF; use Meneses\LaravelMpdf\Facades\LaravelMpdf as mPDF; use Carbon\Carbon; use App\Models\Product; use App\Models\StockColor; use App\Models\CompanyInfo; use App\Models\ProductImei; use App\Models\Color; use App\Models\Stock; use App\Exports\Stock as StockX; use App\Exports\StockImei; use App\Exports\StockIn; use App\Exports\StockSummaryP; use App\Exports\StockSummaryS; use App\Exports\StockSummaryC; use Maatwebsite\Excel\Facades\Excel; class ExportReport extends Controller { public function __construct() { $this->middleware('admin'); } function stockSummary(Request $request){ $s_date = $request->get('s_date'); $e_date = $request->get('e_date'); $brand = $request->get('brand'); $product = $request->get('product'); $category = $request->get('category'); $supplier = $request->get('supplier'); $cnf = $request->get('cnf'); $type = $request->get('type'); $con=array(); if($category){ $con['category_id']= $category; } if($product){ $con['product_id']= $product; } if($brand != 'all' && $brand != null){ $con['brand_id']= $brand; } // if($supplier){ // $con['supplier_id']= $supplier; // } // if($cnf != 'all' && $cnf != null){ // $con['cnf_id']= $cnf; //} $typename=""; // if($type == 'category_wise'){ // $stocks=StockColor::join('products','stock_colors.product_id','products.product_id')->where($con)->whereBetween('stock_date', [$s_date, $e_date])->get()->groupBy('stock_id'); // $pdf = PDF::loadView('backend.pdf.reports.stock.category_stock_summary', compact('stocks', 'request','s_date','e_date'))->setPaper('a4'); // $typename="Category Wise"; // } // else if($type == 'product_wise'){ $stocks=Product::where($con)->get(); $colors=Color::get(); $data = [ 'stocks' => $stocks, 'request' => $request, 'colors' => $colors, ];; $pdf = mPDF::loadView('backend.pdf.reports.stock.product_wise_stock_summary', $data,[],[ 'orientation' => 'L', 'format' => 'Legal' ]); // $pdf = PDF::loadView('backend.pdf.reports.stock.product_wise_stock_summary', compact('stocks','colors'))->setPaper('a4'); // }else{ // $stocks=Stock::where($con)->whereBetween('stock_date', [$s_date, $e_date])->get(); // $pdf = PDF::loadView('backend.pdf.reports.stock.supplier_wise_stock_summary', compact('stocks', 'request','s_date','e_date'))->setPaper('a4'); // } if ($request->action_type == 'download'){ return $pdf->download('stock_summary' . Carbon::now()->format('yyyy-mm-dd'). '.pdf'); }elseif($request->action_type == 'print'){ @unlink('pdf/reports/stock/' . 'stock-summary-report.pdf'); $pdf->save('pdf/reports/stock/' . 'stock-summary-report.pdf'); return redirect('pdf/reports/stock/' . 'stock-summary-report.pdf'); }else{ // if($type == 'category_wise'){ // return Excel::download(new StockSummaryC($s_date, $e_date,$con), 'Category Wise Stock Summary Report.xlsx'); // } // else if($type == 'product_wise'){ return Excel::download(new StockSummaryP($con), 'Stock Summary Report.xlsx'); // }else{ // return Excel::download(new StockSummaryS($s_date, $e_date,$con), 'Suppplier Wise Stock Summary Report.xlsx'); // } } } public function stockExport(Request $request){ $product = $request->get('product'); $brand = $request->get('brand'); $stock_type=$request->get('stock_type'); $con=array(); $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($brand != 'all' && $brand != null ){ $con['brand_id']= $brand; } $colors=Color::get(); $minstock=CompanyInfo::first()->minimum_stock_qty; $chalans=Product::where($con)->get(); $data = [ 'chalans' => $chalans, 'request' => $request, 'end_date' => $end_date, 'start_date' => $start_date, 'colors' => $colors, 'stock_type' => $stock_type, 'minstock' => $minstock, ];; $pdf = mPDF::loadView('backend.pdf.reports.stock.stock', $data,[],[ 'orientation' => 'L', 'format' => 'Legal' ]); //$pdf = PDF::loadView('backend.pdf.reports.stock.stock', compact('chalans', 'request','minstock','colors','start_date','end_date','stock_type'))->setPaper('a4'); if ($request->action_type == 'download'){ return $pdf->download('stock-report-' . Carbon::now()->format('yyyy-mm-dd'). '.pdf'); //return $pdf->download('stock-report-' . Carbon::now()->format('yyyy-mm-dd'). '.pdf'); }elseif($request->action_type == 'print'){ return $pdf->stream('stock-report.pdf'); // @unlink('pdf/reports/stock/' . 'stock-report.pdf'); // $pdf->save('pdf/reports/stock/' . 'stock-report.pdf'); // return redirect('pdf/reports/stock/' . 'stock-report.pdf'); }else{ return Excel::download(new StockX($start_date, $end_date,$stock_type,$con), 'Stock Report.xlsx'); } } public function stockInExport(Request $request){ $product = $request->get('product'); $brand_id = $request->get('brand'); $cnf = $request->get('cnf'); $supplier = $request->get('supplier'); $con=array(); $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'); $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(); $data = [ 'stocks' => $stocks, 'request' => $request, 'end_date' => $end_date, 'start_date' => $start_date, 'colors' => $colors, ]; //return view('backend.pdf.reports.sells.sells', compact('chalans', 'request','e_date','s_date','colors')); $pdf = mPDF::loadView('backend.pdf.reports.stock.stock_in', $data,[],[ 'orientation' => 'L', 'format' => 'Legal' ]); //$pdf = PDF::loadView('backend.pdf.reports.stock.stock_in', compact('stocks', 'request','colors','start_date','end_date'))->setPaper('a4'); if ($request->action_type == 'download'){ return $pdf->download('stock-in-report-' . Carbon::now()->format('yyyy-mm-dd'). '.pdf'); // return $pdf->download('stock-in-report-' . Carbon::now()->format('yyyy-mm-dd'). '.pdf'); }elseif($request->action_type == 'print'){ return $pdf->stream('stock-in-report.pdf'); // @unlink('pdf/reports/stock/' . 'stock-in-report.pdf'); // $pdf->save('pdf/reports/stock/' . 'stock-in-report.pdf'); // return redirect('pdf/reports/stock/' . 'stock-in-report.pdf'); }else{ return Excel::download(new StockIn($start_date, $end_date,$con), 'Stock In Report.xlsx'); } } public function stockImeiExport(Request $request){ ini_set('max_execution_time', '300'); ini_set("pcre.backtrack_limit", "5000000"); $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'); $con=array(); $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'); $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(); //$pdf = PDF::loadView('backend.pdf.reports.stock.stock_imei', compact('stock_imeis', 'request','colors','start_date','end_date'))->setPaper('a4'); if ($request->action_type == 'download'){ $pdf = mPDF::loadView('backend.pdf.reports.stock.stock_in', $data,[],[ 'orientation' => 'L', 'format' => 'Legal' ]); return $pdf->download('stock-imei-report-' . Carbon::now()->format('yyyy-mm-dd'). '.pdf'); }elseif($request->action_type == 'print'){ $data = [ 'stock_imeis' => $stock_imeis, 'request' => $request, 'end_date' => $end_date, 'start_date' => $start_date, ]; $pdf = mPDF::loadView('backend.pdf.reports.stock.stock_imei', $data,[],[ 'orientation' => 'L', 'format' => 'Legal' ]); @unlink('pdf/reports/stock/' . 'stock-imei-report.pdf'); $pdf->save('pdf/reports/stock/' . 'stock-imei-report.pdf'); return redirect('pdf/reports/stock/' . 'stock-imei-report.pdf'); }else{ return Excel::download(new StockImei($start_date, $end_date,$con,$imei), 'Stock IMEI Report.xlsx'); } } }