updates to M3 module
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?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",
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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,
|
||||
|
||||
?>
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
return [
|
||||
'name' => 'M3',
|
||||
'features' => [
|
||||
],
|
||||
'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')),
|
||||
];
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
|
||||
use Modules\M3\Http\Controllers\API\CloseShipment;
|
||||
|
||||
class CallCloseAPI extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:CallCloseAPI {user?} {manifest?} {co?} {whs?} ';
|
||||
|
||||
protected $description = 'Call Close API';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
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'));
|
||||
|
||||
try {
|
||||
# Get the Calling User
|
||||
$userId = $this->argument('user');
|
||||
$SHUSER = isset($userId) ? $userId : (m3_user() !== '' ? Str::upper(trim(m3_user())) : '');
|
||||
|
||||
# Get the Manifest Number
|
||||
$manifest = $this->argument('manifest');
|
||||
$MANIFESTNum = isset($manifest) ? $manifest : '';
|
||||
$co = $this->argument('co');
|
||||
$APCO = isset($co) ? $co : '';
|
||||
$whs = $this->argument('whs');
|
||||
$APWHS = isset($whs) ? $whs : '';
|
||||
|
||||
// if ($SHUSER!='') {
|
||||
// Log::channel('dailyCron')->info("Cron...Start CallCloseAPI...For Manifest#: ".$MANIFESTNum); // ".$SHUSER."
|
||||
|
||||
if( $MANIFESTNum==''){
|
||||
# Get Macpickers from ICM705M1
|
||||
$ICM705M1 = 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();
|
||||
// dump($ICM705M1);
|
||||
|
||||
if (count($ICM705M1)>0) {
|
||||
# Loop the Results from $ICM705M1
|
||||
foreach ($ICM705M1 as $key => $ICM705M1R) {
|
||||
$MANIFESTNum = $ICM705M1R->APMANIFEST;
|
||||
|
||||
$USERCO = isset($ICM705M1R->APCO) ? $ICM705M1R->APCO : '';
|
||||
$USERWH = isset($ICM705M1R->APWHS) ? $ICM705M1R->APWHS : '';
|
||||
|
||||
# Update ICM705M1 and set APSPARE2 to P
|
||||
$ICM705M1U = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->where('APMANIFEST',$MANIFESTNum)
|
||||
->where('APCO',$USERCO)
|
||||
->where('APWHS',$USERWH)
|
||||
->update(["APSPARE2"=>"P"]);
|
||||
|
||||
$myRequest = new Request();
|
||||
$myRequest->setMethod('POST');
|
||||
$myRequest->request->add([
|
||||
'WHS' => $USERWH,
|
||||
'COMPANY' => $USERCO,
|
||||
'TRANSTYPE' => 'M',
|
||||
'MANIFEST' => $MANIFESTNum
|
||||
]);
|
||||
$callCloseShipment = CloseShipment::CloseShipmentCoChargeAPI($myRequest);
|
||||
$responseData = $callCloseShipment->getData();
|
||||
$jsonData = json_encode($responseData);
|
||||
Log::channel('dailyCron')->info("Close Shipment API Response for Manifest:".(string)(int)$MANIFESTNum.'-'.$jsonData);
|
||||
}
|
||||
}
|
||||
}
|
||||
# Call Closing for a specific Manifest
|
||||
else{
|
||||
# Get Macpickers from ICM705M1
|
||||
$ICM705M1 = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->select('APMANIFEST','APCO','APWHS')
|
||||
->where('APSPARE2','')
|
||||
->where('APCO',$APCO)
|
||||
->where('APWHS',$APWHS)
|
||||
->where('APMANIFEST','=',$MANIFESTNum)
|
||||
->first();
|
||||
|
||||
# Update ICM705M1 and set APSPARE2 to P
|
||||
$ICM705M1U = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->where('APMANIFEST',$MANIFESTNum)
|
||||
->where('APCO',$APCO)
|
||||
->where('APWHS',$APWHS)
|
||||
->update(["APSPARE2"=>"P"]);
|
||||
|
||||
$myRequest = new Request();
|
||||
$myRequest->setMethod('POST');
|
||||
|
||||
$myRequest->request->add([
|
||||
'WHS' => $APWHS ,
|
||||
'COMPANY' => $APCO,
|
||||
'TRANSTYPE' => 'M',
|
||||
'MANIFEST' => $MANIFESTNum
|
||||
]);
|
||||
|
||||
$callCloseShipment = CloseShipment::CloseShipmentCoChargeAPI($myRequest);
|
||||
$responseData = $callCloseShipment->getData();
|
||||
$jsonData = json_encode($responseData);
|
||||
Log::channel('dailyCron')->info("Close Shipment API Response for Manifest:".$MANIFESTNum.'-'.$jsonData);
|
||||
return 1;
|
||||
}
|
||||
// }
|
||||
// else{
|
||||
// Log::channel('dailyCron')->error('A user must be defined...');
|
||||
|
||||
// $this->error('A user must be defined...');
|
||||
// }
|
||||
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
|
||||
use Excel;
|
||||
use Storage;
|
||||
|
||||
class ClosedOrderSaveXls extends Command
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
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('dailyCron')->info("Cron...Start Save Orders Closed Lines to Excel");
|
||||
|
||||
# Get the Calling User
|
||||
$userId = $this->argument('user');
|
||||
$SHUSER = isset($userId) ? $userId : (m3_user() !== '' ? Str::upper(trim(m3_user())) : '');
|
||||
|
||||
$CO = $this->argument('co');
|
||||
$COMPANY = isset($CO) ? trim($CO) : '';
|
||||
$PWHS = $this->argument('whs');
|
||||
$WHS = isset($PWHS) ? trim($PWHS) : '';
|
||||
$PPL = $this->argument('pl');
|
||||
$PLANT = isset($PPL) ? trim($PPL) : '';
|
||||
|
||||
# Generate last Month Report
|
||||
$date = new \DateTime('FIRST DAY OF THIS MONTH');
|
||||
$date->modify('-1 month');
|
||||
$fromPreviousMonth = $date->format('Y-m-d');
|
||||
$toPreviousMonth = $date->modify('last day of this month')->format('Y-m-d');
|
||||
$reportDate = \DateTime::createFromFormat('Y-m-d', $fromPreviousMonth )->format('Ymd');
|
||||
$toreportDate = \DateTime::createFromFormat('Y-m-d', $toPreviousMonth )->format('Ymd');
|
||||
$reportDateWD = $fromPreviousMonth;
|
||||
$toreportDateWD = $toPreviousMonth;
|
||||
|
||||
if ($WHS == '321') {
|
||||
$prevMonthFile = 'Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.xlsx';
|
||||
}
|
||||
else {
|
||||
$prevMonthFile = $WHS.'/Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'-'.$WHS.'.xlsx';
|
||||
}
|
||||
|
||||
$this->info("Generate Last Month Report...");
|
||||
$this->info("From Date: ".$reportDate);
|
||||
$this->info("To Date: ".$toreportDate);
|
||||
|
||||
# Check that the Excel file Exist
|
||||
$prevMonthFileExist = Storage::disk('publicCL')->exists($prevMonthFile) ? false: true ;
|
||||
$this->info("Prev Month File Exist: " .$prevMonthFileExist);
|
||||
|
||||
if($reportDate!='' && $COMPANY!='' && $WHS!='' && $PLANT!='' && $prevMonthFileExist ){
|
||||
# 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 = ["A5MACPKR" => 'Delivery #', "A5ONO" => 'Order #', "A4REFORD" => 'Order Type',"A5PART" => 'Part #',"A5RSVQTY" => 'Reserved',
|
||||
// "A5PACKED" => 'Packed',"CALCULATED_COLUMN" => 'Back Order Qty',"ANOTHER_CALCULATED_COLUMN" => 'Value Packed $',"A4SHSHNM" => 'Customer name',
|
||||
// "SHDT" => 'Date',"SHTIME" => 'Time',"REASON" => 'Failure Reason','A1SHCURR'=> 'Currency Code','FREIGHT'=> 'Freight'];
|
||||
|
||||
$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 55K records are allowed
|
||||
$ICM688M2Count = $ICM688M2Col->count();
|
||||
# Set Max allowed records
|
||||
$maxRecords = Config::get('arrays.maxRecCL');
|
||||
if ($ICM688M2Count>$maxRecords) {
|
||||
Log::channel('dailyCron')->info('Maximum allowed records for Excel export is: '.number_format($maxRecords).' current records: '.number_format($ICM688M2Count));
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ICM688M2Col = collect();
|
||||
}
|
||||
|
||||
if ($ICM688M2Col->count()>0) {
|
||||
$this->info("Saving Last Month Excel Report to Disk");
|
||||
Log::channel('dailyCron')->info("Saving Last Month Excel Report to Disk");
|
||||
|
||||
# Store the File to Storage
|
||||
app(\Modules\M3\Services\SpreadsheetExport::class)->store($ICM688M2Col, $prevMonthFile, 'publicCL');
|
||||
# Other File Formats : \Maatwebsite\Excel\Excel::CSV , ,\Maatwebsite\Excel\Excel::ODS
|
||||
}
|
||||
else{
|
||||
Log::channel('dailyCron')->info("Monthly report, no records found: Nothing to save...");
|
||||
}
|
||||
|
||||
# Generate current Month Report
|
||||
$now = new \DateTime();
|
||||
$first_day_of_month = $now->format('Y-m-01');
|
||||
$current_date = $now->format('Y-m-d');
|
||||
$reportDate2 = \DateTime::createFromFormat('Y-m-d', $first_day_of_month )->format('Ymd');
|
||||
$toreportDate2 = \DateTime::createFromFormat('Y-m-d', $current_date )->format('Ymd');
|
||||
|
||||
if ($WHS == '321') {
|
||||
$currentMonthFile = 'first_of_month_to_current_date.xlsx';
|
||||
}
|
||||
else{
|
||||
$currentMonthFile = $WHS.'/first_of_month_to_current_date_'.$WHS.'.xlsx';
|
||||
}
|
||||
|
||||
$this->info("Generate Current Month Report...");
|
||||
$this->info("From Date: ".$reportDate2);
|
||||
$this->info("To Date : ".$toreportDate2);
|
||||
|
||||
if($reportDate2!='' && $COMPANY!='' && $WHS!='' && $PLANT!=''){
|
||||
$this->info(">>> Proceed...");
|
||||
|
||||
# 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 $reportDate2 AND $toreportDate2
|
||||
)
|
||||
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT
|
||||
");
|
||||
|
||||
// $newItem2 = ["A5MACPKR" => 'Delivery #', "A5ONO" => 'Order #', "A4REFORD" => 'Order Type',"A5PART" => 'Part #',"A5RSVQTY" => 'Reserved',
|
||||
// "A5PACKED" => 'Packed',"CALCULATED_COLUMN" => 'Back Order Qty',"ANOTHER_CALCULATED_COLUMN" => 'Value Packed $',"A4SHSHNM" => 'Customer name',
|
||||
// "SHDT" => 'Date',"SHTIME" => 'Time',"REASON" => 'Failure Reason','A1SHCURR'=> 'Currency Code','FREIGHT'=> 'Freight'];
|
||||
|
||||
$newItem2 = ["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'];
|
||||
|
||||
$ICM688M2Col2 = collect($ICM688M2);
|
||||
$ICM688M2Col2->prepend($newItem2);
|
||||
|
||||
# Count records before exporting to excel : Max 55K records are allowed
|
||||
$ICM688M2Count = $ICM688M2Col2->count();
|
||||
# Set Max allowed records
|
||||
$maxRecords = Config::get('arrays.maxRecCL');
|
||||
if ($ICM688M2Count>$maxRecords) {
|
||||
Log::channel('dailyCron')->info('Maximum allowed records for Excel export is: '.number_format($maxRecords).' current records: '.number_format($ICM688M2Count));
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ICM688M2Col2 = collect();
|
||||
}
|
||||
|
||||
if ($ICM688M2Col2->count()>0) {
|
||||
$this->info("Saving Current Month Excel Report to Disk");
|
||||
Log::channel('dailyCron')->info("Saving Current Month Excel Report to Disk");
|
||||
# Store the File to Storage
|
||||
app(\Modules\M3\Services\SpreadsheetExport::class)->store($ICM688M2Col2, $currentMonthFile, 'publicCL');
|
||||
}
|
||||
else{
|
||||
Log::channel('dailyCron')->info("Daily Report, no records found: Nothing to save...");
|
||||
}
|
||||
|
||||
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::error($th);
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
use Storage;
|
||||
use File;
|
||||
|
||||
|
||||
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
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
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 $key => $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 {} \;');
|
||||
# exec('find '.$labelsDirectory.' -ctime +190 -type f -print | wc -l');
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
// $this->info("Files to Delete...");
|
||||
// dump($filesToDeleteArr);
|
||||
|
||||
# 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::error($th);
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
|
||||
use File;
|
||||
use DateTime;
|
||||
|
||||
use Storage;
|
||||
use Cache;
|
||||
use Picqer\Barcode\BarcodeGeneratorPNG;
|
||||
use Dompdf\Dompdf;
|
||||
|
||||
use Ayeo\Barcode;
|
||||
use PDF;
|
||||
use App;
|
||||
|
||||
use Zebra\Client;
|
||||
use Zebra\Zpl\Image;
|
||||
use Zebra\Zpl\Builder;
|
||||
use Zebra\Zpl\GdDecoder;
|
||||
|
||||
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
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
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 = isset($userId) ? $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);
|
||||
// dump($GSArray);
|
||||
|
||||
# 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();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$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 = '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;
|
||||
foreach ($GSArray['PackagesArray'] as $key => $value) {
|
||||
$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 = $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',
|
||||
'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>';
|
||||
// dump($html);
|
||||
// App::call('App\Http\Controllers\utilitiesContoller@generateGS128');
|
||||
|
||||
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();
|
||||
// dump($pdfContent);
|
||||
|
||||
$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::error($th);
|
||||
Log::channel('LabelCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
|
||||
use Modules\M3\Http\Controllers\utilitiesContoller;
|
||||
|
||||
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
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
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...");
|
||||
|
||||
// $this->info('User: '.$SHUSER);
|
||||
$myRequest = new Request();
|
||||
utilitiesContoller::fixICM799MSentPKR($myRequest);
|
||||
|
||||
// Log::channel('dailyCron')->info("Cron...End Save Orders Closed Lines to Excel");
|
||||
$this->info("End Utilities Command...");
|
||||
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
|
||||
|
||||
use Storage;
|
||||
|
||||
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
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
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('dailyCron')->info("Cron...Start Save WHS Metrics to Excel");
|
||||
|
||||
# Get the Calling User
|
||||
$userId = $this->argument('user');
|
||||
$SHUSER = isset($userId) ? $userId : (m3_user() !== '' ? Str::upper(trim(m3_user())) : '');
|
||||
|
||||
$CO = $this->argument('co');
|
||||
// $COMPANY = isset($CO) ? trim($CO) : '110';
|
||||
$COMPANY = '110';
|
||||
$PWHS = $this->argument('whs');
|
||||
// $WHS = isset($PWHS) ? trim($PWHS) : '321';
|
||||
$WHS = '321';
|
||||
$PPL = $this->argument('pl');
|
||||
// $PLANT = isset($PPL) ? trim($PPL) : '143';
|
||||
$PLANT = '143';
|
||||
|
||||
$date = new \DateTime();
|
||||
$DateToday = $date->format('Y-m-d');
|
||||
|
||||
# Define File Name
|
||||
$whsPerfFile = 'WhsPerf/'.$WHS.'/WhsPerfMetrics_'.$DateToday.'-'.$WHS.'.xlsx';
|
||||
Log::channel('dailyCron')->info(">>> File Name:");
|
||||
Log::channel('dailyCron')->info($whsPerfFile);
|
||||
|
||||
$this->info("Generate Today WHS Performance Report...");
|
||||
|
||||
if( $COMPANY!='' && $WHS!='' && $PLANT!='' ){
|
||||
# Get Header Content
|
||||
$ICM700MHeadSel = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select("
|
||||
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='$COMPANY' AND A3WHS='$WHS' AND A3PLT='$PLANT'
|
||||
)
|
||||
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
|
||||
");
|
||||
// dd($ICM700MHeadSel);
|
||||
|
||||
$newItem = ["A4SHIPTYPE" => 'Method', "STATUS" => 'Status', "SOURCE" => 'Source', "PICKERS" => 'Pickers',
|
||||
"WEIGHT" => 'Weight', "LINES" => 'Lines', "DOLLARS" => 'Dollars'];
|
||||
|
||||
# Trim All values
|
||||
$ICM700MHeadCol = collect($ICM700MHeadSel)->map(function ($item) {
|
||||
foreach ($item as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$item->{$key} = trim($value);
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
});
|
||||
# Prepend Header to Collection
|
||||
$ICM700MHeadCol->prepend($newItem);
|
||||
|
||||
// $this->info($ICM700MHeadCol);
|
||||
// Log::channel('dailyCron')->info(">>> Header Content");
|
||||
// Log::channel('dailyCron')->info($ICM700MHeadCol);
|
||||
|
||||
# Count records before exporting to excel
|
||||
$ICM700MHeadCount = $ICM700MHeadCol->count();
|
||||
|
||||
# Get Details Content
|
||||
$ICM700MDetailsSel = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select("
|
||||
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='$COMPANY' AND A3WHS='$WHS' AND A3PLT='$PLANT'
|
||||
)
|
||||
SELECT * FROM TEMPFILE
|
||||
");
|
||||
|
||||
$newItem2 = ["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' ];
|
||||
# Trim all values
|
||||
$ICM700MDetailsCol = collect($ICM700MDetailsSel)->map(function ($item) {
|
||||
foreach ($item as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$item->{$key} = trim($value);
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
});
|
||||
|
||||
# Prepend Header
|
||||
$ICM700MDetailsCol->prepend($newItem2);
|
||||
|
||||
# Count records before exporting to excel
|
||||
$ICM700MDetailsCount = $ICM700MDetailsCol->count();
|
||||
}
|
||||
else{
|
||||
$ICM700MDetailsCol = collect();
|
||||
}
|
||||
// Log::channel('dailyCron')->info(">>> Detail Content");
|
||||
// Log::channel('dailyCron')->info($ICM700MDetailsCol);
|
||||
|
||||
# Save Head and Details to XLS file
|
||||
if ($ICM700MHeadCount>0 && $ICM700MDetailsCount>0) {
|
||||
$this->info("Saving Today WHS Performance Report to Disk...");
|
||||
Log::channel('dailyCron')->info("Saving Today WHS Performance Report to Disk...");
|
||||
|
||||
# Store both collections in one XLSX workbook using Core's PhpSpreadsheet dependency.
|
||||
app(\Modules\M3\Services\SpreadsheetExport::class)->storeSheets([
|
||||
'Summary' => $ICM700MHeadCol,
|
||||
'Details' => $ICM700MDetailsCol,
|
||||
], $whsPerfFile, 'publicLabels');
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
Log::channel('dailyCron')->info("Today WHS Performance Report, no records found: Nothing to save...");
|
||||
}
|
||||
|
||||
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::error($th);
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Modules\M3\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class M3DatabaseSeeder extends Seeder
|
||||
{
|
||||
@@ -16,5 +16,6 @@ class M3DatabaseSeeder extends Seeder
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,382 @@
|
||||
<?php
|
||||
|
||||
use Modules\M3\Support\ModuleInfo;
|
||||
namespace Modules\M3\Helpers;
|
||||
|
||||
if (! function_exists('m3_feature_enabled')) {
|
||||
/**
|
||||
* Check if a feature is enabled in the config.
|
||||
*/
|
||||
function m3_feature_enabled(string $key): bool
|
||||
use Gate;
|
||||
use DB;
|
||||
use Config;
|
||||
use Form;
|
||||
use Auth;
|
||||
use Redirect;
|
||||
use Mail;
|
||||
use Log;
|
||||
use Cache;
|
||||
use Str;
|
||||
use File;
|
||||
|
||||
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;
|
||||
// Log::info("Cached Token: ".$IonToken);
|
||||
}
|
||||
else{
|
||||
### CURL
|
||||
### Generate Token
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
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 => array(
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'charset:UTF-8',
|
||||
'Accept: application/json'
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
// dd($response);
|
||||
$responseJ = json_decode($response);
|
||||
|
||||
if($response === false ){
|
||||
return response()->json([
|
||||
'code' =>'400',
|
||||
'status' =>'Failed',
|
||||
'message' =>'Token Verification Error...'.curl_error($curl)
|
||||
]);
|
||||
}
|
||||
else if(isset($responseJ->access_token) ){
|
||||
$IonToken = $responseJ->access_token;
|
||||
// Log::info("New Token: " . $IonToken);
|
||||
|
||||
Cache::put('token', $IonToken, now()->addMinutes(59));
|
||||
}
|
||||
else{
|
||||
// dd($response);
|
||||
return response()->json([
|
||||
'code' =>'400',
|
||||
'status' =>'Failed',
|
||||
'message' =>'Token Verification Error...M3 response:'.$response
|
||||
]);
|
||||
}
|
||||
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
return $IonToken;
|
||||
// return response()->json([
|
||||
// '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;
|
||||
// Log::info("Cached Token: ".$IonToken);
|
||||
}
|
||||
else{
|
||||
### CURL
|
||||
### Generate Token
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
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 => array(
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'charset:UTF-8',
|
||||
'Accept: application/json'
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
// dd($response);
|
||||
$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)
|
||||
]);
|
||||
}
|
||||
else if(isset($responseJ->access_token) ){
|
||||
$IonToken = $responseJ->access_token;
|
||||
// Log::info("New Token: " . $IonToken);
|
||||
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 $IonToken;
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'token' => $IonToken
|
||||
]);
|
||||
}
|
||||
|
||||
# Read M3 JSON and Analyse it for Errors
|
||||
public static function checkM3Errors($responseResult){
|
||||
// dd($responseResult);
|
||||
# M3 Response Types
|
||||
$M3TypesResponse = ['CloseShipment','Move','COCharge','Replenish','MoveDock'];
|
||||
# CloseShipment Types And Contents
|
||||
$M3CloseShipmentResp = ['AddPackage','PickingListClose','TrailerNo','TrackingNo','ContentLabel', 'DeliveryNote','ShipLabel'];
|
||||
// 'ContentLabel', 'DeliveryNote','ShipLabel'
|
||||
$ErrorMessages = '';
|
||||
|
||||
$typesErrors =0;
|
||||
|
||||
foreach ($M3TypesResponse as $key => $Type) {
|
||||
// dump($responseResult->$Type);
|
||||
if ($Type=='CloseShipment') {
|
||||
// dump($Type);
|
||||
$CloseShipmentErr = 0;
|
||||
$M3RespClose = $responseResult->$Type;
|
||||
foreach ($M3CloseShipmentResp as $key => $closeType) {
|
||||
$ErrorMessage = $M3RespClose->$closeType->ErrorMessage;
|
||||
$ErrorMessage = $ErrorMessage=="" ? "" : $ErrorMessage;
|
||||
$Result = $M3RespClose->$closeType->Result;
|
||||
$ResultT = $M3RespClose->$closeType->Result;
|
||||
$Result = $Result=="N/A" || $Result=="OK" ? "" : $Result;
|
||||
if ($ErrorMessage!='' || $Result!='') {
|
||||
$ErrorMessages .= $closeType.'-'.$Result.'-'.$ErrorMessage.' ';
|
||||
}
|
||||
// dump($closeType);// dump($ErrorMessage);// dump($Result);
|
||||
|
||||
if ($ResultT=="N/A") {
|
||||
$CloseShipmentErr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($Type=='MoveDock'){
|
||||
$MoveDockRes = isset($responseResult->$Type->Move) ? $responseResult->$Type->Move : '';
|
||||
$ErrorMessage = isset($MoveDockRes->ErrorMessage) ? $MoveDockRes->ErrorMessage :'';
|
||||
$ErrorMessage = $ErrorMessage=="" ? "" : $ErrorMessage;
|
||||
$Result = isset($MoveDockRes->Result) ? $MoveDockRes->Result : "";
|
||||
$ResultT = $Result;
|
||||
$Result = $Result=="N/A" || $Result=="OK" ? "" : $Result;
|
||||
if ($ErrorMessage!='' || $Result!='') {
|
||||
$ErrorMessages .= $Type.'-'.$Result.'-'.$ErrorMessage.' ';
|
||||
}
|
||||
// dump($Type);// dump($ErrorMessage);// dump($Result);// dump($responseResult->$Type);
|
||||
if ($ResultT=="N/A") {
|
||||
$typesErrors++;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$ErrorMessage = isset($responseResult->$Type->ErrorMessage) ? $responseResult->$Type->ErrorMessage :'';
|
||||
$ErrorMessage = $ErrorMessage=="" ? "" : $ErrorMessage;
|
||||
$Result = isset($responseResult->$Type->Result) ? $responseResult->$Type->Result : "";
|
||||
$ResultT = $Result;
|
||||
$Result = $Result=="N/A" || $Result=="OK" ? "" : $Result;
|
||||
if ($ErrorMessage!='' || $Result!='') {
|
||||
$ErrorMessages .= $Type.'-'.$Result.'-'.$ErrorMessage.' ';
|
||||
}
|
||||
// dump($Type); // dump($ErrorMessage); // dump($Result); // dump($responseResult->$Type);
|
||||
if ($ResultT=="N/A") {
|
||||
$typesErrors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// dd($ErrorMessages);
|
||||
|
||||
if ($CloseShipmentErr == count($M3CloseShipmentResp) && $typesErrors == count($M3TypesResponse)-1) {
|
||||
$ErrorMessages .= '-M3 did not call any method or type ';
|
||||
}
|
||||
|
||||
return $ErrorMessages;
|
||||
}
|
||||
|
||||
# Log All Success And Error to ICM699M
|
||||
public static function logToICM699M($data){
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOut'));
|
||||
|
||||
$insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('ICM699M')->insert($data);
|
||||
// dump($data);
|
||||
// dump($insertSQL);
|
||||
}
|
||||
|
||||
# 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 '';
|
||||
}
|
||||
$substring = substr($string, $startPos + strlen($start), $endPos - ($startPos + strlen($start)));
|
||||
return $substring;
|
||||
}
|
||||
|
||||
public static function checkLength($JSONL,$DBL,$TYPE)
|
||||
{
|
||||
return (bool) config(ModuleInfo::nameLower() . ".features.{$key}", false);
|
||||
# Check type
|
||||
$JSONType = gettype($JSONL);
|
||||
|
||||
switch ($JSONType) {
|
||||
case 'string':
|
||||
$JSONTypeConv = 'string';
|
||||
break;
|
||||
case 'double':
|
||||
$JSONTypeConv = 'number';
|
||||
break;
|
||||
case 'integer':
|
||||
$JSONTypeConv = 'number';
|
||||
break;
|
||||
default:
|
||||
$JSONTypeConv = 'null';
|
||||
break;
|
||||
}
|
||||
|
||||
$TYPE = $TYPE == 'integer' || $TYPE == 'DEC' ? 'number' : $TYPE;
|
||||
// Log::info( $JSONL .' L: '. strlen($JSONL) .' DBL: '. $DBL .' Type:'.$JSONType.':'.$TYPE );
|
||||
|
||||
// Check Json Field should be < DB Field
|
||||
$LengthOK[413] = ( strlen($JSONL) <= $DBL ) ? true : false ;
|
||||
// Empty Fields
|
||||
$LengthOK[411] = true; //!empty($JSONL) ? true : false ;
|
||||
// Wrong Types
|
||||
$LengthOK[417] = true; //$JSONTypeConv == $TYPE ? true : false ;
|
||||
// Log::info($LengthOK);
|
||||
|
||||
return $LengthOK;
|
||||
}
|
||||
|
||||
public static function sanityzeString($StrTosanityze)
|
||||
{
|
||||
$badChars = Config::get('arrays.BadChars');
|
||||
|
||||
$goodString = trim($StrTosanityze);
|
||||
$goodString = str_replace("'", "",$goodString);
|
||||
$goodString = preg_replace('/\x{f0e0}/u', '', $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 = "";
|
||||
// }
|
||||
|
||||
// dump($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(){
|
||||
# Get Current USER
|
||||
$loggedUser = strtoUpper(m3_user());
|
||||
// dump($loggedUser);
|
||||
$getUsers = DB::connection(config('m3.connection', 'pgsql'))->select("select R428US, R428ADMUSR, R428PWRUSR, R428CO, R428PL, R428WH, R42811A,R42821A from ICM428M where R428US='".$loggedUser."'");
|
||||
|
||||
foreach ($getUsers as $key=>$user) {
|
||||
if(trim($user->R428ADMUSR)=="Y") {
|
||||
# Different logic from Qinclude version : this not an Array
|
||||
$admin_users=trim($user->R428ADMUSR);
|
||||
}
|
||||
if(trim($user->R428PWRUSR)=="Y") {
|
||||
# Different logic from Qinclude version : this not an Array
|
||||
$power_users=trim($user->R428PWRUSR);
|
||||
}
|
||||
if(trim($user->R42811A)=="C") {
|
||||
$csr="Y";
|
||||
}
|
||||
if(trim($user->R42821A)=="Y") {
|
||||
$execUser="Y";
|
||||
}
|
||||
$UserCO = $user->R428CO;
|
||||
$UserWHS = $user->R428WH;
|
||||
$UserPL = $user->R428PL;
|
||||
|
||||
$currentUser = [
|
||||
'UserCO' => $UserCO,
|
||||
'UserWHS' => $UserWHS,
|
||||
'UserPL' => $UserPL,
|
||||
];
|
||||
return $currentUser;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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 '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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'
|
||||
];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,464 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use DB;
|
||||
use Config;
|
||||
use Str;
|
||||
use Log;
|
||||
use Helper;
|
||||
|
||||
class M3Controller extends Controller
|
||||
{
|
||||
# Split Data and Write to ICM666M2
|
||||
public function insertToICM666M2($dataSplit, $commentData)
|
||||
{
|
||||
// dump($commentData);
|
||||
// dump($dataSplit);
|
||||
|
||||
$commentDataSS = explode("\n", $dataSplit);
|
||||
$AXLINENO = 1;
|
||||
foreach ($commentDataSS as $substring) {
|
||||
# Process each substring
|
||||
$fullData = $commentData;
|
||||
$fullData['AXCOMMENT'] = $substring;
|
||||
$fullData['AXLINENO'] = $AXLINENO;
|
||||
// dump($fullData);
|
||||
$insertSQL = 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(){}
|
||||
|
||||
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"] : '';
|
||||
// $ExchangeRate = isset($jsonFile["ExchangeRate"]) ? $jsonFile["ExchangeRate"] : '';
|
||||
$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];
|
||||
// dump($commentData);
|
||||
|
||||
switch ($AXDOCUMENT) {
|
||||
case 'Picker':
|
||||
$Picker = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
// dump($Picker);
|
||||
if ($Picker!='null') {
|
||||
$this->insertToICM666M2($Picker,$commentData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Packer':
|
||||
$Packer = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
// dump($Packer);
|
||||
if ($Packer!='null') {
|
||||
$this->insertToICM666M2($Packer,$commentData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Carrier':
|
||||
$Carrier = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
// dump($Carrier);
|
||||
if ($Carrier!='null') {
|
||||
$this->insertToICM666M2($Carrier,$commentData);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Other':
|
||||
$Other = isset($comment) ? Helper::sanityzeString($comment) : 'null';
|
||||
// dump($Other);
|
||||
if ($Other!='null') {
|
||||
$this->insertToICM666M2($Other,$commentData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Get Products : commodities And Write ICM666M
|
||||
$tmpProd = "";
|
||||
$products = $jsonFile["Contents"]["Commodities"];
|
||||
foreach($products as $key => $product) {
|
||||
$Quantity = isset($product['Quantity']) ? $product['Quantity'] : '';
|
||||
$Description = isset($product['Description']) ? Str::limit($product['Description'],25,'') : '';
|
||||
$PartNumber = isset($product['PartNumber']) ? $product['PartNumber']: '';
|
||||
$OrderLine = isset($product['OrderLine']) ? $product['OrderLine']: '';
|
||||
$PartWeight = isset($product['PartWeight']) ? $product['PartWeight']: '';
|
||||
$PickerLine = isset($product['PickerLine']) ? $product['PickerLine']: '';
|
||||
$PrimaryLocation = isset($product['PrimaryLocation']) ? $product['PrimaryLocation']: '';
|
||||
$Allocation = isset($product['Allocation']) ? $product['Allocation']: '';
|
||||
$AllocatedTo = isset($product['AllocatedTo']) ? $product['AllocatedTo']: '';
|
||||
$LocationSeq = isset($product['LocationSeq']) ? $product['LocationSeq']: '';
|
||||
$Zone = isset($product['Zone']) ? $product['Zone']: '';
|
||||
$BaseUnitPrice = isset($product['BaseUnitPrice']) ? $product['BaseUnitPrice'] : '';
|
||||
$FrgnUnitPrice = isset($product['FrgnUnitPrice']) ? $product['FrgnUnitPrice'] : '';
|
||||
$SellUOM = isset($product['SellUOM']) ? $product['SellUOM'] : '';
|
||||
$PartConv = isset($product['PartConv']) ? $product['PartConv'] : '';
|
||||
$UOM = isset($product['UOM']) ? $product['UOM']: '';
|
||||
$HazMat = isset($product['HazMat']) ? $product['HazMat']: '';
|
||||
$PartUPC = isset($product['PartUPC']) ? $product['PartUPC']: '';
|
||||
$PartEAN = isset($product['PartEAN']) ? $product['PartEAN']: '';
|
||||
$LotFlag = isset($product['LotFlag']) ? $product['LotFlag']: '';
|
||||
$ManOrd = isset($product['ManOrd']) ? $product['ManOrd']: '';
|
||||
$LotNumber = isset($product['LotNumber']) ? $product['LotNumber']: '';
|
||||
$ProductArea = isset($product['ProductArea']) ? $product['ProductArea']: '';
|
||||
$FreightClass = isset($product['FreightClass']) ? $product['FreightClass']: '';
|
||||
$ShipmentPOLine = isset($product['ShipmentPOLine']) ? $product['ShipmentPOLine']: '';
|
||||
$LocationType = isset($product['LocationType']) ? $product['LocationType']: '';
|
||||
$PallSize = isset($product['PallSize']) ? $product['PallSize']: '';
|
||||
$MasterCarton = isset($product['MasterCarton']) ? $product['MasterCarton']: '';
|
||||
$MasterQty = isset($product['MasterQty']) ? $product['MasterQty']: '';
|
||||
$InnerQty = isset($product['InnerQty']) ? $product['InnerQty']: '';
|
||||
$PalletQty = isset($product['PalletQty']) ? $product['PalletQty']: '';
|
||||
$CartonQty = isset($product['CartonQty']) ? $product['CartonQty']: '';
|
||||
$KitPartNumber = isset($product['KitPartNumber']) ? $product['KitPartNumber']: '';
|
||||
$OrderLineSuffix = isset($product['OrderLineSuffix']) ? $product['OrderLineSuffix']: '';
|
||||
$CustomerPartNumber = isset($product['CustomerPartNumber']) ? substr($product['CustomerPartNumber'], 0, 20): ''; # Limit to 20 Chars
|
||||
|
||||
# Initialise Table Fields to be filled
|
||||
$InsertArray = [];
|
||||
|
||||
# Check JSON fields if empty or > DB Fields
|
||||
foreach ($ICM666MFields as $key => $value) {
|
||||
$keyVar = $key;
|
||||
# Sanitize String
|
||||
$$keyVar = Helper::sanityzeString($$keyVar);
|
||||
# Check Var Types & Length
|
||||
$LengthTest = Helper::checkLength($$keyVar, $value[1], $value[2]);
|
||||
|
||||
if (!$LengthTest[413] || !$LengthTest[411] || !$LengthTest[417]) {
|
||||
// Log::error($key .' :: '. $value[0].' :: '. $value[1] .' JSONF: '.$$keyVar .' Type: '.$value[2] );
|
||||
if(!$LengthTest[413]){
|
||||
$message[] = [ 'code'=>'413', 'status'=>'error', 'message'=>'Field: '.$key.' is larger then expected'];
|
||||
}
|
||||
if(!$LengthTest[411]){
|
||||
$message[] = [ 'code'=>'411', 'status'=>'error', 'message'=>'Field: '.$key.' is empty'];
|
||||
}
|
||||
if(!$LengthTest[417]){
|
||||
$message[] = [ 'code'=>'417', 'status'=>'error', 'message'=>'Field: '.$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).' M3-Lis-JSN'.json_encode($jsonFile) ,'SHUSER'=> $REQKPKUS,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$Company,'SHWHS'=>$Warehouse ];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json($message);
|
||||
} else if ($$keyVar != '') {
|
||||
$InsertArray[$value[0]] = $$keyVar;
|
||||
}
|
||||
}
|
||||
// Log::info($InsertArray);
|
||||
|
||||
# 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;
|
||||
|
||||
// if ($PalletQty!='') {
|
||||
// $InsertArray['A1USRN01']=$palletQty;
|
||||
// }
|
||||
|
||||
# SQL Insert to ICM666M
|
||||
$insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm666m')->insert($InsertArray);
|
||||
}
|
||||
|
||||
# Call PGM ICM700CSBM
|
||||
if ($Warehouse!='' && $PickerNumber!='' && $Company!='') {
|
||||
$PGMERRORS = '';
|
||||
$AWREQN = '';
|
||||
|
||||
# connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(\Modules\M3\Services\PostgresProgramBridge::class);
|
||||
} catch (Exception $e) {
|
||||
# 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(array('persistent' => false, 'stateless' => true, 'debug' => true,'debugLogFile' => env('TOOLKIT_DEBUG_LOG')));
|
||||
|
||||
# Add LIB
|
||||
# $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)');
|
||||
|
||||
# define several input/output params
|
||||
$params = [];
|
||||
# $params[] = $conn->AddParameterChar('out',7,'eqNumber');
|
||||
|
||||
# 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);
|
||||
// $params[] = $conn->AddParameterZoned('in', 11, 0, 'ParamIn');
|
||||
|
||||
# Start Time Tracking
|
||||
$start = microtime(true);
|
||||
|
||||
# ICM700C EWOBJTST ICM700C ICM700CSBM
|
||||
$result = $conn->PgmCall('ICM700CSBM', env('OBJLIB'), $params, array(), array());
|
||||
|
||||
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 .' M3-Lis-JSN'.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).' M3-Lis-JSN'.json_encode($jsonFile) ,'SHUSER'=> $REQKPKUS,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$Company,'SHWHS'=>$Warehouse ];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
// Log::error($th);
|
||||
return response()->json([
|
||||
'code'=>'405',
|
||||
'status'=>'error',
|
||||
'message'=>'An Error Occured...'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id){}
|
||||
|
||||
public function edit($id){}
|
||||
|
||||
public function update(Request $request, $id){}
|
||||
|
||||
public function destroy($id){}
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use DB;
|
||||
use Config;
|
||||
use Str;
|
||||
use Log;
|
||||
use Http;
|
||||
use Cache;
|
||||
use DateTime;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use File;
|
||||
use Helper;
|
||||
use Json;
|
||||
|
||||
class M3InventoryReport extends Controller
|
||||
{
|
||||
# M3InventoryReport for Single Part
|
||||
public function M3InventoryReport(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->json()->all());
|
||||
|
||||
# Get the Calling User
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WEBUSER';
|
||||
# Set SHSOURCE
|
||||
$SHSOURCE = 'M3InventoryReport';
|
||||
$M3Errors = '';
|
||||
$DELIVERYNO = isset($DELIVERYNO) ? $DELIVERYNO : '000000';
|
||||
|
||||
try {
|
||||
# Get Json Contents
|
||||
$jsonFile = count($request->json()->all())>0 ? $request->json()->all() : '';
|
||||
if($jsonFile!=''){
|
||||
$WHS = isset($jsonFile["WHS"]) ? $jsonFile["WHS"] : '';
|
||||
$PART = isset($jsonFile["PART"]) ? $jsonFile["PART"] : '';
|
||||
$LOT = isset($jsonFile["LOT"]) ? $jsonFile["LOT"] : '';
|
||||
}
|
||||
else {
|
||||
# code...
|
||||
}
|
||||
|
||||
# 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'=>'000000','SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> '','SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=> $SHDATA ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>'','SHWHS'=>$WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return $tokenResponse;
|
||||
}
|
||||
|
||||
# Call ionapi with Params
|
||||
$endPointURL = env('ENDPOINTURL').'APIFLOWS/Sentinel/M3InventoryReport?ionapiRespStyle=sync';
|
||||
$token = $IonToken;
|
||||
$JSON = [
|
||||
"WHS" => $WHS,
|
||||
"PART"=> $PART,
|
||||
"LOT" => $LOT
|
||||
];
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'accept' => 'application/json',
|
||||
'Content-Type' => 'application/json'
|
||||
])
|
||||
->withToken($token)
|
||||
->timeout(Config::get('arrays.curlTimeOut'))
|
||||
->post($endPointURL, $JSON);
|
||||
$responseStatusCode = $response->getStatusCode();
|
||||
|
||||
$M3SessionId = $response->hasHeader('x-transaction-id') ? "-sessionID:". $response->header('x-transaction-id') : '-sessionID';
|
||||
|
||||
if ($responseStatusCode =='200') {
|
||||
# Check M3 Response for Errors
|
||||
$M3Errors = '';
|
||||
$responseJSON = $response->getBody()->getContents();
|
||||
$JsonSanytized = Helper::sanityzeString($responseJSON);
|
||||
}
|
||||
else{
|
||||
$M3Errors = 'Error: No Response from M3';
|
||||
}
|
||||
|
||||
if ($M3Errors!='') {
|
||||
# Write to Logs : Error
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'X','SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>$responseStatusCode.$M3Errors.$M3SessionId ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>'','SHWHS'=>$WHS ];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Send Response
|
||||
return response()->json([
|
||||
'code'=>'405',
|
||||
'status'=>'error',
|
||||
'message'=>$M3Errors
|
||||
]);
|
||||
}
|
||||
else{
|
||||
# Write to Logs Out : Success
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> '','SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>$responseStatusCode.$JsonSanytized.'-'.json_encode($JSON).$M3SessionId ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,
|
||||
'SHCO'=>'','SHWHS'=>$WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code'=>$responseStatusCode,
|
||||
'status'=>'Success',
|
||||
'message'=>json_decode($JsonSanytized)
|
||||
]);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
$getCurlErrors = str_contains($th->getMessage(), 'cURL error');
|
||||
if($getCurlErrors){
|
||||
# Write to Logs Out : Failed
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'X','SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>'Curl Error: Communication with M3 Timed Out'.' M3-JSN-out'.$JSON ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>'','SHWHS'=>$WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code'=>'405',
|
||||
'status'=>'error',
|
||||
'message'=>'Curl Error: Communication with M3 Timed Out.'
|
||||
]);
|
||||
}
|
||||
else {
|
||||
# Write to Logs Out : Error
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'X','SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>'An Error Occured - '.substr($th,0,300) ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code'=>'405',
|
||||
'status'=>'error',
|
||||
'message'=>'Catched Error: '.$th
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
# End M3InventoryReport
|
||||
|
||||
# M3InventoryReportList with URL Params
|
||||
public function M3InventoryReportListURL(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'));
|
||||
|
||||
# Set API Name
|
||||
$SHSOURCE = 'M3InventoryReportListURL';
|
||||
# Get The Calling User
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
$M3Errors = '';
|
||||
|
||||
try {
|
||||
# Get Json Contents
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
|
||||
$REQPKWS = isset($urlParams["REQPKWS"]) ? $urlParams["REQPKWS"] : '';
|
||||
$REQKPKUS = isset($urlParams["REQKPKUS"]) ? $urlParams["REQKPKUS"] : 'WebUser';
|
||||
$CO = isset($urlParams["CO"]) ? $urlParams["CO"] : '';
|
||||
$WHS = isset($urlParams["WHS"]) ? $urlParams["WHS"] : '';
|
||||
$MACPKR = isset($urlParams["MACPKR"]) ? $urlParams["MACPKR"] : '000000'; # Delivery Number
|
||||
$PKLN = isset($urlParams["PKLN"]) ? $urlParams["PKLN"] : '';
|
||||
|
||||
if($urlParams!=''){
|
||||
$IncomingParams = ['CO'=> $CO,'WHS'=> $WHS,'MACPKR'=> $MACPKR,'PKLN'=> $PKLN,'REQPKWS'=> $REQPKWS,'REQKPKUS'=> $REQKPKUS];
|
||||
$IncomingParams = json_encode($IncomingParams);
|
||||
|
||||
# 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);
|
||||
|
||||
# Get Parts And Lots from ICM688M2
|
||||
$ICM688M2SLTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m2')
|
||||
->select('A5WHS', 'A5PART','A5LOTNUM','A5SENTPKR')
|
||||
->distinct()
|
||||
->where('A5CO',$CO)
|
||||
->where('A5WHS',$WHS)
|
||||
->where('A5MACPKR',$MACPKR);
|
||||
|
||||
# Get Pack Lines
|
||||
if($PKLN!=''){
|
||||
$ICM688M2SLTMP->where('A5PKLN',$PKLN);
|
||||
}
|
||||
$ICM688M2SL = $ICM688M2SLTMP->get();
|
||||
// dd($ICM688M2SL);
|
||||
|
||||
if( count($ICM688M2SL)>0 ){
|
||||
# Update ICM688M1 : Add Timestamp
|
||||
$ICM688M1TS = now();
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
|
||||
->where('A4MACPKR',$MACPKR)
|
||||
->update(['A4INRFSHTS'=>$ICM688M1TS]);
|
||||
|
||||
$PICKERARR = [];
|
||||
foreach ($ICM688M2SL as $key => $ICM688M2) {
|
||||
$PART = trim($ICM688M2->A5PART);
|
||||
$LOT = trim($ICM688M2->A5LOTNUM);
|
||||
$PARTS[] = ["PART"=> $PART , "LOT"=>$LOT];
|
||||
$PICKERARR[$PART] = $ICM688M2->A5SENTPKR;
|
||||
}
|
||||
// Log::info($PARTS);
|
||||
// dump($PARTS);
|
||||
$JSON = json_encode( ["WHS" => $WHS,"PARTS"=> $PARTS ] );
|
||||
// Log::info($JSON);
|
||||
|
||||
# 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' => 'application/json',
|
||||
'Content-Type' => 'application/json'
|
||||
])
|
||||
->withToken($token)
|
||||
->withBody($JSON, 'application/json')
|
||||
->timeout(Config::get('arrays.curlTimeOut'))
|
||||
->post($endPointURL);
|
||||
|
||||
$M3SessionId = $response->hasHeader('x-transaction-id') ? "-sessionID:". $response->header('x-transaction-id') : '-sessionID';
|
||||
|
||||
$responseStatusCode = $response->getStatusCode();
|
||||
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 $key => $value) {
|
||||
// dump($value);
|
||||
$dataToWrite = [];
|
||||
|
||||
foreach ($value as $key2 => $content) {
|
||||
if($key2!='Locations'){
|
||||
$dataToWrite[$key2] = $content;
|
||||
}
|
||||
else{
|
||||
foreach ($content as $key3 => $content2) {
|
||||
//dump($content2);
|
||||
$dataToWrite2[] = array_merge($dataToWrite,$content2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// LOG::info($dataToWrite2);
|
||||
|
||||
# Delete Old Records from IC630M
|
||||
foreach ($dataToWrite2 as $key => $value) {
|
||||
$ICM630MDeleteSQL = DB::connection(config('m3.connection', 'pgsql'))->table('ic630m')
|
||||
->where('LLCO',$CO)
|
||||
->where('LLWHNO',$WHS)
|
||||
->where('LLPPN',trim($value['PartNumber']))
|
||||
->delete();
|
||||
}
|
||||
|
||||
foreach ($dataToWrite2 as $key => $value) {
|
||||
# Check if Location exist in DE640M ("LVCO", "WSELOC", "VLOCID")
|
||||
$DE640MSQLSEL = DB::connection(config('m3.connection', 'pgsql'))->table('de640m')
|
||||
->where('LVCO',$CO)
|
||||
->where('WSELOC',$value['Warehouse'])
|
||||
->where('VLOCID',$value['Location'])
|
||||
->first();
|
||||
// dd($DE640MSQLSEL);
|
||||
|
||||
$LocationExist = isset($DE640MSQLSEL->VLOCID) ? trim($DE640MSQLSEL->VLOCID) : '';
|
||||
$WHExist = isset($DE640MSQLSEL->WSELOC) ? trim($DE640MSQLSEL->WSELOC) : '';
|
||||
$COExist = isset($DE640MSQLSEL->LVCO) ? trim($DE640MSQLSEL->LVCO) : '';
|
||||
// dd($LocationExist .': '.$WHExist.': '.$COExist);
|
||||
|
||||
# if No records Founds insert New Record
|
||||
if ( $LocationExist=='' && $WHExist=='' && $COExist=='' ) {
|
||||
$SQLInsertPrep640M['LVCO'] = $CO; # Company
|
||||
$SQLInsertPrep640M['WSELOC'] = $value['Warehouse'];
|
||||
// $SQLInsertPrep640M['LVDELNO'] = $MACPKR; # M3 Delivery note number DELETED
|
||||
// $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['LLDELNO'] = $MACPKR; # M3 Delivery note number DELETED
|
||||
$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['LLCMDESC'] = $value['Description']; # Description
|
||||
$SQLInsertPrep630M['LLSPR10A01'] = isset($value['Allocation']) ? $value['Allocation'] : ''; # Allocation
|
||||
$SQLInsertPrep630M['LLSPR15A01'] = isset($value['AllocatedTo']) ? $value['AllocatedTo'] : ''; # AllocatedTo
|
||||
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('ic630m')->insert($SQLInsertPrep630M);
|
||||
}
|
||||
// dump($SQLInsertPrep);
|
||||
|
||||
#Send Response
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success'
|
||||
]);
|
||||
}
|
||||
else{
|
||||
# Write to Logs Out : Error
|
||||
$MACPKR = isset($MACPKR) ? $MACPKR : '000000';
|
||||
$data = ['SHMACPKR'=>$MACPKR,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'X','SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>'No Records Found in ICM688M2' ,'SHUSER'=> $REQKPKUS,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$CO,'SHWHS'=>$WHS ];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message'=> 'No Records Found in ICM688M2'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
# Write to Logs Out : Error
|
||||
$MACPKR = isset($MACPKR) ? $MACPKR : '000000';
|
||||
$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'=> $REQKPKUS,'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 : '000000';
|
||||
$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'=>$th->getMessage().' 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'=> $REQKPKUS,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$CO,'SHWHS'=>$WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
Log::error($th);
|
||||
return response()->json([
|
||||
'code'=>'405',
|
||||
'status'=>'error',
|
||||
'message'=>'Catched Error: '.$th
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
# End M3InventoryReportListURL
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use DB;
|
||||
use Config;
|
||||
use Str;
|
||||
use Log;
|
||||
use Http;
|
||||
use Cache;
|
||||
use DateTime;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use File;
|
||||
use Helper;
|
||||
|
||||
class PdfStorage extends Controller
|
||||
{
|
||||
# PdfStorageAPI : PDF file read and save to Cache
|
||||
public function PdfStorageAPI(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());
|
||||
# Get the Calling User
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
$SHSOURCE = 'PdfStorageAPI';
|
||||
# PDF File PATH
|
||||
$pdfFilePath = Config::get('arrays.PdfPath');
|
||||
try {
|
||||
# Get URL PARAMS
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
// dd($urlParams);
|
||||
|
||||
$COMPANY = isset($urlParams["COMPANY"]) ? trim($urlParams["COMPANY"]) : ''; # Company
|
||||
$WHS = isset($urlParams["WHS"]) ? trim($urlParams["WHS"]) : ''; # WareHouse
|
||||
$DOCTYPE = isset($urlParams["DOCTYPE"]) ? trim($urlParams["DOCTYPE"]) : ''; # document type (PackingList, CarrierLabel, ContentLabel)
|
||||
$FILENAME = isset($urlParams["FILENAME"]) ? trim($urlParams["FILENAME"]) : ''; # PDF File name
|
||||
$DOCNUM = isset($urlParams["DOCNUM"]) ? trim($urlParams["DOCNUM"]) : ''; # document number (ie the internal box number, the pick list number)
|
||||
$A4MACPKR = isset($urlParams["A4MACPKR"]) ? trim($urlParams["A4MACPKR"]) : ''; # Delivery note number
|
||||
|
||||
if($urlParams!=''){
|
||||
# Key Combination : COMPANY WHS A4MACPKR DOCTYPE DOCNUM
|
||||
# Document type (PackingList, CarrierLabel, ContentLabel)
|
||||
$DELIVERYNO = isset($A4MACPKR) ? $A4MACPKR : '000000';
|
||||
$DELIVERYNO = $DELIVERYNO!="" && $DELIVERYNO!=null ? $DELIVERYNO : '000000';
|
||||
# Write to Logs : Params In
|
||||
$IncomingParams = ['COMPANY'=> $COMPANY,'WHS'=> $WHS,'DOCTYPE'=> $DOCTYPE,'FILENAME'=> $FILENAME,'A4MACPKR'=> $A4MACPKR,'DOCNUM' => $DOCNUM];
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> '','SHINTBOX'=> $DOCNUM,'SHTYPE'=> 'M3-Req-out' ,
|
||||
'SHDATA'=>json_encode($IncomingParams) ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$COMPANY,'SHWHS'=>$WHS ];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Make Key and Test Validity
|
||||
if ($A4MACPKR!='' && $DOCTYPE!='' && $DOCNUM!='' && $COMPANY!='' && $WHS!=''){
|
||||
$cacheKey = $A4MACPKR.$DOCTYPE.$DOCNUM.$COMPANY.$WHS;
|
||||
}
|
||||
else{
|
||||
$cacheKey ='';
|
||||
}
|
||||
|
||||
# Read PDF File and Encode to Base64
|
||||
$pdfFileName = $pdfFilePath.$FILENAME.'.pdf';
|
||||
// dd($pdfFileName);
|
||||
// dd(File::exists($pdfFileName));
|
||||
if (File::exists($pdfFileName) && $cacheKey!='') {
|
||||
// dd(File::exists($pdfFileName));
|
||||
|
||||
// Parse PDF file and build necessary objects.
|
||||
$parser = new \Smalot\PdfParser\Parser();
|
||||
|
||||
// $pdf = $parser->parseFile('/www/sentm3test/htdocs/labels/E1232824-10826596.pdf');
|
||||
// dump($pdf);
|
||||
// $text = $pdf->getText();
|
||||
// dump("Text Only");
|
||||
// dump($text);
|
||||
|
||||
$pdfFile = File::get($pdfFileName);
|
||||
|
||||
// Transform content to base64
|
||||
$base64PDF = base64_encode($pdfFile);
|
||||
// Output base64 string
|
||||
// dump($base64PDF);
|
||||
|
||||
# Save Cache
|
||||
Cache::forever($cacheKey, $base64PDF);
|
||||
// Cache::put($cacheKey, $base64PDF, now()->addMinutes(60));
|
||||
|
||||
# Retrieve Cache
|
||||
// $cachedPdfFile = Cache::get($cacheKey);
|
||||
// dump("Retrieve Base64 Encoded PDF saved in Cache:");
|
||||
// dump($cachedPdfFile);
|
||||
// $pdfData = substr($cachedPdfFile,0,50);
|
||||
# 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);
|
||||
|
||||
# Write to Logs Out : Success
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> '','SHINTBOX'=> $DOCNUM,'SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>'PDF File converted to Base64 and Saved to Cache.Key: '.$cacheKey,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$COMPANY,'SHWHS'=>$WHS];
|
||||
// dd($data);
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success',
|
||||
'cacheKey'=> $cacheKey
|
||||
// 'PDFData' => $pdfData
|
||||
]);
|
||||
}
|
||||
else {
|
||||
$SHDATA = File::exists($pdfFileName) ? '' : 'PDF File Not Found-';
|
||||
$SHDATA = $cacheKey!='' ? $SHDATA.'' : $SHDATA.'Cache Key is missing Params';
|
||||
|
||||
# Write to Logs Out : Error
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'X','SHINTBOX'=> $DOCNUM,'SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>'An Error Occured -'.$SHDATA,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$COMPANY,'SHWHS'=>$WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message'=> $SHDATA
|
||||
]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Write to Logs Out : Error
|
||||
$DELIVERYNO = isset($DELIVERYNO) ? $DELIVERYNO : '000000';
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'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'=>$COMPANY,'SHWHS'=>$WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message'=> 'No URL Parameters Sent'
|
||||
]);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
|
||||
# Write to Logs Out : Error
|
||||
$DELIVERYNO = isset($DELIVERYNO) ? $DELIVERYNO : '000000';
|
||||
$data = ['SHMACPKR'=>$DELIVERYNO,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> 'X','SHINTBOX'=> '','SHTYPE'=> 'M3-Res-out' ,
|
||||
'SHDATA'=>'An Error Occured - '.substr($th,0,300) ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$COMPANY,'SHWHS'=>$WHS];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
return response()->json([
|
||||
'code'=>'405',
|
||||
'status'=>'error',
|
||||
'message'=>'Catched Error: '.$th
|
||||
]);
|
||||
}
|
||||
}
|
||||
# End PdfStorageAPI
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use DB;
|
||||
use Config;
|
||||
use Str;
|
||||
use Log;
|
||||
use Http;
|
||||
use Cache;
|
||||
use DateTime;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use File;
|
||||
use Helper;
|
||||
|
||||
class ReplenAPI extends Controller
|
||||
{
|
||||
# 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 : '000000';
|
||||
$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 $key => $value){
|
||||
$PARTS[] = ["PART"=> $value,"LOT"=>""];
|
||||
}
|
||||
// dump($PARTS);
|
||||
|
||||
$JSON = json_encode( ["WHS" => $WHS,"PARTS"=> $PARTS ] );
|
||||
|
||||
# Write to Logs : Params Sent To M3
|
||||
$data = ['SHMACPKR'=>$MACPKR,'SHDT'=> date('Y-m-d'),'SHTIME'=> date('H:i:s') ,'SHERROR'=> '','SHINTBOX'=> '','SHTYPE'=> 'M3-Req-out' ,
|
||||
'SHDATA'=>'Sent To M3-'.$JSON ,'SHUSER'=> $SHUSER,'SHSOURCE'=> $SHSOURCE,'SHCO'=>$CO,'SHWHS'=>$WHS ];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Get Token
|
||||
$tokenResponse = Helper::checkReceiveTokenV2();
|
||||
$tokenData = $tokenResponse->getData();
|
||||
// dd($IonToken->code);
|
||||
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' => 'application/json',
|
||||
'Content-Type' => 'application/json'
|
||||
])
|
||||
->withToken($token)
|
||||
->withBody($JSON, 'application/json')
|
||||
->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);
|
||||
// LOG::info( $responseArray);
|
||||
$responseTMP = $responseArray['result'];
|
||||
// LOG::info($responseTMP);
|
||||
}
|
||||
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 $key => $value) {
|
||||
// dump($value);
|
||||
$dataToWrite = [];
|
||||
|
||||
foreach ($value as $key2 => $content) {
|
||||
if($key2!='Locations'){
|
||||
$dataToWrite[$key2] = $content;
|
||||
}
|
||||
else{
|
||||
foreach ($content as $key3 => $content2) {
|
||||
//dump($content2);
|
||||
$dataToWrite2[] = array_merge($dataToWrite,$content2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// LOG::info($dataToWrite2);
|
||||
|
||||
# Delete Old Records from IC630M
|
||||
foreach ($dataToWrite2 as $key => $value) {
|
||||
$ICM630MDeleteSQL = DB::connection(config('m3.connection', 'pgsql'))->table('ic630m')
|
||||
->where('LLCO',$CO)
|
||||
->where('LLWHNO',$WHS)
|
||||
->where('LLPPN',trim($value['PartNumber']))
|
||||
->delete();
|
||||
}
|
||||
|
||||
foreach ($dataToWrite2 as $key => $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();
|
||||
// dd($DE640MSQLSEL);
|
||||
|
||||
$LocationExist = isset($DE640MSQLSEL->VLOCID) ? trim($DE640MSQLSEL->VLOCID) : '';
|
||||
$WHExist = isset($DE640MSQLSEL->WSELOC) ? trim($DE640MSQLSEL->WSELOC) : '';
|
||||
$COExist = isset($DE640MSQLSEL->LVCO) ? trim($DE640MSQLSEL->LVCO) : '';
|
||||
// dd($LocationExist .': '.$WHExist.': '.$COExist);
|
||||
|
||||
# if No records Founds insert New Record
|
||||
if ( $LocationExist=='' && $WHExist=='' && $COExist=='' ) {
|
||||
$SQLInsertPrep640M['LVCO'] = $CO; // Company
|
||||
$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);
|
||||
}
|
||||
// dump($SQLInsertPrep);
|
||||
|
||||
#Send Response
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success'
|
||||
]);
|
||||
}
|
||||
else {
|
||||
# Write to Logs Out : Error
|
||||
$MACPKR = isset($MACPKR) ? $MACPKR : '000000';
|
||||
$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 : '000000';
|
||||
|
||||
$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);
|
||||
|
||||
// Log::error($th);
|
||||
return response()->json([
|
||||
'code'=>'405',
|
||||
'status'=>'error',
|
||||
'message'=>'Catched Error: '.$th
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
# End M3InventoryReportReplen
|
||||
}
|
||||
@@ -0,0 +1,712 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use DB;
|
||||
use Config;
|
||||
use Str;
|
||||
use Log;
|
||||
use Http;
|
||||
use Cache;
|
||||
use DateTime;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use File;
|
||||
use Helper;
|
||||
|
||||
class TransferAPI extends Controller
|
||||
{
|
||||
# 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'));
|
||||
// dd($request->all());
|
||||
|
||||
# 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"] : '000000';
|
||||
$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 : '000000';
|
||||
|
||||
$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();
|
||||
// dump($ICM699MS->SHDATA);
|
||||
|
||||
# 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));
|
||||
} else if ($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);
|
||||
// dd($SHDATAJSON);
|
||||
|
||||
$JSONTR = $SHDATAJSON != '' ? json_decode($SHDATAJSON) : '';
|
||||
// dd($JSONTR);
|
||||
|
||||
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 : '000000';
|
||||
$PICKLISTSUFFIX = isset($JSONTR->PICKLISTSUFFIX) ? $JSONTR->PICKLISTSUFFIX : '';
|
||||
$ENDFLAG = isset($JSONTR->ENDFLAG) ? $JSONTR->ENDFLAG : '';
|
||||
$TYPE = isset($JSONTR->TYPE) ? $JSONTR->TYPE : '';
|
||||
$COLINESUFFIX = isset($JSONTR->COLINESUFFIX) ? $JSONTR->COLINESUFFIX : '';
|
||||
}
|
||||
// dd($JSONTR);
|
||||
|
||||
# Set SHERROR to Z in ICM699M
|
||||
$ICM699MU = 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();
|
||||
// dd($ICM688M2SL->A5BRADLN);
|
||||
|
||||
$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);
|
||||
// dd($JSON);
|
||||
|
||||
# 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' => 'application/json',
|
||||
'Content-Type' => 'application/json'
|
||||
])
|
||||
->withToken($token)
|
||||
->withBody($JSON, 'application/json')
|
||||
->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; //$M3ResponseTimeTmp / 1000;
|
||||
$dateTime = new DateTime();
|
||||
$dateTime->setTimestamp($M3ResponseTimeTmp2);
|
||||
// dump( $dateTime->format('d/m/Y H:i:s.v') );
|
||||
$M3ResponseTime = $M3ResponseTimeTmp != '' ? '-M3ResponseTime:' . $dateTime->format('d/m/Y H:i:s.v') : '-M3ResponseTime';
|
||||
// dump($M3ResponseTime);
|
||||
$transferStats = $response->transferStats;
|
||||
$M3transferTime = $transferStats->getTransferTime() != null ? "-M3transferTime:" . $transferStats->getTransferTime() : "-M3transferTime";
|
||||
// dd($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 . ' Order Category: ' . $ORDERCATEGORY . '-' . $M3JSONResponse . $M3SessionId . $M3ResponseTime . $M3transferTime,
|
||||
'SHUSER' => $SHUSER,
|
||||
'SHSOURCE' => $SHSOURCE,
|
||||
'SHCO' => $DIVI,
|
||||
'SHWHS' => $WHS
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Log to ICM799M
|
||||
$ICM799MINS = 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 . ' Order Category: ' . $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 . ' Order Category: ' . $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 : '000000';
|
||||
$data = ['SHMACPKR' => $DELIVERYNO,
|
||||
'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' => $DIVI,
|
||||
'SHWHS' => $WHS
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message' => 'No URL Parameters Sent'
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
$getCurlErrors = str_contains($th->getMessage(), 'cURL error');
|
||||
if ($getCurlErrors) {
|
||||
# Write to Logs Out : Failed
|
||||
$data = ['SHMACPKR' => $DELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => 'Curl Error: Communication with M3 Timed Out' . ' M3-JSN-out' . $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 : '000000';
|
||||
$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'));
|
||||
// dd($request->all());
|
||||
|
||||
# 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"] : '';
|
||||
// dump($urlParams);
|
||||
|
||||
try {
|
||||
if ($urlParams != '') {
|
||||
$A4SPR15A01 = isset($urlParams["A4SPR15A01"]) ? $urlParams["A4SPR15A01"] : '';
|
||||
$DELIVERYNO = isset($urlParams["DELIVERYNO"]) ? $urlParams["DELIVERYNO"] : '';
|
||||
$TYPE = 'UpdateShipmentNumber';
|
||||
$allMacpkrs = [];
|
||||
// dd($A4SPR15A01);
|
||||
|
||||
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 $key => $ICM688M1) {
|
||||
$allMacpkrs[] = $ICM688M1->A4MACPKR;
|
||||
}
|
||||
}
|
||||
|
||||
# A4SPR15A01 Exists : proceed
|
||||
if ($A4SPR15A01 != '' && count($allMacpkrs)>0) {
|
||||
$JSON = json_encode([
|
||||
"DIVI" => $DIVI,
|
||||
"WHS" => $WHS,
|
||||
"ShipmentNumber" => [
|
||||
"Number" => $A4SPR15A01,
|
||||
"DeliveryNumbers" => $allMacpkrs
|
||||
],
|
||||
"TYPE" => $TYPE,
|
||||
"ENDFLAG" => "",
|
||||
|
||||
], JSON_UNESCAPED_SLASHES);
|
||||
// dd($JSON);
|
||||
|
||||
# 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' => 'application/json',
|
||||
'Content-Type' => 'application/json'
|
||||
])
|
||||
->withToken($token)
|
||||
->withBody($JSON, 'application/json')
|
||||
->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; //$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 : '000000';
|
||||
$data = ['SHMACPKR' => $DELIVERYNO,
|
||||
'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' => $DIVI,
|
||||
'SHWHS' => $WHS
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Return Error
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'Error',
|
||||
'message' => 'No URL Parameters Sent'
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
$getCurlErrors = str_contains($th->getMessage(), 'cURL error');
|
||||
if ($getCurlErrors) {
|
||||
# Write to Logs Out : Failed
|
||||
$data = ['SHMACPKR' => $DELIVERYNO,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'M3-Res-out',
|
||||
'SHDATA' => 'Curl Error: Communication with M3 Timed Out' . ' M3-JSN-out' . $JSON,
|
||||
'SHUSER' => $SHUSER,
|
||||
'SHSOURCE' => $SHSOURCE,
|
||||
'SHCO' => $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 : '000000';
|
||||
$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
|
||||
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers\API;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use DB;
|
||||
use Config;
|
||||
use Str;
|
||||
use Log;
|
||||
use Http;
|
||||
use Cache;
|
||||
use DateTime;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use File;
|
||||
use Helper;
|
||||
|
||||
class TwoShipAPIs extends Controller
|
||||
{
|
||||
# TwoShipUpdateHold with URL Params
|
||||
public function TwoShipUpdateHold(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';
|
||||
|
||||
$SHSOURCE = 'TwoShipUpdateHold';
|
||||
$TwoShipErrors = '';
|
||||
|
||||
$urlParams = count($request->all()) > 0 ? $request->all() : '';
|
||||
$WHS = isset($urlParams["WHS"]) ? $urlParams["WHS"] : '';
|
||||
$CO = isset($urlParams["COMPANY"]) ? $urlParams["COMPANY"] : '';
|
||||
$MACPKR = isset($urlParams["MACPKR"]) ? $urlParams["MACPKR"] : '';
|
||||
|
||||
try {
|
||||
if ($urlParams != '') {
|
||||
$IncomingParams = ['CO' => $CO, 'WHS' => $WHS, 'MACPKR' => $MACPKR];
|
||||
$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' => 'AggStopReq',
|
||||
'SHDATA' => $IncomingParams,
|
||||
'SHUSER' => $SHUSER,
|
||||
'SHSOURCE' => $SHSOURCE,
|
||||
'SHCO' => $CO,
|
||||
'SHWHS' => $WHS
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# First Step : Get MACPKRs list if available
|
||||
# select a4macpkr from icm688m1 where a4shpaggcd in (select a4shpaggcd from icm688m1 where a4macpkr=233709) and a4shpaggcd<>0 and a4concmplt<>'y' and a4co=410 and a4whs=111
|
||||
$A4MACPKRSel = DB::connection(config('m3.connection', 'pgsql'))->select(
|
||||
"select a4macpkr from icm688m1 where a4shpaggcd in (select a4shpaggcd from icm688m1 where a4macpkr={$MACPKR})
|
||||
and a4shpaggcd<>0 and a4concmplt<>'y' and a4co='{$CO}' and a4whs='{$WHS}' "
|
||||
);
|
||||
// dd($A4MACPKRSel);
|
||||
|
||||
if (count($A4MACPKRSel)>0){
|
||||
foreach ($A4MACPKRSel as $key => $A4MACPKRR) {
|
||||
$A4MACPKRArr[] = $A4MACPKRR->A4MACPKR;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$A4MACPKRArr[] = $MACPKR;
|
||||
}
|
||||
|
||||
// dump($A4MACPKRArr);
|
||||
|
||||
# Call 2ship API with Params
|
||||
$WS_key = Config::get('arrays.2Ship.TwoShip_Key');
|
||||
$end_point = Config::get('arrays.2Ship.end_point');
|
||||
$API = Config::get('arrays.2Ship.hold_update');
|
||||
|
||||
$ShipOnHoldOrder_url = $end_point . $API;
|
||||
|
||||
# Build Json Data
|
||||
$data = [
|
||||
'WS_Key' => $WS_key,
|
||||
'OrderNumbers' => [implode(',', $A4MACPKRArr)],
|
||||
// 'ShipmentId' => 3,
|
||||
'FindBy' => 'ByMultipleOrderNumbers',
|
||||
'DataToBeUpdated' => [
|
||||
'UpdateAggregationSettings' => true,
|
||||
'OrderAggregationSettingsInfo' => [
|
||||
'NotConsideredAggregation' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$json_string = json_encode($data);
|
||||
|
||||
// dump($json_string);
|
||||
|
||||
#######
|
||||
# Initialise the cURL var
|
||||
$ch = curl_init();
|
||||
|
||||
# Get the response from cURL
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $ShipOnHoldOrder_url);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
#When CURLOPT_SSL_VERIFYPEER is enabled (value=1), and the verification fails to prove that the certificate is authentic, the connection fails.
|
||||
#When the option is zero, the peer certificate verification succeeds regardless.
|
||||
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
#When CURLOPT_SSL_VERIFYHOST is 2, that certificate must indicate that the server is the server to which you meant to connect,
|
||||
#or the connection fails. Simply put, it means it has to have the same name in the certificate as is in the URL you operate against.
|
||||
|
||||
# Set data content type
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($json_string)
|
||||
)
|
||||
);
|
||||
|
||||
# Post data
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_string);
|
||||
|
||||
# Set timeout
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, Config::get('arrays.PHPTimeOut'));
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, Config::get('arrays.PHPTimeOut'));
|
||||
|
||||
# if set true, cURL will follow redirects
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
# Execute the request
|
||||
$response = curl_exec($ch);
|
||||
|
||||
# Verifying error
|
||||
$info = curl_getinfo($ch);
|
||||
|
||||
# Get status
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
# Output the error code
|
||||
# $CurlError= curl_error($ch);
|
||||
$CurlError = str_replace("'", " ", curl_error($ch));
|
||||
|
||||
# Close the session
|
||||
unset($ch);
|
||||
|
||||
// dump($response);
|
||||
// dump($status);
|
||||
// dump($CurlError);
|
||||
|
||||
if ($status == '200' && $CurlError=='') {
|
||||
$responseJSON = json_decode($response);
|
||||
// dump($responseJSON);
|
||||
if($responseJSON->Success==false){
|
||||
$TwoShipErrors = '2Ship Error: '.$responseJSON->GlobalError;
|
||||
}
|
||||
} else {
|
||||
$TwoShipErrors = 'Error: No Response from 2Ship';
|
||||
$TwoShipErrors .= ' -Curl Error: '.$CurlError;
|
||||
}
|
||||
|
||||
# Validate response From 2Ship
|
||||
# Error
|
||||
if ($TwoShipErrors != '') {
|
||||
// dump($TwoShipErrors);
|
||||
|
||||
# Write to Logs : Error
|
||||
$data = ['SHMACPKR' => $MACPKR,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'AggStopRsp',
|
||||
'SHDATA' => $status . '-' . $TwoShipErrors,
|
||||
'SHUSER' => $SHUSER,
|
||||
'SHSOURCE' => $SHSOURCE,
|
||||
'SHCO' => $CO,
|
||||
'SHWHS' => $WHS
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Send Response
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Status: '.$status . '-' . $TwoShipErrors
|
||||
]);
|
||||
}
|
||||
# Success
|
||||
else{
|
||||
# Write to Logs : JSON
|
||||
$data = ['SHMACPKR' => $MACPKR,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => '',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'AggStopRsp',
|
||||
'SHDATA' => $response,
|
||||
'SHUSER' => $SHUSER,
|
||||
'SHSOURCE' => $SHSOURCE,
|
||||
'SHCO' => $CO,
|
||||
'SHWHS' => $WHS
|
||||
];
|
||||
Helper::logToICM699M($data);
|
||||
|
||||
# Update ICM688M1 set a4concmplt to 'y'
|
||||
DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
|
||||
->whereIn('A4MACPKR',$A4MACPKRArr)
|
||||
->where('A4CO',$CO)
|
||||
->where('A4WHS',$WHS)
|
||||
->update(['A4CONCMPLT'=>'Y']);
|
||||
|
||||
}
|
||||
# Send Response
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success'
|
||||
]);
|
||||
}
|
||||
# Error : No URL params
|
||||
else {
|
||||
# Write to Logs Out : Error
|
||||
$MACPKR = isset($MACPKR) ? $MACPKR : '000000';
|
||||
$data = ['SHMACPKR' => $MACPKR,
|
||||
'SHDT' => date('Y-m-d'),
|
||||
'SHTIME' => date('H:i:s'),
|
||||
'SHERROR' => 'X',
|
||||
'SHINTBOX' => '',
|
||||
'SHTYPE' => 'AggStopRsp',
|
||||
'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
|
||||
$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' => 'AggStopRsp',
|
||||
'SHDATA' => 'Curl Error: Communication with 2Ship Timed Out' . ' 2Ship-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 2Ship Timed Out.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
# End TwoShipUpdateHold
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Str;
|
||||
|
||||
class BoxPackToPalletController extends Controller
|
||||
{
|
||||
|
||||
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();
|
||||
// dump($userWhsCoPlant);
|
||||
|
||||
$boxes = DB::connection(config('m3.connection', 'pgsql'))->table('ICM659M as p')
|
||||
->select(
|
||||
'p.R659PALT',
|
||||
'p.R659BOX',
|
||||
'p.R659LOADED',
|
||||
'p.R659USER',
|
||||
'p.R659DATE',
|
||||
'p.R659TIME',
|
||||
'c.AYMACPKR',
|
||||
'c.AYSPR15A01',
|
||||
'cv.A4APR8N001',
|
||||
'cv.A4SHSHCT',
|
||||
'cnv.R652SORTK as CONVEYOR_NAME'
|
||||
)
|
||||
->leftJoin('ICM695M1 as c', 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin('ICM688M1 as cv', 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin('ICM652M as cnv', '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();
|
||||
// dump($boxes);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $boxes,
|
||||
]);
|
||||
}
|
||||
|
||||
$palletHeader = $boxes->first();
|
||||
// dump($boxes);
|
||||
|
||||
return view('m3::liberty-theme.pages.BoxPackToPalletScan', compact('boxes', 'palletHeader', 'R659PALT'));
|
||||
}
|
||||
|
||||
# Scan Boxes
|
||||
public static function scanBoxes(Request $request)
|
||||
{
|
||||
$R659PALT = $request->R659PALT ?? abort(400, 'Pallet Not Found');
|
||||
$R659BOX = trim($request->R659BOX) ?? abort(400, 'Box Not Found');
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(m3_user()) : 'WebUser';
|
||||
$userWhsCoPlant = self::getUserWhsCoPlant();
|
||||
|
||||
$boxMessage = '';
|
||||
|
||||
# Step 1: Check for duplicate — same pallet + box combo
|
||||
$exists = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->table('icm659m')
|
||||
->select('R659PALT')
|
||||
->where('R659PALT', $R659PALT)
|
||||
->where('R659BOX', $R659BOX)
|
||||
->where('R659CO', trim($userWhsCoPlant["USERCO"]))
|
||||
->where('R659WHS', trim($userWhsCoPlant["USERWHS"]))
|
||||
->where('R659PLANT', trim($userWhsCoPlant["USERPL"]))
|
||||
->first();
|
||||
|
||||
if ($exists) {
|
||||
$boxMessage = "• Box {$R659BOX} is already assigned to Pallet {$exists->R659PALT}.";
|
||||
}
|
||||
|
||||
# Step 2: Check if Box exists in ICM695M1 (with carrier + conveyor joined)
|
||||
$ICM695M1Sel = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->table('ICM695M1 as c')
|
||||
->select(
|
||||
'c.AYINTBOX',
|
||||
'c.AYSPR15A01',
|
||||
'c.AYTYPE',
|
||||
'c.AYMACPKR',
|
||||
'cv.A4APR8N001',
|
||||
'cnv.R652SORTK as CONVEYOR_NAME'
|
||||
)
|
||||
->leftJoin('ICM688M1 as cv', 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin('ICM652M as cnv', 'cv.A4APR8N001', '=', 'cnv.R652SEQ')
|
||||
->where('c.AYINTBOX', $R659BOX)
|
||||
->where('c.AYCO', trim($userWhsCoPlant["USERCO"]))
|
||||
->where('c.AYWHS', trim($userWhsCoPlant["USERWHS"]))
|
||||
->where('c.AYPLANT', trim($userWhsCoPlant["USERPL"]))
|
||||
->first();
|
||||
|
||||
$boxExistInICM695M = isset($ICM695M1Sel->AYINTBOX);
|
||||
$boxisPalletICM695M = isset($ICM695M1Sel->AYTYPE) && $ICM695M1Sel->AYTYPE != 'BX';
|
||||
|
||||
if (!$boxExistInICM695M) {
|
||||
$br = $boxMessage == '' ? '' : '<br>';
|
||||
$boxMessage .= $br . "• Box {$R659BOX} does not exist in ICM695M1 or it belongs to another Company.";
|
||||
}
|
||||
|
||||
if ($boxExistInICM695M && $boxisPalletICM695M) {
|
||||
$br = $boxMessage == '' ? '' : '<br>';
|
||||
$boxMessage .= $br . "• Scanned barcode {$R659BOX} is not a Box.";
|
||||
}
|
||||
|
||||
# Step 3: Check that all boxes on the pallet share the same Carrier and Conveyor
|
||||
if ($boxExistInICM695M && !$boxisPalletICM695M && !$exists) {
|
||||
$firstPalletBox = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->table('ICM659M as p')
|
||||
->select(
|
||||
'c.AYSPR15A01',
|
||||
'cnv.R652SORTK as CONVEYOR_NAME'
|
||||
)
|
||||
->leftJoin('ICM695M1 as c', 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin('ICM688M1 as cv', 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin('ICM652M as cnv', '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"]))
|
||||
->first();
|
||||
|
||||
if ($firstPalletBox) {
|
||||
$incomingCarrier = trim($ICM695M1Sel->AYSPR15A01 ?? '');
|
||||
$incomingConveyor = trim($ICM695M1Sel->CONVEYOR_NAME ?? '');
|
||||
$palletCarrier = trim($firstPalletBox->AYSPR15A01 ?? '');
|
||||
$palletConveyor = trim($firstPalletBox->CONVEYOR_NAME ?? '');
|
||||
|
||||
if ($incomingCarrier !== $palletCarrier) {
|
||||
$br = $boxMessage == '' ? '' : '<br>';
|
||||
$boxMessage .= $br . "• Box {$R659BOX} has a different Carrier ({$incomingCarrier}) than the boxes already on Pallet {$R659PALT} ({$palletCarrier}).";
|
||||
}
|
||||
|
||||
if ($incomingConveyor !== $palletConveyor) {
|
||||
$br = $boxMessage == '' ? '' : '<br>';
|
||||
$boxMessage .= $br . "• Box {$R659BOX} has a different Conveyor ({$incomingConveyor}) than the boxes already on Pallet {$R659PALT} ({$palletConveyor}).";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($exists || !$boxExistInICM695M || $boxisPalletICM695M || $boxMessage !== '') {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $boxMessage,
|
||||
], 409);
|
||||
}
|
||||
|
||||
# Step 4: Insert new box record
|
||||
DB::connection(config('m3.connection', 'pgsql'))
|
||||
->table('icm659m')
|
||||
->insert([
|
||||
'R659PALT' => $R659PALT,
|
||||
'R659BOX' => $R659BOX,
|
||||
'R659LOADED' => '',
|
||||
'R659USER' => $SHUSER,
|
||||
'R659DATE' => date('Y-m-d'),
|
||||
'R659TIME' => date('H:i:s'),
|
||||
'R659CO' => trim($userWhsCoPlant["USERCO"]),
|
||||
'R659WHS' => trim($userWhsCoPlant["USERWHS"]),
|
||||
'R659PLANT' => trim($userWhsCoPlant["USERPL"]),
|
||||
]);
|
||||
|
||||
# Step 5: Return the full refreshed box list
|
||||
$boxes = DB::connection(config('m3.connection', 'pgsql'))->table('ICM659M as p')
|
||||
->select(
|
||||
'p.R659PALT',
|
||||
'p.R659BOX',
|
||||
'p.R659LOADED',
|
||||
'p.R659USER',
|
||||
'p.R659DATE',
|
||||
'p.R659TIME',
|
||||
'c.AYMACPKR',
|
||||
'c.AYSPR15A01',
|
||||
'cv.A4APR8N001',
|
||||
'cv.A4SHSHCT',
|
||||
'cnv.R652SORTK as CONVEYOR_NAME'
|
||||
)
|
||||
->leftJoin('ICM695M1 as c', 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin('ICM688M1 as cv', 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin('ICM652M as cnv', '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} added to Pallet {$R659PALT}.",
|
||||
'data' => $boxes,
|
||||
]);
|
||||
}
|
||||
|
||||
# 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('ICM659M as p')
|
||||
->select(
|
||||
'p.R659PALT',
|
||||
'p.R659BOX',
|
||||
'p.R659LOADED',
|
||||
'p.R659USER',
|
||||
'p.R659DATE',
|
||||
'p.R659TIME',
|
||||
'c.AYMACPKR',
|
||||
'c.AYSPR15A01',
|
||||
'cv.A4APR8N001',
|
||||
'cv.A4SHSHCT',
|
||||
'cnv.R652SORTK as CONVEYOR_NAME'
|
||||
)
|
||||
->leftJoin('ICM695M1 as c', 'p.R659BOX', '=', 'c.AYINTBOX')
|
||||
->leftJoin('ICM688M1 as cv', 'c.AYMACPKR', '=', 'cv.A4MACPKR')
|
||||
->leftJoin('ICM652M as cnv', '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 : '';
|
||||
|
||||
$userWhsCoPlant = [
|
||||
"R428US" => $R428US,
|
||||
"USERCO" => $USERCO,
|
||||
"USERWHS" => $USERWH,
|
||||
"USERPL" => $R428PL,
|
||||
];
|
||||
return $userWhsCoPlant;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
// use Modules\M3\Models\ICM709M;
|
||||
//
|
||||
|
||||
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) {
|
||||
// dump($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];
|
||||
$aggCode = trim($row->A4SHPAGGCD);
|
||||
|
||||
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) {
|
||||
// dump($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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
use Artisan;
|
||||
|
||||
use Modules\M3\Http\Controllers\API\CloseShipment;
|
||||
|
||||
class M3CallCloseAPIController extends Controller
|
||||
{
|
||||
public static function index(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'));
|
||||
|
||||
try {
|
||||
|
||||
# Get the Calling User
|
||||
# Get URL PARAMS
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
// dd($urlParams);
|
||||
$SHUSER = isset($urlParams["SHUSER"]) ? $urlParams["SHUSER"] : '';
|
||||
$MANIFEST = isset($urlParams["MANIFEST"]) ? $urlParams["MANIFEST"] : '';
|
||||
$APCO = isset($urlParams["APCO"]) ? $urlParams["APCO"] : '';
|
||||
$APWHS = isset($urlParams["APWHS"]) ? $urlParams["APWHS"] : '';
|
||||
|
||||
if ($MANIFEST!='' && $APCO!='' && $APWHS!='') { // $SHUSER!='' &&
|
||||
// Log::channel('dailyCron')->info("Cron...Start CallCloseAPI...For user:".$SHUSER." Manifest#: ".$MANIFEST);
|
||||
|
||||
# Get Logged User CO & WH
|
||||
# Get users from ICM428M
|
||||
// $ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
// ->select('R428US','R428CO', 'R428WH')
|
||||
// ->where('R428US','=',$SHUSER)
|
||||
// ->first();
|
||||
|
||||
// $R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : '';
|
||||
// $USERCO = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '';
|
||||
// $USERWH = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '';
|
||||
// dump($R428US.':'.$USERCO.':'.$USERWH);
|
||||
|
||||
# Get Macpickers from ICM705M1
|
||||
# SELECT APMANIFEST FROM ICM705M1 WHERE APSPARE2='' AND APCO='110' AND APWHS='321'
|
||||
$ICM705M1 = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
|
||||
->select('APMANIFEST','APCO','APWHS')
|
||||
->where('APSPARE2','')
|
||||
->where('APCO',$APCO)
|
||||
->where('APWHS',$APWHS)
|
||||
->where('APMANIFEST','=',$MANIFEST)
|
||||
->whereRaw('EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - APLDCLOZ)) / 60 > 15')
|
||||
->orderBy('APMANIFEST')
|
||||
->get();
|
||||
// dump($ICM705M1);
|
||||
|
||||
if (count($ICM705M1)>0) {
|
||||
# Loop the Results from $ICM705M1
|
||||
foreach ($ICM705M1 as $key => $ICM705M1R) {
|
||||
# Send CO and WHS to CallCloseAPI
|
||||
$USERCO = isset($ICM705M1R->APCO) ? $ICM705M1R->APCO : '';
|
||||
$USERWH = isset($ICM705M1R->APWHS) ? $ICM705M1R->APWHS : '';
|
||||
|
||||
$callCloseShipment = Artisan::call('command:CallCloseAPI', ['user'=> $SHUSER ,'manifest' => $ICM705M1R->APMANIFEST ,
|
||||
'co' => $USERCO ,'whs' => $USERWH]);
|
||||
// dump($callCloseShipment);
|
||||
|
||||
if ($callCloseShipment==1) {
|
||||
return response()->json([
|
||||
'code' => '200',
|
||||
'status' => 'Success',
|
||||
'message'=> 'Manifest Closing submitted'
|
||||
]);
|
||||
}
|
||||
else{
|
||||
return response()->json([
|
||||
'code' => '206',
|
||||
'status' => 'Failure',
|
||||
'message'=> 'Manifest Closing Failed'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
Log::channel('dailyCron')->info("Manifest CloseAPI: No records found in ICM705M1...");
|
||||
return response()->json([
|
||||
'code' => '206',
|
||||
'status' => 'Error',
|
||||
'message'=> "Manifest CloseAPI: No records found in ICM705M1..."
|
||||
]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
Log::channel('dailyCron')->error('Manifest CloseAPI: A User and Manifest must be defined...');
|
||||
|
||||
return response()->json([
|
||||
'code' => '206',
|
||||
'status' => 'Error',
|
||||
'message'=> 'Manifest CloseAPI: A User and Manifest must be defined...'
|
||||
]);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\M3\Models\ICM664M;
|
||||
|
||||
|
||||
class M3DeliveryController extends Controller
|
||||
{
|
||||
|
||||
public static function index(Request $request) {
|
||||
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428PWRUSR','R428US','R428CO','R428PL','R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $power_user->R428CO;
|
||||
$plant = $power_user->R428PL;
|
||||
$whs = $power_user->R428WH;
|
||||
$ICM664M = DB::connection(config('m3.connection', 'pgsql'))->select("select * from ICM664M
|
||||
where AVCO='$co' and AVPLANT='$plant' and AVWHS='$whs'");
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->select("select * from IC670M where WDCO='$co' and WDPL='$plant' and WDWHS='$whs'");
|
||||
$shipvia = DB::connection(config('m3.connection', 'pgsql'))->select("select AXCODE, AXDESC from ICM319M order by 1");
|
||||
#646 where AXCO='$co' and AXWHS='$whs' and AXPLANT='$plant'
|
||||
return view('m3::liberty-theme.pages.M3Delivery', compact('ICM664M','IC670M','power_user','shipvia'));
|
||||
|
||||
// AVCO AVCO CHARACTER 3 No ' ' Division
|
||||
// AVWHS AVWHS CHARACTER 3 No ' ' Warehouse
|
||||
// AVPLANT AVPLANT CHARACTER 3 No ' ' Plant
|
||||
// AVDELMETH AVDELMETH CHARACTER 4 No ' ' Delivery method
|
||||
// AVSHPVIA AVSHPVIA CHARACTER 4 No ' ' Sentinel ship via
|
||||
// AVSHSRT AVSHSRT CHARACTER 6 No ' ' Sentinel route
|
||||
// AVSHORCL AVSHORCL CHARACTER 3 No ' ' Sentinel intl code
|
||||
// AVSPR1A01 AVSPR1A01 CHARACTER 1 No ' ' Spare field 1A 01
|
||||
// AVSPR1A02 AVSPR1A02 CHARACTER 1 No ' ' Spare field 1A 02
|
||||
// AVSPR10A01 AVSPR10A01 CHARACTER 10 No ' ' Spare field 10A 1
|
||||
// AVSPR15A01 AVSPR15A01 CHARACTER 15 No ' ' Spare field 15A 1
|
||||
// AVSPR30A01 AVSPR30A01 CHARACTER 30 No ' ' Spare field 30A 1
|
||||
}
|
||||
|
||||
//
|
||||
// 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";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Datatables;
|
||||
use Str;
|
||||
use Excel;
|
||||
|
||||
class M3ErrorsDispController extends Controller
|
||||
{
|
||||
|
||||
public static function index(Request $request)
|
||||
{
|
||||
// dump($request->all());
|
||||
$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
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428FIRST', 'R428FAMILY')
|
||||
->get();
|
||||
$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', compact('macpkr', 'shsource', 'showerrors', 'skipdates', 'ICM428MCOL'));
|
||||
}
|
||||
|
||||
public function datatables(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');
|
||||
|
||||
// dump($request->all());
|
||||
$SHMACPKR = null != $request->SHMACPKR ? trim($request->SHMACPKR) : '';
|
||||
$SHSOURCE = null != $request->SHSOURCE ? trim($request->SHSOURCE) : '';
|
||||
$STARTDATE = null != $request->STARTDATE ? trim($request->STARTDATE) : today()->subDays(1)->format('Y-m-d');
|
||||
$ENDDATE = null != $request->ENDDATE ? trim($request->ENDDATE) : today()->format('Y-m-d');
|
||||
$SHOWERRORS = null != $request->SHOWERRORS ? trim($request->SHOWERRORS) : 'N';
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
$SKIPDATES = null != $request->SKIPDATES ? trim($request->SKIPDATES) : 'N';
|
||||
|
||||
# Get Logged User CO & WH
|
||||
# Get users from ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH')
|
||||
->where('R428US', '=', $SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : '';
|
||||
$USERCO = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '';
|
||||
$USERWH = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '';
|
||||
|
||||
# Merge date and time fields
|
||||
$mergedDateTime = DB::raw(" ICM699M.SHDT || ' ' || ICM699M.SHTIME AS SHDATETIME");
|
||||
|
||||
$ICM699M = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m')
|
||||
->select(
|
||||
'ICM699M.*',
|
||||
'ICM699M.SHACKDATE',
|
||||
'ICM699M.SHACKTIME',
|
||||
'ICM699M.SHACKUSER',
|
||||
$mergedDateTime,
|
||||
'ICM428M.R428FIRST',
|
||||
'ICM428M.R428FAMILY',
|
||||
'ICM688M1.A4ONO',
|
||||
'ICM688M1.A4SHSHNM',
|
||||
'ICM666M.A1ONO',
|
||||
'ICM666M.A1SHSHNM'
|
||||
)
|
||||
->distinct()
|
||||
->leftJoin('ICM428M', 'ICM699M.SHUSER', '=', 'ICM428M.R428US')
|
||||
->leftJoin('ICM688M1', 'ICM699M.SHMACPKR', '=', 'ICM688M1.A4MACPKR')
|
||||
->leftJoin('ICM666M', 'ICM699M.SHMACPKR', '=', 'ICM666M.A1DELNO');
|
||||
|
||||
if ($R428US != '') {
|
||||
$ICM699M->whereIn('SHCO', [$USERCO, '']);
|
||||
$ICM699M->whereIn('SHWHS', [$USERWH, '']);
|
||||
} else {
|
||||
$ICM699M->where('SHCO', null);
|
||||
$ICM699M->where('SHWHS', null);
|
||||
}
|
||||
|
||||
if ($SHMACPKR != '') {
|
||||
$ICM699M->where('SHMACPKR', $SHMACPKR);
|
||||
}
|
||||
|
||||
if ($SHSOURCE != '') {
|
||||
$ICM699M->where('SHSOURCE', $SHSOURCE);
|
||||
}
|
||||
# Disable PDFStorage Search
|
||||
$ICM699M->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
|
||||
if ($SHMACPKR == '' && $SKIPDATES == 'N') {
|
||||
$ICM699M->whereBetween('SHDT', [$STARTDATE, $ENDDATE]);
|
||||
}
|
||||
|
||||
if ($SHOWERRORS == 'Y') {
|
||||
$ICM699M->where('SHERROR', 'X');
|
||||
}
|
||||
|
||||
# Get only M3 Logs
|
||||
$ICM699M->where('SHTYPE', 'like', '%M3%');
|
||||
|
||||
return Datatables::of($ICM699M)->addIndexColumn()->make(true);
|
||||
}
|
||||
|
||||
public static function update699M(Request $request)
|
||||
{
|
||||
// dump($request->all());
|
||||
$SHMACPKR = null != $request->SHMACPKR ? trim($request->SHMACPKR) : '';
|
||||
$SHSOURCE = null != $request->SHSOURCE ? trim($request->SHSOURCE) : '';
|
||||
$SHCO = null != $request->SHCO ? trim($request->SHCO) : '';
|
||||
$SHWHS = null != $request->SHWHS ? trim($request->SHWHS) : '';
|
||||
$SHDT = null != $request->SHDT ? trim($request->SHDT) : '';
|
||||
$SHTIME = null != $request->SHTIME ? trim($request->SHTIME) : '';
|
||||
$SHTYPE = null != $request->SHTYPE ? trim($request->SHTYPE) : '';
|
||||
$SHACKNOTE = null != $request->SHACKNOTE ? trim(substr($request->SHACKNOTE, 0, 99)) : '';
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(m3_user()) : '';
|
||||
$CLOSESIM = null != $request->CLOSESIM ? trim($request->CLOSESIM) : 'N';
|
||||
|
||||
if ($CLOSESIM == 'N') {
|
||||
$ICM699MU = 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 {
|
||||
$ICM699MU = 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)
|
||||
{
|
||||
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 {
|
||||
// dd($request->all());
|
||||
$SHMACPKR = null != $request->SHMACPKR ? trim($request->SHMACPKR) : '';
|
||||
$SHSOURCE = null != $request->SHSOURCE ? trim($request->SHSOURCE) : '';
|
||||
$STARTDATE = null != $request->STARTDATE ? trim($request->STARTDATE) : today()->subDays(1)->format('Y-m-d');
|
||||
$ENDDATE = null != $request->ENDDATE ? trim($request->ENDDATE) : today()->format('Y-m-d');
|
||||
$SHOWERRORS = null != $request->SHOWERRORS ? trim($request->SHOWERRORS) : 'N';
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
$SKIPDATES = null != $request->SKIPDATES ? trim($request->SKIPDATES) : 'N';
|
||||
# Get Logged User CO & WH
|
||||
# Get users from ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH')
|
||||
->where('R428US', '=', $SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : '';
|
||||
$USERCO = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '';
|
||||
$USERWH = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '';
|
||||
|
||||
# Get users from ICM428M
|
||||
$ICM428MAll = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428FIRST', 'R428FAMILY')
|
||||
->get();
|
||||
$ICM428MCOL = collect($ICM428MAll);
|
||||
$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);
|
||||
});
|
||||
|
||||
# Merge date and time fields
|
||||
$mergedDateTime = DB::raw(" ICM699M.SHDT || ' ' || ICM699M.SHTIME AS SHDATETIME");
|
||||
|
||||
$ICM699M = 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 '),
|
||||
$mergedDateTime,
|
||||
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');
|
||||
|
||||
# Get Records Count only
|
||||
$ICM699MC = DB::connection(config('m3.connection', 'pgsql'))->table('icm699m');
|
||||
|
||||
if ($R428US != '') {
|
||||
$ICM699M->whereIn('SHCO', [$USERCO, '']);
|
||||
$ICM699M->whereIn('SHWHS', [$USERWH, '']);
|
||||
|
||||
$ICM699MC->whereIn('SHCO', [$USERCO, '']);
|
||||
$ICM699MC->whereIn('SHWHS', [$USERWH, '']);
|
||||
} else {
|
||||
$ICM699M->where('SHCO', null);
|
||||
$ICM699M->where('SHWHS', null);
|
||||
|
||||
$ICM699MC->where('SHCO', null);
|
||||
$ICM699MC->where('SHWHS', null);
|
||||
}
|
||||
|
||||
if ($SHMACPKR != '') {
|
||||
$ICM699M->where('SHMACPKR', $SHMACPKR);
|
||||
|
||||
$ICM699MC->where('SHMACPKR', $SHMACPKR);
|
||||
}
|
||||
|
||||
if ($SHSOURCE != '') {
|
||||
$ICM699M->where('SHSOURCE', $SHSOURCE);
|
||||
|
||||
$ICM699MC->where('SHSOURCE', $SHSOURCE);
|
||||
}
|
||||
# Disable PDFStorage Search
|
||||
$ICM699M->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
|
||||
$ICM699MC->where('SHSOURCE', '!=', 'PdfStorageAPI');
|
||||
|
||||
if ($SHMACPKR == '' && $SKIPDATES == 'N') {
|
||||
$ICM699M->whereBetween('SHDT', [$STARTDATE, $ENDDATE]);
|
||||
|
||||
$ICM699MC->whereBetween('SHDT', [$STARTDATE, $ENDDATE]);
|
||||
}
|
||||
|
||||
if ($SHOWERRORS == 'Y') {
|
||||
$ICM699M->where('SHERROR', 'X');
|
||||
|
||||
$ICM699MC->where('SHERROR', 'X');
|
||||
}
|
||||
|
||||
# Get only M3 Logs
|
||||
$ICM699M->where('SHTYPE', 'like', '%M3%');
|
||||
|
||||
$ICM699MC->where('SHTYPE', 'like', '%M3%');
|
||||
|
||||
# Count records before exporting to excel : Max 20K records are allowed
|
||||
$ICM699MCount = $ICM699MC->count();
|
||||
// dd($ICM699MCount);
|
||||
# Set Max allowed records
|
||||
$maxRecords = Config::get('arrays.maxRecDL');
|
||||
if ($ICM699MCount > $maxRecords) {
|
||||
return redirect()->back()->withInput()->with('message', 'Maximum allowed records for Excel Download is: ' . number_format($maxRecords) .
|
||||
' current records: ' . number_format($ICM699MCount) . ' , change your search criteria.');
|
||||
}
|
||||
|
||||
# Select Records and export them to Excel
|
||||
$ICM699MSel = $ICM699M->get();
|
||||
$ICM699MCol = collect($ICM699MSel);
|
||||
|
||||
# Get Transaction Types
|
||||
$transxTypes = Config::get('arrays.transxTypes');
|
||||
$ICM699MCol->filter(function ($value) use ($transxTypes) {
|
||||
return $value->SHSOURCE = isset($transxTypes[trim($value->SHSOURCE)]) ? $transxTypes[trim($value->SHSOURCE)] : $value->SHSOURCE;
|
||||
});
|
||||
|
||||
# Get User Names
|
||||
$ICM699MCol->filter(function ($value) use ($ICM428MCOL) {
|
||||
$UserTemp = $ICM428MCOL->firstWhere('R428US', trim($value->SHACKUSER));
|
||||
$SHACKUSER = isset($UserTemp->R428FIRST) ? $UserTemp->R428FIRST . ' ' . $UserTemp->R428FAMILY : trim($value->SHACKUSER);
|
||||
return $value->SHACKUSER = $SHACKUSER;
|
||||
});
|
||||
|
||||
# Prepend Header To Excel
|
||||
$newItem = ["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'
|
||||
];
|
||||
$ICM699MCol->prepend($newItem);
|
||||
// dd($ICM699MCol);
|
||||
|
||||
# Download Excel File
|
||||
return app(\Modules\M3\Services\SpreadsheetExport::class)->download($ICM699MCol, 'transactionLog_' . $STARTDATE . '-' . $ENDDATE . '.xlsx');
|
||||
} catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
// use Datatables;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use File;
|
||||
use Cache;
|
||||
use Str;
|
||||
|
||||
class M3GetPDFFromCacheController extends Controller
|
||||
{
|
||||
public static function index(Request $request){
|
||||
// Parse PDF file and build necessary objects.
|
||||
$parser = new \Smalot\PdfParser\Parser();
|
||||
|
||||
$aggno = $aggmsg = ""; #$carrier = $trackingno = "";
|
||||
|
||||
# PDF File PATH
|
||||
$pdfFilePath = Config::get('arrays.PdfPath');
|
||||
try {
|
||||
# Initialise Vars
|
||||
$PDFArray = $trackingno = $carrier = $ICM688M1 = [];
|
||||
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
// dd($SHUSER);
|
||||
|
||||
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();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : '';
|
||||
$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;
|
||||
// dump($WHDDA);
|
||||
|
||||
# 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();
|
||||
// dump($ICM695M1Agg);
|
||||
$aggno = isset($ICM695M1Agg->AYTRUCK) ? trim($ICM695M1Agg->AYTRUCK) : '';
|
||||
|
||||
if($aggno!="" && $aggno!="0") {
|
||||
// dump($aggno);
|
||||
|
||||
$aggmsg="This delivery note is part of aggregation $aggno ";
|
||||
$ICM688M1 = DB::connection(config('m3.connection', 'pgsql'))->select("select A4MACPKR from ICM688M1 where A4SHPAGGCD='$aggno'");
|
||||
#dump($ICM688M1);
|
||||
// foreach($ICM688M1 as $key => $ICM688M1R) {
|
||||
// $aggmsg.=' <a href="M3GetPDFFromCache?MACPKR='.$ICM688M1R->A4MACPKR.'&COMPANY='.$COMPANY.'&PLANT='.$PLANT.'&WHS='.$WHS.'">'.$ICM688M1R->A4MACPKR.'</a>';
|
||||
// }
|
||||
// $aggmsg.=" )";
|
||||
|
||||
#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();
|
||||
}
|
||||
#dump($ICM695M1);
|
||||
|
||||
$allLabels = [];
|
||||
|
||||
if (count($ICM695M1)>0) {
|
||||
$tmpCacheArr = $carrier = $trackingno = [];
|
||||
# Loop the Results from $ICM595M1TMP
|
||||
foreach ($ICM695M1 as $key => $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!=''){
|
||||
//echo "<script>alert('2');</script>";
|
||||
$CarrierLabel = '';
|
||||
$ContentLabel = '';
|
||||
$PackingList = '';
|
||||
$cacheKeyPackingList = $cacheKeyCarrierLabel = $cacheKeyContentLabel = '';
|
||||
|
||||
# Get Unique Keys
|
||||
foreach ($docTypes as $key => $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;
|
||||
|
||||
// if ($ContentLabel=='LTL' ) {
|
||||
// $PDFKey = $value.'/'.$value.'_'.$AYMACPKR.'_'.$COMPANY.'_'.$WHS;
|
||||
// }
|
||||
// else{
|
||||
// $PDFKey = $value.'/'.$value.'_'.$AYMACPKR.'_'.$COMPANY.'_'.$WHS.'_'.$DOCNUM;
|
||||
// }
|
||||
}
|
||||
else{
|
||||
$PDFKey = $value.'/'.$value.'_'.$AYMACPKR.'_'.$DOCNUMT.'_'.$COMPANY.'_'.$WHS;
|
||||
}
|
||||
$tmpCacheArr[] = $PDFKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
// dump($tmpCacheArr);
|
||||
|
||||
# Get unique values from array $PDFArray
|
||||
$tmpCacheArr = collect($tmpCacheArr)->unique();
|
||||
// dump($tmpCacheArr);
|
||||
foreach($tmpCacheArr as $key => $value){
|
||||
// $isCarrierLabel = Str::contains($value, 'CarrierLabel');
|
||||
|
||||
$pdfFileName = $pdfFilePath.$value.'.pdf';
|
||||
if(File::exists($pdfFileName)){
|
||||
// dump($pdfFileName);
|
||||
|
||||
$pdfFile = File::get($pdfFileName);
|
||||
# Transform content to base64
|
||||
// $base64PDF = $pdfFile;
|
||||
$base64PDF = base64_encode($pdfFile);
|
||||
// dd($base64PDF);
|
||||
$PDFArray[] = $base64PDF;
|
||||
}
|
||||
}
|
||||
// dump($PDFArray);
|
||||
}
|
||||
else {
|
||||
# Nothing Found
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
}
|
||||
# dump($PDFArray);
|
||||
# dump($AYMACPKR);
|
||||
# dump($IC670M);
|
||||
# dump($ICM695M1);
|
||||
|
||||
return view('m3::liberty-theme.pages.M3GetPDF',compact('IC670M','PDFArray','AYMACPKR','WHDDA','aggmsg','carrier','trackingno','ICM688M1','COMPANY','PLANT','WHS'));
|
||||
// compact('IC670M','ViewTitle')
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Config;
|
||||
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();
|
||||
$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 APMANIFEST = $MF and APCO='$co' and APWHS='$whs' and APPLT='$plant' limit 1";
|
||||
|
||||
$ICM705M1 = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
// dump($ICM705M1);
|
||||
$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);
|
||||
// dump($ICM695M1);
|
||||
|
||||
return view('m3::liberty-theme.pages.MFOrders', compact( 'ICM695M1', 'status_ICM688M1_array', 'MF', 'carrier')
|
||||
);
|
||||
}
|
||||
else{
|
||||
abort(404, 'Manifest Not Found');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Str;
|
||||
use Log;
|
||||
use Excel;
|
||||
use Storage;
|
||||
|
||||
class OrderLinesOfClosedOrder extends Controller
|
||||
{
|
||||
public static function index(Request $request){
|
||||
try {
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
// dd($SHUSER);
|
||||
|
||||
if ($SHUSER!='') {
|
||||
# Get User CO & WH from Table ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH','R428PL')
|
||||
->where('R428US','=',$SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '110'; # Company
|
||||
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '144'; # Plant
|
||||
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '322'; # WareHouse
|
||||
}
|
||||
|
||||
# Warehouse Table
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
# Get URL PARAMS
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
// dump($urlParams);
|
||||
$REPORTDATEDisp = isset($urlParams["REPORTDATEDisp"]) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams["REPORTDATEDisp"]))->format('Ymd') : today()->format('Ymd');
|
||||
|
||||
$WHDDA = $COMPANY.$PLANT.$WHS;
|
||||
// dump($WHDDA);
|
||||
if($REPORTDATEDisp!='' && $COMPANY!='' && $WHS!='' && $PLANT!=''){
|
||||
# Case 729: Add Currency code A1SHCURR FROM ICM666M
|
||||
$selectContent = "
|
||||
SELECT A5MACPKR, A5ONO,
|
||||
(SELECT A4REFORD FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) AS A4REFORD,
|
||||
A5PART, A5RSVQTY, A5PACKED, A5RSVQTY - A5PACKED AS CALCULATED_COLUMN,
|
||||
A5SLUNPR * A5PACKED AS ANOTHER_CALCULATED_COLUMN,
|
||||
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";
|
||||
// dump($selectContent);
|
||||
|
||||
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select($selectContent);
|
||||
// dd($ICM688M2);
|
||||
}
|
||||
else{
|
||||
$ICM688M2 = collect();
|
||||
}
|
||||
|
||||
# Get List of Files
|
||||
$allReportsUrls = [];
|
||||
if ($WHS == '321') {
|
||||
$files = Storage::disk('publicCL')->files();
|
||||
}
|
||||
else{
|
||||
$files = Storage::disk('publicCL')->allFiles($WHS);
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
# Get the file URL (if URL is configured in filesystems.php)
|
||||
$url = Storage::disk('publicCL')->url($file);
|
||||
$allReportsUrls[$file] = $url;
|
||||
}
|
||||
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.OrderLinesOfClosed',compact('IC670M','ICM688M2','WHDDA','COMPANY','PLANT','WHS','REPORTDATEDisp','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 {
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
// dd($SHUSER);
|
||||
|
||||
if ($SHUSER!='') {
|
||||
# Get User CO & WH from Table ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH','R428PL')
|
||||
->where('R428US','=',$SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : ''; # 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();
|
||||
|
||||
# Get URL PARAMS
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
// dd($urlParams);
|
||||
$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');
|
||||
|
||||
$WHDDA = $COMPANY.$PLANT.$WHS;
|
||||
// dump($WHDDA);
|
||||
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);
|
||||
// dd($ICM688M2Col);
|
||||
|
||||
# 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(\Modules\M3\Services\SpreadsheetExport::class)->download($ICM688M2Col, 'Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.xlsx');
|
||||
// return $ICM688M2Col->downloadExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.csv',\Maatwebsite\Excel\Excel::CSV,false);
|
||||
}
|
||||
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 {
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
// dd($SHUSER);
|
||||
|
||||
if ($SHUSER!='') {
|
||||
# Get User CO & WH from Table ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH','R428PL')
|
||||
->where('R428US','=',$SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : ''; # 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();
|
||||
|
||||
# Get URL PARAMS
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
// dd($urlParams);
|
||||
$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');
|
||||
// dump($reportDate);
|
||||
// dd($toreportDate);
|
||||
$reportDateWD = isset($urlParams["REPORTDATE"]) ? trim($urlParams["REPORTDATE"]) : today()->format('Y-m-d');
|
||||
$toreportDateWD = isset($urlParams["TOREPORTDATE"]) ? trim($urlParams["TOREPORTDATE"]) : today()->format('Y-m-d');
|
||||
|
||||
$WHDDA = $COMPANY.$PLANT.$WHS;
|
||||
// dump($WHDDA);
|
||||
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);
|
||||
// dd($ICM688M2Col);
|
||||
|
||||
# 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 = "";
|
||||
}
|
||||
|
||||
if ($WHS == '321') {
|
||||
$prevMonthFile = 'Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.xlsx';
|
||||
}
|
||||
else{
|
||||
$prevMonthFile = $WHS.'/Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'-'.$WHS.'.xlsx';
|
||||
}
|
||||
|
||||
# MAK Store the File to Storage
|
||||
app(\Modules\M3\Services\SpreadsheetExport::class)->store($ICM688M2Col, $prevMonthFile, 'publicCL');
|
||||
|
||||
// $ICM688M2Col->storeExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.csv', 'publicCL',\Maatwebsite\Excel\Excel::CSV);
|
||||
|
||||
// $ICM688M2Col->storeExcel('Closedorderlinesreport_'.$reportDateWD.'-'.$toreportDateWD.'.ods', 'publicCL',\Maatwebsite\Excel\Excel::ODS);
|
||||
|
||||
// dump('Done Saving Excel...');
|
||||
return back();
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
}
|
||||
|
||||
# Download File
|
||||
public static function downloadFiles(Request $request){
|
||||
// dd($request->all());
|
||||
$fileName = $request->filename;
|
||||
if (Storage::disk('publicCL')->exists($fileName)) {
|
||||
# File exists, retrieve content or URL
|
||||
// $content = Storage::disk('publicCL')->get($fileName);
|
||||
$fileUrl = Storage::disk('publicCL')->url($fileName);
|
||||
// dd($fileUrl);
|
||||
$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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\M3\Models\ICM658M;
|
||||
use Datatables;
|
||||
|
||||
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
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->where('R428US',$userId)
|
||||
->where('R428STS','A')
|
||||
->first();
|
||||
|
||||
$userCO = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '';
|
||||
$userPL = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '';
|
||||
$userWH = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '' ;
|
||||
|
||||
if ($userCO!='') {
|
||||
# Warehouse Table
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')
|
||||
->where('WDCO',$userCO)
|
||||
->where('WDPL',$userPL)
|
||||
->where('WDWHS',$userWH)
|
||||
->get();
|
||||
}
|
||||
else{
|
||||
// $REFCAT658 =[];
|
||||
$IC670M =[];
|
||||
}
|
||||
|
||||
// $sqlstmt="SELECT t1.REFKEY,t2.FULLID ,t2.*
|
||||
// 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', compact('IC670M'));
|
||||
// 'REFCAT658',
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
// dd( $request->all() );
|
||||
|
||||
$formInputs = $request->all();
|
||||
$formInputs = array_filter($formInputs);
|
||||
unset($formInputs["_token"]);
|
||||
|
||||
$formInputs['R658IZLCF'] = isset($formInputs['R658IZLCF']) ? $formInputs['R658IZLCF'] : '0';
|
||||
// dd($formInputs);
|
||||
|
||||
$ICM658MINS = ICM658M::insert($formInputs);
|
||||
// dd($ICM658MINS);
|
||||
return redirect()->route('m3.replenishmentSettings.index');
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
$R658PN = (trim($request->R658PN) ?? trim($request->R658PN)) != null ? trim($request->R658PN) : "";
|
||||
$R658CO = (trim($request->R658CO) ?? trim($request->R658CO)) != null ? trim($request->R658CO) : "";
|
||||
$R658PL = (trim($request->R658PL) ?? trim($request->R658PL)) != null ? trim($request->R658PL) : "";
|
||||
$R658WH = (trim($request->R658WH) ?? trim($request->R658WH)) != null ? trim($request->R658WH) : "";
|
||||
$R658MQ = trim($request->R658MQ);
|
||||
$R658RQ = trim($request->R658RQ);
|
||||
$R658RMQ = trim($request->R658RMQ);
|
||||
$R658TL = trim($request->R658TL);
|
||||
$R658IZLCF = (trim($request->R658IZLCF) ?? trim($request->R658IZLCF)) != null ? trim($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)
|
||||
{
|
||||
// dd( $request->all() );
|
||||
$R658PN = trim($request->R658PN);
|
||||
$R658CO = trim($request->R658CO);
|
||||
$R658LC = trim($request->R658LC);
|
||||
$R658PL = trim($request->R658PL);
|
||||
$R658WH = trim($request->R658WH);
|
||||
|
||||
$deleteRecord = 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)
|
||||
{
|
||||
// dd( $request->all() );
|
||||
$params = array();
|
||||
parse_str($request['data'], $params);
|
||||
$paramsObj = (object)$params;
|
||||
// dd($paramsObj);
|
||||
|
||||
$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();
|
||||
// dd($recordExists);
|
||||
$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
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->where('R428US',$userId)
|
||||
->where('R428STS','A')
|
||||
->first();
|
||||
|
||||
$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 =[];
|
||||
// $IC670M =[];
|
||||
}
|
||||
|
||||
// $sqlstmt="SELECT t1.REFKEY,t2.FULLID ,t2.*
|
||||
// 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);
|
||||
|
||||
// dd( Datatables::of($REFCAT658)->addIndexColumn()->make(true) );
|
||||
|
||||
return Datatables::of($REFCAT658)->addIndexColumn()->make(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Models\ShipTo;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Datatables;
|
||||
|
||||
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 = \Modules\M3\Helpers\USStates::all();
|
||||
# CA
|
||||
$CAstates = \Modules\M3\Helpers\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();
|
||||
// ShipTo::create($validated);
|
||||
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 = \Modules\M3\Helpers\USStates::all();
|
||||
# CA
|
||||
$CAstates = \Modules\M3\Helpers\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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Str;
|
||||
use Log;
|
||||
use Excel;
|
||||
use Storage;
|
||||
|
||||
class WhsPerfMetrics extends Controller
|
||||
{
|
||||
public static function index(Request $request){
|
||||
try {
|
||||
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
// dd($SHUSER);
|
||||
|
||||
if ($SHUSER!='') {
|
||||
# Get User CO & WH from Table ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH','R428PL')
|
||||
->where('R428US','=',$SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '110'; # Company
|
||||
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '144'; # Plant
|
||||
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '322'; # WareHouse
|
||||
}
|
||||
|
||||
# Warehouse Table
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
# Get URL PARAMS
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
// dump($urlParams);
|
||||
$REPORTDATEDisp = isset($urlParams["REPORTDATEDisp"]) ? \DateTime::createFromFormat('Y-m-d', trim($urlParams["REPORTDATEDisp"]))->format('Ymd') : today()->format('Ymd');
|
||||
|
||||
$WHDDA = $COMPANY.$PLANT.$WHS;
|
||||
// dump($WHDDA);
|
||||
if($REPORTDATEDisp!='' && $COMPANY!='' && $WHS!='' && $PLANT!=''){
|
||||
# Case 729: Add Currency code A1SHCURR FROM ICM666M
|
||||
$selectContent = "
|
||||
SELECT A5MACPKR, A5ONO,
|
||||
(SELECT A4REFORD FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) AS A4REFORD,
|
||||
A5PART, A5RSVQTY, A5PACKED, A5RSVQTY - A5PACKED AS CALCULATED_COLUMN,
|
||||
A5SLUNPR * A5PACKED AS ANOTHER_CALCULATED_COLUMN,
|
||||
(SELECT A4SHSHNM FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) AS A4SHSHNM ,
|
||||
SHDT, SHTIME,
|
||||
CASE WHEN SHDT IS NULL THEN (SELECT SHDATA FROM ICM699M WHERE SHMACPKR=A5MACPKR AND SHTYPE='M3-Res-out' AND SHSOURCE='CloseShipmentCoChargeAPI' ORDER BY SHDT DESC, SHTIME DESC FETCH FIRST 1 ROWS ONLY) ELSE '' END AS REASON,
|
||||
A1SHCURR,
|
||||
CASE
|
||||
WHEN (SELECT A4SHIPTYPE FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) = 'LTL'
|
||||
THEN (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL'))/100 ."
|
||||
ELSE (SELECT A4RATETCP FROM ICM688M1 WHERE A4MACPKR=A5MACPKR) * ".(100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceParcel') )/100 ."
|
||||
END AS FREIGHT
|
||||
FROM ICM688M2
|
||||
LEFT JOIN ICM699M ON SHMACPKR=A5MACPKR AND SHTYPE='M3-Res-out' AND SHDATA LIKE 'Success%' AND SHSOURCE='CloseShipmentCoChargeAPI'
|
||||
LEFT JOIN ICM666M ON A1DELNO=A5MACPKR AND A1ONO=A5ONO AND A1PKLN=A5BRADLN
|
||||
WHERE A5MACPKR IN (
|
||||
SELECT DISTINCT AYMACPKR
|
||||
FROM ICM695M1
|
||||
WHERE AYSTATUS IN ('Z','z') AND AYAPR8N002 = $REPORTDATEDisp
|
||||
)
|
||||
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT";
|
||||
// dump($selectContent);
|
||||
|
||||
$ICM688M2 = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select($selectContent);
|
||||
// dd($ICM688M2);
|
||||
}
|
||||
else{
|
||||
$ICM688M2 = collect();
|
||||
}
|
||||
|
||||
# Get List of Files
|
||||
$allReportsUrls = [];
|
||||
$files = Storage::disk('publicLabels')->allFiles('WhsPerf/'.$WHS);
|
||||
// $whsPerfFile = 'WhsPerf/'.$WHS.'/WhsPerfMetrics_'.$DateToday.'-'.$WHS.'.xlsx';
|
||||
|
||||
foreach ($files as $file) {
|
||||
# Get the file URL (if URL is configured in filesystems.php)
|
||||
$url = Storage::disk('publicLabels')->url($file);
|
||||
$allReportsUrls[$file] = $url;
|
||||
}
|
||||
// dd($allReportsUrls);
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
Log::error($th);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.WhsPerfMetrics',compact('IC670M','WHDDA','COMPANY','PLANT','WHS','allReportsUrls'));
|
||||
}
|
||||
|
||||
|
||||
# Download File
|
||||
public static function downloadFiles(Request $request){
|
||||
// dd($request->all());
|
||||
$fileName = $request->filename;
|
||||
if (Storage::disk('publicLabels')->exists($fileName)) {
|
||||
# File exists, retrieve content or URL
|
||||
$fileUrl = Storage::disk('publicLabels')->url($fileName);
|
||||
$fileNameOnly = basename($fileName);
|
||||
# Download the file
|
||||
return Storage::disk('publicLabels')->download($fileName, $fileNameOnly);
|
||||
} else {
|
||||
// Download the file (use code below)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
class authController extends Controller
|
||||
{
|
||||
public static function logout(){
|
||||
|
||||
return view('m3::liberty-theme.pages.logout');
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\M3\Models\ICM160M;
|
||||
use Helper;
|
||||
|
||||
|
||||
class carrierMaintController extends Controller
|
||||
{
|
||||
|
||||
public static function index(Request $request) {
|
||||
$currentUser = Helper::getUserCOWHSPLT();
|
||||
$UserCO = $currentUser['UserCO'] ?? '';
|
||||
$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'");
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='".strtoUpper(m3_user())."'");
|
||||
return view('m3::liberty-theme.pages.carrierMaint', compact('ICM160M','power_user'));
|
||||
|
||||
}
|
||||
|
||||
# Process data from Add modal
|
||||
public static function savecarrierAdd(Request $request) {
|
||||
$currentUser = Helper::getUserCOWHSPLT();
|
||||
$UserCO = $currentUser['UserCO'] ?? '';
|
||||
// $UserWHS = $currentUser['UserWHS'] ?? '';
|
||||
// $UserPL = $currentUser['UserPL'] ?? '';
|
||||
|
||||
# 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'] ?? '';
|
||||
// $UserWHS = $currentUser['UserWHS'] ?? '';
|
||||
// $UserPL = $currentUser['UserPL'] ?? '';
|
||||
|
||||
# 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";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
use DB;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class dashboardController extends Controller
|
||||
{
|
||||
public static function index(){
|
||||
return view('m3::liberty-theme.pages.dashboard');
|
||||
// , compact('data','whs','whs_array','starting','ending')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Str;
|
||||
use Log;
|
||||
|
||||
|
||||
class execSummaryController extends Controller
|
||||
{
|
||||
public static function index(Request $request){
|
||||
try {
|
||||
# Ajax Call
|
||||
if ($request->ajax()) {
|
||||
// dump($request->all());
|
||||
$WHDDA = isset($request->WHDDA) ? $request->WHDDA : array();
|
||||
$WHArr = array();
|
||||
foreach ($WHDDA as $key => $WHDDAV) {
|
||||
$CO = substr($WHDDAV, 0, 3);
|
||||
// $R428PL = substr($WHDDAV, 3, 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(count($WHArr)>0 && $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."' and a5whs in (".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."' and a5whs in (".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');
|
||||
// $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."' and a5whs in (".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;
|
||||
}
|
||||
// dump($reportDate);
|
||||
// dump($toreportDate);
|
||||
// dump($selectContent);
|
||||
|
||||
$execSummaryRes = DB::connection(config('m3.connection', 'pgsql'))->select($selectContent);
|
||||
}
|
||||
else{
|
||||
$execSummaryRes = collect();
|
||||
}
|
||||
// dump($execSummaryRes);
|
||||
|
||||
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())) : '';
|
||||
// dd($SHUSER);
|
||||
if ($SHUSER!='') {
|
||||
# Get User CO & WH from Table ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH','R428PL')
|
||||
->where('R428US','=',$SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '110'; # Company
|
||||
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '144'; # Plant
|
||||
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '322'; # WareHouse
|
||||
}
|
||||
$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',compact('IC670M','WHDDA'));
|
||||
// ,'ICM688M2',,'COMPANY','PLANT','WHS','reportDate'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Str;
|
||||
use Log;
|
||||
|
||||
|
||||
class execSummaryLineController extends Controller
|
||||
{
|
||||
public static function index(Request $request){
|
||||
try {
|
||||
# Ajax Call
|
||||
if ($request->ajax()) {
|
||||
// dump($request->all());
|
||||
$WHDDA = isset($request->WHDDA) ? $request->WHDDA : array();
|
||||
$WHArr = array();
|
||||
foreach ($WHDDA as $key => $WHDDAV) {
|
||||
$CO = substr($WHDDAV, 0, 3);
|
||||
// $R428PL = substr($WHDDAV, 3, 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(count($WHArr)>0 && $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."' and a5whs in (".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('first day of this month')->format('Ymd'); //
|
||||
$toreportDate = $lastDay ? $lastDay->modify('last day of this month')->format('Ymd') : '';
|
||||
# Last Year Dates
|
||||
// Same period, but for Last Year (LY)
|
||||
$reportDateLY = (clone $firstDay)->modify('-1 year')->modify('first day of this month')->format('Ymd');
|
||||
$toreportDateLY = (clone $lastDay)->modify('-1 year')->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."' and a5whs in (".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."' and a5whs in (".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('first day of this month')->format('Ymd');
|
||||
$toreportDate = $firstDay->modify('last day of this month')->format('Ymd');
|
||||
|
||||
# Last Year Dates
|
||||
$reportDateLY = (clone $firstDay)->modify('-1 year')->modify('first day of this month')->format('Ymd');
|
||||
$toreportDateLY = (clone $firstDay)->modify('-1 year')->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."' and a5whs in (".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."' and a5whs in (".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())) : '';
|
||||
// dd($SHUSER);
|
||||
if ($SHUSER!='') {
|
||||
# Get User CO & WH from Table ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH','R428PL')
|
||||
->where('R428US','=',$SHUSER)
|
||||
->first();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$COMPANY = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '110'; # Company
|
||||
$PLANT = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '144'; # Plant
|
||||
$WHS = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '322'; # WareHouse
|
||||
}
|
||||
$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',compact('IC670M','WHDDA'));
|
||||
// ,'ICM688M2',,'COMPANY','PLANT','WHS','reportDate'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Storage;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\M3\Services\BillOfLadingService;
|
||||
use setasign\Fpdi\Fpdi;
|
||||
|
||||
|
||||
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' => $request->input('master_bill_no') ? 'X' : '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' => $request->input('freight_collect') ? 'X' : '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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Storage;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use mikehaertl\pdftk\Pdf;
|
||||
//use mikehaertl\tmp\File;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#$test = Storage::disk('public')->exists('ETN-BOL.pdf');
|
||||
#dd($test);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
#$test=$pdf->addFile(Storage::disk('public')->path($newfile), 'A');
|
||||
#dd($test);
|
||||
|
||||
$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));
|
||||
dd("step 4");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\M3\Models\ICM709M;
|
||||
|
||||
|
||||
class palletQtyController extends Controller
|
||||
{
|
||||
|
||||
public static function index(Request $request) {
|
||||
|
||||
#$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
#$power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='".strtoUpper(m3_user())."'");
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428PWRUSR','R428US','R428CO','R428PL','R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $power_user->R428CO;
|
||||
$plant = $power_user->R428PL;
|
||||
$whs = $power_user->R428WH;
|
||||
$ICM709M = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')
|
||||
->where('AT9CO','=',$co)
|
||||
->where('AT9PLT','=',$plant)
|
||||
->where('AT9WHS','=',$whs)
|
||||
->get();
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->select("select * from IC670M where WDCO='$co' and WDPL='$plant' and WDWHS='$whs'");
|
||||
return view('m3::liberty-theme.pages.palletQty', compact('ICM709M','IC670M','power_user'));
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Process data from Add modal
|
||||
//
|
||||
public static function saveQtyAdd(Request $request) {
|
||||
|
||||
// Insert record to ICM709M
|
||||
#var_dump($request);
|
||||
#console.log($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);
|
||||
#console.log($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) {
|
||||
|
||||
#dump($request);
|
||||
#console.log($request);
|
||||
|
||||
//$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'");
|
||||
//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";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
#732
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Config;
|
||||
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=array();
|
||||
$ICM699Ma=array();
|
||||
foreach($ICM705M1 as $key=>$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 $key2=>$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 $key2=>$val2) {
|
||||
$ICM699Ma[$val2->SHMACPKR]['SHDT'] = $val2->SHDT;
|
||||
$ICM699Ma[$val2->SHMACPKR]['SHTIME'] = $val2->SHTIME;
|
||||
}
|
||||
}
|
||||
// dump($ICM699Ma);
|
||||
|
||||
|
||||
$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 = array();
|
||||
$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 $key=>$UproccessedOrder) {
|
||||
// $unprocessedArr[] = $UproccessedOrder->APMANIFEST;
|
||||
$unprocessedArr[] = '<a class="btn btn-link mb-1" target="_blank" href="'.url('MFOrders', ['id' => trim($UproccessedOrder->APMANIFEST)]).'"> '.
|
||||
trim($UproccessedOrder->APMANIFEST).'</a>';
|
||||
}
|
||||
// dump($unprocessedArr);
|
||||
|
||||
return view('m3::liberty-theme.pages.pendingClosure',
|
||||
compact('ICM705M1', 'ICM698Ma', 'ICM699M', 'user', 'request','unprocessedArr','ICM699Ma')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public static function allowRetry(Request $request){
|
||||
# Get URL PARAMS
|
||||
$urlParams = count($request->all())>0 ? $request->all() : '';
|
||||
// dd($urlParams);
|
||||
// $SHUSER = isset($urlParams["SHUSER"]) ? $urlParams["SHUSER"] : '';
|
||||
$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) {
|
||||
//throw $th;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\M3\Models\ICM428M;
|
||||
|
||||
|
||||
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 = isset($ICM695M1Sel->AYSENTPKR) ? ($ICM695M1Sel->AYSENTPKR !='' ? true : false ) : false;
|
||||
|
||||
if ($allowDeletion) {
|
||||
$timestamp = date('Y-m-d H:i:s.u');
|
||||
$date1 = date('Ymd');
|
||||
$time1 = date('His');
|
||||
|
||||
# Delete Records from ICM695M1 And ICM695M2
|
||||
$ICM695M1Del = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
||||
->where('AYINTBOX',$AYINTBOX)
|
||||
->where('AYCO',$AYCO)
|
||||
->where('AYWHS',$AYWHS)
|
||||
->delete();
|
||||
|
||||
$ICM695M2Del = 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'";
|
||||
|
||||
$ICM689MInsert = 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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Modules\M3\Models\ICM428M;
|
||||
|
||||
|
||||
class userControlController extends Controller
|
||||
{
|
||||
|
||||
public static function index(Request $request) {
|
||||
|
||||
#$sqlstmt="select * from ICM428M";
|
||||
#$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')->get();
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $ICM428M->R428CO;
|
||||
$whs = $ICM428M->R428WH;
|
||||
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->select("SELECT * FROM ICM428M where R428CO='$co' and R428WH='$whs'");
|
||||
#765 add DATE_PASSWORD_EXPIRES as DATE_EXPIRED, SET_PASSWORD_TO_EXPIRE as EXPIRED
|
||||
$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();
|
||||
#echo "<pre>"; var_dump($USER_INFO); echo "</pre>";
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='".strtoUpper(m3_user())."'");
|
||||
#765
|
||||
# $expired_users = DB::connection(config('m3.connection', 'pgsql'))->select("SELECT USER_PROFILE FROM TABLE (SYSTOOLS.AUDIT_JOURNAL_CP () ) WHERE PASSWORD_EXPIRED = '*YES'");
|
||||
# echo "<pre>"; print_r($expired_users); echo "</pre>";
|
||||
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
return view('m3::liberty-theme.pages.userControl', compact('ICM428M','IC670M','power_user','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 {
|
||||
#echo "<script>alert('User profile entered does not exist, please try again');</script>";
|
||||
|
||||
# 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(\Modules\M3\Services\PostgresProgramBridge::class);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// Determine reason for failure.
|
||||
// Probably database authentication error or invalid or unreachable database.
|
||||
$code = $e->getCode();
|
||||
$msg = $e->getMessage();
|
||||
switch ($code) {
|
||||
case 8001:
|
||||
// "Authorization failure on distributed database connection attempt"
|
||||
// Usually means a wrong DB2 user or password
|
||||
$PGMERRORS = 'Could not connect due to wrong user or password.';
|
||||
return "error profile3";
|
||||
break;
|
||||
case 42705:
|
||||
$PGMERRORS = 'Database not found. Try WRKRDBDIRE to check.';
|
||||
return "error profile4";
|
||||
break;
|
||||
default:
|
||||
$PGMERRORS = 'Could not connect. Error: ' . $code . ' ' . $msg;
|
||||
return "error profile5";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$conn->setOptions(array('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, array(), array());
|
||||
if (!$result) {
|
||||
$PGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' Msg: ' . $conn->getErrorMsg();
|
||||
//echo "<script>alert($PGMERRORS);</script>";
|
||||
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) {
|
||||
|
||||
#dump($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'");
|
||||
//var_dump($ICM428M);
|
||||
|
||||
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) {
|
||||
|
||||
$PGMERRORS = '';
|
||||
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(\Modules\M3\Services\PostgresProgramBridge::class);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// Determine reason for failure.
|
||||
// Probably database authentication error or invalid or unreachable database.
|
||||
$code = $e->getCode();
|
||||
$msg = $e->getMessage();
|
||||
|
||||
switch ($code) {
|
||||
case 8001:
|
||||
// "Authorization failure on distributed database connection attempt"
|
||||
// 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(array('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 = [];
|
||||
|
||||
// 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
|
||||
//$params[] = $conn->AddParameterPackDec('in', 11, 0, 'ParamIn','','00000087125');
|
||||
|
||||
// $params[] = $conn->AddParameterZoned('in', 11, 0, 'ParamIn');
|
||||
|
||||
// Start Time Tracking
|
||||
// $start = microtime(true);
|
||||
|
||||
//dump('Calling: EWOBJ/ICMCHGPRF action='.$request->ACTION.' user='.$request->USERID);
|
||||
|
||||
// Config::get('eproconf.misc.PGM1'), Config::get('eproconf.misc.libname4')
|
||||
// ICM700C EWOBJTST ICM700C ICM700CSBM
|
||||
$result = $conn->PgmCall('ICMCHGPRF', 'EWOBJ', $params, array(), array());
|
||||
|
||||
if (!$result) {
|
||||
$PGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' Msg: ' . $conn->getErrorMsg();
|
||||
//dump($PGMERRORS);
|
||||
echo "<script>alert($PGMERRORS);</script>";
|
||||
return "error";
|
||||
die();
|
||||
}
|
||||
// Successful Call
|
||||
else{
|
||||
//dump($result);
|
||||
// $AWREQN = $result['io_param']["var0"];
|
||||
//return "success";
|
||||
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) {
|
||||
|
||||
#dd('B4');
|
||||
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'));
|
||||
|
||||
$PGMERRORS = '';
|
||||
|
||||
#console_log("request> ");
|
||||
#echo "request="; var_dump($request);
|
||||
|
||||
#echo "B3<br>";
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(\Modules\M3\Services\PostgresProgramBridge::class);
|
||||
#dump($conn);
|
||||
#echo "B4<br>";
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
#echo "B5<br>";
|
||||
// Determine reason for failure.
|
||||
// Probably database authentication error or invalid or unreachable database.
|
||||
### $conn->setOptions(array('persistent' => false, 'stateless' => true, 'debug' => true,'debugLogFile' => '/www/sentm3test/htdocs/storage/logs/toolkit_debug.log'));
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
#$params = [];
|
||||
#$params[] = $conn->AddParameterChar('in', 10, 'userid','USRPRF',$request->USERID);
|
||||
#$params[] = $conn->AddParameterChar('in', 10, 'pwd','PASSWORD',$request->PASSWORD);
|
||||
#$params[] = $conn->AddParameterChar('in', 9, 'sts','STATUS','*ENABLED');
|
||||
#$params[] = $conn->AddParameterChar('in', 4, 'pwdexp','PWDEXP','*NO');
|
||||
|
||||
//dump('Before CHGUSRPRF');
|
||||
$result = $conn->CLCommand('QSYS/CHGUSRPRF USRPRF('.$request->R428US_PWD.') PASSWORD('.$request->NEW_PASSWORD.') STATUS(*ENABLED) PWDEXP(*NO)');
|
||||
#$result = $conn->PgmCall('CHGUSRPRF', 'QSYS', $params, array(), array());
|
||||
#echo "<script>alert('After CHGUSRPRF');</script>";
|
||||
|
||||
if (!$result) {
|
||||
$PGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' Msg: ' . $conn->getErrorMsg();
|
||||
dump($PGMERRORS);
|
||||
echo "<script>alert($PGMERRORS);</script>";
|
||||
return "error pwd";
|
||||
}
|
||||
// Successful Call
|
||||
else{
|
||||
return "success";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Config;
|
||||
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;
|
||||
$min_work_hours_for_break = implode(",", Config::get('arrays.min_work_hours_for_break'));
|
||||
|
||||
##$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
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $ICM428M->R428CO;
|
||||
$whs = $ICM428M->R428WH;
|
||||
|
||||
$user_array=array();
|
||||
#$sqlstmt="SELECT R428US as userprf, R428FIRST, R428FAMILY, R428EMPCDE as empno FROM ICM428M where R428EMPCDE!=0";
|
||||
$sqlstmt="SELECT R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno FROM ICM428M
|
||||
where R428STS='A' and R428EMPCDE!=0 and R428CO='$co' and R428WH='$whs'";
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
// ->selectRaw("R428US, (trim(R428FIRST) || ' ' || trim(R428FAMILY)), R428EMPCDE ")
|
||||
// ->where("R428EMPCDE!=0")
|
||||
// ->get();
|
||||
#while($row = odbc_fetch_object($result)) {
|
||||
$x=0;
|
||||
foreach($ICM428M as $key=>$row) {
|
||||
// print_r($row);
|
||||
$user_array[$x]['userprf']=trim($row->USERPRF);
|
||||
#$user_array[$x]['name']=trim($row->R428FIRST)+' '+trim($row->R428FAMILY);
|
||||
$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');
|
||||
#echo "<pre>"; print_r($user_array); echo "</pre>";
|
||||
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";
|
||||
|
||||
#echo "$sqlstmt<br>";
|
||||
|
||||
$lbpf1 = 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' ";
|
||||
#@dd($sql);
|
||||
|
||||
if (isset($request->dates) || isset($request->user)) {
|
||||
$statistic4 = DB::connection(config('m3.connection', 'pgsql'))->select($sql);
|
||||
} else {
|
||||
$statistic4 = array();
|
||||
}
|
||||
|
||||
#echo "<pre>"; print_r($statistic4); echo "</pre>";
|
||||
|
||||
#$duration = microtime(true) - $start;
|
||||
|
||||
// initialize arrays
|
||||
$monitor_array = $totals_array = $perf_array = array();
|
||||
$totals_array["value"] = 0;
|
||||
$totals_array["weight"] = 0;
|
||||
$totals_array["timediff"] = 0;
|
||||
$totals_array["picked"] = 0;
|
||||
$totals_array["entries"] = 0;
|
||||
$diff = 0;
|
||||
|
||||
#echo "<pre>"; print_r($lbpf1); echo "</pre>";
|
||||
|
||||
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;
|
||||
}
|
||||
#echo "after 1st init<br>";
|
||||
|
||||
// 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"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#echo "<pre>";
|
||||
#print_r($request);
|
||||
#print_r($perf_array); print_r($monitor_array);
|
||||
|
||||
// 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 = array(
|
||||
"day" => $starting,
|
||||
"performance" => $performance,
|
||||
"blendedTargetLPH" => $blendedTargetLPH,
|
||||
"actualLPH" => $actualLPH,
|
||||
"grossHours" => $grossHours
|
||||
);
|
||||
#echo "<pre>"; print_r($json_data);
|
||||
return json_encode($json_data);
|
||||
|
||||
} else {
|
||||
// display webpage of statistic version 4
|
||||
$request->ports = Config::get('arrays.env_ports');
|
||||
$no_data = "N";
|
||||
if (count($statistic4) == 0 && $_SERVER['REQUEST_URI'] != "/userPickingStats4") {
|
||||
$no_data = "Y";
|
||||
}
|
||||
|
||||
#error_log("Time required to xyz: " . $duration . "\n", 3, "/temp/v4.log");
|
||||
|
||||
return view(
|
||||
'liberty-theme.pages.userPickingStats4',
|
||||
compact('statistic4', 'starting', 'user', 'user_array', 'monitor_array', 'totals_array', 'perf_array', 'request', 'no_data')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
use DB;
|
||||
use Config;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Illuminate\Support\Facades\Http; #added this for curl call to v4
|
||||
|
||||
use DateTime;
|
||||
use DatePeriod;
|
||||
use DateInterval;
|
||||
|
||||
class userPickingStats5 extends Controller
|
||||
{
|
||||
|
||||
public static function index(Request $request){
|
||||
|
||||
#618
|
||||
# Get Logged User CO & WH
|
||||
# Get Users from ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $ICM428M->R428CO;
|
||||
$whs = $ICM428M->R428WH;
|
||||
|
||||
#@dd($request);
|
||||
#$user_array=Config::get('arrays.user_array');
|
||||
$user_array=array();
|
||||
$sqlstmt="SELECT R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno FROM ICM428M
|
||||
where R428EMPCDE!=0 and R428CO='$co' and R428WH='$whs'";
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
$x=0;
|
||||
foreach($ICM428M as $key=>$row) {
|
||||
// print_r($row);
|
||||
$user_array[$x]['userprf']=trim($row->USERPRF);
|
||||
#$user_array[$x]['name']=trim($row->R428FIRST)+' '+trim($row->R428FAMILY);
|
||||
$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);
|
||||
|
||||
// Filter by date
|
||||
if (isset($request->dates)) {
|
||||
$date = explode (' - ', $request->dates);
|
||||
$start = str_replace(array(' ', '-'), '', $date[0]);
|
||||
$end = str_replace(array(' ', '-'), '', $date[1]);
|
||||
$starting = $date[0];
|
||||
$ending = $date[1];
|
||||
} else {
|
||||
$start = date("Ymd", strtotime("-5 days"));
|
||||
$end = date("Ymd");
|
||||
$starting = date("Y-m-d", strtotime("-5 days"));
|
||||
#$starting = "2021-11-01";
|
||||
$ending = date("Y-m-d");
|
||||
}
|
||||
|
||||
// calculate day difference between 2 dates
|
||||
$str_date = new DateTime($starting);
|
||||
$end_date = new DateTime($ending);
|
||||
$interval = $str_date->diff($end_date);
|
||||
$days = $interval->format('%a'); //retrieve number of days %a
|
||||
#echo "diff=$days<br>";
|
||||
|
||||
$user=$request->user;
|
||||
|
||||
// retrieve session user and pw, also the HTTP server host address and port
|
||||
$username = $request->header('php-auth-user');
|
||||
$pw = $request->header('php-auth-pw');
|
||||
$http_host = $request->server('HTTP_HOST');
|
||||
$urlStats4 = "http://$http_host/userPickingStats4";
|
||||
|
||||
// initialize arrays
|
||||
$statistic5 = $totals_array = array();
|
||||
// initialize totals
|
||||
$totals_array['performance'] = 0;
|
||||
$totals_array['blendedTargetLPH'] = 0;
|
||||
$totals_array['actualLPH'] = 0;
|
||||
$totals_array['grossHours'] = 0;
|
||||
$y = 0;
|
||||
|
||||
// loop for the days difference and passing proper date to v4 to get json encoded response
|
||||
if (isset($request->dates)) {
|
||||
for($x=0;$x<=$days;$x++) {
|
||||
|
||||
$next_date = date("Y-m-d",strtotime($starting."+$x days"));
|
||||
|
||||
$parameters = ['dates'=>$next_date, 'user'=>$request->user, 'format'=>'json'];
|
||||
#echo "<pre>"; print_r($parameters); echo "$urlStats4</pre>";
|
||||
|
||||
$response = Http::withBasicAuth($username, $pw)->get($urlStats4, $parameters);
|
||||
#echo $response;
|
||||
$statusCode = $response->status();
|
||||
|
||||
#echo "$statusCode json return=".$response->getBody()." <br>";
|
||||
|
||||
$statistic5[$x] = json_decode($response->getBody(),true);
|
||||
|
||||
$totals_array['performance'] += isset($statistic5[$x]['performance'])?$statistic5[$x]['performance']:0;
|
||||
$totals_array['blendedTargetLPH'] += isset($statistic5[$x]['blendedTargetLPH'])?$statistic5[$x]['blendedTargetLPH']:0;
|
||||
$totals_array['actualLPH'] += isset($statistic5[$x]['actualLPH'])?$statistic5[$x]['actualLPH']:0;
|
||||
$totals_array['grossHours'] += isset($statistic5[$x]['grossHours'])?$statistic5[$x]['grossHours']:0;
|
||||
|
||||
if(!isset($statistic5[$x]['day'])) {
|
||||
$statistic5[$x]['day'] = $next_date;
|
||||
}
|
||||
if(isset($statistic5[$x]['performance'])) {
|
||||
if($statistic5[$x]['performance']>0) {
|
||||
$y++;
|
||||
}
|
||||
} else {
|
||||
$statistic5[$x]['performance']=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($y>0) {
|
||||
$totals_array['performance'] /= $y;
|
||||
$totals_array['blendedTargetLPH'] /= $y;
|
||||
$totals_array['actualLPH'] /= $y;
|
||||
$totals_array['grossHours'] /= $y;
|
||||
}
|
||||
|
||||
if($request->format=="json") {
|
||||
echo "<pre>";
|
||||
print_r($statistic5);
|
||||
echo "</pre>";
|
||||
}else{
|
||||
#dd($statistic5);
|
||||
#if($statistic5[1]!=null)
|
||||
return view('m3::liberty-theme.pages.userPickingStats5', compact('statistic5', 'totals_array', 'user_array', 'user', 'starting', 'ending', 'request'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
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', compact('ICM428M','IC670M'));
|
||||
}
|
||||
else{
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function updateUserProfile(Request $request) {
|
||||
// dd($request->all());
|
||||
|
||||
$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);
|
||||
// dd($R428US.'-'.$R428CO.'-'.$R428PL.'-'.$R428WH );
|
||||
|
||||
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 "success";
|
||||
return redirect('/userprofile')->with('success', 'Profile updated successfully!');
|
||||
}
|
||||
else{
|
||||
return redirect('/userprofile')->with('success', 'Profile updated successfully!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function updateUserProfileAjax(Request $request) {
|
||||
// dd($request->all());
|
||||
|
||||
$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);
|
||||
// dd($R428US.'-'.$R428CO.'-'.$R428PL.'-'.$R428WH );
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,646 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
use DB;
|
||||
// use Symfony\Component\HttpFoundation\Request;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use File;
|
||||
use Cache;
|
||||
use DateTime;
|
||||
use Config;
|
||||
use Artisan;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Ayeo\Barcode;
|
||||
use PDF;
|
||||
use Log;
|
||||
use Http;
|
||||
use Picqer\Barcode\BarcodeGeneratorPNG;
|
||||
use Dompdf\Dompdf;
|
||||
|
||||
use Zebra\Client;
|
||||
use Zebra\Zpl\Image;
|
||||
use Zebra\Zpl\Builder;
|
||||
use Zebra\Zpl\GdDecoder;
|
||||
|
||||
use Modules\M3\Http\Controllers\GetContentsController;
|
||||
|
||||
class utilitiesContoller extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
dd("SentM3Test");
|
||||
|
||||
// Get The Next ID by Calling POM002C
|
||||
$PGMERRORS = '';
|
||||
$AWREQN = '';
|
||||
|
||||
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
|
||||
try {
|
||||
$conn = app(\Modules\M3\Services\PostgresProgramBridge::class);
|
||||
} catch (Exception $e) {
|
||||
// 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(array('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 = [];
|
||||
// $params[] = $conn->AddParameterChar('out',7,'eqNumber');
|
||||
|
||||
// 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');
|
||||
|
||||
// $params[] = $conn->AddParameterZoned('in', 11, 0, 'ParamIn');
|
||||
|
||||
// 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, array(), array());
|
||||
|
||||
if (!$result) {
|
||||
$PGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' Msg: ' . $conn->getErrorMsg();
|
||||
}
|
||||
// Successful Call
|
||||
else {
|
||||
dump($result);
|
||||
// $AWREQN = $result['io_param']["var0"];
|
||||
}
|
||||
|
||||
if ($PGMERRORS != "") {
|
||||
// return back()->withMessage('Can not Create PR: '.$PGMERRORS);
|
||||
dump($PGMERRORS);
|
||||
} else {
|
||||
// return $AWREQN;
|
||||
}
|
||||
// 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.
|
||||
$parser = new \Smalot\PdfParser\Parser();
|
||||
|
||||
// $pdf = $parser->parseFile('/www/sentm3test/htdocs/labels/E1232824-10826596.pdf');
|
||||
// dump($pdf);
|
||||
// $text = $pdf->getText();
|
||||
// dump("Text Only");
|
||||
// dump($text);
|
||||
|
||||
// $pdfFile = file_get_contents('/www/sentm3test/htdocs/labels/E1232824-10826596.pdf');
|
||||
$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();
|
||||
|
||||
// $counter=0;
|
||||
foreach ($ICM688M2SLTMP as $key => $ICM688M2SL) {
|
||||
// $counter++;
|
||||
// $counter == 10 ? exit : '';
|
||||
|
||||
$A5MACPKR = isset($ICM688M2SL->A5MACPKR) ? $ICM688M2SL->A5MACPKR : '';
|
||||
$A5SENTPKR = isset($ICM688M2SL->A5SENTPKR) ? $ICM688M2SL->A5SENTPKR : '';
|
||||
|
||||
dump("ICM688M2 Record: " . $A5MACPKR . '-' . $A5SENTPKR);
|
||||
|
||||
$ICM799MINS = 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();
|
||||
// dump($GSArray);
|
||||
|
||||
$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();
|
||||
|
||||
$R428US = isset($ICM428M->R428US) ? $ICM428M->R428US : ''; # User
|
||||
$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 $key => $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
|
||||
$ICM695M3SQLInsert = 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>';
|
||||
// dump($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();
|
||||
// dump($pdfContent);
|
||||
|
||||
$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
|
||||
// $ICM695M3SQLInsert = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m3')
|
||||
// ->insert(['A2CO'=> $COMPANY,'A2WHS'=> $WHS,'A2MACPKR'=> $Macpkr,'A2GS1LABEL'=> $gs1_128_bc]);
|
||||
|
||||
// Log::channel('LabelCron')->info("<<< GS1-128...End of Label Creation for Mackpkr: ".$Macpkr);
|
||||
|
||||
return json_encode(["result" => "success", "GS1File" => $GS1FileNameNoRoot]);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
Log::channel('LabelCron')->error($th);
|
||||
return json_encode(["result" => "error", "GS1File" => $th]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function generateGS128Tst(Request $request)
|
||||
{
|
||||
print_r(">>> Generate PDF");
|
||||
|
||||
// $builder = new Barcode\Builder();
|
||||
// $image = $builder->output('(10)123456(400)11(3906)333333');
|
||||
|
||||
// $builder = new Barcode\Builder();
|
||||
// $builder->setBarcodeType('gs1-128');
|
||||
// $builder->setFilename('barcode.png');
|
||||
// $builder->setImageFormat('png');
|
||||
// $builder->setWidth(500);
|
||||
// $builder->setHeight(150);
|
||||
// $builder->setFontPath('FreeSans.ttf');
|
||||
// $builder->setFontSize(15);
|
||||
// $builder->setBackgroundColor(255, 255, 255);
|
||||
// $builder->setPaintColor(0, 0, 0);
|
||||
// Barcode\Builder::build()->setWidth(600)->setBackgroundColor(100, 100, 100)->output('(10)123456(400)11');
|
||||
// return response($image)->header('Content-Type', 'image/png');
|
||||
|
||||
$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>';
|
||||
|
||||
// return ($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) {
|
||||
// throw new Exception('PDF generation failed.');
|
||||
// }
|
||||
|
||||
# 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();
|
||||
// dd($responseData);
|
||||
// $responseJSON = json_encode($responseData);
|
||||
// dump($responseJSON);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
// use Modules\M3\Models\ICM711M;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
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 = isset($request->date_in)?$request->date_in:date('Ymd');
|
||||
$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', compact('ICM711M','power_user','USER_INFO','date_in','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 = isset($request->date_in)?$request->date_in:date('Ymd');
|
||||
$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', compact('ICM711M','power_user','USER_INFO','date_in','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,90 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use Str;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
||||
class whsePerfDetailsController extends Controller
|
||||
{
|
||||
|
||||
public static function index(Request $request) {
|
||||
|
||||
// $date_in = date('Y-m-d', strtotime($request->date_in));
|
||||
$date_in = isset($request->date)?date('Y-m-d',strtotime($request->date)):date('Y-m-d');
|
||||
$date_in_minus_4_months = date('Y-m-d', strtotime($date_in .' -4 months'));
|
||||
$for = isset($request->for)?$request->for:'a';
|
||||
|
||||
$username = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
|
||||
# Get Logged User CO & WH & PL
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH', 'R428PL')
|
||||
->where('R428US','=',$username)
|
||||
->first();
|
||||
|
||||
$co = isset($ICM428M->R428CO) ? $ICM428M->R428CO : '';
|
||||
$whseno = isset($ICM428M->R428WH) ? $ICM428M->R428WH : '';
|
||||
$plantno = isset($ICM428M->R428PL) ? $ICM428M->R428PL : '';
|
||||
|
||||
$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;
|
||||
}
|
||||
#phpinfo();
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/../../KPI2_update711M_SQL_main.inc.php');
|
||||
#var_dump($sqlstmt1.$stmt2);
|
||||
$perfDetails = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt1.$stmt2);
|
||||
#var_dump($perfDetails);
|
||||
|
||||
return view('m3::liberty-theme.pages.whsePerfDetails', compact('perfDetails','date_in','for'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('m3.login');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BasicAuth
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
|
||||
//select md5 or crypt for $mode. md5 is for md5 encoded passwords, crypt is for passwords encoded using apache's httpasswd
|
||||
$mode = "crypt";
|
||||
if (!m3_user() !== '') {
|
||||
$this->authenticate();
|
||||
} else {
|
||||
if($this->check_pass(m3_user(), m3_legacy_password(), $mode, "%%SYSTEM%%")) {
|
||||
return $next($request);
|
||||
} else {
|
||||
$this->authenticate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function check_pass($login, $password, $mode, $password_file) {
|
||||
if(!$fh = fopen($password_file, "r")) { die("<P>Could Not Open Password File"); }
|
||||
$match = 0;
|
||||
while(!feof($fh)) {
|
||||
$line = fgets($fh, 4096);
|
||||
$from_file = explode(":", $line);
|
||||
if($from_file[0] == $login) {
|
||||
if($mode == "crypt"){
|
||||
$salt = substr($from_file[1],0,2);
|
||||
$user_pass = crypt($password,$salt);
|
||||
} elseif ($mode == "md5") {
|
||||
$user_pass = md5($password);
|
||||
}
|
||||
if(rtrim($from_file[1]) == $user_pass) {
|
||||
$match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($match) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
public static function authenticate() {
|
||||
Header("WWW-Authenticate: Basic realm=\"RESTRICTED ACCESS\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo ("<h1>INVALID USERNAME OR PASSWORD. ACCESS DENIED<h1>");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -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 = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Middleware;
|
||||
|
||||
use Modules\M3\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\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);
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Config;
|
||||
|
||||
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'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Config;
|
||||
|
||||
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'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Config;
|
||||
|
||||
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;
|
||||
// return redirect()->back()
|
||||
// ->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) {
|
||||
// throw new \Exception('Composite unique constraint violated for AUSHSHZP and AUSHWHS');
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
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',
|
||||
];
|
||||
}
|
||||
@@ -2,29 +2,31 @@
|
||||
|
||||
namespace Modules\M3\Providers;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Modules\M3\Support\ModuleInfo;
|
||||
use Config;
|
||||
|
||||
class M3ServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @var string $moduleName
|
||||
*/
|
||||
protected string $moduleName = 'M3';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var string $moduleNameLower
|
||||
*/
|
||||
protected string $moduleNameLower = 'm3';
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides(): array
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides():array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
@@ -34,7 +36,7 @@ class M3ServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): void
|
||||
public function boot() : void
|
||||
{
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
@@ -61,33 +63,34 @@ class M3ServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function registerHelpers(): void
|
||||
{
|
||||
foreach (glob(__DIR__ . '/../Helpers/*.php') as $filename) {
|
||||
foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) {
|
||||
require_once $filename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Dynamically Register Commands.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerCommands(): void
|
||||
{
|
||||
if (! $this->app->runningInConsole()) {
|
||||
return;
|
||||
{
|
||||
if (!$this->app->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
$commandPath = __DIR__ . '/../Console';
|
||||
$commands = collect(File::allFiles($commandPath))
|
||||
->map(function ($file) {
|
||||
$class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension();
|
||||
return $class;
|
||||
})
|
||||
->filter(function ($class) {
|
||||
return class_exists($class);
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
$this->commands($commands);
|
||||
}
|
||||
$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.
|
||||
@@ -97,12 +100,33 @@ class M3ServiceProvider extends ServiceProvider
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([
|
||||
module_path(ModuleInfo::name(), 'Config/config.php') => config_path(ModuleInfo::nameLower() . '.php'),
|
||||
module_path(ModuleInfo::name(), 'Config/config.php') => config_path( ModuleInfo::nameLower(). '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path(ModuleInfo::name(), 'Config/config.php'),
|
||||
ModuleInfo::nameLower(),
|
||||
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',
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,9 +139,9 @@ class M3ServiceProvider extends ServiceProvider
|
||||
$viewPath = resource_path('views/modules/' . ModuleInfo::nameLower());
|
||||
$sourcePath = module_path(ModuleInfo::name(), 'Resources/views');
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath,
|
||||
$sourcePath => $viewPath
|
||||
], ['views', ModuleInfo::nameLower() . '-module-views']);
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,10 +151,10 @@ class M3ServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
|
||||
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
|
||||
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower());
|
||||
}
|
||||
@@ -138,7 +162,6 @@ class M3ServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Regsiter View Paths
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getPublishableViewPaths(): array
|
||||
@@ -149,7 +172,6 @@ class M3ServiceProvider extends ServiceProvider
|
||||
$paths[] = $path . '/modules/' . ModuleInfo::nameLower();
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Modules\M3\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -14,6 +14,18 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@@ -35,7 +47,9 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
Route::prefix('m3')
|
||||
->name('m3.')
|
||||
->middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('M3', '/Routes/web.php'));
|
||||
}
|
||||
@@ -49,7 +63,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
Route::prefix('api/m3')
|
||||
->name('m3.api.')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('M3', '/Routes/api.php'));
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# M3 Core Module
|
||||
|
||||
M3 functionality migrated from the standalone M3 application into Core.
|
||||
|
||||
## Database
|
||||
|
||||
The module uses Core's PostgreSQL connection by default. Override with `M3_DB_CONNECTION` if M3 data uses another configured PostgreSQL connection.
|
||||
|
||||
No DB2, ODBC, IBM i Access, or `zendtech/ibmitoolkit` dependency is required.
|
||||
|
||||
Legacy IBM i program-call requests are captured by `PostgresProgramBridge` in `m3_program_requests`, allowing a PostgreSQL-native worker/integration to process them independently of HTTP requests.
|
||||
|
||||
## Optional paths
|
||||
|
||||
- `M3_LABELS_PATH`
|
||||
- `M3_CLOSING_ORDERS_PATH`
|
||||
|
||||
Both default beneath `storage/app/m3`.
|
||||
|
||||
## After replacing the module
|
||||
|
||||
```bash
|
||||
composer dump-autoload
|
||||
php artisan optimize:clear
|
||||
php artisan migrate
|
||||
php artisan route:list --path=m3
|
||||
```
|
||||
|
||||
Health check: `/m3/health`.
|
||||
@@ -0,0 +1 @@
|
||||
require('./bootstrap');
|
||||
Vendored
+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
|
||||
// });
|
||||
@@ -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.',
|
||||
|
||||
];
|
||||
@@ -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 »',
|
||||
|
||||
];
|
||||
@@ -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,156 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| as the size rules. Feel free to tweak each of these messages here.
|
||||
|
|
||||
*/
|
||||
|
||||
'accepted' => 'The :attribute must be accepted.',
|
||||
'active_url' => 'The :attribute is not a valid URL.',
|
||||
'after' => 'The :attribute must be a date after :date.',
|
||||
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
|
||||
'alpha' => 'The :attribute must only contain letters.',
|
||||
'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.',
|
||||
'alpha_num' => 'The :attribute must only contain letters and numbers.',
|
||||
'array' => 'The :attribute must be an array.',
|
||||
'before' => 'The :attribute must be a date before :date.',
|
||||
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
|
||||
'between' => [
|
||||
'numeric' => 'The :attribute must be between :min and :max.',
|
||||
'file' => 'The :attribute must be between :min and :max kilobytes.',
|
||||
'string' => 'The :attribute must be between :min and :max characters.',
|
||||
'array' => 'The :attribute must have between :min and :max items.',
|
||||
],
|
||||
'boolean' => 'The :attribute field must be true or false.',
|
||||
'confirmed' => 'The :attribute confirmation does not match.',
|
||||
'current_password' => 'The password is incorrect.',
|
||||
'date' => 'The :attribute is not a valid date.',
|
||||
'date_equals' => 'The :attribute must be a date equal to :date.',
|
||||
'date_format' => 'The :attribute does not match the format :format.',
|
||||
'different' => 'The :attribute and :other must be different.',
|
||||
'digits' => 'The :attribute must be :digits digits.',
|
||||
'digits_between' => 'The :attribute must be between :min and :max digits.',
|
||||
'dimensions' => 'The :attribute has invalid image dimensions.',
|
||||
'distinct' => 'The :attribute field has a duplicate value.',
|
||||
'email' => 'The :attribute must be a valid email address.',
|
||||
'ends_with' => 'The :attribute must end with one of the following: :values.',
|
||||
'exists' => 'The selected :attribute is invalid.',
|
||||
'file' => 'The :attribute must be a file.',
|
||||
'filled' => 'The :attribute field must have a value.',
|
||||
'gt' => [
|
||||
'numeric' => 'The :attribute must be greater than :value.',
|
||||
'file' => 'The :attribute must be greater than :value kilobytes.',
|
||||
'string' => 'The :attribute must be greater than :value characters.',
|
||||
'array' => 'The :attribute must have more than :value items.',
|
||||
],
|
||||
'gte' => [
|
||||
'numeric' => 'The :attribute must be greater than or equal :value.',
|
||||
'file' => 'The :attribute must be greater than or equal :value kilobytes.',
|
||||
'string' => 'The :attribute must be greater than or equal :value characters.',
|
||||
'array' => 'The :attribute must have :value items or more.',
|
||||
],
|
||||
'image' => 'The :attribute must be an image.',
|
||||
'in' => 'The selected :attribute is invalid.',
|
||||
'in_array' => 'The :attribute field does not exist in :other.',
|
||||
'integer' => 'The :attribute must be an integer.',
|
||||
'ip' => 'The :attribute must be a valid IP address.',
|
||||
'ipv4' => 'The :attribute must be a valid IPv4 address.',
|
||||
'ipv6' => 'The :attribute must be a valid IPv6 address.',
|
||||
'json' => 'The :attribute must be a valid JSON string.',
|
||||
'lt' => [
|
||||
'numeric' => 'The :attribute must be less than :value.',
|
||||
'file' => 'The :attribute must be less than :value kilobytes.',
|
||||
'string' => 'The :attribute must be less than :value characters.',
|
||||
'array' => 'The :attribute must have less than :value items.',
|
||||
],
|
||||
'lte' => [
|
||||
'numeric' => 'The :attribute must be less than or equal :value.',
|
||||
'file' => 'The :attribute must be less than or equal :value kilobytes.',
|
||||
'string' => 'The :attribute must be less than or equal :value characters.',
|
||||
'array' => 'The :attribute must not have more than :value items.',
|
||||
],
|
||||
'max' => [
|
||||
'numeric' => 'The :attribute must not be greater than :max.',
|
||||
'file' => 'The :attribute must not be greater than :max kilobytes.',
|
||||
'string' => 'The :attribute must not be greater than :max characters.',
|
||||
'array' => 'The :attribute must not have more than :max items.',
|
||||
],
|
||||
'mimes' => 'The :attribute must be a file of type: :values.',
|
||||
'mimetypes' => 'The :attribute must be a file of type: :values.',
|
||||
'min' => [
|
||||
'numeric' => 'The :attribute must be at least :min.',
|
||||
'file' => 'The :attribute must be at least :min kilobytes.',
|
||||
'string' => 'The :attribute must be at least :min characters.',
|
||||
'array' => 'The :attribute must have at least :min items.',
|
||||
],
|
||||
'multiple_of' => 'The :attribute must be a multiple of :value.',
|
||||
'not_in' => 'The selected :attribute is invalid.',
|
||||
'not_regex' => 'The :attribute format is invalid.',
|
||||
'numeric' => 'The :attribute must be a number.',
|
||||
'password' => 'The password is incorrect.',
|
||||
'present' => 'The :attribute field must be present.',
|
||||
'regex' => 'The :attribute format is invalid.',
|
||||
'required' => 'The :attribute field is required.',
|
||||
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||
'required_with' => 'The :attribute field is required when :values is present.',
|
||||
'required_with_all' => 'The :attribute field is required when :values are present.',
|
||||
'required_without' => 'The :attribute field is required when :values is not present.',
|
||||
'required_without_all' => 'The :attribute field is required when none of :values are present.',
|
||||
'prohibited' => 'The :attribute field is prohibited.',
|
||||
'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
|
||||
'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',
|
||||
'same' => 'The :attribute and :other must match.',
|
||||
'size' => [
|
||||
'numeric' => 'The :attribute must be :size.',
|
||||
'file' => 'The :attribute must be :size kilobytes.',
|
||||
'string' => 'The :attribute must be :size characters.',
|
||||
'array' => 'The :attribute must contain :size items.',
|
||||
],
|
||||
'starts_with' => 'The :attribute must start with one of the following: :values.',
|
||||
'string' => 'The :attribute must be a string.',
|
||||
'timezone' => 'The :attribute must be a valid timezone.',
|
||||
'unique' => 'The :attribute has already been taken.',
|
||||
'uploaded' => 'The :attribute failed to upload.',
|
||||
'url' => 'The :attribute must be a valid URL.',
|
||||
'uuid' => 'The :attribute must be a valid UUID.',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => [
|
||||
'attribute-name' => [
|
||||
'rule-name' => 'custom-message',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap our attribute placeholder
|
||||
| with something more reader friendly such as "E-Mail Address" instead
|
||||
| of "email". This simply helps us make our message more expressive.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => [],
|
||||
|
||||
];
|
||||
@@ -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
|
||||
var ctx = document.getElementById("myAreaChart");
|
||||
if (ctx) {
|
||||
var myLineChart = 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
|
||||
var ctx = document.getElementById("myBarChart");
|
||||
if (ctx) {
|
||||
var myLineChart = 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
|
||||
var ctx = document.getElementById("myPieChart");
|
||||
if (ctx){
|
||||
var myPieChart = 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();
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 6.0 KiB |
@@ -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}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
$('#datatablesSimple').DataTable( {
|
||||
|
||||
});
|
||||
|
||||
$('#datatablesSimple2').DataTable( {
|
||||
responsive: true,
|
||||
"pageLength": 50,
|
||||
"aaSorting": []
|
||||
});
|
||||
@@ -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});
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,145 @@
|
||||
/*!
|
||||
* Start Bootstrap - SB Admin v7.0.3 (https://startbootstrap.com/template/sb-admin)
|
||||
* Copyright 2013-2021 Start Bootstrap
|
||||
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-sb-admin/blob/master/LICENSE)
|
||||
*/
|
||||
//
|
||||
// Scripts
|
||||
//
|
||||
|
||||
|
||||
$(function() {
|
||||
let copyButtonTrans = 'Copy'
|
||||
let csvButtonTrans = 'CSV'
|
||||
let excelButtonTrans = 'Excel'
|
||||
let pdfButtonTrans = 'PDF'
|
||||
// let printButtonTrans = '{{ trans('global.datatables.print') }}'
|
||||
let colvisButtonTrans = 'Columns'
|
||||
let selectAllButtonTrans = 'Select All'
|
||||
let selectNoneButtonTrans = 'Deselect All'
|
||||
|
||||
let languages = {
|
||||
'en': 'https://cdn.datatables.net/plug-ins/1.10.19/i18n/English.json'
|
||||
};
|
||||
|
||||
$.extend(true, $.fn.dataTable.Buttons.defaults.dom.button, {
|
||||
className: 'btn'
|
||||
})
|
||||
$.extend(true, $.fn.dataTable.defaults, {
|
||||
language: {
|
||||
url: languages['{{ app()->getLocale() }}']
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
className: 'select-checkbox',
|
||||
targets: 0
|
||||
},
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: -1
|
||||
}
|
||||
],
|
||||
select: {
|
||||
style: 'multi+shift',
|
||||
selector: 'td:first-child'
|
||||
},
|
||||
order: [],
|
||||
scrollX: true,
|
||||
pageLength: 100,
|
||||
dom: "<'row'<'col-sm-12 col-md-2'l><'col-sm-12 col-md-7'B><'col-sm-12 col-md-3'f>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
||||
// dom: '<lBfr>tip<"actions">',
|
||||
buttons: [{
|
||||
extend: 'selectAll',
|
||||
className: 'btn-primary mr-1',
|
||||
text: selectAllButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
},
|
||||
action: function(e, dt) {
|
||||
e.preventDefault()
|
||||
dt.rows().deselect();
|
||||
dt.rows({
|
||||
search: 'applied'
|
||||
}).select();
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'selectNone',
|
||||
className: 'btn-primary mr-1',
|
||||
text: selectNoneButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'copy',
|
||||
className: 'btn-default mr-1',
|
||||
text: copyButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'csv',
|
||||
className: 'btn-default mr-1',
|
||||
text: csvButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
className: 'btn-default mr-1',
|
||||
text: excelButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible',
|
||||
stripHtml: true
|
||||
},
|
||||
customize: function(xlsx,btnObj, tableInst) {
|
||||
var sheet = xlsx.xl.worksheets['sheet1.xml'];
|
||||
var cellIndexes = tableInst.cells(".bg-danger").indexes();
|
||||
for (var i = 0; i < cellIndexes.length; i++) {
|
||||
var cellIndex = cellIndexes[i];
|
||||
var tblRow = cellIndex['row']+3; // adjusted from 0 indexed
|
||||
var tblCol = cellIndex['column']; // adjusted from 0 indexed
|
||||
var xlCol = numberToLetters(tblCol);
|
||||
var excelCell = xlCol+tblRow;
|
||||
$('row c[r='+excelCell+']', sheet).attr( 's', '11' );
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
className: 'btn-default mr-1',
|
||||
text: pdfButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
// {
|
||||
// extend: 'print',
|
||||
// className: 'btn-default',
|
||||
// text: printButtonTrans,
|
||||
// exportOptions: {
|
||||
// columns: ':visible'
|
||||
// }
|
||||
// },
|
||||
{
|
||||
extend: 'colvis',
|
||||
className: 'btn-default mr-1',
|
||||
text: colvisButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$.fn.dataTable.ext.classes.sPageButton = '';
|
||||
});
|
||||
|
||||
// console.log("Scripts");
|
||||
@@ -0,0 +1,197 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"servers": [
|
||||
{
|
||||
"description": "M3 Sentinel Json Receiver",
|
||||
"url": "http://esn2:10014"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"description": "Sentinel Receiver",
|
||||
"version": "1.0.0",
|
||||
"title": "Sentinel API",
|
||||
"contact": {
|
||||
"email": "you@your-company.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "M3 API",
|
||||
"description": "Receive Json from Mulesoft"
|
||||
}
|
||||
],
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"basicAuth": {
|
||||
"type": "http",
|
||||
"scheme": "basic"
|
||||
}
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/api/m3receiver": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"General"
|
||||
],
|
||||
"summary": "M3 Laravel API",
|
||||
"description": "M3 POC listener",
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"example": {
|
||||
|
||||
"Recipient": {
|
||||
"BillToId": "IC7401",
|
||||
"ShipToId": "IC7401",
|
||||
"PersonName": "Mary Berry",
|
||||
"CompanyName": "IC7401",
|
||||
"Country": "SG",
|
||||
"CountryName": "United Kingdom",
|
||||
"State": "ST",
|
||||
"City": "SINGAPORE",
|
||||
"PostalCode": "608830",
|
||||
"Address1": "5A Toh Guan Road East",
|
||||
"Address2": "/#04-01",
|
||||
"Address3": "SINGAPORE 608830",
|
||||
"Address4": "SINGAPORE",
|
||||
"AccountNo": "0212520",
|
||||
"Email": "KRISTIN@ELIT.NO"
|
||||
},
|
||||
"Contents": {
|
||||
"Commodities": [
|
||||
{
|
||||
"Quantity": 40,
|
||||
"PartWeight": 200,
|
||||
"Description": "BRAID MBJ 6-150-6",
|
||||
"PartNumber": "556600",
|
||||
"UOM": "EA",
|
||||
"SellUOM": "EA",
|
||||
"PartConv": 1.000000000,
|
||||
"BaseUnitPrice": 1,
|
||||
"OrderLine": 1,
|
||||
"ShipmentPOLine": 1,
|
||||
"PrimaryLocation": "AD21A13",
|
||||
"LocationSeq": "042620",
|
||||
"LocationType": "PR",
|
||||
"Zone": "A",
|
||||
"HazMat": "H4.1",
|
||||
"PartUPC": "782856449713",
|
||||
"PartEAN": "3479775566009",
|
||||
"ProdType": "EFX",
|
||||
"LotFlag": "Y",
|
||||
"LotNumber": "121333",
|
||||
"ManOrd": "22222",
|
||||
"FreightClass": "50",
|
||||
"PallSize": "60",
|
||||
"MasterCarton": "EBV-240381",
|
||||
"MasterQty": 12,
|
||||
"InnerQty": 1,
|
||||
"PalletQty": 1,
|
||||
"CartonQty": 14
|
||||
}
|
||||
,
|
||||
{
|
||||
"Quantity": 500,
|
||||
"PartWeight": 500,
|
||||
"Description": "ISO TP 15M4",
|
||||
"PartNumber": "548400",
|
||||
"UOM": "EA",
|
||||
"SellUOM": "EA",
|
||||
"PartConv": 1.000000000,
|
||||
"BaseUnitPrice": 1,
|
||||
"OrderLine": 2,
|
||||
"ShipmentPOLine": 1,
|
||||
"PrimaryLocation": "AE40Q26",
|
||||
"LocationSeq": "054130",
|
||||
"LocationType": "PR",
|
||||
"Zone": "A",
|
||||
"HazMat": "H4.1",
|
||||
"PartUPC": "782856875413",
|
||||
"PartEAN": "3479775484006",
|
||||
"ProdType": "EFX",
|
||||
"LotFlag": "Y",
|
||||
"LotNumber": "121333",
|
||||
"ManOrd": "22222",
|
||||
"FreightClass": "50",
|
||||
"PallSize": "60",
|
||||
"MasterCarton": "EBV-240381",
|
||||
"MasterQty": 12,
|
||||
"InnerQty": 1,
|
||||
"PalletQty": 1,
|
||||
"CartonQty": 14
|
||||
}
|
||||
]
|
||||
},
|
||||
"Warehouse": "A02",
|
||||
"PickerNumber": "00000087126",
|
||||
"Company": "001",
|
||||
"Plant": "11",
|
||||
"OrderNumber": "3140001799",
|
||||
"ShipmentNumber": "001",
|
||||
"ShipmentPONumber": "100497",
|
||||
"PromDate": 20220914,
|
||||
"Currency": "EUR",
|
||||
"ExchangeRate": 1.134,
|
||||
"RouteCode": "111009",
|
||||
"ShipTerms": "FCA",
|
||||
"OrderClass": "CIC",
|
||||
"CarrierCode": "BWAY",
|
||||
"ShipVia": "004"
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"basicAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"in": "header",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"example": "application/json"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"headers": {
|
||||
"Content-Type": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"example": "text/plain"
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"text/plain": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"example": {
|
||||
"code": "200",
|
||||
"status": "success",
|
||||
"message": "File Received, DB Updated"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
openapi: 3.0.0
|
||||
servers:
|
||||
- description: M3 Sentinel Json Receiver
|
||||
url: http://esn2:10014
|
||||
info:
|
||||
description: Sentinel Receiver
|
||||
version: 1.0.0
|
||||
title: Sentinel API
|
||||
contact:
|
||||
email: you@your-company.com
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
tags:
|
||||
- name: M3 API
|
||||
description: Receive Json from Mulesoft
|
||||
components:
|
||||
securitySchemes:
|
||||
basicAuth:
|
||||
type: http
|
||||
scheme: basic
|
||||
paths:
|
||||
/api/m3receiver:
|
||||
post:
|
||||
tags:
|
||||
- General
|
||||
summary: M3 Laravel API
|
||||
description: M3 POC listener
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
example:
|
||||
Recipient:
|
||||
BillToId: C09586
|
||||
ShipToId: C09587
|
||||
PersonName: Mary Berry
|
||||
CompanyName: ELIT AS
|
||||
Country: UK
|
||||
CountryName: United Kingdom
|
||||
State: ''
|
||||
City: GJERDRUM N
|
||||
PostalCode: '2022'
|
||||
Address1: HELLENVEGEN 9
|
||||
Address2: ''
|
||||
Address3: ''
|
||||
Address4: ''
|
||||
AccountNo: '0212520'
|
||||
Email: KRISTIN@ELIT.NO
|
||||
Contents:
|
||||
Commodities:
|
||||
- Quantity: 1
|
||||
PartWeight: 102.552
|
||||
Description: Electrical and Fastening Products
|
||||
PartNumber: C1586230
|
||||
UOM: EA
|
||||
SellUOM: EA
|
||||
PartConv: '1'
|
||||
BaseUnitPrice: 1
|
||||
FrgnUnitPrice: 1.134
|
||||
OrderLine: 1
|
||||
ShipmentPOLine: 1
|
||||
PrimaryLocation: 1A69580
|
||||
LocationSeq: B003550
|
||||
LocationType: PRIMARY
|
||||
Zone: A
|
||||
HazMat: H4.1
|
||||
PartUPC: '78285637301'
|
||||
PartEAN: '3479775637204'
|
||||
ProdType: FE
|
||||
LotFlag: 'N'
|
||||
LotNumber: ''
|
||||
ManOrd: ''
|
||||
FreightClass: '50'
|
||||
PallSize: 60
|
||||
MasterCarton: EBV-240381
|
||||
MasterQty: 12
|
||||
InnerQty: 1
|
||||
PalletQty: 14400
|
||||
CartonQty: 14
|
||||
- Quantity: 50
|
||||
PartWeight: 6.21
|
||||
Description: HANGER,CONDUIT,FLEXIBLE
|
||||
PartNumber: KX
|
||||
UOM: BG
|
||||
SellUOM: EA
|
||||
PartConv: '1000'
|
||||
BaseUnitPrice: 15.015
|
||||
FrgnUnitPrice: 19.73
|
||||
OrderLine: 2
|
||||
ShipmentPOLine: 4
|
||||
PrimaryLocation: 1F12L01
|
||||
LocationSeq: A003280
|
||||
LocationType: PRIMARY
|
||||
Zone: A
|
||||
HazMat: H4
|
||||
PartUPC: '78285600156'
|
||||
PartEAN: ''
|
||||
ProdType: FEP
|
||||
LotFlag: A
|
||||
LotNumber: '450012584451'
|
||||
ManOrd: C458987
|
||||
FreightClass: '50'
|
||||
PallSize: 60
|
||||
MasterCarton: EBV-240381
|
||||
MasterQty: 12
|
||||
InnerQty: 1
|
||||
PalletQty: 14400
|
||||
CartonQty: 150
|
||||
- Quantity: 50
|
||||
PartWeight: 6.21
|
||||
Description: HANGER,CONDUIT,FLEXIBLE
|
||||
PartNumber: KX
|
||||
UOM: BG
|
||||
SellUOM: EA
|
||||
PartConv: '1000'
|
||||
BaseUnitPrice: 15.015
|
||||
FrgnUnitPrice: 19.73
|
||||
OrderLine: 2
|
||||
ShipmentPOLine: 4
|
||||
PrimaryLocation: 1F12L01
|
||||
LocationSeq: A003280
|
||||
LocationType: PRIMARY
|
||||
Zone: A
|
||||
HazMat: H4
|
||||
PartUPC: '78285600156'
|
||||
PartEAN: ''
|
||||
ProdType: FEP
|
||||
LotFlag: A
|
||||
LotNumber: '450012584451'
|
||||
ManOrd: C458987
|
||||
FreightClass: '50'
|
||||
PallSize: 60
|
||||
MasterCarton: EBV-240381
|
||||
MasterQty: 12
|
||||
InnerQty: 1
|
||||
PalletQty: 14400
|
||||
CartonQty: 150
|
||||
Company: '11'
|
||||
Plant: '11'
|
||||
Warehouse: '111'
|
||||
OrderNumber: '79758'
|
||||
ReleaseNumber: '05'
|
||||
ShipmentNumber: '001'
|
||||
PickerNumber: '1454221245'
|
||||
ShipmentPONumber: '100497'
|
||||
PromDate: 20221001
|
||||
Currency: EUR
|
||||
ExchangeRate: 1.134
|
||||
RouteCode: '00'
|
||||
ShipTerms: FC
|
||||
FOBCode: SP
|
||||
OrderClass: '001'
|
||||
CarrierCode: BWAY
|
||||
ShipVia: AIR
|
||||
security:
|
||||
- basicAuth: []
|
||||
parameters:
|
||||
- name: Content-Type
|
||||
in: header
|
||||
schema:
|
||||
type: string
|
||||
example: application/json
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
headers:
|
||||
Content-Type:
|
||||
schema:
|
||||
type: string
|
||||
example: text/plain
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
example: File Received, DB Updated
|
||||
@@ -0,0 +1,168 @@
|
||||
@php
|
||||
# Get Current USER
|
||||
$loggedUser = strtoUpper(m3_user());
|
||||
|
||||
$admin_users = $power_users = $csr = $execUser = "";
|
||||
$UserCO = $UserWHS = $UserPL = '';
|
||||
$WDWNAM = '';
|
||||
$IC670MAllWHS = collect();
|
||||
$m3Connection = config('m3.connection', 'pgsql');
|
||||
$getUsers = [];
|
||||
if (\Illuminate\Support\Facades\Schema::connection($m3Connection)->hasTable('icm428m')) {
|
||||
$getUsers = DB::connection($m3Connection)
|
||||
->table('icm428m')
|
||||
->select('R428US', 'R428ADMUSR', 'R428PWRUSR', 'R428CO', 'R428PL', 'R428WH', 'R42811A', 'R42821A')
|
||||
->where('R428US', $loggedUser)
|
||||
->get();
|
||||
}
|
||||
|
||||
foreach ($getUsers as $key=>$user) {
|
||||
if(trim($user->R428ADMUSR)=="Y") {
|
||||
# Different logic from Qinclude version : this not an Array
|
||||
$admin_users=trim($user->R428ADMUSR);
|
||||
}
|
||||
if(trim($user->R428PWRUSR)=="Y") {
|
||||
# Different logic from Qinclude version : this not an Array
|
||||
$power_users=trim($user->R428PWRUSR);
|
||||
}
|
||||
if(trim($user->R42811A)=="C") {
|
||||
$csr="Y";
|
||||
}
|
||||
if(trim($user->R42821A)=="Y") {
|
||||
$execUser="Y";
|
||||
}
|
||||
$UserCO = $user->R428CO;
|
||||
$UserWHS = $user->R428WH;
|
||||
$UserPL = $user->R428PL;
|
||||
}
|
||||
|
||||
# Get current WHS
|
||||
if ($UserCO !== '' && $UserPL !== '' && $UserWHS !== '' && \Illuminate\Support\Facades\Schema::connection($m3Connection)->hasTable('ic670m')) {
|
||||
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')
|
||||
->select('WDWNAM')
|
||||
->where('WDCO', $UserCO)
|
||||
->where('WDPL', $UserPL)
|
||||
->where('WDWHS', $UserWHS)
|
||||
->first();
|
||||
$WDWNAM = isset($IC670M->WDWNAM) ? trim($IC670M->WDWNAM) : '';
|
||||
$IC670MAllWHS = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
}
|
||||
|
||||
# Get the current route information
|
||||
$route = app('request')->route();
|
||||
// dump($route);
|
||||
$pdfURL = str_ends_with($route?->uri() ?? '', 'M3GetPDFFromCache');
|
||||
// dump("CSR:".$csr .' SDA:'.$pdfURL);
|
||||
|
||||
$callingProgramPacking = app('request')->request->get('callingProgram')=='Packing' ? true : false;
|
||||
// dump($callingProgramPacking);
|
||||
@endphp
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<meta name="description" content="" />
|
||||
<meta name="author" content="" />
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}" />
|
||||
<title>@yield('title')</title>
|
||||
@include('m3::liberty-theme.partials.styles')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body class="sb-nav-fixed">
|
||||
@include('m3::liberty-theme.partials.top-navigation')
|
||||
<div id="layoutSidenav">
|
||||
@if ( !($pdfURL && $callingProgramPacking))
|
||||
@include('m3::liberty-theme.partials.left-navigation')
|
||||
@endif
|
||||
|
||||
<div id="layoutSidenav_content">
|
||||
<main>
|
||||
<div id="page-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
@yield('breadcrumb')
|
||||
</div>
|
||||
<div class="page-btn">
|
||||
@yield('btn')
|
||||
</div>
|
||||
<!-- /.col-lg-12 -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
@if( $csr=='')
|
||||
@yield('content')
|
||||
@elseif( $csr=='Y' && $pdfURL)
|
||||
@yield('content')
|
||||
@else
|
||||
{!! '<h1 class="text-center">403 - Unauthorized</h1>' !!}
|
||||
@endif
|
||||
<!-- /.container-fluid -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /#page-wrapper -->
|
||||
</main>
|
||||
<footer class="py-4 bg-light mt-auto">
|
||||
@include('m3::liberty-theme.partials.footer')
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
@include('m3::liberty-theme.partials.scripts')
|
||||
@yield('scripts')
|
||||
</body>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#R428DPWSel").on('change', function() {
|
||||
var R428DPW = $(this).val();
|
||||
var R428US = '{{ $loggedUser }}';
|
||||
var currentWHS = $(this).find('option:selected').text();
|
||||
// console.log(R428DPW);
|
||||
// console.log(R428US);
|
||||
|
||||
var form_post2 = {
|
||||
R428DPW : R428DPW,
|
||||
R428US : R428US,
|
||||
_token : '{{ csrf_token() }}'
|
||||
};
|
||||
// console.log(form_post2);
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('m3.userprofileupdateajax') }}",
|
||||
type: "POST",
|
||||
data: form_post2,
|
||||
success: function(response) {
|
||||
if(response.success==true){
|
||||
Swal.fire({
|
||||
title: "Warehouse changed successfully",
|
||||
text: "",
|
||||
icon: "success",
|
||||
confirmButtonColor: "#3085d6"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
// Swal.fire('Warehouse changed successfully');
|
||||
// $("#currentWHSPAN").html(currentWHS);
|
||||
}
|
||||
else{
|
||||
Swal.fire('Warehouse change Failed');
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
// console.log(error);
|
||||
// alert(error);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,67 @@
|
||||
@extends('m3::liberty-theme.layout.main')
|
||||
@section('title')
|
||||
Solon Sentinel Portal - Scan Boxes To Pallet
|
||||
@endsection
|
||||
@section('content')
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">Scan Boxes To Pallet</h1>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<form id="palletForm" method="GET" action="{{ route('m3.BoxPackToPallet.getboxes') }}">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<label for="R659PALT" class="col-form-label text-nowrap">Scan Pallet</label>
|
||||
<input type="text"
|
||||
id="R659PALT"
|
||||
class="form-control"
|
||||
name="R659PALT"
|
||||
placeholder="S000000000000"
|
||||
maxlength="12"
|
||||
value=""
|
||||
style="max-width: 220px;">
|
||||
<div id="palletError" class="text-danger small" style="display:none;"></div>
|
||||
<button type="submit" class="btn btn-primary text-nowrap">Scan Pallet</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#palletForm').on('submit', function (e) {
|
||||
const val = $('#R659PALT').val().trim();
|
||||
const $error = $('#palletError');
|
||||
|
||||
if (!val.startsWith('S')) {
|
||||
e.preventDefault();
|
||||
$error.text('Pallet must start with "S".').show();
|
||||
$('#R659PALT').addClass('is-invalid');
|
||||
return;
|
||||
}
|
||||
|
||||
if (val.length > 12) {
|
||||
e.preventDefault();
|
||||
$error.text('Pallet must be 12 characters max.').show();
|
||||
$('#R659PALT').addClass('is-invalid');
|
||||
return;
|
||||
}
|
||||
|
||||
$error.hide();
|
||||
$('#R659PALT').removeClass('is-invalid');
|
||||
});
|
||||
|
||||
// Clear error on input
|
||||
$('#R659PALT').on('input', function () {
|
||||
$('#palletError').hide();
|
||||
$(this).removeClass('is-invalid');
|
||||
});
|
||||
|
||||
$('#R659PALT').on('change', function () {
|
||||
$('#palletForm').submit();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -0,0 +1,330 @@
|
||||
@extends('m3::liberty-theme.layout.main')
|
||||
|
||||
@section('title')
|
||||
Solon Sentinel Portal - Load Boxes on Pallets
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid px-4">
|
||||
<h4 class="mt-4">Load Boxes on Pallets</h4>
|
||||
|
||||
<div class="row mb-2">
|
||||
{{-- ── Pallet Header Card ─────────────────────────────── --}}
|
||||
<div class="col-6">
|
||||
<div class="card mb-3 border-primary h-100">
|
||||
<div class="card-header bg-primary text-white fw-bold d-flex justify-content-between align-items-center">
|
||||
<span>Pallet Information</span>
|
||||
<span><a class="btn btn-info" href="{{ route('m3.BoxPackToPallet') }}">Next Pallet</a></span>
|
||||
</div>
|
||||
<div class="card-body py-2">
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="col-auto">
|
||||
<span class="text-muted small">Pallet #</span>
|
||||
<span id="hdr-pallet" class="fs-5 fw-bold ms-1">{{ $R659PALT }}</span>
|
||||
</div>
|
||||
<div class="col-auto border-start ps-3">
|
||||
<span class="text-muted small">User</span>
|
||||
<span id="hdr-user" class="ms-1">
|
||||
{{ $palletHeader->R659USER ?? (m3_user() !== '' ? Str::upper(m3_user()) : '—') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-auto border-start ps-3">
|
||||
<span class="text-muted small">Date</span>
|
||||
<span id="hdr-date" class="ms-1">
|
||||
{{ $palletHeader ? $palletHeader->R659DATE : '—' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-auto border-start ps-3">
|
||||
<span class="text-muted small">Time</span>
|
||||
<span id="hdr-time" class="ms-1">
|
||||
{{ $palletHeader ? $palletHeader->R659TIME : '—' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- ── Scan Input Card ────────────────────────────────── --}}
|
||||
<div class="col-6">
|
||||
<div class="card mb-4 border-secondary h-100">
|
||||
<div class="card-header fw-semibold d-flex justify-content-between align-items-center">
|
||||
<span>Scan Box Barcode</span>
|
||||
{{-- <span id="scan-alert" class="badge bg-danger d-none">Danger</span> --}}
|
||||
</div>
|
||||
<div class="card-body py-2">
|
||||
<div class="d-flex align-items-center gap-2 flex-wrap">
|
||||
<div>
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">Box #</div>
|
||||
<input type="text" id="scan-input" class="form-control" maxlength="12"
|
||||
placeholder="Scan or type box #" autocomplete="off" autofocus style="width: 180px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-auto">
|
||||
<button id="btn-scan" class="btn btn-success">
|
||||
<i class="fas fa-barcode me-1"></i> Add Box
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- <div id="scan-alert" class="d-none align-self-center"></div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- ── Boxes DataTable Card ────────────────────────────── --}}
|
||||
<div class="card mb-4">
|
||||
<div class="card-header fw-semibold d-flex justify-content-between align-items-center">
|
||||
<span>Boxes on Pallet</span>
|
||||
<span id="box-count" class="badge bg-secondary">0 boxes</span>
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
<div class="table-responsive">
|
||||
<table id="boxes-table" class="table table-striped table-hover mb-0 w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Box #</th>
|
||||
<th>Carrier</th>
|
||||
<th>Conveyor</th>
|
||||
<th>Country</th>
|
||||
<th>Status</th>
|
||||
<th>User</th>
|
||||
<th>Date</th>
|
||||
<th>Time</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
const PALT = '{{ $R659PALT ?? '' }}';
|
||||
const GET_URL = '{{ route('m3.BoxPackToPallet.getboxes') }}';
|
||||
const SCAN_URL = '{{ route('m3.BoxPackToPallet.scanboxes') }}';
|
||||
const DEL_URL = '{{ route('m3.BoxPackToPallet.deletebox') }}';
|
||||
|
||||
// Seed from PHP on first load — avoids a redundant AJAX call on page load
|
||||
const initialData = @json($boxes ?? []);
|
||||
|
||||
// ── DataTable init ────────────────────────────────────────
|
||||
const dt = $('#boxes-table').DataTable({
|
||||
data: initialData,
|
||||
columns: [{
|
||||
data: 'R659BOX'
|
||||
},
|
||||
{
|
||||
data: 'AYSPR15A01',
|
||||
defaultContent: '—'
|
||||
},
|
||||
{
|
||||
data: 'CONVEYOR_NAME',
|
||||
defaultContent: '—'
|
||||
},
|
||||
{
|
||||
data: 'A4SHSHCT',
|
||||
defaultContent: '—'
|
||||
},
|
||||
{
|
||||
data: 'R659LOADED',
|
||||
render: val => (val ?? '').toString().trim() ?
|
||||
'<span class="badge bg-success">Loaded</span>' :
|
||||
'<span class="badge bg-warning text-dark">Pending</span>'
|
||||
},
|
||||
{
|
||||
data: 'R659USER'
|
||||
},
|
||||
{
|
||||
data: 'R659DATE',
|
||||
render: val => val
|
||||
},
|
||||
{
|
||||
data: 'R659TIME',
|
||||
render: val => val
|
||||
},
|
||||
{
|
||||
data: null,
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center',
|
||||
render: row => {
|
||||
const loaded = (row.R659LOADED ?? '').toString().trim();
|
||||
if (loaded) return '—';
|
||||
return `<button class="btn btn-danger btn-sm btn-delete"
|
||||
data-box="${row.R659BOX}">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>`;
|
||||
}
|
||||
},
|
||||
],
|
||||
order: [],
|
||||
pageLength: 25,
|
||||
responsive: true,
|
||||
select: false,
|
||||
buttons: false,
|
||||
dom: "<'row mt-2'<'col-sm-12 col-md-2'l><'col-sm-12 col-md-3'f>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row mt-2'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
||||
// Override columnDefs to remove the checkbox class
|
||||
columnDefs: [{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: -1
|
||||
}]
|
||||
});
|
||||
|
||||
// Update count badge on init
|
||||
updateCount();
|
||||
|
||||
// ── Refresh table via AJAX (after scan or delete) ─────────
|
||||
function reloadBoxes() {
|
||||
$.get(GET_URL, {
|
||||
R659PALT: PALT
|
||||
}, function(res) {
|
||||
if (res.success) {
|
||||
dt.clear().rows.add(res.data).draw();
|
||||
updateCount();
|
||||
}
|
||||
}).fail(function() {
|
||||
showAlert('danger', 'Failed to refresh boxes.');
|
||||
});
|
||||
}
|
||||
|
||||
// ── Scan / Add box ────────────────────────────────────────
|
||||
function doScan() {
|
||||
const box = $('#scan-input').val().trim().toUpperCase();
|
||||
if (!box) return;
|
||||
|
||||
$('#btn-scan').prop('disabled', true).html(
|
||||
'<span class="spinner-border spinner-border-sm"></span>');
|
||||
|
||||
$.post(SCAN_URL, {
|
||||
R659PALT: PALT,
|
||||
R659BOX: box,
|
||||
_token: '{{ csrf_token() }}'
|
||||
})
|
||||
.done(function(res) {
|
||||
showAlert('success', res.message);
|
||||
dt.clear().rows.add(res.data).draw();
|
||||
updateCount();
|
||||
$('#scan-input').val('').focus();
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
showAlert('danger', xhr.responseJSON?.message ?? 'Scan failed.');
|
||||
$('#scan-input').select().focus();
|
||||
})
|
||||
.always(function() {
|
||||
$('#btn-scan').prop('disabled', false).html(
|
||||
'<i class="fas fa-barcode me-1"></i> Add Box');
|
||||
});
|
||||
}
|
||||
|
||||
$('#btn-scan').on('click', doScan);
|
||||
$('#scan-input').on('change', function(e) {
|
||||
// if (e.key === 'Enter') doScan();
|
||||
doScan();
|
||||
});
|
||||
|
||||
// ── Delete box ────────────────────────────────────────────
|
||||
$('#boxes-table').on('click', '.btn-delete', function() {
|
||||
const box = $(this).data('box');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Remove Box?',
|
||||
text: `Remove box ${box} from pallet ${PALT}?`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, remove it',
|
||||
}).then(result => {
|
||||
if (!result.isConfirmed) return;
|
||||
|
||||
$.post(DEL_URL, {
|
||||
R659PALT: PALT,
|
||||
R659BOX: box,
|
||||
_token: '{{ csrf_token() }}'
|
||||
})
|
||||
.done(function(res) {
|
||||
showAlert('success', res.message);
|
||||
dt.clear().rows.add(res.data).draw();
|
||||
updateCount();
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
showAlert('danger', xhr.responseJSON?.message ?? 'Delete failed.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────
|
||||
function updateCount() {
|
||||
const n = dt.data().length;
|
||||
$('#box-count').text(n + ' box' + (n !== 1 ? 'es' : ''));
|
||||
}
|
||||
|
||||
function playDing() {
|
||||
const ctx = new AudioContext();
|
||||
const oscillator = ctx.createOscillator();
|
||||
const gainNode = ctx.createGain();
|
||||
|
||||
oscillator.connect(gainNode);
|
||||
gainNode.connect(ctx.destination);
|
||||
|
||||
oscillator.type = 'sine';
|
||||
oscillator.frequency.setValueAtTime(880, ctx.currentTime); // A5 note
|
||||
|
||||
// Fade out for a natural "ding" decay
|
||||
gainNode.gain.setValueAtTime(1, ctx.currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 1.5);
|
||||
|
||||
oscillator.start(ctx.currentTime);
|
||||
oscillator.stop(ctx.currentTime + 1.5);
|
||||
}
|
||||
|
||||
function showAlert(type, msg) {
|
||||
let iconType;
|
||||
|
||||
// Map your badge types to SweetAlert icons
|
||||
if (type === 'success') iconType = 'success';
|
||||
else if (type === 'danger') iconType = 'error';
|
||||
else if (type === 'warning') iconType = 'warning';
|
||||
else iconType = 'info';
|
||||
|
||||
if (type === 'danger' || type === 'warning') {
|
||||
playDing();
|
||||
|
||||
Swal.fire({
|
||||
icon: iconType,
|
||||
title: msg,
|
||||
showConfirmButton: true,
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) $('#scan-input').select().focus();
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
toast: true,
|
||||
position: 'bottom-end',
|
||||
icon: iconType,
|
||||
title: msg,
|
||||
showConfirmButton: false,
|
||||
timer: 3000,
|
||||
timerProgressBar: true
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.body.classList.toggle('sb-sidenav-toggled');
|
||||
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -0,0 +1,282 @@
|
||||
@extends('m3::liberty-theme.layout.main')
|
||||
@section('title')
|
||||
Solon Sentinel Portal - M3 Delivery Methods
|
||||
@endsection
|
||||
@section('content')
|
||||
<!-- /.row -->
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">M3 Delivery Methods Maintenance</h1>
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
@if($power_user->R428PWRUSR=="Y")
|
||||
<button name="M3DeliveryAdd" type="button" class="btn btn-sm btn-info M3DeliveryAdd_click" id="M3DeliveryAdd_click"
|
||||
data-AT9DPW="{{$power_user->R428CO.$power_user->R428PL.$power_user->R428WH}}">Add Record</button>
|
||||
@endif
|
||||
<!-- data-AT9DPW="$co.$plant.$whs">Add Record</button> -->
|
||||
</div>
|
||||
{{-- // AVCO AVCO CHARACTER 3 No ' ' Division
|
||||
// AVWHS AVWHS CHARACTER 3 No ' ' Warehouse
|
||||
// AVPLANT AVPLANT CHARACTER 3 No ' ' Plant
|
||||
// AVDELMETH AVDELMETH CHARACTER 4 No ' ' Delivery method
|
||||
// AVSHPVIA AVSHPVIA CHARACTER 4 No ' ' Sentinel ship via
|
||||
// AVSHSRT AVSHSRT CHARACTER 6 No ' ' Sentinel route
|
||||
// AVSHORCL AVSHORCL CHARACTER 3 No ' ' Sentinel intl code --}}
|
||||
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover" id="datatablesSimple5" style="width:80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<!-- <th align="center">Co-Plt-Whs</th> -->
|
||||
<th align="center">Delivery method</th>
|
||||
<th align="center">Ship Via</th>
|
||||
<th align="center">Route</th>
|
||||
<th align="center">Intl code</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- if($no_data=="Y")
|
||||
<tr> <td colspan=10 style="text-align:center; background-color:yellow"> <b>No data retrieved for this user</b> <td> <tr>
|
||||
else -->
|
||||
@foreach($ICM664M as $key=>$val)
|
||||
<tr>
|
||||
<td></td>
|
||||
<td align="center">
|
||||
@if($power_user->R428PWRUSR=="Y")
|
||||
<button name="M3DeliveryEdit{{trim($val->AVDELMETH)}}" type="submit" class="btn btn-sm btn-info M3DeliveryEdit_click" id="M3DeliveryEdit_click"
|
||||
data-AVDELMETH="{{$val->AVDELMETH}}" data-AVSHPVIA="{{trim($val->AVSHPVIA)}}" data-AVSHSRT="{{trim($val->AVSHSRT)}}"
|
||||
data-AVSHORCL="{{trim($val->AVSHORCL)}}"
|
||||
>Edit</button>
|
||||
@endif
|
||||
</td>
|
||||
<td align="center"> {{ $val->AVDELMETH }} </td>
|
||||
<td align="center"> {{ $val->AVSHPVIA }} </td>
|
||||
<td align="center"> {{ $val->AVSHSRT }} </td>
|
||||
<td align="center"> {{ $val->AVSHORCL }} </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<!-- endif-->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
<!-- @include('m3::liberty-theme.partials.modals.blank') -->
|
||||
@include('m3::liberty-theme.partials.modals.M3DeliveryAdd')
|
||||
@include('m3::liberty-theme.partials.modals.M3DeliveryEdit')
|
||||
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// DataTable init
|
||||
var myTable = $('#datatablesSimple5').DataTable({
|
||||
"aaSorting": [],
|
||||
"lengthMenu": [ [15,35,50,-1], [15,35,50,"All"] ],
|
||||
"sPaginationType": "full_numbers",
|
||||
"dom": 'Bfrtip', // Needs button container
|
||||
"responsive": true,
|
||||
"orderCellsTop": true,
|
||||
"order": [ [2, 'asc'] ],
|
||||
"pageLength": 15,
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
targets: -1
|
||||
}
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
//
|
||||
// Open Modal M3Delivery Edit
|
||||
//
|
||||
// AVCO AVCO CHARACTER 3 No ' ' Division
|
||||
// AVWHS AVWHS CHARACTER 3 No ' ' Warehouse
|
||||
// AVPLANT AVPLANT CHARACTER 3 No ' ' Plant
|
||||
// AVDELMETH AVDELMETH CHARACTER 4 No ' ' Delivery method
|
||||
// AVSHPVIA AVSHPVIA CHARACTER 4 No ' ' Sentinel ship via
|
||||
// AVSHSRT AVSHSRT CHARACTER 6 No ' ' Sentinel route
|
||||
// AVSHORCL AVSHORCL CHARACTER 3 No ' ' Sentinel intl code
|
||||
|
||||
$(document).on('click', '#M3DeliveryEdit_click', function() {
|
||||
// console.log($(this));
|
||||
$("#AVDELMETH").val($(this).data("avdelmeth"));
|
||||
$("#AVSHPVIA").val($(this).data("avshpvia"));
|
||||
$("#AVSHSRT").val($(this).data("avshsrt"));
|
||||
$("#AVSHORCL").val($(this).data("avshorcl"));
|
||||
|
||||
$("#OLD_AVDELMETH").val($(this).data("avdelmeth"));
|
||||
$("#OLD_AVSHPVIA").val($(this).data("avshpvia"));
|
||||
$("#OLD_AVSHSRT").val($(this).data("avshsrt"));
|
||||
$("#OLD_AVSHORCL").val($(this).data("avshorcl"));
|
||||
|
||||
$('#M3DeliveryEdit').modal('show');
|
||||
});
|
||||
|
||||
//
|
||||
// Open Modal M3Delivery Add
|
||||
//
|
||||
$(document).on('click', '#M3DeliveryAdd_click', function() {
|
||||
// console.log($(this));
|
||||
$('#M3DeliveryAdd').modal('show');
|
||||
});
|
||||
|
||||
|
||||
// Clear values on Edit form when Close is clicked
|
||||
$(document).on('click', '#closeEdit', function() {
|
||||
document.getElementById("frmEdit").reset();
|
||||
});
|
||||
|
||||
// Clear values on Add form when Close is clicked
|
||||
$(document).on('click', '#closeAdd', function() {
|
||||
document.getElementById("frmAdd").reset();
|
||||
});
|
||||
|
||||
//
|
||||
// Save M3Delivery Edit
|
||||
//
|
||||
$(document).on('click', '#submitM3DeliveryEdit', function() {
|
||||
|
||||
var changes_detected = 0;
|
||||
var errors_found = 0;
|
||||
|
||||
// Retrieve the values we need to pass on
|
||||
var NEW_AVDELMETH = $("#AVDELMETH").val();
|
||||
var NEW_AVSHPVIA = $("#AVSHPVIA").val();
|
||||
var NEW_AVSHSRT = $("#AVSHSRT").val();
|
||||
var NEW_AVSHORCL = $("#AVSHORCL").val();
|
||||
var NEW_AVCO = $("#AVCO").val();
|
||||
var NEW_AVPLANT = $("#AVPLANT").val();
|
||||
var NEW_AVWHS = $("#AVWHS").val();
|
||||
|
||||
// Retrieve old values
|
||||
var OLD_AVDELMETH = $("#OLD_AVDELMETH").val();
|
||||
var OLD_AVSHPVIA = $("#OLD_AVSHPVIA").val();
|
||||
var OLD_AVSHSRT = $("#OLD_AVSHSRT").val();
|
||||
var OLD_AVSHORCL = $("#OLD_AVSHORCL").val();
|
||||
|
||||
if(NEW_AVSHPVIA!=OLD_AVSHPVIA || NEW_AVSHSRT!=OLD_AVSHSRT || NEW_AVSHORCL!=OLD_AVSHORCL) {
|
||||
changes_detected = 1;
|
||||
}
|
||||
if (changes_detected==0) {
|
||||
$('#M3DeliveryEdit').modal('show');
|
||||
alert("No changes have been detected. Please try again");
|
||||
} else {
|
||||
|
||||
if(errors_found==0) {
|
||||
|
||||
var csrf = document.querySelector('meta[name="csrf-token"]').content;
|
||||
var form_post = {
|
||||
'AVDELMETH': NEW_AVDELMETH,
|
||||
'AVSHPVIA': NEW_AVSHPVIA,
|
||||
'AVSHSRT': NEW_AVSHSRT,
|
||||
'AVSHORCL': NEW_AVSHORCL,
|
||||
'AVCO': NEW_AVCO,
|
||||
'AVPLANT': NEW_AVPLANT,
|
||||
'AVWHS': NEW_AVWHS,
|
||||
'_token': csrf
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url:'/M3Delivery/saveM3DeliveryEdit',
|
||||
data: form_post,
|
||||
success:function(data) {
|
||||
if (data=="success") {
|
||||
//$('#blank-modal').modal('hide');
|
||||
$('#M3DeliveryEdit').modal('hide');
|
||||
// alert("should reload here");
|
||||
location.reload();
|
||||
} else {
|
||||
$("#AVDELMETH").val(NEW_AVDELMETH);
|
||||
$("#AVSHPVIA").val(NEW_AVSHPVIA);
|
||||
$("#AVSHSRT").val(NEW_AVSHSRT);
|
||||
$("#AVSHORCL").val(NEW_AVSHORCL);
|
||||
$("#AVCO").val(NEW_AVCO);
|
||||
$("#AVPLANT").val(NEW_AVPLANT);
|
||||
$("#AVWHS").val(NEW_AVWHS);
|
||||
$("#OLD_AVDELMETH").val(OLD_AVDELMETH);
|
||||
$("#OLD_AVSHPVIA").val(OLD_AVSHPVIA);
|
||||
$("#OLD_AVSHSRT").val(OLD_AVSHSRT);
|
||||
$("#OLD_AVSHORCL").val(OLD_AVSHORCL);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Save M3Delivery Add
|
||||
//
|
||||
$(document).on('click', '#submitM3DeliveryAdd', function() {
|
||||
|
||||
var errors_found = 0;
|
||||
|
||||
// Retrieve the values we need to pass on
|
||||
var NEW_AVDELMETH = $("#addAVDELMETH").val();
|
||||
var NEW_AVSHPVIA = $("#addAVSHPVIA").val();
|
||||
var NEW_AVSHSRT = $("#addAVSHSRT").val();
|
||||
var NEW_AVSHORCL = $("#addAVSHORCL").val();
|
||||
var NEW_AVCO = $("#addAVCO").val();
|
||||
var NEW_AVPLANT = $("#addAVPLANT").val();
|
||||
var NEW_AVWHS = $("#addAVWHS").val();
|
||||
|
||||
var csrf = document.querySelector('meta[name="csrf-token"]').content;
|
||||
var form_post = {
|
||||
'AVDELMETH': NEW_AVDELMETH,
|
||||
'AVSHPVIA': NEW_AVSHPVIA,
|
||||
'AVSHSRT': NEW_AVSHSRT,
|
||||
'AVSHORCL': NEW_AVSHORCL,
|
||||
'AVCO': NEW_AVCO,
|
||||
'AVPLANT': NEW_AVPLANT,
|
||||
'AVWHS': NEW_AVWHS,
|
||||
'_token': csrf
|
||||
};
|
||||
|
||||
if(errors_found==0) {
|
||||
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url:'/M3Delivery/saveM3DeliveryAdd',
|
||||
data: form_post,
|
||||
success:function(data) {
|
||||
if (data=="success") {
|
||||
$('#M3DeliveryAdd').modal('hide');
|
||||
location.reload();
|
||||
} else {
|
||||
$("#addAVDELMETH").val(NEW_AVDELMETH);
|
||||
$("#addAVSHPVIA").val(NEW_AVSHPVIA);
|
||||
$("#addAVSHSRT").val(NEW_AVSHSRT);
|
||||
$("#addAVSHORCL").val(NEW_AVSHORCL);
|
||||
|
||||
if (data=="exists") {
|
||||
alert("Delivery Method entered already exists. Please try again.");
|
||||
$("#addAVDELMETH").val('');
|
||||
$("#addAVSHPVIA").val('');
|
||||
$("#addAVSHSRT").val('');
|
||||
$("#addAVSHORCL").val('');
|
||||
$('#M3DeliveryAdd').modal('show');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//});
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
@@ -0,0 +1,850 @@
|
||||
@extends('m3::liberty-theme.layout.main')
|
||||
@section('title')
|
||||
Transaction log for M3/Sentinel interface
|
||||
@endsection
|
||||
@section('content')
|
||||
<!-- /.row -->
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">Transaction log for M3/Sentinel interface</h1>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-12 mt-1">
|
||||
<form class="needs-validation" enctype="multipart/form-data" id="formFilters">
|
||||
<div class="mb-3 row align-items-center">
|
||||
{{-- Show errors --}}
|
||||
@php $showerrors = old('SHOWERRORS') ?? $showerrors; @endphp
|
||||
<div class="col-auto">
|
||||
<label class=" form-check-label" for="flexSwitchCheckDefault">Show errors</label>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="SHOWERRORS" name="SHOWERRORS"
|
||||
value="Y" {{ $showerrors == 'Y' ? 'checked' : '' }}>
|
||||
</div>
|
||||
</div>
|
||||
{{-- MACPKR --}}
|
||||
<div class="col-auto">
|
||||
<label for="inputPassword2" class="col-form-label">Delivery Note</label>
|
||||
<input type="text" class="form-control form-control-sm" name="SHMACPKR"
|
||||
id="SHMACPKR" value="{{ old('SHMACPKR') ?? $macpkr }}" maxlength="11">
|
||||
</div>
|
||||
{{-- Start Date --}}
|
||||
<div class="col-auto">
|
||||
<label for="exampleFormControlInput1" class="col-form-label">Start Date</label>
|
||||
<input type="date" class="form-control form-control-sm" id="STARTDATE"
|
||||
name="STARTDATE"
|
||||
value="{{ old('STARTDATE') ?? today()->subDays(1)->format('Y-m-d') }}" required>
|
||||
</div>
|
||||
{{-- End Date --}}
|
||||
<div class="col-auto">
|
||||
<label for="exampleFormControlInput1" class="col-form-label">End Date</label>
|
||||
<input type="date" class="form-control form-control-sm" id="ENDDATE" name="ENDDATE"
|
||||
value="{{ old('ENDDATE') ?? date('Y-m-d') }}" required>
|
||||
</div>
|
||||
{{-- SHSOURCE --}}
|
||||
<div class="col-auto">
|
||||
<label for="SHSOURCE" class="col-form-label">Source</label>
|
||||
@php
|
||||
$transxTypes = Config::get('arrays.transxTypes');
|
||||
$shsource = old('SHSOURCE') ?? $shsource;
|
||||
@endphp
|
||||
{{-- transxTypes --}}
|
||||
<select class="form-select" name="SHSOURCE" id="SHSOURCE">
|
||||
<option value="">Select Source...</option>
|
||||
@foreach ($transxTypes as $key => $transxType)
|
||||
<option value="{{ $key }}" {{ $shsource == $key ? 'selected' : '' }}>
|
||||
{{ $transxType }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="SKIPDATES" name="SKIPDATES" value="{{ $skipdates }}">
|
||||
|
||||
<div class="col-auto align-self-end">
|
||||
<button type="button" class="btn btn-sm btn-primary" id="filterTop">Submit</button>
|
||||
</div>
|
||||
<div class="col-auto align-self-end">
|
||||
<a type="button" class="btn btn-sm btn-danger" id="refresh">Refresh</a>
|
||||
</div>
|
||||
<div class="col-auto align-self-end">
|
||||
<button type="button" class="btn btn-sm btn-warning mt-4" id="exportExcel">Download
|
||||
Excel</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
{{-- Form for Export --}}
|
||||
<form enctype="multipart/form-data" method="POST" action="{{ route('m3.exporttoExcel699') }}"
|
||||
id="exporttoExcelForm">
|
||||
@csrf
|
||||
<input type="hidden" name="SHMACPKR" id="SHMACPKR1" value="">
|
||||
<input type="hidden" name="SHSOURCE" id="SHSOURCE1" value="">
|
||||
<input type="hidden" name="STARTDATE" id="STARTDATE1" value="">
|
||||
<input type="hidden" name="ENDDATE" id="ENDDATE1" value="">
|
||||
<input type="hidden" name="SHOWERRORS" id="SHOWERRORS1" value="">
|
||||
<input type="hidden" name="SKIPDATES" id="SKIPDATES1" value="{{ $skipdates }}">
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-12 mt-1">
|
||||
{{-- Header Title --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="container-fluid table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover" id="datatablesSimple5"
|
||||
style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Delivery Note</th>
|
||||
<th>Order #</th>
|
||||
<th>Customer</th>
|
||||
<th>Date</th>
|
||||
<th>Error</th>
|
||||
<th>Error description</th>
|
||||
<th>Request Type</th>
|
||||
<th>Source of transaction</th>
|
||||
<th>User</th>
|
||||
<th>Request or Response Data</th>
|
||||
<th>Error message</th>
|
||||
<th>Division</th>
|
||||
<th>Warehouse</th>
|
||||
<th>Acknowledge/Retry Date</th>
|
||||
<th>Acknowledged/Retried by User</th>
|
||||
<th>Internal Box Number</th>
|
||||
<th>Link to SPD</th>
|
||||
<th>Note</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
var transTypes = JSON.parse('{!! json_encode($transxTypes) !!}');
|
||||
// console.log(transTypes);
|
||||
var usersList = JSON.parse('{!! json_encode($ICM428MCOL) !!}');
|
||||
|
||||
// DataTables Init
|
||||
let copyButtonTrans = 'Copy'
|
||||
let csvButtonTrans = 'CSV'
|
||||
let excelButtonTrans = 'Excel'
|
||||
let pdfButtonTrans = 'PDF'
|
||||
let colvisButtonTrans = 'Columns'
|
||||
let selectAllButtonTrans = 'Select All'
|
||||
let selectNoneButtonTrans = 'Deselect All'
|
||||
|
||||
let languages = {
|
||||
'en': 'https://cdn.datatables.net/plug-ins/1.10.19/i18n/English.json'
|
||||
};
|
||||
|
||||
$.extend(true, $.fn.dataTable.Buttons.defaults.dom.button, {
|
||||
className: 'btn'
|
||||
})
|
||||
// End Datatables
|
||||
|
||||
$(document).ready(function() {
|
||||
// DataTables Columns
|
||||
var columnDefs = [{
|
||||
data: "SHMACPKR",
|
||||
name: "SHMACPKR",
|
||||
render: function(data, type, row) {
|
||||
return '<a class="link-primary getmackpkr" href="#" data-macpkr="' + row.SHMACPKR
|
||||
.trim() + '">' + row.SHMACPKR.trim() + '</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "A4ONO",
|
||||
name: "A4ONO",
|
||||
render: function(data, type, row) {
|
||||
if (data != null) {
|
||||
return data;
|
||||
} else {
|
||||
return row.A1ONO;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "A4SHSHNM",
|
||||
name: "A4SHSHNM",
|
||||
render: function(data, type, row) {
|
||||
if (data != null) {
|
||||
return data;
|
||||
} else {
|
||||
return row.A1SHSHNM;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "SHDATETIME",
|
||||
name: "SHDATETIME",
|
||||
type: 'date'
|
||||
},
|
||||
{
|
||||
data: "SHERROR",
|
||||
name: "SHERROR",
|
||||
render: function(data, type, row) {
|
||||
// return data;
|
||||
|
||||
newData = data == 'X' && (row.SHTYPE.trim() == 'M3-QtyChg') ?
|
||||
'<button type="button" class="btn btn-sm btn-warning ml-1 acknowledge" data-shsource="' +
|
||||
row.SHSOURCE.trim() +
|
||||
'" data-macpkr="' + row.SHMACPKR.trim() + '" data-shco="' + row.SHCO.trim() +
|
||||
'" data-shwhs="' + row.SHWHS.trim() + '" ' +
|
||||
' data-shdt="' + row.SHDT.trim() + '" data-shtime="' + row.SHTIME.trim() +
|
||||
'" data-shtype="' + row.SHTYPE.trim() + '">Acknowledge</button>' :
|
||||
data;
|
||||
|
||||
closeBtn = (data == 'X' && (row.SHTYPE.trim() == 'M3-Err-out' || row.SHTYPE
|
||||
.trim() == 'M3-Res-out' || row.SHTYPE.trim() == 'M3-Req-out' || row.SHTYPE
|
||||
.trim() == 'M3-General')) ||
|
||||
(data == 'X' && row.SHSOURCE.trim() == 'M3ReceiverAPI' && (row.SHTYPE.trim() ==
|
||||
'M3-Lis-in' || row.SHTYPE.trim() == 'M3-Lis-JSN')) ||
|
||||
(data == 'X' && row.SHTYPE.trim().toUpperCase() == 'M3-LIS-SPL' && (row.SHSOURCE
|
||||
.trim() == 'ICM710E12' || row.SHSOURCE.trim() == 'ICM710E13' ||
|
||||
row.SHSOURCE.trim() == 'M3ReceiverAPI' || row.SHSOURCE.trim() ==
|
||||
'ICM710E')) ||
|
||||
(data == 'X' && row.SHTYPE.trim() == 'M3-Res-out' && row.SHSOURCE.trim() ==
|
||||
'M3InventoryReportReplen') ?
|
||||
'<button type="button" class="btn btn-sm btn-danger closeErr" data-shsource="' +
|
||||
row.SHSOURCE.trim() +
|
||||
'" data-macpkr="' + row.SHMACPKR.trim() + '" data-shco="' + row.SHCO.trim() +
|
||||
'" data-shwhs="' + row.SHWHS.trim() + '" ' +
|
||||
' data-shdt="' + row.SHDT.trim() + '" data-shtime="' + row.SHTIME.trim() +
|
||||
'" data-shtype="' + row.SHTYPE.trim() +
|
||||
'" title="Close"><i class="fa fa-times" aria-hidden="true"></i></button> ' :
|
||||
'';
|
||||
|
||||
return (data == 'X' && row.SHSOURCE.trim() == 'CloseShipmentCoChargeAPI') || (
|
||||
data == 'X' && row.SHSOURCE.trim() == 'TransferAPIURL' && row.SHTYPE
|
||||
.trim() == 'M3-Res-out') ?
|
||||
'<button type="button" class="btn btn-sm btn-warning retryAPICall" data-shsource="' +
|
||||
row.SHSOURCE.trim() +
|
||||
'" data-macpkr="' + row.SHMACPKR.trim() + '" data-shco="' + row.SHCO.trim() +
|
||||
'" data-shwhs="' + row.SHWHS.trim() + '" ' +
|
||||
' data-shdt="' + row.SHDT.trim() + '" data-shtime="' + row.SHTIME.trim() +
|
||||
'" data-shtype="' + row.SHTYPE.trim() +
|
||||
'" title="Retry"><i class="fas fa-redo-alt"></i></button> ' + closeBtn :
|
||||
data == 'X' && row.SHTYPE.trim().toUpperCase() == 'M3-LIS-SPL' && (row.SHSOURCE
|
||||
.trim() == 'ICM710E12' || row.SHSOURCE.trim() == 'ICM710E13' ||
|
||||
row.SHSOURCE.trim() == 'M3ReceiverAPI' || row.SHSOURCE.trim() == 'ICM710E'
|
||||
) ||
|
||||
(data == 'X' && row.SHSOURCE.trim() == 'M3ReceiverAPI' && (row.SHTYPE.trim() ==
|
||||
'M3-Lis-in' || row.SHTYPE.trim() == 'M3-Lis-JSN')) ||
|
||||
(data == 'X' && row.SHSOURCE.trim() == 'M3InventoryReportListURL') ||
|
||||
(data == 'X' && row.SHSOURCE.trim() == 'TransferAPIURL' && row.SHTYPE.trim() ==
|
||||
'M3-Err-out') ||
|
||||
(data == 'X' && row.SHTYPE.trim() == 'M3-Res-out' && row.SHSOURCE.trim() ==
|
||||
'M3InventoryReportReplen') ?
|
||||
closeBtn :
|
||||
data == 'Z' ?
|
||||
'<b>Closed</b>' :
|
||||
newData;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "SHDATA",
|
||||
name: "SHDATA",
|
||||
type: 'html',
|
||||
render: function(data, type, row) {
|
||||
var firstOccurrenceIndex = data.indexOf('{') > 0 ? data.indexOf('{') : 0;
|
||||
var TotalLength = data.length;
|
||||
var errorDesc = firstOccurrenceIndex > 0 && TotalLength > 200 ? data.substring(0,
|
||||
firstOccurrenceIndex) : data.substring(0, 200);
|
||||
// console.log(errorDesc);
|
||||
return errorDesc;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "SHTYPE",
|
||||
name: "SHTYPE"
|
||||
},
|
||||
{
|
||||
data: "SHSOURCE",
|
||||
name: "SHSOURCE",
|
||||
render: function(data, type, row) {
|
||||
var key = data.trim();
|
||||
return transTypes[key] != null ? transTypes[key] : data.trim();
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "R428FIRST",
|
||||
name: "R428FIRST",
|
||||
render: function(data, type, row) {
|
||||
return data != null ? (data.trim() + ' ' + row.R428FAMILY.trim()).toUpperCase() : (
|
||||
row.SHUSER.trim()).toUpperCase();
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "SHDATA",
|
||||
name: "SHDATA",
|
||||
type: 'html',
|
||||
render: function(data, type, row) {
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "SHCODE",
|
||||
name: "SHCODE"
|
||||
},
|
||||
{
|
||||
data: "SHCO",
|
||||
name: "SHCO"
|
||||
},
|
||||
{
|
||||
data: "SHWHS",
|
||||
name: "SHWHS"
|
||||
},
|
||||
{
|
||||
data: "SHACKDATE",
|
||||
name: "SHACKDATE",
|
||||
render: function(data, type, row) {
|
||||
return data + ' ' + row.SHACKTIME;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "SHACKUSER",
|
||||
name: "SHACKUSER",
|
||||
render: function(data, type, row) {
|
||||
var key = data.trim();
|
||||
var currUser = key;
|
||||
// console.log(key);
|
||||
if (key != '') {
|
||||
usersList.forEach(element => {
|
||||
// console.log(element.R428US+' '+key);
|
||||
if (element.R428US == key) {
|
||||
currUser = element.R428FIRST + ' ' + element.R428FAMILY;
|
||||
// console.log(currUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
return currUser;
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "SHINTBOX",
|
||||
name: "SHINTBOX"
|
||||
},
|
||||
{
|
||||
data: "SHMACPKR",
|
||||
name: "SHMACPKR",
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
render: function(data, type, row) {
|
||||
fullUrl = "{{ Request::url() }}";
|
||||
UrlPath = "{{ Request::path() }}";
|
||||
sendUrl = fullUrl.replace(UrlPath, "");
|
||||
return '<a class="btn btn-sm btn-secondary" href="' + sendUrl +
|
||||
'php/AllSentPkr.php?macpkr_input=' + row.SHMACPKR.trim() + '">SPD</a>';
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
data: "SHACKNOTE",
|
||||
name: "SHACKNOTE"
|
||||
}
|
||||
];
|
||||
|
||||
// DataTables init Config
|
||||
$.extend(true, $.fn.dataTable.defaults, {
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: '{{ route('m3.M3ErrorsDisplayDT') }}',
|
||||
data: function(d) {
|
||||
d.STARTDATE = $('#STARTDATE').val().trim();
|
||||
d.ENDDATE = $('#ENDDATE').val().trim();
|
||||
d.SHMACPKR = $('#SHMACPKR').val().trim();
|
||||
d.SHSOURCE = $('#SHSOURCE').val().trim();
|
||||
d.SHOWERRORS = $('#SHOWERRORS').is(':checked') ? 'Y' : 'N';
|
||||
d.SKIPDATES = $('#SKIPDATES').val().trim();
|
||||
}
|
||||
},
|
||||
columns: columnDefs,
|
||||
responsive: true,
|
||||
fixedColumns: true,
|
||||
orderCellsTop: true,
|
||||
order: [
|
||||
[3, 'asc'] // Order By Date time
|
||||
],
|
||||
pageLength: 100,
|
||||
"lengthMenu": [
|
||||
[10, 25, 50, 100, 500],
|
||||
[10, 25, 50, 100, 500]
|
||||
],
|
||||
select: {
|
||||
style: 'multi+shift',
|
||||
selector: 'td:first-child'
|
||||
},
|
||||
language: {
|
||||
url: languages['{{ app()->getLocale() }}']
|
||||
},
|
||||
dom: "<'row'<'col-sm-12 col-md-2'l><'col-sm-12 col-md-7'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
||||
// <'col-sm-12 col-md-3'f>
|
||||
buttons: [{
|
||||
extend: 'selectAll',
|
||||
className: 'btn-primary mr-1',
|
||||
text: selectAllButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
},
|
||||
action: function(e, dt) {
|
||||
e.preventDefault()
|
||||
dt.rows().deselect();
|
||||
dt.rows({
|
||||
search: 'applied'
|
||||
}).select();
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'selectNone',
|
||||
className: 'btn-primary mr-1',
|
||||
text: selectNoneButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'copy',
|
||||
className: 'btn-default mr-1',
|
||||
text: copyButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'csv',
|
||||
className: 'btn-default mr-1',
|
||||
text: csvButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
className: 'btn-default mr-1',
|
||||
text: excelButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible',
|
||||
stripHtml: true
|
||||
},
|
||||
customize: function(xlsx, btnObj, tableInst) {
|
||||
var sheet = xlsx.xl.worksheets['sheet1.xml'];
|
||||
var cellIndexes = tableInst.cells(".bg-danger").indexes();
|
||||
for (var i = 0; i < cellIndexes.length; i++) {
|
||||
var cellIndex = cellIndexes[i];
|
||||
var tblRow = cellIndex['row'] + 3; // adjusted from 0 indexed
|
||||
var tblCol = cellIndex['column']; // adjusted from 0 indexed
|
||||
var xlCol = numberToLetters(tblCol);
|
||||
var excelCell = xlCol + tblRow;
|
||||
$('row c[r=' + excelCell + ']', sheet).attr('s', '11');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
className: 'btn-default mr-1',
|
||||
text: pdfButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'colvis',
|
||||
className: 'btn-default mr-1',
|
||||
text: colvisButtonTrans,
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var myTable = $('#datatablesSimple5').DataTable({});
|
||||
|
||||
// Add event listeners to the date filter inputs
|
||||
$('#filterTop,#refresh').on('click', function() {
|
||||
var SHMACPKR = $('#SHMACPKR').val().trim();
|
||||
// Check SHMACPKR for invalid CHARS
|
||||
var numbersOnly = /^[0-9]+$/;
|
||||
if (!SHMACPKR.match(numbersOnly) && SHMACPKR != '') {
|
||||
alert('Only numeric values are allowed for Delivery Note ');
|
||||
$('#SHMACPKR').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Refresh the table data
|
||||
myTable.ajax.reload();
|
||||
});
|
||||
|
||||
// Retry Call API
|
||||
$(document).on('click', '.retryAPICall', function() {
|
||||
$('.retryAPICall').prop("disabled", true);
|
||||
|
||||
SHSOURCE = $(this).data('shsource');
|
||||
SHMACPKR = $(this).data('macpkr');
|
||||
SHCO = $(this).data('shco');
|
||||
SHWHS = $(this).data('shwhs');
|
||||
SHDT = $(this).data('shdt');
|
||||
SHTIME = $(this).data('shtime');
|
||||
SHTYPE = $(this).data('shtype');
|
||||
urlToCall = "";
|
||||
|
||||
fullUrl = "{{ Request::url() }}";
|
||||
UrlPath = "{{ Request::path() }}";
|
||||
sendUrl = fullUrl.replace(UrlPath, "");
|
||||
// console.log(sendUrl);
|
||||
// return false;
|
||||
|
||||
if (SHSOURCE == 'CloseShipmentCoChargeAPI') {
|
||||
urlToCall = sendUrl + "api/" + SHSOURCE + "?TRANSTYPE=P&COMPANY=" + SHCO + "&WHS=" +
|
||||
SHWHS + "&MANIFEST=" + SHMACPKR +
|
||||
"&SHDT=" + SHDT + "&SHTIME=" + SHTIME + "&SHTYPE=" + SHTYPE;
|
||||
} else if (SHSOURCE == 'TransferAPIURL') {
|
||||
urlToCall = sendUrl + "api/" + SHSOURCE + "?TRANSTYPE=R&COMPANY=" + SHCO + "&WHS=" +
|
||||
SHWHS + "&DELIVERYNO=" + SHMACPKR +
|
||||
"&SHDT=" + SHDT + "&SHTIME=" + SHTIME + "&SHTYPE=" + SHTYPE;
|
||||
}
|
||||
// else if (SHSOURCE=='M3ReceiverAPI') {
|
||||
// urlToCall = sendUrl+"api/m3receiver?TRANSTYPE=R&COMPANY="+SHCO+"&WHS="+SHWHS+"&DELIVERYNO="+SHMACPKR+
|
||||
// "&SHDT="+SHDT+"&SHTIME="+SHTIME+"&SHTYPE="+SHTYPE;
|
||||
// }
|
||||
// var urlToCall = "http://esn2.nventco.com:10024/api/"+SHSOURCE+"?TRANSTYPE=R";
|
||||
// console.log(urlToCall); return false;
|
||||
|
||||
// Call API
|
||||
if (urlToCall != '') {
|
||||
var settings = {
|
||||
"url": urlToCall,
|
||||
"method": "POST",
|
||||
"timeout": 0,
|
||||
"headers": {
|
||||
"Content-Type": "application/json",
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
|
||||
},
|
||||
};
|
||||
|
||||
$.ajax(settings).done(function(response) {
|
||||
// console.log(response);
|
||||
if (response.code != '200') {
|
||||
Swal.fire('The retry resulted in another error: ' + response.message);
|
||||
} else {
|
||||
Swal.fire('The retry was Successful');
|
||||
}
|
||||
// Refresh the table data
|
||||
myTable.ajax.reload();
|
||||
$('.retryAPICall').prop("disabled", false);
|
||||
});
|
||||
} else {
|
||||
Swal.fire('It was not possible to issue the retry.');
|
||||
// console.log("URL Not Valid");
|
||||
$('.retryAPICall').prop("disabled", false);
|
||||
}
|
||||
});
|
||||
|
||||
// Acknowledge Call API
|
||||
$(document).on('click', '.acknowledge', function() {
|
||||
$('.acknowledge').prop("disabled", true);
|
||||
|
||||
SHSOURCE = $(this).data('shsource');
|
||||
SHMACPKR = $(this).data('macpkr');
|
||||
SHCO = $(this).data('shco');
|
||||
SHWHS = $(this).data('shwhs');
|
||||
SHDT = $(this).data('shdt');
|
||||
SHTIME = $(this).data('shtime');
|
||||
SHTYPE = $(this).data('shtype');
|
||||
urlToCall = "";
|
||||
// console.log(SHSOURCE);
|
||||
|
||||
fullUrl = "{{ Request::url() }}";
|
||||
UrlPath = "{{ Request::path() }}";
|
||||
sendUrl = fullUrl.replace(UrlPath, "");
|
||||
// console.log(sendUrl);
|
||||
|
||||
Swal.fire({
|
||||
title: 'Acknowledge',
|
||||
text: "Have you ensured that this qty adjustment has been manually posted in the ERP system to ensure that we do not over-invoice the customer?",
|
||||
// icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes',
|
||||
input: 'text',
|
||||
inputAttributes: {
|
||||
autocapitalize: 'off'
|
||||
},
|
||||
// icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes',
|
||||
inputValidator: (value) => {
|
||||
return new Promise((resolve) => {
|
||||
if (value !== '') {
|
||||
resolve();
|
||||
} else {
|
||||
resolve('You should fill a reason.');
|
||||
}
|
||||
})
|
||||
},
|
||||
preConfirm: (text) => {
|
||||
var form_post2 = {
|
||||
SHSOURCE: SHSOURCE,
|
||||
SHMACPKR: SHMACPKR,
|
||||
SHCO: SHCO,
|
||||
SHWHS: SHWHS,
|
||||
SHDT: SHDT,
|
||||
SHTIME: SHTIME,
|
||||
SHTYPE: SHTYPE,
|
||||
SHACKNOTE: text,
|
||||
_token: '{{ csrf_token() }}'
|
||||
};
|
||||
// console.log(form_post2);
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('m3.M3ErrorsDisplay699') }}",
|
||||
type: "POST",
|
||||
data: form_post2,
|
||||
success: function(response) {
|
||||
if (response.success == true) {
|
||||
// Refresh the table data
|
||||
myTable.ajax.reload();
|
||||
Swal.fire('Acknowledge call was Successful');
|
||||
$('.acknowledge').prop("disabled", false);
|
||||
} else {
|
||||
Swal.fire('Acknowledge Failed');
|
||||
$('.acknowledge').prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
// console.log(error);
|
||||
// alert(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
//
|
||||
} else {
|
||||
$('.acknowledge').prop("disabled", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Close Call API
|
||||
$(document).on('click', '.closeErr', function() {
|
||||
$('.closeErr').prop("disabled", true);
|
||||
|
||||
SHSOURCE = $(this).data('shsource');
|
||||
SHMACPKR = $(this).data('macpkr');
|
||||
SHCO = $(this).data('shco');
|
||||
SHWHS = $(this).data('shwhs');
|
||||
SHDT = $(this).data('shdt');
|
||||
SHTIME = $(this).data('shtime');
|
||||
SHTYPE = $(this).data('shtype');
|
||||
|
||||
urlToCall = "";
|
||||
// console.log(SHTYPE);
|
||||
// console.log(SHSOURCE);
|
||||
|
||||
fullUrl = "{{ Request::url() }}";
|
||||
UrlPath = "{{ Request::path() }}";
|
||||
sendUrl = fullUrl.replace(UrlPath, "");
|
||||
// console.log(sendUrl);
|
||||
// return false;
|
||||
|
||||
if (SHTYPE == 'M3-LIS-SPL') {
|
||||
var message = 'Please ask ERP team to correct errors and resend this order';
|
||||
} else {
|
||||
var message =
|
||||
"Please explain what action was taken to ensure the ERP system was updated manually";
|
||||
}
|
||||
// Set Close All Button for Replen
|
||||
if (SHSOURCE == 'M3InventoryReportReplen') {
|
||||
var showCloseAll = true;
|
||||
var closethisErrorMsg = 'Close this error only';
|
||||
} else {
|
||||
var showCloseAll = false;
|
||||
var closethisErrorMsg = 'Close';
|
||||
}
|
||||
|
||||
if (SHSOURCE == 'M3ReceiverAPI') {
|
||||
var noteText = '';
|
||||
} else {
|
||||
var noteText = '';
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Close',
|
||||
text: message,
|
||||
input: 'text',
|
||||
inputValue: noteText,
|
||||
inputAttributes: {
|
||||
autocapitalize: 'off'
|
||||
},
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: closethisErrorMsg,
|
||||
showDenyButton: showCloseAll,
|
||||
denyButtonText: `Close All similar errors`,
|
||||
inputValidator: (value) => {
|
||||
return new Promise((resolve) => {
|
||||
if (value !== '') {
|
||||
resolve();
|
||||
} else {
|
||||
resolve('You should fill a reason.');
|
||||
}
|
||||
})
|
||||
},
|
||||
preConfirm: (text) => {
|
||||
var form_post2 = {
|
||||
SHSOURCE: SHSOURCE,
|
||||
SHMACPKR: SHMACPKR,
|
||||
SHCO: SHCO,
|
||||
SHWHS: SHWHS,
|
||||
SHDT: SHDT,
|
||||
SHTIME: SHTIME,
|
||||
SHTYPE: SHTYPE,
|
||||
SHACKNOTE: text,
|
||||
CLOSESIM: 'N',
|
||||
_token: '{{ csrf_token() }}'
|
||||
};
|
||||
// console.log(form_post2);
|
||||
// return false;
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('m3.M3ErrorsDisplay699') }}",
|
||||
type: "POST",
|
||||
data: form_post2,
|
||||
success: function(response) {
|
||||
if (response.success == true) {
|
||||
// Refresh the table data
|
||||
myTable.ajax.reload();
|
||||
Swal.fire('Close call was Successful');
|
||||
$('.closeErr').prop("disabled", false);
|
||||
} else {
|
||||
Swal.fire('Close Failed');
|
||||
$('.closeErr').prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
// console.log(error);
|
||||
// alert(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
preDeny: () => {
|
||||
// Get the input value manually
|
||||
const text = Swal.getInput().value;
|
||||
|
||||
// Validate the input
|
||||
if (!text || text.trim() === '') {
|
||||
Swal.showValidationMessage('You should fill a reason.');
|
||||
return false; // Prevent the dialog from closing
|
||||
}
|
||||
var form_post2 = {
|
||||
SHSOURCE: SHSOURCE,
|
||||
SHMACPKR: SHMACPKR,
|
||||
SHCO: SHCO,
|
||||
SHWHS: SHWHS,
|
||||
SHDT: SHDT,
|
||||
SHTIME: SHTIME,
|
||||
SHTYPE: SHTYPE,
|
||||
SHACKNOTE: text,
|
||||
CLOSESIM: 'Y',
|
||||
_token: '{{ csrf_token() }}'
|
||||
};
|
||||
// console.log(form_post2);
|
||||
// return false;
|
||||
$.ajax({
|
||||
url: "{{ route('m3.M3ErrorsDisplay699') }}",
|
||||
type: "POST",
|
||||
data: form_post2,
|
||||
success: function(response) {
|
||||
if (response.success == true) {
|
||||
// Refresh the table data
|
||||
myTable.ajax.reload();
|
||||
Swal.fire('Close call was Successful');
|
||||
$('.closeErr').prop("disabled", false);
|
||||
} else {
|
||||
Swal.fire('Close Failed');
|
||||
$('.closeErr').prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
// console.log(error);
|
||||
// alert(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {} else {
|
||||
// console.log("Canceled...");
|
||||
$('.closeErr').prop("disabled", false);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Show all Macpkr on click
|
||||
$(document).on('click', '.getmackpkr', function() {
|
||||
mackpkr = $(this).data("macpkr");
|
||||
$('#SHMACPKR').val(mackpkr);
|
||||
// MAK Change Later
|
||||
$('#SHSOURCE').val("");
|
||||
|
||||
// Refresh the table data
|
||||
myTable.ajax.reload();
|
||||
});
|
||||
|
||||
// Prevent Form Submit
|
||||
$("#formFilters").keypress(function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
e.preventDefault();
|
||||
$('#filterTop').trigger('click');
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
||||
// Export To Excel exportExcel
|
||||
$(document).on('click', '#exportExcel', function() {
|
||||
var SHMACPKR = $('#SHMACPKR').val().trim();
|
||||
// Check SHMACPKR for invalid CHARS
|
||||
var numbersOnly = /^[0-9]+$/;
|
||||
if (!SHMACPKR.match(numbersOnly) && SHMACPKR != '') {
|
||||
alert('Only numeric values are allowed for Delivery Note ');
|
||||
$('#SHMACPKR').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
SHMACPKR = $("#SHMACPKR").val();
|
||||
SHSOURCE = $("#SHSOURCE").val();
|
||||
STARTDATE = $("#STARTDATE").val();
|
||||
ENDDATE = $("#ENDDATE").val();
|
||||
SHOWERRORS = $('#SHOWERRORS').is(':checked') ? 'Y' : 'N';
|
||||
|
||||
$("#SHMACPKR1").val(SHMACPKR);
|
||||
$("#SHSOURCE1").val(SHSOURCE);
|
||||
$("#STARTDATE1").val(STARTDATE);
|
||||
$("#ENDDATE1").val(ENDDATE);
|
||||
$("#SHOWERRORS1").val(SHOWERRORS);
|
||||
|
||||
$("#exporttoExcelForm").submit();
|
||||
|
||||
});
|
||||
|
||||
@if (session('message') != '')
|
||||
alert("{{ session('message') }}");
|
||||
@endif
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -0,0 +1,103 @@
|
||||
@extends('m3::liberty-theme.layout.main')
|
||||
@section('title')
|
||||
Sentinel Doc Archive
|
||||
@endsection
|
||||
@section('content')
|
||||
<!-- /.row -->
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">Sentinel Doc Archive</h1>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-12 mt-1">
|
||||
<form class="needs-validation" enctype="multipart/form-data" method="GET" action="{{ route("m3.M3GetPDFFromCache.index") }}">
|
||||
{{-- @csrf --}}
|
||||
<div class="mb-3 row">
|
||||
<label for="inputPassword2" class="col-sm-1 col-form-label">Del. Note #</label>
|
||||
<div class="col-sm-1">
|
||||
<input type="text" class="form-control form-control-sm" name="MACPKR" id="SHMACPKR" value="{{$AYMACPKR}}">
|
||||
</div>
|
||||
<label for="recipient-name" class="col-sm-1 col-form-label">Warehouse:</label>
|
||||
<div class="col-sm-2">
|
||||
<select class="form-select" id="WHDDA" aria-label="WHDD" tabindex="-1" disabled>
|
||||
@foreach ($IC670M as $key => $IC670MR)
|
||||
@php $currentWHDDA = trim($IC670MR->WDCO).trim($IC670MR->WDPL).trim($IC670MR->WDWHS); @endphp
|
||||
<option value="{{ $currentWHDDA }}"
|
||||
data-comp="{{ trim($IC670MR->WDCO) }}" data-pl="{{ trim($IC670MR->WDPL) }}" data-wh="{{ trim($IC670MR->WDWHS) }}"
|
||||
{{ ($WHDDA!='' && $WHDDA==$currentWHDDA) ? "selected" : "" }}>
|
||||
{{ trim(Str::upper($IC670MR->WDWNAM)) }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<label for="recipient-name" class="col-sm-1 col-form-label">Division:</label>
|
||||
<div class="col-sm-1">
|
||||
<input type="text" class="form-control" name="COMPANY" id="COMPANY" required readonly>
|
||||
</div>
|
||||
<label for="recipient-name" class="col-sm-1 col-form-label">Plant:</label>
|
||||
<div class="col-sm-1">
|
||||
<input type="text" class="form-control" name="PLANT" id="PLANT" required readonly>
|
||||
</div>
|
||||
<label for="recipient-name" class="col-sm-1 col-form-label">Warehouse:</label>
|
||||
<div class="col-sm-1">
|
||||
<input type="text" class="form-control" name="WHS" id="WHS" required readonly>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<button type="submit" class="btn btn-primary mb-3" id="filterTop">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@if($aggmsg!="")
|
||||
<center><b> {{ $aggmsg }}
|
||||
(
|
||||
@foreach($ICM688M1 as $key => $ICM688M1R)
|
||||
<a href="M3GetPDFFromCache?MACPKR={{$ICM688M1R->A4MACPKR}}&COMPANY={{$COMPANY}}&PLANT={{$PLANT}}&WHS={{$WHS}}">{{$ICM688M1R->A4MACPKR}}</a>
|
||||
@endforeach
|
||||
) </b></center>
|
||||
@endif
|
||||
@if(count($trackingno)>0)
|
||||
@foreach($trackingno as $key => $val)
|
||||
@if(trim($carrier[$key])=="UPSG")
|
||||
<center><b> UPSG <a href=https://www.ups.com/track?loc=en_US&tracknum={{$val}}>{{$val}}</a> </b></center>
|
||||
@elseif(trim($carrier[$key])=="FEDG" || trim($carrier[$key])=="FXFE")
|
||||
<center><b> Fedex <a href=https://www.fedex.com/fedextrack/?trknbr={{$val}}>{{$val}}</a> </b></center>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="container-fluid table-responsive">
|
||||
@if(count($PDFArray)>0)
|
||||
{{-- {{ dump(count($PDFArray)); }} --}}
|
||||
@foreach ($PDFArray as $pdf)
|
||||
<iframe src="data:application/pdf;base64,{{ $pdf }}" style="width: 100%; height: 500px;"></iframe>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
// Update Division/WH/Plant on Warehouse change
|
||||
$(document).on('change select','#WHDDA',function(){
|
||||
$("#COMPANY").val($(this).find("option:selected").data("comp"));
|
||||
$("#PLANT").val($(this).find("option:selected").data("pl"));
|
||||
$("#WHS").val($(this).find("option:selected").data("wh"));
|
||||
});
|
||||
$('#WHDDA').trigger('change');
|
||||
// $('#filterTop').trigger('click');
|
||||
|
||||
// Add event listeners to the date filter inputs
|
||||
// $('#STARTDATE, #ENDDATE, #SHMACPKR').on('change', function () {
|
||||
// $('#filterTop').on('click', function () {});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -0,0 +1,92 @@
|
||||
@extends('m3::liberty-theme.layout.main')
|
||||
@section('title')
|
||||
Solon Sentinel Portal - Manifest Orders
|
||||
@endsection
|
||||
@section('content')
|
||||
<div class="container-fluid px-4">
|
||||
<h1 class="mt-4">Manifest Orders</h1>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
@php
|
||||
$fullUrl = Request::url();
|
||||
$UrlPath = Request::path();
|
||||
$sendUrl = str_replace($UrlPath, "", $fullUrl);
|
||||
@endphp
|
||||
<h6>
|
||||
Manifest #
|
||||
<a class="btn btn-link fw-bold mb-1" target="_blank" href="{{$sendUrl.'php/ClosedTrucksDetail.php?manifest='.$MF}}"> {{ $MF }} </a>
|
||||
<span class="ml-6">Carrier: {{ $carrier }} </span>
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered table-hover" id="datatablesSimple5" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Delivery note</th>
|
||||
<th>Order Number</th>
|
||||
<th>Customer</th>
|
||||
<th>Sentinel Picker Status</th>
|
||||
<th>Total weight</th>
|
||||
<th>Boxes/pallets</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@foreach($ICM695M1 as $key=>$val)
|
||||
@php
|
||||
$A4PICKSTSTMP = isset($val->A4PICKSTS) ? trim($val->A4PICKSTS) : "";
|
||||
$A4PICKSTS = $A4PICKSTSTMP!="" && isset($status_ICM688M1_array[trim($val->A4PICKSTS)]) ?
|
||||
$status_ICM688M1_array[trim($val->A4PICKSTS)] : "";
|
||||
@endphp
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a class="btn btn-link" target="_blank" href="{{$sendUrl.'php/AllSentPkr.php?macpkr_input='.$val->AYMACPKR}}" >
|
||||
{{ $val->AYMACPKR }}
|
||||
</a>
|
||||
</td>
|
||||
<td> {{ $val->AYONO }} </td>
|
||||
<td> {{ $val->A4SHSHNM }} </td>
|
||||
<td> {{ $A4PICKSTS }} </td>
|
||||
<td> {{ number_format($val->TOTWEIGHT, 2) }} </td>
|
||||
<td> {{ $val->BOXPAL }} </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// DataTable init
|
||||
$('#datatablesSimple5').DataTable({
|
||||
"aaSorting": [],
|
||||
"lengthMenu": [ [100,200,500,-1], [100,200,500,"All"] ],
|
||||
"sPaginationType": "full_numbers",
|
||||
dom: "<'row mt-2'<'col-sm-12 col-md-2'l><'col-sm-12 col-md-6'B><'col-sm-12 col-md-3'f>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row mt-2'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
||||
"responsive": true,
|
||||
"orderCellsTop": true,
|
||||
"order": [ [0, 'asc'] ],
|
||||
pageLength: 25,
|
||||
"lengthMenu": [ [10,25,50,100,500], [10,25,50,100,500] ],
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
targets: -1
|
||||
}
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user