M3 Integration fixes
This commit is contained in:
Executable
Executable
+96
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
// M3 now uses Core's PostgreSQL connection. No per-user DB credentials are required.
|
||||
|
||||
return [
|
||||
|
||||
// 'nonWorkingHourCode' => ['73,85,89,90,91,92,86,99'],
|
||||
'autorefresh_all' => ['00:15'],
|
||||
'autorefresh_notall' => ['00:15'],
|
||||
|
||||
'payrollCodes' => ['33,49,75,94,98,102,171'],
|
||||
|
||||
'min_work_hours_for_break' => ['4'],
|
||||
|
||||
'ignore_picks_that_last_longer_than_this_many_hours' => ['8'],
|
||||
|
||||
'env_ports' => ['test' => '10004', 'live' => '10005'],
|
||||
|
||||
'hold_code_array' => ['A' => 'Admin Hold',
|
||||
'C' => 'AR Past Due',
|
||||
'D' => 'Over Credit Limit',
|
||||
'E' => 'Over Order Limit',
|
||||
'F' => 'Address Check Fail',
|
||||
'Q' => 'Quote Hold',
|
||||
'H' => 'A/R Cust Hold',
|
||||
'I' => 'EDI Hold',
|
||||
'P' => 'EDI Price Hold',
|
||||
'Z' => 'Haz Hold',
|
||||
'X' => 'CID Hold',
|
||||
'W' => 'Web Hold',
|
||||
'T' => 'Duplicate Hold'],
|
||||
|
||||
'user_array' => '', // $user_array,
|
||||
'misc' => [
|
||||
'discountCarrierRateForCustomerPriceLTL' => 0.00, // This is the percent off list that we want to charge customers
|
||||
'discountCarrierRateForCustomerPriceParcel' => 0.00, // This is the percent off list that we want to charge customers - to use in ship confirm
|
||||
],
|
||||
'transxTypes' => [
|
||||
'ICM710E' => 'Splitting delivery orders',
|
||||
'ICM710E13' => 'Pre-Splitting interco delivery orders',
|
||||
'ICM710E12' => 'Pre-Splitting customer delivery orders',
|
||||
'M3InventoryReportListURL' => 'Retrieve inventory on hand',
|
||||
'M3InventoryReportReplen' => 'Retrieve Replenishments',
|
||||
'M3ReceiverAPI' => 'Post Splitting delivery orders',
|
||||
'PdfStorageAPI' => 'PDF document storage',
|
||||
'PackSyst4tray' => 'Change of qty picked after picking',
|
||||
'CloseShipmentCoChargeAPI' => 'Closing delivery orders',
|
||||
'TransferAPIURL' => 'Move goods to Pack/Dock locations',
|
||||
'OP705API' => 'Closing a manifest',
|
||||
'CloseShipmentCoChargeAPIMfest' => 'Batch closing for M3 manifests at night',
|
||||
'M3-General' => 'General - contact MPBA',
|
||||
'UpdateShipmentNumber' => 'Update Shipment Number',
|
||||
],
|
||||
'curlTimeOut' => 30,
|
||||
'PHPTimeOut' => 600,
|
||||
'PHPTimeOutCL' => 1000,
|
||||
'maxRecDL' => 20000,
|
||||
'maxRecCL' => 55000,
|
||||
'BadChars' => ['–', '\t', '\n', '\u20134807', '\u20131', '\u201333', '\u2013671', 'Ÿ', 'á', 'é', 'í', 'ó', 'ú', '“', '”'],
|
||||
'PdfPath' => env('M3_LABELS_PATH', storage_path('app/m3/labels') . DIRECTORY_SEPARATOR), // Warning : The path for PDF storage is shared by all Instances and should not be altered
|
||||
'DUMMYPDF' => '',
|
||||
'uom_size' => ['110-142-303' => 'mm',
|
||||
'110-143-321' => 'mm',
|
||||
'110-143-322' => 'in'], // unit of mesure for boxes lengths mm or in
|
||||
'uom_wt' => ['110-142-303' => 'kg',
|
||||
'110-143-321' => 'kg',
|
||||
'110-143-322' => 'lbs'], // unit of mesure for boxes weight kg or lbs
|
||||
|
||||
// STATUS ARRAY FOR ICM688M1
|
||||
'status_ICM688M1_array' => [
|
||||
'P' => 'Pending error checking by splitting (OP510E2)',
|
||||
'H' => 'Hold as error found (OP510E3)',
|
||||
'L' => 'Ready to pick',
|
||||
'I' => 'In picking',
|
||||
'F' => 'In packing',
|
||||
'X' => 'Cancelled',
|
||||
'C' => 'Packed',
|
||||
'B' => 'Loaded',
|
||||
'a' => 'Manually removed from Sentinel ship confirm screen',
|
||||
'A' => 'ShipConfirmed'],
|
||||
|
||||
'whsePerf_targets' => [
|
||||
'all_notes' => '90', 'all_dollars' => '85', 'all_weight' => '90',
|
||||
'ltl_notes' => '90', 'ltl_dollars' => '95', 'ltl_weight' => '99',
|
||||
'parcel_notes' => '90', 'parcel_dollars' => '75', 'parcel_weight' => '80',
|
||||
],
|
||||
'2Ship' => [
|
||||
// 2Ship WS_Key
|
||||
// live $TwoShip_Key="FED945D1-5DC7-415E-BDAB-16347E7C1304";
|
||||
// test $TwoShip_Key="45027F2A-EDA6-4C16-8AD4-9BC70CE94AB8";
|
||||
'TwoShip_Key' => '45027F2A-EDA6-4C16-8AD4-9BC70CE94AB8',
|
||||
'end_point' => 'https://euroapi.2ship.com/api/',
|
||||
'hold_update' => 'UpdateOnHoldOrder_V1',
|
||||
],
|
||||
|
||||
];
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
// PayRollCodes are the keys (left) to read LBPF, lines per hours (right)
|
||||
return [
|
||||
|
||||
'lph_per_code_array' => ['16' => '30',
|
||||
'33' => '12',
|
||||
'49' => '25',
|
||||
'66' => '60',
|
||||
'75' => '15',
|
||||
'94' => '40',
|
||||
'98' => '8',
|
||||
'102' => '10',
|
||||
'171' => '17',
|
||||
],
|
||||
|
||||
];
|
||||
// '75'=>'26',
|
||||
// '75'=>'23',
|
||||
// '33'=>'13', #2025-08-04
|
||||
|
||||
// Found in BLDPERFST rpg pgm in EWRPGSRC / EWSRCTST
|
||||
// PICKING stats
|
||||
// when a5sentview in ('7','9') then 33
|
||||
// when a5sentview = 5 then 49
|
||||
// when a5sentview = 12 then 98
|
||||
// when a5sentview in ('2','10') then 75
|
||||
// when a5sentview in ('1','3','4','11') then 94
|
||||
// when a5sentview = 8 then 102
|
||||
// when a5sentview = 6 then 171
|
||||
// else 999
|
||||
|
||||
// PACKING stats
|
||||
// case when (select AYTYPE from ICM695M1
|
||||
// where AYINTBOX=AZINTBOX
|
||||
// and AYSENTPKR=AZSENTPKR FETCH FIRST ROW ONLY)
|
||||
// in ('','BX') then '16' else '66' end as AYTYPE,
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'M3',
|
||||
'connection' => env('M3_DB_CONNECTION', env('DB_CONNECTION', 'pgsql')),
|
||||
'labels_path' => env('M3_LABELS_PATH', storage_path('app/m3/labels')),
|
||||
'closing_orders_path' => env('M3_CLOSING_ORDERS_PATH', storage_path('app/m3/closing-orders')),
|
||||
];
|
||||
Executable
Executable
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Modules\M3\Http\Controllers\API\CloseShipment;
|
||||
|
||||
class CallCloseAPI extends Command
|
||||
{
|
||||
protected $signature = 'command:CallCloseAPI {user?} {manifest?} {co?} {whs?} ';
|
||||
|
||||
protected $description = 'Call Close API';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
self::configureTimeouts();
|
||||
try {
|
||||
$manifest = (string) ($this->argument('manifest') ?? '');
|
||||
if ($manifest !== '') {
|
||||
return $this->closeSpecificManifest($manifest, (string) ($this->argument('co') ?? ''), (string) ($this->argument('whs') ?? ''));
|
||||
}
|
||||
$this->closePendingManifests();
|
||||
|
||||
return self::SUCCESS;
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('dailyCron')->error($th);
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
private static function configureTimeouts(): void
|
||||
{
|
||||
$timeout = Config::get('arrays.PHPTimeOut');
|
||||
ini_set('max_execution_time', $timeout);
|
||||
ini_set('max_input_time', $timeout);
|
||||
ini_set('default_socket_timeout', $timeout);
|
||||
}
|
||||
|
||||
private function closePendingManifests(): void
|
||||
{
|
||||
$rows = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->select('APMANIFEST', 'APCO', 'APWHS')->where('APSPARE2', '')->where('APMANIFEST', '!=', '0')
|
||||
->whereRaw('EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - APLDCLOZ)) / 60 > 15')->orderBy('APMANIFEST', 'desc')->get();
|
||||
foreach ($rows as $row) {
|
||||
$this->closeManifest((string) $row->APMANIFEST, (string) ($row->APCO ?? ''), (string) ($row->APWHS ?? ''));
|
||||
}
|
||||
}
|
||||
|
||||
private function closeSpecificManifest(string $manifest, string $co, string $whs): int
|
||||
{
|
||||
$exists = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->where('APSPARE2', '')->where('APCO', $co)->where('APWHS', $whs)->where('APMANIFEST', $manifest)->exists();
|
||||
if (! $exists) {
|
||||
Log::channel('dailyCron')->warning('Manifest not available for close', compact('manifest', 'co', 'whs'));
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
$this->closeManifest($manifest, $co, $whs);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function closeManifest(string $manifest, string $co, string $whs): void
|
||||
{
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->where('APMANIFEST', $manifest)->where('APCO', $co)->where('APWHS', $whs)->update(['APSPARE2' => 'P']);
|
||||
$request = Request::create('', 'POST', ['WHS' => $whs, 'COMPANY' => $co, 'TRANSTYPE' => 'M', 'MANIFEST' => $manifest]);
|
||||
$response = CloseShipment::CloseShipmentCoChargeAPI($request);
|
||||
$json = json_encode($response->getData());
|
||||
Log::channel('dailyCron')->info('Close Shipment API Response for Manifest:' . $manifest . '-' . $json);
|
||||
}
|
||||
}
|
||||
Executable
+223
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Modules\M3\Services\SpreadsheetExport;
|
||||
use Storage;
|
||||
|
||||
class ClosedOrderSaveXls extends Command
|
||||
{
|
||||
private const XLSX_EXTENSION = '.xlsx';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:ClosedOrderSaveXls {user?} {co?} {whs?} {pl?}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Save Orders Closed Lines to Excel';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->configureRuntime();
|
||||
|
||||
try {
|
||||
Log::channel('dailyCron')->info('Cron...Start Save Orders Closed Lines to Excel');
|
||||
[$company, $warehouse, $plant] = $this->argumentsForReport();
|
||||
|
||||
$this->generatePreviousMonthReport($company, $warehouse, $plant);
|
||||
$this->generateCurrentMonthReport($company, $warehouse, $plant);
|
||||
|
||||
Log::channel('dailyCron')->info('Cron...End Save Orders Closed Lines to Excel');
|
||||
$this->info('Cron...End Save Orders Closed Lines to Excel');
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('dailyCron')->error($th);
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function configureRuntime(): void
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
}
|
||||
|
||||
private function argumentsForReport(): array
|
||||
{
|
||||
return [
|
||||
trim((string) $this->argument('co')),
|
||||
trim((string) $this->argument('whs')),
|
||||
trim((string) $this->argument('pl')),
|
||||
];
|
||||
}
|
||||
|
||||
private function generatePreviousMonthReport(string $company, string $warehouse, string $plant): void
|
||||
{
|
||||
$date = new \DateTime('FIRST DAY OF THIS MONTH');
|
||||
$date->modify('-1 month');
|
||||
$from = $date->format('Y-m-d');
|
||||
$to = $date->modify('last day of this month')->format('Y-m-d');
|
||||
$file = $warehouse === '321'
|
||||
? 'Closedorderlinesreport_' . $from . '-' . $to . self::XLSX_EXTENSION
|
||||
: $warehouse . '/Closedorderlinesreport_' . $from . '-' . $to . '-' . $warehouse . self::XLSX_EXTENSION;
|
||||
|
||||
$this->info('Generate Last Month Report...');
|
||||
$this->generateReport(
|
||||
$company,
|
||||
$warehouse,
|
||||
$plant,
|
||||
str_replace('-', '', $from),
|
||||
str_replace('-', '', $to),
|
||||
$file,
|
||||
! Storage::disk('publicCL')->exists($file),
|
||||
'Last Month',
|
||||
);
|
||||
}
|
||||
|
||||
private function generateCurrentMonthReport(string $company, string $warehouse, string $plant): void
|
||||
{
|
||||
$now = new \DateTime;
|
||||
$from = $now->format('Y-m-01');
|
||||
$to = $now->format('Y-m-d');
|
||||
$file = $warehouse === '321'
|
||||
? 'first_of_month_to_current_date.xlsx'
|
||||
: $warehouse . '/first_of_month_to_current_date_' . $warehouse . self::XLSX_EXTENSION;
|
||||
|
||||
$this->info('Generate Current Month Report...');
|
||||
$this->generateReport(
|
||||
$company,
|
||||
$warehouse,
|
||||
$plant,
|
||||
str_replace('-', '', $from),
|
||||
str_replace('-', '', $to),
|
||||
$file,
|
||||
true,
|
||||
'Current Month',
|
||||
);
|
||||
}
|
||||
|
||||
private function generateReport(
|
||||
string $company,
|
||||
string $warehouse,
|
||||
string $plant,
|
||||
string $from,
|
||||
string $to,
|
||||
string $file,
|
||||
bool $shouldGenerate,
|
||||
string $label,
|
||||
): void {
|
||||
$this->info('From Date: ' . $from);
|
||||
$this->info('To Date: ' . $to);
|
||||
|
||||
if (! $shouldGenerate || ! $this->hasReportScope($company, $warehouse, $plant)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = $this->closedOrderRows($company, $warehouse, $plant, $from, $to);
|
||||
if ($rows->isEmpty()) {
|
||||
Log::channel('dailyCron')->info($label . ' report, no records found: Nothing to save...');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$rows->prepend($this->headers());
|
||||
$this->logRecordLimit($rows->count());
|
||||
$this->info('Saving ' . $label . ' Excel Report to Disk');
|
||||
Log::channel('dailyCron')->info('Saving ' . $label . ' Excel Report to Disk');
|
||||
app(SpreadsheetExport::class)->store($rows, $file, 'publicCL');
|
||||
}
|
||||
|
||||
private function hasReportScope(string $company, string $warehouse, string $plant): bool
|
||||
{
|
||||
return $company !== '' && $warehouse !== '' && $plant !== '';
|
||||
}
|
||||
|
||||
private function closedOrderRows(string $company, string $warehouse, string $plant, string $from, string $to)
|
||||
{
|
||||
$ltlFactor = (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL')) / 100;
|
||||
$parcelFactor = (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel')) / 100;
|
||||
|
||||
$sql = <<<'SQL'
|
||||
SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO,
|
||||
A4OFSTRM, A5PMPWHT*A5PACKED AS WEIGHT, A4SCAC, A4SHIPTYPE,
|
||||
(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,
|
||||
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) * ?
|
||||
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ?
|
||||
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
|
||||
LEFT JOIN ICM688M1 ON A4MACPKR=A5MACPKR
|
||||
WHERE A5MACPKR IN (
|
||||
SELECT DISTINCT AYMACPKR FROM ICM695M1
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 BETWEEN ? AND ?
|
||||
)
|
||||
AND A5CO=? AND A5WHS=? AND A5PLANT=?
|
||||
SQL;
|
||||
|
||||
return collect(DB::connection(config('m3.connection', 'pgsql'))->select($sql, [
|
||||
$ltlFactor, $parcelFactor, $from, $to, $company, $warehouse, $plant,
|
||||
]));
|
||||
}
|
||||
|
||||
private function headers(): array
|
||||
{
|
||||
return [
|
||||
'DATECLOSED' => 'Close Date', 'A5MACPKR' => 'Delivery #', 'A5ONO' => 'Order #',
|
||||
'A4OFSTRM' => 'Terms', 'WEIGHT' => 'Weight', 'A4SCAC' => 'Carrier',
|
||||
'A4SHIPTYPE' => 'Mode (Parcel, Air, TL or LTL)', 'A4REFORD' => 'Order Type',
|
||||
'A5PART' => 'Part #', 'A5RSVQTY' => 'Reserved', 'A5PACKED' => 'Packed',
|
||||
'CALCULATED_COLUMN' => 'Back Order Qty', 'ANOTHER_CALCULATED_COLUMN' => 'Value Packed $',
|
||||
'A4SHSHNM' => 'Customer name', 'REASON' => 'Failure Reason',
|
||||
'A1SHCURR' => 'Currency Code', 'FREIGHT' => 'Freight',
|
||||
];
|
||||
}
|
||||
|
||||
private function logRecordLimit(int $count): void
|
||||
{
|
||||
$maxRecords = (int) Config::get('arrays.maxRecCL');
|
||||
if ($count <= $maxRecords) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::channel('dailyCron')->info(
|
||||
'Maximum allowed records for Excel export is: ' . number_format($maxRecords)
|
||||
. ' current records: ' . number_format($count),
|
||||
);
|
||||
}
|
||||
}
|
||||
Executable
+88
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Config;
|
||||
use File;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
class DeleteOldLabels extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:DeleteOldLabelsCmd';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Delete Old Labels Command';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
$this->info('Start Delete Old Labels Command...');
|
||||
Log::channel('dailyCron')->info('Cron...Start Delete Old Labels Command...');
|
||||
|
||||
$labelsDirectoryTmp = '/www/sentm3live/htdocs/labels/';
|
||||
$subFolders = ['CarrierLabel/', 'ContentLabel/', 'PackingList/']; // ,'CarrierLabel/','ContentLabel','PackingList',''
|
||||
$daysOld = 180; // Number of days to consider a file old : 180 =Six Months
|
||||
$filesToDeleteArr = [];
|
||||
|
||||
foreach ($subFolders as $subFolder) {
|
||||
$labelsDirectory = $labelsDirectoryTmp . $subFolder;
|
||||
|
||||
$this->info('Getting Files From Directory: ' . $labelsDirectory);
|
||||
Log::channel('dailyCron')->info('Getting Files From Directory: ' . $labelsDirectory);
|
||||
|
||||
exec('find ' . $labelsDirectory . ' -ctime +180 -type f -exec rm {} \;');
|
||||
}
|
||||
|
||||
$labelsFolder = $labelsDirectoryTmp;
|
||||
// Get Files from the specified Directory
|
||||
$filesToDelete = File::allFiles($labelsFolder);
|
||||
|
||||
foreach ($filesToDelete as $file) {
|
||||
$lastAccessTime = new \DateTime('@' . $file->getATime());
|
||||
$now = new \DateTime;
|
||||
$diff = $now->diff($lastAccessTime)->days;
|
||||
|
||||
if ($diff >= $daysOld) {
|
||||
$this->info('File: ' . $file . ' is Days Old: ' . $diff);
|
||||
// Log::channel('dailyCron')->info("File: ".$file." is Days Old: ".$diff);
|
||||
// Add the File to Array
|
||||
$filesToDeleteArr[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete Old Files
|
||||
File::delete($filesToDeleteArr);
|
||||
|
||||
Log::channel('dailyCron')->info('Cron...End Delete Old Labels Command...');
|
||||
$this->info('End Delete Old Labels Command...');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+258
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Ayeo\Barcode;
|
||||
use Cache;
|
||||
use Config;
|
||||
use DB;
|
||||
use Dompdf\Dompdf;
|
||||
use File;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use PDF;
|
||||
use Picqer\Barcode\BarcodeGeneratorPNG;
|
||||
use Str;
|
||||
|
||||
class GenerateGS1Cmd extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:GenerateGS1Cmd {user?} {--gsarray=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate GS1-128 Label';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
$this->info('>>> Run GS1 Label creation Command...');
|
||||
Log::channel('LabelCron')->info('>>> Run GS1 Label creation Command...');
|
||||
|
||||
// Get the Calling User
|
||||
$userId = $this->argument('user');
|
||||
$sHUSER = $userId ?? (m3_user() !== '' ? Str::upper(trim(m3_user())) : 'TWOSHIP');
|
||||
$this->info('User: ' . $sHUSER);
|
||||
|
||||
// Get Manifest Array
|
||||
$gSArray1 = $this->option('gsarray');
|
||||
$gSArray = json_decode($gSArray1, true);
|
||||
|
||||
// MAK : Used for debug only
|
||||
$gSArray = ['Macpkr' => '55555', 'Recipient_Address1' => '9571 Pan American DR', 'Recipient_Address2' => 'C/O AEE Solar', 'Recipient_City' => 'El Paso',
|
||||
'Recipient_CompanyName' => 'SNAPRACK EL PASO PRODUCTION', 'Recipient_CountryCode' => 'US', 'Recipient_PostalCode' => '79927', 'Recipient_State' => 'TX',
|
||||
'Sender_Address1' => '6800 Arnold Miller Pkwy', 'Sender_Address2' => '', 'Sender_City' => 'Solon',
|
||||
'Sender_CompanyName' => 'Erico International', 'Sender_Country' => 'US', 'Sender_PostalCode' => '44139', 'Sender_State' => 'OH',
|
||||
'CarrierName' => 'R&L Carriers', 'trackingno' => '306539838', 'BOLnumber' => '693103848064454', 'ShipmentPONumber' => '4523039092',
|
||||
'PackagesArray' => ['package 1', 'package 2'],
|
||||
];
|
||||
|
||||
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();
|
||||
|
||||
$cOMPANY = isset($iCM428M->R428CO) ? $iCM428M->R428CO : ''; // Company
|
||||
$wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : ''; // WareHouse
|
||||
|
||||
$macpkr = $gSArray['Macpkr'];
|
||||
$packageType = '0';
|
||||
$manufactID = '0826528'; // MAK : get ID from Nvent and save to Config File
|
||||
$total_length = 9;
|
||||
|
||||
$html = '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.border_btm {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
.border_rght {
|
||||
border-right: 1px solid;
|
||||
}
|
||||
|
||||
.margin_t {
|
||||
padding-top : 10px;
|
||||
}
|
||||
|
||||
.align_lft {
|
||||
text-align: left;
|
||||
}
|
||||
.align_center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@page { margin: 5px; }
|
||||
body { margin: 0px; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif;">';
|
||||
|
||||
// Get number of Pallets
|
||||
$packageCount = count($gSArray['PackagesArray']);
|
||||
$packageNum = 1;
|
||||
while ($packageNum <= $packageCount) {
|
||||
$table_style = $packageNum < $packageCount ? ' style="page-break-after: always;" ' : '';
|
||||
|
||||
if (Cache::has('GS1SEQUENCE')) {
|
||||
$gS1SEQUENCE = Cache::get('GS1SEQUENCE');
|
||||
$gS1SEQUENCE++;
|
||||
$gS1SEQUENCEID = str_pad($gS1SEQUENCE, $total_length, '0', STR_PAD_LEFT);
|
||||
}
|
||||
// Box Number Not Found Get it from DB
|
||||
else {
|
||||
$gS1SEQUENCE = 1;
|
||||
$gS1SEQUENCEID = str_pad($gS1SEQUENCE, $total_length, '0', STR_PAD_LEFT);
|
||||
}
|
||||
Cache::forever('GS1SEQUENCE', $gS1SEQUENCEID);
|
||||
$this->info('>>> GS1 sequence Id: ' . $gS1SEQUENCEID);
|
||||
|
||||
$gs1_128_bc_1 = '00' . $packageType . $manufactID . $gS1SEQUENCEID;
|
||||
|
||||
// Calculate Check Digit
|
||||
$digits = str_split($gs1_128_bc_1);
|
||||
$sum = 0;
|
||||
$length = count($digits);
|
||||
|
||||
// Loop through each digit starting from the right
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$digit = $digits[$length - $i - 1];
|
||||
// Assign a weight of 3 or 1 alternately
|
||||
$weight = ($i % 2 == 0) ? 3 : 1;
|
||||
// Add the product of the digit and its weight to the sum
|
||||
$sum += $digit * $weight;
|
||||
}
|
||||
// Calculate the remainder when sum is divided by 10
|
||||
$remainder = $sum % 10;
|
||||
// If remainder is 0, check digit is 0; otherwise, subtract remainder from 10
|
||||
$checkDigit = ($remainder == 0) ? 0 : 10 - $remainder;
|
||||
|
||||
$gs1_128_bc_desc = '(00)' . $packageType . $manufactID . $gS1SEQUENCEID . $checkDigit;
|
||||
|
||||
$data = [
|
||||
'ship_to' => $gSArray['Recipient_CompanyName'] . '<br>' . $gSArray['Recipient_Address1'] . '<br>' .
|
||||
$gSArray['Recipient_City'] . ',' . $gSArray['Recipient_State']
|
||||
. '<br>' . $gSArray['Recipient_PostalCode'],
|
||||
'from' => $gSArray['Sender_CompanyName'] . '<br>' . $gSArray['Sender_Address1'] . '<br>' .
|
||||
$gSArray['Sender_City'] . ',' . $gSArray['Sender_State']
|
||||
. '<br>' . $gSArray['Sender_PostalCode'],
|
||||
'ship_to_lbl' => '420' . $gSArray['Recipient_PostalCode'],
|
||||
'ship_to_desc' => '(420)' . $gSArray['Recipient_PostalCode'],
|
||||
'pro' => '190071217845706',
|
||||
'item_number' => '10000B',
|
||||
'upc' => '098506095310',
|
||||
'quantity' => '1',
|
||||
'serial_shipping_container' => $gs1_128_bc_desc,
|
||||
];
|
||||
|
||||
// Initialize barcode generator
|
||||
$generator = new BarcodeGeneratorPNG;
|
||||
|
||||
// Generate barcodes
|
||||
$shipToPostalCodeBarcode = $generator->getBarcode($data['ship_to_lbl'], $generator::TYPE_CODE_128);
|
||||
$serialShippingContainerBarcode = $generator->getBarcode($data['serial_shipping_container'], $generator::TYPE_CODE_128, 2, 50);
|
||||
|
||||
// HTML content for the label
|
||||
$html .= '
|
||||
<table ' . $table_style . '>
|
||||
<tr>
|
||||
<td colspan="2" class="border_btm border_rght align_lft">
|
||||
FROM:<br>' . $data['from'] . '
|
||||
</td>
|
||||
<td colspan="2" class="border_btm align_lft">
|
||||
SHIP TO:<br>' . $data['ship_to'] . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="border_btm border_rght margin_t align_center">
|
||||
<img src="data:image/png;base64,' . base64_encode($shipToPostalCodeBarcode) . '"> <br>
|
||||
' . $data['ship_to_desc'] . '
|
||||
</td>
|
||||
<td class="border_btm margin_t align_lft">
|
||||
Carrier: ' . $gSArray['CarrierName'] . ' <br>
|
||||
PRO #: ' . $gSArray['ShipmentPONumber'] . ' <br>
|
||||
B/L #: ' . $gSArray['BOLnumber'] . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="border_btm margin_t align_lft border_rght">
|
||||
PURCHASE ORDER: ' . $gSArray['Macpkr'] . ' <br>
|
||||
Vendor: ' . $manufactID . '
|
||||
</td>
|
||||
<td colspan="2" class="border_btm margin_t align_center">
|
||||
Pallet # : ' . $packageNum . ' of ' . $packageCount . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: center;" class="margin_t">
|
||||
<img src="data:image/png;base64,' . base64_encode($serialShippingContainerBarcode) . '"><br>
|
||||
' . $data['serial_shipping_container'] . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
$packageNum++;
|
||||
}
|
||||
|
||||
$html .= '</body> </html>';
|
||||
|
||||
ob_start();
|
||||
|
||||
// Initialize Dompdf
|
||||
$dompdf = new Dompdf;
|
||||
$dompdf->loadHtml($html);
|
||||
$dompdf->setPaper('a6', 'portrait');
|
||||
// Render the HTML as PDF
|
||||
$dompdf->render();
|
||||
|
||||
// Output the generated PDF to Browser
|
||||
// $dompdf->stream();
|
||||
|
||||
$pdfContent = $dompdf->output();
|
||||
|
||||
$labelsPath = Config::get('arrays.PdfPath');
|
||||
// Put the PDF in labels/CarrierLabel
|
||||
$gSFolder = 'GSLabel';
|
||||
$carrierFileName = $gSFolder . '_' . $macpkr . '_' . $cOMPANY . '_' . $wHS;
|
||||
file_put_contents($labelsPath . $gSFolder . '/' . $carrierFileName . '.pdf', $pdfContent);
|
||||
|
||||
// Check if the PDF was generated correctly
|
||||
// if (!file_exists($tempPdfPath) || filesize($tempPdfPath) === 0) {
|
||||
// throw new Exception('PDF generation failed.');
|
||||
// }
|
||||
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
Log::channel('LabelCron')->info('<<< GS1-128...End of Label Creation');
|
||||
$this->info('<<< GS1-128...End of Label Creation');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('LabelCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Modules\M3\Http\Controllers\UtilitiesController;
|
||||
|
||||
class UtilitiesCmd extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:UtilitiesCmd';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Utilities Command';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
$this->info('Start Utilities Command...');
|
||||
|
||||
$myRequest = new Request;
|
||||
UtilitiesController::fixICM799MSentPKR($myRequest);
|
||||
|
||||
$this->info('End Utilities Command...');
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+145
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Modules\M3\Services\SpreadsheetExport;
|
||||
|
||||
class WHSMetricsSaveXls extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:WHSMetricsSaveXls {user?} {co?} {whs?} {pl?}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Save WHS Metrics to Excel';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->configureRuntime();
|
||||
|
||||
try {
|
||||
Log::channel('dailyCron')->info('Cron...Start Save WHS Metrics to Excel');
|
||||
$company = '110';
|
||||
$warehouse = '321';
|
||||
$plant = '143';
|
||||
$file = 'WhsPerf/' . $warehouse . '/WhsPerfMetrics_' . date('Y-m-d') . '-' . $warehouse . '.xlsx';
|
||||
|
||||
Log::channel('dailyCron')->info('>>> File Name: ' . $file);
|
||||
$this->info('Generate Today WHS Performance Report...');
|
||||
|
||||
[$summary, $details] = $this->reportCollections($company, $warehouse, $plant);
|
||||
$this->storeReport($summary, $details, $file);
|
||||
|
||||
Log::channel('dailyCron')->info('Cron...End Save Today WHS Performance Report to Excel');
|
||||
$this->info('Cron...End Save Today WHS Performance Report to Excel');
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function configureRuntime(): void
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
}
|
||||
|
||||
private function reportCollections(string $company, string $warehouse, string $plant): array
|
||||
{
|
||||
$summary = collect($this->summaryRows($company, $warehouse, $plant))->map(fn ($item) => $this->trimRow($item));
|
||||
$summary->prepend([
|
||||
'A4SHIPTYPE' => 'Method', 'STATUS' => 'Status', 'SOURCE' => 'Source', 'PICKERS' => 'Pickers',
|
||||
'WEIGHT' => 'Weight', 'LINES' => 'Lines', 'DOLLARS' => 'Dollars',
|
||||
]);
|
||||
|
||||
$details = collect($this->detailRows($company, $warehouse, $plant))->map(fn ($item) => $this->trimRow($item));
|
||||
$details->prepend([
|
||||
'A3CO' => 'Co', 'A3WHS' => 'Whs', 'A3PLT' => 'Plt', 'A3MACPKR' => 'Delivery No', 'A4PICKCRTS' => 'Date Time Arrived in Sentinel',
|
||||
'SOURCE' => 'Source', 'CARRIERASSIGNED' => 'Date carrier Assigned', 'A4ONO' => 'Order No', 'A4SHSHNM' => 'Customer name',
|
||||
'A4SCAC' => 'Carrier', 'A42SSVCNAM' => 'Service', 'A4PICKSTS' => 'Picker Status', 'STATUS' => 'Open or Closed',
|
||||
'A4SHIPTYPE' => 'Method', 'A4TPCKWGHT' => 'Weight', 'A4NOPICLNS' => 'Lines', 'DOLLARS' => 'Dollars',
|
||||
]);
|
||||
|
||||
return [$summary, $details];
|
||||
}
|
||||
|
||||
private function trimRow(object $item): object
|
||||
{
|
||||
foreach ($item as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$item->{$key} = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function summaryRows(string $company, string $warehouse, string $plant): array
|
||||
{
|
||||
return DB::connection(config('m3.connection', 'pgsql'))->select(<<<'SQL'
|
||||
WITH TEMPFILE AS (
|
||||
SELECT A.*,A4TPCKWGHT,A4NOPICLNS,A4PICKSTS,
|
||||
CASE WHEN UPPER(A4PICKSTS)<>'A' THEN 'Open' ELSE 'Closed' END AS STATUS,
|
||||
CASE WHEN A4TPCKWGHT>16000 THEN 'FTL' ELSE A4SHIPTYPE END AS A4SHIPTYPE,
|
||||
(SELECT SUM(A5RSVQTY*A5SLUNPR) FROM ICM688M2 WHERE A4MACPKR=A5MACPKR) AS DOLLARS
|
||||
FROM ICM700M A LEFT JOIN ICM688M1 B ON A4MACPKR=A3MACPKR
|
||||
WHERE A3MSMTDATE=(SELECT MAX(A3MSMTDATE) FROM ICM700M) AND A3CO=? AND A3WHS=? AND A3PLT=?
|
||||
)
|
||||
SELECT A4SHIPTYPE,STATUS,SOURCE,COUNT(*) AS PICKERS,SUM(A4TPCKWGHT) AS WEIGHT,SUM(A4NOPICLNS) AS LINES,SUM(DOLLARS) AS DOLLARS
|
||||
FROM TEMPFILE GROUP BY A4SHIPTYPE,STATUS,SOURCE ORDER BY 1,3,2
|
||||
SQL, [$company, $warehouse, $plant]);
|
||||
}
|
||||
|
||||
private function detailRows(string $company, string $warehouse, string $plant): array
|
||||
{
|
||||
return DB::connection(config('m3.connection', 'pgsql'))->select(<<<'SQL'
|
||||
WITH TEMPFILE AS (
|
||||
SELECT A3CO,A3WHS,A3PLT,A3MACPKR,A4PICKCRTS,SOURCE,
|
||||
(SELECT TO_TIMESTAMP(CAST(SHDT AS TEXT) || ' ' || CAST(SHTIME AS TEXT), 'YYYY-MM-DD HH24:MI:SS') FROM ICM699M WHERE SHMACPKR=A4MACPKR AND SHTYPE='Lisnr-Hold' ORDER BY SHDT DESC,SHTIME DESC FETCH FIRST 1 ROWS ONLY) AS CARRIERASSIGNED,
|
||||
A4ONO,A4SHSHNM,A4SCAC,A42SSVCNAM,A4PICKSTS,
|
||||
CASE WHEN UPPER(A4PICKSTS)<>'A' THEN 'Open' ELSE 'Closed' END AS STATUS,
|
||||
CASE WHEN A4TPCKWGHT>16000 THEN 'FTL' ELSE A4SHIPTYPE END AS A4SHIPTYPE,
|
||||
A4TPCKWGHT,A4NOPICLNS,(SELECT SUM(A5RSVQTY*A5SLUNPR) FROM ICM688M2 WHERE A4MACPKR=A5MACPKR) AS DOLLARS
|
||||
FROM ICM700M A LEFT JOIN ICM688M1 B ON A4MACPKR=A3MACPKR
|
||||
WHERE A3MSMTDATE=(SELECT MAX(A3MSMTDATE) FROM ICM700M) AND A3CO=? AND A3WHS=? AND A3PLT=?
|
||||
) SELECT * FROM TEMPFILE
|
||||
SQL, [$company, $warehouse, $plant]);
|
||||
}
|
||||
|
||||
private function storeReport($summary, $details, string $file): void
|
||||
{
|
||||
if ($summary->isEmpty() || $details->isEmpty()) {
|
||||
Log::channel('dailyCron')->info('Today WHS Performance Report, no records found: Nothing to save...');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->info('Saving Today WHS Performance Report to Disk...');
|
||||
Log::channel('dailyCron')->info('Saving Today WHS Performance Report to Disk...');
|
||||
app(SpreadsheetExport::class)->storeSheets(['Summary' => $summary, 'Details' => $details], $file, 'publicLabels');
|
||||
}
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::connection(config('m3.connection', 'pgsql'))->create('m3_program_requests', function (Blueprint $table): void {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('type', 20);
|
||||
$table->string('operation', 255);
|
||||
$table->string('library', 255)->nullable();
|
||||
$table->jsonb('payload')->nullable();
|
||||
$table->string('requested_by', 255)->nullable();
|
||||
$table->string('status', 30)->default('pending')->index();
|
||||
$table->text('result')->nullable();
|
||||
$table->text('error')->nullable();
|
||||
$table->timestamp('processed_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection(config('m3.connection', 'pgsql'))->dropIfExists('m3_program_requests');
|
||||
}
|
||||
};
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class M3DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
}
|
||||
}
|
||||
Executable
Executable
Executable
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// app/Helpers/USStates.php
|
||||
|
||||
namespace Modules\M3\Helpers;
|
||||
|
||||
class CAProvinces
|
||||
{
|
||||
public static function all()
|
||||
{
|
||||
return [
|
||||
'AB' => 'Alberta',
|
||||
'BC' => 'British Columbia',
|
||||
'MB' => 'Manitoba',
|
||||
'NB' => 'New Brunswick',
|
||||
'NL' => 'Newfoundland and Labrador',
|
||||
'NS' => 'Nova Scotia',
|
||||
'NT' => 'Northwest Territories',
|
||||
'NU' => 'Nunavut',
|
||||
'ON' => 'Ontario',
|
||||
'PE' => 'Prince Edward Island',
|
||||
'QC' => 'Quebec',
|
||||
'SK' => 'Saskatchewan',
|
||||
'YT' => 'Yukon',
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+352
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Helpers;
|
||||
|
||||
use Cache;
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Log;
|
||||
|
||||
class Helper
|
||||
{
|
||||
// Check M3 API Token
|
||||
public static function checkReceiveToken()
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOut'));
|
||||
|
||||
// Clear Cache
|
||||
// Cache::forget('token');
|
||||
// Check if cached Token is still Valid
|
||||
$token = Cache::get('token');
|
||||
|
||||
if (isset($token)) {
|
||||
$ionToken = $token;
|
||||
} else {
|
||||
// ## CURL
|
||||
// ## Generate Token
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => env('ENDPOINTURLSSO') . env('URLTOKEN'),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => 'grant_type=' . env('GRANT_TYPE') . '&password=' . env('PASSWORD') . '&username=' . env('USERNAME') . '&client_secret=' . env('CLIENT_SECRET') .
|
||||
'&client_id=' . env('CLIENT_ID'),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'charset:UTF-8',
|
||||
'Accept: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$responseJ = json_decode($response);
|
||||
|
||||
if ($response === false) {
|
||||
return response()->json([
|
||||
'code' => '400',
|
||||
'status' => 'Failed',
|
||||
'message' => 'Token Verification Error...' . curl_error($curl),
|
||||
]);
|
||||
} elseif (isset($responseJ->access_token)) {
|
||||
$ionToken = $responseJ->access_token;
|
||||
|
||||
Cache::put('token', $ionToken, now()->addMinutes(59));
|
||||
} else {
|
||||
return response()->json([
|
||||
'code' => '400',
|
||||
'status' => 'Failed',
|
||||
'message' => 'Token Verification Error...M3 response:' . $response,
|
||||
]);
|
||||
}
|
||||
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
return $ionToken;
|
||||
// 'code' => '200',
|
||||
// 'token' => $ionToken
|
||||
// ]);
|
||||
}
|
||||
|
||||
// Check M3 API Token V2
|
||||
public static function checkReceiveTokenV2()
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOut'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOut'));
|
||||
|
||||
// Clear Cache
|
||||
// Cache::forget('token');
|
||||
|
||||
// Check if cached Token is still Valid
|
||||
$token = Cache::get('token');
|
||||
|
||||
if (isset($token)) {
|
||||
$ionToken = $token;
|
||||
} else {
|
||||
// ## CURL
|
||||
// ## Generate Token
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => env('ENDPOINTURLSSO') . env('URLTOKEN'),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => 'grant_type=' . env('GRANT_TYPE') . '&password=' . env('PASSWORD') . '&username=' . env('USERNAME') . '&client_secret=' . env('CLIENT_SECRET') .
|
||||
'&client_id=' . env('CLIENT_ID'),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'charset:UTF-8',
|
||||
'Accept: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$responseJ = json_decode($response);
|
||||
curl_close($curl);
|
||||
|
||||
if ($response === false) {
|
||||
// Clear Cache
|
||||
Cache::forget('token');
|
||||
|
||||
// Return Error
|
||||
return response()->json([
|
||||
'code' => '400',
|
||||
'status' => 'Failed',
|
||||
'message' => 'Token Verification Error...' . curl_error($curl),
|
||||
]);
|
||||
} elseif (isset($responseJ->access_token)) {
|
||||
$ionToken = $responseJ->access_token;
|
||||
Cache::put('token', $ionToken, now()->addMinutes(59));
|
||||
} else {
|
||||
// Clear Cache
|
||||
Cache::forget('token');
|
||||
|
||||
return response()->json([
|
||||
'code' => '400',
|
||||
'status' => 'Failed',
|
||||
'message' => 'Token Verification Error...M3 response:' . $response,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'token' => $ionToken,
|
||||
]);
|
||||
}
|
||||
|
||||
// Read M3 JSON and Analyse it for Errors
|
||||
public static function checkM3Errors($responseResult)
|
||||
{
|
||||
if (! is_object($responseResult)) {
|
||||
return 'Invalid M3 response ';
|
||||
}
|
||||
|
||||
$messages = [];
|
||||
$inactiveTypes = 0;
|
||||
$closeShipmentInactive = self::collectCloseShipmentErrors($responseResult, $messages);
|
||||
|
||||
foreach (['Move', 'COCharge', 'Replenish', 'MoveDock'] as $type) {
|
||||
$result = self::extractM3Result($responseResult, $type);
|
||||
self::appendM3Error($messages, $type, $result);
|
||||
|
||||
if ($result['rawResult'] === 'N/A') {
|
||||
$inactiveTypes++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($closeShipmentInactive === 7 && $inactiveTypes === 4) {
|
||||
$messages[] = '-M3 did not call any method or type';
|
||||
}
|
||||
|
||||
return $messages === [] ? '' : implode(' ', $messages) . ' ';
|
||||
}
|
||||
|
||||
private static function collectCloseShipmentErrors(object $responseResult, array &$messages): int
|
||||
{
|
||||
$closeShipment = $responseResult->CloseShipment ?? null;
|
||||
if (! is_object($closeShipment)) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
$inactive = 0;
|
||||
foreach (['AddPackage', 'PickingListClose', 'TrailerNo', 'TrackingNo', 'ContentLabel', 'DeliveryNote', 'ShipLabel'] as $type) {
|
||||
$result = self::extractResultNode($closeShipment->{$type} ?? null);
|
||||
self::appendM3Error($messages, $type, $result);
|
||||
|
||||
if ($result['rawResult'] === 'N/A') {
|
||||
$inactive++;
|
||||
}
|
||||
}
|
||||
|
||||
return $inactive;
|
||||
}
|
||||
|
||||
private static function extractM3Result(object $responseResult, string $type): array
|
||||
{
|
||||
$node = $responseResult->{$type} ?? null;
|
||||
if ($type === 'MoveDock' && is_object($node)) {
|
||||
$node = $node->Move ?? null;
|
||||
}
|
||||
|
||||
return self::extractResultNode($node);
|
||||
}
|
||||
|
||||
private static function extractResultNode(mixed $node): array
|
||||
{
|
||||
if (! is_object($node)) {
|
||||
return ['error' => '', 'result' => '', 'rawResult' => 'N/A'];
|
||||
}
|
||||
|
||||
$error = trim((string) ($node->ErrorMessage ?? ''));
|
||||
$rawResult = trim((string) ($node->Result ?? ''));
|
||||
$result = in_array($rawResult, ['N/A', 'OK'], true) ? '' : $rawResult;
|
||||
|
||||
return ['error' => $error, 'result' => $result, 'rawResult' => $rawResult];
|
||||
}
|
||||
|
||||
private static function appendM3Error(array &$messages, string $type, array $result): void
|
||||
{
|
||||
if ($result['error'] === '' && $result['result'] === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$messages[] = $type . '-' . $result['result'] . '-' . $result['error'];
|
||||
}
|
||||
|
||||
// Log All Success And Error to ICM699M
|
||||
public static function logToICM699M($data)
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOut'));
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('ICM699M')->insert($data);
|
||||
}
|
||||
|
||||
// Get Substring in string between 2 Substrings
|
||||
public static function getSubstringBetween($string, $start, $end)
|
||||
{
|
||||
$startPos = strpos($string, $start);
|
||||
if ($startPos === false) {
|
||||
return '';
|
||||
}
|
||||
$endPos = strpos($string, $end, $startPos + strlen($start));
|
||||
if ($endPos === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return substr($string, $startPos + strlen($start), $endPos - ($startPos + strlen($start)));
|
||||
}
|
||||
|
||||
public static function checkLength($jsonFields, $dbFields, $type)
|
||||
{
|
||||
$type = $type == 'integer' || $type == 'DEC' ? 'number' : $type;
|
||||
|
||||
// Check Json Field should be < DB Field
|
||||
$lengthOK[413] = (strlen($jsonFields) <= $dbFields) ? true : false;
|
||||
// Empty Fields
|
||||
$lengthOK[411] = true; // !empty($jsonFields) ? true : false ;
|
||||
// Wrong Types
|
||||
$lengthOK[417] = true; // $jSONTypeConv == $type ? true : false ;
|
||||
// Log::info($lengthOK);
|
||||
|
||||
return $lengthOK;
|
||||
}
|
||||
|
||||
public static function sanityzeString($strToSanitize)
|
||||
{
|
||||
$badChars = Config::get('arrays.BadChars');
|
||||
|
||||
$goodString = trim($strToSanitize);
|
||||
$goodString = str_replace("'", '', $goodString);
|
||||
$goodString = str_replace("\u{f0e0}", '', $goodString);
|
||||
$goodString = preg_replace('/\\\\u201[0-9A-F]+/i', '', $goodString);
|
||||
$goodString = str_replace($badChars, '', $goodString);
|
||||
$goodString = iconv('UTF-8', 'ISO-8859-1//IGNORE', $goodString);
|
||||
$goodString = iconv('ISO-8859-1', 'UTF-8', $goodString);
|
||||
|
||||
// MAK : New Automatic Detection for encoding and conversion
|
||||
// Detect the encoding
|
||||
// $encoding = mb_detect_encoding($goodString, mb_list_encodings(), true);
|
||||
// Log::info($goodString);
|
||||
|
||||
// If encoding is detected, convert the string
|
||||
// if ($encoding !== false) {
|
||||
// // Log::info($encoding);
|
||||
// // Log::info($goodString);
|
||||
|
||||
// $goodString = mb_convert_encoding($goodString, "UTF-8", $encoding);
|
||||
// } else {
|
||||
// $goodString = "";
|
||||
// }
|
||||
|
||||
return $goodString;
|
||||
}
|
||||
|
||||
// Remove Duplicate SubString
|
||||
public static function removeDuplicateSubstrings($str)
|
||||
{
|
||||
$result = '';
|
||||
$seenPhrases = [];
|
||||
|
||||
$phrases = explode(' ', $str);
|
||||
foreach ($phrases as $phrase) {
|
||||
if (! in_array($phrase, $seenPhrases)) {
|
||||
$result .= $phrase . ' ';
|
||||
$seenPhrases[] = $phrase;
|
||||
}
|
||||
}
|
||||
|
||||
return trim($result);
|
||||
}
|
||||
|
||||
public static function getUserCOWHSPLT()
|
||||
{
|
||||
$defaults = [
|
||||
'UserCO' => '',
|
||||
'UserWHS' => '',
|
||||
'UserPL' => '',
|
||||
];
|
||||
|
||||
$loggedUser = strtoupper(trim((string) m3_user()));
|
||||
if ($loggedUser === '') {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
try {
|
||||
if (! Schema::connection(config('m3.connection', 'pgsql'))->hasTable('icm428m')) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
$user = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428ADMUSR', 'R428PWRUSR', 'R428CO', 'R428PL', 'R428WH', 'R42811A', 'R42821A')
|
||||
->where('R428US', $loggedUser)
|
||||
->first();
|
||||
|
||||
if (! $user) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
return [
|
||||
'UserCO' => trim((string) ($user->R428CO ?? '')),
|
||||
'UserWHS' => trim((string) ($user->R428WH ?? '')),
|
||||
'UserPL' => trim((string) ($user->R428PL ?? '')),
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('M3 user context unavailable', ['exception' => $e->getMessage()]);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
if (! function_exists('m3_user')) {
|
||||
/**
|
||||
* Return the current Core username in the format expected by the legacy M3 data.
|
||||
* M3 previously depended on PHP Basic Auth and read PHP_AUTH_USER directly.
|
||||
*/
|
||||
function m3_user(): string
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$value = $user?->username
|
||||
?? $user?->user_name
|
||||
?? $user?->name
|
||||
?? $user?->email
|
||||
?? request()->server('PHP_AUTH_USER')
|
||||
?? '';
|
||||
|
||||
if (str_contains((string) $value, '@')) {
|
||||
$value = strstr((string) $value, '@', true) ?: $value;
|
||||
}
|
||||
|
||||
return strtoupper(trim((string) $value));
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('m3_legacy_password')) {
|
||||
/**
|
||||
* Passwords are intentionally unavailable in Core. PostgreSQL access uses
|
||||
* Laravel's configured connection and never reuses a user's login password.
|
||||
*/
|
||||
function m3_legacy_password(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
if (! function_exists('subdirAsset')) {
|
||||
function subdirAsset($path)
|
||||
{
|
||||
return asset((App::environment('production') ? env('APP_DIR') : '') . '/' . $path);
|
||||
}
|
||||
}
|
||||
if (! function_exists('subdirMix')) {
|
||||
function subdirMix($path)
|
||||
{
|
||||
return mix((App::environment('production') ? env('APP_DIR') : '') . '/' . $path);
|
||||
}
|
||||
}
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
// app/Helpers/USStates.php
|
||||
|
||||
namespace Modules\M3\Helpers;
|
||||
|
||||
class USStates
|
||||
{
|
||||
public static function all()
|
||||
{
|
||||
return [
|
||||
'AL' => 'Alabama',
|
||||
'AK' => 'Alaska',
|
||||
'AZ' => 'Arizona',
|
||||
'AR' => 'Arkansas',
|
||||
'CA' => 'California',
|
||||
'CO' => 'Colorado',
|
||||
'CT' => 'Connecticut',
|
||||
'DE' => 'Delaware',
|
||||
'FL' => 'Florida',
|
||||
'GA' => 'Georgia',
|
||||
'HI' => 'Hawaii',
|
||||
'ID' => 'Idaho',
|
||||
'IL' => 'Illinois',
|
||||
'IN' => 'Indiana',
|
||||
'IA' => 'Iowa',
|
||||
'KS' => 'Kansas',
|
||||
'KY' => 'Kentucky',
|
||||
'LA' => 'Louisiana',
|
||||
'ME' => 'Maine',
|
||||
'MD' => 'Maryland',
|
||||
'MA' => 'Massachusetts',
|
||||
'MI' => 'Michigan',
|
||||
'MN' => 'Minnesota',
|
||||
'MS' => 'Mississippi',
|
||||
'MO' => 'Missouri',
|
||||
'MT' => 'Montana',
|
||||
'NE' => 'Nebraska',
|
||||
'NV' => 'Nevada',
|
||||
'NH' => 'New Hampshire',
|
||||
'NJ' => 'New Jersey',
|
||||
'NM' => 'New Mexico',
|
||||
'NY' => 'New York',
|
||||
'NC' => 'North Carolina',
|
||||
'ND' => 'North Dakota',
|
||||
'OH' => 'Ohio',
|
||||
'OK' => 'Oklahoma',
|
||||
'OR' => 'Oregon',
|
||||
'PA' => 'Pennsylvania',
|
||||
'RI' => 'Rhode Island',
|
||||
'SC' => 'South Carolina',
|
||||
'SD' => 'South Dakota',
|
||||
'TN' => 'Tennessee',
|
||||
'TX' => 'Texas',
|
||||
'UT' => 'Utah',
|
||||
'VT' => 'Vermont',
|
||||
'VA' => 'Virginia',
|
||||
'WA' => 'Washington',
|
||||
'WV' => 'West Virginia',
|
||||
'WI' => 'Wisconsin',
|
||||
'WY' => 'Wyoming',
|
||||
'DC' => 'District of Columbia',
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+1050
File diff suppressed because it is too large
Load Diff
+535
@@ -0,0 +1,535 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\M3\Helpers\Helper;
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Modules\M3\Services\PostgresProgramBridge;
|
||||
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
|
||||
public function insertToICM666M2($dataSplit, $commentData)
|
||||
{
|
||||
|
||||
$commentDataSS = explode("\n", $dataSplit);
|
||||
$aXLINENO = 1;
|
||||
foreach ($commentDataSS as $substring) {
|
||||
// Process each substring
|
||||
$fullData = $commentData;
|
||||
$fullData['AXCOMMENT'] = $substring;
|
||||
$fullData['AXLINENO'] = $aXLINENO;
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm666m2')->insert($fullData);
|
||||
|
||||
$aXLINENO++;
|
||||
|
||||
// AXCO ICM666M2 CHARACTER 3
|
||||
// AXWHS ICM666M2 CHARACTER 3
|
||||
// AXPLANT ICM666M2 CHARACTER 3
|
||||
// AXDOCUMENT ICM666M2 CHARACTER 15
|
||||
// AXCOMMENT ICM666M2 CHARACTER 60
|
||||
// AXLINENO DECIMAL(3,0)
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
dd('Index');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
// This API controller does not expose a create form.
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
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'));
|
||||
|
||||
$rEQKPKUS = m3_user() !== '' ? Str::upper(m3_user()) : 'WEBUSER';
|
||||
$sHSOURCE = 'M3ReceiverAPI';
|
||||
|
||||
$iCM666MFields = [
|
||||
'Company' => ['A1CO', 3, 'string'],
|
||||
'Warehouse' => ['A1WHS', 3, 'string'],
|
||||
'Plant' => ['A1PLANT', 3, 'string'],
|
||||
'PickerNumber' => ['A1DELNO', 11, 'integer'],
|
||||
'OrderNumber' => ['A1ONO', 10, 'string'],
|
||||
'ReleaseNumber' => ['A1RLNO', 3, 'string'], // Pick list suffix in ICM666M
|
||||
'ShipmentNumber' => ['A1SHNO', 7, 'string'],
|
||||
'OrderLine' => ['A1PKLN', 6, 'integer'],
|
||||
'PartNumber' => ['A1PART', 15, 'string'],
|
||||
'Description' => ['A1PARTDES', 120, 'string'],
|
||||
'Quantity' => ['A1RSVQTY', 22, 'DEC'],
|
||||
'BaseUnitPrice' => ['A1SLUNPR', 22, 'DEC'],
|
||||
'Currency' => ['A1SHCURR', 3, 'string'],
|
||||
'Zone' => ['A1LVZONE', 2, 'string'],
|
||||
'PromDate' => ['A1PROMDTE', 8, 'integer'],
|
||||
'RouteCode' => ['A1SHSRT', 6, 'string'],
|
||||
'BillToId' => ['A1BILLTO', 10, 'string'],
|
||||
'ShipToId' => ['A1SHIPTO', 10, 'string'],
|
||||
'CompanyName' => ['A1SHSHNM', 36, 'string'],
|
||||
'Address1' => ['A1SHSHA1', 36, 'string'],
|
||||
'Address2' => ['A1SHSHA2', 36, 'string'],
|
||||
'Address3' => ['A1SHSHA3', 36, 'string'],
|
||||
'Address4' => ['A1SHSHA4', 36, 'string'],
|
||||
'City' => ['A1SHSHCI', 20, 'string'],
|
||||
'State' => ['A1SHSHST', 2, 'string'],
|
||||
'PostalCode' => ['A1SHSHZP', 10, 'string'],
|
||||
'Country' => ['A1SHSHCT', 3, 'string'],
|
||||
'CountryName' => ['A1SHP2CNTY', 40, 'string'],
|
||||
'PartWeight' => ['A1PRTWGT', 15, 'integer'],
|
||||
'SellUOM' => ['A1SLUOM', 3, 'string'],
|
||||
'PartConv' => ['A1PARTCONV', 25, 'DEC'],
|
||||
'CarrierCode' => ['A1CARRIER', 6, 'string'],
|
||||
'ShipVia' => ['A1SHPVIA', 3, 'string'],
|
||||
'PrimaryLocation' => ['A1PRIMLOC', 10, 'string'],
|
||||
'Allocation' => ['A1SPR10A01', 10, 'string'],
|
||||
'AllocatedTo' => ['A1SPR15A01', 10, 'string'],
|
||||
'LocationSeq' => ['A1LOCSEQ', 10, 'string'],
|
||||
'UOM' => ['A1UOM', 3, 'string'],
|
||||
'HazMat' => ['A1MATWRN', 4, 'string'],
|
||||
'PartUPC' => ['A1UPC', 30, 'string'],
|
||||
'PartEAN' => ['A1EAN', 30, 'string'],
|
||||
'LotFlag' => ['A1IZLCF', 1, 'string'],
|
||||
'ManOrd' => ['A1MONUM', 30, 'string'],
|
||||
'LotNumber' => ['A1LOTNUM', 30, 'string'],
|
||||
'ProductArea' => ['A1LVUSD1', 15, 'string'],
|
||||
'FreightClass' => ['A1WBFRCT', 10, 'string'],
|
||||
'ShipmentPONumber' => ['A1SOPONO', 20, 'string'],
|
||||
'ShipmentPOLine' => ['A1SOPOLN', 7, 'integer'],
|
||||
'ShipTerms' => ['A1OFSTRM', 3, 'string'],
|
||||
// 'ExchangeRate' =>[ 'A1EXGRATE', 18,'DEC'],
|
||||
'OrderClass' => ['A1SHORCL', 3, 'string'],
|
||||
'LocationType' => ['A1LVUSD2', 2, 'string'],
|
||||
'PallSize' => ['A1LVUSD3', 10, 'string'],
|
||||
'MasterCarton' => ['A1USRLD1', 30, 'string'],
|
||||
'MasterQty' => ['A1WBSHQY', 25, 'DEC'],
|
||||
'InnerQty' => ['A1WBPKQY', 25, 'DEC'],
|
||||
'PalletQty' => ['A1USRN01', 24, 'DEC'],
|
||||
'CartonQty' => ['A1USRN31', 25, 'DEC'],
|
||||
'PersonName' => ['A1PERNAME', 30, 'string'],
|
||||
'AccountNo' => ['A1ACCNUM', 20, 'string'],
|
||||
'Email' => ['A1EMAIL', 100, 'string'],
|
||||
'OrderCategory' => ['A1REFORD', 1, 'string'],
|
||||
'A1DATEADD' => ['A1DATEADD', 12, 'string'],
|
||||
'A1TIMEADD' => ['A1TIMEADD', 12, 'string'],
|
||||
'KitPartNumber' => ['A1KITPART', 15, 'string'],
|
||||
'OrderLineSuffix' => ['A1PKSFX', 6, 'DEC'],
|
||||
'CustomerPartNumber' => ['A1CUSTPART', 20, 'string'],
|
||||
'GS1Label' => ['A1SPR1A01', 1, 'string'],
|
||||
'CurrencyExchangeRate' => ['A1EXGRATE', 18, 'DEC'],
|
||||
|
||||
];
|
||||
|
||||
try {
|
||||
$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'] : '';
|
||||
|
||||
// Set Carrier BWAY if it's empty for Tilburg only
|
||||
if (($carrierCode == '' || $carrierCode == null) && $warehouse == '111' && $company == '410' && $plant == '410') {
|
||||
$carrierCode = 'BWAY';
|
||||
}
|
||||
|
||||
$sHMACPKR = $pickerNumber != '' ? $pickerNumber : '000000';
|
||||
|
||||
if ($jsonFile != '') {
|
||||
// Order Category
|
||||
/*
|
||||
1 = Material to manufacturing order
|
||||
3 = Customer Order
|
||||
4 = Requisition Order
|
||||
5 = Distribution Order
|
||||
9 = Move order / Replenishment
|
||||
*/
|
||||
|
||||
// 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');
|
||||
|
||||
// MycarrierDetails
|
||||
$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;
|
||||
|
||||
$comments = isset($jsonFile['Comments']) ? $jsonFile['Comments'] : '';
|
||||
|
||||
if ($comments != '') {
|
||||
foreach ($comments as $key => $comment) {
|
||||
$commentData = [];
|
||||
$aXDOCUMENT = Helper::sanityzeString($key);
|
||||
|
||||
$commentData = ['AXCO' => $aXCO, 'AXPLANT' => $aXPLANT, 'AXWHS' => $aXWHS, 'AXDELNO' => $aXDELNO, 'AXONO' => $aXONO,
|
||||
'AXRLNO' => $aXRLNO, 'AXSHNO' => $aXSHNO, 'AXDOCUMENT' => $aXDOCUMENT];
|
||||
|
||||
switch ($aXDOCUMENT) {
|
||||
case 'Picker':
|
||||
$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);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Carrier':
|
||||
$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);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get Products : commodities And Write ICM666M
|
||||
$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'] : '';
|
||||
$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'] : '';
|
||||
$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 = [];
|
||||
$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' => $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) {
|
||||
// Sanitize String
|
||||
$fieldValue = Helper::sanityzeString($fieldValues[$key] ?? '');
|
||||
// Check Var Types & Length
|
||||
$lengthTest = Helper::checkLength($fieldValue, $value[1], $value[2]);
|
||||
|
||||
if (! $lengthTest[413] || ! $lengthTest[411] || ! $lengthTest[417]) {
|
||||
if (! $lengthTest[413]) {
|
||||
$message[] = ['code' => '413', 'status' => 'error', 'message' => self::FIELD_PREFIX . $key . ' is larger then expected'];
|
||||
}
|
||||
if (! $lengthTest[411]) {
|
||||
$message[] = ['code' => '411', 'status' => 'error', 'message' => self::FIELD_PREFIX . $key . ' is empty'];
|
||||
}
|
||||
if (! $lengthTest[417]) {
|
||||
$message[] = ['code' => '417', 'status' => 'error', 'message' => self::FIELD_PREFIX . $key . 'type is different then Expected type: ' . $value[2]];
|
||||
}
|
||||
|
||||
// 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];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json($message);
|
||||
} elseif ($fieldValue != '') {
|
||||
$insertArray[$value[0]] = $fieldValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Check ICM709M
|
||||
$iCM709MSEL = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')
|
||||
->select()
|
||||
->where('AT9CO', $aXCO)
|
||||
->where('AT9PLT', $aXPLANT)
|
||||
->where('AT9WHS', $aXWHS)
|
||||
->where('AT9PART', $partNumber)
|
||||
->first();
|
||||
$palletQty = isset($iCM709MSEL->AT9QTY) ? $iCM709MSEL->AT9QTY : 0;
|
||||
// dd($palletQty);
|
||||
// Get Pallet Qty
|
||||
$insertArray['A1USRN01'] = $palletQty;
|
||||
|
||||
// Hazard Material
|
||||
$hazMat = isset($iCM709MSEL->AT9WRN) ? $iCM709MSEL->AT9WRN : '';
|
||||
$insertArray['A1MATWRN'] = $hazMat;
|
||||
|
||||
// }
|
||||
|
||||
// SQL Insert to ICM666M
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm666m')->insert($insertArray);
|
||||
}
|
||||
|
||||
// Call PGM ICM700CSBM
|
||||
if ($warehouse != '' && $pickerNumber != '' && $company != '') {
|
||||
$pGMERRORS = '';
|
||||
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(PostgresProgramBridge::class);
|
||||
} 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 = 'Could not connect due to wrong user or password.';
|
||||
break;
|
||||
case 42705:
|
||||
$pGMERRORS = 'Database not found. Try WRKRDBDIRE to check.';
|
||||
break;
|
||||
default:
|
||||
$pGMERRORS = 'Could not connect. Error: ' . $code . ' ' . $msg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$conn->setOptions(['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 = [];
|
||||
|
||||
// AddParameterChar($io, $size, $comment, $varName, $value, $varying, $dimension)
|
||||
// Add Warehouse Param
|
||||
$params[] = $conn->AddParameterChar('in', 3, 'Company', '', $company);
|
||||
|
||||
$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);
|
||||
|
||||
// Start Time Tracking
|
||||
|
||||
// ICM700C EWOBJTST ICM700C ICM700CSBM
|
||||
$result = $conn->PgmCall('ICM700CSBM', env('OBJLIB'), $params, [], []);
|
||||
|
||||
if (! $result) {
|
||||
$pGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' - Msg: ' . $conn->getErrorMsg();
|
||||
}
|
||||
|
||||
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];
|
||||
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];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'success',
|
||||
'message' => 'File Received, DB Updated',
|
||||
]);
|
||||
} 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',
|
||||
'message' => 'No Json File Found',
|
||||
]);
|
||||
}
|
||||
} 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];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'An Error Occured...',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
// This resource endpoint is intentionally unsupported.
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
// This resource endpoint is intentionally unsupported.
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// This resource endpoint is intentionally unsupported.
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
// This resource endpoint is intentionally unsupported.
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Cache;
|
||||
use Config;
|
||||
use File;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\M3\Helpers\Helper;
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Str;
|
||||
|
||||
class PdfStorage extends Controller
|
||||
{
|
||||
private const ZERO_PAD = '000000';
|
||||
|
||||
public function PdfStorageAPI(Request $request): JsonResponse
|
||||
{
|
||||
$this->configureTimeouts();
|
||||
|
||||
$context = $this->requestContext($request);
|
||||
if ($context === null) {
|
||||
return $this->errorResponse('No URL Parameters Sent', self::ZERO_PAD, '', '', '');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->logRequest($context);
|
||||
|
||||
$cacheKey = $this->buildCacheKey($context);
|
||||
$pdfFileName = (string) Config::get('arrays.PdfPath') . $context['FILENAME'] . '.pdf';
|
||||
$error = $this->validateStorageRequest($pdfFileName, $cacheKey);
|
||||
|
||||
if ($error !== null) {
|
||||
return $this->errorResponse($error, $context['DELIVERYNO'], $context['DOCNUM'], $context['COMPANY'], $context['WHS']);
|
||||
}
|
||||
|
||||
Cache::forever($cacheKey, base64_encode(File::get($pdfFileName)));
|
||||
$this->logResult($context, 'PDF File converted to Base64 and Saved to Cache.Key: ' . $cacheKey);
|
||||
|
||||
return response()->json(['code' => '200', 'status' => 'Success', 'cacheKey' => $cacheKey]);
|
||||
} catch (\Throwable $exception) {
|
||||
$message = 'An Error Occured - ' . substr($exception->getMessage(), 0, 300);
|
||||
$this->safeLog($context, $message, true);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Catched Error: ' . $exception->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function configureTimeouts(): void
|
||||
{
|
||||
$timeout = (string) Config::get('arrays.PHPTimeOut');
|
||||
ini_set('max_execution_time', $timeout);
|
||||
ini_set('max_input_time', $timeout);
|
||||
ini_set('default_socket_timeout', $timeout);
|
||||
}
|
||||
|
||||
private function requestContext(Request $request): ?array
|
||||
{
|
||||
if ($request->all() === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$context = [];
|
||||
foreach (['COMPANY', 'WHS', 'DOCTYPE', 'FILENAME', 'DOCNUM', 'A4MACPKR'] as $key) {
|
||||
$context[$key] = trim((string) $request->input($key, ''));
|
||||
}
|
||||
|
||||
$context['DELIVERYNO'] = $context['A4MACPKR'] !== '' ? $context['A4MACPKR'] : self::ZERO_PAD;
|
||||
$context['SHUSER'] = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
$context['SHSOURCE'] = 'PdfStorageAPI';
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
private function buildCacheKey(array $context): string
|
||||
{
|
||||
foreach (['A4MACPKR', 'DOCTYPE', 'DOCNUM', 'COMPANY', 'WHS'] as $required) {
|
||||
if ($context[$required] === '') {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return $context['A4MACPKR'] . $context['DOCTYPE'] . $context['DOCNUM'] . $context['COMPANY'] . $context['WHS'];
|
||||
}
|
||||
|
||||
private function validateStorageRequest(string $pdfFileName, string $cacheKey): ?string
|
||||
{
|
||||
$messages = [];
|
||||
if (! File::exists($pdfFileName)) {
|
||||
$messages[] = 'PDF File Not Found-';
|
||||
}
|
||||
if ($cacheKey === '') {
|
||||
$messages[] = 'Cache Key is missing Params';
|
||||
}
|
||||
|
||||
return $messages === [] ? null : implode('', $messages);
|
||||
}
|
||||
|
||||
private function logRequest(array $context): void
|
||||
{
|
||||
$params = array_intersect_key($context, array_flip(['COMPANY', 'WHS', 'DOCTYPE', 'FILENAME', 'A4MACPKR', 'DOCNUM']));
|
||||
$this->safeLog($context, json_encode($params, JSON_THROW_ON_ERROR), false, 'M3-Req-out');
|
||||
}
|
||||
|
||||
private function logResult(array $context, string $message): void
|
||||
{
|
||||
$this->safeLog($context, $message);
|
||||
}
|
||||
|
||||
private function safeLog(array $context, string $message, bool $error = false, string $type = 'M3-Res-out'): void
|
||||
{
|
||||
try {
|
||||
Helper::logToICM699M([
|
||||
'SHMACPKR' => $context['DELIVERYNO'] ?? self::ZERO_PAD,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => $error ? 'X' : '',
|
||||
'SHINTBOX' => $context['DOCNUM'] ?? '',
|
||||
'SHTYPE' => $type,
|
||||
'SHDATA' => $message,
|
||||
'SHUSER' => $context['SHUSER'] ?? (m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser'),
|
||||
'SHSOURCE' => $context['SHSOURCE'] ?? 'PdfStorageAPI',
|
||||
'SHCO' => $context['COMPANY'] ?? '',
|
||||
'SHWHS' => $context['WHS'] ?? '',
|
||||
]);
|
||||
} catch (\Throwable) {
|
||||
// Logging must never turn an API response into a 500 error.
|
||||
}
|
||||
}
|
||||
|
||||
private function errorResponse(string $message, string $deliveryNo, string $docNum, string $company, string $warehouse): JsonResponse
|
||||
{
|
||||
$context = [
|
||||
'DELIVERYNO' => $deliveryNo,
|
||||
'DOCNUM' => $docNum,
|
||||
'COMPANY' => $company,
|
||||
'WHS' => $warehouse,
|
||||
'SHUSER' => m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser',
|
||||
'SHSOURCE' => 'PdfStorageAPI',
|
||||
];
|
||||
$this->safeLog($context, 'An Error Occured -' . $message, true);
|
||||
|
||||
return response()->json(['code' => '405', 'status' => 'Error', 'message' => $message]);
|
||||
}
|
||||
}
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Http;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Log;
|
||||
use Modules\M3\Helpers\Helper;
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Str;
|
||||
|
||||
class ReplenAPI extends Controller
|
||||
{
|
||||
private const ZERO_PAD = '000000';
|
||||
|
||||
private const JSON_CONTENT_TYPE = 'application/json';
|
||||
|
||||
// M3Replenishement with URL Params
|
||||
public function M3InventoryReportReplen(Request $request)
|
||||
{
|
||||
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->all());
|
||||
// Log::info( $request->all() );
|
||||
// Get The Calling User
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
$mACPKR = isset($mACPKR) ? $mACPKR : self::ZERO_PAD;
|
||||
$sHSOURCE = 'M3InventoryReportReplen';
|
||||
$m3Errors = '';
|
||||
|
||||
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'] : '';
|
||||
$pKLN = isset($urlParams['PKLN']) ? $urlParams['PKLN'] : '';
|
||||
$rEQPKWS = isset($urlParams['REQPKWS']) ? $urlParams['REQPKWS'] : '';
|
||||
$rEQKPKUS = isset($urlParams['REQKPKUS']) ? $urlParams['REQKPKUS'] : 'WebUser';
|
||||
|
||||
if ($urlParams != '') {
|
||||
$incomingParams = ['CO' => $cO, 'WHS' => $wHS, 'PARTNO' => $pARTNO, 'PKLN' => $pKLN, 'REQPKWS' => $rEQPKWS, 'REQKPKUS' => $rEQKPKUS];
|
||||
$incomingParams = json_encode($incomingParams);
|
||||
|
||||
// Write to Logs : Params In
|
||||
$data = ['SHMACPKR' => $mACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => '', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Req-out',
|
||||
'SHDATA' => $incomingParams, 'SHUSER' => $sHUSER, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $cO, 'SHWHS' => $wHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
$pART = explode(',', $pARTNO);
|
||||
foreach ($pART as $value) {
|
||||
$pARTS[] = ['PART' => $value, 'LOT' => ''];
|
||||
}
|
||||
|
||||
$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];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// 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' => $mACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $sHDATA, 'SHUSER' => $sHUSER, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $cO, 'SHWHS' => $wHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return $tokenResponse;
|
||||
}
|
||||
|
||||
// Call ionapi with Params
|
||||
$endPointURL = env('ENDPOINTURL') . 'APIFLOWS/Sentinel/M3InventoryReportList?ionapiRespStyle=sync';
|
||||
$token = $ionToken;
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'accept' => self::JSON_CONTENT_TYPE,
|
||||
'Content-Type' => self::JSON_CONTENT_TYPE,
|
||||
])
|
||||
->withToken($token)
|
||||
->withBody($jSON, self::JSON_CONTENT_TYPE)
|
||||
->timeout(Config::get('arrays.curlTimeOut'))
|
||||
->retry(3, 100)
|
||||
->post($endPointURL);
|
||||
|
||||
$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);
|
||||
// Array
|
||||
$responseArray = json_decode($jsonSanytized, true);
|
||||
$responseTMP = $responseArray['result'];
|
||||
} else {
|
||||
$m3Errors = 'Error: No 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',
|
||||
'status' => 'error',
|
||||
'message' => 'Error: No Response from M3',
|
||||
]);
|
||||
} else {
|
||||
// Write to Logs : JSON
|
||||
$data = ['SHMACPKR' => $mACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => '', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $responseStatusCode . '-' . $jsonSanytized . $m3SessionId, 'SHUSER' => $sHUSER, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $cO, 'SHWHS' => $wHS];
|
||||
Helper::logToICM699M($data);
|
||||
}
|
||||
|
||||
$dataToWrite2 = [];
|
||||
foreach ($responseTMP as $value) {
|
||||
$dataToWrite = [];
|
||||
|
||||
foreach ($value as $key2 => $content) {
|
||||
if ($key2 != 'Locations') {
|
||||
$dataToWrite[$key2] = $content;
|
||||
} else {
|
||||
foreach ($content as $content2) {
|
||||
$dataToWrite2[] = array_merge($dataToWrite, $content2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete Old Records from IC630M
|
||||
foreach ($dataToWrite2 as $value) {
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('ic630m')
|
||||
->where('LLCO', $cO)
|
||||
->where('LLWHNO', $wHS)
|
||||
->where('LLPPN', trim($value['PartNumber']))
|
||||
->delete();
|
||||
}
|
||||
|
||||
foreach ($dataToWrite2 as $value) {
|
||||
// Check if Location exist in DE640M $value['Location']
|
||||
$dE640MSQLSEL = DB::connection(config('m3.connection', 'pgsql'))->table('de640m')
|
||||
->where('LVCO', $cO)
|
||||
->where('WSELOC', $value['Warehouse'])
|
||||
->where('VLOCID', $value['Location'])
|
||||
->first();
|
||||
|
||||
$locationExist = isset($dE640MSQLSEL->VLOCID) ? trim($dE640MSQLSEL->VLOCID) : '';
|
||||
$wHExist = isset($dE640MSQLSEL->WSELOC) ? trim($dE640MSQLSEL->WSELOC) : '';
|
||||
$cOExist = isset($dE640MSQLSEL->LVCO) ? trim($dE640MSQLSEL->LVCO) : '';
|
||||
|
||||
// if No records Founds insert New Record
|
||||
if ($locationExist == '' && $wHExist == '' && $cOExist == '') {
|
||||
$sQLInsertPrep640M['LVCO'] = $cO; // Company
|
||||
$sQLInsertPrep640M['WSELOC'] = $value['Warehouse'];
|
||||
// $sQLInsertPrep640M['LVUSD3'] = $value['']; // Pallet Size : Not Found in M3 JSON
|
||||
$sQLInsertPrep640M['VLOCID'] = $value['Location']; // Stock location
|
||||
$sQLInsertPrep640M['LVSEQN'] = $value['LocationSeq'];
|
||||
$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();
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('de640m')
|
||||
->where('LVCO', $cO)
|
||||
->where('WSELOC', $value['Warehouse'])
|
||||
->where('VLOCID', $value['Location'])
|
||||
->update($sQLUpdatePrep640M);
|
||||
}
|
||||
|
||||
// Insert New Records to IC630M
|
||||
$sQLInsertPrep630M = [];
|
||||
$sQLInsertPrep630M['LLCO'] = $cO; // Company
|
||||
$sQLInsertPrep630M['LLWHNO'] = $value['Warehouse']; // Warehouse
|
||||
$sQLInsertPrep630M['LLPPN'] = $value['PartNumber']; // Part Number
|
||||
$sQLInsertPrep630M['LLBALANCE'] = $value['Quantity']; // Quantity
|
||||
$sQLInsertPrep630M['LLSTLC'] = $value['Location']; // Stock location
|
||||
$sQLInsertPrep630M['LLLTNO'] = $value['LotNumber']; // Lot Number
|
||||
$sQLInsertPrep630M['LLMAINTTS'] = now(); // Request time timestamp
|
||||
$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);
|
||||
}
|
||||
|
||||
// Send Response
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success',
|
||||
]);
|
||||
} else {
|
||||
// Write to Logs Out : Error
|
||||
$mACPKR = isset($mACPKR) ? $mACPKR : self::ZERO_PAD;
|
||||
$data = ['SHMACPKR' => $mACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => 'No URL Parameters Sent', 'SHUSER' => $sHUSER, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $cO, 'SHWHS' => $wHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message' => 'No URL Parameters Sent',
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
// Write to Logs Out : Error
|
||||
$mACPKR = isset($mACPKR) ? $mACPKR : self::ZERO_PAD;
|
||||
|
||||
$getCurlErrors = str_contains($th->getMessage(), 'cURL error');
|
||||
if ($getCurlErrors) {
|
||||
// dd($getCurlErrors);
|
||||
// Write to Logs Out : Failed
|
||||
$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',
|
||||
'message' => 'Curl Error: Communication with M3 Timed Out.',
|
||||
]);
|
||||
} else {
|
||||
// Set SHERROR To Z if Duplicate Key Detected $th
|
||||
// Read The substring from SHDATA after M3-JSN-out
|
||||
$sHERROR = 'X';
|
||||
$word = 'Duplicate key value specified';
|
||||
$position = strpos($th, $word);
|
||||
|
||||
if ($position !== false) {
|
||||
$sHERROR = 'Z';
|
||||
}
|
||||
|
||||
$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' => $sHUSER, 'SHSOURCE' => $sHSOURCE, 'SHCO' => $cO, 'SHWHS' => $wHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Catched Error: ' . $th,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// End M3InventoryReportReplen
|
||||
}
|
||||
+698
@@ -0,0 +1,698 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Config;
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Http;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Log;
|
||||
use Modules\M3\Helpers\Helper;
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Str;
|
||||
|
||||
class TransferAPI extends Controller
|
||||
{
|
||||
private const ZERO_PAD = '000000';
|
||||
|
||||
private const JSON_CONTENT_TYPE = 'application/json';
|
||||
|
||||
private const ORDER_CATEGORY_LABEL = ' Order Category: ';
|
||||
|
||||
private const NO_URL_PARAMETERS = 'No URL Parameters Sent';
|
||||
|
||||
// TransferAPIURL : with URL PARAMS
|
||||
public function TransferAPIURL(Request $request)
|
||||
{
|
||||
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'));
|
||||
|
||||
// Get the Calling User
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
// Set SHSOURCE
|
||||
$sHSOURCE = 'TransferAPIURL';
|
||||
$m3Errors = '';
|
||||
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$dIVI = isset($urlParams['COMPANY']) ? $urlParams['COMPANY'] : '';
|
||||
$wHS = isset($urlParams['WHS']) ? $urlParams['WHS'] : '';
|
||||
|
||||
try {
|
||||
if ($urlParams != '') {
|
||||
$pART = isset($urlParams['PART']) ? $urlParams['PART'] : '';
|
||||
$lOCATIONFROM = isset($urlParams['LOCATIONFROM']) ? $urlParams['LOCATIONFROM'] : '';
|
||||
$lOCATIONTO = isset($urlParams['LOCATIONTO']) ? $urlParams['LOCATIONTO'] : '';
|
||||
$qUANTITY = isset($urlParams['QUANTITY']) ? $urlParams['QUANTITY'] : '';
|
||||
$oRDERCATEGORY = isset($urlParams['ORDERCATEGORY']) ? $urlParams['ORDERCATEGORY'] : '';
|
||||
$lOTNUMBER = isset($urlParams['LOTNUMBER']) ? $urlParams['LOTNUMBER'] : '';
|
||||
$cONUMBER = isset($urlParams['CONUMBER']) ? $urlParams['CONUMBER'] : '';
|
||||
$cOLINENO = isset($urlParams['COLINENO']) ? $urlParams['COLINENO'] : '';
|
||||
$dELIVERYNO = isset($urlParams['DELIVERYNO']) ? $urlParams['DELIVERYNO'] : self::ZERO_PAD;
|
||||
$pICKLISTSUFFIX = isset($urlParams['PICKLISTSUFFIX']) ? $urlParams['PICKLISTSUFFIX'] : '';
|
||||
$eNDFLAG = isset($urlParams['ENDFLAG']) ? $urlParams['ENDFLAG'] : '';
|
||||
$tYPE = isset($urlParams['TYPE']) ? $urlParams['TYPE'] : '';
|
||||
$cOLINESUFFIX = isset($urlParams['COLINESUFFIX']) ? $urlParams['COLINESUFFIX'] : '';
|
||||
|
||||
// TYPE :
|
||||
// DeliveryNote
|
||||
// S15
|
||||
// CloseShipment
|
||||
// COCharge
|
||||
// Replenishment
|
||||
// Move
|
||||
|
||||
// ORDERCATEGORY : Order Category
|
||||
// 1 = Material to manufacturing order
|
||||
// 3 = Customer Order
|
||||
// 4 = Requisition Order
|
||||
// 5 = Distribution Order
|
||||
// 9 = Move order
|
||||
|
||||
$dELIVERYNO = isset($dELIVERYNO) ? $dELIVERYNO : self::ZERO_PAD;
|
||||
|
||||
$tRANSTYPE = isset($urlParams['TRANSTYPE']) ? $urlParams['TRANSTYPE'] : ''; // R for Retry
|
||||
$sHDT = isset($urlParams['SHDT']) ? $urlParams['SHDT'] : '';
|
||||
$sHTIME = isset($urlParams['SHTIME']) ? $urlParams['SHTIME'] : '';
|
||||
$sHTYPE = isset($urlParams['SHTYPE']) ? $urlParams['SHTYPE'] : '';
|
||||
|
||||
// Retry Transfer
|
||||
if ($tRANSTYPE == 'R') {
|
||||
// $t = strtotime($sHTIME);
|
||||
// $SHTIMEHM = date('H:i',$t);
|
||||
// dd($SHTIMEHM);
|
||||
// Get the record that contain the payload
|
||||
$iCM699MS = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
|
||||
->select('SHDATA')
|
||||
->where('SHMACPKR', $dELIVERYNO)
|
||||
->where('SHDT', $sHDT)
|
||||
->where('SHTIME', $sHTIME)
|
||||
// ->whereRaw("VARCHAR_FORMAT (TIMESTAMP (CURRENT DATE) + MIDNIGHT_SECONDS (SHTIME) SECONDS, 'HH24:MI') = ?", [$SHTIMEHM])
|
||||
->where('SHCO', $dIVI)
|
||||
->where('SHWHS', $wHS)
|
||||
->where('SHSOURCE', $sHSOURCE)
|
||||
->where('SHERROR', 'X')
|
||||
->where('SHTYPE', $sHTYPE)
|
||||
->first();
|
||||
|
||||
// Read The substring from SHDATA after M3-JSN-out
|
||||
$word = 'M3-JSN-out';
|
||||
$sHDATA = isset($iCM699MS->SHDATA) ? $iCM699MS->SHDATA : '';
|
||||
$sHDATAJSON = '';
|
||||
$position = strpos($sHDATA, $word);
|
||||
// Also Read CommTCP_read
|
||||
$word2 = 'url:http://127.0.0.1:10005/api/TransferAPIURL?';
|
||||
$sHDATA2 = isset($iCM699MS->SHDATA) ? $iCM699MS->SHDATA : '';
|
||||
$position2 = strpos($sHDATA2, $word2);
|
||||
|
||||
if ($position !== false) {
|
||||
$sHDATAJSON = substr($sHDATA, $position + strlen($word));
|
||||
} elseif ($position2 !== false) {
|
||||
$sHDATAJSONS = substr($sHDATA2, $position2 + strlen($word2));
|
||||
$sHDATAJSONA = [];
|
||||
parse_str($sHDATAJSONS, $sHDATAJSONA);
|
||||
$sHDATAJSON = json_encode($sHDATAJSONA);
|
||||
}
|
||||
// Find the position of the opening and closing curly braces
|
||||
$startPos = strpos($sHDATAJSON, '{');
|
||||
$endPos = strrpos($sHDATAJSON, '}');
|
||||
// Extract the substring within the curly braces
|
||||
$sHDATAJSON = substr($sHDATAJSON, $startPos, $endPos - $startPos + 1);
|
||||
|
||||
$jSONTR = $sHDATAJSON != '' ? json_decode($sHDATAJSON) : '';
|
||||
|
||||
if ($jSONTR != '') {
|
||||
$pART = isset($jSONTR->PART) ? $jSONTR->PART : '';
|
||||
$lOCATIONFROM = isset($jSONTR->LOCATIONFROM) ? $jSONTR->LOCATIONFROM : '';
|
||||
$lOCATIONTO = isset($jSONTR->LOCATIONTO) ? $jSONTR->LOCATIONTO : '';
|
||||
$qUANTITY = isset($jSONTR->QUANTITY) ? $jSONTR->QUANTITY : '';
|
||||
$oRDERCATEGORY = isset($jSONTR->ORDERCATEGORY) ? $jSONTR->ORDERCATEGORY : '';
|
||||
$lOTNUMBER = isset($jSONTR->LOTNUMBER) ? $jSONTR->LOTNUMBER : '';
|
||||
$cONUMBER = isset($jSONTR->CONUMBER) ? $jSONTR->CONUMBER : '';
|
||||
$cOLINENO = isset($jSONTR->COLINENO) ? $jSONTR->COLINENO : '';
|
||||
$dELIVERYNO = isset($jSONTR->DELIVERYNO) ? $jSONTR->DELIVERYNO : self::ZERO_PAD;
|
||||
$pICKLISTSUFFIX = isset($jSONTR->PICKLISTSUFFIX) ? $jSONTR->PICKLISTSUFFIX : '';
|
||||
$eNDFLAG = isset($jSONTR->ENDFLAG) ? $jSONTR->ENDFLAG : '';
|
||||
$tYPE = isset($jSONTR->TYPE) ? $jSONTR->TYPE : '';
|
||||
$cOLINESUFFIX = isset($jSONTR->COLINESUFFIX) ? $jSONTR->COLINESUFFIX : '';
|
||||
}
|
||||
|
||||
// Set SHERROR to Z in ICM699M
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
|
||||
->where('SHMACPKR', $dELIVERYNO)
|
||||
->where('SHDT', $sHDT)
|
||||
->where('SHTIME', $sHTIME)
|
||||
->where('SHCO', $dIVI)
|
||||
->where('SHWHS', $wHS)
|
||||
->where('SHSOURCE', $sHSOURCE)
|
||||
->where('SHERROR', 'X')
|
||||
->where('SHTYPE', $sHTYPE)
|
||||
->update(['SHERROR' => 'Z', 'SHACKUSER' => $sHUSER, 'SHACKDATE' => date('Y-m-d'), 'SHACKTIME' => date('H:i:s')]);
|
||||
}
|
||||
|
||||
// Part Exists : proceed
|
||||
if ($pART != '') {
|
||||
// Read from ICM688M2
|
||||
// Get Parts And Lots from ICM688M2
|
||||
$iCM688M2SLTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m2')
|
||||
->select('A5BRADLN', 'A5PKSFX', 'A5PLANT', 'A5SENTPKR')
|
||||
->distinct()
|
||||
->where('A5CO', $dIVI)
|
||||
->where('A5WHS', $wHS)
|
||||
->where('A5MACPKR', $dELIVERYNO);
|
||||
|
||||
// Get Pack Lines
|
||||
if ($cOLINENO != '') {
|
||||
$iCM688M2SLTMP->where('A5PKLN', $cOLINENO);
|
||||
}
|
||||
$iCM688M2SL = $iCM688M2SLTMP->first();
|
||||
|
||||
$a5BRADLINE = isset($iCM688M2SL->A5BRADLN) ? $iCM688M2SL->A5BRADLN : '';
|
||||
$cOLINESUFFIX = isset($iCM688M2SL->A5PKSFX) ? $iCM688M2SL->A5PKSFX : ''; // Case 551 : $cOLINESUFFIX
|
||||
$a5PLANT = isset($iCM688M2SL->A5PLANT) ? $iCM688M2SL->A5PLANT : '';
|
||||
$a5SENTPKR = isset($iCM688M2SL->A5SENTPKR) ? $iCM688M2SL->A5SENTPKR : '';
|
||||
|
||||
$jSONIN = json_encode([
|
||||
'DIVI' => $dIVI,
|
||||
'WHS' => $wHS,
|
||||
'PART' => $pART,
|
||||
'LOCATIONFROM' => $lOCATIONFROM,
|
||||
'LOCATIONTO' => $lOCATIONTO,
|
||||
'QUANTITY' => $qUANTITY,
|
||||
'ORDERCATEGORY' => $oRDERCATEGORY,
|
||||
'LOTNUMBER' => $lOTNUMBER,
|
||||
'CONUMBER' => $cONUMBER,
|
||||
'COLINENO' => $cOLINENO,
|
||||
'DELIVERYNO' => $dELIVERYNO,
|
||||
'PICKLISTSUFFIX' => $pICKLISTSUFFIX,
|
||||
'ENDFLAG' => $eNDFLAG,
|
||||
'TYPE' => $tYPE,
|
||||
'COLINESUFFIX' => $cOLINESUFFIX,
|
||||
], JSON_UNESCAPED_SLASHES);
|
||||
|
||||
$jSON = json_encode([
|
||||
'DIVI' => $dIVI,
|
||||
'WHS' => $wHS,
|
||||
'PART' => $pART,
|
||||
'LOCATIONFROM' => $lOCATIONFROM,
|
||||
'LOCATIONTO' => $lOCATIONTO,
|
||||
'QUANTITY' => $qUANTITY,
|
||||
'ORDERCATEGORY' => $oRDERCATEGORY,
|
||||
'LOTNUMBER' => $lOTNUMBER,
|
||||
'CONUMBER' => $cONUMBER,
|
||||
'COLINENO' => $a5BRADLINE,
|
||||
'DELIVERYNO' => $dELIVERYNO,
|
||||
'PICKLISTSUFFIX' => $pICKLISTSUFFIX,
|
||||
'ENDFLAG' => $eNDFLAG,
|
||||
'TYPE' => $tYPE,
|
||||
'COLINESUFFIX' => $cOLINESUFFIX,
|
||||
], JSON_UNESCAPED_SLASHES);
|
||||
|
||||
// Write JSON Params to Logs Out
|
||||
$data = ['SHMACPKR' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => '',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Req-out',
|
||||
'SHDATA' => $jSON,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// 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' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => '',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $sHDATA,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return $tokenResponse;
|
||||
}
|
||||
|
||||
// Call ionapi with Params
|
||||
$endPointURL = env('ENDPOINTURL') . 'APIFLOWS/Sentinel/TransferAPI?ionapiRespStyle=sync';
|
||||
$token = $ionToken;
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'accept' => self::JSON_CONTENT_TYPE,
|
||||
'Content-Type' => self::JSON_CONTENT_TYPE,
|
||||
])
|
||||
->withToken($token)
|
||||
->withBody($jSON, self::JSON_CONTENT_TYPE)
|
||||
->timeout(Config::get('arrays.curlTimeOut'))
|
||||
->post($endPointURL);
|
||||
$responseStatusCode = $response->getStatusCode();
|
||||
$m3SessionId = $response->hasHeader('x-transaction-id') ? '-sessionID:' . $response->header('x-transaction-id') : '-sessionID';
|
||||
$m3ResponseTimeTmp = $response->hasHeader('x-response-time') ? ltrim($response->header('x-response-time'), '-') : '0';
|
||||
$m3ResponseTimeTmp2 = floatval($m3ResponseTimeTmp) / 1000;
|
||||
$dateTime = new DateTime;
|
||||
$dateTime->setTimestamp($m3ResponseTimeTmp2);
|
||||
$m3ResponseTime = $m3ResponseTimeTmp != '' ? '-M3ResponseTime:' . $dateTime->format('d/m/Y H:i:s.v') : '-M3ResponseTime';
|
||||
$transferStats = $response->transferStats;
|
||||
$m3transferTime = $transferStats->getTransferTime() != null ? '-M3transferTime:' . $transferStats->getTransferTime() : '-M3transferTime';
|
||||
|
||||
if ($responseStatusCode == '200') {
|
||||
$responseContents = json_decode($response->getBody()->getContents());
|
||||
$responseResult = $responseContents->result;
|
||||
$m3JSONResponse = json_encode($responseContents);
|
||||
// Check M3 Response for Errors
|
||||
$m3Errors = Helper::checkM3Errors($responseResult);
|
||||
} else {
|
||||
$m3JSONResponse = '';
|
||||
$m3Errors = 'Error: No Response from M3';
|
||||
}
|
||||
|
||||
if ($m3Errors == '') {
|
||||
// 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 . 'TYPE :' . $tYPE . self::ORDER_CATEGORY_LABEL . $oRDERCATEGORY . '-' . $m3JSONResponse . $m3SessionId . $m3ResponseTime . $m3transferTime,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// Log to ICM799M
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm799m')
|
||||
->insert(['IMDIV' => $dIVI,
|
||||
'IMPLANT' => $a5PLANT,
|
||||
'IMWHS' => $wHS,
|
||||
'IMSENTPKR' => $a5SENTPKR,
|
||||
'IMDELNO' => $dELIVERYNO,
|
||||
'IMORDER' => $cONUMBER,
|
||||
'IMLINE' => $cOLINENO,
|
||||
'IMBRADLN' => $a5BRADLINE,
|
||||
'IMSUFFIX' => $pICKLISTSUFFIX,
|
||||
'IMPART' => $pART,
|
||||
'IMLOT' => $lOTNUMBER,
|
||||
'IMQTY' => $qUANTITY,
|
||||
'IMFRLOC' => $lOCATIONFROM,
|
||||
'IMTOLOC' => $lOCATIONTO,
|
||||
'IMDATE' => date('Ymd'),
|
||||
'IMTIME' => date('His'),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'code' => $responseStatusCode,
|
||||
'status' => 'Success',
|
||||
]);
|
||||
} else {
|
||||
// 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' => $responseStatusCode . '-' . $m3Errors . '-TYPE:' . $tYPE . self::ORDER_CATEGORY_LABEL . $oRDERCATEGORY . '-' . $m3JSONResponse .
|
||||
'M3-JSN-out' . $jSONIN . $m3SessionId . $m3ResponseTime . $m3transferTime,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '206',
|
||||
'status' => 'Error',
|
||||
'message' => $responseStatusCode . '-' . $m3Errors . '- TYPE :' . $tYPE . self::ORDER_CATEGORY_LABEL . $oRDERCATEGORY . '-' . $m3JSONResponse,
|
||||
]);
|
||||
}
|
||||
}
|
||||
// Part Does not Exist : Failure
|
||||
else {
|
||||
// Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message' => 'Json Payload Not Valid, possible cause: Retry butto was clicked by another user.',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// Write to Logs Out : Error
|
||||
$dELIVERYNO = isset($dELIVERYNO) ? $dELIVERYNO : self::ZERO_PAD;
|
||||
$data = ['SHMACPKR' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => self::NO_URL_PARAMETERS,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message' => self::NO_URL_PARAMETERS,
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $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' . $jSONIN,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'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
|
||||
$dELIVERYNO = isset($dELIVERYNO) ? $dELIVERYNO : self::ZERO_PAD;
|
||||
$data = ['SHMACPKR' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Err-out',
|
||||
'SHDATA' => 'An Error Occured - ' . substr($th, 0, 300),
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
Log::error($th);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Uncaught Error',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// End TransferAPIURL
|
||||
|
||||
// UpdateShipmentNumber : with URL PARAMS
|
||||
public function UpdateShipmentNumber(Request $request)
|
||||
{
|
||||
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'));
|
||||
|
||||
// Get the Calling User
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
// Set SHSOURCE
|
||||
$sHSOURCE = 'UpdateShipmentNumber';
|
||||
$m3Errors = '';
|
||||
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$dIVI = isset($urlParams['COMPANY']) ? $urlParams['COMPANY'] : '';
|
||||
$wHS = isset($urlParams['WHS']) ? $urlParams['WHS'] : '';
|
||||
$pLANT = isset($urlParams['PLANT']) ? $urlParams['PLANT'] : '';
|
||||
|
||||
try {
|
||||
if ($urlParams != '') {
|
||||
$a4SPR15A01 = isset($urlParams['A4SPR15A01']) ? $urlParams['A4SPR15A01'] : '';
|
||||
$dELIVERYNO = isset($urlParams['DELIVERYNO']) ? $urlParams['DELIVERYNO'] : '';
|
||||
$tYPE = 'UpdateShipmentNumber';
|
||||
$allMacpkrs = [];
|
||||
|
||||
if ($a4SPR15A01 != '') {
|
||||
// Read from ICM688M1
|
||||
$iCM688M1SLTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
|
||||
->select('A4MACPKR')
|
||||
->where('A4CO', $dIVI)
|
||||
->where('A4WHS', $wHS)
|
||||
->where('A4PLANT', $pLANT)
|
||||
->where('A4SPR15A01', $a4SPR15A01);
|
||||
|
||||
// Get Macpikers also if sent as Parameter
|
||||
if ($dELIVERYNO != '') {
|
||||
$iCM688M1SLTMP->where('A4MACPKR', $dELIVERYNO);
|
||||
}
|
||||
$iCM688M1SL = $iCM688M1SLTMP->get();
|
||||
// Loop ICM688M1 to get all A4MACPKR
|
||||
foreach ($iCM688M1SL as $ICM688M1) {
|
||||
$allMacpkrs[] = $ICM688M1->A4MACPKR;
|
||||
}
|
||||
}
|
||||
|
||||
// A4SPR15A01 Exists : proceed
|
||||
if ($a4SPR15A01 != '' && ! empty($allMacpkrs)) {
|
||||
$jSON = json_encode([
|
||||
'DIVI' => $dIVI,
|
||||
'WHS' => $wHS,
|
||||
'ShipmentNumber' => [
|
||||
'Number' => $a4SPR15A01,
|
||||
'DeliveryNumbers' => $allMacpkrs,
|
||||
],
|
||||
'TYPE' => $tYPE,
|
||||
'ENDFLAG' => '',
|
||||
|
||||
], JSON_UNESCAPED_SLASHES);
|
||||
|
||||
// Write JSON Params to Logs Out
|
||||
$data = ['SHMACPKR' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => '',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Req-out',
|
||||
'SHDATA' => $jSON,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// 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' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => '',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => $sHDATA,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return $tokenResponse;
|
||||
}
|
||||
|
||||
// Call ionapi with Params
|
||||
$endPointURL = env('ENDPOINTURL') . 'APIFLOWS/Sentinel/TransferAPI?ionapiRespStyle=sync';
|
||||
$token = $ionToken;
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'accept' => self::JSON_CONTENT_TYPE,
|
||||
'Content-Type' => self::JSON_CONTENT_TYPE,
|
||||
])
|
||||
->withToken($token)
|
||||
->withBody($jSON, self::JSON_CONTENT_TYPE)
|
||||
->timeout(Config::get('arrays.curlTimeOut'))
|
||||
->post($endPointURL);
|
||||
$responseStatusCode = $response->getStatusCode();
|
||||
$m3SessionId = $response->hasHeader('x-transaction-id') ? '-sessionID:' . $response->header('x-transaction-id') : '-sessionID';
|
||||
$m3ResponseTimeTmp = $response->hasHeader('x-response-time') ? ltrim($response->header('x-response-time'), '-') : '0';
|
||||
$m3ResponseTimeTmp2 = floatval($m3ResponseTimeTmp) / 1000;
|
||||
$dateTime = new DateTime;
|
||||
$dateTime->setTimestamp($m3ResponseTimeTmp2);
|
||||
$m3ResponseTime = $m3ResponseTimeTmp != '' ? '-M3ResponseTime:' . $dateTime->format('d/m/Y H:i:s.v') : '-M3ResponseTime';
|
||||
$transferStats = $response->transferStats;
|
||||
$m3transferTime = $transferStats->getTransferTime() != null ? '-M3transferTime:' . $transferStats->getTransferTime() : '-M3transferTime';
|
||||
|
||||
if ($responseStatusCode == '200') {
|
||||
$responseContents = json_decode($response->getBody()->getContents());
|
||||
$responseResult = $responseContents->result;
|
||||
$m3JSONResponse = json_encode($responseContents);
|
||||
// Check M3 Response for Errors
|
||||
$m3Errors = Helper::checkM3Errors($responseResult);
|
||||
} else {
|
||||
$m3JSONResponse = '';
|
||||
$m3Errors = 'Error: No Response from M3';
|
||||
}
|
||||
|
||||
if ($m3Errors == '') {
|
||||
// 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 . 'TYPE :' . $tYPE . '-' . $m3JSONResponse . $m3SessionId . $m3ResponseTime . $m3transferTime,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => $responseStatusCode,
|
||||
'status' => 'Success',
|
||||
]);
|
||||
} else {
|
||||
// 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' => $responseStatusCode . '-' . $m3Errors . '-TYPE:' . $tYPE . '-' . $m3JSONResponse .
|
||||
'M3-JSN-out' . $jSON . $m3SessionId . $m3ResponseTime . $m3transferTime,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '206',
|
||||
'status' => 'Error',
|
||||
'message' => $responseStatusCode . '-' . $m3Errors . '- TYPE :' . $tYPE . '-' . $m3JSONResponse,
|
||||
]);
|
||||
}
|
||||
}
|
||||
// A4SPR15A01 Does not Exist : Failure
|
||||
else {
|
||||
// Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message' => 'Json Payload Not Valid, missing Parameter or no Macpicker # found.',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// Write to Logs Out : Error
|
||||
$dELIVERYNO = isset($dELIVERYNO) ? $dELIVERYNO : self::ZERO_PAD;
|
||||
$data = ['SHMACPKR' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => self::NO_URL_PARAMETERS,
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message' => self::NO_URL_PARAMETERS,
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $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' => $dIVI,
|
||||
'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
|
||||
$dELIVERYNO = isset($dELIVERYNO) ? $dELIVERYNO : self::ZERO_PAD;
|
||||
$data = ['SHMACPKR' => $dELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Err-out',
|
||||
'SHDATA' => 'An Error Occured - ' . substr($th, 0, 300),
|
||||
'SHUSER' => $sHUSER,
|
||||
'SHSOURCE' => $sHSOURCE,
|
||||
'SHCO' => $dIVI,
|
||||
'SHWHS' => $wHS,
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
Log::error($th);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Uncaught Error',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// End UpdateShipmentNumber
|
||||
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\Client\Response as HttpResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Modules\M3\Helpers\Helper;
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Str;
|
||||
|
||||
class TwoShipAPIs extends Controller
|
||||
{
|
||||
private const SOURCE = 'TwoShipUpdateHold';
|
||||
|
||||
private const RESPONSE_TYPE = 'AggStopRsp';
|
||||
|
||||
public function TwoShipUpdateHold(Request $request)
|
||||
{
|
||||
$this->configureTimeouts();
|
||||
$user = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
$params = $request->all();
|
||||
$whs = (string) ($params['WHS'] ?? '');
|
||||
$co = (string) ($params['COMPANY'] ?? '');
|
||||
$macpkr = (string) ($params['MACPKR'] ?? '');
|
||||
|
||||
if ($params === []) {
|
||||
$this->log($macpkr ?: '000000', $co, $whs, $user, 'X', 'No URL Parameters Sent');
|
||||
|
||||
return response()->json(['code' => '405', 'status' => 'Error', 'message' => 'No URL Parameters Sent']);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->logRequest($macpkr, $co, $whs, $user);
|
||||
$orders = $this->aggregationOrders($macpkr, $co, $whs);
|
||||
$response = $this->callTwoShip($orders);
|
||||
$error = $this->responseError($response);
|
||||
if ($error !== '') {
|
||||
$this->log($macpkr, $co, $whs, $user, 'X', $response->status() . '-' . $error);
|
||||
|
||||
return response()->json(['code' => '405', 'status' => 'error', 'message' => 'Status: ' . $response->status() . '-' . $error]);
|
||||
}
|
||||
|
||||
$this->log($macpkr, $co, $whs, $user, '', $response->body());
|
||||
$this->markAggregationComplete($orders, $co, $whs);
|
||||
|
||||
return response()->json(['code' => '200', 'status' => 'Success']);
|
||||
} catch (\Throwable $th) {
|
||||
$message = str_contains($th->getMessage(), 'cURL error')
|
||||
? 'Curl Error: Communication with 2Ship Timed Out.'
|
||||
: '2Ship communication failed.';
|
||||
$this->log($macpkr, $co, $whs, $user, 'X', $message);
|
||||
|
||||
return response()->json(['code' => '405', 'status' => 'error', 'message' => $message]);
|
||||
}
|
||||
}
|
||||
|
||||
private function configureTimeouts(): void
|
||||
{
|
||||
$timeout = Config::get('arrays.PHPTimeOut');
|
||||
ini_set('max_execution_time', $timeout);
|
||||
ini_set('max_input_time', $timeout);
|
||||
ini_set('default_socket_timeout', $timeout);
|
||||
}
|
||||
|
||||
private function logRequest(string $macpkr, string $co, string $whs, string $user): void
|
||||
{
|
||||
$data = json_encode(['CO' => $co, 'WHS' => $whs, 'MACPKR' => $macpkr]);
|
||||
Helper::logToICM699M($this->logData($macpkr, $co, $whs, $user, '', (string) $data, 'AggStopReq'));
|
||||
}
|
||||
|
||||
private function aggregationOrders(string $macpkr, string $co, string $whs): array
|
||||
{
|
||||
$aggregation = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
|
||||
->where('A4MACPKR', $macpkr)->value('A4SHPAGGCD');
|
||||
if (empty($aggregation) || (string) $aggregation === '0') {
|
||||
return [$macpkr];
|
||||
}
|
||||
$orders = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
|
||||
->where('A4SHPAGGCD', $aggregation)->where('A4SHPAGGCD', '<>', 0)->where('A4CONCMPLT', '<>', 'y')
|
||||
->where('A4CO', $co)->where('A4WHS', $whs)->pluck('A4MACPKR')->all();
|
||||
|
||||
return $orders !== [] ? $orders : [$macpkr];
|
||||
}
|
||||
|
||||
private function callTwoShip(array $orders): HttpResponse
|
||||
{
|
||||
$payload = [
|
||||
'WS_Key' => Config::get('arrays.2Ship.TwoShip_Key'),
|
||||
'OrderNumbers' => [implode(',', $orders)],
|
||||
'FindBy' => 'ByMultipleOrderNumbers',
|
||||
'DataToBeUpdated' => ['UpdateAggregationSettings' => true, 'OrderAggregationSettingsInfo' => ['NotConsideredAggregation' => true]],
|
||||
];
|
||||
|
||||
return Http::acceptJson()->asJson()->timeout((int) Config::get('arrays.PHPTimeOut'))
|
||||
->post(Config::get('arrays.2Ship.end_point') . Config::get('arrays.2Ship.hold_update'), $payload);
|
||||
}
|
||||
|
||||
private function responseError(HttpResponse $response): string
|
||||
{
|
||||
if (! $response->successful()) {
|
||||
return 'Error: No Response from 2Ship';
|
||||
}
|
||||
$body = $response->json();
|
||||
|
||||
return ($body['Success'] ?? true) === false ? '2Ship Error: ' . ($body['GlobalError'] ?? 'Unknown error') : '';
|
||||
}
|
||||
|
||||
private function markAggregationComplete(array $orders, string $co, string $whs): void
|
||||
{
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
|
||||
->whereIn('A4MACPKR', $orders)->where('A4CO', $co)->where('A4WHS', $whs)->update(['A4CONCMPLT' => 'Y']);
|
||||
}
|
||||
|
||||
private function log(string $macpkr, string $co, string $whs, string $user, string $error, string $message): void
|
||||
{
|
||||
Helper::logToICM699M($this->logData($macpkr, $co, $whs, $user, $error, $message, self::RESPONSE_TYPE));
|
||||
}
|
||||
|
||||
private function logData(string $macpkr, string $co, string $whs, string $user, string $error, string $message, string $type): array
|
||||
{
|
||||
return ['SHMACPKR' => $macpkr, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => $error,
|
||||
'SHINTBOX' => '', 'SHTYPE' => $type, 'SHDATA' => $message, 'SHUSER' => $user, 'SHSOURCE' => self::SOURCE, 'SHCO' => $co, 'SHWHS' => $whs];
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public static function logout()
|
||||
{
|
||||
|
||||
return view('m3::liberty-theme.pages.logout');
|
||||
|
||||
}
|
||||
}
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Str;
|
||||
|
||||
class BoxPackToPalletController extends Controller
|
||||
{
|
||||
private const PALLET_TABLE_ALIAS = 'ICM659M as p';
|
||||
|
||||
private const CONVEYOR_SELECT = 'cnv.R652SORTK as CONVEYOR_NAME';
|
||||
|
||||
private const CARTON_TABLE_ALIAS = 'ICM695M1 as c';
|
||||
|
||||
private const CONVEYOR_VALUE_ALIAS = 'ICM688M1 as cv';
|
||||
|
||||
private const CONVEYOR_TABLE_ALIAS = 'ICM652M as cnv';
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
return view('m3::liberty-theme.pages.BoxPackToPallet');
|
||||
}
|
||||
|
||||
// Load Existing Boxes from ICM659M
|
||||
public static function getBoxes(Request $request)
|
||||
{
|
||||
$r659PALT = $request->R659PALT ?? abort(404, 'Manifest Not Found');
|
||||
|
||||
$userWhsCoPlant = self::getUserWhsCoPlant();
|
||||
|
||||
$boxes = DB::connection(config('m3.connection', 'pgsql'))->table(self::PALLET_TABLE_ALIAS)
|
||||
->select(
|
||||
'p.R659PALT',
|
||||
'p.R659BOX',
|
||||
'p.R659LOADED',
|
||||
'p.R659USER',
|
||||
'p.R659DATE',
|
||||
'p.R659TIME',
|
||||
'c.AYMACPKR',
|
||||
'c.AYSPR15A01',
|
||||
'cv.A4APR8N001',
|
||||
'cv.A4SHSHCT',
|
||||
self::CONVEYOR_SELECT,
|
||||
)
|
||||
->leftJoin(self::CARTON_TABLE_ALIAS, 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin(self::CONVEYOR_VALUE_ALIAS, 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin(self::CONVEYOR_TABLE_ALIAS, 'cv.A4APR8N001', '=', 'cnv.R652SEQ')
|
||||
->where('p.R659PALT', $r659PALT)
|
||||
->where('p.R659CO', trim($userWhsCoPlant['USERCO']))
|
||||
->where('p.R659WHS', trim($userWhsCoPlant['USERWHS']))
|
||||
->where('p.R659PLANT', trim($userWhsCoPlant['USERPL']))
|
||||
->orderBy('p.R659DATE', 'desc')
|
||||
->orderBy('p.R659TIME', 'desc')
|
||||
->distinct()
|
||||
->get()
|
||||
->unique('R659BOX')
|
||||
->values();
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $boxes,
|
||||
]);
|
||||
}
|
||||
|
||||
$palletHeader = $boxes->first();
|
||||
|
||||
return view('m3::liberty-theme.pages.BoxPackToPalletScan', ['boxes' => $boxes, 'palletHeader' => $palletHeader, 'R659PALT' => $r659PALT]);
|
||||
}
|
||||
|
||||
// Scan Boxes
|
||||
public static function scanBoxes(Request $request)
|
||||
{
|
||||
$pallet = $request->R659PALT ?? abort(400, 'Pallet Not Found');
|
||||
$box = trim((string) ($request->R659BOX ?? ''));
|
||||
abort_if($box === '', 400, 'Box Not Found');
|
||||
|
||||
$user = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
$profile = self::getUserWhsCoPlant();
|
||||
$validation = self::validateScannedBox($pallet, $box, $profile);
|
||||
|
||||
if ($validation !== '') {
|
||||
return response()->json(['success' => false, 'message' => $validation], 409);
|
||||
}
|
||||
|
||||
self::insertScannedBox($pallet, $box, $user, $profile);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => "• Box {$box} added to Pallet {$pallet}.",
|
||||
'data' => self::boxesForPallet($pallet, $profile),
|
||||
]);
|
||||
}
|
||||
|
||||
private static function validateScannedBox($pallet, string $box, array $profile): string
|
||||
{
|
||||
$messages = [];
|
||||
$existing = self::findExistingBox($pallet, $box, $profile);
|
||||
if ($existing) {
|
||||
$messages[] = "• Box {$box} is already assigned to Pallet {$existing->R659PALT}.";
|
||||
}
|
||||
|
||||
$boxRecord = self::findCarton($box, $profile);
|
||||
if (! isset($boxRecord->AYINTBOX)) {
|
||||
$messages[] = "• Box {$box} does not exist in ICM695M1 or it belongs to another Company.";
|
||||
} elseif (($boxRecord->AYTYPE ?? '') !== 'BX') {
|
||||
$messages[] = "• Scanned barcode {$box} is not a Box.";
|
||||
} elseif (! $existing) {
|
||||
$messages = array_merge($messages, self::palletCompatibilityMessages($pallet, $box, $boxRecord, $profile));
|
||||
}
|
||||
|
||||
return implode('<br>', $messages);
|
||||
}
|
||||
|
||||
private static function findExistingBox($pallet, string $box, array $profile): ?object
|
||||
{
|
||||
return DB::connection(config('m3.connection', 'pgsql'))->table('icm659m')
|
||||
->select('R659PALT')->where('R659PALT', $pallet)->where('R659BOX', $box)
|
||||
->where('R659CO', trim($profile['USERCO']))->where('R659WHS', trim($profile['USERWHS']))
|
||||
->where('R659PLANT', trim($profile['USERPL']))->first();
|
||||
}
|
||||
|
||||
private static function findCarton(string $box, array $profile): ?object
|
||||
{
|
||||
return DB::connection(config('m3.connection', 'pgsql'))->table(self::CARTON_TABLE_ALIAS)
|
||||
->select('c.AYINTBOX', 'c.AYSPR15A01', 'c.AYTYPE', 'c.AYMACPKR', 'cv.A4APR8N001', self::CONVEYOR_SELECT)
|
||||
->leftJoin(self::CONVEYOR_VALUE_ALIAS, 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin(self::CONVEYOR_TABLE_ALIAS, 'cv.A4APR8N001', '=', 'cnv.R652SEQ')
|
||||
->where('c.AYINTBOX', $box)->where('c.AYCO', trim($profile['USERCO']))
|
||||
->where('c.AYWHS', trim($profile['USERWHS']))->where('c.AYPLANT', trim($profile['USERPL']))->first();
|
||||
}
|
||||
|
||||
private static function palletCompatibilityMessages($pallet, string $box, object $incoming, array $profile): array
|
||||
{
|
||||
$first = DB::connection(config('m3.connection', 'pgsql'))->table(self::PALLET_TABLE_ALIAS)
|
||||
->select('c.AYSPR15A01', self::CONVEYOR_SELECT)
|
||||
->leftJoin(self::CARTON_TABLE_ALIAS, 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin(self::CONVEYOR_VALUE_ALIAS, 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin(self::CONVEYOR_TABLE_ALIAS, 'cv.A4APR8N001', '=', 'cnv.R652SEQ')
|
||||
->where('p.R659PALT', $pallet)->where('p.R659CO', trim($profile['USERCO']))
|
||||
->where('p.R659WHS', trim($profile['USERWHS']))->where('p.R659PLANT', trim($profile['USERPL']))->first();
|
||||
|
||||
if (! $first) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$messages = [];
|
||||
$incomingCarrier = trim($incoming->AYSPR15A01 ?? '');
|
||||
$incomingConveyor = trim($incoming->CONVEYOR_NAME ?? '');
|
||||
$palletCarrier = trim($first->AYSPR15A01 ?? '');
|
||||
$palletConveyor = trim($first->CONVEYOR_NAME ?? '');
|
||||
if ($incomingCarrier !== $palletCarrier) {
|
||||
$messages[] = "• Box {$box} has a different Carrier ({$incomingCarrier}) than the boxes already on Pallet {$pallet} ({$palletCarrier}).";
|
||||
}
|
||||
if ($incomingConveyor !== $palletConveyor) {
|
||||
$messages[] = "• Box {$box} has a different Conveyor ({$incomingConveyor}) than the boxes already on Pallet {$pallet} ({$palletConveyor}).";
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
private static function insertScannedBox($pallet, string $box, string $user, array $profile): void
|
||||
{
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm659m')->insert([
|
||||
'R659PALT' => $pallet, 'R659BOX' => $box, 'R659LOADED' => '', 'R659USER' => $user,
|
||||
'R659DATE' => date('Y-m-d'), 'R659TIME' => date('H:i:s'), 'R659CO' => trim($profile['USERCO']),
|
||||
'R659WHS' => trim($profile['USERWHS']), 'R659PLANT' => trim($profile['USERPL']),
|
||||
]);
|
||||
}
|
||||
|
||||
private static function boxesForPallet($pallet, array $profile)
|
||||
{
|
||||
return DB::connection(config('m3.connection', 'pgsql'))->table(self::PALLET_TABLE_ALIAS)
|
||||
->select(
|
||||
'p.R659PALT',
|
||||
'p.R659BOX',
|
||||
'p.R659LOADED',
|
||||
'p.R659USER',
|
||||
'p.R659DATE',
|
||||
'p.R659TIME',
|
||||
'c.AYMACPKR',
|
||||
'c.AYSPR15A01',
|
||||
'cv.A4APR8N001',
|
||||
'cv.A4SHSHCT',
|
||||
self::CONVEYOR_SELECT,
|
||||
)
|
||||
->leftJoin(self::CARTON_TABLE_ALIAS, 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin(self::CONVEYOR_VALUE_ALIAS, 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin(self::CONVEYOR_TABLE_ALIAS, 'cv.A4APR8N001', '=', 'cnv.R652SEQ')
|
||||
->where('p.R659PALT', $pallet)->where('p.R659CO', trim($profile['USERCO']))
|
||||
->where('p.R659WHS', trim($profile['USERWHS']))->where('p.R659PLANT', trim($profile['USERPL']))
|
||||
->orderBy('p.R659DATE', 'desc')->orderBy('p.R659TIME', 'desc')->distinct()->get()->unique('R659BOX')->values();
|
||||
}
|
||||
|
||||
// Delete Box
|
||||
public static function deleteBox(Request $request)
|
||||
{
|
||||
$r659PALT = $request->R659PALT ?? abort(400, 'Pallet Not Found');
|
||||
$r659BOX = trim($request->R659BOX) ?? abort(400, 'Box Not Found');
|
||||
|
||||
$userWhsCoPlant = self::getUserWhsCoPlant();
|
||||
|
||||
// Guard: only allow delete if R659LOADED is empty
|
||||
$record = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->table('icm659m')
|
||||
->where('R659PALT', $r659PALT)
|
||||
->where('R659BOX', $r659BOX)
|
||||
->first();
|
||||
|
||||
if (! $record) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => "Box {$r659BOX} not found on Pallet {$r659PALT}.",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (! empty(trim($record->R659LOADED))) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => "Box {$r659BOX} is already loaded and cannot be removed.",
|
||||
], 403);
|
||||
}
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))
|
||||
->table('icm659m')
|
||||
->where('R659PALT', $r659PALT)
|
||||
->where('R659BOX', $r659BOX)
|
||||
->delete();
|
||||
|
||||
// Return refreshed list
|
||||
$boxes = DB::connection(config('m3.connection', 'pgsql'))->table(self::PALLET_TABLE_ALIAS)
|
||||
->select(
|
||||
'p.R659PALT',
|
||||
'p.R659BOX',
|
||||
'p.R659LOADED',
|
||||
'p.R659USER',
|
||||
'p.R659DATE',
|
||||
'p.R659TIME',
|
||||
'c.AYMACPKR',
|
||||
'c.AYSPR15A01',
|
||||
'cv.A4APR8N001',
|
||||
'cv.A4SHSHCT',
|
||||
self::CONVEYOR_SELECT,
|
||||
)
|
||||
->leftJoin(self::CARTON_TABLE_ALIAS, 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin(self::CONVEYOR_VALUE_ALIAS, 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin(self::CONVEYOR_TABLE_ALIAS, 'cv.A4APR8N001', '=', 'cnv.R652SEQ')
|
||||
->where('p.R659PALT', $r659PALT)
|
||||
->where('p.R659CO', trim($userWhsCoPlant['USERCO']))
|
||||
->where('p.R659WHS', trim($userWhsCoPlant['USERWHS']))
|
||||
->where('p.R659PLANT', trim($userWhsCoPlant['USERPL']))
|
||||
->orderBy('p.R659DATE', 'desc')
|
||||
->orderBy('p.R659TIME', 'desc')
|
||||
->distinct()
|
||||
->get()
|
||||
->unique('R659BOX')
|
||||
->values();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => "Box {$r659BOX} removed from Pallet {$r659PALT}.",
|
||||
'data' => $boxes,
|
||||
]);
|
||||
}
|
||||
|
||||
// Get Logged User CO/WHS/PLANT
|
||||
public static function getUserWhsCoPlant()
|
||||
{
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
// Get users from 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 : '';
|
||||
$uSERCO = isset($iCM428M->R428CO) ? $iCM428M->R428CO : '';
|
||||
$uSERWH = isset($iCM428M->R428WH) ? $iCM428M->R428WH : '';
|
||||
$r428PL = isset($iCM428M->R428PL) ? $iCM428M->R428PL : '';
|
||||
|
||||
return [
|
||||
'R428US' => $r428US,
|
||||
'USERCO' => $uSERCO,
|
||||
'USERWHS' => $uSERWH,
|
||||
'USERPL' => $r428PL,
|
||||
];
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\M3\Helpers\Helper;
|
||||
use Modules\M3\Models\ICM160M;
|
||||
|
||||
class CarrierMaintController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$currentUser = Helper::getUserCOWHSPLT();
|
||||
$userCO = $currentUser['UserCO'] ?? '';
|
||||
$iCM160M = [];
|
||||
$power_user = [];
|
||||
$schema = Schema::connection(config('m3.connection', 'pgsql'));
|
||||
if ($schema->hasTable('icm160m')) {
|
||||
$iCM160M = DB::connection(config('m3.connection', 'pgsql'))->select('
|
||||
select canum, canam, substr(CATPID,1,3) as TwoshipCarrierCode, substr(CATPID,4,1) as ParcelCarrierCode, caspr10A01, caspr1A01
|
||||
from icm160m WHERE CACO=?', [$userCO]);
|
||||
}
|
||||
if ($schema->hasTable('icm428m')) {
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428PWRUSR', 'R428CO', 'R428PL', 'R428WH')
|
||||
->where('R428US', strtoupper(m3_user()))->get()->all();
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.carrierMaint', ['ICM160M' => $iCM160M, 'power_user' => $power_user]);
|
||||
|
||||
}
|
||||
|
||||
// Process data from Add modal
|
||||
public static function savecarrierAdd(Request $request)
|
||||
{
|
||||
$currentUser = Helper::getUserCOWHSPLT();
|
||||
$userCO = $currentUser['UserCO'] ?? '';
|
||||
|
||||
// Insert record to ICM160M
|
||||
// Verify record does not already exist in ICM160M
|
||||
if ($request->CANUM == null) {
|
||||
return 'null';
|
||||
}
|
||||
$icm160m = DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from ICM160M where CANUM='$request->CANUM' AND CACO='$userCO'");
|
||||
if ($icm160m[0]->COUNT1 == '1') {
|
||||
return 'exists';
|
||||
} else {
|
||||
$cASPR10A01 = isset($request->CASPR10A01) && $request->CASPR10A01 != null ? $request->CASPR10A01 : ' ';
|
||||
$cASPR1A01 = isset($request->CASPR1A01) && $request->CASPR1A01 != null ? $request->CASPR1A01 : ' ';
|
||||
|
||||
$data = ['CANUM' => $request->CANUM, 'CANAM' => $request->CANAM,
|
||||
'CATPID' => str_pad(substr($request->TWOSHIPCARRIERCODE, 0, 3), 3, ' ') . substr($request->PARCELCARRIERCODE, 0, 1),
|
||||
'CASPR10A01' => $cASPR10A01, 'CASPR1A01' => $cASPR1A01, 'CACO' => $userCO]; // ,'CAPLNT'=>$UserPL,'CAWHS'=>$UserWHS
|
||||
$insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm160m')->insert($data);
|
||||
if ($insertSQL) {
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function savecarrierAdd2(Request $request)
|
||||
{
|
||||
$currentUser = Helper::getUserCOWHSPLT();
|
||||
$userCO = $currentUser['UserCO'] ?? '';
|
||||
|
||||
// Insert record to ICM160M
|
||||
if ($request->CANUM == null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
$cASPR10A01 = isset($request->CASPR10A01) && $request->CASPR10A01 != null ? $request->CASPR10A01 : ' ';
|
||||
$cASPR1A01 = isset($request->CASPR1A01) && $request->CASPR1A01 != null ? $request->CASPR1A01 : ' ';
|
||||
|
||||
$data = ['CANUM' => $request->CANUM, 'CANAM' => $request->CANAM, 'CATPID' => str_pad(substr($request->TWOSHIPCARRIERCODE, 0, 3), 3, ' ') . substr($request->PARCELCARRIERCODE, 0, 1),
|
||||
'CASPR10A01' => $cASPR10A01, 'CASPR1A01' => $cASPR1A01, 'CACO' => $userCO]; // ,'CAPLNT'=>$UserPL,'CAWHS'=>$UserWHS
|
||||
$insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm160m')->insert($data);
|
||||
if ($insertSQL) {
|
||||
return 'success';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Process data from Edit modal
|
||||
public static function savecarrierEdit(Request $request)
|
||||
{
|
||||
$currentUser = Helper::getUserCOWHSPLT();
|
||||
$userCO = $currentUser['UserCO'] ?? '';
|
||||
|
||||
if ($request->CANUM == null) {
|
||||
return 'null';
|
||||
}
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM160M
|
||||
set CANAM='$request->CANAM', CATPID='" . str_pad(substr($request->TWOSHIPCARRIERCODE, 0, 3), 3, ' ') . substr($request->PARCELCARRIERCODE, 0, 1) . "',
|
||||
CASPR10A01='$request->CASPR10A01', CASPR1A01='$request->CASPR1A01'
|
||||
where CANUM='$request->CANUM' AND CACO='$userCO'");
|
||||
|
||||
return 'success';
|
||||
|
||||
}
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public static function index()
|
||||
{
|
||||
return view('m3::liberty-theme.pages.dashboard');
|
||||
// , compact('data','whs','whs_array','starting','ending')
|
||||
}
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Str;
|
||||
|
||||
class ExecSummaryController extends Controller
|
||||
{
|
||||
private const WAREHOUSE_IN_CLAUSE = "' and a5whs in (";
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$iC670M = collect();
|
||||
$wHDDA = '';
|
||||
$cOMPANY = '110';
|
||||
$pLANT = '144';
|
||||
$wHS = '322';
|
||||
|
||||
try {
|
||||
// Ajax Call
|
||||
if ($request->ajax()) {
|
||||
$wHDDA = isset($request->WHDDA) ? $request->WHDDA : [];
|
||||
$wHArr = [];
|
||||
foreach ($wHDDA as $WHDDAV) {
|
||||
$cO = substr($WHDDAV, 0, 3);
|
||||
$wHArr[] = substr($WHDDAV, 6, 3);
|
||||
}
|
||||
|
||||
$reportPeriod = isset($request->reportPeriod) ? $request->reportPeriod : ''; // monthly , quarter , year , daily
|
||||
// Current
|
||||
$checkSales = isset($request->checkSales) ? $request->checkSales : ''; // on
|
||||
$checkWeight = isset($request->checkWeight) ? $request->checkWeight : ''; // on
|
||||
$checkLines = isset($request->checkLines) ? $request->checkLines : ''; // on
|
||||
|
||||
if (! empty($wHArr) && $cO != '' && $reportPeriod != '') {
|
||||
switch ($reportPeriod) {
|
||||
case 'year':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : '';
|
||||
$reportDate = $firstDay->modify('first day of January')->format('Ymd');
|
||||
|
||||
$lastDay = isset($request->TOREPORTDATE) ? \DateTime::createFromFormat('Y-m', trim($request->TOREPORTDATE)) : '';
|
||||
$toreportDate = $lastDay->modify('last day of December')->format('Ymd');
|
||||
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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) . ')
|
||||
)
|
||||
select substr(ayapr8N002,1,4) 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 from tempfile
|
||||
group by substr(ayapr8N002,1,4),a5whs order by 1 ';
|
||||
break;
|
||||
|
||||
case 'quarter':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : '';
|
||||
$reportDate = $firstDay->modify('first day of January')->format('Ymd');
|
||||
|
||||
$lastDay = isset($request->TOREPORTDATE) ? \DateTime::createFromFormat('Y-m', trim($request->TOREPORTDATE)) : '';
|
||||
$toreportDate = $lastDay->modify('last day of December')->format('Ymd');
|
||||
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by substr(ayapr8N002,3,2) ||'-' || 'Q' || EXTRACT(QUARTER FROM TO_DATE(CAST(ayapr8n002 AS TEXT),'YYYYMMDD')),a5whs order by 1 ";
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : '';
|
||||
$reportDate = $firstDay->modify('first day of this month')->format('Ymd');
|
||||
|
||||
$lastDay = isset($request->TOREPORTDATE) ? \DateTime::createFromFormat('Y-m', trim($request->TOREPORTDATE)) : '';
|
||||
$toreportDate = $lastDay->modify('last day of this month')->format('Ymd');
|
||||
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by substr(ayapr8N002,1,4) || '-' || substr(ayapr8N002,5,2),a5whs order by 1 ";
|
||||
break;
|
||||
|
||||
case 'custom':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : '';
|
||||
$reportDate = $firstDay->modify('first day of this month')->format('Ymd');
|
||||
|
||||
$toreportDate = $firstDay->modify('last day of this month')->format('Ymd');
|
||||
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by substr(ayapr8N002,7,2),a5whs order by 1 ';
|
||||
break;
|
||||
|
||||
default:
|
||||
$selectContent = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$execSummaryRes = DB::connection(config('m3.connection', 'pgsql'))->select($selectContent);
|
||||
} else {
|
||||
$execSummaryRes = collect();
|
||||
}
|
||||
|
||||
return response()->json(['success' => true, 'reportPeriod' => $reportPeriod, 'result' => $execSummaryRes, 'checkSales' => $checkSales,
|
||||
'checkWeight' => $checkWeight, 'checkLines' => $checkLines]);
|
||||
}
|
||||
|
||||
// Init Page
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
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();
|
||||
|
||||
$cOMPANY = isset($iCM428M->R428CO) ? $iCM428M->R428CO : '110'; // Company
|
||||
$pLANT = isset($iCM428M->R428PL) ? $iCM428M->R428PL : '144'; // Plant
|
||||
$wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : '322'; // WareHouse
|
||||
}
|
||||
$wHDDA = $cOMPANY . $pLANT . $wHS;
|
||||
// dump($wHDDA);
|
||||
// Warehouse Table
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.execSummary', ['IC670M' => $iC670M, 'WHDDA' => $wHDDA]);
|
||||
// ,'ICM688M2',,'COMPANY','PLANT','WHS','reportDate'
|
||||
}
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
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';
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
try {
|
||||
// Ajax Call
|
||||
if ($request->ajax()) {
|
||||
$wHDDA = isset($request->WHDDA) ? $request->WHDDA : [];
|
||||
$wHArr = [];
|
||||
foreach ($wHDDA as $WHDDAV) {
|
||||
$cO = substr($WHDDAV, 0, 3);
|
||||
$wHArr[] = substr($WHDDAV, 6, 3);
|
||||
}
|
||||
|
||||
$reportPeriod = isset($request->reportPeriod) ? $request->reportPeriod : ''; // monthly , quarter , year , daily
|
||||
// Current
|
||||
$checkSales = isset($request->checkSales) ? $request->checkSales : ''; // on
|
||||
$checkWeight = isset($request->checkWeight) ? $request->checkWeight : ''; // on
|
||||
$checkLines = isset($request->checkLines) ? $request->checkLines : ''; // on
|
||||
|
||||
if (! empty($wHArr) && $cO != '' && $reportPeriod != '') {
|
||||
switch ($reportPeriod) {
|
||||
case 'year':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : '';
|
||||
$reportDate = $firstDay->modify('first day of January')->format('Ymd');
|
||||
|
||||
$lastDay = isset($request->TOREPORTDATE) ? \DateTime::createFromFormat('Y-m', trim($request->TOREPORTDATE)) : '';
|
||||
$toreportDate = $lastDay->modify('last day of December')->format('Ymd');
|
||||
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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) . ')
|
||||
)
|
||||
select substr(ayapr8N002,1,4) 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 from tempfile
|
||||
group by substr(ayapr8N002,1,4),a5whs order by 1 ';
|
||||
|
||||
$execSummaryResLY = [];
|
||||
break;
|
||||
|
||||
case 'quarter':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : '';
|
||||
$reportDate = $firstDay->modify('first day of January')->format('Ymd');
|
||||
|
||||
$lastDay = isset($request->TOREPORTDATE) ? \DateTime::createFromFormat('Y-m', trim($request->TOREPORTDATE)) : '';
|
||||
$toreportDate = $lastDay->modify('last day of December')->format('Ymd');
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by 'Q' || EXTRACT(QUARTER FROM TO_DATE(CAST(ayapr8n002 AS TEXT),'YYYYMMDD')) ||'-' || substr(ayapr8N002,3,2),a5whs order by 1 ";
|
||||
|
||||
$execSummaryResLY = [];
|
||||
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : null;
|
||||
|
||||
$lastDay = (clone $firstDay);
|
||||
$reportDate = $firstDay->modify('-11 months')->modify(self::FIRST_DAY_THIS_MONTH)->format('Ymd'); //
|
||||
$toreportDate = $lastDay ? $lastDay->modify(self::LAST_DAY_THIS_MONTH)->format('Ymd') : '';
|
||||
// Last Year Dates
|
||||
// Same period, but for Last Year (LY)
|
||||
$reportDateLY = (clone $firstDay)->modify(self::ONE_YEAR_AGO)->modify(self::FIRST_DAY_THIS_MONTH)->format('Ymd');
|
||||
$toreportDateLY = (clone $lastDay)->modify(self::ONE_YEAR_AGO)->modify(self::LAST_DAY_THIS_MONTH)->format('Ymd');
|
||||
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by substr(ayapr8N002,1,4) || '-' || substr(ayapr8N002,5,2),a5whs order by 1 ";
|
||||
|
||||
$selectContentLY = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by substr(ayapr8N002,1,4) || '-' || substr(ayapr8N002,5,2),a5whs order by 1 ";
|
||||
|
||||
$execSummaryResLY = DB::connection(config('m3.connection', 'pgsql'))->select($selectContentLY);
|
||||
|
||||
break;
|
||||
|
||||
case 'custom':
|
||||
// Set Dates based on reportPeriod type
|
||||
$firstDay = isset($request->REPORTDATE) ? \DateTime::createFromFormat('Y-m', $request->REPORTDATE) : '';
|
||||
$reportDate = $firstDay->modify(self::FIRST_DAY_THIS_MONTH)->format('Ymd');
|
||||
$toreportDate = $firstDay->modify(self::LAST_DAY_THIS_MONTH)->format('Ymd');
|
||||
|
||||
// Last Year Dates
|
||||
$reportDateLY = (clone $firstDay)->modify(self::ONE_YEAR_AGO)->modify(self::FIRST_DAY_THIS_MONTH)->format('Ymd');
|
||||
$toreportDateLY = (clone $firstDay)->modify(self::ONE_YEAR_AGO)->modify(self::LAST_DAY_THIS_MONTH)->format('Ymd');
|
||||
|
||||
// Build SQL
|
||||
$selectContent = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by substr(ayapr8N002,7,2),a5whs order by 1 ';
|
||||
|
||||
$selectContentLY = "with tempfile as (
|
||||
select a5rsvqty,a5packed,a5slunpr*a5packed as dollars,a5lnwght,a5whs,
|
||||
(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 . 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
|
||||
from tempfile
|
||||
group by substr(ayapr8N002,7,2),a5whs order by 1 ';
|
||||
|
||||
$execSummaryResLY = DB::connection(config('m3.connection', 'pgsql'))->select($selectContentLY);
|
||||
break;
|
||||
|
||||
default:
|
||||
$selectContent = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$execSummaryRes = DB::connection(config('m3.connection', 'pgsql'))->select($selectContent);
|
||||
} else {
|
||||
$execSummaryRes = collect();
|
||||
$execSummaryResLY = collect();
|
||||
}
|
||||
|
||||
return response()->json(['success' => true, 'reportPeriod' => $reportPeriod, 'result' => $execSummaryRes, 'resultLY' => $execSummaryResLY,
|
||||
'checkSales' => $checkSales, 'checkWeight' => $checkWeight, 'checkLines' => $checkLines]);
|
||||
}
|
||||
|
||||
// Init Page
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
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();
|
||||
|
||||
$cOMPANY = isset($iCM428M->R428CO) ? $iCM428M->R428CO : '110'; // Company
|
||||
$pLANT = isset($iCM428M->R428PL) ? $iCM428M->R428PL : '144'; // Plant
|
||||
$wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : '322'; // WareHouse
|
||||
}
|
||||
$wHDDA = $cOMPANY . $pLANT . $wHS;
|
||||
// dump($wHDDA);
|
||||
// Warehouse Table
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.execSummaryLine', ['IC670M' => $iC670M, 'WHDDA' => $wHDDA]);
|
||||
// ,'ICM688M2',,'COMPANY','PLANT','WHS','reportDate'
|
||||
}
|
||||
}
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\M3\Services\BillOfLadingService;
|
||||
|
||||
class FillBOL2Controller extends Controller
|
||||
{
|
||||
protected $bolService;
|
||||
|
||||
public function __construct(BillOfLadingService $bolService)
|
||||
{
|
||||
$this->bolService = $bolService;
|
||||
}
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
return view('m3::liberty-theme.pages.fillBOL2');
|
||||
|
||||
}
|
||||
|
||||
public function fillBOL(Request $request)
|
||||
{
|
||||
|
||||
// # $bOL = BOL::findOrFail($request);
|
||||
$bOL = $request;
|
||||
|
||||
$data = [
|
||||
'bol_number' => $request->input('BOL_number') ?? '1234567890',
|
||||
'shipper_no' => $request->input('shipper_no') ?? '1234567890',
|
||||
'date' => now()->format('m/d/Y') ?? '01/01/2000',
|
||||
'master_bill_no' => 'X',
|
||||
'master_bill_yes' => $request->input('master_bill_yes') ? 'X' : '',
|
||||
'master_bill_drops' => $request->input('master_bill_drops') ?? '',
|
||||
'consignor_name' => $request->input('consignor_name') ?? 'ERICO INTERNATIONAL CORP',
|
||||
'consignor_address1' => $request->input('consignor_address1') ?? '6800 ARNOLD MILLER PARKWAY',
|
||||
'consignor_address2' => $request->input('consignor_address2') ?? 'SOLON, OH 44139',
|
||||
'consignor_address3' => $request->input('consignor_address3') ?? 'USA',
|
||||
'consignee_name' => $request->input('consignee_name') ?? 'ERICO EUROPE BV',
|
||||
'consignee_address1' => $request->input('consignee_address1') ?? 'JULES VERNEWEG 75',
|
||||
'consignee_address2' => $request->input('consignee_address2') ?? '',
|
||||
'consignee_address3' => $request->input('consignee_address3') ?? 'TILBURG . 5015 BG',
|
||||
'freight_collect' => 'X',
|
||||
'carrier_name' => $request->input('carrier_name') ?? 'ICL / Expeditors',
|
||||
|
||||
'pieces' => $request->input('pieces') ?? '20',
|
||||
'line_class' => $request->input('line_class') ?? '50',
|
||||
'line_weight' => $request->input('line_weight') ?? '8320',
|
||||
|
||||
'total_pieces' => $request->input('total_pieces') ?? '20',
|
||||
'total_line_weight' => $request->input('total_line_weight') ?? '8320',
|
||||
'description' => $request->input('description') ?? 'Package Description sfdfsdfasdfas dfasdfasdfcasdfvasfa clsdalcdfl
|
||||
Line 2
|
||||
Line 3
|
||||
Line 4
|
||||
Line 5',
|
||||
|
||||
'DTESHIPED.1' => date('d/m/Y'),
|
||||
'invoice_number' => $bOL['BOL_number'],
|
||||
'amount_due' => number_format($bOL['amount'], 2),
|
||||
'TYPEANDESCPTN.1' => 'TOTAL: 20 SKIDS 8320 #',
|
||||
'TYPEANDESCPTN.10' => 'ROTTERDAM ETA: 11/22',
|
||||
'TYPEANDESCPTN.13' => 'CONTAINER:',
|
||||
'TYPEANDESCPTN.2' => 'MECHANICAL / CADDY/ ELECTRICAL',
|
||||
'TYPEANDESCPTN.4' => 'BOOKING: 150744100',
|
||||
'TYPEANDESCPTN.5' => 'REFERENCE: 3140028046',
|
||||
'TYPEANDESCPTN.6' => 'VESSEL: INDEPENDENT HORIZON V. 1023E',
|
||||
'TYPEANDESCPTN.7' => 'SEAL: 637053',
|
||||
'TYPEANDESCPTN.9' => 'CHESTER, PA ETD: 11/05',
|
||||
'BOFLADNGAGYCD' => $bOL['BOL_number'],
|
||||
'CLASSORATE1' => '50',
|
||||
'CNMETRKLICNSE' => 'ICL / Expeditors',
|
||||
'CONSIGTONMADDR' => 'ERICO EUROPE BV JULES VERNEWEG 75 TILBURG . 5015 BG',
|
||||
'DATE' => date('d/m/Y'),
|
||||
'FRMNMADDR' => 'ERICO INTERNATIONAL CORP 6800 ARNOLD MILLER PARKWAY SOLON, OH 44139 USA',
|
||||
'LNITEMWT1' => '8320',
|
||||
'PARTOFMSTRBILL' => 'No',
|
||||
'PKGTYPECOUNT1' => '20',
|
||||
'SHPRNMBR' => '3140028046',
|
||||
'TOTALWT' => '8320',
|
||||
'TOTPIECES' => '20',
|
||||
'ckFREIGHTCOLECT' => 'Yes',
|
||||
'ckPREPAY' => 'Off',
|
||||
|
||||
'DTESHIPED.2' => '',
|
||||
'LNITEMWT24' => '',
|
||||
'CLASSORATE24' => '',
|
||||
'LNITEMCLAS24' => '',
|
||||
'TYPEANDESCPTN.24' => '',
|
||||
'PKGTYPECOUNT24' => '',
|
||||
'LNITEMWT23' => '',
|
||||
'CLASSORATE23' => '',
|
||||
'LNITEMCLAS23' => '',
|
||||
'TYPEANDESCPTN.23' => '',
|
||||
'PKGTYPECOUNT23' => '',
|
||||
'LNITEMWT22' => '',
|
||||
'CLASSORATE22' => '',
|
||||
'LNITEMCLAS22' => '',
|
||||
'TYPEANDESCPTN.22' => '',
|
||||
'PKGTYPECOUNT22' => '',
|
||||
'LNITEMWT21' => '',
|
||||
'CLASSORATE21' => '',
|
||||
'LNITEMCLAS21' => '',
|
||||
'TYPEANDESCPTN.21' => '',
|
||||
'PKGTYPECOUNT21' => '',
|
||||
'LNITEMWT20' => '',
|
||||
'CLASSORATE20' => '',
|
||||
'LNITEMCLAS20' => '',
|
||||
'TYPEANDESCPTN.20' => '',
|
||||
'PKGTYPECOUNT20' => '',
|
||||
'LNITEMWT19' => '',
|
||||
'CLASSORATE19' => '',
|
||||
'LNITEMCLAS19' => '',
|
||||
'TYPEANDESCPTN.19' => '',
|
||||
'PKGTYPECOUNT19' => '',
|
||||
'LNITEMWT18' => '',
|
||||
'CLASSORATE18' => '',
|
||||
'LNITEMCLAS18' => '',
|
||||
'TYPEANDESCPTN.18' => '',
|
||||
'PKGTYPECOUNT18' => '',
|
||||
'LNITEMWT17' => '',
|
||||
'CLASSORATE17' => '',
|
||||
'LNITEMCLAS17' => '',
|
||||
'TYPEANDESCPTN.17' => '',
|
||||
'PKGTYPECOUNT17' => '',
|
||||
'LNITEMWT16' => '',
|
||||
'CLASSORATE16' => '',
|
||||
'LNITEMCLAS16' => '',
|
||||
'TYPEANDESCPTN.16' => '',
|
||||
'PKGTYPECOUNT16' => '',
|
||||
'LNITEMWT15' => '',
|
||||
'CLASSORATE15' => '',
|
||||
'LNITEMCLAS15' => '',
|
||||
'TYPEANDESCPTN.15' => '',
|
||||
'PKGTYPECOUNT15' => '',
|
||||
'LNITEMWT14' => '',
|
||||
'CLASSORAT14' => '',
|
||||
'LNITEMCLAS14' => '',
|
||||
'TYPEANDESCPTN.14' => '',
|
||||
'PKGTYPECOUNT14' => '',
|
||||
'LNITEMWT13' => '',
|
||||
'CLASSORATE13' => '',
|
||||
'LNITEMCLAS13' => '',
|
||||
'PKGTYPECOUNT13' => '',
|
||||
'LNITEMWT12' => '',
|
||||
'CLASSORATE12' => '',
|
||||
'LNITEMCLAS12' => '',
|
||||
'TYPEANDESCPTN.12' => '',
|
||||
'PKGTYPECOUNT12' => '',
|
||||
'LNITEMWT11' => '',
|
||||
'CLASSORATE11' => '',
|
||||
'LNITEMCLAS11' => '',
|
||||
'TYPEANDESCPTN.11' => '',
|
||||
'PKGTYPECOUNT11' => '',
|
||||
'LNITEMWT10' => '',
|
||||
'CLASSORATE10' => '',
|
||||
'LNITEMCLAS10' => '',
|
||||
'PKGTYPECOUNT10' => '',
|
||||
'LNITEMWT9' => '',
|
||||
'CLASSORATE9' => '',
|
||||
'LNITEMCLAS8' => '',
|
||||
'PKGTYPECOUNT9' => '',
|
||||
'LNITEMWT8' => '',
|
||||
'CLASSORATE8' => '',
|
||||
'TYPEANDESCPTN.8' => '',
|
||||
'PKGTYPECOUNT8' => '',
|
||||
'LNITEMWT7' => '',
|
||||
'CLASSORATE7' => '',
|
||||
'LNITEMCLAS7' => '',
|
||||
'PKGTYPECOUNT7' => '',
|
||||
'LNITEMWT6' => '',
|
||||
'CLASSORATE6' => '',
|
||||
'LNITEMCLAS6' => '',
|
||||
'PKGTYPECOUNT6' => '',
|
||||
'LNITEMWT5' => '',
|
||||
'CLASSORATE5' => '',
|
||||
'LNITEMCLAS5' => '',
|
||||
'PKGTYPECOUNT5' => '',
|
||||
'LNITEMWT4' => '',
|
||||
'CLASSORATE4' => '',
|
||||
'LNITEMCLAS4' => '',
|
||||
'PKGTYPECOUNT4' => '',
|
||||
'LNITEMWT3' => '',
|
||||
'CLASSORATE3' => '',
|
||||
'LNITEMCLAS3' => '',
|
||||
'TYPEANDESCPTN.3' => '',
|
||||
'PKGTYPECOUNT3' => '',
|
||||
'LNITEMWT2' => '',
|
||||
'CLASSORATE2' => '',
|
||||
'LNITEMCLAS2' => '',
|
||||
'PKGTYPECOUNT2' => '',
|
||||
'LNITEMCLAS1' => '',
|
||||
'HAZLNITEMWT3' => '',
|
||||
'HAZCLASSORATE3' => '',
|
||||
'HAZLNITEMCLAS3' => '',
|
||||
'HAZMATERDESL3' => '',
|
||||
'HAZMATERL3' => '',
|
||||
'HAZLNITEMWT2' => '',
|
||||
'HAZCLASSORATE2' => '',
|
||||
'HAZLNITEMCLAS2' => '',
|
||||
'HAZMATERDESL2' => '',
|
||||
'HAZMATERL2' => '',
|
||||
'HAZLNITEMWT1' => '',
|
||||
'HAZCLASSORATE1' => '',
|
||||
'HAZLNITEMCLAS1' => '',
|
||||
'HAZMATERDESL1' => '',
|
||||
'HAZMATERL1' => '',
|
||||
'24HREMGCYRSPNS' => '',
|
||||
'CARIERFEDEMPID' => '',
|
||||
'BILLTOADDR' => '',
|
||||
'NUMDROPS' => '',
|
||||
|
||||
];
|
||||
|
||||
try {
|
||||
$filledPdf = $this->bolService->fillBillOfLading($data);
|
||||
|
||||
return response()->download($filledPdf)->deleteFileAfterSend(true);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use mikehaertl\pdftk\Pdf;
|
||||
use Storage;
|
||||
|
||||
class FillBOLController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
return view('m3::liberty-theme.pages.fillBOL');
|
||||
|
||||
}
|
||||
|
||||
public static function fillBOL(Request $request)
|
||||
{
|
||||
// # $bOL = BOL::findOrFail($request);
|
||||
$bOL = $request;
|
||||
|
||||
$pdf = new Pdf(Storage::disk('public')->path('ETN-BOL.pdf'));
|
||||
// $pdf = new Pdf(Storage::disk('public')->path('ETN-BOL.pdf'), [
|
||||
// //'command' => '/usr/local/bin/pdftk',
|
||||
// 'useExec' => true,
|
||||
// ]);
|
||||
if ($pdf === false) {
|
||||
var_dump('step 1');
|
||||
$error = $pdf->getError();
|
||||
dd($error);
|
||||
}
|
||||
|
||||
$newfile = "BOL-{$bOL['BOL_number']}.pdf";
|
||||
var_dump($newfile);
|
||||
|
||||
$test = Storage::disk('public')->put($newfile, '');
|
||||
if ($test === false) {
|
||||
var_dump('step 2');
|
||||
$error = $test->getError();
|
||||
dd($error);
|
||||
}
|
||||
|
||||
$result = $pdf->fillForm([
|
||||
'DTESHIPED.1' => date('d/m/Y'),
|
||||
'invoice_number' => $bOL['BOL_number'],
|
||||
'amount_due' => number_format($bOL['amount'], 2),
|
||||
'TYPEANDESCPTN.1' => 'TOTAL: 20 SKIDS 8320 #',
|
||||
'TYPEANDESCPTN.10' => 'ROTTERDAM ETA: 11/22',
|
||||
'TYPEANDESCPTN.13' => 'CONTAINER:',
|
||||
'TYPEANDESCPTN.2' => 'MECHANICAL / CADDY/ ELECTRICAL',
|
||||
'TYPEANDESCPTN.4' => 'BOOKING: 150744100',
|
||||
'TYPEANDESCPTN.5' => 'REFERENCE: 3140028046',
|
||||
'TYPEANDESCPTN.6' => 'VESSEL: INDEPENDENT HORIZON V. 1023E',
|
||||
'TYPEANDESCPTN.7' => 'SEAL: 637053',
|
||||
'TYPEANDESCPTN.9' => 'CHESTER, PA ETD: 11/05',
|
||||
'BOFLADNGAGYCD' => $bOL['BOL_number'],
|
||||
'CLASSORATE1' => '50',
|
||||
'CNMETRKLICNSE' => 'ICL / Expeditors',
|
||||
'CONSIGTONMADDR' => 'ERICO EUROPE BV JULES VERNEWEG 75 TILBURG . 5015 BG',
|
||||
'DATE' => date('d/m/Y'),
|
||||
'FRMNMADDR' => 'ERICO INTERNATIONAL CORP 6800 ARNOLD MILLER PARKWAY SOLON, OH 44139 USA',
|
||||
'LNITEMWT1' => '8320',
|
||||
'PARTOFMSTRBILL' => 'No',
|
||||
'PKGTYPECOUNT1' => '20',
|
||||
'SHPRNMBR' => '3140028046',
|
||||
'TOTALWT' => '8320',
|
||||
'TOTPIECES' => '20',
|
||||
'ckFREIGHTCOLECT' => 'Yes',
|
||||
'ckPREPAY' => 'Off',
|
||||
|
||||
'DTESHIPED.2' => '',
|
||||
'LNITEMWT24' => '',
|
||||
'CLASSORATE24' => '',
|
||||
'LNITEMCLAS24' => '',
|
||||
'TYPEANDESCPTN.24' => '',
|
||||
'PKGTYPECOUNT24' => '',
|
||||
'LNITEMWT23' => '',
|
||||
'CLASSORATE23' => '',
|
||||
'LNITEMCLAS23' => '',
|
||||
'TYPEANDESCPTN.23' => '',
|
||||
'PKGTYPECOUNT23' => '',
|
||||
'LNITEMWT22' => '',
|
||||
'CLASSORATE22' => '',
|
||||
'LNITEMCLAS22' => '',
|
||||
'TYPEANDESCPTN.22' => '',
|
||||
'PKGTYPECOUNT22' => '',
|
||||
'LNITEMWT21' => '',
|
||||
'CLASSORATE21' => '',
|
||||
'LNITEMCLAS21' => '',
|
||||
'TYPEANDESCPTN.21' => '',
|
||||
'PKGTYPECOUNT21' => '',
|
||||
'LNITEMWT20' => '',
|
||||
'CLASSORATE20' => '',
|
||||
'LNITEMCLAS20' => '',
|
||||
'TYPEANDESCPTN.20' => '',
|
||||
'PKGTYPECOUNT20' => '',
|
||||
'LNITEMWT19' => '',
|
||||
'CLASSORATE19' => '',
|
||||
'LNITEMCLAS19' => '',
|
||||
'TYPEANDESCPTN.19' => '',
|
||||
'PKGTYPECOUNT19' => '',
|
||||
'LNITEMWT18' => '',
|
||||
'CLASSORATE18' => '',
|
||||
'LNITEMCLAS18' => '',
|
||||
'TYPEANDESCPTN.18' => '',
|
||||
'PKGTYPECOUNT18' => '',
|
||||
'LNITEMWT17' => '',
|
||||
'CLASSORATE17' => '',
|
||||
'LNITEMCLAS17' => '',
|
||||
'TYPEANDESCPTN.17' => '',
|
||||
'PKGTYPECOUNT17' => '',
|
||||
'LNITEMWT16' => '',
|
||||
'CLASSORATE16' => '',
|
||||
'LNITEMCLAS16' => '',
|
||||
'TYPEANDESCPTN.16' => '',
|
||||
'PKGTYPECOUNT16' => '',
|
||||
'LNITEMWT15' => '',
|
||||
'CLASSORATE15' => '',
|
||||
'LNITEMCLAS15' => '',
|
||||
'TYPEANDESCPTN.15' => '',
|
||||
'PKGTYPECOUNT15' => '',
|
||||
'LNITEMWT14' => '',
|
||||
'CLASSORAT14' => '',
|
||||
'LNITEMCLAS14' => '',
|
||||
'TYPEANDESCPTN.14' => '',
|
||||
'PKGTYPECOUNT14' => '',
|
||||
'LNITEMWT13' => '',
|
||||
'CLASSORATE13' => '',
|
||||
'LNITEMCLAS13' => '',
|
||||
'PKGTYPECOUNT13' => '',
|
||||
'LNITEMWT12' => '',
|
||||
'CLASSORATE12' => '',
|
||||
'LNITEMCLAS12' => '',
|
||||
'TYPEANDESCPTN.12' => '',
|
||||
'PKGTYPECOUNT12' => '',
|
||||
'LNITEMWT11' => '',
|
||||
'CLASSORATE11' => '',
|
||||
'LNITEMCLAS11' => '',
|
||||
'TYPEANDESCPTN.11' => '',
|
||||
'PKGTYPECOUNT11' => '',
|
||||
'LNITEMWT10' => '',
|
||||
'CLASSORATE10' => '',
|
||||
'LNITEMCLAS10' => '',
|
||||
'PKGTYPECOUNT10' => '',
|
||||
'LNITEMWT9' => '',
|
||||
'CLASSORATE9' => '',
|
||||
'LNITEMCLAS8' => '',
|
||||
'PKGTYPECOUNT9' => '',
|
||||
'LNITEMWT8' => '',
|
||||
'CLASSORATE8' => '',
|
||||
'TYPEANDESCPTN.8' => '',
|
||||
'PKGTYPECOUNT8' => '',
|
||||
'LNITEMWT7' => '',
|
||||
'CLASSORATE7' => '',
|
||||
'LNITEMCLAS7' => '',
|
||||
'PKGTYPECOUNT7' => '',
|
||||
'LNITEMWT6' => '',
|
||||
'CLASSORATE6' => '',
|
||||
'LNITEMCLAS6' => '',
|
||||
'PKGTYPECOUNT6' => '',
|
||||
'LNITEMWT5' => '',
|
||||
'CLASSORATE5' => '',
|
||||
'LNITEMCLAS5' => '',
|
||||
'PKGTYPECOUNT5' => '',
|
||||
'LNITEMWT4' => '',
|
||||
'CLASSORATE4' => '',
|
||||
'LNITEMCLAS4' => '',
|
||||
'PKGTYPECOUNT4' => '',
|
||||
'LNITEMWT3' => '',
|
||||
'CLASSORATE3' => '',
|
||||
'LNITEMCLAS3' => '',
|
||||
'TYPEANDESCPTN.3' => '',
|
||||
'PKGTYPECOUNT3' => '',
|
||||
'LNITEMWT2' => '',
|
||||
'CLASSORATE2' => '',
|
||||
'LNITEMCLAS2' => '',
|
||||
'PKGTYPECOUNT2' => '',
|
||||
'LNITEMCLAS1' => '',
|
||||
'HAZLNITEMWT3' => '',
|
||||
'HAZCLASSORATE3' => '',
|
||||
'HAZLNITEMCLAS3' => '',
|
||||
'HAZMATERDESL3' => '',
|
||||
'HAZMATERL3' => '',
|
||||
'HAZLNITEMWT2' => '',
|
||||
'HAZCLASSORATE2' => '',
|
||||
'HAZLNITEMCLAS2' => '',
|
||||
'HAZMATERDESL2' => '',
|
||||
'HAZMATERL2' => '',
|
||||
'HAZLNITEMWT1' => '',
|
||||
'HAZCLASSORATE1' => '',
|
||||
'HAZLNITEMCLAS1' => '',
|
||||
'HAZMATERDESL1' => '',
|
||||
'HAZMATERL1' => '',
|
||||
'24HREMGCYRSPNS' => '',
|
||||
'CARIERFEDEMPID' => '',
|
||||
'BILLTOADDR' => '',
|
||||
'NUMDROPS' => '',
|
||||
|
||||
])
|
||||
->needAppearances() // ensures values are visible in viewer
|
||||
->saveAs(Storage::disk('public')->path($newfile));
|
||||
// Always check for errors
|
||||
if ($result === false) {
|
||||
var_dump('step 3');
|
||||
$error = $pdf->getError();
|
||||
dd($error);
|
||||
} else {
|
||||
return response()->file(Storage::disk('public')->path($newfile));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+297
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
//
|
||||
|
||||
class GetContentsController extends Controller
|
||||
{
|
||||
public function processShipment(Request $request)
|
||||
{
|
||||
// Get Mackpkr from Request
|
||||
$macpacPicker = isset($request->MACPKR) ? trim($request->MACPKR) : '';
|
||||
|
||||
// ESN1
|
||||
// $macpacPicker='888568'; // LTL example
|
||||
// $macpacPicker='894337'; // another LTL example with smaller orders, therefore pallets are more mixed
|
||||
// $macpacPicker='1225311'; // parcel example
|
||||
// ESN2
|
||||
// $macpacPicker='748101'; // LTL example
|
||||
|
||||
try {
|
||||
$icm704mArray = $this->buildNMFCCodesArray();
|
||||
|
||||
$shipmentData = $this->getShipmentData($macpacPicker);
|
||||
if (empty($shipmentData['orderNumber'])) {
|
||||
return response()->json(['error' => "Picker {$macpacPicker} was not found in ICM688M1"]);
|
||||
}
|
||||
|
||||
// Get Packages
|
||||
$packages = $this->getPackagesData($shipmentData['macpkr_list']);
|
||||
// Add NMFC to Packages
|
||||
$packagesWithNMFC = $this->addNMFCDataToPackages($packages, $macpacPicker, $icm704mArray);
|
||||
|
||||
// Get Commodities
|
||||
$commodities = $this->getCommoditiesData(
|
||||
$shipmentData['company'],
|
||||
$shipmentData['warehouse'],
|
||||
$macpacPicker,
|
||||
$packages['package_595m1'],
|
||||
$icm704mArray,
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'error' => '',
|
||||
'shipmentData' => $shipmentData,
|
||||
'packages' => $packagesWithNMFC,
|
||||
'commodities' => $commodities,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
protected function buildNMFCCodesArray()
|
||||
{
|
||||
$results = DB::table('ICM704M')->get();
|
||||
|
||||
return $results->mapWithKeys(function ($row) {
|
||||
return [
|
||||
trim($row->AONMIT) => [
|
||||
'LTLClassId' => number_format(trim($row->AOFCID), 1),
|
||||
'NMFCItem' => trim($row->AONMIT),
|
||||
'NMFCSub' => trim($row->AONMSB),
|
||||
'SkidDescription' => trim($row->AOSKDE),
|
||||
],
|
||||
];
|
||||
})->all();
|
||||
|
||||
}
|
||||
|
||||
protected function getShipmentData($macpacPicker)
|
||||
{
|
||||
$result = DB::select(
|
||||
'
|
||||
SELECT
|
||||
SUM(A4TPCKWGHT) as total_weight,
|
||||
A4MACPKR, A4SHSHA1, A4SHSHA2, A4SHSHCI, A4SHSHNM,
|
||||
A4SHSHCT, A4SHSHZP, A4SHSHST, A4ONO, A4STCN, A4CO,
|
||||
A4WHS, A4SHIPVIA, A4SLCO, A4SLWHS, A4CATPID, A42SSVCCOD,
|
||||
A4CARRIER, A4SHPAGGCD, A4SALESLOC, A4SHCSPO, A4OFSTRM,
|
||||
A4SCAC, A4PLANT
|
||||
FROM ICM688M1
|
||||
WHERE A4MACPKR = ?
|
||||
GROUP BY A4MACPKR, A4SHSHA1, A4SHSHA2, A4SHSHCI, A4SHSHNM,
|
||||
A4SHSHCT, A4SHSHZP, A4SHSHST, A4ONO, A4RLNO, A4SHNO,
|
||||
A4STCN, A4CO, A4WHS, A4SHIPVIA, A4SLCO, A4SLWHS,
|
||||
A4CATPID, A42SSVCCOD, A4CARRIER, A4SHPAGGCD,
|
||||
A4SALESLOC, A4SHCSPO, A4OFSTRM, A4SCAC, A4PLANT',
|
||||
[$macpacPicker],
|
||||
);
|
||||
|
||||
if (empty($result)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$row = $result[0];
|
||||
|
||||
return [
|
||||
'orderNumber' => trim($row->A4MACPKR),
|
||||
'recipient' => [
|
||||
'address1' => trim($row->A4SHSHA1),
|
||||
'address2' => trim($row->A4SHSHA2),
|
||||
'city' => trim($row->A4SHSHCI),
|
||||
'companyName' => trim($row->A4SHSHNM),
|
||||
'country' => trim($row->A4SHSHCT),
|
||||
'postalCode' => trim($row->A4SHSHZP),
|
||||
'state' => trim($row->A4SHSHST),
|
||||
],
|
||||
'shipmentReference' => trim($row->A4ONO),
|
||||
'company' => trim($row->A4CO),
|
||||
'warehouse' => trim($row->A4WHS),
|
||||
'macpkr_list' => $macpacPicker,
|
||||
'shipment_list' => "'" . trim($row->A4ONO) . "'",
|
||||
'po_list' => "'" . trim($row->A4SHCSPO) . "'",
|
||||
'order_list' => "'" . trim($row->A4ONO) . "'",
|
||||
];
|
||||
}
|
||||
|
||||
protected function getPackagesData($macpkrList)
|
||||
{
|
||||
$results = DB::select(
|
||||
'
|
||||
SELECT
|
||||
AYINTBOX,
|
||||
MAX(AYHEIGHT) as height,
|
||||
MAX(AYWIDTH) as width,
|
||||
MAX(AYDEPTH) as depth,
|
||||
SUM(AYLNWGHT) as weight
|
||||
FROM ICM695M1
|
||||
WHERE AYMACPKR IN (?)
|
||||
GROUP BY AYINTBOX
|
||||
ORDER BY AYINTBOX',
|
||||
[$macpkrList],
|
||||
);
|
||||
|
||||
$packages = [];
|
||||
$package595m1 = [];
|
||||
$packagesGS1Array = [];
|
||||
|
||||
foreach ($results as $index => $row) {
|
||||
$internalBox = trim($row->AYINTBOX);
|
||||
|
||||
$package595m1[$internalBox] = [
|
||||
'INDEX' => $index,
|
||||
'HEIGHT' => $row->HEIGHT,
|
||||
'WIDTH' => $row->WIDTH,
|
||||
'DEPTH' => $row->DEPTH,
|
||||
'WEIGHT' => $row->WEIGHT,
|
||||
];
|
||||
|
||||
$packages[] = [
|
||||
'Width' => $row->WIDTH,
|
||||
'Height' => $row->HEIGHT,
|
||||
'Length' => $row->DEPTH,
|
||||
'Weight' => $row->WEIGHT,
|
||||
'LicencePlate' => $internalBox,
|
||||
'Reference1' => $internalBox,
|
||||
'WeightType' => 0,
|
||||
'DimensionType' => 0,
|
||||
];
|
||||
|
||||
$packagesGS1Array[] = $internalBox;
|
||||
}
|
||||
|
||||
return [
|
||||
'packages' => $packages,
|
||||
'package_595m1' => $package595m1,
|
||||
'packagesGS1Array' => $packagesGS1Array,
|
||||
];
|
||||
}
|
||||
|
||||
protected function addNMFCDataToPackages($packages, $macpkrList, $icm704mArray)
|
||||
{
|
||||
$nmfcResults = DB::select(
|
||||
'
|
||||
WITH tempfile AS (
|
||||
SELECT
|
||||
(SELECT A5WBFRCT FROM ICM688M2
|
||||
WHERE A5MACPKR IN (?) AND A5PART=AZPART
|
||||
FETCH FIRST 1 ROWS ONLY) as WBFRCT,
|
||||
az.*
|
||||
FROM ICM695M2 az
|
||||
WHERE AZMACPKR IN (?)
|
||||
)
|
||||
SELECT azintbox, MIN(WBFRCT) as MIN_WBFRCT
|
||||
FROM tempfile
|
||||
GROUP BY azintbox
|
||||
ORDER BY 1',
|
||||
[$macpkrList, $macpkrList],
|
||||
);
|
||||
|
||||
foreach ($nmfcResults as $index => $row) {
|
||||
$wbfrct = trim($row->MIN_WBFRCT);
|
||||
$packages['packages'][$index]['SkidDesc'] =
|
||||
$icm704mArray[$wbfrct]['SkidDescription'] ?? 'CLIPS, FASTENERS OR MOUNTS';
|
||||
}
|
||||
|
||||
return $packages;
|
||||
}
|
||||
|
||||
protected function getCommoditiesData($company, $warehouse, $macpkrList, $package595m1, $icm704mArray)
|
||||
{
|
||||
$results = DB::select(
|
||||
'
|
||||
WITH tempfile1 AS (
|
||||
SELECT
|
||||
A5PART,
|
||||
MAX(A5CMDESC) as A5CMDESC,
|
||||
MAX(A5MUTMS) as A5MUTMS,
|
||||
MAX(A5PMPWHT) as A5PMPWHT,
|
||||
MAX(A5SLUNPR) as A5SLUNPR,
|
||||
TRIM(MIN(A5WBFRCT)) as A5WBFRCT
|
||||
FROM ICM688M2
|
||||
WHERE A5CO = ? AND A5WHS = ? AND A5MACPKR IN (?) AND A5PACKED > 0
|
||||
GROUP BY A5PART
|
||||
),
|
||||
tempfile2 AS (
|
||||
SELECT
|
||||
AZINTBOX,
|
||||
AZPART,
|
||||
SUM(AZPACKED) as AZPACKED,
|
||||
MAX(SUBSTR(AZSPR15A01,1,4)) as HAZARDOUS
|
||||
FROM ICM695M2
|
||||
WHERE AZCO = ? AND AZWHS = ? AND AZMACPKR IN (?) AND AZPACKED <> 0
|
||||
GROUP BY AZINTBOX, AZPART
|
||||
)
|
||||
SELECT
|
||||
A5PART, A5CMDESC, A5MUTMS,
|
||||
A5PMPWHT * AZPACKED as WEIGHt,
|
||||
AZPACKED, AZINTBOX,
|
||||
A5WBFRCT, HAZARDOUS, A5SLUNPR
|
||||
FROM tempfile1
|
||||
LEFT JOIN tempfile2 ON AZPART = A5PART
|
||||
ORDER BY A5PART',
|
||||
[$company, $warehouse, $macpkrList, $company, $warehouse, $macpkrList],
|
||||
);
|
||||
|
||||
$commodities = [];
|
||||
$prevPartNumber = '';
|
||||
$index = -1;
|
||||
|
||||
foreach ($results as $row) {
|
||||
$partNumber = trim($row->A5PART);
|
||||
|
||||
if ($partNumber !== $prevPartNumber) {
|
||||
$index++;
|
||||
$quantityIndex = 0;
|
||||
|
||||
$wbfrct = trim($row->A5WBFRCT);
|
||||
$nmfcData = $icm704mArray[$wbfrct] ?? [
|
||||
'LTLClassId' => '50',
|
||||
'NMFCItem' => '93490',
|
||||
'NMFCSub' => '',
|
||||
];
|
||||
|
||||
$commodities[] = [
|
||||
'Description' => trim($row->A5CMDESC),
|
||||
'PartNumber' => $partNumber,
|
||||
'SKUOrItemOrUPC' => $partNumber,
|
||||
'MadeInCountryCode' => 'US',
|
||||
'UnitValue' => $row->A5SLUNPR == '.000' ? 1 : (float) $row->A5SLUNPR,
|
||||
'TotalWeight' => (float) $row->WEIGHT,
|
||||
'QuantityUnitOfMeasure' => trim($row->A5MUTMS) ?: 'EA',
|
||||
'Quantity' => (float) $row->AZPACKED,
|
||||
'LTLClassId' => $nmfcData['LTLClassId'],
|
||||
'NMFCItem' => $nmfcData['NMFCItem'],
|
||||
'NMFCSub' => $nmfcData['NMFCSub'],
|
||||
'DangerousGoodsInfo' => [
|
||||
'ContainsDangerousGoods' => trim($row->HAZARDOUS) === 'H4.1',
|
||||
],
|
||||
'QuantityAssignment' => [
|
||||
[
|
||||
'PackageIndex' => $package595m1[trim($row->AZINTBOX)]['INDEX'],
|
||||
'Quantity' => (float) $row->AZPACKED,
|
||||
],
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$quantityIndex++;
|
||||
$commodities[$index]['TotalWeight'] += (float) $row->WEIGHT;
|
||||
$commodities[$index]['Quantity'] += (float) $row->AZPACKED;
|
||||
$commodities[$index]['QuantityAssignment'][] = [
|
||||
'PackageIndex' => $package595m1[trim($row->AZINTBOX)]['INDEX'],
|
||||
'Quantity' => (float) $row->AZPACKED,
|
||||
];
|
||||
}
|
||||
|
||||
$prevPartNumber = $partNumber;
|
||||
}
|
||||
|
||||
return $commodities;
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Artisan;
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Log;
|
||||
|
||||
class M3CallCloseAPIController extends Controller
|
||||
{
|
||||
public static function index(Request $request): JsonResponse
|
||||
{
|
||||
self::configureTimeouts();
|
||||
$params = self::validatedParams($request);
|
||||
|
||||
if ($params === null) {
|
||||
Log::channel('dailyCron')->error('Manifest CloseAPI: Manifest, company and warehouse must be defined.');
|
||||
|
||||
return self::errorResponse('Manifest CloseAPI: Manifest, company and warehouse must be defined.');
|
||||
}
|
||||
|
||||
try {
|
||||
$records = self::findOpenManifestRecords($params);
|
||||
if ($records->isEmpty()) {
|
||||
Log::channel('dailyCron')->info('Manifest CloseAPI: No records found in ICM705M1.');
|
||||
|
||||
return self::errorResponse('Manifest CloseAPI: No records found in ICM705M1.');
|
||||
}
|
||||
|
||||
return self::submitManifest($records->first(), $params['SHUSER']);
|
||||
} catch (\Throwable $exception) {
|
||||
Log::error($exception);
|
||||
|
||||
return response()->json([
|
||||
'code' => '500',
|
||||
'status' => 'Error',
|
||||
'message' => 'Manifest Closing failed unexpectedly.',
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
private static function configureTimeouts(): void
|
||||
{
|
||||
$timeout = (string) Config::get('arrays.PHPTimeOut');
|
||||
ini_set('max_execution_time', $timeout);
|
||||
ini_set('max_input_time', $timeout);
|
||||
ini_set('default_socket_timeout', $timeout);
|
||||
}
|
||||
|
||||
private static function validatedParams(Request $request): ?array
|
||||
{
|
||||
$params = [
|
||||
'SHUSER' => trim((string) $request->input('SHUSER', '')),
|
||||
'MANIFEST' => trim((string) $request->input('MANIFEST', '')),
|
||||
'APCO' => trim((string) $request->input('APCO', '')),
|
||||
'APWHS' => trim((string) $request->input('APWHS', '')),
|
||||
];
|
||||
|
||||
if ($params['MANIFEST'] === '' || $params['APCO'] === '' || $params['APWHS'] === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
private static function findOpenManifestRecords(array $params)
|
||||
{
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
if (! Schema::connection($connection)->hasTable('icm705m1')) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
return DB::connection($connection)->table('icm705m1')
|
||||
->select('APMANIFEST', 'APCO', 'APWHS')
|
||||
->where('APSPARE2', '')
|
||||
->where('APCO', $params['APCO'])
|
||||
->where('APWHS', $params['APWHS'])
|
||||
->where('APMANIFEST', $params['MANIFEST'])
|
||||
->whereRaw('EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - APLDCLOZ)) / 60 > 15')
|
||||
->orderBy('APMANIFEST')
|
||||
->get();
|
||||
}
|
||||
|
||||
private static function submitManifest(object $record, string $user): JsonResponse
|
||||
{
|
||||
$exitCode = Artisan::call('command:CallCloseAPI', [
|
||||
'user' => $user,
|
||||
'manifest' => $record->APMANIFEST ?? '',
|
||||
'co' => $record->APCO ?? '',
|
||||
'whs' => $record->APWHS ?? '',
|
||||
]);
|
||||
|
||||
if ($exitCode === 1) {
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success',
|
||||
'message' => 'Manifest Closing submitted',
|
||||
]);
|
||||
}
|
||||
|
||||
return self::errorResponse('Manifest Closing Failed');
|
||||
}
|
||||
|
||||
private static function errorResponse(string $message): JsonResponse
|
||||
{
|
||||
return response()->json(['code' => '206', 'status' => 'Error', 'message' => $message]);
|
||||
}
|
||||
}
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class M3Controller extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('m3::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('m3::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('m3::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('m3::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\M3\Models\ICM664M;
|
||||
|
||||
class M3DeliveryController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
$power_user = (object) ['R428PWRUSR' => 'N', 'R428US' => strtoupper(m3_user()), 'R428CO' => '', 'R428PL' => '', 'R428WH' => ''];
|
||||
if (Schema::connection($connection)->hasTable('icm428m')) {
|
||||
$power_user = DB::connection($connection)->table('icm428m')->select('R428PWRUSR', 'R428US', 'R428CO', 'R428PL', 'R428WH')
|
||||
->where('R428US', strtoupper(m3_user()))->first() ?? $power_user;
|
||||
}
|
||||
$co = $power_user->R428CO;
|
||||
$plant = $power_user->R428PL;
|
||||
$whs = $power_user->R428WH;
|
||||
$iCM664M = Schema::connection($connection)->hasTable('icm664m')
|
||||
? DB::connection($connection)->table('icm664m')->where('AVCO', $co)->where('AVPLANT', $plant)->where('AVWHS', $whs)->get() : collect();
|
||||
$iC670M = Schema::connection($connection)->hasTable('ic670m')
|
||||
? DB::connection($connection)->table('ic670m')->where('WDCO', $co)->where('WDPL', $plant)->where('WDWHS', $whs)->get() : collect();
|
||||
$shipvia = Schema::connection($connection)->hasTable('icm319m')
|
||||
? DB::connection($connection)->table('icm319m')->select('AXCODE', 'AXDESC')->orderBy('AXCODE')->get() : collect();
|
||||
|
||||
return view('m3::liberty-theme.pages.M3Delivery', ['ICM664M' => $iCM664M, 'IC670M' => $iC670M, 'power_user' => $power_user, 'shipvia' => $shipvia]);
|
||||
}
|
||||
|
||||
//
|
||||
// Process data from Add modal
|
||||
//
|
||||
public static function saveM3DeliveryAdd(Request $request)
|
||||
{
|
||||
|
||||
$icm664m = DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from ICM664M
|
||||
where AVCO='$request->AVCO' and AVWHS='$request->AVWHS' and AVPLANT='$request->AVPLANT' and AVDELMETH='$request->AVDELMETH'");
|
||||
if ($icm664m[0]->COUNT1 == '1') {
|
||||
return 'exists';
|
||||
} else {
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM664M
|
||||
(AVCO, AVPLANT, AVWHS, AVDELMETH, AVSHPVIA, AVSHSRT, AVSHORCL)
|
||||
values ('$request->AVCO', '$request->AVPLANT', '$request->AVWHS', '$request->AVDELMETH',
|
||||
'$request->AVSHPVIA', '$request->AVSHSRT', '$request->AVSHORCL')");
|
||||
|
||||
return 'success';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Process data from Edit modal
|
||||
//
|
||||
public static function saveM3DeliveryEdit(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
// Update record to ICM664M
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM664M
|
||||
set AVSHPVIA='$request->AVSHPVIA', AVSHSRT='$request->AVSHSRT', AVSHORCL='$request->AVSHORCL'
|
||||
where AVCO='$request->AVCO' and AVPLANT='$request->AVPLANT' and AVWHS='$request->AVWHS' and AVDELMETH='$request->AVDELMETH'");
|
||||
|
||||
return 'success';
|
||||
|
||||
}
|
||||
}
|
||||
+368
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use Datatables;
|
||||
use DB;
|
||||
use Excel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\M3\Services\SpreadsheetExport;
|
||||
use Str;
|
||||
|
||||
class M3ErrorsDispController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$macpkr = isset($request->macpkr) ? trim($request->macpkr) : '';
|
||||
$shsource = isset($request->shsource) ? trim($request->shsource) : '';
|
||||
$showerrors = isset($request->showerrors) ? trim($request->showerrors) : 'N';
|
||||
$skipdates = isset($request->skipdates) ? trim($request->skipdates) : 'N';
|
||||
|
||||
// Get users from ICM428M
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
$iCM428M = Schema::connection($connection)->hasTable('icm428m')
|
||||
? DB::connection($connection)->table('icm428m')->select('R428US', 'R428FIRST', 'R428FAMILY')->get()
|
||||
: collect();
|
||||
$iCM428MCOL = collect($iCM428M);
|
||||
$iCM428MCOL->filter(function ($value) {
|
||||
return $value->R428US = trim($value->R428US);
|
||||
});
|
||||
$iCM428MCOL->filter(function ($value) {
|
||||
return $value->R428FIRST = trim($value->R428FIRST);
|
||||
});
|
||||
$iCM428MCOL->filter(function ($value) {
|
||||
return $value->R428FAMILY = trim($value->R428FAMILY);
|
||||
});
|
||||
|
||||
return view('m3::liberty-theme.pages.M3ErrorsDisplay', ['macpkr' => $macpkr, 'shsource' => $shsource, 'showerrors' => $showerrors, 'skipdates' => $skipdates, 'ICM428MCOL' => $iCM428MCOL]);
|
||||
}
|
||||
|
||||
public function datatables(Request $request)
|
||||
{
|
||||
$this->configureDataTableRuntime();
|
||||
$filters = $this->dataTableFilters($request);
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
|
||||
if (! Schema::connection($connection)->hasTable('icm699m')) {
|
||||
return Datatables::of(collect())->addIndexColumn()->make(true);
|
||||
}
|
||||
|
||||
$profile = $this->findM3Profile($connection, $filters['SHUSER']);
|
||||
$query = $this->buildM3LogQuery($connection);
|
||||
$this->applyM3LogFilters($query, $filters, $profile);
|
||||
|
||||
return Datatables::of($query)->addIndexColumn()->make(true);
|
||||
}
|
||||
|
||||
private function configureDataTableRuntime(): void
|
||||
{
|
||||
$timeout = (string) Config::get('arrays.PHPTimeOut');
|
||||
ini_set('max_execution_time', $timeout);
|
||||
ini_set('max_input_time', $timeout);
|
||||
ini_set('default_socket_timeout', $timeout);
|
||||
ini_set('memory_limit', '1024M');
|
||||
}
|
||||
|
||||
private function dataTableFilters(Request $request): array
|
||||
{
|
||||
return [
|
||||
'SHMACPKR' => trim((string) $request->input('SHMACPKR', '')),
|
||||
'SHSOURCE' => trim((string) $request->input('SHSOURCE', '')),
|
||||
'STARTDATE' => trim((string) $request->input('STARTDATE', today()->subDays(1)->format('Y-m-d'))),
|
||||
'ENDDATE' => trim((string) $request->input('ENDDATE', today()->format('Y-m-d'))),
|
||||
'SHOWERRORS' => trim((string) $request->input('SHOWERRORS', 'N')),
|
||||
'SHUSER' => m3_user() !== '' ? Str::upper(trim(m3_user())) : '',
|
||||
'SKIPDATES' => trim((string) $request->input('SKIPDATES', 'N')),
|
||||
];
|
||||
}
|
||||
|
||||
private function findM3Profile(string $connection, string $user): ?object
|
||||
{
|
||||
if ($user === '' || ! Schema::connection($connection)->hasTable('icm428m')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DB::connection($connection)->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH')
|
||||
->where('R428US', $user)
|
||||
->first();
|
||||
}
|
||||
|
||||
private function buildM3LogQuery(string $connection)
|
||||
{
|
||||
$query = DB::connection($connection)->table('icm699m')
|
||||
->select('ICM699M.*', DB::raw("ICM699M.SHDT || ' ' || ICM699M.SHTIME AS SHDATETIME"))
|
||||
->distinct();
|
||||
|
||||
if (Schema::connection($connection)->hasTable('icm428m')) {
|
||||
$query->addSelect('ICM428M.R428FIRST', 'ICM428M.R428FAMILY')
|
||||
->leftJoin('ICM428M', 'ICM699M.SHUSER', '=', 'ICM428M.R428US');
|
||||
}
|
||||
if (Schema::connection($connection)->hasTable('icm688m1')) {
|
||||
$query->addSelect('ICM688M1.A4ONO', 'ICM688M1.A4SHSHNM')
|
||||
->leftJoin('ICM688M1', 'ICM699M.SHMACPKR', '=', 'ICM688M1.A4MACPKR');
|
||||
}
|
||||
if (Schema::connection($connection)->hasTable('icm666m')) {
|
||||
$query->addSelect('ICM666M.A1ONO', 'ICM666M.A1SHSHNM')
|
||||
->leftJoin('ICM666M', 'ICM699M.SHMACPKR', '=', 'ICM666M.A1DELNO');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
private function applyM3LogFilters($query, array $filters, ?object $profile): void
|
||||
{
|
||||
if ($profile !== null) {
|
||||
$query->whereIn('SHCO', [trim((string) ($profile->R428CO ?? '')), ''])
|
||||
->whereIn('SHWHS', [trim((string) ($profile->R428WH ?? '')), '']);
|
||||
} else {
|
||||
$query->whereNull('SHCO')->whereNull('SHWHS');
|
||||
}
|
||||
|
||||
foreach (['SHMACPKR', 'SHSOURCE'] as $field) {
|
||||
if ($filters[$field] !== '') {
|
||||
$query->where($field, $filters[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
$query->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
if ($filters['SHMACPKR'] === '' && $filters['SKIPDATES'] === 'N') {
|
||||
$query->whereBetween('SHDT', [$filters['STARTDATE'], $filters['ENDDATE']]);
|
||||
}
|
||||
if ($filters['SHOWERRORS'] === 'Y') {
|
||||
$query->where('SHERROR', 'X');
|
||||
}
|
||||
$query->where('SHTYPE', 'like', '%M3%');
|
||||
}
|
||||
|
||||
public static function update699M(Request $request)
|
||||
{
|
||||
$sHMACPKR = $request->SHMACPKR != null ? trim($request->SHMACPKR) : '';
|
||||
$sHSOURCE = $request->SHSOURCE != null ? trim($request->SHSOURCE) : '';
|
||||
$sHCO = $request->SHCO != null ? trim($request->SHCO) : '';
|
||||
$sHWHS = $request->SHWHS != null ? trim($request->SHWHS) : '';
|
||||
$sHDT = $request->SHDT != null ? trim($request->SHDT) : '';
|
||||
$sHTIME = $request->SHTIME != null ? trim($request->SHTIME) : '';
|
||||
$sHTYPE = $request->SHTYPE != null ? trim($request->SHTYPE) : '';
|
||||
$sHACKNOTE = $request->SHACKNOTE != null ? trim(substr($request->SHACKNOTE, 0, 99)) : '';
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(m3_user()) : '';
|
||||
$cLOSESIM = $request->CLOSESIM != null ? trim($request->CLOSESIM) : 'N';
|
||||
|
||||
if ($cLOSESIM == 'N') {
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
|
||||
->where('SHMACPKR', $sHMACPKR)
|
||||
->where('SHDT', $sHDT)
|
||||
->where('SHTIME', $sHTIME)
|
||||
->where('SHCO', $sHCO)
|
||||
->where('SHWHS', $sHWHS)
|
||||
->where('SHSOURCE', $sHSOURCE)
|
||||
->where('SHERROR', 'X')
|
||||
->where('SHTYPE', $sHTYPE)
|
||||
->update(['SHERROR' => 'Z', 'SHACKUSER' => $sHUSER, 'SHACKDATE' => date('Y-m-d'), 'SHACKTIME' => date('H:i:s'), 'SHACKNOTE' => $sHACKNOTE]);
|
||||
|
||||
} else {
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
|
||||
->where('SHCO', $sHCO)
|
||||
->where('SHWHS', $sHWHS)
|
||||
->where('SHSOURCE', $sHSOURCE)
|
||||
->where('SHERROR', 'X')
|
||||
->where('SHTYPE', $sHTYPE)
|
||||
->update(['SHERROR' => 'Z', 'SHACKUSER' => $sHUSER, 'SHACKDATE' => date('Y-m-d'), 'SHACKTIME' => date('H:i:s'), 'SHACKNOTE' => $sHACKNOTE]);
|
||||
}
|
||||
|
||||
if ($sHSOURCE == 'CloseShipmentCoChargeAPI') {
|
||||
// Update ICM688M1 : Change A4PICKSTS
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
|
||||
->where('A4MACPKR', $sHMACPKR)
|
||||
->where('A4CO', $sHCO)
|
||||
->where('A4WHS', $sHWHS)
|
||||
->update(['A4PICKSTS' => 'a']);
|
||||
}
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
// Export To Excel
|
||||
public static function exporttoExcel(Request $request)
|
||||
{
|
||||
self::configureExportRuntime();
|
||||
|
||||
try {
|
||||
$filters = self::exportFiltersFromRequest($request);
|
||||
[$profileUser, $company, $warehouse] = self::exportUserScope($filters['user']);
|
||||
$users = self::exportUsers();
|
||||
[$query, $countQuery] = self::exportQueries();
|
||||
|
||||
self::applyExportFilters($query, $countQuery, [
|
||||
'profileUser' => $profileUser,
|
||||
'company' => $company,
|
||||
'warehouse' => $warehouse,
|
||||
'manifest' => $filters['manifest'],
|
||||
'source' => $filters['source'],
|
||||
'startDate' => $filters['startDate'],
|
||||
'endDate' => $filters['endDate'],
|
||||
'skipDates' => $filters['skipDates'],
|
||||
'showErrors' => $filters['showErrors'],
|
||||
]);
|
||||
|
||||
$limitResponse = self::validateExportCount($countQuery->count());
|
||||
if ($limitResponse !== null) {
|
||||
return $limitResponse;
|
||||
}
|
||||
|
||||
$rows = self::prepareExportRows($query->get(), $users);
|
||||
|
||||
return app(SpreadsheetExport::class)->download(
|
||||
$rows,
|
||||
'transactionLog_' . $filters['startDate'] . '-' . $filters['endDate'] . '.xlsx',
|
||||
);
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
|
||||
return redirect()->back()->withInput()->with('message', 'Unable to export the transaction log.');
|
||||
}
|
||||
}
|
||||
|
||||
private static function configureExportRuntime(): void
|
||||
{
|
||||
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'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
}
|
||||
|
||||
private static function exportFiltersFromRequest(Request $request): array
|
||||
{
|
||||
return [
|
||||
'manifest' => trim((string) $request->input('SHMACPKR', '')),
|
||||
'source' => trim((string) $request->input('SHSOURCE', '')),
|
||||
'startDate' => trim((string) $request->input('STARTDATE', today()->subDays(1)->format('Y-m-d'))),
|
||||
'endDate' => trim((string) $request->input('ENDDATE', today()->format('Y-m-d'))),
|
||||
'showErrors' => trim((string) $request->input('SHOWERRORS', 'N')),
|
||||
'skipDates' => trim((string) $request->input('SKIPDATES', 'N')),
|
||||
'user' => Str::upper(trim(m3_user())),
|
||||
];
|
||||
}
|
||||
|
||||
private static function exportUserScope(string $user): array
|
||||
{
|
||||
$profile = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH')
|
||||
->where('R428US', $user)
|
||||
->first();
|
||||
|
||||
return [
|
||||
trim((string) ($profile->R428US ?? '')),
|
||||
trim((string) ($profile->R428CO ?? '')),
|
||||
trim((string) ($profile->R428WH ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
private static function exportUsers()
|
||||
{
|
||||
return DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428FIRST', 'R428FAMILY')
|
||||
->get()
|
||||
->each(function ($value): void {
|
||||
$value->R428US = trim((string) $value->R428US);
|
||||
$value->R428FIRST = trim((string) $value->R428FIRST);
|
||||
$value->R428FAMILY = trim((string) $value->R428FAMILY);
|
||||
});
|
||||
}
|
||||
|
||||
private static function exportQueries(): array
|
||||
{
|
||||
$query = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
|
||||
->select(
|
||||
DB::raw('COALESCE(ICM688M1.A4ONO, ICM666M.A1ONO) AS DELIVERY_NUM '),
|
||||
'ICM699M.SHMACPKR',
|
||||
DB::raw('COALESCE(ICM688M1.A4SHSHNM, ICM666M.A1SHSHNM) AS CUSTOMER '),
|
||||
DB::raw(" ICM699M.SHDT || ' ' || ICM699M.SHTIME AS SHDATETIME"),
|
||||
DB::raw("CASE WHEN ICM699M.SHERROR !='Z' THEN TRIM(ICM699M.SHERROR) ELSE 'Closed' END AS ERROR"),
|
||||
'ICM699M.SHTYPE',
|
||||
'ICM699M.SHSOURCE',
|
||||
DB::raw("CASE WHEN ICM428M.R428FIRST IS NOT NULL THEN TRIM(ICM428M.R428FIRST) ||' '|| TRIM(ICM428M.R428FAMILY) ELSE TRIM(ICM699M.SHUSER) END AS USER"),
|
||||
'ICM699M.SHCODE',
|
||||
'ICM699M.SHCO',
|
||||
'ICM699M.SHWHS',
|
||||
DB::raw(" ICM699M.SHACKDATE ||' '||ICM699M.SHACKTIME AS ACKDATE"),
|
||||
'ICM699M.SHACKUSER',
|
||||
'ICM699M.SHINTBOX',
|
||||
'ICM699M.SHACKNOTE',
|
||||
DB::raw('SUBSTR(ICM699M.SHDATA, 1, 200)'),
|
||||
)
|
||||
->distinct()
|
||||
->leftJoin('ICM428M', 'ICM699M.SHUSER', '=', 'ICM428M.R428US')
|
||||
->leftJoin('ICM688M1', 'ICM699M.SHMACPKR', '=', 'ICM688M1.A4MACPKR')
|
||||
->leftJoin('ICM666M', 'ICM699M.SHMACPKR', '=', 'ICM666M.A1DELNO');
|
||||
|
||||
return [$query, DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')];
|
||||
}
|
||||
|
||||
private static function validateExportCount(int $count)
|
||||
{
|
||||
$maxRecords = (int) Config::get('arrays.maxRecDL');
|
||||
if ($count <= $maxRecords) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->with(
|
||||
'message',
|
||||
'Maximum allowed records for Excel Download is: ' . number_format($maxRecords)
|
||||
. ' current records: ' . number_format($count) . ' , change your search criteria.',
|
||||
);
|
||||
}
|
||||
|
||||
private static function prepareExportRows($records, $users)
|
||||
{
|
||||
$transactionTypes = Config::get('arrays.transxTypes');
|
||||
$rows = collect($records)->each(function ($value) use ($transactionTypes, $users): void {
|
||||
$source = trim((string) $value->SHSOURCE);
|
||||
$value->SHSOURCE = $transactionTypes[$source] ?? $source;
|
||||
$user = $users->firstWhere('R428US', trim((string) $value->SHACKUSER));
|
||||
$value->SHACKUSER = $user
|
||||
? trim($user->R428FIRST . ' ' . $user->R428FAMILY)
|
||||
: trim((string) $value->SHACKUSER);
|
||||
});
|
||||
|
||||
$rows->prepend([
|
||||
'SHMACPKR' => 'Delivery Note', 'DELIVERY_NUM' => 'Order #', 'CUSTOMER' => 'Customer',
|
||||
'SHDATETIME' => 'Date', 'ERROR' => 'Error', 'SHTYPE' => 'Request Type',
|
||||
'SHSOURCE' => 'Source of transaction', 'USER' => 'User', 'SHCODE' => 'Request or Response Data',
|
||||
'SHCO' => 'Division', 'SHWHS' => 'Warehouse', 'ACKDATE' => 'Acknowledge/Retry Date',
|
||||
'SHACKUSER' => 'Acknowledged/Retried by User', 'SHINTBOX' => 'Internal Box Number',
|
||||
'SHACKNOTE' => 'Note', 'SHDATA' => 'Error description',
|
||||
]);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
private static function applyExportFilters($query, $countQuery, array $filters): void
|
||||
{
|
||||
$queries = [$query, $countQuery];
|
||||
foreach ($queries as $builder) {
|
||||
if ($filters['profileUser'] !== '') {
|
||||
$builder->whereIn('SHCO', [$filters['company'], ''])->whereIn('SHWHS', [$filters['warehouse'], '']);
|
||||
} else {
|
||||
$builder->whereNull('SHCO')->whereNull('SHWHS');
|
||||
}
|
||||
|
||||
if ($filters['manifest'] !== '') {
|
||||
$builder->where('SHMACPKR', $filters['manifest']);
|
||||
}
|
||||
if ($filters['source'] !== '') {
|
||||
$builder->where('SHSOURCE', $filters['source']);
|
||||
}
|
||||
$builder->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
if ($filters['manifest'] === '' && $filters['skipDates'] === 'N') {
|
||||
$builder->whereBetween('SHDT', [$filters['startDate'], $filters['endDate']]);
|
||||
}
|
||||
if ($filters['showErrors'] === 'Y') {
|
||||
$builder->where('SHERROR', 'X');
|
||||
}
|
||||
$builder->where('SHTYPE', 'like', '%M3%');
|
||||
}
|
||||
}
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use File;
|
||||
use Illuminate\Http\Request;
|
||||
use Str;
|
||||
|
||||
class M3GetPDFFromCacheController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
// Parse PDF file and build necessary objects.
|
||||
|
||||
$aggno = $aggmsg = '';
|
||||
$iC670M = $pDFArray = $carrier = $trackingno = $iCM688M1 = [];
|
||||
$aYMACPKR = $wHDDA = $cOMPANY = $pLANT = $wHS = '';
|
||||
|
||||
// PDF File PATH
|
||||
$pdfFilePath = Config::get('arrays.PdfPath');
|
||||
try {
|
||||
// Initialise Vars
|
||||
$pDFArray = $trackingno = $carrier = $iCM688M1 = [];
|
||||
|
||||
$sHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
|
||||
if ($sHUSER != '') {
|
||||
// Get User CO & WH
|
||||
// Get user from ICM428M
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH', 'R428PL')
|
||||
->where('R428US', '=', $sHUSER)
|
||||
->first();
|
||||
|
||||
$cOMPANY = isset($iCM428M->R428CO) ? $iCM428M->R428CO : ''; // Company
|
||||
$pLANT = isset($iCM428M->R428PL) ? $iCM428M->R428PL : ''; // Plant
|
||||
$wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : ''; // WareHouse
|
||||
}
|
||||
|
||||
// Warehouse Table
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
// ->where('WDCO',$userCO)->where('WDPL',$userPL)->where('WDWHS',$userWH)
|
||||
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
// dump($urlParams);
|
||||
$aYMACPKR = isset($urlParams['MACPKR']) ? trim($urlParams['MACPKR']) : ''; // Delivery note number
|
||||
$dOCTYPE = isset($urlParams['DOCTYPE']) ? trim($urlParams['DOCTYPE']) : ''; // Document type (PackingList, CarrierLabel, ContentLabel)
|
||||
$wHDDA = $cOMPANY . $pLANT . $wHS;
|
||||
|
||||
// Check Doctype fisrt
|
||||
$docTypes = $dOCTYPE != '' ? [$dOCTYPE] : ['PackingList', 'ContentLabel', 'CarrierLabel', 'GSLabel']; // document type (PackingList, CarrierLabel, ContentLabel)
|
||||
|
||||
if ($urlParams != '') {
|
||||
// dump($urlParams);
|
||||
// document number (ie the internal box number, the pick list number)
|
||||
// Key Combination : COMPANY WHS A4MACPKR DOCTYPE DOCNUM
|
||||
// Document type (PackingList, CarrierLabel, ContentLabel)
|
||||
|
||||
// Get Aggregation Number if it exists
|
||||
$iCM695M1Agg = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
||||
->select('AYTRUCK')
|
||||
->where('AYCO', $cOMPANY)
|
||||
->where('AYWHS', $wHS)
|
||||
->where('AYMACPKR', $aYMACPKR)
|
||||
->first();
|
||||
$aggno = isset($iCM695M1Agg->AYTRUCK) ? trim($iCM695M1Agg->AYTRUCK) : '';
|
||||
|
||||
if ($aggno != '' && $aggno != '0') {
|
||||
|
||||
$aggmsg = "This delivery note is part of aggregation $aggno ";
|
||||
$iCM688M1 = DB::connection(config('m3.connection', 'pgsql'))->select("select A4MACPKR from ICM688M1 where A4SHPAGGCD='$aggno'");
|
||||
|
||||
// 654 add 'AYSPR15A01', 'AYSPR30A01', 'AYTRUCK' carrier and tracking# and agg#
|
||||
$iCM695M1 = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
||||
->select('AYCO', 'AYWHS', 'AYMACPKR', 'AYINTBOX', 'AYSPR15A01', 'AYSPR30A01', 'AYTRUCK')
|
||||
->distinct()
|
||||
->where('AYCO', $cOMPANY)
|
||||
->where('AYWHS', $wHS)
|
||||
// ->where('AYMACPKR',$aYMACPKR)
|
||||
->where('AYTRUCK', $aggno)
|
||||
->orderBy('AYMACPKR')
|
||||
->get();
|
||||
} else {
|
||||
// 654 add 'AYSPR15A01', 'AYSPR30A01', 'AYTRUCK' carrier and tracking# and agg#
|
||||
$iCM695M1 = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
||||
->select('AYCO', 'AYWHS', 'AYMACPKR', 'AYINTBOX', 'AYSPR15A01', 'AYSPR30A01', 'AYTRUCK')
|
||||
->distinct()
|
||||
->where('AYCO', $cOMPANY)
|
||||
->where('AYWHS', $wHS)
|
||||
->where('AYMACPKR', $aYMACPKR)
|
||||
->orderBy('AYMACPKR')
|
||||
->get();
|
||||
}
|
||||
|
||||
if (count($iCM695M1) > 0) {
|
||||
$tmpCacheArr = $carrier = $trackingno = [];
|
||||
// Loop the Results from $ICM595M1TMP
|
||||
foreach ($iCM695M1 as $ICM695M1R) {
|
||||
$wHS = trim($ICM695M1R->AYWHS);
|
||||
$cOMPANY = trim($ICM695M1R->AYCO);
|
||||
$aYMACPKR = trim($ICM695M1R->AYMACPKR);
|
||||
$dOCNUM = trim($ICM695M1R->AYINTBOX);
|
||||
// 654
|
||||
$carrier[] = trim($ICM695M1R->AYSPR15A01);
|
||||
$trackingno[] = trim($ICM695M1R->AYSPR30A01);
|
||||
$aggno = trim($ICM695M1R->AYTRUCK);
|
||||
|
||||
// Make Key and Test Validity
|
||||
if ($aYMACPKR != '' && $cOMPANY != '' && $wHS != '') {
|
||||
$contentLabel = '';
|
||||
|
||||
// Get Unique Keys
|
||||
foreach ($docTypes as $value) {
|
||||
// Check Parcel vs LTL
|
||||
if ($value == 'ContentLabel') {
|
||||
$dOCNUMT = $dOCNUM;
|
||||
$contentLabel = ! is_numeric($dOCNUM) ? 'LTL' : '';
|
||||
}
|
||||
|
||||
if ($value == 'CarrierLabel') {
|
||||
$dOCNUMT = $dOCNUM;
|
||||
|
||||
// Keep Solon Logic to read LTL
|
||||
$dOCNUMT2 = $contentLabel == 'LTL' ? $aYMACPKR : $dOCNUM;
|
||||
if ($dOCNUMT2 != $dOCNUMT) {
|
||||
$pDFKey2 = $value . '/' . $value . '_' . $aYMACPKR . '_' . $dOCNUMT2 . '_' . $cOMPANY . '_' . $wHS;
|
||||
$tmpCacheArr[] = $pDFKey2;
|
||||
}
|
||||
}
|
||||
|
||||
if ($value == 'PackingList') {
|
||||
$dOCNUMT = $aYMACPKR;
|
||||
}
|
||||
|
||||
// Get GS1 Labels
|
||||
if ($value == 'GSLabel') {
|
||||
$pDFKey = $value . '/' . $value . '_' . $aYMACPKR . '_' . $cOMPANY . '_' . $wHS . '_' . $dOCNUM;
|
||||
|
||||
// $pDFKey = $value.'/'.$value.'_'.$aYMACPKR.'_'.$cOMPANY.'_'.$wHS;
|
||||
// }
|
||||
// else{
|
||||
// $pDFKey = $value.'/'.$value.'_'.$aYMACPKR.'_'.$cOMPANY.'_'.$wHS.'_'.$dOCNUM;
|
||||
// }
|
||||
} else {
|
||||
$pDFKey = $value . '/' . $value . '_' . $aYMACPKR . '_' . $dOCNUMT . '_' . $cOMPANY . '_' . $wHS;
|
||||
}
|
||||
$tmpCacheArr[] = $pDFKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get unique values from array $pDFArray
|
||||
$tmpCacheArr = collect($tmpCacheArr)->unique();
|
||||
foreach ($tmpCacheArr as $value) {
|
||||
|
||||
$pdfFileName = $pdfFilePath . $value . '.pdf';
|
||||
if (File::exists($pdfFileName)) {
|
||||
|
||||
$pdfFile = File::get($pdfFileName);
|
||||
// Transform content to base64
|
||||
// $base64PDF = $pdfFile;
|
||||
$base64PDF = base64_encode($pdfFile);
|
||||
$pDFArray[] = $base64PDF;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Nothing Found
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.M3GetPDF', ['IC670M' => $iC670M, 'PDFArray' => $pDFArray, 'AYMACPKR' => $aYMACPKR, 'WHDDA' => $wHDDA, 'aggmsg' => $aggmsg, 'carrier' => $carrier, 'trackingno' => $trackingno, 'ICM688M1' => $iCM688M1, 'COMPANY' => $cOMPANY, 'PLANT' => $pLANT, 'WHS' => $wHS]);
|
||||
// compact('IC670M','ViewTitle')
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class MFOrdersController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$mF = isset($request->id) ? trim($request->id) : '';
|
||||
|
||||
// dd("MFOrders ".$mF);
|
||||
// Get Users from ICM428M
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH', 'R428PL')
|
||||
->where('R428US', '=', strtoupper(m3_user()))
|
||||
->first();
|
||||
$co = $iCM428M->R428CO;
|
||||
$whs = $iCM428M->R428WH;
|
||||
$plant = $iCM428M->R428PL;
|
||||
|
||||
// ICM705M1 Statement
|
||||
$sqlstmt = "select APMANIFEST,APDOCKDOOR,APCARRIER,APTRUCKIDT,APSPARE1,APLDSTRU,APLDSTRD,APLDSTRT,
|
||||
APLDCLOU,APLDCLOD,APLDCLOT,APCO,APWHS,APPLT,APSPARE2,APLDCLOZ
|
||||
from ICM705M1
|
||||
where APMANIFEST = $mF and APCO='$co' and APWHS='$whs' and APPLT='$plant' limit 1";
|
||||
|
||||
$iCM705M1 = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
$carrier = isset($iCM705M1[0]->APCARRIER) ? trim($iCM705M1[0]->APCARRIER) : '';
|
||||
|
||||
if ($mF != '') {
|
||||
$status_ICM688M1_array = Config::get('arrays.status_ICM688M1_array');
|
||||
|
||||
$sqlstmt = "SELECT AYCO,AYPLANT,AYMACPKR,AYONO,A4SHSHNM,A4PICKSTS,AYSPR15A01,SUM(AYLNWGHT) AS TOTWEIGHT,COUNT(*) AS BOXPAL FROM ICM695M1
|
||||
LEFT JOIN ICM688M1 ON AYCO=A4CO AND AYPLANT=A4PLANT AND AYMACPKR=A4MACPKR
|
||||
WHERE AYAPRF1551= $mF and AYCO='$co' and AYWHS='$whs' and AYPLANT='$plant'
|
||||
GROUP BY AYCO,AYPLANT,AYMACPKR,AYONO,A4SHSHNM,A4PICKSTS,AYSPR15A01";
|
||||
|
||||
$iCM695M1 = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
|
||||
return view(
|
||||
'm3::liberty-theme.pages.MFOrders',
|
||||
['ICM695M1' => $iCM695M1, 'status_ICM688M1_array' => $status_ICM688M1_array, 'MF' => $mF, 'carrier' => $carrier],
|
||||
);
|
||||
} else {
|
||||
abort(404, 'Manifest Not Found');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Excel;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Modules\M3\Services\SpreadsheetExport;
|
||||
use Storage;
|
||||
use Str;
|
||||
|
||||
class OrderLinesOfClosedOrder extends Controller
|
||||
{
|
||||
private const XLSX_EXTENSION = '.xlsx';
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$iC670M = $iCM688M2 = [];
|
||||
$rEPORTDATEDisp = today()->format('Ymd');
|
||||
$allReportsUrls = [];
|
||||
try {
|
||||
[$cOMPANY, $pLANT, $wHS] = self::userWarehouseContext('110', '144', '322');
|
||||
|
||||
// Warehouse Table
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$rEPORTDATEDisp = isset($urlParams['REPORTDATEDisp']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['REPORTDATEDisp']))->format('Ymd') : today()->format('Ymd');
|
||||
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,
|
||||
A5PMPWHT*A5PACKED AS WEIGHT,
|
||||
(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,
|
||||
A4SHIPTYPE,
|
||||
A4SHIPVIA1,
|
||||
A4SCAC,
|
||||
A4OFSTRM
|
||||
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
|
||||
LEFT JOIN ICM688M1 ON A4MACPKR=A5MACPKR
|
||||
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";
|
||||
|
||||
$iCM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select($selectContent);
|
||||
} else {
|
||||
$iCM688M2 = collect();
|
||||
}
|
||||
|
||||
// Get List of Files
|
||||
$allReportsUrls = self::reportUrls($wHS);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.OrderLinesOfClosed', ['IC670M' => $iC670M, 'ICM688M2' => $iCM688M2, 'WHDDA' => $wHDDA, 'COMPANY' => $cOMPANY, 'PLANT' => $pLANT, 'WHS' => $wHS, 'REPORTDATEDisp' => $rEPORTDATEDisp, 'allReportsUrls' => $allReportsUrls]);
|
||||
}
|
||||
|
||||
public static function exporttoExcel(Request $request)
|
||||
{
|
||||
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'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
[$cOMPANY, $pLANT, $wHS] = self::userWarehouseContext();
|
||||
|
||||
// Warehouse Table
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$reportDate = isset($urlParams['REPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['REPORTDATE']))->format('Ymd') : today()->format('Ymd');
|
||||
$toreportDate = isset($urlParams['TOREPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['TOREPORTDATE']))->format('Ymd') : today()->format('Ymd');
|
||||
|
||||
$reportDateWD = isset($urlParams['REPORTDATE']) ? trim($urlParams['REPORTDATE']) : today()->format('Y-m-d');
|
||||
$toreportDateWD = isset($urlParams['TOREPORTDATE']) ? trim($urlParams['TOREPORTDATE']) : today()->format('Y-m-d');
|
||||
if ($reportDate != '' && $cOMPANY != '' && $wHS != '' && $pLANT != '') {
|
||||
// Case 729: Add Currency code A1SHCURR FROM ICM666M
|
||||
$selectContent = "
|
||||
SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO,
|
||||
A4OFSTRM,
|
||||
A5PMPWHT*A5PACKED AS WEIGHT,
|
||||
A4SCAC,
|
||||
A4SHIPTYPE,
|
||||
(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 ,
|
||||
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
|
||||
LEFT JOIN ICM688M1 ON A4MACPKR=A5MACPKR
|
||||
WHERE A5MACPKR IN (
|
||||
SELECT DISTINCT AYMACPKR
|
||||
FROM ICM695M1
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 BETWEEN $reportDate AND $toreportDate
|
||||
)
|
||||
AND A5CO=$cOMPANY AND A5WHS=$wHS AND A5PLANT=$pLANT";
|
||||
|
||||
$iCM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select($selectContent);
|
||||
|
||||
$newItem = ['DATECLOSED' => 'Close Date', 'A5MACPKR' => 'Delivery #', 'A5ONO' => 'Order #',
|
||||
'A4OFSTRM' => 'Terms', 'WEIGHT' => 'Weight', 'A4SCAC' => 'Carrier', 'A4SHIPTYPE' => 'Mode (Parcel, Air, TL or LTL)',
|
||||
'A4REFORD' => 'Order Type', 'A5PART' => 'Part #', 'A5RSVQTY' => 'Reserved',
|
||||
'A5PACKED' => 'Packed', 'CALCULATED_COLUMN' => 'Back Order Qty', 'ANOTHER_CALCULATED_COLUMN' => 'Value Packed $', 'A4SHSHNM' => 'Customer name',
|
||||
'REASON' => 'Failure Reason', 'A1SHCURR' => 'Currency Code', 'FREIGHT' => 'Freight'];
|
||||
$iCM688M2Col = collect($iCM688M2);
|
||||
$iCM688M2Col->prepend($newItem);
|
||||
|
||||
// Count records before exporting to excel : Max 20K records are allowed
|
||||
$iCM688M2Count = $iCM688M2Col->count();
|
||||
// Set Max allowed records
|
||||
$maxRecords = Config::get('arrays.maxRecCL');
|
||||
if ($iCM688M2Count > $maxRecords) {
|
||||
return redirect()->back()->withInput()->with('message', 'Maximum allowed records for Excel Download is: ' . number_format($maxRecords) .
|
||||
' current records: ' . number_format($iCM688M2Count) . ' , change your search criteria.');
|
||||
}
|
||||
|
||||
} else {
|
||||
$iCM688M2Col = '';
|
||||
}
|
||||
|
||||
// Download Excel
|
||||
// Add true at the end to include fields names in the Header
|
||||
return app(SpreadsheetExport::class)->download($iCM688M2Col, 'Closedorderlinesreport_' . $reportDateWD . '-' . $toreportDateWD . self::XLSX_EXTENSION);
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
}
|
||||
|
||||
public static function StoreExcelToDisk(Request $request)
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
[$cOMPANY, $pLANT, $wHS] = self::userWarehouseContext();
|
||||
|
||||
// Warehouse Table
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$reportDate = isset($urlParams['REPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['REPORTDATE']))->format('Ymd') : today()->format('Ymd');
|
||||
$toreportDate = isset($urlParams['TOREPORTDATE']) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams['TOREPORTDATE']))->format('Ymd') : today()->format('Ymd');
|
||||
$reportDateWD = isset($urlParams['REPORTDATE']) ? trim($urlParams['REPORTDATE']) : today()->format('Y-m-d');
|
||||
$toreportDateWD = isset($urlParams['TOREPORTDATE']) ? trim($urlParams['TOREPORTDATE']) : today()->format('Y-m-d');
|
||||
if ($reportDate != '' && $cOMPANY != '' && $wHS != '' && $pLANT != '') {
|
||||
// Case 729: Add Currency code A1SHCURR FROM ICM666M
|
||||
$iCM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select("
|
||||
SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO,
|
||||
A4OFSTRM,
|
||||
A5PMPWHT*A5PACKED AS WEIGHT,
|
||||
A4SCAC,
|
||||
A4SHIPTYPE,
|
||||
(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 ,
|
||||
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
|
||||
LEFT JOIN ICM688M1 ON A4MACPKR=A5MACPKR
|
||||
WHERE A5MACPKR IN (
|
||||
SELECT DISTINCT AYMACPKR
|
||||
FROM ICM695M1
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 BETWEEN $reportDate AND $toreportDate
|
||||
)
|
||||
AND A5CO=$cOMPANY AND A5WHS=$wHS AND A5PLANT=$pLANT
|
||||
");
|
||||
|
||||
$newItem = ['DATECLOSED' => 'Close Date', 'A5MACPKR' => 'Delivery #', 'A5ONO' => 'Order #',
|
||||
'A4OFSTRM' => 'Terms', 'WEIGHT' => 'Weight', 'A4SCAC' => 'Carrier', 'A4SHIPTYPE' => 'Mode (Parcel, Air, TL or LTL)',
|
||||
'A4REFORD' => 'Order Type', 'A5PART' => 'Part #', 'A5RSVQTY' => 'Reserved',
|
||||
'A5PACKED' => 'Packed', 'CALCULATED_COLUMN' => 'Back Order Qty', 'ANOTHER_CALCULATED_COLUMN' => 'Value Packed $', 'A4SHSHNM' => 'Customer name',
|
||||
'REASON' => 'Failure Reason', 'A1SHCURR' => 'Currency Code', 'FREIGHT' => 'Freight'];
|
||||
$iCM688M2Col = collect($iCM688M2);
|
||||
$iCM688M2Col->prepend($newItem);
|
||||
|
||||
// Count records before exporting to excel : Max 20K records are allowed
|
||||
$iCM688M2Count = $iCM688M2Col->count();
|
||||
// Set Max allowed records
|
||||
$maxRecords = Config::get('arrays.maxRecCL');
|
||||
if ($iCM688M2Count > $maxRecords) {
|
||||
return redirect()->back()->withInput()->with('message', 'Maximum allowed records for Excel Download is: ' . number_format($maxRecords) .
|
||||
' current records: ' . number_format($iCM688M2Count) . ' , change your search criteria.');
|
||||
}
|
||||
} else {
|
||||
$iCM688M2Col = '';
|
||||
}
|
||||
|
||||
$prevMonthFile = self::storedReportName($wHS, $reportDateWD, $toreportDateWD);
|
||||
|
||||
// MAK Store the File to Storage
|
||||
app(SpreadsheetExport::class)->store($iCM688M2Col, $prevMonthFile, 'publicCL');
|
||||
|
||||
return back();
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
}
|
||||
|
||||
private static function userWarehouseContext(string $defaultCompany = '', string $defaultPlant = '', string $defaultWarehouse = ''): array
|
||||
{
|
||||
$user = trim((string) m3_user());
|
||||
if ($user === '') {
|
||||
return [$defaultCompany, $defaultPlant, $defaultWarehouse];
|
||||
}
|
||||
|
||||
$profile = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428CO', 'R428WH', 'R428PL')
|
||||
->where('R428US', Str::upper($user))
|
||||
->first();
|
||||
|
||||
return [
|
||||
$profile->R428CO ?? $defaultCompany,
|
||||
$profile->R428PL ?? $defaultPlant,
|
||||
$profile->R428WH ?? $defaultWarehouse,
|
||||
];
|
||||
}
|
||||
|
||||
private static function reportUrls(string $warehouse): array
|
||||
{
|
||||
$disk = Storage::disk('publicCL');
|
||||
$files = $warehouse === '321' ? $disk->files() : $disk->allFiles($warehouse);
|
||||
$urls = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$urls[$file] = $disk->url($file);
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
private static function storedReportName(string $warehouse, string $from, string $to): string
|
||||
{
|
||||
$name = 'Closedorderlinesreport_' . $from . '-' . $to;
|
||||
|
||||
return $warehouse === '321'
|
||||
? $name . self::XLSX_EXTENSION
|
||||
: $warehouse . '/' . $name . '-' . $warehouse . self::XLSX_EXTENSION;
|
||||
}
|
||||
|
||||
// Download File
|
||||
public static function downloadFiles(Request $request)
|
||||
{
|
||||
$fileName = $request->filename;
|
||||
if (Storage::disk('publicCL')->exists($fileName)) {
|
||||
// File exists, retrieve content or URL
|
||||
// $content = Storage::disk('publicCL')->get($fileName);
|
||||
$fileNameOnly = strpos($fileName, '/') != false ? substr($fileName, strpos($fileName, '/') + 1) : $fileName;
|
||||
|
||||
// Download the file
|
||||
return Storage::disk('publicCL')->download($fileName, $fileNameOnly);
|
||||
} else {
|
||||
// Download the file (use code below)
|
||||
}
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\M3\Models\ICM709M;
|
||||
|
||||
class PalletQtyController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
$power_user = (object) ['R428PWRUSR' => 'N', 'R428US' => strtoupper(m3_user()), 'R428CO' => '', 'R428PL' => '', 'R428WH' => ''];
|
||||
if (Schema::connection($connection)->hasTable('icm428m')) {
|
||||
$power_user = DB::connection($connection)->table('icm428m')
|
||||
->select('R428PWRUSR', 'R428US', 'R428CO', 'R428PL', 'R428WH')
|
||||
->where('R428US', '=', strtoupper(m3_user()))->first() ?? $power_user;
|
||||
}
|
||||
$co = $power_user->R428CO;
|
||||
$plant = $power_user->R428PL;
|
||||
$whs = $power_user->R428WH;
|
||||
$iCM709M = Schema::connection($connection)->hasTable('icm709m')
|
||||
? DB::connection($connection)->table('icm709m')->where('AT9CO', $co)->where('AT9PLT', $plant)->where('AT9WHS', $whs)->get() : collect();
|
||||
$iC670M = Schema::connection($connection)->hasTable('ic670m')
|
||||
? DB::connection($connection)->table('ic670m')->where('WDCO', $co)->where('WDPL', $plant)->where('WDWHS', $whs)->get() : collect();
|
||||
|
||||
return view('m3::liberty-theme.pages.palletQty', ['ICM709M' => $iCM709M, 'IC670M' => $iC670M, 'power_user' => $power_user]);
|
||||
}
|
||||
|
||||
//
|
||||
// Process data from Add modal
|
||||
//
|
||||
public static function saveQtyAdd(Request $request)
|
||||
{
|
||||
|
||||
// Insert record to ICM709M
|
||||
// var_dump($request);
|
||||
// Verify record does not already exist in ICM709M
|
||||
$icm709m = DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from ICM709M
|
||||
where AT9CO='$request->AT9CO' and AT9PLT='$request->AT9PLT' and AT9WHS='$request->AT9WHS' and AT9PART='$request->AT9PART'");
|
||||
if ($icm709m[0]->COUNT1 >= '1') {
|
||||
return 'exists';
|
||||
} else {
|
||||
// Verify Part# already exists in ICM630M
|
||||
$ic630m = DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from IC630M
|
||||
where LLCO='$request->AT9CO' and LLWHNO='$request->AT9WHS' and LLPPN='$request->AT9PART'");
|
||||
if ($ic630m[0]->COUNT1 == '0') {
|
||||
return 'not exist';
|
||||
} else {
|
||||
DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM709M (AT9CO, AT9PLT, AT9WHS, AT9PART, AT9QTY, AT9WRN)
|
||||
values ('$request->AT9CO', '$request->AT9PLT', '$request->AT9WHS', '$request->AT9PART', '$request->AT9QTY', '$request->AT9WRN')");
|
||||
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveQtyAdd2(Request $request)
|
||||
{
|
||||
|
||||
// Insert record to ICM709M
|
||||
// var_dump($request);
|
||||
// Verify record does not already exist in ICM709M
|
||||
// DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM709M (AT9CO, AT9PLT, AT9WHS, AT9PART, AT9QTY)
|
||||
// values ('$request->AT9CO', '$request->AT9PLT', '$request->AT9WHS', '$request->AT9PART', '$request->AT9QTY')");
|
||||
// $data=['AT9CO'=>$request->AT9CO, 'AT9PLT'=>$request->AT9PLT, 'AT9WHS'=>$request->AT9WHS, 'AT9PART'=>$request->AT9PART,
|
||||
// 'AT9QTY'=>$request->AT9QTY, 'AT9WRN'=>$request->AT9WRN];
|
||||
// $insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')->insert($data);
|
||||
DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM709M (AT9CO, AT9PLT, AT9WHS, AT9PART, AT9QTY, AT9WRN)
|
||||
values ('$request->AT9CO', '$request->AT9PLT', '$request->AT9WHS', '$request->AT9PART', '$request->AT9QTY', '$request->AT9WRN')");
|
||||
|
||||
// if($insertSQL) {
|
||||
return 'success';
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Process data from Edit modal
|
||||
//
|
||||
public static function saveQtyEdit(Request $request)
|
||||
{
|
||||
|
||||
// where AT9CO='$request->AT9CO' and AT9PLT='$request->AT9PLT' and AT9WHS='$request->AT9WHS' and AT9PART='$request->AT9PART'");
|
||||
// var_dump($icm709m);
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM709M
|
||||
set AT9QTY='$request->AT9QTY', AT9WRN='$request->AT9WRN'
|
||||
where AT9CO='$request->AT9CO' and AT9PLT='$request->AT9PLT' and AT9WHS='$request->AT9WHS' and AT9PART='$request->AT9PART'");
|
||||
|
||||
return 'success';
|
||||
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
// 732
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class PendingClosureController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
// Get Users from ICM428M
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH', 'R428PL')
|
||||
->where('R428US', '=', strtoupper(m3_user()))
|
||||
->first();
|
||||
$user = $iCM428M->R428US;
|
||||
$co = $iCM428M->R428CO;
|
||||
$whs = $iCM428M->R428WH;
|
||||
$plant = $iCM428M->R428PL;
|
||||
|
||||
// ICM705M1 Statement
|
||||
$sqlstmt = "select APMANIFEST,APDOCKDOOR,APCARRIER,APTRUCKIDT,APSPARE1,APLDSTRU,APLDSTRD,APLDSTRT,
|
||||
APLDCLOU,APLDCLOD,APLDCLOT,APCO,APWHS,APPLT,APSPARE2,APLDCLOZ
|
||||
from ICM705M1
|
||||
where APSPARE2 in ('','P') and APCO='$co' and APWHS='$whs' and APPLT='$plant'";
|
||||
|
||||
$iCM705M1 = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
|
||||
$iCM698Ma = [];
|
||||
$iCM699Ma = [];
|
||||
foreach ($iCM705M1 as $val) {
|
||||
$sqlstmt1 = "select LGUSER,LGCONFDT,LGCONFTM
|
||||
from ICM698M
|
||||
where LGCO='$val->APCO' and LGWHS='$val->APWHS'and LGURL='op605api.php'
|
||||
and LGRESPONSE like 'Close of Sentinel Manifest%'
|
||||
and LGRESPONSE like '%' || right('000000000' || '$val->APMANIFEST',9) || '%'";
|
||||
$iCM698M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt1);
|
||||
$iCM698Ma[$val->APMANIFEST]['TMSUSER'] = '';
|
||||
$iCM698Ma[$val->APMANIFEST]['TMSDATE'] = '';
|
||||
$iCM698Ma[$val->APMANIFEST]['TMSTIME'] = '';
|
||||
foreach ($iCM698M as $val2) {
|
||||
$iCM698Ma[$val->APMANIFEST]['TMSUSER'] = $val2->LGUSER;
|
||||
$iCM698Ma[$val->APMANIFEST]['TMSDATE'] = $val2->LGCONFDT;
|
||||
$iCM698Ma[$val->APMANIFEST]['TMSTIME'] = $val2->LGCONFTM;
|
||||
}
|
||||
|
||||
$iCM699MSel1 = "select SHMACPKR,SHDT,SHTIME from ICM699M
|
||||
WHERE SHMACPKR='$val->APMANIFEST' AND SHCO='$co' AND SHWHS='$whs'
|
||||
AND SHSOURCE='CloseShipmentCoChargeAPI' AND SHERROR='' AND SHTYPE='M3-Req-out' limit 1";
|
||||
$iCM699MSel = DB::connection(config('m3.connection', 'pgsql'))->select($iCM699MSel1);
|
||||
foreach ($iCM699MSel as $val2) {
|
||||
$iCM699Ma[$val2->SHMACPKR]['SHDT'] = $val2->SHDT;
|
||||
$iCM699Ma[$val2->SHMACPKR]['SHTIME'] = $val2->SHTIME;
|
||||
}
|
||||
}
|
||||
|
||||
$sqlstmt = "select count(*) as COUNT1 from ICM699M
|
||||
where SHCO='$co' and SHWHS='$whs' and SHTYPE like '%M3%' and SHERROR='X'
|
||||
and SHSOURCE='CloseShipmentCoChargeAPI'";
|
||||
$iCM699M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
|
||||
// Get Unprocessed Orders
|
||||
$unprocessedArr = [];
|
||||
$sqlstmt3 = "WITH TEMPFILE AS (
|
||||
SELECT A4MACPKR,A4SPKRFUD,(SELECT AYAPRF1551 FROM ICM695M1 WHERE AYMACPKR=A4MACPKR AND AYSLWHS='$whs' FETCH FIRST 1 ROWS ONLY) AS MF FROM ICM688M1
|
||||
WHERE A4PICKSTS='B' AND A4WHS='$whs' ORDER BY A4SPKRFUD
|
||||
)
|
||||
SELECT APMANIFEST,APSPARE2 FROM ICM705M1 WHERE APMANIFEST IN (SELECT DISTINCT MF FROM TEMPFILE) AND APSPARE2='X' AND APWHS='$whs' ";
|
||||
// AND APSPARE2!=''
|
||||
// dump($sqlstmt3);
|
||||
$uproccessedOrders = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt3);
|
||||
foreach ($uproccessedOrders as $UproccessedOrder) {
|
||||
$unprocessedArr[] = '<a class="btn btn-link mb-1" target="_blank" href="' . url('MFOrders', ['id' => trim($UproccessedOrder->APMANIFEST)]) . '"> ' .
|
||||
trim($UproccessedOrder->APMANIFEST) . '</a>';
|
||||
}
|
||||
|
||||
return view(
|
||||
'm3::liberty-theme.pages.pendingClosure',
|
||||
['ICM705M1' => $iCM705M1, 'ICM698Ma' => $iCM698Ma, 'ICM699M' => $iCM699M, 'user' => $user, 'request' => $request, 'unprocessedArr' => $unprocessedArr, 'ICM699Ma' => $iCM699Ma],
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public static function allowRetry(Request $request)
|
||||
{
|
||||
// Get URL PARAMS
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$mANIFEST = isset($urlParams['MANIFEST']) ? $urlParams['MANIFEST'] : '';
|
||||
$aPCO = isset($urlParams['APCO']) ? $urlParams['APCO'] : '';
|
||||
$aPWHS = isset($urlParams['APWHS']) ? $urlParams['APWHS'] : '';
|
||||
|
||||
try {
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->where('APCO', $aPCO)
|
||||
->where('APWHS', $aPWHS)
|
||||
->where('APMANIFEST', '=', $mANIFEST)
|
||||
->update(['APSPARE2' => '']);
|
||||
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success',
|
||||
'message' => 'Manifest Closing submitted',
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use Datatables;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\M3\Models\ICM658M;
|
||||
|
||||
class ReplenishSettingsController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
// Replenishment Table
|
||||
// $rEFCAT658 = DB::connection(config('m3.connection', 'pgsql'))->table('icm658m')->get();
|
||||
// Warehouse Table
|
||||
// $iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// Get Logged user Id
|
||||
$userId = m3_user() !== '' ? strtoupper(m3_user()) : '';
|
||||
// $userId = 'E1135818'; // Brad : E1135818 Malak : E2011812 ACOM_PDF
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
$iCM428M = Schema::connection($connection)->hasTable('icm428m')
|
||||
? DB::connection($connection)->table('icm428m')->where('R428US', $userId)->where('R428STS', 'A')->first()
|
||||
: null;
|
||||
|
||||
$userCO = isset($iCM428M->R428CO) ? $iCM428M->R428CO : '';
|
||||
$userPL = isset($iCM428M->R428PL) ? $iCM428M->R428PL : '';
|
||||
$userWH = isset($iCM428M->R428WH) ? $iCM428M->R428WH : '';
|
||||
|
||||
if ($userCO != '') {
|
||||
// Warehouse Table
|
||||
$iC670M = Schema::connection($connection)->hasTable('ic670m')
|
||||
? DB::connection($connection)->table('ic670m')
|
||||
->where('WDCO', $userCO)
|
||||
->where('WDPL', $userPL)
|
||||
->where('WDWHS', $userWH)
|
||||
->get()
|
||||
: [];
|
||||
} else {
|
||||
$iC670M = [];
|
||||
}
|
||||
|
||||
// FROM PRDAT.REFERPS t1 LEFT JOIN ( SELECT R658CO,R658PL,R658WH,R658LC,R658PN,R658MQ,R658RQ,R658TL,R658RMQ,
|
||||
// TRIM(R658WH)||TRIM(R658LC)||TRIM(R658PN) AS FULLID FROM EWOBJTST.ICM658M
|
||||
// ) t2 ON t1.REFKEY = t2.FULLID WHERE t1.REFCAT = '658'";
|
||||
// $rEFCAT658 = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
// dd($rEFCAT658);
|
||||
|
||||
return view('m3::liberty-theme.pages.ReplenishSettings', ['IC670M' => $iC670M]);
|
||||
// 'REFCAT658',
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
$formInputs = $request->all();
|
||||
$formInputs = array_filter($formInputs);
|
||||
unset($formInputs['_token']);
|
||||
|
||||
$formInputs['R658IZLCF'] = isset($formInputs['R658IZLCF']) ? $formInputs['R658IZLCF'] : '0';
|
||||
|
||||
ICM658M::insert($formInputs);
|
||||
|
||||
return redirect()->route('m3.replenishmentSettings.index');
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$r658PN = trim((string) ($request->R658PN ?? ''));
|
||||
$r658CO = trim((string) ($request->R658CO ?? ''));
|
||||
$r658PL = trim((string) ($request->R658PL ?? ''));
|
||||
$r658WH = trim((string) ($request->R658WH ?? ''));
|
||||
$r658MQ = trim($request->R658MQ);
|
||||
$r658RQ = trim($request->R658RQ);
|
||||
$r658RMQ = trim($request->R658RMQ);
|
||||
$r658TL = trim($request->R658TL);
|
||||
$r658IZLCF = trim((string) ($request->R658IZLCF ?? '0'));
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm658m')
|
||||
->where('R658PN', $r658PN)
|
||||
->where('R658CO', $r658CO)
|
||||
->where('R658PL', $r658PL)
|
||||
->where('R658WH', $r658WH)
|
||||
->update(['R658MQ' => $r658MQ, 'R658RQ' => $r658RQ, 'R658RMQ' => $r658RMQ, 'R658TL' => $r658TL, 'R658IZLCF' => $r658IZLCF]);
|
||||
|
||||
return redirect()->route('m3.replenishmentSettings.index');
|
||||
}
|
||||
|
||||
public function deleteRec(Request $request)
|
||||
{
|
||||
$r658PN = trim($request->R658PN);
|
||||
$r658CO = trim($request->R658CO);
|
||||
$r658LC = trim($request->R658LC);
|
||||
$r658PL = trim($request->R658PL);
|
||||
$r658WH = trim($request->R658WH);
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm658m')
|
||||
->where('R658PN', $r658PN)
|
||||
->where('R658CO', $r658CO)
|
||||
->where('R658LC', $r658LC)
|
||||
->where('R658PL', $r658PL)
|
||||
->where('R658WH', $r658WH)
|
||||
->delete();
|
||||
|
||||
return response()->json(['success' => 'Record Deleted']);
|
||||
}
|
||||
|
||||
public function checkRecExit(Request $request)
|
||||
{
|
||||
$params = [];
|
||||
parse_str($request['data'], $params);
|
||||
$paramsObj = (object) $params;
|
||||
|
||||
$r658PN = trim($paramsObj->R658PN);
|
||||
$r658CO = trim($paramsObj->R658CO);
|
||||
$r658LC = trim($paramsObj->R658LC);
|
||||
$r658PL = trim($paramsObj->R658PL);
|
||||
$r658WH = trim($paramsObj->R658WH);
|
||||
|
||||
$recordExistSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm658m')
|
||||
->where('R658PN', $r658PN)
|
||||
->where('R658CO', $r658CO)
|
||||
->where('R658LC', $r658LC)
|
||||
->where('R658PL', $r658PL)
|
||||
->where('R658WH', $r658WH)
|
||||
->first();
|
||||
$recordExists = $recordExistSQL == null ? true : false;
|
||||
|
||||
return response()->json(['recordExists' => $recordExists]);
|
||||
}
|
||||
|
||||
public function datatables(Request $request)
|
||||
{
|
||||
// Replenishment Table
|
||||
// $rEFCAT658 = DB::connection(config('m3.connection', 'pgsql'))->table('icm658m')->get();
|
||||
// Warehouse Table
|
||||
// $iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// Get Logged user Id
|
||||
$userId = m3_user() !== '' ? strtoupper(m3_user()) : '';
|
||||
// $userId = 'E1135818'; // Brad : E1135818 Malak : E2011812 ACOM_PDF
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
$iCM428M = Schema::connection($connection)->hasTable('icm428m')
|
||||
? DB::connection($connection)->table('icm428m')->where('R428US', $userId)->where('R428STS', 'A')->first()
|
||||
: null;
|
||||
|
||||
$userCO = isset($iCM428M->R428CO) ? $iCM428M->R428CO : '';
|
||||
$userPL = isset($iCM428M->R428PL) ? $iCM428M->R428PL : '';
|
||||
$userWH = isset($iCM428M->R428WH) ? $iCM428M->R428WH : '';
|
||||
|
||||
if ($userCO != '') {
|
||||
// Replenishment Table
|
||||
$rEFCAT658 = DB::connection(config('m3.connection', 'pgsql'))->table('icm658m')
|
||||
->select('*')
|
||||
->where('R658CO', $userCO)
|
||||
->where('R658PL', $userPL)
|
||||
->where('R658WH', $userWH)
|
||||
->orderBy('R658CO', 'asc');
|
||||
|
||||
// Warehouse Table
|
||||
// $iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')
|
||||
// ->where('WDCO',$userCO)
|
||||
// ->where('WDPL',$userPL)
|
||||
// ->where('WDWHS',$userWH)
|
||||
// ->get();
|
||||
} else {
|
||||
$rEFCAT658 = [];
|
||||
}
|
||||
|
||||
// FROM PRDAT.REFERPS t1 LEFT JOIN ( SELECT R658CO,R658PL,R658WH,R658LC,R658PN,R658MQ,R658RQ,R658TL,R658RMQ,
|
||||
// TRIM(R658WH)||TRIM(R658LC)||TRIM(R658PN) AS FULLID FROM EWOBJTST.ICM658M
|
||||
// ) t2 ON t1.REFKEY = t2.FULLID WHERE t1.REFCAT = '658'";
|
||||
// $rEFCAT658 = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
// dd($rEFCAT658);
|
||||
|
||||
return Datatables::of($rEFCAT658)->addIndexColumn()->make(true);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SentinelController extends Controller
|
||||
{
|
||||
public static function packSyst5Func(Request $request)
|
||||
{
|
||||
|
||||
$aYINTBOX = isset($request->AYINTBOX) ? trim($request->AYINTBOX) : '';
|
||||
$aYCO = isset($request->AYCO) ? trim($request->AYCO) : '';
|
||||
$aYWHS = isset($request->AYWHS) ? trim($request->AYWHS) : '';
|
||||
$aYUSER = isset($request->AYUSER) ? trim($request->AYUSER) : '';
|
||||
|
||||
if ($aYINTBOX != '') {
|
||||
// Get the record from ICM695M1
|
||||
$iCM695M1Sel = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
||||
->select()
|
||||
->where('AYINTBOX', $aYINTBOX)
|
||||
->where('AYCO', $aYCO)
|
||||
->where('AYWHS', $aYWHS)
|
||||
->where('AYSTATUS', '')
|
||||
->first();
|
||||
|
||||
$allowDeletion = ! empty($iCM695M1Sel->AYSENTPKR);
|
||||
|
||||
if ($allowDeletion) {
|
||||
$timestamp = date('Y-m-d H:i:s.u');
|
||||
$date1 = date('Ymd');
|
||||
$time1 = date('His');
|
||||
|
||||
// Delete Records from ICM695M1 And ICM695M2
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
||||
->where('AYINTBOX', $aYINTBOX)
|
||||
->where('AYCO', $aYCO)
|
||||
->where('AYWHS', $aYWHS)
|
||||
->delete();
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm695m2')
|
||||
->where('AZINTBOX', $aYINTBOX)
|
||||
->where('AZCO', $aYCO)
|
||||
->where('AZWHS', $aYWHS)
|
||||
->delete();
|
||||
|
||||
// Log the event as an unusual transaction to appear on SPD bottom right:
|
||||
$insertValues = "'$iCM695M1Sel->AYCO', '$iCM695M1Sel->AYWHS', '$iCM695M1Sel->AYSENTPKR', '$iCM695M1Sel->AYMACPKR', '$iCM695M1Sel->AYONO', '$iCM695M1Sel->AYRLNO', '$iCM695M1Sel->AYSHNO', '', 'Box $aYINTBOX emptied and repacked',
|
||||
'$timestamp', '$date1', '$time1', '$aYUSER','$timestamp', '$date1', '$time1', '$aYUSER','$aYINTBOX'";
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->insert("INSERT INTO ICM689M
|
||||
(A7CO, A7WHS, A7SENTPKR, A7MACPKR, A7ONO, A7RLNO, A7SHNO, A7SOURCE, A7ERRMSG, A7DISRAITS, A7DISRAID, A7DISRAIT, A7DISRAIU, A7DISRESTS ,A7DISRESD ,A7DISREST ,A7DISRESU , A7SPR15A01)
|
||||
values ($insertValues)");
|
||||
|
||||
return response()->json(['success' => true, 'message' => 'Line Deleted']);
|
||||
} else {
|
||||
return response()->json(['success' => false, 'message' => 'Line already packed']);
|
||||
}
|
||||
} else {
|
||||
return response()->json(['success' => false, 'message' => 'Line missing']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Datatables;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\M3\Helpers\CAProvinces;
|
||||
use Modules\M3\Helpers\USStates;
|
||||
use Modules\M3\Models\ShipTo;
|
||||
|
||||
class ShipToController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = ShipTo::select('*');
|
||||
|
||||
return Datatables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('checkbox', function ($row) {
|
||||
return '';
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . url('/ship-to/' . trim($row->AUSHSHZP) . '/' . trim($row->AUSHWHS) . '/edit') . '" class="edit btn btn-primary btn-sm">Edit</a> ';
|
||||
$actionBtn .= '<form method="POST" action="' . url('ship-to/' . urlencode(trim($row->AUSHSHZP)) . '/' . urlencode(trim($row->AUSHWHS))) . '" style="display:inline">';
|
||||
$actionBtn .= csrf_field() . method_field('DELETE');
|
||||
$actionBtn .= '<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm(\'Are you sure?\')">Delete</button></form>';
|
||||
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['checkbox', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.ship-to.index');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
// US
|
||||
$uSstates = USStates::all();
|
||||
// CA
|
||||
$cAstates = CAProvinces::all();
|
||||
|
||||
// All States
|
||||
$states = array_merge($uSstates, $cAstates);
|
||||
|
||||
return view('m3::liberty-theme.pages.ship-to.create', compact('states'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate(
|
||||
[
|
||||
'AUSTCN' => 'nullable|max:11',
|
||||
'AUSHSHNM' => 'required|max:36',
|
||||
'AUSHSHA1' => 'required|max:36',
|
||||
'AUSHSHA2' => 'required|max:36',
|
||||
'AUSHSHA3' => 'nullable|max:36',
|
||||
'AUSHSHA4' => 'nullable|max:36',
|
||||
'AUSHSHCI' => 'required|max:20',
|
||||
'AUSHSHST' => 'required|max:2',
|
||||
'AUSHSHZP' => 'required|max:10',
|
||||
'AUSHSHCT' => 'required|max:3',
|
||||
'AUSHWHS' => 'required|max:3',
|
||||
],
|
||||
[
|
||||
'AUSHSHNM.required' => 'Name is required',
|
||||
'AUSHSHA1.required' => 'Address 1 is required',
|
||||
'AUSHSHA2.required' => 'Address 2 is required',
|
||||
'AUSHSHCI.required' => 'City is required',
|
||||
'AUSHSHST.required' => 'State is required',
|
||||
'AUSHSHZP.required' => 'Zip code is required',
|
||||
'AUSHSHCT.required' => 'Country is required',
|
||||
'AUSHWHS.required' => 'Warehouse is required',
|
||||
|
||||
'AUSTCN.max' => 'Customer Number cannot exceed 11 characters',
|
||||
'AUSHSHNM.max' => 'Name cannot exceed 36 characters',
|
||||
'AUSHSHA1.max' => 'Address 1 cannot exceed 36 characters',
|
||||
'AUSHSHA2.max' => 'Address 2 cannot exceed 36 characters',
|
||||
'AUSHSHA3.max' => 'Address 3 cannot exceed 36 characters',
|
||||
'AUSHSHA4.max' => 'Address 4 cannot exceed 36 characters',
|
||||
'AUSHSHCI.max' => 'City cannot exceed 20 characters',
|
||||
'AUSHSHST.max' => 'State cannot exceed 2 characters',
|
||||
'AUSHSHZP.max' => 'Zip code cannot exceed 10 characters',
|
||||
'AUSHSHCT.max' => 'Country cannot exceed 3 characters',
|
||||
'AUSHWHS.max' => 'Warehouse cannot exceed 3 characters',
|
||||
],
|
||||
);
|
||||
$validated['AUSTCN'] = $validated['AUSTCN'] ?? ' ';
|
||||
|
||||
$model = new ShipTo;
|
||||
$model->fill($validated);
|
||||
$success = $model->save();
|
||||
if ($success) {
|
||||
return redirect()->route('m3.ship-to.index')->with('success', 'Record created successfully.');
|
||||
} else {
|
||||
return redirect()->back()
|
||||
->withErrors(['unique' => 'The combination of ZipCode and Warehouse must be unique.'])
|
||||
->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($aushshzp, $aushwhs)
|
||||
{
|
||||
// US
|
||||
$uSstates = USStates::all();
|
||||
// CA
|
||||
$cAstates = CAProvinces::all();
|
||||
|
||||
// All States
|
||||
$states = array_merge($uSstates, $cAstates);
|
||||
|
||||
$shipTo = ShipTo::where('AUSHSHZP', $aushshzp)
|
||||
->where('AUSHWHS', $aushwhs)
|
||||
->firstOrFail();
|
||||
|
||||
return view('m3::liberty-theme.pages.ship-to.edit', compact('shipTo', 'states'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $aushshzp, $aushwhs)
|
||||
{
|
||||
$validated = array_map(function ($value) {
|
||||
return $value === null ? '' : $value;
|
||||
}, $request->validate(
|
||||
[
|
||||
'AUSTCN' => 'nullable|string|max:11',
|
||||
'AUSHSHNM' => 'required|max:36',
|
||||
'AUSHSHA1' => 'required|max:36',
|
||||
'AUSHSHA2' => 'required|max:36',
|
||||
'AUSHSHA3' => 'nullable|string|max:36',
|
||||
'AUSHSHA4' => 'nullable|string|max:36',
|
||||
'AUSHSHCI' => 'required|max:20',
|
||||
'AUSHSHST' => 'required|max:2',
|
||||
'AUSHSHCT' => 'required|max:3',
|
||||
],
|
||||
[
|
||||
'AUSHSHNM.required' => 'Name is required',
|
||||
'AUSHSHA1.required' => 'Address 1 is required',
|
||||
'AUSHSHA2.required' => 'Address 2 is required',
|
||||
'AUSHSHCI.required' => 'City is required',
|
||||
'AUSHSHST.required' => 'State is required',
|
||||
'AUSHSHZP.required' => 'Zip code is required',
|
||||
'AUSHSHCT.required' => 'Country is required',
|
||||
'AUSHWHS.required' => 'Warehouse is required',
|
||||
|
||||
'AUSTCN.max' => 'Customer Number cannot exceed 11 characters',
|
||||
'AUSHSHNM.max' => 'Name cannot exceed 36 characters',
|
||||
'AUSHSHA1.max' => 'Address 1 cannot exceed 36 characters',
|
||||
'AUSHSHA2.max' => 'Address 2 cannot exceed 36 characters',
|
||||
'AUSHSHA3.max' => 'Address 3 cannot exceed 36 characters',
|
||||
'AUSHSHA4.max' => 'Address 4 cannot exceed 36 characters',
|
||||
'AUSHSHCI.max' => 'City cannot exceed 20 characters',
|
||||
'AUSHSHST.max' => 'State cannot exceed 2 characters',
|
||||
'AUSHSHZP.max' => 'Zip code cannot exceed 10 characters',
|
||||
'AUSHSHCT.max' => 'Country cannot exceed 3 characters',
|
||||
'AUSHWHS.max' => 'Warehouse cannot exceed 3 characters',
|
||||
],
|
||||
));
|
||||
|
||||
$updated = ShipTo::where('AUSHSHZP', $aushshzp)
|
||||
->where('AUSHWHS', $aushwhs)
|
||||
->update($validated);
|
||||
|
||||
if ($updated) {
|
||||
return redirect()->route('m3.ship-to.index')->with('success', 'Record updated successfully.');
|
||||
} else {
|
||||
return redirect()->route('m3.ship-to.index')->with('error', 'Record could not be updated.');
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($aushshzp, $aushwhs)
|
||||
{
|
||||
$deleted = ShipTo::where('AUSHSHZP', $aushshzp)
|
||||
->where('AUSHWHS', $aushwhs)
|
||||
->delete();
|
||||
|
||||
if ($deleted) {
|
||||
return redirect()->route('m3.ship-to.index')->with('success', 'Record deleted successfully.');
|
||||
} else {
|
||||
return redirect()->route('m3.ship-to.index')->with('error', 'Record not found or could not be deleted.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+293
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\M3\Models\ICM428M;
|
||||
use Modules\M3\Services\PostgresProgramBridge;
|
||||
|
||||
class UserControlController extends Controller
|
||||
{
|
||||
private const AUTH_FAILURE_MESSAGE = 'Could not connect due to wrong user or password.';
|
||||
|
||||
private const DATABASE_NOT_FOUND_MESSAGE = 'Database not found. Try WRKRDBDIRE to check.';
|
||||
|
||||
private const CONNECTION_ERROR_PREFIX = 'Could not connect. Error: ';
|
||||
|
||||
private const PROGRAM_ERROR_PREFIX = 'Error calling program. Code: ';
|
||||
|
||||
private const MESSAGE_SEPARATOR = ' Msg: ';
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
$profile = null;
|
||||
if (Schema::connection($connection)->hasTable('icm428m')) {
|
||||
$profile = DB::connection($connection)->table('icm428m')->where('R428US', strtoupper(m3_user()))->first();
|
||||
}
|
||||
$co = $profile->R428CO ?? '';
|
||||
$whs = $profile->R428WH ?? '';
|
||||
$iCM428M = Schema::connection($connection)->hasTable('icm428m')
|
||||
? DB::connection($connection)->table('icm428m')->where('R428CO', $co)->where('R428WH', $whs)->get() : collect();
|
||||
$uSER_INFO = Schema::connection($connection)->hasTable('icm428m')
|
||||
? DB::connection($connection)->table('icm428m')->selectRaw('R428US as USERPRF, R428STS as STATUS, NULL as DATE_EXPIRED, NULL as EXPIRED')->get()->all() : [];
|
||||
$power_user = [(object) ['R428PWRUSR' => $profile->R428PWRUSR ?? 'N', 'R428CO' => $co, 'R428PL' => $profile->R428PL ?? '', 'R428WH' => $whs]];
|
||||
$iC670M = Schema::connection($connection)->hasTable('ic670m')
|
||||
? DB::connection($connection)->table('ic670m')->get() : collect();
|
||||
|
||||
return view('m3::liberty-theme.pages.userControl', ['ICM428M' => $iCM428M, 'IC670M' => $iC670M, 'power_user' => $power_user, 'USER_INFO' => $uSER_INFO]);
|
||||
}
|
||||
|
||||
//
|
||||
// Process data from Add modal
|
||||
//
|
||||
public static function saveUserAdd(Request $request)
|
||||
{
|
||||
|
||||
if ($request->R428EMPCDE == '') {
|
||||
$request->R428EMPCDE = 0;
|
||||
}
|
||||
|
||||
// Insert record to ICM428M
|
||||
// dump($request);
|
||||
// Validate user profile exists on the system
|
||||
$usrprf = [(object) ['COUNT' => 0]]; // PostgreSQL/Core owns M3 profiles; no QSYS2 lookup.
|
||||
|
||||
// Validate employee code exists in LBPF file
|
||||
// if($request->R428EMPCDE>0) {
|
||||
// $empcde=DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT2 from LBPF where EMPNO='$request->R428EMPCDE'");
|
||||
// if($empcde[0]->COUNT2=="0") {
|
||||
// #echo "<script>alert('Employee code entered does not exist, please try again');</script>";
|
||||
// return "error empcd";
|
||||
// }
|
||||
// }
|
||||
$icm428m = DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from ICM428M where R428US='$request->R428US'");
|
||||
if ($icm428m[0]->COUNT1 == '1') {
|
||||
return 'error exists';
|
||||
} else {
|
||||
|
||||
if ($usrprf[0]->COUNT == '1') {
|
||||
DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM428M
|
||||
(R428CO, R428PL, R428WH, R428STS, R428US, R428FIRST, R428FAMILY, R428EMAIL, R428EMPCDE, R428ADMUSR, R428PWRUSR, MENU2OPT, MENU3OPT, MENU4OPT, MENU5OPT, MENU6OPT, R42811A)
|
||||
values ('$request->R428CO', '$request->R428PL', '$request->R428WH', '$request->R428STS', '$request->R428US', '$request->R428FIRST',
|
||||
'$request->R428FAMILY', '$request->R428EMAIL', $request->R428EMPCDE, '$request->R428ADMUSR', '$request->R428PWRUSR',
|
||||
'NN" . $request->MENU2OPT3 . 'NNN' . $request->MENU2OPT7 . $request->MENU2OPT8 . "N', '" . $request->MENU3OPT1 . $request->MENU3OPT2 . "NNNNNNN',
|
||||
'" . $request->MENU4OPT1 . $request->MENU4OPT2 . $request->MENU4OPT3 . "NNNNNN',
|
||||
'" . $request->MENU5OPT1 . $request->MENU5OPT2 . $request->MENU5OPT3 . 'N' . $request->MENU5OPT5 . "NNNN','" . $request->MENU6OPT1 . $request->MENU6OPT2 . $request->MENU6OPT3 . "','" . $request->R42811A . "')");
|
||||
|
||||
return 'success';
|
||||
} else {
|
||||
|
||||
// CL program call here (ewobjtst.)ICMUSRPRF parms(R428US, R428FIRST, R428FAMILY)
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(PostgresProgramBridge::class);
|
||||
} catch (\Throwable $e) {
|
||||
// Determine reason for failure.
|
||||
// Probably database authentication error or invalid or unreachable database.
|
||||
return self::programBridgeConnectionError($e);
|
||||
}
|
||||
$conn->setOptions(['persistent' => false, 'stateless' => true, 'debug' => true, 'debugLogFile' => '/www/sentm3test/htdocs/M3/storage/logs/toolkit_debug.log']);
|
||||
// Add LIB
|
||||
// $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)');
|
||||
// define several input/output params
|
||||
$params = [];
|
||||
$params[] = $conn->AddParameterChar('in', 10, 'User profile', 'E#iUsrPrf', $request->R428US);
|
||||
$params[] = $conn->AddParameterChar('in', 20, 'First name', 'FIRST', $request->R428FIRST);
|
||||
$params[] = $conn->AddParameterChar('in', 30, 'Family name', 'FAMILY', $request->R428FAMILY);
|
||||
// # $result = $conn->PgmCall(Config::get('eproconf.misc.PGM1'), Config::get('eproconf.misc.libname4'), $params, array(), array());
|
||||
$result = $conn->PgmCall('ICMUSRPRF', 'EWOBJ', $params, [], []);
|
||||
if (! $result) {
|
||||
|
||||
return 'error profile2';
|
||||
} else {
|
||||
// Successful Call : User profile created with default password
|
||||
// dd($result);
|
||||
// echo "<script>alert('User profile $request->R428US was created on the system with default password.');</script>";
|
||||
DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM428M
|
||||
(R428CO, R428PL, R428WH, R428STS, R428US, R428FIRST, R428FAMILY, R428EMAIL, R428EMPCDE, R428ADMUSR, R428PWRUSR, MENU2OPT, MENU3OPT, MENU4OPT, MENU5OPT, MENU6OPT, R42811A,R42821A)
|
||||
values ('$request->R428CO', '$request->R428PL', '$request->R428WH', '$request->R428STS', '$request->R428US', '$request->R428FIRST',
|
||||
'$request->R428FAMILY', '$request->R428EMAIL', $request->R428EMPCDE, '$request->R428ADMUSR', '$request->R428PWRUSR',
|
||||
'NN" . $request->MENU2OPT3 . 'NNN' . $request->MENU2OPT7 . $request->MENU2OPT8 . "N', '" . $request->MENU3OPT1 . $request->MENU3OPT2 . "NNNNNNN',
|
||||
'" . $request->MENU4OPT1 . $request->MENU4OPT2 . $request->MENU4OPT3 . "NNNNNN',
|
||||
'" . $request->MENU5OPT1 . $request->MENU5OPT2 . $request->MENU5OPT3 . 'N' . $request->MENU5OPT5 . "NNNN','" . $request->MENU6OPT1 . $request->MENU6OPT2 . $request->MENU6OPT3 . "','" . $request->R42811A . "','" . $request->R42821A . "')");
|
||||
|
||||
return 'success2';
|
||||
}
|
||||
// #kd return "error profile";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Process data from Edit modal
|
||||
//
|
||||
public static function saveUserEdit(Request $request)
|
||||
{
|
||||
|
||||
if ($request->R428EMPCDE == '') {
|
||||
$request->R428EMPCDE = 0;
|
||||
}
|
||||
|
||||
// Validate employee code exists in LBPF file
|
||||
// dump($request->R428EMPCDE);
|
||||
// if($request->R428EMPCDE>0) {
|
||||
// $sqlstmt="select count(*) as COUNT from LBPF where EMPNO='$request->R428EMPCDE'";
|
||||
// #echo "$sqlstmt<br>";
|
||||
// $empcde=DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
// #dump($empcde);
|
||||
// if($empcde[0]->COUNT=="0") {
|
||||
// #echo "<script>alert('Employee code entered does not exist, please try again');</script>";
|
||||
// return "error empcd";
|
||||
// }
|
||||
// }
|
||||
|
||||
// Update record to ICM428M
|
||||
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->select("select * from ICM428M where R428US='$request->R428US'");
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM428M
|
||||
set R428CO='$request->R428CO', R428PL='$request->R428PL', R428WH='$request->R428WH', R428STS='$request->R428STS', R428FIRST='$request->R428FIRST',
|
||||
R428FAMILY='$request->R428FAMILY', R428EMAIL='$request->R428EMAIL', R428EMPCDE=$request->R428EMPCDE, R428ADMUSR='$request->R428ADMUSR',
|
||||
R428PWRUSR='$request->R428PWRUSR',
|
||||
MENU2OPT='" . substr($iCM428M[0]->MENU2OPT, 0, 2) . $request->MENU2OPT3 . substr($iCM428M[0]->MENU2OPT, 3, 3) . $request->MENU2OPT7 . $request->MENU2OPT8 . "',
|
||||
MENU3OPT='" . $request->MENU3OPT1 . $request->MENU3OPT2 . substr($iCM428M[0]->MENU3OPT, 2, -1) . "',
|
||||
MENU4OPT='" . $request->MENU4OPT1 . $request->MENU4OPT2 . $request->MENU4OPT3 . substr($iCM428M[0]->MENU4OPT, 3, -1) . "',
|
||||
MENU5OPT='" . $request->MENU5OPT1 . $request->MENU5OPT2 . $request->MENU5OPT3 . substr($iCM428M[0]->MENU5OPT, 3, 1) . $request->MENU5OPT5 . substr($iCM428M[0]->MENU5OPT, 5, -1) . "',
|
||||
MENU6OPT='" . $request->MENU6OPT1 . $request->MENU6OPT2 . $request->MENU6OPT3 . substr($iCM428M[0]->MENU6OPT, 3, -1) . "',
|
||||
R42811A='" . $request->R42811A . "',R42821A='" . $request->R42821A . "'
|
||||
where R428US='$request->R428US'");
|
||||
|
||||
return 'success';
|
||||
|
||||
}
|
||||
|
||||
// 590
|
||||
public static function callCL(Request $request)
|
||||
{
|
||||
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(PostgresProgramBridge::class);
|
||||
} 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
|
||||
break;
|
||||
case 42705:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add LIB
|
||||
// $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)');
|
||||
|
||||
// define several input/output params
|
||||
$params = [];
|
||||
|
||||
// AddParameterChar($io, $size, $comment, $varName, $value, $varying, $dimension)
|
||||
// Add Warehouse Param
|
||||
$params[] = $conn->AddParameterChar('in', 10, 'userid', 'USERID', $request->USERID);
|
||||
$params[] = $conn->AddParameterChar('in', 1, 'action', 'ACTION', $request->ACTION);
|
||||
|
||||
// AddParameterPackDec($io, $length, $scale, $comment, $varName, $value,$dimension)
|
||||
// Add Delivery Note Param
|
||||
|
||||
// Start Time Tracking
|
||||
// $start = microtime(true);
|
||||
|
||||
// Config::get('eproconf.misc.PGM1'), Config::get('eproconf.misc.libname4')
|
||||
// ICM700C EWOBJTST ICM700C ICM700CSBM
|
||||
$result = $conn->PgmCall('ICMCHGPRF', 'EWOBJ', $params, [], []);
|
||||
|
||||
if (! $result) {
|
||||
echo "<script>alert($pGMERRORS);</script>";
|
||||
|
||||
return 'error';
|
||||
}
|
||||
// Successful Call
|
||||
else {
|
||||
if ($request->ACTION == 'P') {
|
||||
echo "<script>alert('The password has been reset to QAZ1WSX2 for '" . $request->USERID . "'. The user will need to enter a new password on next green screen connection.');</script>";
|
||||
}
|
||||
if ($request->ACTION == 'R') {
|
||||
echo "<script>alert('User '" . $request->USERID . "' has been re-enabled successfully');</script>";
|
||||
}
|
||||
echo "<script>window.location.replace('.')</script>";
|
||||
}
|
||||
|
||||
// if ($pGMERRORS!="") {
|
||||
// // return back()->withMessage('Can not Create PR: '.$pGMERRORS);
|
||||
// dump($pGMERRORS);
|
||||
// }
|
||||
// else{
|
||||
// // return $AWREQN;
|
||||
// }
|
||||
}
|
||||
|
||||
// 765
|
||||
public static function savePassword(Request $request)
|
||||
{
|
||||
|
||||
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'));
|
||||
|
||||
// echo "B3<br>";
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(PostgresProgramBridge::class);
|
||||
} catch (\Throwable $e) {
|
||||
$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
|
||||
break;
|
||||
case 42705:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $conn->CLCommand('QSYS/CHGUSRPRF USRPRF(' . $request->R428US_PWD . ') PASSWORD(' . $request->NEW_PASSWORD . ') STATUS(*ENABLED) PWDEXP(*NO)');
|
||||
|
||||
if (! $result) {
|
||||
dump($pGMERRORS);
|
||||
echo "<script>alert($pGMERRORS);</script>";
|
||||
|
||||
return 'error pwd';
|
||||
}
|
||||
// Successful Call
|
||||
else {
|
||||
return 'success';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static function programBridgeConnectionError(\Throwable $exception): string
|
||||
{
|
||||
$code = (int) $exception->getCode();
|
||||
|
||||
return match ($code) {
|
||||
8001 => 'error profile3',
|
||||
42705 => 'error profile4',
|
||||
default => 'error profile5',
|
||||
};
|
||||
}
|
||||
}
|
||||
+297
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class UserPickingStats4 extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
// $start = microtime(true);
|
||||
// dd($request);
|
||||
// Filter by date
|
||||
if (isset($request->dates)) {
|
||||
$date = $request->dates;
|
||||
$starting = $date;
|
||||
} else {
|
||||
$starting = date('Y-m-d', strtotime('-1 days'));
|
||||
}
|
||||
|
||||
// #$min_work_hours_for_break = 4;
|
||||
|
||||
// #$ignore_picks_that_last_longer_than_this_many_hours = 8;
|
||||
$ignore_picks_that_last_longer_than_this_many_hours = implode(',', Config::get('arrays.ignore_picks_that_last_longer_than_this_many_hours'));
|
||||
|
||||
// $user_array = Config::get('arrays.user_array');
|
||||
// 618
|
||||
// Get Logged User CO & WH
|
||||
// Get Users from ICM428M
|
||||
$co = '';
|
||||
$whs = '';
|
||||
$iCM428M = [];
|
||||
$schema = Schema::connection(config('m3.connection', 'pgsql'));
|
||||
if ($schema->hasTable('icm428m')) {
|
||||
$profile = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH')
|
||||
->where('R428US', '=', strtoupper(m3_user()))
|
||||
->first();
|
||||
$co = $profile->R428CO ?? '';
|
||||
$whs = $profile->R428WH ?? '';
|
||||
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->selectRaw("R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno")
|
||||
->where('R428STS', 'A')->where('R428EMPCDE', '!=', 0)
|
||||
->where('R428CO', $co)->where('R428WH', $whs)->get()->all();
|
||||
}
|
||||
|
||||
$user_array = [];
|
||||
// while($row = odbc_fetch_object($result)) {
|
||||
$x = 0;
|
||||
foreach ($iCM428M as $key => $row) {
|
||||
$user_array[$x]['userprf'] = trim($row->USERPRF);
|
||||
$user_array[$x]['name'] = trim($row->NAME);
|
||||
$user_array[$x]['empno'] = $row->EMPNO;
|
||||
$x++;
|
||||
}
|
||||
array_multisort(array_column($user_array, 'name'), SORT_ASC, $user_array);
|
||||
|
||||
// fill array of Lines per Hour per Monitor
|
||||
$lph_per_monitor_array = Config::get('arrays_custom.lph_per_code_array');
|
||||
if (isset($request->user)) {
|
||||
$user = $request->user;
|
||||
$empno = 0;
|
||||
foreach ($user_array as $key => $val) {
|
||||
if ($user_array[$key]['userprf'] == $user) {
|
||||
$empno = $user_array[$key]['empno'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$empno = 0;
|
||||
$user = '';
|
||||
}
|
||||
|
||||
// get data from LBPF for user and day
|
||||
$payrollCodes = '';
|
||||
ksort($lph_per_monitor_array);
|
||||
foreach ($lph_per_monitor_array as $key => $val) {
|
||||
$payrollCodes .= $key . ',';
|
||||
}
|
||||
$payrollCodes = substr($payrollCodes, 0, -1);
|
||||
|
||||
$yr = substr($starting, 0, 4) - 2000;
|
||||
$mth = substr($starting, 5, 2);
|
||||
$day = substr($starting, 8, 2);
|
||||
$sqlstmt = "select oppno, sum(cast (hrs as integer)+ (hrs-cast (hrs as integer))/0.6) as hrs from LBPF
|
||||
where empno=$empno and lbyr=$yr and lbmo=$mth and lbdy=$day
|
||||
and oppno in ($payrollCodes)
|
||||
group by oppno";
|
||||
|
||||
$lbpf1 = $schema->hasTable('lbpf')
|
||||
? DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt)
|
||||
: [];
|
||||
|
||||
$lbpf = 0;
|
||||
foreach ($lbpf1 as $key => $val) {
|
||||
$lbpf += $val->HRS;
|
||||
}
|
||||
|
||||
$sql = "select * from perfstat where dt='$starting' and a5pickcomu='$user' ";
|
||||
|
||||
if ((isset($request->dates) || isset($request->user)) && $schema->hasTable('perfstat')) {
|
||||
$statistic4 = DB::connection(config('m3.connection', 'pgsql'))->select($sql);
|
||||
} else {
|
||||
$statistic4 = [];
|
||||
}
|
||||
|
||||
// initialize arrays
|
||||
$monitor_array = $totals_array = $perf_array = [];
|
||||
$totals_array['value'] = 0;
|
||||
$totals_array['weight'] = 0;
|
||||
$totals_array['timediff'] = 0;
|
||||
$totals_array['picked'] = 0;
|
||||
$totals_array['entries'] = 0;
|
||||
$diff = 0;
|
||||
|
||||
foreach ($lbpf1 as $key => $val) {
|
||||
$monitor_array[$val->OPPNO]['tot_hours'] = $val->HRS;
|
||||
// Initialize these variables in case not existant in statistic4
|
||||
$monitor_array[$val->OPPNO]['header'] = 'Mon' . $val->OPPNO;
|
||||
$monitor_array[$val->OPPNO]['timediff'] = 0;
|
||||
$monitor_array[$val->OPPNO]['percent_per_monitor'] = 0;
|
||||
$monitor_array[$val->OPPNO]['percent_per_activity'] = 0;
|
||||
$monitor_array[$val->OPPNO]['lph_blended_per_activity'] = 0;
|
||||
$monitor_array[$val->OPPNO]['picked'] = 0;
|
||||
$monitor_array[$val->OPPNO]['weight'] = 0;
|
||||
$monitor_array[$val->OPPNO]['lines'] = 0;
|
||||
|
||||
}
|
||||
if (! empty($statistic4)) {
|
||||
// echo "in !empty<br>";
|
||||
// Initialize the Monitor array
|
||||
foreach ($statistic4 as $key => $val) {
|
||||
|
||||
// Initialize these variables in case not existant in LBPF
|
||||
$monitor_array[$val->CODE]['header'] = 'Mon' . $statistic4[$key]->CODE;
|
||||
$monitor_array[$val->CODE]['timediff'] = 0;
|
||||
$monitor_array[$val->CODE]['percent_per_monitor'] = 0;
|
||||
$monitor_array[$val->CODE]['percent_per_activity'] = 0;
|
||||
$monitor_array[$val->CODE]['lph_blended_per_activity'] = 0;
|
||||
$monitor_array[$val->CODE]['picked'] = 0;
|
||||
$monitor_array[$val->CODE]['weight'] = 0;
|
||||
$monitor_array[$val->CODE]['lines'] = 0;
|
||||
}
|
||||
|
||||
// add another element (0) in monitor_array to capture the total blended lph value expected
|
||||
$monitor_array[0]['lph_blended_per_activity'] = 0;
|
||||
$monitor_array[0]['header'] = '0';
|
||||
|
||||
// cycle thru stats again, and accumulate totals at global level (totals_array) and at monitor level (monitor_array)
|
||||
foreach ($statistic4 as $key => $val) {
|
||||
|
||||
$statistic4[$key]->WEIGHT = round($statistic4[$key]->WEIGHT);
|
||||
$statistic4[$key]->A5VALUE = round($statistic4[$key]->A5VALUE);
|
||||
$statistic4[$key]->A5PICKED = round($statistic4[$key]->A5PICKED);
|
||||
|
||||
$statistic4[$key]->A5PICKCMTS = date('Y-m-d H:i', strtotime($statistic4[$key]->A5PICKCMTS));
|
||||
|
||||
// Calculate difference from previous time entry in seconds and save in TIMEDIFF key of STATISTIC4 array
|
||||
// $time_now=strtotime($statistic4[$key]->A5PICKCMTSADJ);
|
||||
$time_now = strtotime($statistic4[$key]->A5CMTSADJ);
|
||||
if ($key > 0) {
|
||||
$diff = round(abs($time_now - $time_prev));
|
||||
if ($diff > $ignore_picks_that_last_longer_than_this_many_hours * 60 * 60) {
|
||||
$diff = -1;
|
||||
}
|
||||
}
|
||||
|
||||
$statistic4[$key]->TIMEDIFF = $diff;
|
||||
|
||||
if ($diff / 60 < 5) {
|
||||
$statistic4[$key]->COLOUR = '';
|
||||
}
|
||||
if ($diff / 60 >= 5 && $diff / 60 <= 10) {
|
||||
$statistic4[$key]->COLOUR = 'yellow';
|
||||
}
|
||||
if ($diff / 60 > 10 && $diff / 60 <= 15) {
|
||||
$statistic4[$key]->COLOUR = '#88ace0';
|
||||
}
|
||||
if ($diff / 60 > 15) {
|
||||
$statistic4[$key]->COLOUR = 'red';
|
||||
}
|
||||
|
||||
// save the time for previous entry
|
||||
// $time_prev=strtotime($statistic4[$key]->A5PICKCMTSADJ);
|
||||
$time_prev = strtotime($statistic4[$key]->A5CMTSADJ);
|
||||
|
||||
// accumulate totals at monitor level
|
||||
$monitor_array[$val->CODE]['timediff'] += $diff;
|
||||
$monitor_array[$val->CODE]['picked'] += $statistic4[$key]->A5PICKED;
|
||||
$monitor_array[$val->CODE]['weight'] += $statistic4[$key]->WEIGHT;
|
||||
$monitor_array[$val->CODE]['lines']++;
|
||||
|
||||
// calculate totals at global level
|
||||
$totals_array['entries'] = count($statistic4);
|
||||
$totals_array['weight'] += $statistic4[$key]->WEIGHT;
|
||||
$totals_array['value'] += $statistic4[$key]->A5VALUE;
|
||||
$totals_array['timediff'] += $diff;
|
||||
$totals_array['picked'] += $statistic4[$key]->A5PICKED;
|
||||
|
||||
}
|
||||
// echo "after 2<pre>"; print_r($statistic4);
|
||||
// build array for Performance with Greg's time entry (at one point we had a [0] array as well)
|
||||
|
||||
if (! is_null($lbpf)) {
|
||||
|
||||
$perf_array['tot_hours'] = (isset($lbpf) ? $lbpf : 0);
|
||||
|
||||
if ($perf_array['tot_hours'] != 0) {
|
||||
$perf_array['per_hour_actual'] = $totals_array['entries'] / $perf_array['tot_hours'];
|
||||
} else {
|
||||
$perf_array['per_hour_actual'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// cycle through monitors array and compute percentage to allocate to each monitor (code)
|
||||
ksort($monitor_array);
|
||||
foreach ($monitor_array as $key => $val) {
|
||||
if ($key != '0') {
|
||||
if (! isset($monitor_array[$key]['tot_hours'])) {
|
||||
$monitor_array[$key]['tot_hours'] = 0;
|
||||
}
|
||||
|
||||
if ($totals_array['timediff'] != 0) {
|
||||
$monitor_array[$key]['percent_per_monitor'] = $monitor_array[$key]['timediff'] / $totals_array['timediff'];
|
||||
}
|
||||
|
||||
if ($lbpf != 0) {
|
||||
$monitor_array[$key]['percent_per_activity'] = $monitor_array[$key]['tot_hours'] / $lbpf;
|
||||
}
|
||||
$monitor_array[$key]['lph_blended_per_activity'] = $monitor_array[$key]['percent_per_activity'] * (isset($lph_per_monitor_array[$key]) ? $lph_per_monitor_array[$key] : 0);
|
||||
$monitor_array[0]['lph_blended_per_activity'] += $monitor_array[$key]['lph_blended_per_activity'];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($monitor_array[0]['lph_blended_per_activity'] != 0) {
|
||||
$perf_array['performance_activity'] = $perf_array['per_hour_actual'] / $monitor_array[0]['lph_blended_per_activity'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// return encoded json if input field named format is json
|
||||
if ($request->format == 'json') {
|
||||
|
||||
if (! array_key_exists('performance_activity', $perf_array)) {
|
||||
$performance = 0;
|
||||
} else {
|
||||
$performance = number_format($perf_array['performance_activity'] * 100, 0);
|
||||
}
|
||||
if (! array_key_exists('0', $monitor_array)) {
|
||||
$blendedTargetLPH = 0;
|
||||
} else {
|
||||
$blendedTargetLPH = number_format($monitor_array[0]['lph_blended_per_activity'], 1);
|
||||
}
|
||||
if (! array_key_exists('per_hour_actual', $perf_array)) {
|
||||
$actualLPH = 0;
|
||||
} else {
|
||||
$actualLPH = number_format($perf_array['per_hour_actual'], 1);
|
||||
}
|
||||
if (! array_key_exists('tot_hours', $perf_array)) {
|
||||
$grossHours = 0;
|
||||
} else {
|
||||
$grossHours = $perf_array['tot_hours'];
|
||||
}
|
||||
|
||||
$json_data = [
|
||||
'day' => $starting,
|
||||
'performance' => $performance,
|
||||
'blendedTargetLPH' => $blendedTargetLPH,
|
||||
'actualLPH' => $actualLPH,
|
||||
'grossHours' => $grossHours,
|
||||
];
|
||||
|
||||
return json_encode($json_data);
|
||||
|
||||
} else {
|
||||
// display webpage of statistic version 4
|
||||
$request->ports = Config::get('arrays.env_ports');
|
||||
$no_data = 'N';
|
||||
if (empty($statistic4) && $_SERVER['REQUEST_URI'] != '/UserPickingStats4') {
|
||||
$no_data = 'Y';
|
||||
}
|
||||
|
||||
return view(
|
||||
'm3::liberty-theme.pages.UserPickingStats4',
|
||||
compact('statistic4', 'starting', 'user', 'user_array', 'monitor_array', 'totals_array', 'perf_array', 'request', 'no_data'),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class UserPickingStats5 extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
[$userArray] = self::loadUsers();
|
||||
[$starting, $ending, $days] = self::dateRange($request);
|
||||
$user = $request->user;
|
||||
$statistics = [];
|
||||
$totals = self::emptyTotals();
|
||||
|
||||
if (isset($request->dates)) {
|
||||
[$statistics, $totals] = self::collectDailyStatistics($request, $starting, $days, $totals);
|
||||
}
|
||||
|
||||
if ($request->format === 'json') {
|
||||
return response()->json($statistics);
|
||||
}
|
||||
|
||||
$statistic5 = $statistics;
|
||||
$totals_array = $totals;
|
||||
$user_array = $userArray;
|
||||
|
||||
return view('m3::liberty-theme.pages.UserPickingStats5', compact(
|
||||
'statistic5',
|
||||
'totals_array',
|
||||
'user_array',
|
||||
'user',
|
||||
'starting',
|
||||
'ending',
|
||||
'request',
|
||||
));
|
||||
}
|
||||
|
||||
private static function loadUsers(): array
|
||||
{
|
||||
$users = [];
|
||||
$co = '';
|
||||
$whs = '';
|
||||
|
||||
try {
|
||||
$connection = config('m3.connection', 'pgsql');
|
||||
if (! Schema::connection($connection)->hasTable('icm428m')) {
|
||||
return [$users, $co, $whs];
|
||||
}
|
||||
|
||||
$profile = DB::connection($connection)->table('icm428m')
|
||||
->select('R428CO', 'R428WH')
|
||||
->where('R428US', strtoupper((string) m3_user()))
|
||||
->first();
|
||||
$co = trim((string) ($profile->R428CO ?? ''));
|
||||
$whs = trim((string) ($profile->R428WH ?? ''));
|
||||
if ($co === '' || $whs === '') {
|
||||
return [$users, $co, $whs];
|
||||
}
|
||||
|
||||
$rows = DB::connection($connection)->table('icm428m')
|
||||
->selectRaw("R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno")
|
||||
->where('R428EMPCDE', '!=', 0)->where('R428CO', $co)->where('R428WH', $whs)->get();
|
||||
foreach ($rows as $row) {
|
||||
$users[] = ['userprf' => trim((string) $row->userprf), 'name' => trim((string) $row->name), 'empno' => $row->empno];
|
||||
}
|
||||
array_multisort(array_column($users, 'name'), SORT_ASC, $users);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('M3 picking user list unavailable', ['exception' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
return [$users, $co, $whs];
|
||||
}
|
||||
|
||||
private static function dateRange(Request $request): array
|
||||
{
|
||||
if (isset($request->dates)) {
|
||||
$dates = explode(' - ', (string) $request->dates);
|
||||
$starting = $dates[0] ?? date('Y-m-d');
|
||||
$ending = $dates[1] ?? $starting;
|
||||
} else {
|
||||
$starting = date('Y-m-d', strtotime('-5 days'));
|
||||
$ending = date('Y-m-d');
|
||||
}
|
||||
|
||||
$days = (int) (new DateTime($starting))->diff(new DateTime($ending))->format('%a');
|
||||
|
||||
return [$starting, $ending, $days];
|
||||
}
|
||||
|
||||
private static function emptyTotals(): array
|
||||
{
|
||||
return ['performance' => 0, 'blendedTargetLPH' => 0, 'actualLPH' => 0, 'grossHours' => 0];
|
||||
}
|
||||
|
||||
private static function collectDailyStatistics(Request $request, string $starting, int $days, array $totals): array
|
||||
{
|
||||
$statistics = [];
|
||||
$count = 0;
|
||||
$url = $request->getSchemeAndHttpHost() . '/UserPickingStats4';
|
||||
|
||||
for ($day = 0; $day <= $days; $day++) {
|
||||
$date = date('Y-m-d', strtotime($starting . "+$day days"));
|
||||
$statistics[$day] = self::fetchStatistic($request, $url, $date);
|
||||
self::addTotals($totals, $statistics[$day]);
|
||||
if (($statistics[$day]['performance'] ?? 0) > 0) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($count > 0) {
|
||||
foreach (array_keys($totals) as $key) {
|
||||
$totals[$key] /= $count;
|
||||
}
|
||||
}
|
||||
|
||||
return [$statistics, $totals];
|
||||
}
|
||||
|
||||
private static function fetchStatistic(Request $request, string $url, string $date): array
|
||||
{
|
||||
try {
|
||||
$response = Http::withBasicAuth((string) $request->header('php-auth-user'), (string) $request->header('php-auth-pw'))
|
||||
->get($url, ['dates' => $date, 'user' => $request->user, 'format' => 'json']);
|
||||
$data = $response->successful() ? (json_decode($response->body(), true) ?: []) : [];
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('M3 picking statistics unavailable', ['date' => $date, 'exception' => $e->getMessage()]);
|
||||
$data = [];
|
||||
}
|
||||
$data['day'] = $data['day'] ?? $date;
|
||||
$data['performance'] = $data['performance'] ?? 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function addTotals(array &$totals, array $statistic): void
|
||||
{
|
||||
foreach (array_keys($totals) as $key) {
|
||||
$totals[$key] += (float) ($statistic[$key] ?? 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\M3\Models\ICM428M;
|
||||
|
||||
class UserProfileController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
// Get Current USER
|
||||
$loggedUser = strtoupper(m3_user());
|
||||
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH', 'R428PL', 'R428FIRST', 'R428FAMILY')
|
||||
->where('R428US', '=', $loggedUser)
|
||||
->where('R42821A', '=', 'Y')
|
||||
->first();
|
||||
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// Check if user is eligible for Profile update
|
||||
if (isset($iCM428M->R428US)) {
|
||||
return view('m3::liberty-theme.pages.userProfile', ['ICM428M' => $iCM428M, 'IC670M' => $iC670M]);
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function updateUserProfile(Request $request)
|
||||
{
|
||||
|
||||
$r428US = isset($request->R428US) ? trim($request->R428US) : '';
|
||||
$r428DPW = isset($request->R428DPW) ? trim($request->R428DPW) : '';
|
||||
|
||||
$r428CO = substr($r428DPW, 0, 3);
|
||||
$r428PL = substr($r428DPW, 3, 3);
|
||||
$r428WH = substr($r428DPW, 6, 3);
|
||||
|
||||
if ($r428US != '') {
|
||||
// Update record to ICM428M
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM428M
|
||||
set R428CO='$r428CO', R428PL='$r428PL', R428WH='$r428WH'
|
||||
where R428US='$r428US'");
|
||||
|
||||
return redirect('/userprofile')->with('success', 'Profile updated successfully!');
|
||||
} else {
|
||||
return redirect('/userprofile')->with('success', 'Profile updated successfully!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function updateUserProfileAjax(Request $request)
|
||||
{
|
||||
|
||||
$r428US = isset($request->R428US) ? trim($request->R428US) : '';
|
||||
$r428DPW = isset($request->R428DPW) ? trim($request->R428DPW) : '';
|
||||
|
||||
$r428CO = substr($r428DPW, 0, 3);
|
||||
$r428PL = substr($r428DPW, 3, 3);
|
||||
$r428WH = substr($r428DPW, 6, 3);
|
||||
|
||||
if ($r428US != '') {
|
||||
// Update record to ICM428M
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM428M
|
||||
set R428CO='$r428CO', R428PL='$r428PL', R428WH='$r428WH'
|
||||
where R428US='$r428US'");
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
} else {
|
||||
return response()->json(['success' => false]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+582
@@ -0,0 +1,582 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Ayeo\Barcode;
|
||||
use Cache;
|
||||
use Config;
|
||||
use DB;
|
||||
use Dompdf\Dompdf;
|
||||
use File;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Modules\M3\Services\PostgresProgramBridge;
|
||||
use PDF;
|
||||
use Picqer\Barcode\BarcodeGeneratorPNG;
|
||||
use Zebra\Zpl\Image;
|
||||
|
||||
class UtilitiesController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
dd('SentM3Test');
|
||||
|
||||
// Get The Next ID by Calling POM002C
|
||||
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(PostgresProgramBridge::class);
|
||||
} 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
|
||||
break;
|
||||
case 42705:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
$conn->setOptions(['persistent' => false, 'stateless' => true, 'debug' => true, 'debugLogFile' => '/www/sentustesx/htdocs/storage/logs/toolkit_debug.log']);
|
||||
|
||||
// Add LIB
|
||||
// $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)');
|
||||
|
||||
// define several input/output params
|
||||
$params = [];
|
||||
|
||||
// AddParameterChar($io, $size, $comment, $varName, $value, $varying, $dimension)
|
||||
// Add Warehouse Param
|
||||
$params[] = $conn->AddParameterChar('in', 3, 'eqNumber', '', '111');
|
||||
|
||||
// AddParameterPackDec($io, $length, $scale, $comment, $varName, $value,$dimension)
|
||||
// Add Delivery Note Param
|
||||
$params[] = $conn->AddParameterPackDec('in', 11, 0, 'ParamIn', '', '00000087125');
|
||||
|
||||
// Start Time Tracking
|
||||
$start = microtime(true);
|
||||
|
||||
dump('Calling: EWOBJTST/ICM700C');
|
||||
|
||||
// Config::get('eproconf.misc.PGM1'), Config::get('eproconf.misc.libname4')
|
||||
// ICM700C EWOBJTST ICM700C ICM700CSBM
|
||||
$result = $conn->PgmCall('ICM700CSBM', 'EWOBJTST', $params, [], []);
|
||||
|
||||
if (! $result) {
|
||||
}
|
||||
// Successful Call
|
||||
else {
|
||||
dump($result);
|
||||
}
|
||||
|
||||
if ($pGMERRORS != '') {
|
||||
dump($pGMERRORS);
|
||||
}
|
||||
// Get Execution Time
|
||||
$time = microtime(true) - $start;
|
||||
dump($time);
|
||||
}
|
||||
|
||||
public static function pdfReadWrite(Request $request)
|
||||
{
|
||||
dump('PDF Read Write');
|
||||
|
||||
$pdfFileName = 'E1232824-10826596';
|
||||
|
||||
// Parse PDF file and build necessary objects.
|
||||
$pdfFile = File::get('/www/sentm3test/htdocs/labels/' . $pdfFileName . '.pdf');
|
||||
|
||||
// Transform content to base64
|
||||
$base64PDF = base64_encode($pdfFile);
|
||||
// Output base64 string
|
||||
// dump($base64PDF);
|
||||
|
||||
// Save Cache
|
||||
Cache::put($pdfFileName, $base64PDF, now()->addMinutes(60));
|
||||
|
||||
// Retrieve Cache
|
||||
$cachedPdfFile = Cache::get($pdfFileName);
|
||||
dump('Retrieve Base64 Encoded PDF saved in Cache:');
|
||||
dump($cachedPdfFile);
|
||||
|
||||
// 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();
|
||||
// dump($text);
|
||||
|
||||
}
|
||||
|
||||
public static function fixICM799MSentPKR(Request $request)
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
dump('Run Fix IMSENTPKR...');
|
||||
|
||||
$sHUSER = 'TWOSHIP';
|
||||
|
||||
// Get User CO & WH
|
||||
// Get users from ICM428M
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH')
|
||||
->where('R428US', '=', $sHUSER)
|
||||
->first();
|
||||
|
||||
$dIVI = isset($iCM428M->R428CO) ? $iCM428M->R428CO : '';
|
||||
$wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : '';
|
||||
|
||||
// Get Parts And Lots from ICM688M2
|
||||
$iCM688M2SLTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m2')
|
||||
->select('A5MACPKR', 'A5SENTPKR', 'A5PICKSTRD')
|
||||
->distinct()
|
||||
->where('A5CO', $dIVI)
|
||||
->where('A5WHS', $wHS)
|
||||
->where('A5PICKSTRD', '!=', '0')
|
||||
->orderBy('A5PICKSTRD', 'ASC')
|
||||
->get();
|
||||
|
||||
foreach ($iCM688M2SLTMP as $ICM688M2SL) {
|
||||
|
||||
$a5MACPKR = isset($ICM688M2SL->A5MACPKR) ? $ICM688M2SL->A5MACPKR : '';
|
||||
$a5SENTPKR = isset($ICM688M2SL->A5SENTPKR) ? $ICM688M2SL->A5SENTPKR : '';
|
||||
|
||||
dump('ICM688M2 Record: ' . $a5MACPKR . '-' . $a5SENTPKR);
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm799m')
|
||||
->where('IMDELNO', '=', $a5MACPKR)
|
||||
->update(['IMSENTPKR' => $a5SENTPKR]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Generate GS1-128
|
||||
public static function generateGS128(Request $request)
|
||||
{
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
Log::channel('LabelCron')->info('>>> Run GS1 Label creation Command...');
|
||||
|
||||
// Get the Calling User
|
||||
// $userId = 'TWOSHIP';
|
||||
// $sHUSER = isset($userId) ? $userId : (m3_user() !== '' ? Str::upper(trim(m3_user())) : '');
|
||||
|
||||
// Get Manifest Array
|
||||
$gSArray = $request->query();
|
||||
|
||||
$sHUSER = isset($gSArray['User']) ? trim($gSArray['User']) : '';
|
||||
|
||||
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();
|
||||
|
||||
$cOMPANY = isset($iCM428M->R428CO) ? $iCM428M->R428CO : ''; // Company
|
||||
$pLANT = isset($iCM428M->R428PL) ? $iCM428M->R428PL : ''; // Plant
|
||||
$wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : ''; // WareHouse
|
||||
|
||||
$macpkr = $gSArray['Macpkr'];
|
||||
$packageType = trim($gSArray['packageType']); // 1 => Pallet , 0 => Carton
|
||||
$packageTypeDesc = $packageType == 1 ? 'Pallet' : 'Carton';
|
||||
$manufactID = '0826528'; // MAK : get ID from Nvent and save to Config File
|
||||
$total_length = 9;
|
||||
|
||||
$html = '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.border_btm {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
.border_rght {
|
||||
border-right: 1px solid;
|
||||
}
|
||||
|
||||
.margin_t {
|
||||
padding-top : 10px;
|
||||
}
|
||||
|
||||
.align_lft {
|
||||
text-align: left;
|
||||
}
|
||||
.align_center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@page { margin: 5px; }
|
||||
body { margin: 0px; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif;">';
|
||||
|
||||
// Get number of Pallets
|
||||
$packageCount = count($gSArray['PackagesArray']);
|
||||
$packageNum = 1;
|
||||
|
||||
// Get GS1 Label MAX ID from ICM695M3 :
|
||||
$gS1SEQUENCESel = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m3')->max('ID');
|
||||
$gS1SEQUENCE = isset($gS1SEQUENCESel) ? $gS1SEQUENCESel : 0;
|
||||
|
||||
// Loop PackagesArray : Build Table for PDF and Insert to ICM695m3
|
||||
foreach ($gSArray['PackagesArray'] as $value) {
|
||||
$table_style = $packageNum < $packageCount ? ' style="page-break-after: always;" ' : '';
|
||||
|
||||
$a2INTBOX = trim($value);
|
||||
|
||||
$gS1SEQUENCE++;
|
||||
$gS1SEQUENCEID = str_pad($gS1SEQUENCE, $total_length, '0', STR_PAD_LEFT);
|
||||
// Build GS1 18 Digits Code
|
||||
$gs1_128_bc_1 = '00' . $packageType . $manufactID . $gS1SEQUENCEID;
|
||||
|
||||
// Calculate Check Digit
|
||||
$digits = str_split($gs1_128_bc_1);
|
||||
$sum = 0;
|
||||
$length = count($digits);
|
||||
|
||||
// Loop through each digit starting from the right
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$digit = $digits[$length - $i - 1];
|
||||
// Assign a weight of 3 or 1 alternately
|
||||
$weight = ($i % 2 == 0) ? 3 : 1;
|
||||
// Add the product of the digit and its weight to the sum
|
||||
$sum += $digit * $weight;
|
||||
}
|
||||
// Calculate the remainder when sum is divided by 10
|
||||
$remainder = $sum % 10;
|
||||
// If remainder is 0, check digit is 0; otherwise, subtract remainder from 10
|
||||
$checkDigit = ($remainder == 0) ? 0 : 10 - $remainder;
|
||||
// End Check Digit Calculation
|
||||
|
||||
// SSCC 18 Digits Code
|
||||
$gs1_128_bc = $gs1_128_bc_1 . $checkDigit;
|
||||
|
||||
$gs1_128_bc_desc = '(00)' . $packageType . $manufactID . $gS1SEQUENCEID . $checkDigit;
|
||||
|
||||
$data = [
|
||||
'ship_to' => $gSArray['Recipient_CompanyName'] . '<br>' . $gSArray['Recipient_Address1'] . '<br>' .
|
||||
$gSArray['Recipient_City'] . ',' . $gSArray['Recipient_State']
|
||||
. '<br>' . $gSArray['Recipient_PostalCode'],
|
||||
'from' => $gSArray['Sender_CompanyName'] . '<br>' . $gSArray['Sender_Address1'] . '<br>' .
|
||||
$gSArray['Sender_City'] . ',' . $gSArray['Sender_State']
|
||||
. '<br>' . $gSArray['Sender_PostalCode'],
|
||||
'ship_to_lbl' => '420' . $gSArray['Recipient_PostalCode'],
|
||||
'ship_to_desc' => '(420)' . $gSArray['Recipient_PostalCode'],
|
||||
'pro' => '190071217845706', // MAK : Check missing info with Brad
|
||||
'item_number' => '10000B',
|
||||
'upc' => '098506095310',
|
||||
'quantity' => '1',
|
||||
'serial_shipping_container' => $gs1_128_bc_desc,
|
||||
];
|
||||
|
||||
// Initialize barcode generator
|
||||
$generator = new BarcodeGeneratorPNG;
|
||||
|
||||
// Generate barcodes
|
||||
$shipToPostalCodeBarcode = $generator->getBarcode($data['ship_to_lbl'], $generator::TYPE_CODE_128);
|
||||
$serialShippingContainerBarcode = $generator->getBarcode($data['serial_shipping_container'], $generator::TYPE_CODE_128, 2, 50);
|
||||
|
||||
// HTML content for the label
|
||||
$html .= '
|
||||
<table ' . $table_style . '>
|
||||
<tr>
|
||||
<td colspan="2" class="border_btm border_rght align_lft">
|
||||
FROM:<br>' . $data['from'] . '
|
||||
</td>
|
||||
<td colspan="2" class="border_btm align_lft">
|
||||
SHIP TO:<br>' . $data['ship_to'] . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="border_btm border_rght margin_t align_center">
|
||||
<img src="data:image/png;base64,' . base64_encode($shipToPostalCodeBarcode) . '"> <br>
|
||||
' . $data['ship_to_desc'] . '
|
||||
</td>
|
||||
<td class="border_btm margin_t align_lft">
|
||||
Carrier: ' . $gSArray['CarrierName'] . ' <br>
|
||||
PRO #: ' . $gSArray['trackingno'] . ' <br>
|
||||
B/L #: ' . $gSArray['BOLnumber'] . ' <br>
|
||||
Ref : ' . $a2INTBOX . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" class="border_btm margin_t align_lft">
|
||||
PURCHASE ORDER: ' . $gSArray['ShipmentPONumber'] . ' <br>
|
||||
Vendor: ' . $manufactID . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" class="border_btm margin_t align_center">
|
||||
' . $packageTypeDesc . ' # : ' . $packageNum . ' of ' . $packageCount . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: center;" class="margin_t">
|
||||
<img src="data:image/png;base64,' . base64_encode($serialShippingContainerBarcode) . '"><br>
|
||||
' . $data['serial_shipping_container'] . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
$packageNum++;
|
||||
|
||||
// Insert new Record to ICM695M3 $gs1_128_bc
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm695m3')
|
||||
->insert(['A2CO' => $cOMPANY, 'A2WHS' => $wHS, 'A2PLANT' => $pLANT, 'A2MACPKR' => $macpkr, 'A2GS1LABEL' => $gs1_128_bc, 'A2INTBOX' => $a2INTBOX]);
|
||||
|
||||
Log::channel('LabelCron')->info('<<< GS1-128...End of Label Creation for Mackpkr: ' . $macpkr);
|
||||
}
|
||||
|
||||
$html .= '</body> </html>';
|
||||
|
||||
ob_start();
|
||||
|
||||
// Initialize Dompdf
|
||||
$dompdf = new Dompdf;
|
||||
$dompdf->loadHtml($html);
|
||||
$dompdf->setPaper('a6', 'portrait');
|
||||
// Render the HTML as PDF
|
||||
$dompdf->render();
|
||||
|
||||
// Output the generated PDF to Browser
|
||||
// $dompdf->stream();
|
||||
|
||||
$pdfContent = $dompdf->output();
|
||||
|
||||
$labelsPath = Config::get('arrays.PdfPath'); // '/www/sentm3live/htdocs/labels/';
|
||||
// Put the PDF in labels/CarrierLabel
|
||||
$gSFolder = 'GSLabel';
|
||||
|
||||
$carrierFileName = $gSFolder . '_' . $macpkr . '_' . $cOMPANY . '_' . $wHS . '_' . $a2INTBOX;
|
||||
// LTL
|
||||
// if ($packageType=='1') {
|
||||
// $carrierFileName = $gSFolder.'_'.$macpkr.'_'.$cOMPANY.'_'.$wHS;
|
||||
// }
|
||||
// # small Packs
|
||||
// else{
|
||||
// $carrierFileName = $gSFolder.'_'.$macpkr.'_'.$cOMPANY.'_'.$wHS.'_'.$a2INTBOX;
|
||||
// }
|
||||
|
||||
$gS1FileName = $labelsPath . $gSFolder . '/' . $carrierFileName . '.pdf';
|
||||
$gS1FileNameNoRoot = $gSFolder . '/' . $carrierFileName;
|
||||
file_put_contents($gS1FileName, $pdfContent);
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
// # Insert new Record to ICM695M3 $gs1_128_bc
|
||||
// DB::connection(config('m3.connection', 'pgsql'))->table('icm695m3')
|
||||
// ->insert(['A2CO'=> $cOMPANY,'A2WHS'=> $wHS,'A2MACPKR'=> $macpkr,'A2GS1LABEL'=> $gs1_128_bc]);
|
||||
|
||||
return json_encode(['result' => 'success', 'GS1File' => $gS1FileNameNoRoot]);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::channel('LabelCron')->error($th);
|
||||
|
||||
return json_encode(['result' => 'error', 'GS1File' => $th]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function generateGS128Tst(Request $request)
|
||||
{
|
||||
print_r('>>> Generate PDF');
|
||||
|
||||
$data = [
|
||||
'from' => 'Any Vendor<br>123 Any Street<br>SomeTown, ST 01234',
|
||||
'ship_to' => 'True Value Hardware<br>123 Any Street<br>SomeTown, ST 01234',
|
||||
'ship_to_postal_code' => '42016172',
|
||||
'pro' => '190071217845706',
|
||||
'item_number' => '10000B',
|
||||
'upc' => '098506095310',
|
||||
'quantity' => '1',
|
||||
'serial_shipping_container' => '(00)107904370000005',
|
||||
];
|
||||
|
||||
// Initialize barcode generator
|
||||
$generator = new BarcodeGeneratorPNG;
|
||||
|
||||
// Generate barcodes
|
||||
$shipToPostalCodeBarcode = $generator->getBarcode($data['ship_to_postal_code'], $generator::TYPE_CODE_128);
|
||||
$proBarcode = $generator->getBarcode($data['pro'], $generator::TYPE_CODE_128);
|
||||
$serialShippingContainerBarcode = $generator->getBarcode($data['serial_shipping_container'], $generator::TYPE_CODE_128, 2, 50);
|
||||
|
||||
// HTML content for the label
|
||||
// border="1" style="border-collapse: collapse; width: 100%; height: 300px;"
|
||||
$html = '
|
||||
<html>
|
||||
<style>
|
||||
.border_btm {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
.border_rght {
|
||||
border-right: 1px solid;
|
||||
}
|
||||
|
||||
.margin_t {
|
||||
padding-top : 10px;
|
||||
}
|
||||
|
||||
.align_lft {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@page { margin: 5px; }
|
||||
body { margin: 0px; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td colspan="2" class="border_btm border_rght align_lft">
|
||||
FROM:<br>' . $data['from'] . '
|
||||
</td>
|
||||
<td colspan="2" class="border_btm align_lft">
|
||||
SHIP TO:<br>' . $data['ship_to'] . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="border_btm border_rght margin_t align_lft">
|
||||
<img src="data:image/png;base64,' . base64_encode($shipToPostalCodeBarcode) . '"><br>
|
||||
(' . $data['ship_to_postal_code'] . ')
|
||||
</td>
|
||||
<td colspan="2" class="border_btm margin_t align_lft">
|
||||
Carrier Routing(SCAC) <br>
|
||||
PRO #: <br>
|
||||
B/L # :
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: center;" class="border_btm margin_t">
|
||||
PURCHASE ORDER: PO1234567 <br>
|
||||
<img src="data:image/png;base64,' . base64_encode($proBarcode) . '"><br>
|
||||
PRO: ' . $data['pro'] . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: left;" class="border_btm margin_t">
|
||||
ITEM #: ' . $data['item_number'] . '<br>
|
||||
UPC: ' . $data['upc'] . '<br>
|
||||
QUANTITY: ' . $data['quantity'] . '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: center;" class="margin_t">
|
||||
<img src="data:image/png;base64,' . base64_encode($serialShippingContainerBarcode) . '"><br>
|
||||
' . $data['serial_shipping_container'] . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
// Initialize Dompdf
|
||||
$dompdf = new Dompdf;
|
||||
$dompdf->loadHtml($html);
|
||||
$dompdf->setPaper('a6', 'portrait');
|
||||
// Render the HTML as PDF
|
||||
$dompdf->render();
|
||||
|
||||
// Output the generated PDF to Browser
|
||||
// $dompdf->stream();
|
||||
|
||||
$pdfContent = $dompdf->output();
|
||||
// // return $pdfContent;
|
||||
$labelsPath = '/www/sentm3live/htdocs/labels/';
|
||||
// # Put the PDF in labels/CarrierLabel
|
||||
$gSFolder = 'GSLabel';
|
||||
$carrierFileName = 'GSLabel';
|
||||
file_put_contents($labelsPath . $gSFolder . '/' . $carrierFileName . '.pdf', $pdfContent);
|
||||
|
||||
// Save the PDF string to a temporary file for debugging
|
||||
// $tempPdfPath = tempnam(sys_get_temp_dir(), 'pdf') . '.pdf';
|
||||
// // dump($tempPdfPath);
|
||||
// file_put_contents($tempPdfPath, $pdfContent);
|
||||
|
||||
// // Check if the PDF was generated correctly
|
||||
// if (!file_exists($tempPdfPath) || filesize($tempPdfPath) === 0) {
|
||||
// }
|
||||
|
||||
// Create an Imagick instance
|
||||
// $imagick = new \Imagick();
|
||||
|
||||
// // Read the PDF from the string
|
||||
// // $imagick->readImageBlob( $pdfContent );
|
||||
// // Read the PDF from the file
|
||||
// $imagick->readImage($tempPdfPath);
|
||||
|
||||
// // Set the resolution (optional)
|
||||
// $imagick->setResolution(300, 300);
|
||||
|
||||
// // Convert the first page of the PDF to an image
|
||||
// $imagick->setIteratorIndex(0);
|
||||
// $imagick->setImageFormat('png');
|
||||
|
||||
}
|
||||
|
||||
public static function miscTests(Request $request)
|
||||
{
|
||||
// $total_length = 9;
|
||||
// # MAK replace cache ID with MAX ID+1 from ICM695M3
|
||||
// $gS1SEQUENCESel = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m3')->max('ID');
|
||||
// dump($gS1SEQUENCESel);
|
||||
// $gS1SEQUENCE = isset($gS1SEQUENCESel) ? $gS1SEQUENCESel : 0;
|
||||
// $gS1SEQUENCE++;
|
||||
// $gS1SEQUENCEID = str_pad($gS1SEQUENCE, $total_length, "0", STR_PAD_LEFT);
|
||||
// dump($gS1SEQUENCEID);
|
||||
|
||||
// MAK Get Contents
|
||||
// ESN1
|
||||
// $aYMACPKR='888568'; // LTL example
|
||||
// $aYMACPKR='894337'; // another LTL example with smaller orders, therefore pallets are more mixed
|
||||
// $aYMACPKR='1225311'; // parcel example
|
||||
|
||||
// ESN2
|
||||
// $aYMACPKR='999999'; // LTL example
|
||||
$aYMACPKR = '748101'; // LTL example
|
||||
|
||||
$myRequest = new Request;
|
||||
$myRequest->setMethod('POST');
|
||||
|
||||
$myRequest->request->add([
|
||||
'MACPKR' => $aYMACPKR,
|
||||
]);
|
||||
|
||||
// Call the controller method properly
|
||||
$controller = new GetContentsController;
|
||||
$response = $controller->processShipment($myRequest);
|
||||
|
||||
$responseData = $response->getData();
|
||||
|
||||
$error = isset($responseData->error) ? $responseData->error : '';
|
||||
|
||||
if ($error == '') {
|
||||
// Get Commodities
|
||||
$commoditiesTmp = isset($responseData->commodities) ? $responseData->commodities : '';
|
||||
if ($commoditiesTmp != '') {
|
||||
$commodities = json_encode($commoditiesTmp);
|
||||
dump($commodities);
|
||||
} else {
|
||||
dump('Commodities Empty...');
|
||||
}
|
||||
} else {
|
||||
dump($error);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Log;
|
||||
use Storage;
|
||||
use Str;
|
||||
|
||||
class WhsPerfMetrics extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
$context = self::defaultContext();
|
||||
|
||||
try {
|
||||
$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', $context);
|
||||
}
|
||||
|
||||
public static function downloadFiles(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'filename' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
class WhsePerfController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
return view('m3::liberty-theme.pages.whsePerfRequest');
|
||||
|
||||
}
|
||||
|
||||
public static function displayTable(Request $request)
|
||||
{
|
||||
|
||||
// **********************************************************************************
|
||||
// **** Changes in this section must be replicated in function exportTable below ****
|
||||
// **********************************************************************************
|
||||
$date_in_yr = isset($request->date_in_yr) ? $request->date_in_yr : date('Y');
|
||||
$date_in_mth = isset($request->date_in_mth) ? $request->date_in_mth : date('m');
|
||||
$date_in = $date_in_yr . $date_in_mth . '01';
|
||||
$sqlstmt = 'select AVDATE, AVANOTESCL,AVADLRCL,AVAWGTCL,AVANOTESCH,AVADLRCH,AVAWGTCH,AVANOTESOP,AVADLROP,AVAWGTOP,
|
||||
AVLNOTESCL,AVLDLRCL,AVLWGTCL,AVLNOTESCH,AVLDLRCH,AVLWGTCH,AVLNOTESOP,AVLDLROP,AVLWGTOP,
|
||||
AVPNOTESCL,AVPDLRCL,AVPWGTCL,AVPNOTESCH,AVPDLRCH,AVPWGTCH,AVPNOTESOP,AVPDLROP,AVPWGTOP,
|
||||
AVINOTESCL,AVIDLRCL,AVIWGTCL,AVINOTESOP,AVIDLROP,AVIWGTOP
|
||||
from ICM711M
|
||||
where AVDATE between ' . date('Ym', strtotime($date_in)) . '00 and ' . date('Ym', strtotime($date_in)) . '32';
|
||||
|
||||
$iCM711M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
$uSER_INFO = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')->selectRaw('R428US as USERPRF, R428STS as STATUS, NULL as DATE_EXPIRED, NULL as EXPIRED')->get()->all();
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='" . strtoupper(m3_user()) . "'");
|
||||
|
||||
$pct_array = Config::get('arrays.whsePerf_targets');
|
||||
|
||||
return view('m3::liberty-theme.pages.whsePerf', ['ICM711M' => $iCM711M, 'power_user' => $power_user, 'USER_INFO' => $uSER_INFO, 'date_in' => $date_in, 'pct_array' => $pct_array]);
|
||||
|
||||
}
|
||||
|
||||
public function exportTable(Request $request)
|
||||
{
|
||||
|
||||
$date_in_yr = isset($request->date_in_yr) ? $request->date_in_yr : date('Y');
|
||||
$date_in_mth = isset($request->date_in_mth) ? $request->date_in_mth : date('m');
|
||||
$date_in = $date_in_yr . $date_in_mth . '01';
|
||||
$sqlstmt = 'select AVDATE, AVANOTESCL,AVADLRCL,AVAWGTCL,AVANOTESCH,AVADLRCH,AVAWGTCH,AVANOTESOP,AVADLROP,AVAWGTOP,
|
||||
AVLNOTESCL,AVLDLRCL,AVLWGTCL,AVLNOTESCH,AVLDLRCH,AVLWGTCH,AVLNOTESOP,AVLDLROP,AVLWGTOP,
|
||||
AVPNOTESCL,AVPDLRCL,AVPWGTCL,AVPNOTESCH,AVPDLRCH,AVPWGTCH,AVPNOTESOP,AVPDLROP,AVPWGTOP,
|
||||
AVINOTESCL,AVIDLRCL,AVIWGTCL,AVINOTESOP,AVIDLROP,AVIWGTOP
|
||||
from ICM711M
|
||||
where AVDATE between ' . date('Ym', strtotime($date_in)) . '00 and ' . date('Ym', strtotime($date_in)) . '32';
|
||||
|
||||
$iCM711M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
$uSER_INFO = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')->selectRaw('R428US as USERPRF, R428STS as STATUS, NULL as DATE_EXPIRED, NULL as EXPIRED')->get()->all();
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='" . strtoupper(m3_user()) . "'");
|
||||
|
||||
$pct_array = Config::get('arrays.whsePerf_targets');
|
||||
|
||||
$html = view('m3::liberty-theme.pages.whsePerf', ['ICM711M' => $iCM711M, 'power_user' => $power_user, 'USER_INFO' => $uSER_INFO, 'date_in' => $date_in, 'pct_array' => $pct_array])->render();
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
$doc = new \DOMDocument;
|
||||
$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); // Extract only table elements
|
||||
$tables = $doc->getElementsByTagName('table');
|
||||
if ($tables->length === 0) {
|
||||
abort(400, 'No table found in HTML');
|
||||
}
|
||||
// Create new document with only the table
|
||||
$newDoc = new \DOMDocument;
|
||||
$newDoc->appendChild($newDoc->importNode($tables->item(0), true));
|
||||
$cleanHtml = '<!DOCTYPE html><html><body>' . $newDoc->saveHTML() . '</body></html>';
|
||||
libxml_clear_errors();
|
||||
$tempFile = tempnam(sys_get_temp_dir(), 'html') . '.html';
|
||||
file_put_contents($tempFile, $cleanHtml);
|
||||
$reader = IOFactory::createReader('Html');
|
||||
$spreadsheet = $reader->load($tempFile);
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$fileName = 'export.xlsx';
|
||||
$tempExcel = tempnam(sys_get_temp_dir(), 'excel');
|
||||
$writer->save($tempExcel);
|
||||
unlink($tempFile);
|
||||
|
||||
return response()->download($tempExcel, $fileName)->deleteFileAfterSend(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WhsePerfDetailsController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
$date_in = isset($request->date) ? date('Y-m-d', strtotime($request->date)) : date('Y-m-d');
|
||||
$for = isset($request->for) ? $request->for : 'a';
|
||||
|
||||
$all = "tempfile4 as (
|
||||
select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source
|
||||
from tempfile3
|
||||
where not (a4shipvia1='OCEAN' or interco='interco') and source<>'A2'
|
||||
group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype
|
||||
)
|
||||
select * from tempfile4 order by source";
|
||||
|
||||
$ltl = "tempfile4 as (
|
||||
select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source
|
||||
from tempfile3
|
||||
where not (a4shipvia1='OCEAN' or interco='interco') and source<>'A2' and a4shiptype='LTL'
|
||||
group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype
|
||||
)
|
||||
select * from tempfile4 order by source";
|
||||
|
||||
$parcel = "tempfile4 as (
|
||||
select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source
|
||||
from tempfile3
|
||||
where not (a4shipvia1='OCEAN' or interco='interco') and source<>'A2' and a4shiptype='SmallPack'
|
||||
group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype
|
||||
)
|
||||
select * from tempfile4 order by source";
|
||||
|
||||
$io = "tempfile4 as (
|
||||
select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source
|
||||
from tempfile3
|
||||
where (a4shipvia1='OCEAN' or interco='interco') and source<>'A2'
|
||||
group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype
|
||||
)
|
||||
select * from tempfile4 order by source";
|
||||
|
||||
switch ($for) {
|
||||
case 'a':
|
||||
$stmt2 = $all;
|
||||
break;
|
||||
case 'l':
|
||||
$stmt2 = $ltl;
|
||||
break;
|
||||
case 'p':
|
||||
$stmt2 = $parcel;
|
||||
break;
|
||||
case 'i':
|
||||
$stmt2 = $io;
|
||||
break;
|
||||
default:
|
||||
$stmt2 = $all;
|
||||
break;
|
||||
}
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/../../KPI2_update711M_SQL_main.inc.php';
|
||||
$perfDetails = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt1 . $stmt2);
|
||||
|
||||
return view('m3::liberty-theme.pages.whsePerfDetails', compact('perfDetails', 'date_in', 'for'));
|
||||
|
||||
}
|
||||
}
|
||||
Executable
Executable
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('m3.login');
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class BasicAuth
|
||||
{
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
$login = trim((string) m3_user());
|
||||
$password = (string) m3_legacy_password();
|
||||
|
||||
if ($login !== '' && $this->checkPassword($login, $password, '%%SYSTEM%%')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return $this->unauthorized();
|
||||
}
|
||||
|
||||
private function checkPassword(string $login, string $password, string $passwordFile): bool
|
||||
{
|
||||
if (! is_readable($passwordFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$handle = fopen($passwordFile, 'rb');
|
||||
if ($handle === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
$parts = explode(':', trim($line), 2);
|
||||
if (count($parts) !== 2 || ! hash_equals($parts[0], $login)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$storedHash = trim($parts[1]);
|
||||
|
||||
return $storedHash !== '' && password_verify($password, $storedHash);
|
||||
}
|
||||
} finally {
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function unauthorized(): Response
|
||||
{
|
||||
return response('INVALID USERNAME OR PASSWORD. ACCESS DENIED', 401)
|
||||
->header('WWW-Authenticate', 'Basic realm="RESTRICTED ACCESS"');
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\M3\Providers\RouteServiceProvider;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string|null ...$guards
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
Executable
Executable
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ICM428M extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $connection = 'pgsql';
|
||||
|
||||
protected $table;
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'ICM428M';
|
||||
}
|
||||
|
||||
// R428DV R428PL R428WHS R428STS R428US R428FIRST R428FAMILY R428EMPCDE R428ADMUSR R428PWRUSR -->
|
||||
protected $fillable = [
|
||||
'R428CO', 'R428PL', 'R428WH', 'R428STS', 'R428US', 'R428FIRST', 'R428FAMILY', 'R428EMPCDE', 'R428ADMUSR', 'R428PWRUSR',
|
||||
];
|
||||
}
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ICM658M extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $connection = 'pgsql';
|
||||
|
||||
protected $table;
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'ICM658M';
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'R658CO', 'R658PL', 'R658WH', 'R658LC', 'R658PN', 'R658MQ', 'R658RQ', 'R658TL', 'R658RMQ', 'R658IZLCF',
|
||||
];
|
||||
}
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ShipTo extends Model
|
||||
{
|
||||
protected $table = 'ICM665M';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $primaryKey = ['AUSHSHZP', 'AUSHWHS'];
|
||||
|
||||
protected $uniqueKey = ['AUSHSHZP', 'AUSHWHS'];
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $fillable = [
|
||||
'AUSTCN',
|
||||
'AUSHSHNM',
|
||||
'AUSHSHA1',
|
||||
'AUSHSHA2',
|
||||
'AUSHSHCI',
|
||||
'AUSHSHST',
|
||||
'AUSHSHZP',
|
||||
'AUSHSHCT',
|
||||
'AUSHWHS',
|
||||
];
|
||||
|
||||
public function save(array $options = [])
|
||||
{
|
||||
if ($this->validateUniqueComposite()) {
|
||||
return parent::save($options);
|
||||
} else {
|
||||
return false;
|
||||
// ->withErrors(['unique' => 'The combination of AUSHSHZP and AUSHWHS must be unique'])
|
||||
// ->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
protected function validateUniqueComposite()
|
||||
{
|
||||
$query = self::query();
|
||||
|
||||
// Check if the combination of AUSHSHZP and AUSHWHS already exists
|
||||
$existingRecord = $query->where('AUSHSHZP', $this->AUSHSHZP)
|
||||
->where('AUSHWHS', $this->AUSHWHS);
|
||||
|
||||
// If this is an existing record being updated, exclude itself from the check
|
||||
if ($this->exists) {
|
||||
$existingRecord->where($this->getKeyName(), '!=', $this->getKey());
|
||||
}
|
||||
|
||||
if ($existingRecord->count() > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
Executable
Executable
+177
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Providers;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\M3\Support\ModuleInfo;
|
||||
|
||||
class M3ServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $moduleName = 'M3';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $moduleNameLower = 'm3';
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->registerHelpers();
|
||||
$this->registerCommands();
|
||||
$this->loadMigrationsFrom(module_path(ModuleInfo::name(), 'Database/Migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the helpers.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerHelpers(): void
|
||||
{
|
||||
foreach (glob(__DIR__ . '/../Helpers/*.php') as $filename) {
|
||||
require_once $filename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically Register Commands.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerCommands(): void
|
||||
{
|
||||
if (! $this->app->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
$commandPath = __DIR__ . '/../Console';
|
||||
$commands = collect(File::allFiles($commandPath))
|
||||
->map(function ($file) {
|
||||
return 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension();
|
||||
})
|
||||
->filter(function ($class) {
|
||||
return class_exists($class);
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
$this->commands($commands);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([
|
||||
module_path(ModuleInfo::name(), 'Config/config.php') => config_path(ModuleInfo::nameLower() . '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path(ModuleInfo::name(), 'Config/config.php'),
|
||||
ModuleInfo::nameLower(),
|
||||
);
|
||||
|
||||
// The legacy M3 application reads these keys directly as arrays.* and
|
||||
// arrays_custom.*. Keep those public config keys while the application
|
||||
// is hosted inside Core.
|
||||
$this->mergeConfigFrom(module_path(ModuleInfo::name(), 'Config/arrays.php'), 'arrays');
|
||||
$this->mergeConfigFrom(module_path(ModuleInfo::name(), 'Config/arrays_custom.php'), 'arrays_custom');
|
||||
|
||||
// Legacy M3 storage disks now live under Core storage by default.
|
||||
if (! config('filesystems.disks.publicLabels')) {
|
||||
config(['filesystems.disks.publicLabels' => [
|
||||
'driver' => 'local',
|
||||
'root' => config('m3.labels_path'),
|
||||
'visibility' => 'public',
|
||||
]]);
|
||||
}
|
||||
if (! config('filesystems.disks.publicCL')) {
|
||||
config(['filesystems.disks.publicCL' => [
|
||||
'driver' => 'local',
|
||||
'root' => config('m3.closing_orders_path'),
|
||||
'visibility' => 'public',
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . ModuleInfo::nameLower());
|
||||
$sourcePath = module_path(ModuleInfo::name(), 'Resources/views');
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath,
|
||||
], ['views', ModuleInfo::nameLower() . '-module-views']);
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Regsiter View Paths
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (Config::get('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . ModuleInfo::nameLower())) {
|
||||
$paths[] = $path . '/modules/' . ModuleInfo::nameLower();
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $moduleNamespace = 'Modules\M3\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::prefix('m3')
|
||||
->name('m3.')
|
||||
->middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('M3', '/Routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api/m3')
|
||||
->name('m3.api.')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('M3', '/Routes/api.php'));
|
||||
}
|
||||
}
|
||||
Executable
Executable
@@ -0,0 +1,26 @@
|
||||
/* M3 integration inside the Core WMS shell. Core owns the global sidebar, topbar, typography and appearance. */
|
||||
.m3-core-page{font-family:inherit;color:inherit;width:100%;max-width:1600px;margin:0 auto;padding:1.5rem}
|
||||
.m3-core-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1.5rem;padding:1.5rem;border:1px solid rgb(228 228 231);border-radius:1.5rem;background:linear-gradient(135deg,#020617,#0f172a 55%,#172554);color:#fff}
|
||||
.m3-core-eyebrow{margin:0 0 .5rem;font-size:.75rem;font-weight:700;letter-spacing:.28em;color:#bfdbfe}
|
||||
.m3-core-title{margin:0;font:inherit;font-size:2rem;font-weight:650;line-height:1.15;letter-spacing:-.025em;color:#fff}
|
||||
.m3-core-context{margin:.5rem 0 0;color:#dbeafe}
|
||||
.m3-core-actions{display:flex;gap:.5rem;flex-wrap:wrap}
|
||||
.m3-core-breadcrumb{margin-bottom:1rem;color:rgb(82 82 91);font-size:.875rem}
|
||||
.m3-core-content{color:rgb(24 24 27)}
|
||||
.m3-core-content .container-fluid{padding:0}
|
||||
.m3-core-content .panel,.m3-core-content .card,.m3-core-content .well{border:1px solid rgb(228 228 231);border-radius:1rem;background:#fff;box-shadow:0 1px 2px rgb(0 0 0/.04);overflow:hidden}
|
||||
.m3-core-content .panel-heading,.m3-core-content .card-header{background:rgb(250 250 250);border-bottom:1px solid rgb(228 228 231);padding:.9rem 1rem;font-weight:600}
|
||||
.m3-core-content table{color:inherit;background:transparent}
|
||||
.m3-core-content .table>tbody>tr>td,.m3-core-content .table>tbody>tr>th,.m3-core-content .table>tfoot>tr>td,.m3-core-content .table>tfoot>tr>th,.m3-core-content .table>thead>tr>td,.m3-core-content .table>thead>tr>th{border-color:rgb(228 228 231)}
|
||||
.m3-core-content input,.m3-core-content select,.m3-core-content textarea,.m3-core-content button{font-family:inherit}
|
||||
.m3-core-alert{padding:1rem;border:1px solid rgb(254 202 202);border-radius:1rem;background:rgb(254 242 242);color:rgb(153 27 27);font-weight:600}
|
||||
html.dark .m3-core-header{border-color:rgb(63 63 70);background:linear-gradient(135deg,#020617,#0f172a 55%,#172554)}
|
||||
html.dark .m3-core-breadcrumb{color:rgb(161 161 170)}
|
||||
html.dark .m3-core-content{color:rgb(244 244 245)}
|
||||
html.dark .m3-core-content .panel,html.dark .m3-core-content .card,html.dark .m3-core-content .well{border-color:rgb(63 63 70);background:rgb(24 24 27)}
|
||||
html.dark .m3-core-content .panel-heading,html.dark .m3-core-content .card-header{background:rgb(39 39 42);border-color:rgb(63 63 70);color:rgb(244 244 245)}
|
||||
html.dark .m3-core-content .table{color:rgb(244 244 245)}
|
||||
html.dark .m3-core-content .table>tbody>tr>td,html.dark .m3-core-content .table>tbody>tr>th,html.dark .m3-core-content .table>tfoot>tr>td,html.dark .m3-core-content .table>tfoot>tr>th,html.dark .m3-core-content .table>thead>tr>td,html.dark .m3-core-content .table>thead>tr>th{border-color:rgb(63 63 70)}
|
||||
html.dark .m3-core-content input,html.dark .m3-core-content select,html.dark .m3-core-content textarea{background:rgb(39 39 42);border-color:rgb(82 82 91);color:rgb(244 244 245)}
|
||||
html.dark .m3-core-alert{border-color:rgb(127 29 29);background:rgb(69 10 10);color:rgb(254 202 202)}
|
||||
@media(max-width:768px){.m3-core-page{padding:1rem}.m3-core-header{padding:1.25rem}.m3-core-title{font-size:1.6rem}}
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
/* M3 module styles are provided by the Core application theme. */
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
require('./bootstrap');
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
window._ = require('lodash');
|
||||
|
||||
/**
|
||||
* We'll load the axios HTTP library which allows us to easily issue requests
|
||||
* to our Laravel back-end. This library automatically handles sending the
|
||||
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
||||
*/
|
||||
|
||||
window.axios = require('axios');
|
||||
|
||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||
|
||||
/**
|
||||
* Echo exposes an expressive API for subscribing to channels and listening
|
||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||
* allows your team to easily build robust real-time web applications.
|
||||
*/
|
||||
|
||||
// import Echo from 'laravel-echo';
|
||||
|
||||
// window.Pusher = require('pusher-js');
|
||||
|
||||
// window.Echo = new Echo({
|
||||
// broadcaster: 'pusher',
|
||||
// key: process.env.MIX_PUSHER_APP_KEY,
|
||||
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
|
||||
// forceTLS: true
|
||||
// });
|
||||
Executable
Executable
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used during authentication for various
|
||||
| messages that we need to display to the user. You are free to modify
|
||||
| these language lines according to your application's requirements.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'password' => 'The provided password is incorrect.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
|
||||
];
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Pagination Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used by the paginator library to build
|
||||
| the simple pagination links. You are free to change them to anything
|
||||
| you want to customize your views to better match your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'previous' => '« Previous',
|
||||
'next' => 'Next »',
|
||||
|
||||
];
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are the default lines which match reasons
|
||||
| that are given by the password broker for a password update attempt
|
||||
| has failed, such as for an invalid token or invalid new password.
|
||||
|
|
||||
*/
|
||||
|
||||
'reset' => 'Your password has been reset!',
|
||||
'sent' => 'We have emailed your password reset link!',
|
||||
'throttled' => 'Please wait before retrying.',
|
||||
'token' => 'This password reset token is invalid.',
|
||||
'user' => "We can't find a user with that email address.",
|
||||
|
||||
];
|
||||
@@ -0,0 +1,57 @@
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Area Chart Example
|
||||
let ctx = document.getElementById("myAreaChart");
|
||||
if (ctx) {
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ["Mar 1", "Mar 2", "Mar 3", "Mar 4", "Mar 5", "Mar 6", "Mar 7", "Mar 8", "Mar 9", "Mar 10", "Mar 11", "Mar 12", "Mar 13"],
|
||||
datasets: [{
|
||||
label: "Sessions",
|
||||
lineTension: 0.3,
|
||||
backgroundColor: "rgba(2,117,216,0.2)",
|
||||
borderColor: "rgba(2,117,216,1)",
|
||||
pointRadius: 5,
|
||||
pointBackgroundColor: "rgba(2,117,216,1)",
|
||||
pointBorderColor: "rgba(255,255,255,0.8)",
|
||||
pointHoverRadius: 5,
|
||||
pointHoverBackgroundColor: "rgba(2,117,216,1)",
|
||||
pointHitRadius: 50,
|
||||
pointBorderWidth: 2,
|
||||
data: [10000, 30162, 26263, 18394, 18287, 28682, 31274, 33259, 25849, 24159, 32651, 31984, 38451],
|
||||
}],
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
time: {
|
||||
unit: 'date'
|
||||
},
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: {
|
||||
maxTicksLimit: 7
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
min: 0,
|
||||
max: 40000,
|
||||
maxTicksLimit: 5
|
||||
},
|
||||
gridLines: {
|
||||
color: "rgba(0, 0, 0, .125)",
|
||||
}
|
||||
}],
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Bar Chart Example
|
||||
let ctx = document.getElementById("myBarChart");
|
||||
if (ctx) {
|
||||
new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: ["January", "February", "March", "April", "May", "June"],
|
||||
datasets: [{
|
||||
label: "Revenue",
|
||||
backgroundColor: "rgba(2,117,216,1)",
|
||||
borderColor: "rgba(2,117,216,1)",
|
||||
data: [4215, 5312, 6251, 7841, 9821, 14984],
|
||||
}],
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
time: {
|
||||
unit: 'month'
|
||||
},
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: {
|
||||
maxTicksLimit: 6
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
min: 0,
|
||||
max: 15000,
|
||||
maxTicksLimit: 5
|
||||
},
|
||||
gridLines: {
|
||||
display: true
|
||||
}
|
||||
}],
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Pie Chart Example
|
||||
let ctx = document.getElementById("myPieChart");
|
||||
if (ctx){
|
||||
new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: ["Blue", "Red", "Yellow", "Green"],
|
||||
datasets: [{
|
||||
data: [12.21, 15.58, 11.25, 8.32],
|
||||
backgroundColor: ['#007bff', '#dc3545', '#ffc107', '#28a745'],
|
||||
}],
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Call the dataTables jQuery plugin
|
||||
$(document).ready(function() {
|
||||
$('#dataTable').DataTable();
|
||||
});
|
||||
+1
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,26 @@
|
||||
/* M3 integration inside the Core WMS shell. Core owns the global sidebar, topbar, typography and appearance. */
|
||||
.m3-core-page{font-family:inherit;color:inherit;width:100%;max-width:1600px;margin:0 auto;padding:1.5rem}
|
||||
.m3-core-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1.5rem;padding:1.5rem;border:1px solid rgb(228 228 231);border-radius:1.5rem;background:linear-gradient(135deg,#020617,#0f172a 55%,#172554);color:#fff}
|
||||
.m3-core-eyebrow{margin:0 0 .5rem;font-size:.75rem;font-weight:700;letter-spacing:.28em;color:#bfdbfe}
|
||||
.m3-core-title{margin:0;font:inherit;font-size:2rem;font-weight:650;line-height:1.15;letter-spacing:-.025em;color:#fff}
|
||||
.m3-core-context{margin:.5rem 0 0;color:#dbeafe}
|
||||
.m3-core-actions{display:flex;gap:.5rem;flex-wrap:wrap}
|
||||
.m3-core-breadcrumb{margin-bottom:1rem;color:rgb(82 82 91);font-size:.875rem}
|
||||
.m3-core-content{color:rgb(24 24 27)}
|
||||
.m3-core-content .container-fluid{padding:0}
|
||||
.m3-core-content .panel,.m3-core-content .card,.m3-core-content .well{border:1px solid rgb(228 228 231);border-radius:1rem;background:#fff;box-shadow:0 1px 2px rgb(0 0 0/.04);overflow:hidden}
|
||||
.m3-core-content .panel-heading,.m3-core-content .card-header{background:rgb(250 250 250);border-bottom:1px solid rgb(228 228 231);padding:.9rem 1rem;font-weight:600}
|
||||
.m3-core-content table{color:inherit;background:transparent}
|
||||
.m3-core-content .table>tbody>tr>td,.m3-core-content .table>tbody>tr>th,.m3-core-content .table>tfoot>tr>td,.m3-core-content .table>tfoot>tr>th,.m3-core-content .table>thead>tr>td,.m3-core-content .table>thead>tr>th{border-color:rgb(228 228 231)}
|
||||
.m3-core-content input,.m3-core-content select,.m3-core-content textarea,.m3-core-content button{font-family:inherit}
|
||||
.m3-core-alert{padding:1rem;border:1px solid rgb(254 202 202);border-radius:1rem;background:rgb(254 242 242);color:rgb(153 27 27);font-weight:600}
|
||||
html.dark .m3-core-header{border-color:rgb(63 63 70);background:linear-gradient(135deg,#020617,#0f172a 55%,#172554)}
|
||||
html.dark .m3-core-breadcrumb{color:rgb(161 161 170)}
|
||||
html.dark .m3-core-content{color:rgb(244 244 245)}
|
||||
html.dark .m3-core-content .panel,html.dark .m3-core-content .card,html.dark .m3-core-content .well{border-color:rgb(63 63 70);background:rgb(24 24 27)}
|
||||
html.dark .m3-core-content .panel-heading,html.dark .m3-core-content .card-header{background:rgb(39 39 42);border-color:rgb(63 63 70);color:rgb(244 244 245)}
|
||||
html.dark .m3-core-content .table{color:rgb(244 244 245)}
|
||||
html.dark .m3-core-content .table>tbody>tr>td,html.dark .m3-core-content .table>tbody>tr>th,html.dark .m3-core-content .table>tfoot>tr>td,html.dark .m3-core-content .table>tfoot>tr>th,html.dark .m3-core-content .table>thead>tr>td,html.dark .m3-core-content .table>thead>tr>th{border-color:rgb(63 63 70)}
|
||||
html.dark .m3-core-content input,html.dark .m3-core-content select,html.dark .m3-core-content textarea{background:rgb(39 39 42);border-color:rgb(82 82 91);color:rgb(244 244 245)}
|
||||
html.dark .m3-core-alert{border-color:rgb(127 29 29);background:rgb(69 10 10);color:rgb(254 202 202)}
|
||||
@media(max-width:768px){.m3-core-page{padding:1rem}.m3-core-header{padding:1.25rem}.m3-core-title{font-size:1.6rem}}
|
||||
@@ -0,0 +1,2 @@
|
||||
.morris-hover{overflow: auto; height: 300px;position:absolute;z-index:1000}.morris-hover.morris-default-style{border-radius:10px;padding:6px;color:#666;background:rgba(255,255,255,0.8);border:solid 2px rgba(230,230,230,0.8);font-family:sans-serif;font-size:12px;text-align:center}.morris-hover.morris-default-style .morris-hover-row-label{font-weight:bold;margin:0.25em 0}
|
||||
.morris-hover.morris-default-style .morris-hover-point{white-space:nowrap;margin:0.1em 0}
|
||||
+11820
File diff suppressed because it is too large
Load Diff
+1216
File diff suppressed because it is too large
Load Diff
+17
@@ -0,0 +1,17 @@
|
||||
/*!
|
||||
Bootstrap integration for DataTables' Editor
|
||||
©2015 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var e=a.length,d=0;d<e;d++){var f=a[d];if(b.call(c,f,d,a))return{i:d,v:f}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
|
||||
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
|
||||
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,b){var c=$jscomp.propertyToPolyfillSymbol[b];if(null==c)return a[b];c=a[c];return void 0!==c?c:a[b]};
|
||||
$jscomp.polyfill=function(a,b,c,e){b&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,b,c,e):$jscomp.polyfillUnisolated(a,b,c,e))};$jscomp.polyfillUnisolated=function(a,b,c,e){c=$jscomp.global;a=a.split(".");for(e=0;e<a.length-1;e++){var d=a[e];if(!(d in c))return;c=c[d]}a=a[a.length-1];e=c[a];b=b(e);b!=e&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})};
|
||||
$jscomp.polyfillIsolated=function(a,b,c,e){var d=a.split(".");a=1===d.length;e=d[0];e=!a&&e in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var f=0;f<d.length-1;f++){var k=d[f];if(!(k in e))return;e=e[k]}d=d[d.length-1];c=$jscomp.IS_SYMBOL_NATIVE&&"es6"===c?e[d]:null;b=b(c);null!=b&&(a?$jscomp.defineProperty($jscomp.polyfills,d,{configurable:!0,writable:!0,value:b}):b!==c&&($jscomp.propertyToPolyfillSymbol[d]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(d):$jscomp.POLYFILL_PREFIX+d,d=
|
||||
$jscomp.propertyToPolyfillSymbol[d],$jscomp.defineProperty(e,d,{configurable:!0,writable:!0,value:b})))};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(b,c){return $jscomp.findInternal(this,b,c).v}},"es6","es3");
|
||||
(function(a){"function"===typeof define&&define.amd?define(["jquery","datatables.net-bs5","datatables.net-editor"],function(b){return a(b,window,document)}):"object"===typeof exports?module.exports=function(b,c){b||(b=window);c&&c.fn.dataTable||(c=require("datatables.net-bs5")(b,c).$);c.fn.dataTable.Editor||require("datatables.net-editor")(b,c);return a(c,b,b.document)}:a(jQuery,window,document)})(function(a,b,c,e){var d=a.fn.dataTable;d.Editor.defaults.display="bootstrap";e=d.Editor.defaults.i18n;
|
||||
e.create.title='<h5 class="modal-title">'+e.create.title+"</h5>";e.edit.title='<h5 class="modal-title">'+e.edit.title+"</h5>";e.remove.title='<h5 class="modal-title">'+e.remove.title+"</h5>";a.extend(!0,a.fn.dataTable.Editor.classes,{header:{wrapper:"DTE_Header modal-header"},body:{wrapper:"DTE_Body modal-body"},footer:{wrapper:"DTE_Footer modal-footer"},form:{tag:"form-horizontal",button:"btn",buttonInternal:"btn btn-outline-secondary"},field:{wrapper:"DTE_Field form-group row",label:"col-lg-4 col-form-label",
|
||||
input:"col-lg-8",error:"error is-invalid","msg-labelInfo":"form-text text-secondary small","msg-info":"form-text text-secondary small","msg-message":"form-text text-secondary small","msg-error":"form-text text-danger small",multiValue:"card multi-value",multiInfo:"small",multiRestore:"card multi-restore"}});a.extend(!0,d.ext.buttons,{create:{formButtons:{className:"btn-primary"}},edit:{formButtons:{className:"btn-primary"}},remove:{formButtons:{className:"btn-danger"}}});d.Editor.fieldTypes.datatable.tableClass=
|
||||
"table";var f=!1,k=!1,l=a('<div class="modal fade DTED"><div class="modal-dialog modal-dialog-scrollable modal-dialog-centered"></div></div>'),v=a('<button class="btn-close"></div>'),n,u=b.bootstrap;d.Editor.bootstrap=function(g){u=g};d.Editor.display.bootstrap=a.extend(!0,{},d.Editor.models.displayController,{init:function(g){g.on("displayOrder.dtebs",function(h,m,q,r){a.each(g.s.fields,function(p,t){a("input:not([type=checkbox]):not([type=radio]), select, textarea",t.node()).addClass("form-control");
|
||||
a("input[type=checkbox], input[type=radio]",t.node()).addClass("form-check-input");a("select",t.node()).addClass("form-select")})});return d.Editor.display.bootstrap},open:function(g,h,m){n||(n=new u.Modal(l[0],{backdrop:"static",keyboard:!1}));a(h).addClass("modal-content");a(h).find("div.DTE_Field_Type_datatable div.dt-buttons").removeClass("btn-group").addClass("btn-group-vertical");v.attr("title",g.i18n.close).off("click.dte-bs5").on("click.dte-bs5",function(){g.close("icon")}).appendTo(a("div.modal-header",
|
||||
h));var q=!1;a(c).off("mousedown.dte-bs5").on("mousedown.dte-bs5","div.modal",function(p){q=a(p.target).hasClass("modal")&&f?!0:!1});a(c).off("click.dte-bs5").on("click.dte-bs5","div.modal",function(p){a(p.target).hasClass("modal")&&q&&g.background()});var r=l.find("div.modal-dialog");r.children().detach();r.append(h);f?m&&m():(f=!0,k=!1,a(l).one("shown.bs.modal",function(){g.s.setFocus&&g.s.setFocus.focus();k=!0;m&&m()}).one("hidden",function(){f=!1}).appendTo("body"),n.show())},close:function(g,
|
||||
h){if(f)if(k)a(l).one("hidden.bs.modal",function(){a(this).detach()}),n.hide(),k=f=!1,h&&h();else a(l).one("shown.bs.modal",function(){d.Editor.display.bootstrap.close(g,h)});else h&&h()},node:function(g){return l[0]}});return d.Editor});
|
||||
+1
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user