nhance/app/Models/PartnerEndorsementRequestModel.php
venba-Inspriron-3558 0c0bd545b9 Retails endrosement 3
2025-09-09 16:50:30 +05:30

90 lines
2.6 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Models;
use CodeIgniter\Model;
class PartnerEndorsementRequestModel extends Model
{
protected $table = 'partner_endorsement_request';
protected $primaryKey = 'id';
// Auto-increment
protected $useAutoIncrement = true;
// Return type
protected $returnType = 'array';
// Soft deletes (youre using is_active instead of deleted_at, so keep it false)
protected $useSoftDeletes = false;
// Allowed fields (columns you want to insert/update)
protected $allowedFields = [
'id',
'client_id',
'client_policy_id',
'insurer_id',
'insurer_branch_id',
'policy_number',
'endorsement_no',
'endorsement_type',
'endorsement_description',
'updated_by',
'is_active',
'created_by',
'manager_id',
'agent_id',
'status',
];
public function getRetailEndorsementList($client_id, $insurers_id, $status)
{
$query = $this->db->table('partner_endorsement_request per')
->distinct()
->select('
per.id,
per.client_id,
per.client_policy_id,
per.insurer_id,
per.insurer_branch_id,
per.policy_number,
per.endorsement_no,
per.endorsement_type,
per.endorsement_description,
per.created_at,
per.updated_by,
per.updated_at,
per.is_active,
per.created_by,
per.manager_id,
per.agent_id,
per.status,
i.name as insurer_name,
i.short_name as insurer_short_name,
c.client_name,
c.short_name as client_short_name,
ps.name as manager_name,
pa.name as agent_name
')
->join('insurers as i', 'i.id = per.insurer_id', 'left')
->join('clients as c', 'c.id = per.client_id AND c.client_type = 2', 'left')
->join('partner_staff as ps', 'ps.id = per.manager_id AND ps.role_id = 1', 'left')
->join('partner_agent as pa', 'pa.id = per.agent_id', 'left');
if (!empty($status)) {
$query->where('per.status', $status);
}
if (!empty($client_id)) {
$query->where('per.client_id', $client_id);
}
if (!empty($insurers_id)) {
$query->where('per.insurer_id', $insurers_id);
}
$query->orderBy('per.id', 'desc');
return $query->get()->getResultArray();
}
}