Added AHA Report to download in Preorder Index
This commit is contained in:
@@ -239,7 +239,7 @@ class Rimoapi {
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public static function getWorkorderAhReport($rimo_id) {
|
||||
public static function getWorkorderAhaReport($rimo_id) {
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
if(!$rimo_id) {
|
||||
@@ -293,31 +293,58 @@ class Rimoapi {
|
||||
|
||||
if(!$response) return false;
|
||||
|
||||
/* remove boundary from rimo response
|
||||
// rimo returns multipart download
|
||||
// check if multipart boundary exists
|
||||
|
||||
header:
|
||||
if(strpos($response, "\n--") !== false) {
|
||||
// file begins with \n--, so boundary exists
|
||||
$boundary_to_pos = strpos($response, "\r\n\r\n");
|
||||
|
||||
--uuid:b0b72203-db4d-4a85-9d26-b01cd08338c1
|
||||
Content-Type: application/octet-stream
|
||||
Content-Transfer-Encoding: binary
|
||||
Content-ID: <101DCY_AHA.pdf>
|
||||
if($boundary_to_pos === false) {
|
||||
$log->warn(__METHOD__.": Cannot find end of boundary");
|
||||
return false;
|
||||
}
|
||||
$new_resp = substr($response, $boundary_to_pos + 4); // including \r\n\r\n
|
||||
|
||||
footer:
|
||||
|
||||
--uuid:b0b72203-db4d-4a85-9d26-b01cd08338c1--
|
||||
*/
|
||||
// get boundary label
|
||||
$m = [];
|
||||
if(!preg_match("/\n(--[^\r\n]+)\r?\n/", $response, $m)) {
|
||||
$log->warn(__METHOD__.": Cannot find boundary label beginning");
|
||||
return false;
|
||||
}
|
||||
if(!array_key_exists(1, $m)) {
|
||||
$log->warn(__METHOD__.": Cannot find boundary label");
|
||||
return false;
|
||||
}
|
||||
$boundary_label = trim($m[1]);
|
||||
if(!$boundary_label) {
|
||||
$log->warn(__METHOD__.": boundary label empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
$boundary_end = $boundary_label."--";
|
||||
|
||||
$boundary_end_pos = strrpos($new_resp, "\r\n".$boundary_end);
|
||||
//echo "$boundary_end $boundary_end_pos\n";exit;
|
||||
|
||||
$filecontent = substr($new_resp, 0, $boundary_end_pos);
|
||||
//echo "$filecontent";exit;
|
||||
|
||||
} else {
|
||||
$filecontent = $response;
|
||||
}
|
||||
|
||||
|
||||
$finfo = new Finfo(FILEINFO_MIME);
|
||||
$mimetype = $finfo->buffer($response);
|
||||
$mimetype = $finfo->buffer($filecontent);
|
||||
|
||||
var_dump($mimetype);exit;
|
||||
//var_dump($mimetype);exit;
|
||||
|
||||
if(!stripos($mimetype, "pdf")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $response;
|
||||
return $filecontent;
|
||||
}
|
||||
|
||||
public static function getFilenames($rimo_id) {
|
||||
|
||||
Reference in New Issue
Block a user