43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
class Attachment extends MY_Controller
|
|
{
|
|
var $folder;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->folder = "/data-pacs/";
|
|
}
|
|
function list($orderHeaderID)
|
|
{
|
|
$sql = "select T_OrderHeaderDate,T_OrderHeaderLabNumberExt from t_orderheader where T_OrderHeaderID =?";
|
|
$qry = $this->db->query($sql, [$orderHeaderID]);
|
|
if (!$qry) {
|
|
echo json_encode([
|
|
"status" => "ERR", $reports => [],
|
|
"message" => $this->db->error()["message"]
|
|
]);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0) {
|
|
echo json_encode(["status" => "OK", "reports" => []]);
|
|
exit;
|
|
}
|
|
$labNo = $rows[0]["T_OrderHeaderLabNumberExt"];
|
|
$xdate = date("Ymd", strtotime($rows[0]["T_OrderHeaderDate"]));
|
|
$pat = $this->folder . $xdate . "/" . $labNo . "*.jp*";
|
|
$results = glob($pat);
|
|
$urls = [];
|
|
foreach ($results as $r) {
|
|
$urls[] = "/$xdate/" . basename($r);
|
|
}
|
|
echo json_encode(["status" => "OK", "reports" => $urls]);
|
|
}
|
|
function image($date, $name)
|
|
{
|
|
$path = $this->folder . $date . "/" . $name;
|
|
header("Content-Type: image/jpeg");
|
|
echo file_get_contents($path);
|
|
}
|
|
}
|