add location param

This commit is contained in:
mahdahar 2025-09-26 16:33:54 +07:00
parent e15a2d98db
commit 38bb2e04d3
2 changed files with 18 additions and 5 deletions

View File

@ -8,6 +8,9 @@ use CodeIgniter\Database\RawSql;
class Location extends Controller {
use ResponseTrait;
protected $db;
protected $rules;
public function __construct() {
$this->db = \Config\Database::connect();
$this->rules = [
@ -17,11 +20,18 @@ class Location extends Controller {
}
public function index() {
$rows = $this->db->table('location l')
$LocName = $this->request->getVar('LocName');
$LocCode = $this->request->getVar('LocCode');
$sql = $this->db->table('location l')
->select("l.LocationID, LocCode, Parent, LocFull, LocType, v.VDesc ")
->join("locationaddress la", "l.LocationID=la.LocationID", 'left')
->join("valueset v", "v.VSetID=12 and v.VValue=l.loctype", 'left')
->get()->getResultArray();
->join("valueset v", "v.VSetID=12 and v.VValue=l.loctype", 'left');
if($LocName != '') { $sql->like('LocFull', $LocName, 'both'); $rows[] = 'LocName'; }
if($LocCode != '') { $sql->like('LocCode', $LocCode, 'both'); $rows[] = 'LocCode'; }
$rows[] = $sql->get()->getResultArray();
if (empty($rows)) {
return $this->respond([
@ -156,7 +166,7 @@ class Location extends Controller {
$input = $this->request->getJSON(true);
$LocationID = $input["LocationID"];
if (!$LocationID) {
return $this->failValidationError('LocationID is required.');
return $this->failValidationErrors('LocationID is required.');
}
@ -211,6 +221,9 @@ class Location extends Controller {
"PostCode" => $input['PostCode'] ?? null,
"GeoLocationSystem" => $input['GeoLocationSystem'] ?? null,
"GeoLocationData" => $input['GeoLocationData'] ?? null,
"Email" => $input['Email'] ?? null,
"Phone" => $input['Phone'] ?? null,
"Mobile" => $input['Mobile'] ?? null,
];
return $data;

View File

@ -51,7 +51,7 @@ class PatVisit extends Controller {
$input = $this->request->getJSON(true);
try {
if (!$input) { return $this->respond(['status' => 'error', 'message' => 'Invalid JSON input'], 400); }
if (!$input) { return $this->respond( ['status' => 'error', 'message' => 'Invalid JSON input'], 400); }
if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
$InternalPVID = $input["InternalPVID"];