m3 Security Fixes
This commit is contained in:
@@ -25,124 +25,165 @@ class M3InventoryReport extends Controller
|
||||
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'));
|
||||
// dd($request->json()->all());
|
||||
|
||||
// Get the Calling User
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WEBUSER';
|
||||
// Set SHSOURCE
|
||||
$SHSOURCE = 'M3InventoryReport';
|
||||
$M3Errors = '';
|
||||
$DELIVERYNO = isset($DELIVERYNO) ? $DELIVERYNO : self::ZERO_PAD;
|
||||
$user = Str::upper(trim((string) m3_user())) ?: 'WEBUSER';
|
||||
$source = 'M3InventoryReport';
|
||||
$warehouse = '';
|
||||
$payload = [];
|
||||
|
||||
try {
|
||||
// Get Json Contents
|
||||
$jsonFile = count($request->json()->all()) > 0 ? $request->json()->all() : '';
|
||||
if ($jsonFile != '') {
|
||||
$WHS = isset($jsonFile['WHS']) ? $jsonFile['WHS'] : '';
|
||||
$PART = isset($jsonFile['PART']) ? $jsonFile['PART'] : '';
|
||||
$LOT = isset($jsonFile['LOT']) ? $jsonFile['LOT'] : '';
|
||||
} else {
|
||||
// code...
|
||||
}
|
||||
$input = $request->json()->all();
|
||||
$warehouse = trim((string) ($input['WHS'] ?? ''));
|
||||
$payload = [
|
||||
'WHS' => $warehouse,
|
||||
'PART' => trim((string) ($input['PART'] ?? '')),
|
||||
'LOT' => trim((string) ($input['LOT'] ?? '')),
|
||||
];
|
||||
|
||||
// Get Token
|
||||
$tokenResponse = Helper::checkReceiveTokenV2();
|
||||
$tokenData = $tokenResponse->getData();
|
||||
if ($tokenData->code == '200') {
|
||||
$IonToken = isset($tokenData->token) ? $tokenData->token : '';
|
||||
} else {
|
||||
$SHDATA = isset($tokenData->message) ? $tokenData->message : '';
|
||||
// Write to Logs : Error
|
||||
$data = ['SHMACPKR' => self::ZERO_PAD, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => '', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $SHDATA, 'SHUSER' => $SHUSER, 'SHSOURCE' => $SHSOURCE, 'SHCO' => '', 'SHWHS' => $WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
if ((string) ($tokenData->code ?? '') !== '200') {
|
||||
self::logInventoryResponse(
|
||||
self::ZERO_PAD,
|
||||
(string) ($tokenData->message ?? ''),
|
||||
$user,
|
||||
$source,
|
||||
$warehouse
|
||||
);
|
||||
|
||||
return $tokenResponse;
|
||||
}
|
||||
|
||||
// Call ionapi with Params
|
||||
$endPointURL = env('ENDPOINTURL') . 'APIFLOWS/Sentinel/M3InventoryReport?ionapiRespStyle=sync';
|
||||
$token = $IonToken;
|
||||
$JSON = [
|
||||
'WHS' => $WHS,
|
||||
'PART' => $PART,
|
||||
'LOT' => $LOT,
|
||||
];
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'accept' => self::JSON_CONTENT_TYPE,
|
||||
'Content-Type' => self::JSON_CONTENT_TYPE,
|
||||
])
|
||||
->withToken($token)
|
||||
->timeout(Config::get('arrays.curlTimeOut'))
|
||||
->post($endPointURL, $JSON);
|
||||
$responseStatusCode = $response->getStatusCode();
|
||||
|
||||
$M3SessionId = $response->hasHeader('x-transaction-id') ? '-sessionID:' . $response->header('x-transaction-id') : '-sessionID';
|
||||
|
||||
if ($responseStatusCode == '200') {
|
||||
// Check M3 Response for Errors
|
||||
$M3Errors = '';
|
||||
$responseJSON = $response->getBody()->getContents();
|
||||
$JsonSanytized = Helper::sanityzeString($responseJSON);
|
||||
} else {
|
||||
$M3Errors = self::NO_M3_RESPONSE;
|
||||
}
|
||||
|
||||
if ($M3Errors != '') {
|
||||
// Write to Logs : Error
|
||||
$data = ['SHMACPKR' => $DELIVERYNO, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $responseStatusCode . $M3Errors . $M3SessionId, 'SHUSER' => $SHUSER, 'SHSOURCE' => $SHSOURCE, 'SHCO' => '', 'SHWHS' => $WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// Send Response
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => $M3Errors,
|
||||
]);
|
||||
} else {
|
||||
// Write to Logs Out : Success
|
||||
$data = ['SHMACPKR' => $DELIVERYNO, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => '', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $responseStatusCode . $JsonSanytized . '-' . json_encode($JSON) . $M3SessionId, 'SHUSER' => $SHUSER, 'SHSOURCE' => $SHSOURCE,
|
||||
'SHCO' => '', 'SHWHS' => $WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => $responseStatusCode,
|
||||
'status' => 'Success',
|
||||
'message' => json_decode($JsonSanytized),
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
$getCurlErrors = str_contains($th->getMessage(), 'cURL error');
|
||||
if ($getCurlErrors) {
|
||||
// Write to Logs Out : Failed
|
||||
$data = ['SHMACPKR' => $DELIVERYNO, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => 'Curl Error: Communication with M3 Timed Out' . ' M3-JSN-out' . $JSON, 'SHUSER' => $SHUSER, 'SHSOURCE' => $SHSOURCE, 'SHCO' => '', 'SHWHS' => $WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Curl Error: Communication with M3 Timed Out.',
|
||||
]);
|
||||
} else {
|
||||
// Write to Logs Out : Error
|
||||
$data = ['SHMACPKR' => $DELIVERYNO, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => 'An Error Occured - ' . substr($th, 0, 300), 'SHUSER' => $SHUSER, 'SHSOURCE' => $SHSOURCE];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Catched Error: ' . $th,
|
||||
]);
|
||||
}
|
||||
|
||||
return self::sendInventoryRequest(
|
||||
(string) ($tokenData->token ?? ''),
|
||||
$payload,
|
||||
$user,
|
||||
$source,
|
||||
$warehouse
|
||||
);
|
||||
} catch (\Throwable $exception) {
|
||||
return self::inventoryExceptionResponse($exception, $payload, $user, $source, $warehouse);
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendInventoryRequest(
|
||||
string $token,
|
||||
array $payload,
|
||||
string $user,
|
||||
string $source,
|
||||
string $warehouse
|
||||
) {
|
||||
if ($token === '') {
|
||||
return response()->json([
|
||||
'code' => '401',
|
||||
'status' => 'error',
|
||||
'message' => 'M3 authentication token was not returned.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'accept' => self::JSON_CONTENT_TYPE,
|
||||
'Content-Type' => self::JSON_CONTENT_TYPE,
|
||||
])
|
||||
->withToken($token)
|
||||
->timeout(Config::get('arrays.curlTimeOut'))
|
||||
->post(env('ENDPOINTURL') . 'APIFLOWS/Sentinel/M3InventoryReport?ionapiRespStyle=sync', $payload);
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
$sessionId = $response->hasHeader('x-transaction-id')
|
||||
? '-sessionID:' . $response->header('x-transaction-id')
|
||||
: '-sessionID';
|
||||
|
||||
if ($statusCode !== Response::HTTP_OK) {
|
||||
self::logInventoryResponse(
|
||||
self::ZERO_PAD,
|
||||
$statusCode . self::NO_M3_RESPONSE . $sessionId,
|
||||
$user,
|
||||
$source,
|
||||
$warehouse,
|
||||
true
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => self::NO_M3_RESPONSE,
|
||||
], 502);
|
||||
}
|
||||
|
||||
$sanitized = Helper::sanityzeString($response->body());
|
||||
self::logInventoryResponse(
|
||||
self::ZERO_PAD,
|
||||
$statusCode . $sanitized . '-' . json_encode($payload) . $sessionId,
|
||||
$user,
|
||||
$source,
|
||||
$warehouse
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'code' => $statusCode,
|
||||
'status' => 'Success',
|
||||
'message' => json_decode($sanitized),
|
||||
]);
|
||||
}
|
||||
|
||||
private static function inventoryExceptionResponse(
|
||||
\Throwable $exception,
|
||||
array $payload,
|
||||
string $user,
|
||||
string $source,
|
||||
string $warehouse
|
||||
) {
|
||||
$isCurlError = str_contains($exception->getMessage(), 'cURL error');
|
||||
$message = $isCurlError
|
||||
? 'Curl Error: Communication with M3 Timed Out.'
|
||||
: 'M3 inventory request failed.';
|
||||
|
||||
self::logInventoryResponse(
|
||||
self::ZERO_PAD,
|
||||
$isCurlError ? $message : mb_substr($exception->getMessage(), 0, 300),
|
||||
$user,
|
||||
$source,
|
||||
$warehouse,
|
||||
true
|
||||
);
|
||||
|
||||
Log::error('M3 inventory request failed.', [
|
||||
'exception' => $exception,
|
||||
'payload' => $payload,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => $message,
|
||||
], 502);
|
||||
}
|
||||
|
||||
private static function logInventoryResponse(
|
||||
string $deliveryNumber,
|
||||
string $message,
|
||||
string $user,
|
||||
string $source,
|
||||
string $warehouse,
|
||||
bool $isError = false
|
||||
): void {
|
||||
Helper::logToICM699M([
|
||||
'SHMACPKR' => $deliveryNumber,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => $isError ? 'X' : '',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $message,
|
||||
'SHUSER' => $user,
|
||||
'SHSOURCE' => $source,
|
||||
'SHCO' => '',
|
||||
'SHWHS' => $warehouse,
|
||||
]);
|
||||
}
|
||||
|
||||
// End M3InventoryReport
|
||||
|
||||
// M3InventoryReportList with URL Params
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Log;
|
||||
use Storage;
|
||||
use Str;
|
||||
@@ -13,99 +13,95 @@ class WhsPerfMetrics extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$context = self::defaultContext();
|
||||
|
||||
try {
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
// dd($SHUSER);
|
||||
|
||||
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)
|
||||
->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
|
||||
}
|
||||
|
||||
// Warehouse Table
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// 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 = "
|
||||
SELECT A5MACPKR, A5ONO,
|
||||
(SELECT A4REFORD FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) AS A4REFORD,
|
||||
A5PART, A5RSVQTY, A5PACKED, A5RSVQTY - A5PACKED AS CALCULATED_COLUMN,
|
||||
A5SLUNPR * A5PACKED AS ANOTHER_CALCULATED_COLUMN,
|
||||
(SELECT A4SHSHNM FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) AS A4SHSHNM ,
|
||||
SHDT, SHTIME,
|
||||
CASE WHEN SHDT IS NULL THEN (SELECT SHDATA FROM ICM699M WHERE SHMACPKR=A5MACPKR AND SHTYPE='M3-Res-out' AND SHSOURCE='CloseShipmentCoChargeAPI' ORDER BY SHDT DESC, SHTIME DESC FETCH FIRST 1 ROWS ONLY) ELSE '' END AS REASON,
|
||||
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 . "
|
||||
END AS FREIGHT
|
||||
FROM ICM688M2
|
||||
LEFT JOIN ICM699M ON SHMACPKR=A5MACPKR AND SHTYPE='M3-Res-out' AND SHDATA LIKE 'Success%' AND SHSOURCE='CloseShipmentCoChargeAPI'
|
||||
LEFT JOIN ICM666M ON A1DELNO=A5MACPKR AND A1ONO=A5ONO AND A1PKLN=A5BRADLN
|
||||
WHERE A5MACPKR IN (
|
||||
SELECT DISTINCT AYMACPKR
|
||||
FROM ICM695M1
|
||||
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();
|
||||
}
|
||||
|
||||
// Get List of Files
|
||||
$allReportsUrls = [];
|
||||
$files = Storage::disk('publicLabels')->allFiles('WhsPerf/' . $WHS);
|
||||
// $whsPerfFile = 'WhsPerf/'.$WHS.'/WhsPerfMetrics_'.$DateToday.'-'.$WHS.'.xlsx';
|
||||
|
||||
foreach ($files as $file) {
|
||||
// Get the file URL (if URL is configured in filesystems.php)
|
||||
$url = Storage::disk('publicLabels')->url($file);
|
||||
$allReportsUrls[$file] = $url;
|
||||
}
|
||||
// dd($allReportsUrls);
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
$context = array_merge($context, self::loadUserContext());
|
||||
$context['IC670M'] = self::loadWarehouses();
|
||||
$context['WHDDA'] = $context['COMPANY'] . $context['PLANT'] . $context['WHS'];
|
||||
$context['allReportsUrls'] = self::loadReportUrls($context['WHS']);
|
||||
} catch (\Throwable $exception) {
|
||||
Log::error('Unable to load warehouse performance metrics.', [
|
||||
'exception' => $exception,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.WhsPerfMetrics', compact('IC670M', 'WHDDA', 'COMPANY', 'PLANT', 'WHS', 'allReportsUrls'));
|
||||
return view('m3::liberty-theme.pages.WhsPerfMetrics', $context);
|
||||
}
|
||||
|
||||
// Download File
|
||||
public static function downloadFiles(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
$fileName = $request->filename;
|
||||
if (Storage::disk('publicLabels')->exists($fileName)) {
|
||||
// File exists, retrieve content or URL
|
||||
$fileUrl = Storage::disk('publicLabels')->url($fileName);
|
||||
$fileNameOnly = basename($fileName);
|
||||
$validated = $request->validate([
|
||||
'filename' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
// Download the file
|
||||
return Storage::disk('publicLabels')->download($fileName, $fileNameOnly);
|
||||
} else {
|
||||
// Download the file (use code below)
|
||||
$fileName = ltrim($validated['filename'], '/');
|
||||
$disk = Storage::disk('publicLabels');
|
||||
|
||||
if (! $disk->exists($fileName)) {
|
||||
abort(404, 'Warehouse performance file not found.');
|
||||
}
|
||||
|
||||
return $disk->download($fileName, basename($fileName));
|
||||
}
|
||||
|
||||
private static function defaultContext(): array
|
||||
{
|
||||
return [
|
||||
'IC670M' => collect(),
|
||||
'WHDDA' => '',
|
||||
'COMPANY' => '',
|
||||
'PLANT' => '',
|
||||
'WHS' => '',
|
||||
'allReportsUrls' => [],
|
||||
];
|
||||
}
|
||||
|
||||
private static function loadUserContext(): array
|
||||
{
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
$user = Str::upper(trim((string) m3_user()));
|
||||
|
||||
if ($user === '' || ! Schema::connection($connection)->hasTable('icm428m')) {
|
||||
return ['COMPANY' => '', 'PLANT' => '', 'WHS' => ''];
|
||||
}
|
||||
|
||||
$profile = DB::connection($connection)->table('icm428m')
|
||||
->select('R428CO', 'R428PL', 'R428WH')
|
||||
->where('R428US', $user)
|
||||
->first();
|
||||
|
||||
return [
|
||||
'COMPANY' => trim((string) ($profile->R428CO ?? '')),
|
||||
'PLANT' => trim((string) ($profile->R428PL ?? '')),
|
||||
'WHS' => trim((string) ($profile->R428WH ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
private static function loadWarehouses()
|
||||
{
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
|
||||
if (! Schema::connection($connection)->hasTable('ic670m')) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
return DB::connection($connection)->table('ic670m')->get();
|
||||
}
|
||||
|
||||
private static function loadReportUrls(string $warehouse): array
|
||||
{
|
||||
if ($warehouse === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$disk = Storage::disk('publicLabels');
|
||||
$urls = [];
|
||||
|
||||
foreach ($disk->allFiles('WhsPerf/' . $warehouse) as $file) {
|
||||
$urls[$file] = $disk->url($file);
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Str;
|
||||
|
||||
class execSummaryController extends Controller
|
||||
{
|
||||
private const WAREHOUSE_IN_CLAUSE = "' and a5whs in (";
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$IC670M = collect();
|
||||
@@ -71,7 +72,7 @@ class execSummaryController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDate and ayapr8N002<=$toreportDate )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ")
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ")
|
||||
)
|
||||
select substr(ayapr8N002,3,2) ||'-' || 'Q' || EXTRACT(QUARTER FROM TO_DATE(CAST(ayapr8n002 AS TEXT),'YYYYMMDD')) as years,count(*) as lines,
|
||||
sum(a5rsvqty) as reserveqty, sum(a5packed) as packed,sum (a5lnwght*a5packed/a5rsvqty) as weight,sum(dollars) as dollars, a5whs as whs
|
||||
@@ -93,7 +94,7 @@ class execSummaryController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDate and ayapr8N002<=$toreportDate )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ")
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ")
|
||||
)
|
||||
select substr(ayapr8N002,1,4) || '-' || substr(ayapr8N002,5,2) as years,count(*) as lines,sum(a5rsvqty) as reserveqty,sum(a5packed) as packed,
|
||||
sum(a5lnwght*a5packed/a5rsvqty) as weight,sum(dollars) as dollars, a5whs as whs
|
||||
@@ -116,7 +117,7 @@ class execSummaryController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDate and ayapr8N002<=$toreportDate )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ')
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ')
|
||||
)
|
||||
select substr(ayapr8N002,7,2) as years,count(*) as lines,sum(a5rsvqty) as reserveqty,sum(a5packed) as packed,
|
||||
sum(a5lnwght*a5packed/a5rsvqty) as weight, sum(dollars) as dollars, a5whs as whs
|
||||
|
||||
@@ -9,6 +9,7 @@ use Str;
|
||||
|
||||
class execSummaryLineController extends Controller
|
||||
{
|
||||
private const WAREHOUSE_IN_CLAUSE = "' and a5whs in (";
|
||||
private const FIRST_DAY_THIS_MONTH = 'first day of this month';
|
||||
private const LAST_DAY_THIS_MONTH = 'last day of this month';
|
||||
private const ONE_YEAR_AGO = '-1 year';
|
||||
@@ -70,7 +71,7 @@ class execSummaryLineController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDate and ayapr8N002<=$toreportDate )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ")
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ")
|
||||
)
|
||||
select 'Q' || EXTRACT(QUARTER FROM TO_DATE(CAST(ayapr8n002 AS TEXT),'YYYYMMDD')) ||'-' || substr(ayapr8N002,3,2) as years,count(*) as lines,
|
||||
sum(a5rsvqty) as reserveqty, sum(a5packed) as packed,sum (a5lnwght*a5packed/a5rsvqty) as weight,sum(dollars) as dollars, a5whs as whs
|
||||
@@ -99,7 +100,7 @@ class execSummaryLineController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDate and ayapr8N002<=$toreportDate )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ")
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ")
|
||||
)
|
||||
select substr(ayapr8N002,1,4) || '-' || substr(ayapr8N002,5,2) as years,count(*) as lines,sum(a5rsvqty) as reserveqty,sum(a5packed) as packed,
|
||||
sum(a5lnwght*a5packed/a5rsvqty) as weight,sum(dollars) as dollars, a5whs as whs
|
||||
@@ -111,7 +112,7 @@ class execSummaryLineController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDateLY and ayapr8N002<=$toreportDateLY )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ")
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ")
|
||||
)
|
||||
select substr(ayapr8N002,1,4) || '-' || substr(ayapr8N002,5,2) as years,count(*) as lines,sum(a5rsvqty) as reserveqty,sum(a5packed) as packed,
|
||||
sum(a5lnwght*a5packed/a5rsvqty) as weight,sum(dollars) as dollars, a5whs as whs
|
||||
@@ -138,7 +139,7 @@ class execSummaryLineController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDate and ayapr8N002<=$toreportDate )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ')
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ')
|
||||
)
|
||||
select substr(ayapr8N002,7,2) as years,count(*) as lines,sum(a5rsvqty) as reserveqty,sum(a5packed) as packed,
|
||||
sum(a5lnwght*a5packed/a5rsvqty) as weight, sum(dollars) as dollars, a5whs as whs
|
||||
@@ -150,7 +151,7 @@ class execSummaryLineController extends Controller
|
||||
(select max(ayapr8N002) as ayapr8N002 from icm695m1 where a5macpkr=aymacpkr fetch first 1 rows only)
|
||||
from icm688m2 where a5macpkr in (
|
||||
select distinct aymacpkr from icm695m1 where (AYSTATUS in ('Z','z') and ayapr8N002>=$reportDateLY and ayapr8N002<=$toreportDateLY )
|
||||
) and a5co='" . $CO . "' and a5whs in (" . implode(',', $WHArr) . ')
|
||||
) and a5co='" . $CO . self::WAREHOUSE_IN_CLAUSE . implode(',', $WHArr) . ')
|
||||
)
|
||||
select substr(ayapr8N002,7,2) as years,count(*) as lines,sum(a5rsvqty) as reserveqty,sum(a5packed) as packed,
|
||||
sum(a5lnwght*a5packed/a5rsvqty) as weight, sum(dollars) as dollars, a5whs as whs
|
||||
|
||||
@@ -85,27 +85,7 @@ class userControlController extends Controller
|
||||
} catch (\Throwable $e) {
|
||||
// Determine reason for failure.
|
||||
// Probably database authentication error or invalid or unreachable database.
|
||||
$code = $e->getCode();
|
||||
$msg = $e->getMessage();
|
||||
switch ($code) {
|
||||
case 8001:
|
||||
// "Authorization failure on distributed database connection attempt"
|
||||
// Usually means a wrong DB2 user or password
|
||||
$PGMERRORS = self::AUTH_FAILURE_MESSAGE;
|
||||
|
||||
return 'error profile3';
|
||||
break;
|
||||
case 42705:
|
||||
$PGMERRORS = self::DATABASE_NOT_FOUND_MESSAGE;
|
||||
|
||||
return 'error profile4';
|
||||
break;
|
||||
default:
|
||||
$PGMERRORS = self::CONNECTION_ERROR_PREFIX . $code . ' ' . $msg;
|
||||
|
||||
return 'error profile5';
|
||||
break;
|
||||
}
|
||||
return self::programBridgeConnectionError($e);
|
||||
}
|
||||
$conn->setOptions(['persistent' => false, 'stateless' => true, 'debug' => true, 'debugLogFile' => '/www/sentm3test/htdocs/M3/storage/logs/toolkit_debug.log']);
|
||||
// Add LIB
|
||||
@@ -343,4 +323,15 @@ class userControlController extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
private static function programBridgeConnectionError(\Throwable $exception): string
|
||||
{
|
||||
$code = (int) $exception->getCode();
|
||||
|
||||
return match ($code) {
|
||||
8001 => 'error profile3',
|
||||
42705 => 'error profile4',
|
||||
default => 'error profile5',
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
<?php
|
||||
|
||||
$selectedInvalidMessage = $selectedInvalidMessage;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| as the size rules. Feel free to tweak each of these messages here.
|
||||
|
|
||||
*/
|
||||
|
||||
'accepted' => 'The :attribute must be accepted.',
|
||||
'active_url' => 'The :attribute is not a valid URL.',
|
||||
'after' => 'The :attribute must be a date after :date.',
|
||||
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
|
||||
'alpha' => 'The :attribute must only contain letters.',
|
||||
'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.',
|
||||
'alpha_num' => 'The :attribute must only contain letters and numbers.',
|
||||
'array' => 'The :attribute must be an array.',
|
||||
'before' => 'The :attribute must be a date before :date.',
|
||||
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
|
||||
'between' => [
|
||||
'numeric' => 'The :attribute must be between :min and :max.',
|
||||
'file' => 'The :attribute must be between :min and :max kilobytes.',
|
||||
'string' => 'The :attribute must be between :min and :max characters.',
|
||||
'array' => 'The :attribute must have between :min and :max items.',
|
||||
],
|
||||
'boolean' => 'The :attribute field must be true or false.',
|
||||
'confirmed' => 'The :attribute confirmation does not match.',
|
||||
'current_password' => 'The password is incorrect.',
|
||||
'date' => 'The :attribute is not a valid date.',
|
||||
'date_equals' => 'The :attribute must be a date equal to :date.',
|
||||
'date_format' => 'The :attribute does not match the format :format.',
|
||||
'different' => 'The :attribute and :other must be different.',
|
||||
'digits' => 'The :attribute must be :digits digits.',
|
||||
'digits_between' => 'The :attribute must be between :min and :max digits.',
|
||||
'dimensions' => 'The :attribute has invalid image dimensions.',
|
||||
'distinct' => 'The :attribute field has a duplicate value.',
|
||||
'email' => 'The :attribute must be a valid email address.',
|
||||
'ends_with' => 'The :attribute must end with one of the following: :values.',
|
||||
'exists' => $selectedInvalidMessage,
|
||||
'file' => 'The :attribute must be a file.',
|
||||
'filled' => 'The :attribute field must have a value.',
|
||||
'gt' => [
|
||||
'numeric' => 'The :attribute must be greater than :value.',
|
||||
'file' => 'The :attribute must be greater than :value kilobytes.',
|
||||
'string' => 'The :attribute must be greater than :value characters.',
|
||||
'array' => 'The :attribute must have more than :value items.',
|
||||
],
|
||||
'gte' => [
|
||||
'numeric' => 'The :attribute must be greater than or equal :value.',
|
||||
'file' => 'The :attribute must be greater than or equal :value kilobytes.',
|
||||
'string' => 'The :attribute must be greater than or equal :value characters.',
|
||||
'array' => 'The :attribute must have :value items or more.',
|
||||
],
|
||||
'image' => 'The :attribute must be an image.',
|
||||
'in' => $selectedInvalidMessage,
|
||||
'in_array' => 'The :attribute field does not exist in :other.',
|
||||
'integer' => 'The :attribute must be an integer.',
|
||||
'ip' => 'The :attribute must be a valid IP address.',
|
||||
'ipv4' => 'The :attribute must be a valid IPv4 address.',
|
||||
'ipv6' => 'The :attribute must be a valid IPv6 address.',
|
||||
'json' => 'The :attribute must be a valid JSON string.',
|
||||
'lt' => [
|
||||
'numeric' => 'The :attribute must be less than :value.',
|
||||
'file' => 'The :attribute must be less than :value kilobytes.',
|
||||
'string' => 'The :attribute must be less than :value characters.',
|
||||
'array' => 'The :attribute must have less than :value items.',
|
||||
],
|
||||
'lte' => [
|
||||
'numeric' => 'The :attribute must be less than or equal :value.',
|
||||
'file' => 'The :attribute must be less than or equal :value kilobytes.',
|
||||
'string' => 'The :attribute must be less than or equal :value characters.',
|
||||
'array' => 'The :attribute must not have more than :value items.',
|
||||
],
|
||||
'max' => [
|
||||
'numeric' => 'The :attribute must not be greater than :max.',
|
||||
'file' => 'The :attribute must not be greater than :max kilobytes.',
|
||||
'string' => 'The :attribute must not be greater than :max characters.',
|
||||
'array' => 'The :attribute must not have more than :max items.',
|
||||
],
|
||||
'mimes' => 'The :attribute must be a file of type: :values.',
|
||||
'mimetypes' => 'The :attribute must be a file of type: :values.',
|
||||
'min' => [
|
||||
'numeric' => 'The :attribute must be at least :min.',
|
||||
'file' => 'The :attribute must be at least :min kilobytes.',
|
||||
'string' => 'The :attribute must be at least :min characters.',
|
||||
'array' => 'The :attribute must have at least :min items.',
|
||||
],
|
||||
'multiple_of' => 'The :attribute must be a multiple of :value.',
|
||||
'not_in' => $selectedInvalidMessage,
|
||||
'not_regex' => 'The :attribute format is invalid.',
|
||||
'numeric' => 'The :attribute must be a number.',
|
||||
'password' => 'The password is incorrect.',
|
||||
'present' => 'The :attribute field must be present.',
|
||||
'regex' => 'The :attribute format is invalid.',
|
||||
'required' => 'The :attribute field is required.',
|
||||
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||
'required_with' => 'The :attribute field is required when :values is present.',
|
||||
'required_with_all' => 'The :attribute field is required when :values are present.',
|
||||
'required_without' => 'The :attribute field is required when :values is not present.',
|
||||
'required_without_all' => 'The :attribute field is required when none of :values are present.',
|
||||
'prohibited' => 'The :attribute field is prohibited.',
|
||||
'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
|
||||
'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',
|
||||
'same' => 'The :attribute and :other must match.',
|
||||
'size' => [
|
||||
'numeric' => 'The :attribute must be :size.',
|
||||
'file' => 'The :attribute must be :size kilobytes.',
|
||||
'string' => 'The :attribute must be :size characters.',
|
||||
'array' => 'The :attribute must contain :size items.',
|
||||
],
|
||||
'starts_with' => 'The :attribute must start with one of the following: :values.',
|
||||
'string' => 'The :attribute must be a string.',
|
||||
'timezone' => 'The :attribute must be a valid timezone.',
|
||||
'unique' => 'The :attribute has already been taken.',
|
||||
'uploaded' => 'The :attribute failed to upload.',
|
||||
'url' => 'The :attribute must be a valid URL.',
|
||||
'uuid' => 'The :attribute must be a valid UUID.',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => [
|
||||
'attribute-name' => [
|
||||
'rule-name' => 'custom-message',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap our attribute placeholder
|
||||
| with something more reader friendly such as "E-Mail Address" instead
|
||||
| of "email". This simply helps us make our message more expressive.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => [],
|
||||
|
||||
];
|
||||
Reference in New Issue
Block a user