function closeFedEx($close_date = '', $report_only = false, $report_type = 'MANIFEST') { global $messageStack; if (MODULE_SHIPPING_FEDEX_V7_TEST_MODE == 'Test') { $client = new SoapClient(PATH_TO_TEST_CLOSE_WSDL, array('trace' => 1)); } else { $client = new SoapClient(PATH_TO_CLOSE_WSDL, array('trace' => 1)); } $today = date('c'); if (!$close_date) { $close_date = $today; } $report_only = $close_date == $today ? false : true; $date = explode('-', $close_date); $error = false; $request = $this->FormatFedExCloseRequest($close_date, $report_only, $report_type); //echo 'request = '; print_r($request); echo '<br />'; try { $response = $client->groundClose($request); //echo 'Request <pre>' . htmlspecialchars($client->__getLastRequest()) . '</pre>'; //echo 'Response <pre>' . htmlspecialchars($client->__getLastResponse()) . '</pre>'; //echo 'close response array = '; print_r($response); echo '<br />'; if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') { // Fetch the FedEx reports $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/reports/' . $this->code . '/' . $date[0] . '/' . $date[1] . '/'; validate_path($file_path); $file_name = $date[2] . '-' . $response->Manifest->FileName . '.txt'; $closeReport = base64_decode($response->Manifest->File); $mwReport = base64_decode($response->MultiweightReport); $codReport = base64_decode($response->CODReport); // $hazMatReport = base64_decode($response->HazMatCertificate); //echo 'file_path = ' . $file_path . ' and file_name = ' . $file_name . '<br />'; if (!($handle = fopen($file_path . $file_name, 'w'))) { echo 'Cannot open file (' . $file_path . $file_name . ')'; $error = true; continue; } if (fwrite($handle, $closeReport) === false) { $messageStack->add('Cannot write close report to file (' . $file_path . $file_name . ')', 'error'); $error = true; continue; } if (fwrite($handle, $mwReport) === false) { $messageStack->add('Cannot write multi-weight report to file (' . $file_path . $file_name . ')', 'error'); $error = true; continue; } if (fwrite($handle, $codReport) === false) { $messageStack->add('Cannot write COD report to file (' . $file_path . $file_name . ')', 'error'); $error = true; continue; } /* if (fwrite($handle, $hazMatReport) === false) { $messageStack->add('Cannot write Hazmat report to file (' . $file_path . $file_name . ')','error'); $error = true; continue; } */ fclose($handle); if (!$error) { $messageStack->add(SHIPPING_FEDEX_V7_CLOSE_SUCCESS, 'success'); return true; } } else { foreach ($response->Notifications as $notification) { if (is_object($notification)) { $message .= ' (' . $notification->Severity . ') ' . $notification->Message; } else { $message .= ' ' . $notification; } } $messageStack->add(SHIPPING_FEDEX_V7_DEL_ERROR . $message, 'error'); } } catch (SoapFault $exception) { //echo 'Error Request <pre>' . htmlspecialchars($client->__getLastRequest()) . '</pre>'; //echo ' Error Response <pre>' . htmlspecialchars($client->__getLastResponse()) . '</pre>'; $message = " ({$exception->faultcode}) {$exception->faultstring}"; $messageStack->add(SHIPPING_FEDEX_CURL_ERROR . $message, 'error'); } return false; }
/** * Sends the GroundCloseRequest and returns the response * * @param ComplexType\GroundCloseRequest $groundCloseRequest * @return stdClass */ public function getGroundCloseReply(ComplexType\GroundCloseRequest $groundCloseRequest) { return $this->_soapClient->groundClose($groundCloseRequest->toArray()); }