m3 Security Fixes

This commit is contained in:
Mark Gregory
2026-09-16 17:16:25 +01:00
parent d68687f062
commit 8f37245e13
64 changed files with 4247 additions and 4426 deletions
@@ -2,52 +2,52 @@
namespace Modules\M3\Http\Controllers;
use Modules\M3\Http\Controllers\Controller;
use DB;
use Config;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Str;
use Log;
use DB;
use Excel;
use Illuminate\Http\Request;
use Log;
use Modules\M3\Services\SpreadsheetExport;
use Storage;
use Str;
class OrderLinesOfClosedOrder extends Controller
{
public static function index(Request $request){
public static function index(Request $request)
{
$IC670M = $ICM688M2 = [];
$WHDDA = $COMPANY = $PLANT = $WHS = '';
$REPORTDATEDisp = today()->format('Ymd');
$allReportsUrls = [];
try {
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
// dd($SHUSER);
if ($SHUSER!='') {
# Get User CO & WH from Table ICM428M
if ($SHUSER != '') {
// Get User CO & WH from Table ICM428M
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
->select('R428US','R428CO', 'R428WH','R428PL')
->where('R428US','=',$SHUSER)
->select('R428US', 'R428CO', 'R428WH', 'R428PL')
->where('R428US', '=', $SHUSER)
->first();
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '110'; # Company
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '144'; # Plant
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '322'; # WareHouse
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; // User
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '110'; // Company
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '144'; // Plant
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '322'; // WareHouse
}
# Warehouse Table
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
// Warehouse Table
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
# Get URL PARAMS
$urlParams = count($request->all())>0 ? $request->all() : '';
// Get URL PARAMS
$urlParams = count($request->all()) > 0 ? $request->all() : '';
// dump($urlParams);
$REPORTDATEDisp = isset($urlParams["REPORTDATEDisp"]) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams["REPORTDATEDisp"]))->format('Ymd') : today()->format('Ymd');
$REPORTDATEDisp = isset($urlParams['REPORTDATEDisp']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['REPORTDATEDisp']))->format('Ymd') : today()->format('Ymd');
$WHDDA = $COMPANY.$PLANT.$WHS;
$WHDDA = $COMPANY . $PLANT . $WHS;
// dump($WHDDA);
if($REPORTDATEDisp!='' && $COMPANY!='' && $WHS!='' && $PLANT!=''){
# Case 729: Add Currency code A1SHCURR FROM ICM666M
if ($REPORTDATEDisp != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
// Case 729: Add Currency code A1SHCURR FROM ICM666M
$selectContent = "
SELECT A5MACPKR, A5ONO,
(SELECT A4REFORD FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) AS A4REFORD,
@@ -60,8 +60,8 @@ class OrderLinesOfClosedOrder extends Controller
A1SHCURR,
CASE
WHEN (SELECT A4SHIPTYPE FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) = 'LTL'
THEN (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL'))/100 ."
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel') )/100 ."
THEN (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * " . (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL')) / 100 . '
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ' . (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel')) / 100 . "
END AS FREIGHT,
A4SHIPTYPE,
A4SHIPVIA1,
@@ -80,75 +80,73 @@ class OrderLinesOfClosedOrder extends Controller
// dump($selectContent);
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
->select($selectContent);
->select($selectContent);
// dd($ICM688M2);
}
else{
} else {
$ICM688M2 = collect();
}
# Get List of Files
// Get List of Files
$allReportsUrls = [];
if ($WHS == '321') {
$files = Storage::disk('publicCL')->files();
}
else{
$files = Storage::disk('publicCL')->files();
} else {
$files = Storage::disk('publicCL')->allFiles($WHS);
}
foreach ($files as $file) {
# Get the file URL (if URL is configured in filesystems.php)
// Get the file URL (if URL is configured in filesystems.php)
$url = Storage::disk('publicCL')->url($file);
$allReportsUrls[$file] = $url;
}
}
catch (\Throwable $th) {
} catch (\Throwable $th) {
Log::error($th);
}
return view('m3::liberty-theme.pages.OrderLinesOfClosed',compact('IC670M','ICM688M2','WHDDA','COMPANY','PLANT','WHS','REPORTDATEDisp','allReportsUrls'));
return view('m3::liberty-theme.pages.OrderLinesOfClosed', compact('IC670M', 'ICM688M2', 'WHDDA', 'COMPANY', 'PLANT', 'WHS', 'REPORTDATEDisp', 'allReportsUrls'));
}
public static function exporttoExcel(Request $request){
public static function exporttoExcel(Request $request)
{
ini_set('max_execution_time', Config::get('arrays.PHPTimeOut'));
ini_set('max_input_time', Config::get('arrays.PHPTimeOut'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOut'));
ini_set('memory_limit', '1024M');
try {
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
// dd($SHUSER);
if ($SHUSER!='') {
# Get User CO & WH from Table ICM428M
if ($SHUSER != '') {
// Get User CO & WH from Table ICM428M
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
->select('R428US','R428CO', 'R428WH','R428PL')
->where('R428US','=',$SHUSER)
->select('R428US', 'R428CO', 'R428WH', 'R428PL')
->where('R428US', '=', $SHUSER)
->first();
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : ''; # Company
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : ''; # Plant
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : ''; # WareHouse
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; // User
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : ''; // Company
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : ''; // Plant
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : ''; // WareHouse
}
# Warehouse Table
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
// Warehouse Table
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
# Get URL PARAMS
$urlParams = count($request->all())>0 ? $request->all() : '';
// Get URL PARAMS
$urlParams = count($request->all()) > 0 ? $request->all() : '';
// dd($urlParams);
$reportDate = isset($urlParams["REPORTDATE"]) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams["REPORTDATE"]))->format('Ymd') : today()->format('Ymd');
$toreportDate = isset($urlParams["TOREPORTDATE"]) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams["TOREPORTDATE"]))->format('Ymd') : today()->format('Ymd');
$reportDate = isset($urlParams['REPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['REPORTDATE']))->format('Ymd') : today()->format('Ymd');
$toreportDate = isset($urlParams['TOREPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['TOREPORTDATE']))->format('Ymd') : today()->format('Ymd');
$reportDateWD = isset($urlParams["REPORTDATE"]) ? trim($urlParams["REPORTDATE"]) : today()->format('Y-m-d');
$toreportDateWD = isset($urlParams["TOREPORTDATE"]) ? trim($urlParams["TOREPORTDATE"]) : today()->format('Y-m-d');
$reportDateWD = isset($urlParams['REPORTDATE']) ? trim($urlParams['REPORTDATE']) : today()->format('Y-m-d');
$toreportDateWD = isset($urlParams['TOREPORTDATE']) ? trim($urlParams['TOREPORTDATE']) : today()->format('Y-m-d');
$WHDDA = $COMPANY.$PLANT.$WHS;
$WHDDA = $COMPANY . $PLANT . $WHS;
// dump($WHDDA);
if($reportDate!='' && $COMPANY!='' && $WHS!='' && $PLANT!=''){
# Case 729: Add Currency code A1SHCURR FROM ICM666M
if ($reportDate != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
// Case 729: Add Currency code A1SHCURR FROM ICM666M
$selectContent = "
SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO,
A4OFSTRM,
@@ -163,8 +161,8 @@ class OrderLinesOfClosedOrder extends Controller
A1SHCURR,
CASE
WHEN (SELECT A4SHIPTYPE FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) = 'LTL'
THEN (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL'))/100 ."
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel'))/100 ."
THEN (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * " . (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL')) / 100 . '
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ' . (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel')) / 100 . "
END AS FREIGHT
FROM ICM688M2
LEFT JOIN ICM699M ON SHMACPKR=A5MACPKR AND SHTYPE='M3-Res-out' AND SHDATA LIKE 'Success%' AND SHSOURCE='CloseShipmentCoChargeAPI'
@@ -178,82 +176,82 @@ class OrderLinesOfClosedOrder extends Controller
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT";
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
->select($selectContent);
->select($selectContent);
$newItem = ["DATECLOSED" => 'Close Date',"A5MACPKR" => 'Delivery #', "A5ONO" => 'Order #',
"A4OFSTRM" => 'Terms',"WEIGHT" => 'Weight',"A4SCAC" => 'Carrier',"A4SHIPTYPE" => 'Mode (Parcel, Air, TL or LTL)',
"A4REFORD" => 'Order Type',"A5PART" => 'Part #',"A5RSVQTY" => 'Reserved',
"A5PACKED" => 'Packed',"CALCULATED_COLUMN" => 'Back Order Qty',"ANOTHER_CALCULATED_COLUMN" => 'Value Packed $',"A4SHSHNM" => 'Customer name',
"REASON" => 'Failure Reason','A1SHCURR'=> 'Currency Code','FREIGHT'=> 'Freight'];
$newItem = ['DATECLOSED' => 'Close Date', 'A5MACPKR' => 'Delivery #', 'A5ONO' => 'Order #',
'A4OFSTRM' => 'Terms', 'WEIGHT' => 'Weight', 'A4SCAC' => 'Carrier', 'A4SHIPTYPE' => 'Mode (Parcel, Air, TL or LTL)',
'A4REFORD' => 'Order Type', 'A5PART' => 'Part #', 'A5RSVQTY' => 'Reserved',
'A5PACKED' => 'Packed', 'CALCULATED_COLUMN' => 'Back Order Qty', 'ANOTHER_CALCULATED_COLUMN' => 'Value Packed $', 'A4SHSHNM' => 'Customer name',
'REASON' => 'Failure Reason', 'A1SHCURR' => 'Currency Code', 'FREIGHT' => 'Freight'];
$ICM688M2Col = collect($ICM688M2);
$ICM688M2Col->prepend($newItem);
// dd($ICM688M2Col);
# Count records before exporting to excel : Max 20K records are allowed
$ICM688M2Count = $ICM688M2Col->count();
# Set Max allowed records
$maxRecords = Config::get('arrays.maxRecCL');
if ($ICM688M2Count>$maxRecords) {
return redirect()->back()->withInput()->with('message', 'Maximum allowed records for Excel Download is: '.number_format($maxRecords).
' current records: '.number_format($ICM688M2Count) . ' , change your search criteria.');
// Count records before exporting to excel : Max 20K records are allowed
$ICM688M2Count = $ICM688M2Col->count();
// Set Max allowed records
$maxRecords = Config::get('arrays.maxRecCL');
if ($ICM688M2Count > $maxRecords) {
return redirect()->back()->withInput()->with('message', 'Maximum allowed records for Excel Download is: ' . number_format($maxRecords) .
' current records: ' . number_format($ICM688M2Count) . ' , change your search criteria.');
}
} else {
$ICM688M2Col = '';
}
else{
$ICM688M2Col = "";
}
# Download Excel
# Add true at the end to include fields names in the Header
return app(\Modules\M3\Services\SpreadsheetExport::class)->download($ICM688M2Col, 'Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.xlsx');
// Download Excel
// Add true at the end to include fields names in the Header
return app(SpreadsheetExport::class)->download($ICM688M2Col, 'Closedorderlinesreport_' . $reportDateWD . '-' . $toreportDateWD . '.xlsx');
// return $ICM688M2Col->downloadExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.csv',\Maatwebsite\Excel\Excel::CSV,false);
}
catch (\Throwable $th) {
} catch (\Throwable $th) {
Log::error($th);
}
}
public static function StoreExcelToDisk(Request $request){
public static function StoreExcelToDisk(Request $request)
{
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
ini_set('memory_limit', '1024M');
try {
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
// dd($SHUSER);
if ($SHUSER!='') {
# Get User CO & WH from Table ICM428M
if ($SHUSER != '') {
// Get User CO & WH from Table ICM428M
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
->select('R428US','R428CO', 'R428WH','R428PL')
->where('R428US','=',$SHUSER)
->select('R428US', 'R428CO', 'R428WH', 'R428PL')
->where('R428US', '=', $SHUSER)
->first();
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : ''; # Company
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : ''; # Plant
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : ''; # WareHouse
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; // User
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : ''; // Company
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : ''; // Plant
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : ''; // WareHouse
}
# Warehouse Table
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
// Warehouse Table
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
# Get URL PARAMS
$urlParams = count($request->all())>0 ? $request->all() : '';
// Get URL PARAMS
$urlParams = count($request->all()) > 0 ? $request->all() : '';
// dd($urlParams);
$reportDate = isset($urlParams["REPORTDATE"]) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams["REPORTDATE"]))->format('Ymd') : today()->format('Ymd');
$toreportDate = isset($urlParams["TOREPORTDATE"]) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams["TOREPORTDATE"]))->format('Ymd') : today()->format('Ymd');
$reportDate = isset($urlParams['REPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['REPORTDATE']))->format('Ymd') : today()->format('Ymd');
$toreportDate = isset($urlParams['TOREPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['TOREPORTDATE']))->format('Ymd') : today()->format('Ymd');
// dump($reportDate);
// dd($toreportDate);
$reportDateWD = isset($urlParams["REPORTDATE"]) ? trim($urlParams["REPORTDATE"]) : today()->format('Y-m-d');
$toreportDateWD = isset($urlParams["TOREPORTDATE"]) ? trim($urlParams["TOREPORTDATE"]) : today()->format('Y-m-d');
$reportDateWD = isset($urlParams['REPORTDATE']) ? trim($urlParams['REPORTDATE']) : today()->format('Y-m-d');
$toreportDateWD = isset($urlParams['TOREPORTDATE']) ? trim($urlParams['TOREPORTDATE']) : today()->format('Y-m-d');
$WHDDA = $COMPANY.$PLANT.$WHS;
$WHDDA = $COMPANY . $PLANT . $WHS;
// dump($WHDDA);
if($reportDate!='' && $COMPANY!='' && $WHS!='' && $PLANT!=''){
# Case 729: Add Currency code A1SHCURR FROM ICM666M
if ($reportDate != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
// Case 729: Add Currency code A1SHCURR FROM ICM666M
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
->select("
->select("
SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO,
A4OFSTRM,
A5PMPWHT*A5PACKED AS WEIGHT,
@@ -267,8 +265,8 @@ class OrderLinesOfClosedOrder extends Controller
A1SHCURR,
CASE
WHEN (SELECT A4SHIPTYPE FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) = 'LTL'
THEN (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL'))/100 ."
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel'))/100 ."
THEN (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * " . (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL')) / 100 . '
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ' . (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel')) / 100 . "
END AS FREIGHT
FROM ICM688M2
LEFT JOIN ICM699M ON SHMACPKR=A5MACPKR AND SHTYPE='M3-Res-out' AND SHDATA LIKE 'Success%' AND SHSOURCE='CloseShipmentCoChargeAPI'
@@ -282,37 +280,35 @@ class OrderLinesOfClosedOrder extends Controller
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT
");
$newItem = ["DATECLOSED" => 'Close Date',"A5MACPKR" => 'Delivery #', "A5ONO" => 'Order #',
"A4OFSTRM" => 'Terms',"WEIGHT" => 'Weight',"A4SCAC" => 'Carrier',"A4SHIPTYPE" => 'Mode (Parcel, Air, TL or LTL)',
"A4REFORD" => 'Order Type',"A5PART" => 'Part #',"A5RSVQTY" => 'Reserved',
"A5PACKED" => 'Packed',"CALCULATED_COLUMN" => 'Back Order Qty',"ANOTHER_CALCULATED_COLUMN" => 'Value Packed $',"A4SHSHNM" => 'Customer name',
"REASON" => 'Failure Reason','A1SHCURR'=> 'Currency Code','FREIGHT'=> 'Freight'];
$newItem = ['DATECLOSED' => 'Close Date', 'A5MACPKR' => 'Delivery #', 'A5ONO' => 'Order #',
'A4OFSTRM' => 'Terms', 'WEIGHT' => 'Weight', 'A4SCAC' => 'Carrier', 'A4SHIPTYPE' => 'Mode (Parcel, Air, TL or LTL)',
'A4REFORD' => 'Order Type', 'A5PART' => 'Part #', 'A5RSVQTY' => 'Reserved',
'A5PACKED' => 'Packed', 'CALCULATED_COLUMN' => 'Back Order Qty', 'ANOTHER_CALCULATED_COLUMN' => 'Value Packed $', 'A4SHSHNM' => 'Customer name',
'REASON' => 'Failure Reason', 'A1SHCURR' => 'Currency Code', 'FREIGHT' => 'Freight'];
$ICM688M2Col = collect($ICM688M2);
$ICM688M2Col->prepend($newItem);
// dd($ICM688M2Col);
# Count records before exporting to excel : Max 20K records are allowed
$ICM688M2Count = $ICM688M2Col->count();
# Set Max allowed records
// Count records before exporting to excel : Max 20K records are allowed
$ICM688M2Count = $ICM688M2Col->count();
// Set Max allowed records
$maxRecords = Config::get('arrays.maxRecCL');
if ($ICM688M2Count>$maxRecords) {
return redirect()->back()->withInput()->with('message', 'Maximum allowed records for Excel Download is: '.number_format($maxRecords).
' current records: '.number_format($ICM688M2Count) . ' , change your search criteria.');
if ($ICM688M2Count > $maxRecords) {
return redirect()->back()->withInput()->with('message', 'Maximum allowed records for Excel Download is: ' . number_format($maxRecords) .
' current records: ' . number_format($ICM688M2Count) . ' , change your search criteria.');
}
}
else{
$ICM688M2Col = "";
} else {
$ICM688M2Col = '';
}
if ($WHS == '321') {
$prevMonthFile = 'Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.xlsx';
}
else{
$prevMonthFile = $WHS.'/Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'-'.$WHS.'.xlsx';
$prevMonthFile = 'Closedorderlinesreport_' . $reportDateWD . '-' . $toreportDateWD . '.xlsx';
} else {
$prevMonthFile = $WHS . '/Closedorderlinesreport_' . $reportDateWD . '-' . $toreportDateWD . '-' . $WHS . '.xlsx';
}
# MAK Store the File to Storage
app(\Modules\M3\Services\SpreadsheetExport::class)->store($ICM688M2Col, $prevMonthFile, 'publicCL');
// MAK Store the File to Storage
app(SpreadsheetExport::class)->store($ICM688M2Col, $prevMonthFile, 'publicCL');
// $ICM688M2Col->storeExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.csv', 'publicCL',\Maatwebsite\Excel\Excel::CSV);
@@ -320,27 +316,27 @@ class OrderLinesOfClosedOrder extends Controller
// dump('Done Saving Excel...');
return back();
}
catch (\Throwable $th) {
} catch (\Throwable $th) {
Log::error($th);
}
}
# Download File
public static function downloadFiles(Request $request){
// Download File
public static function downloadFiles(Request $request)
{
// dd($request->all());
$fileName = $request->filename;
if (Storage::disk('publicCL')->exists($fileName)) {
# File exists, retrieve content or URL
// File exists, retrieve content or URL
// $content = Storage::disk('publicCL')->get($fileName);
$fileUrl = Storage::disk('publicCL')->url($fileName);
// dd($fileUrl);
$fileNameOnly = strpos($fileName, '/')!= false ? substr($fileName, strpos($fileName, '/') + 1) : $fileName;
# Download the file
$fileNameOnly = strpos($fileName, '/') != false ? substr($fileName, strpos($fileName, '/') + 1) : $fileName;
// Download the file
return Storage::disk('publicCL')->download($fileName, $fileNameOnly);
} else {
// Download the file (use code below)
}
}
}