Fix profile master data loading and remove city_auto_u migration

This commit is contained in:
DevSoftTech Server 2026-04-01 19:22:03 +05:30
parent 14a5a4e79a
commit f4891c0bb4
2 changed files with 14 additions and 54 deletions

View File

@ -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([

View File

@ -1,44 +0,0 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateCityAutoUTable extends Migration
{
public function up(): void
{
$this->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);
}
}