m3 Security Fixes

This commit is contained in:
Mark Gregory
2026-09-16 17:14:26 +01:00
parent 1602bdd72e
commit d68687f062
78 changed files with 1297 additions and 1228 deletions
@@ -50,11 +50,11 @@ class CloseShipment extends Controller
# PDF File PATH
$pdfFilePath = Config::get('arrays.PdfPath');
$DELIVERYNO = $MANIFEST != '' ? $MANIFEST : '000000';
// Log::channel('dailyCron')->info("Close Manifest:".$MANIFEST.'-WHS: '.$WHS."-CO:".$COMPANY);
if ($urlParams != '') {
# Write to Logs : JSON
# Write to Logs : JSON
$JSONIN = json_encode([
"WHS" => $WHS,
"COMPANY" => $COMPANY,
@@ -87,7 +87,7 @@ class CloseShipment extends Controller
if ($tokenData->code == '200') {
$IonToken = isset($tokenData->token) ? $tokenData->token : '';
}
}
else {
$SHDATA = isset($tokenData->message) ? $tokenData->message : '';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
@@ -107,7 +107,7 @@ class CloseShipment extends Controller
'SHWHS' => $WHS
];
Helper::logToICM699M($data);
return $tokenResponse;
}
@@ -133,7 +133,7 @@ class CloseShipment extends Controller
->where('AYMACPKR',$MANIFEST)
->where('AYWHS',$WHS)
->orderBy('AYMACPKR');
# Check Date & Time Before Updating ICM699M
if ($SHDT!='' && $SHTIME!='' && $SHTYPE!='' && $NODEBUG) {
$ICM699MU = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
@@ -141,7 +141,7 @@ class CloseShipment extends Controller
->where('SHDT',$SHDT)
->where('SHTIME',$SHTIME)
->where('SHCO',$COMPANY)
->where('SHWHS',$WHS)
->where('SHWHS',$WHS)
->where('SHSOURCE',$SHSOURCE)
->where('SHERROR','X')
->where('SHTYPE',$SHTYPE)
@@ -153,7 +153,7 @@ class CloseShipment extends Controller
->select()
->where('SHMACPKR',$MANIFEST)
->where('SHCO',$COMPANY)
->where('SHWHS',$WHS)
->where('SHWHS',$WHS)
->where('SHSOURCE','PackSyst4tray')
->where('SHERROR','Z')
->where('SHTYPE','M3-QtyChg')
@@ -176,7 +176,7 @@ class CloseShipment extends Controller
->where('A4MACPKR',$MANIFEST)
->orderBy('A4MACPKR');
}
$ICM695M1TMP = $ICM695M1PREP->get();
// dump($ICM695M1TMP);
// Log::channel('dailyCron')->info($ICM695M1TMP);
@@ -194,7 +194,7 @@ class CloseShipment extends Controller
});
}
// dump($ICM695M1TMPCOLF);
$ICM695M1TMPCOLFA = $ICM695M1TMPCOLF->toArray();
// dump($ICM695M1TMPCOLFA);
@@ -239,7 +239,7 @@ class CloseShipment extends Controller
# Close Shipment for Manifest or Single MacPKR
if (count($ICM695M1TMP)>0 && ($TRANSTYPE=='M' || $TRANSTYPE=='P')) {
# Loop the Results from $ICM595M1TMP
# Loop the Results from $ICM595M1TMP
foreach ($ICM695M1TMP as $key => $ICM695M1R) {
$PACKAGES = [];
$AYWHS = trim($ICM695M1R->AYWHS);
@@ -272,7 +272,7 @@ class CloseShipment extends Controller
// ->where('IMWHS',$AYWHS)
// ->where('IMDELNO',$AYMACPKR)
// ->where('IMLINE',$AYRLNO)
// ->whereIn('IMTOLOC',['DOCK','PACK'])
// ->whereIn('IMTOLOC',['DOCK','PACK'])
// ->get();
# PFC : Check that Picked / Packed are all Equal
@@ -283,13 +283,13 @@ class CloseShipment extends Controller
$A5RSVQTY = isset($ICM688M2SLR->A5RSVQTY) ? $ICM688M2SLR->A5RSVQTY : 0;
$A5ShortShipQty = (int) $A5RSVQTY - (int) $A5PICKED;
# Set EndFLag=1 for short picks
# Set EndFLag=1 for short picks
if ($A5ShortShipQty > 0) {
$EndFlag = 1;
}
}
# Get TRAILERNUMBER SELECT APTRUCKID FROM ICM705M1 WHERE APCO=110 AND APWHS=321 AND APMANIFEST=22
# Get TRAILERNUMBER SELECT APTRUCKID FROM ICM705M1 WHERE APCO=110 AND APWHS=321 AND APMANIFEST=22
$TRAILERNUMBERS = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
->select('APTRUCKID','APTRACKNO','APMANIFEST')
->where('APCO',$COMPANY)
@@ -313,7 +313,7 @@ class CloseShipment extends Controller
->orderBy('AYINTBOX')
->get();
// dd($ICM695M1JOINTMP);
foreach ($ICM695M1JOINTMP as $key => $ICM695M1JOINR) {
$A4SHIPVIA = isset($ICM695M1JOINR->A4SHIPVIA) ? trim(str_replace("&", "_",$ICM695M1JOINR->A4SHIPVIA)) : '';
@@ -375,18 +375,18 @@ class CloseShipment extends Controller
->where('A1DELNO',$AYMACPKR)
->first();
$GS1LabelExist = isset($ICM666MSQLSel->A1SPR1A01) ? trim($ICM666MSQLSel->A1SPR1A01) : 0;
# Case #566: BOL = PRONUMBER For SCAC=='RETR'
if ($SCAC=='RETR') {
$BILLOFLADING = $PRONUMBER;
}
# Get Commodities
# Get Commodities
$myRequest = new Request();
$myRequest->setMethod('POST');
$myRequest->request->add([
'MACPKR' => $AYMACPKR
'MACPKR' => $AYMACPKR
]);
# Call processShipment
$controller = new GetContentsController();
@@ -411,7 +411,7 @@ class CloseShipment extends Controller
$commodities = '';
$ErrorMsgs = $ErrorMsgs ." Could not find Commodities; ";
}
# End Commodities
# End Commodities
# Check ICM699M for SHERROR=X
$ICM699MS = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
@@ -433,7 +433,7 @@ class CloseShipment extends Controller
}
if($AYTYPE==""){
# Get AETYPE SELECT APTRUCKID FROM ICM705M1 WHERE APCO=110 AND APWHS=321 AND APMANIFEST=22
# Get AETYPE SELECT APTRUCKID FROM ICM705M1 WHERE APCO=110 AND APWHS=321 AND APMANIFEST=22
$ICM693MS = DB::connection(config('m3.connection', 'pgsql'))->table('icm693m')
->select('AEID')
->where('AESPR1A01','D')
@@ -448,11 +448,11 @@ class CloseShipment extends Controller
# If billable=Y and a4ratetcp(FREIGHT)>0 and a4ratem3=blank, then call the freight API CoCharge
if ($BILLABLE=='Y' && $FREIGHT>0 && $A4RATEM3=='') {
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
if($SHIPTYPE=='LTL') {
$shippingToBill = $FREIGHT*(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL'))/100;
$shippingToBill = $FREIGHT*(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL'))/100;
} else {
$shippingToBill = $FREIGHT*(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel') )/100;
$shippingToBill = $FREIGHT*(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel') )/100;
}
# Construct Json for COCharge
$JSONCoCharge = [
@@ -478,7 +478,7 @@ class CloseShipment extends Controller
# Set PDF URLs for Labels
$CarrierLabel = '';
$ContentLabel = '';
$docTypes = ['ContentLabel','CarrierLabel'];
foreach ($docTypes as $key => $value) {
switch ($value) {
@@ -489,7 +489,7 @@ class CloseShipment extends Controller
$pdfFileName = $pdfFilePath.$PDFKey.'.pdf';
// dd($pdfFileName);
if(File::exists($pdfFileName)){
if(File::exists($pdfFileName)){
$CarrierLabel = route('m3.M3GetPDFFromCache.index',['MACPKR'=>$AYMACPKR, 'DOCTYPE'=>$DOCTYPE ]);
}
break;
@@ -524,7 +524,7 @@ class CloseShipment extends Controller
}
}
# Get Packages Array
# Get Packages Array
$PACKAGES[]=[
"TRACKINGID" => $TRACKING,
"BUNDLES" => $AYTYPE,
@@ -617,7 +617,7 @@ class CloseShipment extends Controller
# MAK : Log JSON Manifest # and MACKPKR #
// Log::channel('dailyCron')->info('1 >>> JSON Sent for Manifest: '.$MANIFEST.' ,Macpicker: '.$AYMACPKR);
Log::channel('dailyCron')->info('1 >>> JSON Sent for Manifest: '.(string)(int)$MANIFEST.' ,Macpicker: '.$AYMACPKR);
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -670,13 +670,13 @@ class CloseShipment extends Controller
$responseMsg = $responseContents->result->CloseShipment;
$M3APIRESULT = $responseMsg->PickingListClose->Result;
$M3APIRESULTMsg = isset($responseMsg->PickingListClose->ErrorMessage) ? $responseMsg->PickingListClose->ErrorMessage: '';
# 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
# If you get a successful response, update database file ICM688M1/A4RATEm3=X
# Update ICM688M1 : Change A4RATEM3
if (count($JSONCoCharge)>0 && $M3APIRESULT != 'Error') {
DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
@@ -781,7 +781,7 @@ class CloseShipment extends Controller
$ICM699MUZ = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
->where('SHMACPKR',$AYMACPKR)
->where('SHCO',$COMPANY)
->where('SHWHS',$WHS)
->where('SHWHS',$WHS)
->where('SHSOURCE',$SHSOURCE)
->where('SHERROR','X')
->where('SHTYPE','M3-General')
@@ -793,17 +793,17 @@ class CloseShipment extends Controller
$ICM705M1U = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
->where('APMANIFEST',$MANIFEST)
->where('APCO',$COMPANY)
->where('APWHS',$WHS)
->where('APWHS',$WHS)
->update(["APSPARE2"=>"X"]);
}
# Send Response
# Send Response
if ($allErrMsgs=='') {
return response()->json([
'code' => '200',
'status' => 'Success',
'message'=> 'All Operations Successful'
]);
]);
}
else{
$allErrMsgsC = Helper::removeDuplicateSubstrings($allErrMsgs);
@@ -812,9 +812,9 @@ class CloseShipment extends Controller
'code' => '206',
'status' => 'Success With Warnings',
'message'=> $allErrMsgsC ."; Check Transaction Logs for Errors or Warnings."
]);
]);
}
}
# Close Shipment for Zero Picks
else if (count($ICM695M1TMP)>0 && $TRANSTYPE=='Z') {
@@ -876,12 +876,12 @@ class CloseShipment extends Controller
$responseContents = json_decode($response->getBody()->getContents());
$M3SessionId = $response->hasHeader('x-transaction-id') ? "-sessionID:". $response->header('x-transaction-id') : '-sessionID';
$M3Errors = '';
if ($responseContents!=null) {
$responseMsg = $responseContents->result->CloseShipment;
$M3APIRESULT = $responseMsg->PickingListClose->Result;
$M3APIRESULTMsg = isset($responseMsg->PickingListClose->ErrorMessage) ? $responseMsg->PickingListClose->ErrorMessage: '';
# Check M3 Response for Errors
$responseResult = $responseContents->result;
$M3Errors = Helper::checkM3Errors($responseResult);
@@ -959,21 +959,21 @@ class CloseShipment extends Controller
$ICM699MUZ = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
->where('SHMACPKR',$AYMACPKR)
->where('SHCO',$COMPANY)
->where('SHWHS',$WHS)
->where('SHWHS',$WHS)
->where('SHSOURCE',$SHSOURCE)
->where('SHERROR','X')
->where('SHTYPE','M3-General')
->where('SHDATA','like','%CommTCP_read%')
->update(["SHERROR"=>"Z","SHACKUSER"=>$SHUSER,"SHACKDATE"=>date('Y-m-d'),"SHACKTIME"=>date('H:i:s'),"SHACKNOTE"=> $SHACKNOTE]);
}
# Send Response
# Send Response
if ($ErrorMsgs=='') {
return response()->json([
'code' => '200',
'status' => 'Success',
'message'=> 'All Operations Successful'
]);
]);
}
else{
return response()->json([
@@ -988,9 +988,9 @@ class CloseShipment extends Controller
$DELIVERYNO = isset($MANIFEST) ? $MANIFEST : '000000';
// # Set SHDATA Message
$SHDATAMSG = 'No records found in ICM695M1,or URL parameters incomplete';
# count($ICM695M1TMP)==0 ? 'MacPkr already closed' :
# count($ICM695M1TMP)==0 ? 'MacPkr already closed' :
$SHERROR = 'X';
# count($ICM695M1TMP)==0 ? 'Z' :
# count($ICM695M1TMP)==0 ? 'Z' :
# Write to Logs Out : Error
$data = [
@@ -128,7 +128,7 @@ class M3Controller extends Controller
try {
$jsonFile = count($request->json()->all()) > 0 ? $request->json()->all() : '';
# Root
# Root
$Company = isset($jsonFile["Company"]) ? $jsonFile["Company"] : '';
$Plant = isset($jsonFile["Plant"]) ? $jsonFile["Plant"] : '';
$Warehouse = isset($jsonFile["Warehouse"]) ? $jsonFile["Warehouse"] : '';
@@ -148,7 +148,7 @@ class M3Controller extends Controller
$GS1Label = isset($jsonFile["GS1-128Label"]) ? $jsonFile["GS1-128Label"] : '0';
$CurrencyExchangeRate = isset($jsonFile["CurrencyExchangeRate"]) ? $jsonFile["CurrencyExchangeRate"] : '';
# Set Carrier BWAY if it's empty for Tilburg only
# Set Carrier BWAY if it's empty for Tilburg only
if (($CarrierCode=='' || $CarrierCode==null) && $Warehouse=='111' && $Company=='410' && $Plant=='410' ) {
$CarrierCode = 'BWAY';
}
@@ -188,7 +188,7 @@ class M3Controller extends Controller
# MycarrierDetails
$ShipVia = isset($jsonFile["ShipVia"]) ? $jsonFile["ShipVia"]: '';
# Comments
$Picker = $Packer = $Carrier = $Other ='';
$AXCO = $Company;
@@ -200,11 +200,11 @@ class M3Controller extends Controller
$AXSHNO = $ShipmentNumber;
$comments = isset($jsonFile["Comments"]) ? $jsonFile["Comments"] : '';
if ($comments!='') {
foreach($comments as $key => $comment) {
$commentData = [];
$AXDOCUMENT = Helper::sanityzeString($key);
$AXDOCUMENT = Helper::sanityzeString($key);
$commentData=["AXCO"=>$AXCO,"AXPLANT"=>$AXPLANT,"AXWHS"=>$AXWHS,"AXDELNO"=>$AXDELNO,"AXONO"=>$AXONO,
"AXRLNO"=>$AXRLNO,"AXSHNO"=>$AXSHNO,"AXDOCUMENT"=>$AXDOCUMENT];
@@ -285,17 +285,87 @@ class M3Controller extends Controller
$KitPartNumber = isset($product['KitPartNumber']) ? $product['KitPartNumber']: '';
$OrderLineSuffix = isset($product['OrderLineSuffix']) ? $product['OrderLineSuffix']: '';
$CustomerPartNumber = isset($product['CustomerPartNumber']) ? substr($product['CustomerPartNumber'], 0, 20): ''; # Limit to 20 Chars
# Initialise Table Fields to be filled
$InsertArray = [];
$InsertArray = [];
$fieldValues = [
'Company' => $Company,
'Warehouse' => $Warehouse,
'Plant' => $Plant,
'PickerNumber' => $PickerNumber,
'OrderNumber' => $OrderNumber,
'ReleaseNumber' => $ReleaseNumber,
'ShipmentNumber' => $ShipmentNumber,
'OrderLine' => $OrderLine,
'PartNumber' => $PartNumber,
'Description' => $Description,
'Quantity' => $Quantity,
'BaseUnitPrice' => $BaseUnitPrice,
'Currency' => $Currency,
'Zone' => $Zone,
'PromDate' => $PromDate,
'RouteCode' => $RouteCode,
'BillToId' => $BillToId,
'ShipToId' => $ShipToId,
'CompanyName' => $CompanyName,
'Address1' => $Address1,
'Address2' => $Address2,
'Address3' => $Address3,
'Address4' => $Address4,
'City' => $City,
'State' => $State,
'PostalCode' => $PostalCode,
'Country' => $Country,
'CountryName' => $CountryName,
'PartWeight' => $PartWeight,
'SellUOM' => $SellUOM,
'PartConv' => $PartConv,
'CarrierCode' => $CarrierCode,
'ShipVia' => $ShipVia,
'PrimaryLocation' => $PrimaryLocation,
'Allocation' => $Allocation,
'AllocatedTo' => $AllocatedTo,
'LocationSeq' => $LocationSeq,
'UOM' => $UOM,
'HazMat' => $HazMat,
'PartUPC' => $PartUPC,
'PartEAN' => $PartEAN,
'LotFlag' => $LotFlag,
'ManOrd' => $ManOrd,
'LotNumber' => $LotNumber,
'ProductArea' => $ProductArea,
'FreightClass' => $FreightClass,
'ShipmentPONumber' => $ShipmentPONumber,
'ShipmentPOLine' => $ShipmentPOLine,
'ShipTerms' => $ShipTerms,
'ExchangeRate' => $ExchangeRate,
'OrderClass' => $OrderClass,
'LocationType' => $LocationType,
'PallSize' => $PallSize,
'MasterCarton' => $MasterCarton,
'MasterQty' => $MasterQty,
'InnerQty' => $InnerQty,
'PalletQty' => $PalletQty,
'CartonQty' => $CartonQty,
'PersonName' => $PersonName,
'AccountNo' => $AccountNo,
'Email' => $Email,
'OrderCategory' => $OrderCategory,
'A1DATEADD' => $A1DATEADD,
'A1TIMEADD' => $A1TIMEADD,
'KitPartNumber' => $KitPartNumber,
'OrderLineSuffix' => $OrderLineSuffix,
'CustomerPartNumber' => $CustomerPartNumber,
'GS1Label' => $GS1Label,
'CurrencyExchangeRate' => $CurrencyExchangeRate,
];
# Check JSON fields if empty or > DB Fields
foreach ($ICM666MFields as $key => $value) {
$keyVar = $key;
# Sanitize String
$$keyVar = Helper::sanityzeString($$keyVar);
$fieldValue = Helper::sanityzeString($fieldValues[$key] ?? '');
# Check Var Types & Length
$LengthTest = Helper::checkLength($$keyVar, $value[1], $value[2]);
$LengthTest = Helper::checkLength($fieldValue, $value[1], $value[2]);
if (!$LengthTest[413] || !$LengthTest[411] || !$LengthTest[417]) {
// Log::error($key .' :: '. $value[0].' :: '. $value[1] .' JSONF: '.$$keyVar .' Type: '.$value[2] );
@@ -315,12 +385,12 @@ class M3Controller extends Controller
Helper::logToICM699M($data);
return response()->json($message);
} else if ($$keyVar != '') {
$InsertArray[$value[0]] = $$keyVar;
} else if ($fieldValue != '') {
$InsertArray[$value[0]] = $fieldValue;
}
}
// Log::info($InsertArray);
# Check ICM709M
$ICM709MSEL = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')
->select()
@@ -339,7 +409,7 @@ class M3Controller extends Controller
$InsertArray['A1MATWRN'] = $HazMat;
// if ($PalletQty!='') {
// $InsertArray['A1USRN01']=$palletQty;
// $InsertArray['A1USRN01']=$palletQty;
// }
# SQL Insert to ICM666M
@@ -350,16 +420,16 @@ class M3Controller extends Controller
if ($Warehouse!='' && $PickerNumber!='' && $Company!='') {
$PGMERRORS = '';
$AWREQN = '';
# connect to toolkit using DB2 credentials (can also leave blank for default authority)
try {
$conn = app(\Modules\M3\Services\PostgresProgramBridge::class);
} catch (Exception $e) {
} catch (\Exception $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"
@@ -375,10 +445,10 @@ class M3Controller extends Controller
}
}
$conn->setOptions(array('persistent' => false, 'stateless' => true, 'debug' => true,'debugLogFile' => env('TOOLKIT_DEBUG_LOG')));
# Add LIB
# $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)');
# define several input/output params
$params = [];
# $params[] = $conn->AddParameterChar('out',7,'eqNumber');
@@ -391,7 +461,7 @@ class M3Controller extends Controller
# AddParameterPackDec($io, $length, $scale, $comment, $varName, $value,$dimension)
# Add Delivery Note Param
$PickerNumberNoZero = ltrim(strval($PickerNumber), '0');
$PickerNumberNoZero = ltrim(strval($PickerNumber), '0');
$params[] = $conn->AddParameterChar('in', 11, 'PickerNumber','',$PickerNumberNoZero);
// $params[] = $conn->AddParameterZoned('in', 11, 0, 'ParamIn');
@@ -427,11 +497,11 @@ class M3Controller extends Controller
else{
# Write to Logs Out : Error & JSON
$SHACKNOTE = 'Sentinel automatically closed the error related to this empty data set sent by M3';
$data = ['SHMACPKR'=>$SHMACPKR,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'Z','SHINTBOX'=> '','SHTYPE'=> 'M3-Lis-in' ,
'SHDATA'=>'No Json File Found...' ,'SHUSER'=> $REQKPKUS,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$Company,'SHWHS'=>$Warehouse,"SHACKNOTE"=> $SHACKNOTE ];
Helper::logToICM699M($data);
return response()->json([
'code'=>'415',
'status'=>'error',
@@ -96,7 +96,7 @@ class M3InventoryReport extends Controller
$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',
@@ -126,7 +126,7 @@ class M3InventoryReport extends Controller
$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',
@@ -172,7 +172,7 @@ class M3InventoryReport extends Controller
$WHS = isset($urlParams["WHS"]) ? $urlParams["WHS"] : '';
$MACPKR = isset($urlParams["MACPKR"]) ? $urlParams["MACPKR"] : '000000'; # Delivery Number
$PKLN = isset($urlParams["PKLN"]) ? $urlParams["PKLN"] : '';
if($urlParams!=''){
$IncomingParams = ['CO'=> $CO,'WHS'=> $WHS,'MACPKR'=> $MACPKR,'PKLN'=> $PKLN,'REQPKWS'=> $REQPKWS,'REQKPKUS'=> $REQKPKUS];
$IncomingParams = json_encode($IncomingParams);
@@ -211,11 +211,11 @@ class M3InventoryReport extends Controller
$PARTS[] = ["PART"=> $PART , "LOT"=>$LOT];
$PICKERARR[$PART] = $ICM688M2->A5SENTPKR;
}
// Log::info($PARTS);
// Log::info($PARTS);
// dump($PARTS);
$JSON = json_encode( ["WHS" => $WHS,"PARTS"=> $PARTS ] );
// Log::info($JSON);
// Log::info($JSON);
# Get Token
$tokenResponse = Helper::checkReceiveTokenV2();
$tokenData = $tokenResponse->getData();
@@ -234,7 +234,7 @@ class M3InventoryReport extends Controller
# Call ionapi with Params
$endPointURL = env('ENDPOINTURL').'APIFLOWS/Sentinel/M3InventoryReportList?ionapiRespStyle=sync';
$token = $IonToken;
$response = Http::withHeaders([
'accept' => 'application/json',
'Content-Type' => 'application/json'
@@ -260,13 +260,13 @@ class M3InventoryReport extends Controller
$M3Errors = 'Error: No Response from M3';
}
# Validate response From M3
# Validate response From M3
if ($M3Errors!='') {
# Write to Logs : Error
$data = ['SHMACPKR'=>$MACPKR,'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'=>$CO,'SHWHS'=>$WHS ];
Helper::logToICM699M($data);
# Send Response
return response()->json([
'code'=>'405',
@@ -285,7 +285,7 @@ class M3InventoryReport extends Controller
foreach ($responseTMP as $key => $value) {
// dump($value);
$dataToWrite = [];
foreach ($value as $key2 => $content) {
if($key2!='Locations'){
$dataToWrite[$key2] = $content;
@@ -317,12 +317,12 @@ class M3InventoryReport extends Controller
->where('VLOCID',$value['Location'])
->first();
// dd($DE640MSQLSEL);
$LocationExist = isset($DE640MSQLSEL->VLOCID) ? trim($DE640MSQLSEL->VLOCID) : '';
$WHExist = isset($DE640MSQLSEL->WSELOC) ? trim($DE640MSQLSEL->WSELOC) : '';
$COExist = isset($DE640MSQLSEL->LVCO) ? trim($DE640MSQLSEL->LVCO) : '';
// dd($LocationExist .': '.$WHExist.': '.$COExist);
# if No records Founds insert New Record
if ( $LocationExist=='' && $WHExist=='' && $COExist=='' ) {
$SQLInsertPrep640M['LVCO'] = $CO; # Company
@@ -364,7 +364,7 @@ class M3InventoryReport extends Controller
$SQLInsertPrep630M['LLIZLCF'] = trim($value['LotNumber'])!='' ? '1' : ''; # Lot control flag
$SQLInsertPrep630M['LLCMDESC'] = $value['Description']; # Description
$SQLInsertPrep630M['LLSPR10A01'] = isset($value['Allocation']) ? $value['Allocation'] : ''; # Allocation
$SQLInsertPrep630M['LLSPR15A01'] = isset($value['AllocatedTo']) ? $value['AllocatedTo'] : ''; # AllocatedTo
$SQLInsertPrep630M['LLSPR15A01'] = isset($value['AllocatedTo']) ? $value['AllocatedTo'] : ''; # AllocatedTo
DB::connection(config('m3.connection', 'pgsql'))->table('ic630m')->insert($SQLInsertPrep630M);
}
@@ -431,7 +431,7 @@ class M3InventoryReport extends Controller
$SHERROR = 'X';
$word = 'Duplicate key value specified';
$position = strpos($th, $word);
if ($position !== false) {
$SHERROR = 'Z';
}
@@ -439,7 +439,7 @@ class M3InventoryReport extends Controller
$data = ['SHMACPKR'=>$MACPKR,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> $SHERROR,'SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
'SHDATA'=>'An Error Occured-'.substr($th,0,300) ,'SHUSER'=> $REQKPKUS,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$CO,'SHWHS'=>$WHS];
Helper::logToICM699M($data);
Log::error($th);
return response()->json([
'code'=>'405',
+10 -10
View File
@@ -33,11 +33,11 @@ class PdfStorage extends Controller
# Get URL PARAMS
$urlParams = count($request->all())>0 ? $request->all() : '';
// dd($urlParams);
$COMPANY = isset($urlParams["COMPANY"]) ? trim($urlParams["COMPANY"]) : ''; # Company
$WHS = isset($urlParams["WHS"]) ? trim($urlParams["WHS"]) : ''; # WareHouse
$DOCTYPE = isset($urlParams["DOCTYPE"]) ? trim($urlParams["DOCTYPE"]) : ''; # document type (PackingList, CarrierLabel, ContentLabel)
$FILENAME = isset($urlParams["FILENAME"]) ? trim($urlParams["FILENAME"]) : ''; # PDF File name
$FILENAME = isset($urlParams["FILENAME"]) ? trim($urlParams["FILENAME"]) : ''; # PDF File name
$DOCNUM = isset($urlParams["DOCNUM"]) ? trim($urlParams["DOCNUM"]) : ''; # document number (ie the internal box number, the pick list number)
$A4MACPKR = isset($urlParams["A4MACPKR"]) ? trim($urlParams["A4MACPKR"]) : ''; # Delivery note number
@@ -52,7 +52,7 @@ class PdfStorage extends Controller
'SHDATA'=>json_encode($IncomingParams) ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$COMPANY,'SHWHS'=>$WHS ];
Helper::logToICM699M($data);
# Make Key and Test Validity
# Make Key and Test Validity
if ($A4MACPKR!='' && $DOCTYPE!='' && $DOCNUM!='' && $COMPANY!='' && $WHS!=''){
$cacheKey = $A4MACPKR.$DOCTYPE.$DOCNUM.$COMPANY.$WHS;
}
@@ -69,24 +69,24 @@ class PdfStorage extends Controller
// Parse PDF file and build necessary objects.
$parser = new \Smalot\PdfParser\Parser();
// $pdf = $parser->parseFile('/www/sentm3test/htdocs/labels/E1232824-10826596.pdf');
// dump($pdf);
// $text = $pdf->getText();
// dump("Text Only");
// dump($text);
$pdfFile = File::get($pdfFileName);
// Transform content to base64
$base64PDF = base64_encode($pdfFile);
// Output base64 string
// dump($base64PDF);
# Save Cache
Cache::forever($cacheKey, $base64PDF);
// Cache::put($cacheKey, $base64PDF, now()->addMinutes(60));
# Retrieve Cache
// $cachedPdfFile = Cache::get($cacheKey);
// dump("Retrieve Base64 Encoded PDF saved in Cache:");
@@ -95,7 +95,7 @@ class PdfStorage extends Controller
# remove File from Cache
// Cache::put(pdfFileName, 'value', -5);
// Cache::forget($pdfFileName);
# Base64 Decode and Display
// $pdf = $parser->parseContent(base64_decode($base64PDF));
// $text = $pdf->getText();
@@ -117,7 +117,7 @@ class PdfStorage extends Controller
else {
$SHDATA = File::exists($pdfFileName) ? '' : 'PDF File Not Found-';
$SHDATA = $cacheKey!='' ? $SHDATA.'' : $SHDATA.'Cache Key is missing Params';
# Write to Logs Out : Error
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'X','SHINTBOX'=> $DOCNUM,'SHTYPE'=> 'M3-Res-out' ,
'SHDATA'=>'An Error Occured -'.$SHDATA,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$COMPANY,'SHWHS'=>$WHS];
+16 -16
View File
@@ -24,7 +24,7 @@ class ReplenAPI extends Controller
ini_set('max_input_time', Config::get('arrays.PHPTimeOut'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOut'));
// dd($request->all());
// dd($request->all());
// Log::info( $request->all() );
# Get The Calling User
$SHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
@@ -35,7 +35,7 @@ class ReplenAPI extends Controller
try {
# Get Json Contents
$urlParams = count($request->all())>0 ? $request->all() : '';
$CO = isset($urlParams["CO"]) ? $urlParams["CO"] : '';
$WHS = isset($urlParams["WHS"]) ? $urlParams["WHS"] : '';
$PARTNO = isset($urlParams["PARTNO"]) ? $urlParams["PARTNO"] : '';
@@ -59,7 +59,7 @@ class ReplenAPI extends Controller
// dump($PARTS);
$JSON = json_encode( ["WHS" => $WHS,"PARTS"=> $PARTS ] );
# Write to Logs : Params Sent To M3
$data = ['SHMACPKR'=>$MACPKR,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> '','SHINTBOX'=> '','SHTYPE'=> 'M3-Req-out' ,
'SHDATA'=>'Sent To M3-'.$JSON ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$CO,'SHWHS'=>$WHS ];
@@ -116,13 +116,13 @@ class ReplenAPI extends Controller
$M3Errors = 'Error: No Response from M3';
}
# Validate response From M3
# Validate response From M3
if ($M3Errors!='') {
# Write to Logs : Error
$data = ['SHMACPKR'=>$MACPKR,'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'=>$CO,'SHWHS'=>$WHS ];
Helper::logToICM699M($data);
# Send Response
return response()->json([
'code'=>'405',
@@ -141,7 +141,7 @@ class ReplenAPI extends Controller
foreach ($responseTMP as $key => $value) {
// dump($value);
$dataToWrite = [];
foreach ($value as $key2 => $content) {
if($key2!='Locations'){
$dataToWrite[$key2] = $content;
@@ -173,12 +173,12 @@ class ReplenAPI extends Controller
->where('VLOCID',$value['Location'])
->first();
// dd($DE640MSQLSEL);
$LocationExist = isset($DE640MSQLSEL->VLOCID) ? trim($DE640MSQLSEL->VLOCID) : '';
$WHExist = isset($DE640MSQLSEL->WSELOC) ? trim($DE640MSQLSEL->WSELOC) : '';
$COExist = isset($DE640MSQLSEL->LVCO) ? trim($DE640MSQLSEL->LVCO) : '';
// dd($LocationExist .': '.$WHExist.': '.$COExist);
# if No records Founds insert New Record
if ( $LocationExist=='' && $WHExist=='' && $COExist=='' ) {
$SQLInsertPrep640M['LVCO'] = $CO; // Company
@@ -189,15 +189,15 @@ class ReplenAPI extends Controller
$SQLInsertPrep640M['LVUSD2'] = $value['LocationType'];
$SQLInsertPrep640M['LVZONE'] = $value['Zone']; // Warehouse zone
$SQLInsertPrep640M['LVMAINTTS'] = now(); // Last maintained time stamp
DB::connection(config('m3.connection', 'pgsql'))->table('de640m')->insert($SQLInsertPrep640M);
}
# Update
else {
$SQLUpdatePrep640M['LVSEQN'] = $value['LocationSeq'];
$SQLUpdatePrep640M['LVUSD2'] = $value['LocationType'];
$SQLUpdatePrep640M['LVZONE'] = $value['Zone'];
$SQLUpdatePrep640M['LVMAINTTS'] = now();
$SQLUpdatePrep640M['LVZONE'] = $value['Zone'];
$SQLUpdatePrep640M['LVMAINTTS'] = now();
DB::connection(config('m3.connection', 'pgsql'))->table('de640m')
->where('LVCO',$CO)
@@ -218,15 +218,15 @@ class ReplenAPI extends Controller
$SQLInsertPrep630M['LLIZLCF'] = trim($value['LotNumber'])!='' ? '1' : ''; # Lot control flag
$SQLInsertPrep630M['LLSPR10A01'] = $value['Allocation']; # Allocation
$SQLInsertPrep630M['LLSPR15A01'] = $value['AllocatedTo']; # AllocatedTo
$DescSanytized = Helper::sanityzeString($value['Description']);
// $DescSanytized = str_replace(['–','\u20131'], '-',$value['Description']);
$SQLInsertPrep630M['LLCMDESC'] = $DescSanytized; // Description
DB::connection(config('m3.connection', 'pgsql'))->table('ic630m')->insert($SQLInsertPrep630M);
}
// dump($SQLInsertPrep);
#Send Response
return response()->json([
'code' => '200',
@@ -259,7 +259,7 @@ class ReplenAPI extends Controller
$data = ['SHMACPKR'=>$MACPKR,'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'.$IncomingParams,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$CO,'SHWHS'=>$WHS];
Helper::logToICM699M($data);
return response()->json([
'code'=>'405',
'status'=>'error',
@@ -272,7 +272,7 @@ class ReplenAPI extends Controller
$SHERROR = 'X';
$word = 'Duplicate key value specified';
$position = strpos($th, $word);
if ($position !== false) {
$SHERROR = 'Z';
}
@@ -87,7 +87,7 @@ class TransferAPI extends Controller
->where('SHMACPKR', $DELIVERYNO)
->where('SHDT', $SHDT)
->where('SHTIME', $SHTIME)
# ->whereRaw("VARCHAR_FORMAT (TIMESTAMP (CURRENT DATE) + MIDNIGHT_SECONDS (SHTIME) SECONDS, 'HH24:MI') = ?", [$SHTIMEHM])
# ->whereRaw("VARCHAR_FORMAT (TIMESTAMP (CURRENT DATE) + MIDNIGHT_SECONDS (SHTIME) SECONDS, 'HH24:MI') = ?", [$SHTIMEHM])
->where('SHCO', $DIVI)
->where('SHWHS', $WHS)
->where('SHSOURCE', $SHSOURCE)
@@ -101,7 +101,7 @@ class TransferAPI extends Controller
$SHDATA = isset($ICM699MS->SHDATA) ? $ICM699MS->SHDATA : '';
$SHDATAJSON = "";
$position = strpos($SHDATA, $word);
# Also Read CommTCP_read
# Also Read CommTCP_read
$word2 = 'url:http://127.0.0.1:10005/api/TransferAPIURL?';
$SHDATA2 = isset($ICM699MS->SHDATA) ? $ICM699MS->SHDATA : '';
$position2 = strpos($SHDATA2, $word2);
@@ -141,7 +141,7 @@ class TransferAPI extends Controller
}
// dd($JSONTR);
# Set SHERROR to Z in ICM699M
# Set SHERROR to Z in ICM699M
$ICM699MU = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
->where('SHMACPKR', $DELIVERYNO)
->where('SHDT', $SHDT)
@@ -154,9 +154,9 @@ class TransferAPI extends Controller
->update(["SHERROR" => "Z", "SHACKUSER" => $SHUSER, "SHACKDATE" => date('Y-m-d'), "SHACKTIME" => date('H:i:s')]);
}
# Part Exists : proceed
# Part Exists : proceed
if ($PART != '') {
# Read from ICM688M2
# Read from ICM688M2
# Get Parts And Lots from ICM688M2
$ICM688M2SLTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m2')
->select('A5BRADLN', 'A5PKSFX', 'A5PLANT', 'A5SENTPKR')
@@ -470,7 +470,7 @@ class TransferAPI extends Controller
// dd($A4SPR15A01);
if ($A4SPR15A01 != '') {
# Read from ICM688M1
# Read from ICM688M1
$ICM688M1SLTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
->select('A4MACPKR')
->where('A4CO', $DIVI)
@@ -490,7 +490,7 @@ class TransferAPI extends Controller
}
}
# A4SPR15A01 Exists : proceed
# A4SPR15A01 Exists : proceed
if ($A4SPR15A01 != '' && count($allMacpkrs)>0) {
$JSON = json_encode([
"DIVI" => $DIVI,
@@ -631,7 +631,7 @@ class TransferAPI extends Controller
'message' => 'Json Payload Not Valid, missing Parameter or no Macpicker # found.'
]);
}
}
}
else {
# Write to Logs Out : Error
$DELIVERYNO = isset($DELIVERYNO) ? $DELIVERYNO : '000000';
@@ -25,7 +25,7 @@ class TwoShipAPIs extends Controller
ini_set('max_input_time', Config::get('arrays.PHPTimeOut'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOut'));
// dd($request->all());
// dd($request->all());
// Log::info( $request->all() );
# Get The Calling User
@@ -115,12 +115,12 @@ class TwoShipAPIs extends Controller
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
#When CURLOPT_SSL_VERIFYPEER is enabled (value=1), and the verification fails to prove that the certificate is authentic, the connection fails.
#When CURLOPT_SSL_VERIFYPEER is enabled (value=1), and the verification fails to prove that the certificate is authentic, the connection fails.
#When the option is zero, the peer certificate verification succeeds regardless.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
#When CURLOPT_SSL_VERIFYHOST is 2, that certificate must indicate that the server is the server to which you meant to connect,
#or the connection fails. Simply put, it means it has to have the same name in the certificate as is in the URL you operate against.
#When CURLOPT_SSL_VERIFYHOST is 2, that certificate must indicate that the server is the server to which you meant to connect,
#or the connection fails. Simply put, it means it has to have the same name in the certificate as is in the URL you operate against.
# Set data content type
curl_setopt(
@@ -157,7 +157,7 @@ class TwoShipAPIs extends Controller
# Close the session
unset($ch);
// dump($response);
// dump($status);
// dump($CurlError);
@@ -173,7 +173,7 @@ class TwoShipAPIs extends Controller
$TwoShipErrors .= ' -Curl Error: '.$CurlError;
}
# Validate response From 2Ship
# Validate response From 2Ship
# Error
if ($TwoShipErrors != '') {
// dump($TwoShipErrors);