GWM : dashboard api changes
This commit is contained in:
parent
df1c339d1d
commit
2dbb0ad464
@ -6,6 +6,7 @@ use App\Models\ClaimModel;
|
||||
use App\Models\PolicyModel;
|
||||
use App\Models\EnquiryModel;
|
||||
use App\Models\QuotationModel;
|
||||
use App\Models\ClaimStatusModel;
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
|
||||
class ClaimController extends ResourceController
|
||||
@ -15,6 +16,7 @@ class ClaimController extends ResourceController
|
||||
protected $PolicyModel;
|
||||
protected $QuotationModel;
|
||||
protected $EnquiryModel;
|
||||
protected $ClaimStatusModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -23,6 +25,7 @@ class ClaimController extends ResourceController
|
||||
$this->PolicyModel = new PolicyModel();
|
||||
$this->QuotationModel = new QuotationModel();
|
||||
$this->EnquiryModel = new EnquiryModel();
|
||||
$this->ClaimStatusModel = new ClaimStatusModel();
|
||||
}
|
||||
|
||||
// Get all tickets
|
||||
@ -115,10 +118,12 @@ class ClaimController extends ResourceController
|
||||
], 200);
|
||||
}
|
||||
|
||||
$status = $this->ClaimStatusModel->where('ticket_type', 8)->first();
|
||||
|
||||
// Prepare claim data for ticket_master
|
||||
$claimData = [
|
||||
'ticket_type_id' => 8,
|
||||
'claim_status_id' => 1,
|
||||
'claim_status_id' => $status['id'],
|
||||
'policy_no' => $policy['policy_number'],
|
||||
'client_policy_id' => $policy['client_policy_id'],
|
||||
'insurer_id' => $policy['insurer_id'],
|
||||
|
||||
@ -77,6 +77,13 @@ class DashboardController extends ResourceController
|
||||
->getResultArray();
|
||||
|
||||
|
||||
// --- Un assigned enquiry ---
|
||||
$unassignedEnquiry = $this->db->table('partner_enquiry pe')
|
||||
->where('pe.assigned_to', null)
|
||||
->where('pe.manager_id', $manager_id)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
|
||||
// --- Staff level Quotations Pending ---
|
||||
@ -88,6 +95,15 @@ class DashboardController extends ResourceController
|
||||
->groupBy('ps.id, ps.name')
|
||||
->get()->getResultArray();
|
||||
|
||||
// --- Staff level Quotations Approva Pending ---
|
||||
$quotationsApprovalPending = $this->db->table('partner_staff ps')
|
||||
->select('ps.name as staff_name, COUNT(pe.id) as total_approval_pending')
|
||||
->join('partner_enquiry pe', "pe.assigned_to = ps.id AND pe.status = 'Quotation Created'", 'left')
|
||||
->where('ps.role_id', 2)
|
||||
->where('ps.manager_id',$manager_id)
|
||||
->groupBy('ps.id, ps.name')
|
||||
->get()->getResultArray();
|
||||
|
||||
|
||||
|
||||
// --- Staff level Policies Pending ---
|
||||
@ -117,9 +133,11 @@ class DashboardController extends ResourceController
|
||||
'month' => $earningsMonth,
|
||||
'year' => $earningsYear,
|
||||
],
|
||||
'agents_performance' => $performanceAgents,
|
||||
'quotations_pending' => $quotationsPending,
|
||||
'policies_pending' => $policiesPending,
|
||||
'agents_performance' => $performanceAgents,
|
||||
'unassigned_enquiry' => $unassignedEnquiry,
|
||||
'quotations_pending' => $quotationsPending,
|
||||
'quotations_approval_pending' => $quotationsApprovalPending,
|
||||
'policies_pending' => $policiesPending,
|
||||
];
|
||||
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||
@ -136,7 +154,18 @@ class DashboardController extends ResourceController
|
||||
->select('pe.* , I.name as insurer_name, I.short_name as insurer_short_name')
|
||||
->join('insurers I', 'I.id = pe.insurer_id', 'left')
|
||||
->where('pe.assigned_to',$staff_id)
|
||||
->where('pe.status','Awaiting Quotation')
|
||||
->whereIn('pe.status',["Awaiting Quotation","Quotation Rejected"])
|
||||
->orderBy('pe.created_on', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
// --- Quotation Approval pending for staff (last 30 days) ---
|
||||
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
|
||||
->select('pe.* , I.name as insurer_name, I.short_name as insurer_short_name')
|
||||
->join('insurers I', 'I.id = pe.insurer_id', 'left')
|
||||
->where('pe.assigned_to',$staff_id)
|
||||
->whereIn('pe.status',["Quotation Created"])
|
||||
->orderBy('pe.created_on', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
@ -146,13 +175,15 @@ class DashboardController extends ResourceController
|
||||
->select('pe.* , I.name as insurer_name, I.short_name as insurer_short_name')
|
||||
->join('insurers I', 'I.id = pe.insurer_id', 'left')
|
||||
->where('pe.assigned_to',$staff_id)
|
||||
->where('pe.status','Quotation Accepted')
|
||||
->whereIn('pe.status',["Quotation Accepted"])
|
||||
->orderBy('pe.created_on', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$result = [
|
||||
'quotations_pending' => $quotationsPending,
|
||||
'quotations_approval_pending' => $quotationsApprovalPending,
|
||||
'quotations_rejected' => $quotationsApprovalPending,
|
||||
'policies_pending' => $policiesPending,
|
||||
];
|
||||
|
||||
@ -220,7 +251,18 @@ class DashboardController extends ResourceController
|
||||
->join('insurers I', 'I.id = pe.insurer_id', 'left')
|
||||
->where('pe.created_on >=', $last30)
|
||||
->where('pe.agent_id',$agent_id)
|
||||
->where('pe.status','Awaiting Quotation')
|
||||
->whereIn('pe.status',["Awaiting Quotation","Quotation Rejected"])
|
||||
->orderBy('pe.created_on', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
// --- Quotation approval pending for agent (last 30 days) ---
|
||||
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
|
||||
->select('pe.* , I.name as insurer_name , I.short_name as insurer_short_name')
|
||||
->join('insurers I', 'I.id = pe.insurer_id', 'left')
|
||||
->where('pe.created_on >=', $last30)
|
||||
->where('pe.agent_id',$agent_id)
|
||||
->whereIn('pe.status',["Awaiting Created"])
|
||||
->orderBy('pe.created_on', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
@ -253,6 +295,7 @@ class DashboardController extends ResourceController
|
||||
'year' => $earningsYear,
|
||||
],
|
||||
'quotations_pending' => $quotationsPending,
|
||||
'quotations_approval_pending' => $quotationsApprovalPending,
|
||||
'policies_pending' => $policiesPending,
|
||||
];
|
||||
|
||||
|
||||
41
app/Models/ClaimStatusModel.php
Normal file
41
app/Models/ClaimStatusModel.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ClaimStatusModel extends Model
|
||||
{
|
||||
protected $table = 'ticket_claim_status';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $returnType = 'array'; // or 'object' if you prefer
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = [
|
||||
'ticket_type',
|
||||
'claim_status',
|
||||
'allowed_status',
|
||||
'trigger_type',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
// Timestamps (use created_at, updated_at from DB)
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $dateFormat = 'datetime'; // works fine with timestamp
|
||||
|
||||
// Validation rules (optional)
|
||||
protected $validationRules = [
|
||||
'claim_status' => 'required|max_length[40]',
|
||||
'allowed_status' => 'max_length[250]',
|
||||
'is_active' => 'in_list[0,1]'
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user