M3 Security Fixes for pass 28

This commit is contained in:
Mark Gregory
2026-09-17 10:50:37 +01:00
parent 1037c1c202
commit ed3db89018
77 changed files with 82 additions and 2387 deletions
@@ -23,7 +23,6 @@ class OrderLinesOfClosedOrder extends Controller
$allReportsUrls = [];
try {
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
// dd($SHUSER);
if ($SHUSER != '') {
// Get User CO & WH from Table ICM428M
@@ -43,11 +42,9 @@ class OrderLinesOfClosedOrder extends Controller
// 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');
$WHDDA = $COMPANY . $PLANT . $WHS;
// dump($WHDDA);
if ($REPORTDATEDisp != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
// Case 729: Add Currency code A1SHCURR FROM ICM666M
$selectContent = "
@@ -79,11 +76,9 @@ class OrderLinesOfClosedOrder extends Controller
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 = $REPORTDATEDisp
)
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT";
// dump($selectContent);
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
->select($selectContent);
// dd($ICM688M2);
} else {
$ICM688M2 = collect();
}
@@ -118,7 +113,6 @@ class OrderLinesOfClosedOrder extends Controller
try {
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
// dd($SHUSER);
if ($SHUSER != '') {
// Get User CO & WH from Table ICM428M
@@ -138,7 +132,6 @@ class OrderLinesOfClosedOrder extends Controller
// 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');
@@ -146,7 +139,6 @@ class OrderLinesOfClosedOrder extends Controller
$toreportDateWD = isset($urlParams['TOREPORTDATE']) ? trim($urlParams['TOREPORTDATE']) : today()->format('Y-m-d');
$WHDDA = $COMPANY . $PLANT . $WHS;
// dump($WHDDA);
if ($reportDate != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
// Case 729: Add Currency code A1SHCURR FROM ICM666M
$selectContent = "
@@ -187,7 +179,6 @@ class OrderLinesOfClosedOrder extends Controller
'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();
@@ -205,7 +196,6 @@ class OrderLinesOfClosedOrder extends Controller
// Download Excel
// Add true at the end to include fields names in the Header
return app(SpreadsheetExport::class)->download($ICM688M2Col, 'Closedorderlinesreport_' . $reportDateWD . '-' . $toreportDateWD . self::XLSX_EXTENSION);
// return $ICM688M2Col->downloadExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.csv',\Maatwebsite\Excel\Excel::CSV,false);
} catch (\Throwable $th) {
Log::error($th);
}
@@ -220,7 +210,6 @@ class OrderLinesOfClosedOrder extends Controller
try {
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
// dd($SHUSER);
if ($SHUSER != '') {
// Get User CO & WH from Table ICM428M
@@ -240,16 +229,13 @@ class OrderLinesOfClosedOrder extends Controller
// 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');
// 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');
$WHDDA = $COMPANY . $PLANT . $WHS;
// dump($WHDDA);
if ($reportDate != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
// Case 729: Add Currency code A1SHCURR FROM ICM666M
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
@@ -289,7 +275,6 @@ class OrderLinesOfClosedOrder extends Controller
'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();
@@ -312,11 +297,8 @@ class OrderLinesOfClosedOrder extends Controller
// MAK Store the File to Storage
app(SpreadsheetExport::class)->store($ICM688M2Col, $prevMonthFile, 'publicCL');
// $ICM688M2Col->storeExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.csv', 'publicCL',\Maatwebsite\Excel\Excel::CSV);
// $ICM688M2Col->storeExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.ods', 'publicCL',\Maatwebsite\Excel\Excel::ODS);
// dump('Done Saving Excel...');
return back();
} catch (\Throwable $th) {
Log::error($th);
@@ -326,13 +308,11 @@ class OrderLinesOfClosedOrder extends Controller
// 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
// $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