$e]); return response()->json(['error' => 'Program bridge connection failed.'], 503); } $conn->setOptions(['persistent' => false, 'stateless' => true, 'debug' => true, 'debugLogFile' => '/www/sentustesx/htdocs/storage/logs/toolkit_debug.log']); // Add LIB // $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)'); // define several input/output params $params = []; // AddParameterChar($io, $size, $comment, $varName, $value, $varying, $dimension) // Add Warehouse Param $params[] = $conn->AddParameterChar('in', 3, 'eqNumber', '', '111'); // AddParameterPackDec($io, $length, $scale, $comment, $varName, $value,$dimension) // Add Delivery Note Param $params[] = $conn->AddParameterPackDec('in', 11, 0, 'ParamIn', '', '00000087125'); // Start Time Tracking $start = microtime(true); dump('Calling: EWOBJTST/ICM700C'); // Config::get('eproconf.misc.PGM1'), Config::get('eproconf.misc.libname4') // ICM700C EWOBJTST ICM700C ICM700CSBM $result = $conn->PgmCall('ICM700CSBM', 'EWOBJTST', $params, [], []); if ($result) { dump($result); } // Get Execution Time $time = microtime(true) - $start; dump($time); } public static function pdfReadWrite(Request $request) { dump('PDF Read Write'); $pdfFileName = 'E1232824-10826596'; // Parse PDF file and build necessary objects. $pdfFile = File::get('/www/sentm3test/htdocs/labels/' . $pdfFileName . '.pdf'); // Transform content to base64 $base64PDF = base64_encode($pdfFile); // Output base64 string // dump($base64PDF); // Save Cache Cache::put($pdfFileName, $base64PDF, now()->addMinutes(60)); // Retrieve Cache $cachedPdfFile = Cache::get($pdfFileName); dump('Retrieve Base64 Encoded PDF saved in Cache:'); dump($cachedPdfFile); // remove File from Cache // Cache::put(pdfFileName, 'value', -5); // Cache::forget($pdfFileName); // Base64 Decode and Display // $pdf = $parser->parseContent(base64_decode($base64PDF)); // $text = $pdf->getText(); // dump($text); } public static function fixICM799MSentPKR(Request $request) { ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL')); ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL')); ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL')); ini_set('memory_limit', '1024M'); dump('Run Fix IMSENTPKR...'); $sHUSER = 'TWOSHIP'; // Get User CO & WH // Get users from ICM428M $iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m') ->select('R428US', 'R428CO', 'R428WH') ->where('R428US', '=', $sHUSER) ->first(); $dIVI = isset($iCM428M->R428CO) ? $iCM428M->R428CO : ''; $wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : ''; // Get Parts And Lots from ICM688M2 $iCM688M2SLTMP = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m2') ->select('A5MACPKR', 'A5SENTPKR', 'A5PICKSTRD') ->distinct() ->where('A5CO', $dIVI) ->where('A5WHS', $wHS) ->where('A5PICKSTRD', '!=', '0') ->orderBy('A5PICKSTRD', 'ASC') ->get(); foreach ($iCM688M2SLTMP as $ICM688M2SL) { $a5MACPKR = isset($ICM688M2SL->A5MACPKR) ? $ICM688M2SL->A5MACPKR : ''; $a5SENTPKR = isset($ICM688M2SL->A5SENTPKR) ? $ICM688M2SL->A5SENTPKR : ''; dump('ICM688M2 Record: ' . $a5MACPKR . '-' . $a5SENTPKR); DB::connection(config('m3.connection', 'pgsql'))->table('icm799m') ->where('IMDELNO', '=', $a5MACPKR) ->update(['IMSENTPKR' => $a5SENTPKR]); } } // Generate GS1-128 public static function generateGS128(Request $request) { ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL')); ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL')); ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL')); ini_set('memory_limit', '1024M'); try { Log::channel('LabelCron')->info('>>> Run GS1 Label creation Command...'); $gSArray = $request->query(); $sHUSER = trim((string) ($gSArray['User'] ?? '')); $gS1FileNameNoRoot = ''; if ($sHUSER !== '') { $gS1FileNameNoRoot = self::generateGS128ForUser($gSArray, $sHUSER); } return json_encode(['result' => 'success', 'GS1File' => $gS1FileNameNoRoot]); } catch (\Throwable $th) { Log::channel('LabelCron')->error($th); return json_encode(['result' => 'error', 'GS1File' => $th]); } } private static function generateGS128ForUser(array $gSArray, string $sHUSER): string { // Get User CO & WH from Table ICM428M $iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m') ->select('R428US', 'R428CO', 'R428WH', 'R428PL') ->where('R428US', '=', $sHUSER) ->first(); $cOMPANY = isset($iCM428M->R428CO) ? $iCM428M->R428CO : ''; // Company $pLANT = isset($iCM428M->R428PL) ? $iCM428M->R428PL : ''; // Plant $wHS = isset($iCM428M->R428WH) ? $iCM428M->R428WH : ''; // WareHouse $macpkr = $gSArray['Macpkr']; $packageType = trim($gSArray['packageType']); // 1 => Pallet , 0 => Carton $packageTypeDesc = $packageType == 1 ? 'Pallet' : 'Carton'; $manufactID = '0826528'; // MAK : get ID from Nvent and save to Config File $total_length = 9; $html = '
'; // Get number of Pallets $packageCount = count($gSArray['PackagesArray']); $packageNum = 1; // Get GS1 Label MAX ID from ICM695M3 : $gS1SEQUENCESel = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m3')->max('ID'); $gS1SEQUENCE = isset($gS1SEQUENCESel) ? $gS1SEQUENCESel : 0; // Loop PackagesArray : Build Table for PDF and Insert to ICM695m3 foreach ($gSArray['PackagesArray'] as $value) { $table_style = $packageNum < $packageCount ? ' style="page-break-after: always;" ' : ''; $a2INTBOX = trim($value); $gS1SEQUENCE++; $gS1SEQUENCEID = str_pad($gS1SEQUENCE, $total_length, '0', STR_PAD_LEFT); // Build GS1 18 Digits Code $gs1_128_bc_1 = '00' . $packageType . $manufactID . $gS1SEQUENCEID; $checkDigit = self::gs1CheckDigit($gs1_128_bc_1); // 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'] . '|
FROM: ' . $data['from'] . ' |
SHIP TO: ' . $data['ship_to'] . ' |
||
|
' . $data['ship_to_desc'] . ' |
Carrier: ' . $gSArray['CarrierName'] . ' PRO #: ' . $gSArray['trackingno'] . ' B/L #: ' . $gSArray['BOLnumber'] . ' Ref : ' . $a2INTBOX . ' |
||
|
PURCHASE ORDER: ' . $gSArray['ShipmentPONumber'] . ' Vendor: ' . $manufactID . ' |
|||
| ' . $packageTypeDesc . ' # : ' . $packageNum . ' of ' . $packageCount . ' | |||
|
' . $data['serial_shipping_container'] . ' |
|||
|
FROM: ' . $data['from'] . ' |
SHIP TO: ' . $data['ship_to'] . ' |
||
|
(' . $data['ship_to_postal_code'] . ') |
Carrier Routing(SCAC) PRO #: B/L # : |
||
|
PURCHASE ORDER: PO1234567 PRO: ' . $data['pro'] . ' |
|||
|
ITEM #: ' . $data['item_number'] . ' UPC: ' . $data['upc'] . ' QUANTITY: ' . $data['quantity'] . ' |
|||
|
' . $data['serial_shipping_container'] . ' |
|||