diff --git a/Modules/M3/Config/arrays.php b/Modules/M3/Config/arrays.php index 4dc301d9..c35dcce8 100644 --- a/Modules/M3/Config/arrays.php +++ b/Modules/M3/Config/arrays.php @@ -2,96 +2,95 @@ // 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'], + // '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'], + 'payrollCodes' => ['33,49,75,94,98,102,171'], - 'min_work_hours_for_break' => ['4'], + 'min_work_hours_for_break' => ['4'], 'ignore_picks_that_last_longer_than_this_many_hours' => ['8'], - 'env_ports' => ['test'=>'10004','live'=>'10005'], + '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'], + '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, + '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 + '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', + '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', + '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 + '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" ], + // 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' + '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", + '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', ], ]; diff --git a/Modules/M3/Config/arrays_custom.php b/Modules/M3/Config/arrays_custom.php index fac2f222..d2563ad3 100644 --- a/Modules/M3/Config/arrays_custom.php +++ b/Modules/M3/Config/arrays_custom.php @@ -1,40 +1,37 @@ ['16'=>'30', - '33'=>'12', - '49'=>'25', - '66'=>'60', - '75'=>'15', - '94'=>'40', - '98'=>'8', - '102'=>'10', - '171'=>'17' - ] - + '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 +// '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 +// 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, - -?> \ No newline at end of file +// 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, diff --git a/Modules/M3/Console/CallCloseAPI.php b/Modules/M3/Console/CallCloseAPI.php index be3bdbbf..ff48f079 100644 --- a/Modules/M3/Console/CallCloseAPI.php +++ b/Modules/M3/Console/CallCloseAPI.php @@ -2,17 +2,13 @@ namespace Modules\M3\Console; -use Illuminate\Console\Command; - -use Modules\M3\Http\Controllers\Controller; -use DB; use Config; +use DB; +use Illuminate\Console\Command; use Illuminate\Http\Request; -use Symfony\Component\HttpFoundation\Response; use Log; -use Str; - use Modules\M3\Http\Controllers\API\CloseShipment; +use Str; class CallCloseAPI extends Command { @@ -32,100 +28,101 @@ class CallCloseAPI extends Command public function handle() { - //$this->info('Start CallCloseAPI...'); + // $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 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 : ''; + // 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 + if ($MANIFESTNum == '') { + // Get Macpickers from ICM705M1 $ICM705M1 = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1') - ->select('APMANIFEST','APCO','APWHS') - ->where('APSPARE2','') - ->where('APMANIFEST','!=','0') + ->select('APMANIFEST', 'APCO', 'APWHS') + ->where('APSPARE2', '') + ->where('APMANIFEST', '!=', '0') ->whereRaw('EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - APLDCLOZ)) / 60 > 15') - ->orderBy('APMANIFEST','desc') + ->orderBy('APMANIFEST', 'desc') ->get(); // dump($ICM705M1); - if (count($ICM705M1)>0) { - # Loop the Results from $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 + // 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"]); + ->where('APMANIFEST', $MANIFESTNum) + ->where('APCO', $USERCO) + ->where('APWHS', $USERWH) + ->update(['APSPARE2' => 'P']); - $myRequest = new Request(); + $myRequest = new Request; $myRequest->setMethod('POST'); $myRequest->request->add([ - 'WHS' => $USERWH, - 'COMPANY' => $USERCO, + 'WHS' => $USERWH, + 'COMPANY' => $USERCO, 'TRANSTYPE' => 'M', - 'MANIFEST' => $MANIFESTNum + '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); + $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 + // 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) + ->select('APMANIFEST', 'APCO', 'APWHS') + ->where('APSPARE2', '') + ->where('APCO', $APCO) + ->where('APWHS', $APWHS) + ->where('APMANIFEST', '=', $MANIFESTNum) ->first(); - # Update ICM705M1 and set APSPARE2 to P + // 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"]); + ->where('APMANIFEST', $MANIFESTNum) + ->where('APCO', $APCO) + ->where('APWHS', $APWHS) + ->update(['APSPARE2' => 'P']); - $myRequest = new Request(); + $myRequest = new Request; $myRequest->setMethod('POST'); $myRequest->request->add([ - 'WHS' => $APWHS , - 'COMPANY' => $APCO, + 'WHS' => $APWHS, + 'COMPANY' => $APCO, 'TRANSTYPE' => 'M', - 'MANIFEST' => $MANIFESTNum + '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); + $responseData = $callCloseShipment->getData(); + $jsonData = json_encode($responseData); + Log::channel('dailyCron')->info('Close Shipment API Response for Manifest:' . $MANIFESTNum . '-' . $jsonData); + return 1; } // } @@ -135,8 +132,7 @@ class CallCloseAPI extends Command // $this->error('A user must be defined...'); // } - } - catch (\Throwable $th) { + } catch (\Throwable $th) { // Log::error($th); Log::channel('dailyCron')->error($th); } diff --git a/Modules/M3/Console/ClosedOrderSaveXls.php b/Modules/M3/Console/ClosedOrderSaveXls.php index 8a6e9ae5..3c95b125 100644 --- a/Modules/M3/Console/ClosedOrderSaveXls.php +++ b/Modules/M3/Console/ClosedOrderSaveXls.php @@ -2,18 +2,14 @@ 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 DB; use Excel; +use Illuminate\Console\Command; +use Log; +use Modules\M3\Services\SpreadsheetExport; use Storage; +use Str; class ClosedOrderSaveXls extends Command { @@ -48,53 +44,52 @@ class ClosedOrderSaveXls extends Command */ public function handle() { - //$this->info('Start CallCloseAPI...'); + // $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"); + 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())) : ''); + // 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) : ''; + $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'); + // 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; + $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'; + $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); + $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); + // 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 + 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, @@ -110,8 +105,8 @@ class ClosedOrderSaveXls extends Command 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 ." + 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' @@ -129,61 +124,58 @@ class ClosedOrderSaveXls extends Command // "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']; + $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 + // 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)); + if ($ICM688M2Count > $maxRecords) { + Log::channel('dailyCron')->info('Maximum allowed records for Excel export is: ' . number_format($maxRecords) . ' current records: ' . number_format($ICM688M2Count)); } - } - else{ + } 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"); + 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..."); + // Store the File to Storage + app(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(); + // 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'); + $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'; + $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); + $this->info('Generate Current Month Report...'); + $this->info('From Date: ' . $reportDate2); + $this->info('To Date : ' . $toreportDate2); - if($reportDate2!='' && $COMPANY!='' && $WHS!='' && $PLANT!=''){ - $this->info(">>> Proceed..."); + if ($reportDate2 != '' && $COMPANY != '' && $WHS != '' && $PLANT != '') { + $this->info('>>> Proceed...'); - # Case 729: Add Currency code A1SHCURR FROM ICM666M + // Case 729: Add Currency code A1SHCURR FROM ICM666M $ICM688M2 = DB::connection(config('m3.connection', 'pgsql')) ->select(" SELECT (SHDT || ' ' || SHTIME) AS DATECLOSED, A5MACPKR, A5ONO, @@ -199,8 +191,8 @@ class ClosedOrderSaveXls extends Command 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 ." + 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' @@ -218,42 +210,39 @@ class ClosedOrderSaveXls extends Command // "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']; + $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 + // 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)); + if ($ICM688M2Count > $maxRecords) { + Log::channel('dailyCron')->info('Maximum allowed records for Excel export is: ' . number_format($maxRecords) . ' current records: ' . number_format($ICM688M2Count)); } - } - else{ + } 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..."); + 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(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"); + 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) { + } catch (\Throwable $th) { // Log::error($th); Log::channel('dailyCron')->error($th); } diff --git a/Modules/M3/Console/DeleteOldLabels.php b/Modules/M3/Console/DeleteOldLabels.php index 073440ae..4d287c49 100644 --- a/Modules/M3/Console/DeleteOldLabels.php +++ b/Modules/M3/Console/DeleteOldLabels.php @@ -2,18 +2,10 @@ 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; - +use Illuminate\Console\Command; +use Log; class DeleteOldLabels extends Command { @@ -48,44 +40,44 @@ class DeleteOldLabels extends Command */ public function handle(): void { - //$this->info('Start CallCloseAPI...'); + // $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..."); + $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 = []; + $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; + $labelsDirectory = $labelsDirectoryTmp . $subFolder; - $this->info("Getting Files From Directory: ".$labelsDirectory); - Log::channel('dailyCron')->info("Getting Files From Directory: ".$labelsDirectory); + $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'); + 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 + $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; + $lastAccessTime = new \DateTime('@' . $file->getATime()); + $now = new \DateTime; + $diff = $now->diff($lastAccessTime)->days; if ($diff >= $daysOld) { - $this->info("File: ".$file." is Days Old: ".$diff); + $this->info('File: ' . $file . ' is Days Old: ' . $diff); // Log::channel('dailyCron')->info("File: ".$file." is Days Old: ".$diff); - # Add the File to Array + // Add the File to Array $filesToDeleteArr[] = $file; } } @@ -93,14 +85,13 @@ class DeleteOldLabels extends Command // $this->info("Files to Delete..."); // dump($filesToDeleteArr); - # Delete Old Files + // Delete Old Files File::delete($filesToDeleteArr); - Log::channel('dailyCron')->info("Cron...End Delete Old Labels Command..."); - $this->info("End Delete Old Labels Command..."); + Log::channel('dailyCron')->info('Cron...End Delete Old Labels Command...'); + $this->info('End Delete Old Labels Command...'); - } - catch (\Throwable $th) { + } catch (\Throwable $th) { // Log::error($th); Log::channel('dailyCron')->error($th); } diff --git a/Modules/M3/Console/GenerateGS1Cmd.php b/Modules/M3/Console/GenerateGS1Cmd.php index 9d9dc60a..cc24f8b6 100644 --- a/Modules/M3/Console/GenerateGS1Cmd.php +++ b/Modules/M3/Console/GenerateGS1Cmd.php @@ -2,32 +2,18 @@ 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; +use Ayeo\Barcode; +use Cache; +use Config; +use DB; +use Dompdf\Dompdf; +use File; +use Illuminate\Console\Command; +use Log; +use PDF; +use Picqer\Barcode\BarcodeGeneratorPNG; +use Str; class GenerateGS1Cmd extends Command { @@ -62,7 +48,7 @@ class GenerateGS1Cmd extends Command */ public function handle() { - //$this->info('Start CallCloseAPI...'); + // $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')); @@ -70,44 +56,43 @@ class GenerateGS1Cmd extends Command try { $this->info('>>> Run GS1 Label creation Command...'); - Log::channel('LabelCron')->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 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); + // 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"] + // 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 + 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) + ->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 + $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; + $Macpkr = $GSArray['Macpkr']; + $packageType = '0'; + $manufactID = '0826528'; // MAK : get ID from Nvent and save to Config File + $total_length = 9; $html = ' @@ -137,74 +122,74 @@ class GenerateGS1Cmd extends Command
'; - # Get number of Pallets + // Get number of Pallets $packageCount = count($GSArray['PackagesArray']); - $packageNum = 1; + $packageNum = 1; foreach ($GSArray['PackagesArray'] as $key => $value) { - $table_style = $packageNum < $packageCount ? ' style="page-break-after: always;" ' : ''; + $table_style = $packageNum < $packageCount ? ' style="page-break-after: always;" ' : ''; if (Cache::has('GS1SEQUENCE')) { - $GS1SEQUENCE = Cache::get('GS1SEQUENCE'); + $GS1SEQUENCE = Cache::get('GS1SEQUENCE'); $GS1SEQUENCE++; - $GS1SEQUENCEID = str_pad($GS1SEQUENCE, $total_length, "0", STR_PAD_LEFT); + $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); + // 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); + $this->info('>>> GS1 sequence Id: ' . $GS1SEQUENCEID); - $gs1_128_bc_1 = '00' .$packageType . $manufactID . $GS1SEQUENCEID; + $gs1_128_bc_1 = '00' . $packageType . $manufactID . $GS1SEQUENCEID; - # Calculate Check Digit + // Calculate Check Digit $digits = str_split($gs1_128_bc_1); - $sum = 0; + $sum = 0; $length = count($digits); - # Loop through each digit starting from the right + // 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 + // 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 + // Add the product of the digit and its weight to the sum $sum += $digit * $weight; } - # Calculate the remainder when sum is divided by 10 + // 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 + // 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; + $gs1_128_bc = $gs1_128_bc_1 . $checkDigit; + $gs1_128_bc_desc = '(00)' . $packageType . $manufactID . $GS1SEQUENCEID . $checkDigit; $data = [ - 'ship_to' => $GSArray["Recipient_CompanyName"].'|
FROM: ' . $data['from'] . ' @@ -219,18 +204,18 @@ class GenerateGS1Cmd extends Command ' . $data['ship_to_desc'] . ' |
- Carrier: '.$GSArray["CarrierName"].' - PRO #: '.$GSArray["ShipmentPONumber"].' - B/L #: '.$GSArray["BOLnumber"].' + Carrier: ' . $GSArray['CarrierName'] . ' + PRO #: ' . $GSArray['ShipmentPONumber'] . ' + B/L #: ' . $GSArray['BOLnumber'] . ' |
||
|
- PURCHASE ORDER: '.$GSArray["Macpkr"].' + PURCHASE ORDER: ' . $GSArray['Macpkr'] . ' Vendor: ' . $manufactID . ' |
- Pallet # : '.$packageNum.' of '.$packageCount.' + Pallet # : ' . $packageNum . ' of ' . $packageCount . ' | ||