ss_gw.php: clinic-service_req optional start_date/end_date filter
- date range filter on T_OrderHeaderDate via prepared params - ids stays supported (gateway harvest path unchanged) - empty ids + no dates keeps legacy empty result - isset guard on ids so date-only calls emit no PHP notice
This commit is contained in:
31
ss_gw.php
31
ss_gw.php
@@ -67,9 +67,27 @@ if ($p["cmd"] == "service_req") {
|
|||||||
if ($p["cmd"] == "clinic-service_req") {
|
if ($p["cmd"] == "clinic-service_req") {
|
||||||
$resp = $dbh->connect();
|
$resp = $dbh->connect();
|
||||||
$dbh->exit_if_error($resp[0], $resp[1]);
|
$dbh->exit_if_error($resp[0], $resp[1]);
|
||||||
$ids = implode(",", $p["ids"]);
|
$ids = isset($p["ids"]) ? implode(",", $p["ids"]) : "";
|
||||||
if ($ids == "") {
|
$start_date = isset($p["start_date"]) ? $p["start_date"] : "";
|
||||||
$ids = "0";
|
$end_date = isset($p["end_date"]) ? $p["end_date"] : "";
|
||||||
|
$params = [];
|
||||||
|
$where_date = "";
|
||||||
|
if ($start_date != "" || $end_date != "") {
|
||||||
|
if ($start_date == "") {
|
||||||
|
$start_date = date("Y-m-d");
|
||||||
|
}
|
||||||
|
if ($end_date == "") {
|
||||||
|
$end_date = $start_date;
|
||||||
|
}
|
||||||
|
$params = [$start_date . " 00:00:00", $end_date . " 23:59:59"];
|
||||||
|
$where_date = " and T_OrderHeaderDate >= ? and T_OrderHeaderDate <= ? ";
|
||||||
|
}
|
||||||
|
$where_ids = "";
|
||||||
|
if ($ids != "") {
|
||||||
|
$where_ids = " and T_OrderDetailT_OrderHeaderID in ($ids) ";
|
||||||
|
} else if ($start_date == "" && $end_date == "") {
|
||||||
|
//legacy: no ids and no date -> empty result
|
||||||
|
$where_ids = " and T_OrderDetailT_OrderHeaderID in (0) ";
|
||||||
}
|
}
|
||||||
$sql = "select
|
$sql = "select
|
||||||
T_OrderDetailUserID,
|
T_OrderDetailUserID,
|
||||||
@@ -85,16 +103,17 @@ if ($p["cmd"] == "clinic-service_req") {
|
|||||||
from
|
from
|
||||||
t_orderdetail
|
t_orderdetail
|
||||||
join t_orderheader
|
join t_orderheader
|
||||||
on T_OrderDetailT_OrderHeaderID in ($ids)
|
on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
||||||
and T_OrderDetailIsActive='Y'
|
and T_OrderDetailIsActive='Y'
|
||||||
and T_OrderDetailPrice > 0
|
and T_OrderDetailPrice > 0
|
||||||
|
$where_ids
|
||||||
|
$where_date
|
||||||
join m_user on T_OrderDetailUserID = M_UserID
|
join m_user on T_OrderDetailUserID = M_UserID
|
||||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||||
and T_TestIsActive = 'Y'
|
and T_TestIsActive = 'Y'
|
||||||
join t_testgroup on T_TestT_TestGroupID = T_TestGroupID
|
join t_testgroup on T_TestT_TestGroupID = T_TestGroupID
|
||||||
and T_TestGroupT_ServiceID <> 1 and T_TestGroupIsActive = 'Y'";
|
and T_TestGroupT_ServiceID <> 1 and T_TestGroupIsActive = 'Y'";
|
||||||
$resp = $dbh->query($sql);
|
$resp = $dbh->query($sql, $params);
|
||||||
$dbh->exit_if_error($resp[0], $resp[1]);
|
$dbh->exit_if_error($resp[0], $resp[1]);
|
||||||
$dbh->jsonReply($resp, $dbh->info());
|
$dbh->jsonReply($resp, $dbh->info());
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
Reference in New Issue
Block a user