M3 Security Fixes for scan command pass 33 major code smell fixes and style fixes
This commit is contained in:
@@ -17,22 +17,22 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$IC670M = $ICM688M2 = [];
|
||||
$WHDDA = $COMPANY = $PLANT = $WHS = '';
|
||||
$REPORTDATEDisp = today()->format('Ymd');
|
||||
$iC670M = $iCM688M2 = [];
|
||||
$wHDDA = $cOMPANY = $pLANT = $wHS = '';
|
||||
$rEPORTDATEDisp = today()->format('Ymd');
|
||||
$allReportsUrls = [];
|
||||
try {
|
||||
[$COMPANY, $PLANT, $WHS] = self::userWarehouseContext('110', '144', '322');
|
||||
[$cOMPANY, $pLANT, $wHS] = self::userWarehouseContext('110', '144', '322');
|
||||
|
||||
// Warehouse Table
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$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;
|
||||
if ($REPORTDATEDisp != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
|
||||
$wHDDA = $cOMPANY . $pLANT . $wHS;
|
||||
if ($rEPORTDATEDisp != '' && $cOMPANY != '' && $wHS != '' && $pLANT != '') {
|
||||
// Case 729: Add Currency code A1SHCURR FROM ICM666M
|
||||
$selectContent = "
|
||||
SELECT A5MACPKR, A5ONO,
|
||||
@@ -60,18 +60,18 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
WHERE A5MACPKR IN (
|
||||
SELECT DISTINCT AYMACPKR
|
||||
FROM ICM695M1
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 = $REPORTDATEDisp
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 = $rEPORTDATEDisp
|
||||
)
|
||||
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT";
|
||||
AND A5CO=$cOMPANY AND A5WHS=$wHS AND A5PLANT=$pLANT";
|
||||
|
||||
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
$iCM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select($selectContent);
|
||||
} else {
|
||||
$ICM688M2 = collect();
|
||||
$iCM688M2 = collect();
|
||||
}
|
||||
|
||||
// Get List of Files
|
||||
$allReportsUrls = self::reportUrls($WHS);
|
||||
$allReportsUrls = self::reportUrls($wHS);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
@@ -88,10 +88,10 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
[$COMPANY, $PLANT, $WHS] = self::userWarehouseContext();
|
||||
[$cOMPANY, $pLANT, $wHS] = self::userWarehouseContext();
|
||||
|
||||
// Warehouse Table
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
@@ -101,8 +101,8 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
$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;
|
||||
if ($reportDate != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
|
||||
$wHDDA = $cOMPANY . $pLANT . $wHS;
|
||||
if ($reportDate != '' && $cOMPANY != '' && $wHS != '' && $pLANT != '') {
|
||||
// Case 729: Add Currency code A1SHCURR FROM ICM666M
|
||||
$selectContent = "
|
||||
SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO,
|
||||
@@ -130,9 +130,9 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
FROM ICM695M1
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 BETWEEN $reportDate AND $toreportDate
|
||||
)
|
||||
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT";
|
||||
AND A5CO=$cOMPANY AND A5WHS=$wHS AND A5PLANT=$pLANT";
|
||||
|
||||
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
$iCM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select($selectContent);
|
||||
|
||||
$newItem = ['DATECLOSED' => 'Close Date', 'A5MACPKR' => 'Delivery #', 'A5ONO' => 'Order #',
|
||||
@@ -140,25 +140,25 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
'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);
|
||||
$iCM688M2Col = collect($iCM688M2);
|
||||
$iCM688M2Col->prepend($newItem);
|
||||
|
||||
// Count records before exporting to excel : Max 20K records are allowed
|
||||
$ICM688M2Count = $ICM688M2Col->count();
|
||||
$iCM688M2Count = $iCM688M2Col->count();
|
||||
// Set Max allowed records
|
||||
$maxRecords = Config::get('arrays.maxRecCL');
|
||||
if ($ICM688M2Count > $maxRecords) {
|
||||
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.');
|
||||
' current records: ' . number_format($iCM688M2Count) . ' , change your search criteria.');
|
||||
}
|
||||
|
||||
} else {
|
||||
$ICM688M2Col = '';
|
||||
$iCM688M2Col = '';
|
||||
}
|
||||
|
||||
// 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 app(SpreadsheetExport::class)->download($iCM688M2Col, 'Closedorderlinesreport_' . $reportDateWD . '-' . $toreportDateWD . self::XLSX_EXTENSION);
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
@@ -172,10 +172,10 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
[$COMPANY, $PLANT, $WHS] = self::userWarehouseContext();
|
||||
[$cOMPANY, $pLANT, $wHS] = self::userWarehouseContext();
|
||||
|
||||
// Warehouse Table
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
@@ -185,10 +185,10 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
$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;
|
||||
if ($reportDate != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') {
|
||||
$wHDDA = $cOMPANY . $pLANT . $wHS;
|
||||
if ($reportDate != '' && $cOMPANY != '' && $wHS != '' && $pLANT != '') {
|
||||
// Case 729: Add Currency code A1SHCURR FROM ICM666M
|
||||
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
$iCM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select("
|
||||
SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO,
|
||||
A4OFSTRM,
|
||||
@@ -215,7 +215,7 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
FROM ICM695M1
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 BETWEEN $reportDate AND $toreportDate
|
||||
)
|
||||
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT
|
||||
AND A5CO=$cOMPANY AND A5WHS=$wHS AND A5PLANT=$pLANT
|
||||
");
|
||||
|
||||
$newItem = ['DATECLOSED' => 'Close Date', 'A5MACPKR' => 'Delivery #', 'A5ONO' => 'Order #',
|
||||
@@ -223,27 +223,25 @@ class OrderLinesOfClosedOrder extends Controller
|
||||
'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);
|
||||
$iCM688M2Col = collect($iCM688M2);
|
||||
$iCM688M2Col->prepend($newItem);
|
||||
|
||||
// Count records before exporting to excel : Max 20K records are allowed
|
||||
$ICM688M2Count = $ICM688M2Col->count();
|
||||
$iCM688M2Count = $iCM688M2Col->count();
|
||||
// Set Max allowed records
|
||||
$maxRecords = Config::get('arrays.maxRecCL');
|
||||
if ($ICM688M2Count > $maxRecords) {
|
||||
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.');
|
||||
' current records: ' . number_format($iCM688M2Count) . ' , change your search criteria.');
|
||||
}
|
||||
} else {
|
||||
$ICM688M2Col = '';
|
||||
$iCM688M2Col = '';
|
||||
}
|
||||
|
||||
$prevMonthFile = self::storedReportName($WHS, $reportDateWD, $toreportDateWD);
|
||||
$prevMonthFile = self::storedReportName($wHS, $reportDateWD, $toreportDateWD);
|
||||
|
||||
// MAK Store the File to Storage
|
||||
app(SpreadsheetExport::class)->store($ICM688M2Col, $prevMonthFile, 'publicCL');
|
||||
|
||||
|
||||
app(SpreadsheetExport::class)->store($iCM688M2Col, $prevMonthFile, 'publicCL');
|
||||
|
||||
return back();
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
Reference in New Issue
Block a user