GWM
This commit is contained in:
parent
b4dd5aab1d
commit
b0d2031e33
@ -99,6 +99,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
|||||||
|
|
||||||
//dashboard
|
//dashboard
|
||||||
$routes->get('dashboard/managerDashboard', 'DashboardController::managerDashboard');
|
$routes->get('dashboard/managerDashboard', 'DashboardController::managerDashboard');
|
||||||
|
$routes->get('dashboard/handlerDashboard', 'DashboardController::handlerDashboard');
|
||||||
$routes->get('dashboard/staffDashboard', 'DashboardController::staffDashboard');
|
$routes->get('dashboard/staffDashboard', 'DashboardController::staffDashboard');
|
||||||
$routes->get('dashboard/agentDashboard', 'DashboardController::agentDashboard');
|
$routes->get('dashboard/agentDashboard', 'DashboardController::agentDashboard');
|
||||||
|
|
||||||
|
|||||||
@ -118,6 +118,19 @@ class ClaimController extends ResourceController
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$uploadFile = $this->request->getFile('claim_file_name');
|
||||||
|
$uploadedFileName = null;
|
||||||
|
|
||||||
|
if ($uploadFile && $uploadFile->isValid()) {
|
||||||
|
$uploadPath = WRITEPATH . 'uploads/claims/';
|
||||||
|
if (!is_dir($uploadPath)) {
|
||||||
|
mkdir($uploadPath, 0777, true);
|
||||||
|
}
|
||||||
|
$uploadedFileName = time() . '_' . $uploadFile->getRandomName();
|
||||||
|
$uploadFile->move($uploadPath, $uploadedFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$status = $this->ClaimStatusModel->where('ticket_type', 8)->first();
|
$status = $this->ClaimStatusModel->where('ticket_type', 8)->first();
|
||||||
|
|
||||||
// Prepare claim data for ticket_master
|
// Prepare claim data for ticket_master
|
||||||
@ -139,6 +152,7 @@ class ClaimController extends ResourceController
|
|||||||
'claim_type' => $reqData['claim_type'],
|
'claim_type' => $reqData['claim_type'],
|
||||||
'claim_description'=> $reqData['claim_description'],
|
'claim_description'=> $reqData['claim_description'],
|
||||||
'created_by' => $reqData['created_by'] ?? null,
|
'created_by' => $reqData['created_by'] ?? null,
|
||||||
|
'claim_file_name' => $uploadedFileName,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Insert claim
|
// Insert claim
|
||||||
|
|||||||
@ -89,35 +89,54 @@ class DashboardController extends ResourceController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --- Staff level Quotations Pending ---
|
// // --- Staff level Quotations Pending ---
|
||||||
$quotationsPending = $this->db->table('partner_staff ps')
|
// $quotationsPending = $this->db->table('partner_staff ps')
|
||||||
->select('ps.name as staff_name, COUNT(pe.id) as total_quotation_pending')
|
// ->select('ps.name as staff_name, COUNT(pe.id) as total_quotation_pending')
|
||||||
->join('partner_enquiry pe', "pe.assigned_to = ps.id AND pe.status = 'Awaiting Quotation'", 'left')
|
// ->join('partner_enquiry pe', "pe.assigned_to = ps.id AND pe.status = 'Awaiting Quotation'", 'left')
|
||||||
->where('ps.role_id', 2)
|
// ->where('ps.role_id', 2)
|
||||||
->where('ps.manager_id',$manager_id)
|
// ->where('ps.manager_id',$manager_id)
|
||||||
->groupBy('ps.id, ps.name')
|
// ->groupBy('ps.id, ps.name')
|
||||||
->get()->getResultArray();
|
// ->get()->getResultArray();
|
||||||
|
|
||||||
// --- Staff level Quotations Approva Pending ---
|
// // --- Staff level Quotations Approva Pending ---
|
||||||
$quotationsApprovalPending = $this->db->table('partner_staff ps')
|
// $quotationsApprovalPending = $this->db->table('partner_staff ps')
|
||||||
->select('ps.name as staff_name, COUNT(pe.id) as total_approval_pending')
|
// ->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')
|
// ->join('partner_enquiry pe', "pe.assigned_to = ps.id AND pe.status = 'Quotation Created'", 'left')
|
||||||
->where('ps.role_id', 2)
|
// ->where('ps.role_id', 2)
|
||||||
->where('ps.manager_id',$manager_id)
|
// ->where('ps.manager_id',$manager_id)
|
||||||
->groupBy('ps.id, ps.name')
|
// ->groupBy('ps.id, ps.name')
|
||||||
->get()->getResultArray();
|
// ->get()->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --- Staff level Policies Pending ---
|
// // --- Staff level Policies Pending ---
|
||||||
$policiesPending = $this->db->table('partner_staff ps')
|
// $policiesPending = $this->db->table('partner_staff ps')
|
||||||
->select('ps.name as staff_name, COUNT(pe.id) as total_policis_pending, SUM(pq.premium_amount) as total_premium_value')
|
// ->select('ps.name as staff_name, COUNT(pe.id) as total_policis_pending, SUM(pq.premium_amount) as total_premium_value')
|
||||||
->join('partner_enquiry pe', "pe.assigned_to = ps.id AND pe.status = 'Quotation Accepted'", 'left')
|
// ->join('partner_enquiry pe', "pe.assigned_to = ps.id AND pe.status = 'Quotation Accepted'", 'left')
|
||||||
->join('partner_quotation pq', "pq.enquiry_id = pe.id AND pq.status = 'Accepted'", 'left')
|
// ->join('partner_quotation pq', "pq.enquiry_id = pe.id AND pq.status = 'Accepted'", 'left')
|
||||||
->where('ps.role_id', 2)
|
// ->where('ps.role_id', 2)
|
||||||
->where('ps.manager_id',$manager_id)
|
// ->where('ps.manager_id',$manager_id)
|
||||||
->groupBy('ps.id, ps.name')
|
// ->groupBy('ps.id, ps.name')
|
||||||
->get()->getResultArray();
|
// ->get()->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
$staffLevelPendingSummary = $this->db->table('partner_enquiry pe')
|
||||||
|
->select("
|
||||||
|
ps.name AS staff_name,
|
||||||
|
ps.id AS staff_id,
|
||||||
|
COUNT(pe.id) AS total_assigned,
|
||||||
|
SUM(CASE WHEN pe.status = 'Awaiting Quotation' THEN 1 ELSE 0 END) AS awaiting_quotation,
|
||||||
|
SUM(CASE WHEN pe.status = 'Quotation Created' THEN 1 ELSE 0 END) AS pending_quotation_approval,
|
||||||
|
SUM(CASE WHEN pe.status = 'Quotation Accepted' THEN 1 ELSE 0 END) AS awaiting_policy,
|
||||||
|
SUM(CASE WHEN pe.status = 'Policy Created' THEN 1 ELSE 0 END) AS policy_created
|
||||||
|
")
|
||||||
|
->join('partner_staff ps', 'ps.id = pe.assigned_to', 'left')
|
||||||
|
->where('pe.manager_id', $manager_id)
|
||||||
|
->where('pe.is_active', 1)
|
||||||
|
->groupBy('pe.assigned_to')
|
||||||
|
->orderBy('ps.name', 'ASC')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
$result = [
|
$result = [
|
||||||
@ -138,14 +157,52 @@ class DashboardController extends ResourceController
|
|||||||
],
|
],
|
||||||
'agents_performance' => $performanceAgents,
|
'agents_performance' => $performanceAgents,
|
||||||
'unassigned_enquiry' => $unassignedEnquiry,
|
'unassigned_enquiry' => $unassignedEnquiry,
|
||||||
'quotations_pending' => $quotationsPending,
|
// 'quotations_pending' => $quotationsPending,
|
||||||
'quotations_approval_pending' => $quotationsApprovalPending,
|
// 'quotations_approval_pending' => $quotationsApprovalPending,
|
||||||
'policies_pending' => $policiesPending,
|
// 'policies_pending' => $policiesPending,
|
||||||
|
'staff_level_pending_summary' => $staffLevelPendingSummary
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function handlerDashboard()
|
||||||
|
{
|
||||||
|
$handler_id = $this->request->getGet('handler_id');
|
||||||
|
|
||||||
|
if (empty($handler_id)) {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'Handler ID is required.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$staffLevelPendingSummary = $this->db->table('partner_enquiry pe')
|
||||||
|
->select("
|
||||||
|
ps.name AS staff_name,
|
||||||
|
ps.id AS staff_id,
|
||||||
|
COUNT(pe.id) AS total_assigned,
|
||||||
|
SUM(CASE WHEN pe.status = 'Awaiting Quotation' THEN 1 ELSE 0 END) AS awaiting_quotation,
|
||||||
|
SUM(CASE WHEN pe.status = 'Quotation Created' THEN 1 ELSE 0 END) AS pending_quotation_approval,
|
||||||
|
SUM(CASE WHEN pe.status = 'Quotation Accepted' THEN 1 ELSE 0 END) AS awaiting_policy,
|
||||||
|
SUM(CASE WHEN pe.status = 'Policy Created' THEN 1 ELSE 0 END) AS policy_created
|
||||||
|
")
|
||||||
|
->join('partner_staff ps', 'ps.id = pe.assigned_to', 'left')
|
||||||
|
->where('ps.handler_id', $handler_id)
|
||||||
|
->where('pe.is_active', 1)
|
||||||
|
->groupBy('pe.assigned_to')
|
||||||
|
->orderBy('ps.name', 'ASC')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'staff_level_pending_summary' => $staffLevelPendingSummary
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function staffDashboard()
|
public function staffDashboard()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,7 @@ class EndorsementController extends ResourceController
|
|||||||
|
|
||||||
|
|
||||||
public function createEndorsement()
|
public function createEndorsement()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$reqData = $this->request->getJSON(true);
|
$reqData = $this->request->getJSON(true);
|
||||||
|
|
||||||
@ -107,6 +107,19 @@ class EndorsementController extends ResourceController
|
|||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => 'Policy not found'], 200);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => 'Policy not found'], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$uploadFile = $this->request->getFile('endorsement_file_name');
|
||||||
|
$uploadedFileName = null;
|
||||||
|
|
||||||
|
if ($uploadFile && $uploadFile->isValid()) {
|
||||||
|
$uploadPath = WRITEPATH . 'uploads/endorsement/';
|
||||||
|
if (!is_dir($uploadPath)) {
|
||||||
|
mkdir($uploadPath, 0777, true);
|
||||||
|
}
|
||||||
|
$uploadedFileName = time() . '_' . $uploadFile->getRandomName();
|
||||||
|
$uploadFile->move($uploadPath, $uploadedFileName);
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare endorsement data
|
// Prepare endorsement data
|
||||||
$endorsementData = [
|
$endorsementData = [
|
||||||
'policy_number' => $policy['policy_number'],
|
'policy_number' => $policy['policy_number'],
|
||||||
@ -121,6 +134,7 @@ class EndorsementController extends ResourceController
|
|||||||
'endorsement_no' => $reqData['endorsement_no'] ?? null,
|
'endorsement_no' => $reqData['endorsement_no'] ?? null,
|
||||||
'created_by' => $reqData['created_by'] ?? null,
|
'created_by' => $reqData['created_by'] ?? null,
|
||||||
'status' => 'Open',
|
'status' => 'Open',
|
||||||
|
'endorsement_file_name' => $uploadedFileName,
|
||||||
'is_active' => 1
|
'is_active' => 1
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -146,7 +160,7 @@ class EndorsementController extends ResourceController
|
|||||||
'data' => $e->getMessage()
|
'data' => $e->getMessage()
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,7 @@ class ClaimModel extends Model
|
|||||||
'vehicle_id',
|
'vehicle_id',
|
||||||
'claim_description',
|
'claim_description',
|
||||||
'is_active',
|
'is_active',
|
||||||
|
'claim_file_name'
|
||||||
];
|
];
|
||||||
|
|
||||||
// Auto timestamps
|
// Auto timestamps
|
||||||
|
|||||||
@ -23,6 +23,7 @@ class EndorsementModel extends Model
|
|||||||
'endorsement_type',
|
'endorsement_type',
|
||||||
'endorsement_description',
|
'endorsement_description',
|
||||||
'status',
|
'status',
|
||||||
|
'endorsement_file_name',
|
||||||
'created_at',
|
'created_at',
|
||||||
'updated_by',
|
'updated_by',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user