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); } } }