79 lines
2.6 KiB
PHP
Executable File
79 lines
2.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class InsurerModel extends Model
|
|
{
|
|
protected $table = 'insurers';
|
|
protected $primaryKey = 'id';
|
|
protected $allowedFields = [
|
|
"id",
|
|
"type",
|
|
"category",
|
|
"name",
|
|
"short_name",
|
|
"insurer_logo",
|
|
"created_by",
|
|
"updated_by",
|
|
"is_active",
|
|
"addition_add_day",
|
|
"is_multi_event",
|
|
"deletion_add_day",
|
|
|
|
];
|
|
|
|
|
|
|
|
public function getCreatedByUserName()
|
|
{
|
|
|
|
return $this->db->table('insurers')
|
|
->select('insurers.*')
|
|
// ->select('user_profiles.first_name as user_name')
|
|
// ->join('user_profiles', 'user_profiles.id = clients.created_by')
|
|
->get()
|
|
->getResult();
|
|
}
|
|
|
|
public function getInsurerName($insurerId, $client_id)
|
|
{
|
|
// Fetch the insurer name based on the insurer ID
|
|
$query = $this->db->table('client_policy')
|
|
->select('insurers.id, insurers.name, cd_master.cd_ac_no as cd_master_account_no')
|
|
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
|
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
|
|
->where('client_policy.insurer_id', $insurerId)
|
|
->where('client_policy.client_id', $client_id)
|
|
->where('cd_master.id = client_policy.cd_ac_pk')
|
|
->where('cd_master.is_active', 1)
|
|
->get();
|
|
|
|
if ($query->resultID->num_rows > 0) {
|
|
$result = $query->getRow();
|
|
return $result;
|
|
}
|
|
|
|
return null; // or handle accordingly if the insurer is not found
|
|
}
|
|
|
|
public function getInsurerTemplateByInsurerID($insurer_id)
|
|
{
|
|
$insurer_data = $this->db->table('insurer_excel_export_template')
|
|
->select('insurer_excel_export_template.*, insurers.name as insurer_name, insurers.is_multi_event')
|
|
// ->select('CASE WHEN insurers.is_multi_event = 1 THEN "All" ELSE insurer_excel_export_template.event_name END as event_name', false)
|
|
->select('insurer_excel_export_template.type_name, insurer_excel_export_template.jsoncolumns, policy_type.policy_type')
|
|
->join('insurers', 'insurers.id = insurer_excel_export_template.insurer_id')
|
|
->join('policy_type', 'policy_type.id = insurer_excel_export_template.policy_type_id')
|
|
->where('insurers.id', $insurer_id)
|
|
->where('insurers.is_active', 1)
|
|
->where('insurer_excel_export_template.is_active', 1)
|
|
->get()
|
|
->getResultArray();
|
|
|
|
return $insurer_data;
|
|
}
|
|
}
|
|
|
|
|