M3 Security Fixes for scan command
This commit is contained in:
@@ -256,52 +256,11 @@ class M3ErrorsDispController extends Controller
|
||||
// Get Records Count only
|
||||
$ICM699MC = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m');
|
||||
|
||||
if ($R428US != '') {
|
||||
$ICM699M->whereIn('SHCO', [$USERCO, '']);
|
||||
$ICM699M->whereIn('SHWHS', [$USERWH, '']);
|
||||
|
||||
$ICM699MC->whereIn('SHCO', [$USERCO, '']);
|
||||
$ICM699MC->whereIn('SHWHS', [$USERWH, '']);
|
||||
} else {
|
||||
$ICM699M->where('SHCO', null);
|
||||
$ICM699M->where('SHWHS', null);
|
||||
|
||||
$ICM699MC->where('SHCO', null);
|
||||
$ICM699MC->where('SHWHS', null);
|
||||
}
|
||||
|
||||
if ($SHMACPKR != '') {
|
||||
$ICM699M->where('SHMACPKR', $SHMACPKR);
|
||||
|
||||
$ICM699MC->where('SHMACPKR', $SHMACPKR);
|
||||
}
|
||||
|
||||
if ($SHSOURCE != '') {
|
||||
$ICM699M->where('SHSOURCE', $SHSOURCE);
|
||||
|
||||
$ICM699MC->where('SHSOURCE', $SHSOURCE);
|
||||
}
|
||||
// Disable PDFStorage Search
|
||||
$ICM699M->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
|
||||
$ICM699MC->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
|
||||
if ($SHMACPKR == '' && $SKIPDATES == 'N') {
|
||||
$ICM699M->whereBetween('SHDT', [$STARTDATE, $ENDDATE]);
|
||||
|
||||
$ICM699MC->whereBetween('SHDT', [$STARTDATE, $ENDDATE]);
|
||||
}
|
||||
|
||||
if ($SHOWERRORS == 'Y') {
|
||||
$ICM699M->where('SHERROR', 'X');
|
||||
|
||||
$ICM699MC->where('SHERROR', 'X');
|
||||
}
|
||||
|
||||
// Get only M3 Logs
|
||||
$ICM699M->where('SHTYPE', 'like', '%M3%');
|
||||
|
||||
$ICM699MC->where('SHTYPE', 'like', '%M3%');
|
||||
self::applyExportFilters($ICM699M, $ICM699MC, [
|
||||
'profileUser' => $R428US, 'company' => $USERCO, 'warehouse' => $USERWH,
|
||||
'manifest' => $SHMACPKR, 'source' => $SHSOURCE, 'startDate' => $STARTDATE,
|
||||
'endDate' => $ENDDATE, 'skipDates' => $SKIPDATES, 'showErrors' => $SHOWERRORS,
|
||||
]);
|
||||
|
||||
// Count records before exporting to excel : Max 20K records are allowed
|
||||
$ICM699MCount = $ICM699MC->count();
|
||||
@@ -357,4 +316,31 @@ class M3ErrorsDispController extends Controller
|
||||
Log::error($th);
|
||||
}
|
||||
}
|
||||
private static function applyExportFilters($query, $countQuery, array $filters): void
|
||||
{
|
||||
$queries = [$query, $countQuery];
|
||||
foreach ($queries as $builder) {
|
||||
if ($filters['profileUser'] !== '') {
|
||||
$builder->whereIn('SHCO', [$filters['company'], ''])->whereIn('SHWHS', [$filters['warehouse'], '']);
|
||||
} else {
|
||||
$builder->whereNull('SHCO')->whereNull('SHWHS');
|
||||
}
|
||||
|
||||
if ($filters['manifest'] !== '') {
|
||||
$builder->where('SHMACPKR', $filters['manifest']);
|
||||
}
|
||||
if ($filters['source'] !== '') {
|
||||
$builder->where('SHSOURCE', $filters['source']);
|
||||
}
|
||||
$builder->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
if ($filters['manifest'] === '' && $filters['skipDates'] === 'N') {
|
||||
$builder->whereBetween('SHDT', [$filters['startDate'], $filters['endDate']]);
|
||||
}
|
||||
if ($filters['showErrors'] === 'Y') {
|
||||
$builder->where('SHERROR', 'X');
|
||||
}
|
||||
$builder->where('SHTYPE', 'like', '%M3%');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user