M3 Security Fixes for scan command pass 33 major code smell fixes and style fixes
This commit is contained in:
@@ -5,7 +5,6 @@ namespace Modules\M3\Http\Controllers\API;
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Modules\M3\Helpers\Helper;
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Modules\M3\Services\PostgresProgramBridge;
|
||||
@@ -14,6 +13,7 @@ use Str;
|
||||
class M3Controller extends Controller
|
||||
{
|
||||
private const FIELD_PREFIX = 'Field: ';
|
||||
|
||||
private const M3_LIST_SUFFIX = ' M3-Lis-JSN';
|
||||
|
||||
// Split Data and Write to ICM666M2
|
||||
@@ -22,15 +22,15 @@ class M3Controller extends Controller
|
||||
// dump($dataSplit);
|
||||
|
||||
$commentDataSS = explode("\n", $dataSplit);
|
||||
$AXLINENO = 1;
|
||||
$aXLINENO = 1;
|
||||
foreach ($commentDataSS as $substring) {
|
||||
// Process each substring
|
||||
$fullData = $commentData;
|
||||
$fullData['AXCOMMENT'] = $substring;
|
||||
$fullData['AXLINENO'] = $AXLINENO;
|
||||
$fullData['AXLINENO'] = $aXLINENO;
|
||||
$insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm666m2')->insert($fullData);
|
||||
|
||||
$AXLINENO++;
|
||||
$aXLINENO++;
|
||||
|
||||
// AXCO ICM666M2 CHARACTER 3
|
||||
// AXWHS ICM666M2 CHARACTER 3
|
||||
@@ -57,10 +57,10 @@ class M3Controller extends Controller
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOut'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOut'));
|
||||
|
||||
$REQKPKUS = m3_user() !== '' ? Str::upper(m3_user()) : 'WEBUSER';
|
||||
$SHSOURCE = 'M3ReceiverAPI';
|
||||
$rEQKPKUS = m3_user() !== '' ? Str::upper(m3_user()) : 'WEBUSER';
|
||||
$sHSOURCE = 'M3ReceiverAPI';
|
||||
|
||||
$ICM666MFields = [
|
||||
$iCM666MFields = [
|
||||
'Company' => ['A1CO', 3, 'string'],
|
||||
'Warehouse' => ['A1WHS', 3, 'string'],
|
||||
'Plant' => ['A1PLANT', 3, 'string'],
|
||||
@@ -137,30 +137,30 @@ class M3Controller extends Controller
|
||||
$jsonFile = count($request->json()->all()) > 0 ? $request->json()->all() : '';
|
||||
|
||||
// Root
|
||||
$Company = isset($jsonFile['Company']) ? $jsonFile['Company'] : '';
|
||||
$Plant = isset($jsonFile['Plant']) ? $jsonFile['Plant'] : '';
|
||||
$Warehouse = isset($jsonFile['Warehouse']) ? $jsonFile['Warehouse'] : '';
|
||||
$OrderNumber = isset($jsonFile['OrderNumber']) ? $jsonFile['OrderNumber'] : '';
|
||||
$PickerNumber = isset($jsonFile['PickerNumber']) ? $jsonFile['PickerNumber'] : '';
|
||||
$PromDate = isset($jsonFile['PromDate']) ? $jsonFile['PromDate'] : '';
|
||||
$RouteCode = isset($jsonFile['RouteCode']) ? $jsonFile['RouteCode'] : '';
|
||||
$OrderCategory = isset($jsonFile['OrderCategory']) ? $jsonFile['OrderCategory'] : '';
|
||||
$ReleaseNumber = isset($jsonFile['ReleaseNumber']) ? $jsonFile['ReleaseNumber'] : '';
|
||||
$ShipmentNumber = isset($jsonFile['ShipmentNumber']) ? $jsonFile['ShipmentNumber'] : '';
|
||||
$Currency = isset($jsonFile['Currency']) ? $jsonFile['Currency'] : '';
|
||||
$CarrierCode = isset($jsonFile['CarrierCode']) ? $jsonFile['CarrierCode'] : '';
|
||||
$ShipmentPONumber = isset($jsonFile['ShipmentPONumber']) ? $jsonFile['ShipmentPONumber'] : ''; // CustPo
|
||||
$ShipTerms = isset($jsonFile['ShipTerms']) ? $jsonFile['ShipTerms'] : '';
|
||||
$OrderClass = isset($jsonFile['OrderClass']) ? $jsonFile['OrderClass'] : '';
|
||||
$GS1Label = isset($jsonFile['GS1-128Label']) ? $jsonFile['GS1-128Label'] : '0';
|
||||
$CurrencyExchangeRate = isset($jsonFile['CurrencyExchangeRate']) ? $jsonFile['CurrencyExchangeRate'] : '';
|
||||
$company = isset($jsonFile['Company']) ? $jsonFile['Company'] : '';
|
||||
$plant = isset($jsonFile['Plant']) ? $jsonFile['Plant'] : '';
|
||||
$warehouse = isset($jsonFile['Warehouse']) ? $jsonFile['Warehouse'] : '';
|
||||
$orderNumber = isset($jsonFile['OrderNumber']) ? $jsonFile['OrderNumber'] : '';
|
||||
$pickerNumber = isset($jsonFile['PickerNumber']) ? $jsonFile['PickerNumber'] : '';
|
||||
$promDate = isset($jsonFile['PromDate']) ? $jsonFile['PromDate'] : '';
|
||||
$routeCode = isset($jsonFile['RouteCode']) ? $jsonFile['RouteCode'] : '';
|
||||
$orderCategory = isset($jsonFile['OrderCategory']) ? $jsonFile['OrderCategory'] : '';
|
||||
$releaseNumber = isset($jsonFile['ReleaseNumber']) ? $jsonFile['ReleaseNumber'] : '';
|
||||
$shipmentNumber = isset($jsonFile['ShipmentNumber']) ? $jsonFile['ShipmentNumber'] : '';
|
||||
$currency = isset($jsonFile['Currency']) ? $jsonFile['Currency'] : '';
|
||||
$carrierCode = isset($jsonFile['CarrierCode']) ? $jsonFile['CarrierCode'] : '';
|
||||
$shipmentPONumber = isset($jsonFile['ShipmentPONumber']) ? $jsonFile['ShipmentPONumber'] : ''; // CustPo
|
||||
$shipTerms = isset($jsonFile['ShipTerms']) ? $jsonFile['ShipTerms'] : '';
|
||||
$orderClass = isset($jsonFile['OrderClass']) ? $jsonFile['OrderClass'] : '';
|
||||
$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
|
||||
if (($CarrierCode == '' || $CarrierCode == null) && $Warehouse == '111' && $Company == '410' && $Plant == '410') {
|
||||
$CarrierCode = 'BWAY';
|
||||
if (($carrierCode == '' || $carrierCode == null) && $warehouse == '111' && $company == '410' && $plant == '410') {
|
||||
$carrierCode = 'BWAY';
|
||||
}
|
||||
|
||||
$SHMACPKR = $PickerNumber != '' ? $PickerNumber : '000000';
|
||||
$sHMACPKR = $pickerNumber != '' ? $pickerNumber : '000000';
|
||||
|
||||
if ($jsonFile != '') {
|
||||
// Order Category
|
||||
@@ -174,74 +174,74 @@ class M3Controller extends Controller
|
||||
|
||||
// Recipient
|
||||
$recipient = $jsonFile['Recipient'];
|
||||
$CompanyName = isset($recipient['CompanyName']) ? $recipient['CompanyName'] : '';
|
||||
$Address1 = isset($recipient['Address1']) ? $recipient['Address1'] : '';
|
||||
$Address2 = isset($recipient['Address2']) ? $recipient['Address2'] : '';
|
||||
$City = isset($recipient['City']) ? $recipient['City'] : '';
|
||||
$State = isset($recipient['State']) ? $recipient['State'] : '';
|
||||
$PostalCode = isset($recipient['PostalCode']) ? $recipient['PostalCode'] : '';
|
||||
$Country = isset($recipient['Country']) ? $recipient['Country'] : '';
|
||||
$PostalCode = isset($recipient['PostalCode']) ? $recipient['PostalCode'] : '';
|
||||
$BillToId = isset($recipient['BillToId']) ? $recipient['BillToId'] : '';
|
||||
$ShipToId = isset($recipient['ShipToId']) ? $recipient['ShipToId'] : '';
|
||||
$Address3 = isset($recipient['Address3']) ? $recipient['Address3'] : '';
|
||||
$Address4 = isset($recipient['Address4']) ? $recipient['Address4'] : '';
|
||||
$CountryName = isset($recipient['CountryName']) ? $recipient['CountryName'] : '';
|
||||
$PersonName = isset($recipient['PersonName']) ? $recipient['PersonName'] : '';
|
||||
$AccountNo = isset($recipient['AccountNo']) ? $recipient['AccountNo'] : '';
|
||||
$Email = isset($recipient['Email']) ? $recipient['Email'] : '';
|
||||
$A1DATEADD = date('Ymd');
|
||||
$A1TIMEADD = date('His');
|
||||
$companyName = isset($recipient['CompanyName']) ? $recipient['CompanyName'] : '';
|
||||
$address1 = isset($recipient['Address1']) ? $recipient['Address1'] : '';
|
||||
$address2 = isset($recipient['Address2']) ? $recipient['Address2'] : '';
|
||||
$city = isset($recipient['City']) ? $recipient['City'] : '';
|
||||
$state = isset($recipient['State']) ? $recipient['State'] : '';
|
||||
$postalCode = isset($recipient['PostalCode']) ? $recipient['PostalCode'] : '';
|
||||
$country = isset($recipient['Country']) ? $recipient['Country'] : '';
|
||||
$postalCode = isset($recipient['PostalCode']) ? $recipient['PostalCode'] : '';
|
||||
$billToId = isset($recipient['BillToId']) ? $recipient['BillToId'] : '';
|
||||
$shipToId = isset($recipient['ShipToId']) ? $recipient['ShipToId'] : '';
|
||||
$address3 = isset($recipient['Address3']) ? $recipient['Address3'] : '';
|
||||
$address4 = isset($recipient['Address4']) ? $recipient['Address4'] : '';
|
||||
$countryName = isset($recipient['CountryName']) ? $recipient['CountryName'] : '';
|
||||
$personName = isset($recipient['PersonName']) ? $recipient['PersonName'] : '';
|
||||
$accountNo = isset($recipient['AccountNo']) ? $recipient['AccountNo'] : '';
|
||||
$email = isset($recipient['Email']) ? $recipient['Email'] : '';
|
||||
$a1DATEADD = date('Ymd');
|
||||
$a1TIMEADD = date('His');
|
||||
|
||||
// MycarrierDetails
|
||||
$ShipVia = isset($jsonFile['ShipVia']) ? $jsonFile['ShipVia'] : '';
|
||||
$shipVia = isset($jsonFile['ShipVia']) ? $jsonFile['ShipVia'] : '';
|
||||
|
||||
// Comments
|
||||
$Picker = $Packer = $Carrier = $Other = '';
|
||||
$AXCO = $Company;
|
||||
$AXPLANT = $Plant;
|
||||
$AXWHS = $Warehouse;
|
||||
$AXDELNO = $PickerNumber;
|
||||
$AXONO = $OrderNumber;
|
||||
$AXRLNO = $ReleaseNumber;
|
||||
$AXSHNO = $ShipmentNumber;
|
||||
$picker = $packer = $carrier = $other = '';
|
||||
$aXCO = $company;
|
||||
$aXPLANT = $plant;
|
||||
$aXWHS = $warehouse;
|
||||
$aXDELNO = $pickerNumber;
|
||||
$aXONO = $orderNumber;
|
||||
$aXRLNO = $releaseNumber;
|
||||
$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];
|
||||
$commentData = ['AXCO' => $aXCO, 'AXPLANT' => $aXPLANT, 'AXWHS' => $aXWHS, 'AXDELNO' => $aXDELNO, 'AXONO' => $aXONO,
|
||||
'AXRLNO' => $aXRLNO, 'AXSHNO' => $aXSHNO, 'AXDOCUMENT' => $aXDOCUMENT];
|
||||
|
||||
switch ($AXDOCUMENT) {
|
||||
switch ($aXDOCUMENT) {
|
||||
case 'Picker':
|
||||
$Picker = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($Picker != 'null') {
|
||||
$this->insertToICM666M2($Picker, $commentData);
|
||||
$picker = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($picker != 'null') {
|
||||
$this->insertToICM666M2($picker, $commentData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Packer':
|
||||
$Packer = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($Packer != 'null') {
|
||||
$this->insertToICM666M2($Packer, $commentData);
|
||||
$packer = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($packer != 'null') {
|
||||
$this->insertToICM666M2($packer, $commentData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Carrier':
|
||||
$Carrier = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($Carrier != 'null') {
|
||||
$this->insertToICM666M2($Carrier, $commentData);
|
||||
$carrier = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($carrier != 'null') {
|
||||
$this->insertToICM666M2($carrier, $commentData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Other':
|
||||
$Other = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($Other != 'null') {
|
||||
$this->insertToICM666M2($Other, $commentData);
|
||||
$other = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
if ($other != 'null') {
|
||||
$this->insertToICM666M2($other, $commentData);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -255,117 +255,117 @@ class M3Controller extends Controller
|
||||
$tmpProd = '';
|
||||
$products = $jsonFile['Contents']['Commodities'];
|
||||
foreach ($products as $key => $product) {
|
||||
$Quantity = isset($product['Quantity']) ? $product['Quantity'] : '';
|
||||
$Description = isset($product['Description']) ? Str::limit($product['Description'], 25, '') : '';
|
||||
$PartNumber = isset($product['PartNumber']) ? $product['PartNumber'] : '';
|
||||
$OrderLine = isset($product['OrderLine']) ? $product['OrderLine'] : '';
|
||||
$PartWeight = isset($product['PartWeight']) ? $product['PartWeight'] : '';
|
||||
$PickerLine = isset($product['PickerLine']) ? $product['PickerLine'] : '';
|
||||
$PrimaryLocation = isset($product['PrimaryLocation']) ? $product['PrimaryLocation'] : '';
|
||||
$Allocation = isset($product['Allocation']) ? $product['Allocation'] : '';
|
||||
$AllocatedTo = isset($product['AllocatedTo']) ? $product['AllocatedTo'] : '';
|
||||
$LocationSeq = isset($product['LocationSeq']) ? $product['LocationSeq'] : '';
|
||||
$Zone = isset($product['Zone']) ? $product['Zone'] : '';
|
||||
$BaseUnitPrice = isset($product['BaseUnitPrice']) ? $product['BaseUnitPrice'] : '';
|
||||
$FrgnUnitPrice = isset($product['FrgnUnitPrice']) ? $product['FrgnUnitPrice'] : '';
|
||||
$SellUOM = isset($product['SellUOM']) ? $product['SellUOM'] : '';
|
||||
$PartConv = isset($product['PartConv']) ? $product['PartConv'] : '';
|
||||
$UOM = isset($product['UOM']) ? $product['UOM'] : '';
|
||||
$HazMat = isset($product['HazMat']) ? $product['HazMat'] : '';
|
||||
$PartUPC = isset($product['PartUPC']) ? $product['PartUPC'] : '';
|
||||
$PartEAN = isset($product['PartEAN']) ? $product['PartEAN'] : '';
|
||||
$LotFlag = isset($product['LotFlag']) ? $product['LotFlag'] : '';
|
||||
$ManOrd = isset($product['ManOrd']) ? $product['ManOrd'] : '';
|
||||
$LotNumber = isset($product['LotNumber']) ? $product['LotNumber'] : '';
|
||||
$ProductArea = isset($product['ProductArea']) ? $product['ProductArea'] : '';
|
||||
$FreightClass = isset($product['FreightClass']) ? $product['FreightClass'] : '';
|
||||
$ShipmentPOLine = isset($product['ShipmentPOLine']) ? $product['ShipmentPOLine'] : '';
|
||||
$LocationType = isset($product['LocationType']) ? $product['LocationType'] : '';
|
||||
$PallSize = isset($product['PallSize']) ? $product['PallSize'] : '';
|
||||
$MasterCarton = isset($product['MasterCarton']) ? $product['MasterCarton'] : '';
|
||||
$MasterQty = isset($product['MasterQty']) ? $product['MasterQty'] : '';
|
||||
$InnerQty = isset($product['InnerQty']) ? $product['InnerQty'] : '';
|
||||
$PalletQty = isset($product['PalletQty']) ? $product['PalletQty'] : '';
|
||||
$CartonQty = isset($product['CartonQty']) ? $product['CartonQty'] : '';
|
||||
$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
|
||||
$quantity = isset($product['Quantity']) ? $product['Quantity'] : '';
|
||||
$description = isset($product['Description']) ? Str::limit($product['Description'], 25, '') : '';
|
||||
$partNumber = isset($product['PartNumber']) ? $product['PartNumber'] : '';
|
||||
$orderLine = isset($product['OrderLine']) ? $product['OrderLine'] : '';
|
||||
$partWeight = isset($product['PartWeight']) ? $product['PartWeight'] : '';
|
||||
$pickerLine = isset($product['PickerLine']) ? $product['PickerLine'] : '';
|
||||
$primaryLocation = isset($product['PrimaryLocation']) ? $product['PrimaryLocation'] : '';
|
||||
$allocation = isset($product['Allocation']) ? $product['Allocation'] : '';
|
||||
$allocatedTo = isset($product['AllocatedTo']) ? $product['AllocatedTo'] : '';
|
||||
$locationSeq = isset($product['LocationSeq']) ? $product['LocationSeq'] : '';
|
||||
$zone = isset($product['Zone']) ? $product['Zone'] : '';
|
||||
$baseUnitPrice = isset($product['BaseUnitPrice']) ? $product['BaseUnitPrice'] : '';
|
||||
$frgnUnitPrice = isset($product['FrgnUnitPrice']) ? $product['FrgnUnitPrice'] : '';
|
||||
$sellUOM = isset($product['SellUOM']) ? $product['SellUOM'] : '';
|
||||
$partConv = isset($product['PartConv']) ? $product['PartConv'] : '';
|
||||
$uOM = isset($product['UOM']) ? $product['UOM'] : '';
|
||||
$hazMat = isset($product['HazMat']) ? $product['HazMat'] : '';
|
||||
$partUPC = isset($product['PartUPC']) ? $product['PartUPC'] : '';
|
||||
$partEAN = isset($product['PartEAN']) ? $product['PartEAN'] : '';
|
||||
$lotFlag = isset($product['LotFlag']) ? $product['LotFlag'] : '';
|
||||
$manOrd = isset($product['ManOrd']) ? $product['ManOrd'] : '';
|
||||
$lotNumber = isset($product['LotNumber']) ? $product['LotNumber'] : '';
|
||||
$productArea = isset($product['ProductArea']) ? $product['ProductArea'] : '';
|
||||
$freightClass = isset($product['FreightClass']) ? $product['FreightClass'] : '';
|
||||
$shipmentPOLine = isset($product['ShipmentPOLine']) ? $product['ShipmentPOLine'] : '';
|
||||
$locationType = isset($product['LocationType']) ? $product['LocationType'] : '';
|
||||
$pallSize = isset($product['PallSize']) ? $product['PallSize'] : '';
|
||||
$masterCarton = isset($product['MasterCarton']) ? $product['MasterCarton'] : '';
|
||||
$masterQty = isset($product['MasterQty']) ? $product['MasterQty'] : '';
|
||||
$innerQty = isset($product['InnerQty']) ? $product['InnerQty'] : '';
|
||||
$sonar_pallet_qty = isset($product['PalletQty']) ? $product['PalletQty'] : '';
|
||||
$cartonQty = isset($product['CartonQty']) ? $product['CartonQty'] : '';
|
||||
$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,
|
||||
'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,
|
||||
'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,
|
||||
'OrderClass' => $orderClass,
|
||||
'LocationType' => $locationType,
|
||||
'PallSize' => $pallSize,
|
||||
'MasterCarton' => $masterCarton,
|
||||
'MasterQty' => $masterQty,
|
||||
'InnerQty' => $innerQty,
|
||||
'PalletQty' => $sonar_pallet_qty,
|
||||
'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) {
|
||||
foreach ($iCM666MFields as $key => $value) {
|
||||
// Sanitize String
|
||||
$fieldValue = Helper::sanityzeString($fieldValues[$key] ?? '');
|
||||
// Check Var Types & Length
|
||||
@@ -383,44 +383,44 @@ class M3Controller extends Controller
|
||||
}
|
||||
|
||||
// Write to Logs Out : Error & JSON
|
||||
$data = ['SHMACPKR' => $SHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-spl',
|
||||
'SHDATA' => json_encode($message) . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
|
||||
$data = ['SHMACPKR' => $sHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-spl',
|
||||
'SHDATA' => json_encode($message) . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $rEQKPKUS, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $company, 'SHWHS' => $warehouse];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json($message);
|
||||
} elseif ($fieldValue != '') {
|
||||
$InsertArray[$value[0]] = $fieldValue;
|
||||
$insertArray[$value[0]] = $fieldValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Check ICM709M
|
||||
$ICM709MSEL = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')
|
||||
$iCM709MSEL = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')
|
||||
->select()
|
||||
->where('AT9CO', $AXCO)
|
||||
->where('AT9PLT', $AXPLANT)
|
||||
->where('AT9WHS', $AXWHS)
|
||||
->where('AT9PART', $PartNumber)
|
||||
->where('AT9CO', $aXCO)
|
||||
->where('AT9PLT', $aXPLANT)
|
||||
->where('AT9WHS', $aXWHS)
|
||||
->where('AT9PART', $partNumber)
|
||||
->first();
|
||||
$palletQty = isset($ICM709MSEL->AT9QTY) ? $ICM709MSEL->AT9QTY : 0;
|
||||
$palletQty = isset($iCM709MSEL->AT9QTY) ? $iCM709MSEL->AT9QTY : 0;
|
||||
// dd($palletQty);
|
||||
// Get Pallet Qty
|
||||
$InsertArray['A1USRN01'] = $palletQty;
|
||||
$insertArray['A1USRN01'] = $palletQty;
|
||||
|
||||
// Hazard Material
|
||||
$HazMat = isset($ICM709MSEL->AT9WRN) ? $ICM709MSEL->AT9WRN : '';
|
||||
$InsertArray['A1MATWRN'] = $HazMat;
|
||||
$hazMat = isset($iCM709MSEL->AT9WRN) ? $iCM709MSEL->AT9WRN : '';
|
||||
$insertArray['A1MATWRN'] = $hazMat;
|
||||
|
||||
// $InsertArray['A1USRN01']=$palletQty;
|
||||
// $insertArray['A1USRN01']=$palletQty;
|
||||
// }
|
||||
|
||||
// SQL Insert to ICM666M
|
||||
$insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm666m')->insert($InsertArray);
|
||||
$insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm666m')->insert($insertArray);
|
||||
}
|
||||
|
||||
// Call PGM ICM700CSBM
|
||||
if ($Warehouse != '' && $PickerNumber != '' && $Company != '') {
|
||||
$PGMERRORS = '';
|
||||
$AWREQN = '';
|
||||
if ($warehouse != '' && $pickerNumber != '' && $company != '') {
|
||||
$pGMERRORS = '';
|
||||
$aWREQN = '';
|
||||
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
@@ -435,13 +435,13 @@ class M3Controller extends Controller
|
||||
case 8001:
|
||||
// "Authorization failure on distributed database connection attempt"
|
||||
// Usually means a wrong DB2 user or password
|
||||
$PGMERRORS = 'Could not connect due to wrong user or password.';
|
||||
$pGMERRORS = 'Could not connect due to wrong user or password.';
|
||||
break;
|
||||
case 42705:
|
||||
$PGMERRORS = 'Database not found. Try WRKRDBDIRE to check.';
|
||||
$pGMERRORS = 'Database not found. Try WRKRDBDIRE to check.';
|
||||
break;
|
||||
default:
|
||||
$PGMERRORS = 'Could not connect. Error: ' . $code . ' ' . $msg;
|
||||
$pGMERRORS = 'Could not connect. Error: ' . $code . ' ' . $msg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -455,14 +455,14 @@ class M3Controller extends Controller
|
||||
|
||||
// AddParameterChar($io, $size, $comment, $varName, $value, $varying, $dimension)
|
||||
// Add Warehouse Param
|
||||
$params[] = $conn->AddParameterChar('in', 3, 'Company', '', $Company);
|
||||
$params[] = $conn->AddParameterChar('in', 3, 'Company', '', $company);
|
||||
|
||||
$params[] = $conn->AddParameterChar('in', 3, 'Warehouse', '', $Warehouse);
|
||||
$params[] = $conn->AddParameterChar('in', 3, 'Warehouse', '', $warehouse);
|
||||
|
||||
// AddParameterPackDec($io, $length, $scale, $comment, $varName, $value,$dimension)
|
||||
// Add Delivery Note Param
|
||||
$PickerNumberNoZero = ltrim(strval($PickerNumber), '0');
|
||||
$params[] = $conn->AddParameterChar('in', 11, 'PickerNumber', '', $PickerNumberNoZero);
|
||||
$pickerNumberNoZero = ltrim(strval($pickerNumber), '0');
|
||||
$params[] = $conn->AddParameterChar('in', 11, 'PickerNumber', '', $pickerNumberNoZero);
|
||||
|
||||
// Start Time Tracking
|
||||
$start = microtime(true);
|
||||
@@ -471,20 +471,20 @@ class M3Controller extends Controller
|
||||
$result = $conn->PgmCall('ICM700CSBM', env('OBJLIB'), $params, [], []);
|
||||
|
||||
if (! $result) {
|
||||
$PGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' - Msg: ' . $conn->getErrorMsg();
|
||||
$pGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' - Msg: ' . $conn->getErrorMsg();
|
||||
}
|
||||
|
||||
if ($PGMERRORS != '') {
|
||||
if ($pGMERRORS != '') {
|
||||
// Write to Logs Out : Error & JSON
|
||||
$data = ['SHMACPKR' => $SHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-spl',
|
||||
'SHDATA' => $PGMERRORS . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
|
||||
$data = ['SHMACPKR' => $sHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-spl',
|
||||
'SHDATA' => $pGMERRORS . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $rEQKPKUS, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $company, 'SHWHS' => $warehouse];
|
||||
Helper::logToICM699M($data);
|
||||
}
|
||||
}
|
||||
|
||||
// Write to Logs Out : Success
|
||||
$data = ['SHMACPKR' => $SHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => '', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-in',
|
||||
'SHDATA' => json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
|
||||
$data = ['SHMACPKR' => $sHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => '', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-in',
|
||||
'SHDATA' => json_encode($jsonFile), 'SHUSER' => $rEQKPKUS, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $company, 'SHWHS' => $warehouse];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
@@ -494,10 +494,10 @@ 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';
|
||||
$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];
|
||||
$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([
|
||||
@@ -508,8 +508,8 @@ class M3Controller extends Controller
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
// Write to Logs Out : Error & JSON
|
||||
$data = ['SHMACPKR' => $SHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-in',
|
||||
'SHDATA' => 'General Catchable Error - ' . substr($th, 0, 300) . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
|
||||
$data = ['SHMACPKR' => $sHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-in',
|
||||
'SHDATA' => 'General Catchable Error - ' . substr($th, 0, 300) . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $rEQKPKUS, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $company, 'SHWHS' => $warehouse];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
|
||||
Reference in New Issue
Block a user