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
@@ -14,7 +14,6 @@ use Modules\M3\Http\Controllers\Controller;
use Modules\M3\Http\Controllers\GetContentsController;
use Str;
// use Request;
class CloseShipment extends Controller
{
private const ZERO_PAD = '000000';
@@ -55,7 +54,6 @@ class CloseShipment extends Controller
$pdfFilePath = Config::get('arrays.PdfPath');
$DELIVERYNO = $MANIFEST != '' ? $MANIFEST : self::ZERO_PAD;
// Log::channel('dailyCron')->info("Close Manifest:".$MANIFEST.'-WHS: '.$WHS."-CO:".$COMPANY);
if ($urlParams != '') {
// Write to Logs : JSON
@@ -65,7 +63,6 @@ class CloseShipment extends Controller
'MANIFEST-MACPKR' => $MANIFEST,
'TRANSTYPE' => $TRANSTYPE,
]);
// dd($JSONIN);
$data = [
'SHMACPKR' => $DELIVERYNO,
@@ -81,13 +78,11 @@ class CloseShipment extends Controller
'SHWHS' => $WHS,
];
Helper::logToICM699M($data);
// dd($JSONIN);
// Get Token
$tokenResponse = Helper::checkReceiveTokenV2();
$tokenData = $tokenResponse->getData();
// dd($IonToken->code);
if ($tokenData->code == '200') {
$IonToken = isset($tokenData->token) ? $tokenData->token : '';
@@ -160,14 +155,12 @@ class CloseShipment extends Controller
->where('SHERROR', 'Z')
->where('SHTYPE', 'M3-QtyChg')
->get();
// dd($ICM699MQtyChg);
foreach ($ICM699MQtyChg as $key => $ICM699MQtyChgR) {
$string = $ICM699MQtyChgR->SHDATA;
$start = 'PickerLine:';
$end = ' -';
$LineAck[] = Helper::getSubstringBetween($string, $start, $end);
}
// dd($LineAck);
} elseif ($TRANSTYPE == 'Z') {
$ICM695M1PREP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
->select()
@@ -179,7 +172,6 @@ class CloseShipment extends Controller
}
$ICM695M1TMP = $ICM695M1PREP->get();
// dump($ICM695M1TMP);
// Log::channel('dailyCron')->info($ICM695M1TMP);
// PFC if MACKPKR already Closed : Case 671
@@ -193,10 +185,8 @@ class CloseShipment extends Controller
return trim($post->AYMACPKR);
});
}
// dump($ICM695M1TMPCOLF);
$ICM695M1TMPCOLFA = $ICM695M1TMPCOLF->toArray();
// dump($ICM695M1TMPCOLFA);
$ICM699MSuccess = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
->select('SHMACPKR')
@@ -208,12 +198,10 @@ class CloseShipment extends Controller
->where('SHTYPE', 'M3-Res-out')
->where('SHDATA', 'like', '%Success%')
->get();
// dump($ICM699MSuccess);
$ICM699MSuccessCol = collect($ICM699MSuccess);
$ICM699MSuccessColF = $ICM699MSuccessCol->map(function ($post) {
return $post->SHMACPKR;
});
// dump($ICM699MSuccessColF);
$ICM699MSuccessColFAr = $ICM699MSuccessColF->toArray();
if ($TRANSTYPE == 'Z') {
@@ -229,9 +217,7 @@ class CloseShipment extends Controller
}
$ICM695M1TMP = $ICM695M1TMPF;
// Log::channel('dailyCron')->info($ICM695M1TMP);
// dd($ICM695M1TMP);
$FreightTermsTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm321m')
->selectRaw('TRIM(ARCODE) as FREIGHTTERMS,ARCHARGE as BILLABLE')
->get();
@@ -311,7 +297,6 @@ class CloseShipment extends Controller
->where('AYWHS', $AYWHS)
->orderBy('AYINTBOX')
->get();
// dd($ICM695M1JOINTMP);
foreach ($ICM695M1JOINTMP as $key => $ICM695M1JOINR) {
$A4SHIPVIA = isset($ICM695M1JOINR->A4SHIPVIA) ? trim(str_replace('&', '_', $ICM695M1JOINR->A4SHIPVIA)) : '';
@@ -421,7 +406,6 @@ class CloseShipment extends Controller
->first();
$AlreadySentToM3 = isset($ICM699MS->SHMACPKR) ? trim($ICM699MS->SHMACPKR) : '';
// dump($AlreadySentToM3);
if ($AlreadySentToM3 != '') {
// Add Message
@@ -482,7 +466,6 @@ class CloseShipment extends Controller
$DOCNUMT = $AYINTBOX;
$PDFKey = $value . '/' . $value . '_' . $AYMACPKR . '_' . $DOCNUMT . '_' . $COMPANY . '_' . $WHS;
$pdfFileName = $pdfFilePath . $PDFKey . '.pdf';
// dd($pdfFileName);
if (File::exists($pdfFileName)) {
$CarrierLabel = route('m3.M3GetPDFFromCache.index', ['MACPKR' => $AYMACPKR, 'DOCTYPE' => $DOCTYPE]);
@@ -494,7 +477,6 @@ class CloseShipment extends Controller
$DOCNUMT = $AYINTBOX;
$PDFKey = $value . '/' . $value . '_' . $AYMACPKR . '_' . $DOCNUMT . '_' . $COMPANY . '_' . $WHS;
$pdfFileName = $pdfFilePath . $PDFKey . '.pdf';
// dd($pdfFileName);
if (File::exists($pdfFileName)) {
$ContentLabel = route('m3.M3GetPDFFromCache.index', ['MACPKR' => $AYMACPKR, 'DOCTYPE' => $DOCTYPE]);
@@ -535,7 +517,6 @@ class CloseShipment extends Controller
'CONTENTLABELDOC' => $ContentLabel,
];
}
// dump($PACKAGES);
// Check Packages array before proceeding with CloseShipment
if (count($PACKAGES) > 0) {
@@ -545,12 +526,10 @@ class CloseShipment extends Controller
$DOCNUMT = $AYMACPKR;
$PDFKey = $DOCTYPE . '/' . $DOCTYPE . '_' . $AYMACPKR . '_' . $DOCNUMT . '_' . $COMPANY . '_' . $WHS;
$pdfFileName = $pdfFilePath . $PDFKey . '.pdf';
// dd($pdfFileName);
if (File::exists($pdfFileName)) {
$PackingList = route('m3.M3GetPDFFromCache.index', ['MACPKR' => $AYMACPKR, 'DOCTYPE' => $DOCTYPE]);
}
// dd($PackingList);
// Add Cocharge
if (count($JSONCoCharge) > 0) {
@@ -604,7 +583,6 @@ class CloseShipment extends Controller
'ENDFLAG' => $EndFlag,
]);
}
// dump($JSONCS);
// No Errors Proceed in Calling M3 CLose API
if ($ErrorMsgs == '') {
@@ -670,7 +648,6 @@ class CloseShipment extends Controller
// Check M3 Response for Errors
$responseResult = $responseContents->result;
$M3Errors = Helper::checkM3Errors($responseResult);
// dd($M3Errors);
// If you get a successful response, update database file ICM688M1/A4RATEm3=X
// Update ICM688M1 : Change A4RATEM3
@@ -811,7 +788,6 @@ class CloseShipment extends Controller
}
// Close Shipment for Zero Picks
elseif (count($ICM695M1TMP) > 0 && $TRANSTYPE == 'Z') {
// dd($ICM695M1TMP);
$ErrorMsgs = '';
foreach ($ICM695M1TMP as $key => $ICM695M1JOINR) {
@@ -825,7 +801,6 @@ class CloseShipment extends Controller
$A4CLOSEM3 = trim($ICM695M1JOINR->A4CLOSEM3);
$AYWHS = trim($ICM695M1JOINR->A4WHS);
$AYCO = trim($ICM695M1JOINR->A4CO);
// dump($AYMACPKR);
// Construct Json for CloseShipment Without PDF Files
$JSONCS = json_encode([
@@ -939,7 +914,6 @@ class CloseShipment extends Controller
'SHCO' => $COMPANY,
'SHWHS' => $WHS,
];
// dump($data);
Helper::logToICM699M($data);
// Add Message
$ErrorMsgs = $ErrorMsgs . $M3Errors . '-';
@@ -1031,7 +1005,6 @@ class CloseShipment extends Controller
]);
}
} catch (\Throwable $th) {
// Log::error($th);
$getCurlErrors = str_contains($th->getMessage(), 'cURL error');
if ($getCurlErrors) {
// dd($getCurlErrors);