From f4891c0bb4d2291c106a402eb3a543ffb71b030a Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Wed, 1 Apr 2026 19:22:03 +0530 Subject: [PATCH] Fix profile master data loading and remove city_auto_u migration --- app/Controllers/Opd_prescription.php | 24 +++++----- ...2026-03-18-000028_CreateCityAutoUTable.php | 44 ------------------- 2 files changed, 14 insertions(+), 54 deletions(-) delete mode 100644 app/Database/Migrations/2026-03-18-000028_CreateCityAutoUTable.php diff --git a/app/Controllers/Opd_prescription.php b/app/Controllers/Opd_prescription.php index 8d9b2a0..adff062 100644 --- a/app/Controllers/Opd_prescription.php +++ b/app/Controllers/Opd_prescription.php @@ -3291,10 +3291,10 @@ class Opd_prescription extends BaseController return view('billing/opd_invest_profile_master_workspace'); } - public function opd_invest_profile_master_list() + private function buildInvestigationProfileRows(string $filter = ''): array { if (! $this->db->tableExists('invprofiles') || ! $this->db->tableExists('invtprofiles') || ! $this->db->tableExists('investigation')) { - return $this->response->setJSON(['rows' => []]); + return []; } $pFields = $this->db->getFieldNames('invprofiles'); @@ -3310,11 +3310,9 @@ class Opd_prescription extends BaseController $iName = $this->resolveFirstField($iFields, ['Name', 'name']); if ($pCode === null || $pName === null || $jProfileCode === null || $jInvestCode === null || $iCode === null || $iName === null) { - return $this->response->setJSON(['rows' => []]); + return []; } - $filter = trim((string) $this->request->getGet('filter')); - $sql = 'SELECT ' . 'p.`' . $pCode . '` AS profile_code, ' . 'p.`' . $pName . '` AS profile_name, ' @@ -3360,13 +3358,20 @@ class Opd_prescription extends BaseController } } - return $this->response->setJSON(['rows' => array_values($map)]); + return array_values($map); + } + + public function opd_invest_profile_master_list() + { + $filter = trim((string) $this->request->getGet('filter')); + + return $this->response->setJSON(['rows' => $this->buildInvestigationProfileRows($filter)]); } public function opd_invest_profile_master_data() { - $rows = $this->opd_invest_profile_master_list()->getJSON(true); - $list = $rows['rows'] ?? []; + $filter = trim((string) $this->request->getGet('filter')); + $list = $this->buildInvestigationProfileRows($filter); $draw = (int) $this->request->getGet('draw'); $start = max(0, (int) $this->request->getGet('start')); $length = (int) $this->request->getGet('length'); @@ -3393,8 +3398,7 @@ class Opd_prescription extends BaseController public function opd_invest_profile_master_get(int $profileCode) { - $response = $this->opd_invest_profile_master_list()->getJSON(true); - $rows = $response['rows'] ?? []; + $rows = $this->buildInvestigationProfileRows(); foreach ($rows as $row) { if ((int) ($row['profile_code'] ?? 0) === $profileCode) { return $this->response->setJSON([ diff --git a/app/Database/Migrations/2026-03-18-000028_CreateCityAutoUTable.php b/app/Database/Migrations/2026-03-18-000028_CreateCityAutoUTable.php deleted file mode 100644 index 44d90fb..0000000 --- a/app/Database/Migrations/2026-03-18-000028_CreateCityAutoUTable.php +++ /dev/null @@ -1,44 +0,0 @@ -forge->addField([ - 'id' => [ - 'type' => 'INT', - 'unsigned' => true, - 'auto_increment' => true, - ], - 'city' => [ - 'type' => 'VARCHAR', - 'constraint' => 150, - 'default' => '', - ], - 'district' => [ - 'type' => 'VARCHAR', - 'constraint' => 150, - 'default' => '', - ], - 'state' => [ - 'type' => 'VARCHAR', - 'constraint' => 100, - 'default' => '', - ], - ]); - - $this->forge->addKey('id', true); - $this->forge->addKey(['city', 'district', 'state']); - - $this->forge->createTable('city_auto_u', true); - } - - public function down(): void - { - $this->forge->dropTable('city_auto_u', true); - } -}