GWM : Quotation name changed to Proposal
This commit is contained in:
parent
bf6a914ded
commit
f02c9b67ba
@ -74,7 +74,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
|||||||
$routes->post('enquiry/updateEnquiry', 'EnquiryController::updateEnquiry');
|
$routes->post('enquiry/updateEnquiry', 'EnquiryController::updateEnquiry');
|
||||||
$routes->get('enquiry/downloadEnquiryFile', 'EnquiryController::downloadEnquiryFile');
|
$routes->get('enquiry/downloadEnquiryFile', 'EnquiryController::downloadEnquiryFile');
|
||||||
|
|
||||||
//Quotation
|
//Proposal
|
||||||
$routes->get('quotation/quotationList', 'QuotationController::quotationList');
|
$routes->get('quotation/quotationList', 'QuotationController::quotationList');
|
||||||
$routes->get('quotation/findQuotation', 'QuotationController::findQuotation');
|
$routes->get('quotation/findQuotation', 'QuotationController::findQuotation');
|
||||||
$routes->post('quotation/createQuotation', 'QuotationController::createQuotation');
|
$routes->post('quotation/createQuotation', 'QuotationController::createQuotation');
|
||||||
|
|||||||
@ -92,7 +92,7 @@ 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 Proposal'", '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')
|
||||||
@ -101,7 +101,7 @@ class DashboardController extends ResourceController
|
|||||||
// // --- 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 = 'Proposal 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')
|
||||||
@ -112,7 +112,7 @@ class DashboardController extends ResourceController
|
|||||||
// // --- 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 = 'Proposal 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)
|
||||||
@ -126,9 +126,9 @@ class DashboardController extends ResourceController
|
|||||||
ps.id AS staff_id,
|
ps.id AS staff_id,
|
||||||
ph.name AS handler_name,
|
ph.name AS handler_name,
|
||||||
COUNT(pe.id) AS total_assigned,
|
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 = 'Awaiting Proposal' 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 = 'Proposal 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 = 'Proposal Accepted' THEN 1 ELSE 0 END) AS awaiting_policy,
|
||||||
SUM(CASE WHEN pe.status = 'Policy Created' THEN 1 ELSE 0 END) AS policy_created
|
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')
|
->join('partner_staff ps', 'ps.id = pe.assigned_to', 'left')
|
||||||
@ -185,9 +185,9 @@ class DashboardController extends ResourceController
|
|||||||
ps.name AS staff_name,
|
ps.name AS staff_name,
|
||||||
ps.id AS staff_id,
|
ps.id AS staff_id,
|
||||||
COUNT(pe.id) AS total_assigned,
|
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 = 'Awaiting Proposal' 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 = 'Proposal 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 = 'Proposal Accepted' THEN 1 ELSE 0 END) AS awaiting_policy,
|
||||||
SUM(CASE WHEN pe.status = 'Policy Created' THEN 1 ELSE 0 END) AS policy_created
|
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')
|
->join('partner_staff ps', 'ps.id = pe.assigned_to', 'left')
|
||||||
@ -237,21 +237,21 @@ class DashboardController extends ResourceController
|
|||||||
$staff_id = $this->request->getGet('staff_id');
|
$staff_id = $this->request->getGet('staff_id');
|
||||||
|
|
||||||
|
|
||||||
// --- Quotation pending for staff (last 30 days) ---
|
// --- Proposal pending for staff (last 30 days) ---
|
||||||
$quotationsPending = $this->db->table('partner_enquiry pe')
|
$quotationsPending = $this->db->table('partner_enquiry pe')
|
||||||
->select('pe.* ')
|
->select('pe.* ')
|
||||||
->where('pe.assigned_to',$staff_id)
|
->where('pe.assigned_to',$staff_id)
|
||||||
->whereIn('pe.status',["Awaiting Quotation","Quotation Rejected"])
|
->whereIn('pe.status',["Awaiting Proposal","Proposal Rejected"])
|
||||||
->orderBy('pe.created_on', 'DESC')
|
->orderBy('pe.created_on', 'DESC')
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
// --- Quotation Approval pending for staff (last 30 days) ---
|
// --- Proposal Approval pending for staff (last 30 days) ---
|
||||||
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
|
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
|
||||||
->select('pe.* ')
|
->select('pe.* ')
|
||||||
->where('pe.assigned_to',$staff_id)
|
->where('pe.assigned_to',$staff_id)
|
||||||
->whereIn('pe.status',["Quotation Created"])
|
->whereIn('pe.status',["Proposal Created"])
|
||||||
->orderBy('pe.created_on', 'DESC')
|
->orderBy('pe.created_on', 'DESC')
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
@ -262,7 +262,7 @@ class DashboardController extends ResourceController
|
|||||||
->join('partner_quotation Q', 'Q.enquiry_id = pe.id AND Q.status = "Accepted"', 'left')
|
->join('partner_quotation Q', 'Q.enquiry_id = pe.id AND Q.status = "Accepted"', 'left')
|
||||||
->join('insurers I', 'I.id = Q.insurer_id', 'left')
|
->join('insurers I', 'I.id = Q.insurer_id', 'left')
|
||||||
->where('pe.assigned_to',$staff_id)
|
->where('pe.assigned_to',$staff_id)
|
||||||
->whereIn('pe.status',["Quotation Accepted"])
|
->whereIn('pe.status',["Proposal Accepted"])
|
||||||
->orderBy('pe.created_on', 'DESC')
|
->orderBy('pe.created_on', 'DESC')
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
@ -332,17 +332,17 @@ class DashboardController extends ResourceController
|
|||||||
|
|
||||||
$last30 = date('Y-m-d H:i:s', strtotime('-30 days'));
|
$last30 = date('Y-m-d H:i:s', strtotime('-30 days'));
|
||||||
|
|
||||||
// --- Quotation pending for agent (last 30 days) ---
|
// --- Proposal pending for agent (last 30 days) ---
|
||||||
$quotationsPending = $this->db->table('partner_enquiry pe')
|
$quotationsPending = $this->db->table('partner_enquiry pe')
|
||||||
->select('pe.* ')
|
->select('pe.* ')
|
||||||
->where('pe.created_on >=', $last30)
|
->where('pe.created_on >=', $last30)
|
||||||
->where('pe.agent_id',$agent_id)
|
->where('pe.agent_id',$agent_id)
|
||||||
->whereIn('pe.status',["Awaiting Quotation","Quotation Rejected"])
|
->whereIn('pe.status',["Awaiting Proposal","Proposal Rejected"])
|
||||||
->orderBy('pe.created_on', 'DESC')
|
->orderBy('pe.created_on', 'DESC')
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
|
|
||||||
// --- Quotation approval pending for agent (last 30 days) ---
|
// --- Proposal approval pending for agent (last 30 days) ---
|
||||||
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
|
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
|
||||||
->select('pe.* ')
|
->select('pe.* ')
|
||||||
->where('pe.created_on >=', $last30)
|
->where('pe.created_on >=', $last30)
|
||||||
@ -359,7 +359,7 @@ class DashboardController extends ResourceController
|
|||||||
->join('insurers I', 'I.id = Q.insurer_id', 'left')
|
->join('insurers I', 'I.id = Q.insurer_id', 'left')
|
||||||
->where('pe.created_on >=', $last30)
|
->where('pe.created_on >=', $last30)
|
||||||
->where('pe.agent_id',$agent_id)
|
->where('pe.agent_id',$agent_id)
|
||||||
->where('pe.status','Quotation Accepted')
|
->where('pe.status','Proposal Accepted')
|
||||||
->orderBy('pe.created_on', 'DESC')
|
->orderBy('pe.created_on', 'DESC')
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
|
|||||||
@ -88,7 +88,8 @@ class EnquiryController extends ResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get enquiry details
|
//Get enquiry details
|
||||||
$enquiry = $this->enquiryModel->select('partner_enquiry.*')
|
$enquiry = $this->enquiryModel->select('partner_enquiry.* , I.name as insurer_name ')
|
||||||
|
->join('insurers I', 'I.id = partner_enquiry.insurer_id', 'left')
|
||||||
->where('partner_enquiry.id', $enquiry_id)
|
->where('partner_enquiry.id', $enquiry_id)
|
||||||
->where('partner_enquiry.is_active', 1)
|
->where('partner_enquiry.is_active', 1)
|
||||||
->first();
|
->first();
|
||||||
|
|||||||
@ -99,8 +99,8 @@ class QuotationController extends ResourceController
|
|||||||
trigger_email('quotation_created', ['quotation_id' => $id]);
|
trigger_email('quotation_created', ['quotation_id' => $id]);
|
||||||
|
|
||||||
//update enquiry status
|
//update enquiry status
|
||||||
$enquiryData = $this->EnquiryModel->where('id',$data['enquiry_id'])->where('status','Awaiting Quotation')->first();
|
$enquiryData = $this->EnquiryModel->where('id',$data['enquiry_id'])->where('status','Awaiting Proposal')->first();
|
||||||
if (!empty($enquiryData)){ $this->EnquiryModel->update($data['enquiry_id'], ['status'=>'Quotation Created']); }
|
if (!empty($enquiryData)){ $this->EnquiryModel->update($data['enquiry_id'], ['status'=>'Proposal Created']); }
|
||||||
|
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200);
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ class QuotationController extends ResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quotation status update
|
// Proposal status update
|
||||||
public function acceptOrRejectQuotation()
|
public function acceptOrRejectQuotation()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -184,11 +184,11 @@ class QuotationController extends ResourceController
|
|||||||
//update enquiry status
|
//update enquiry status
|
||||||
$enquiryData = $this->EnquiryModel->where('id',$quotation['enquiry_id'])
|
$enquiryData = $this->EnquiryModel->where('id',$quotation['enquiry_id'])
|
||||||
->groupStart()
|
->groupStart()
|
||||||
->where('status', 'Quotation Created')
|
->where('status', 'Proposal Created')
|
||||||
->orWhere('status', 'Quotation Rejected')
|
->orWhere('status', 'Proposal Rejected')
|
||||||
->groupEnd()
|
->groupEnd()
|
||||||
->first();
|
->first();
|
||||||
$enqStatus = 'Quotation '.$data['status'];
|
$enqStatus = 'Proposal '.$data['status'];
|
||||||
if (!empty($enquiryData)){
|
if (!empty($enquiryData)){
|
||||||
$this->EnquiryModel->update($quotation['enquiry_id'], ['status'=> $enqStatus]);
|
$this->EnquiryModel->update($quotation['enquiry_id'], ['status'=> $enqStatus]);
|
||||||
if( $newStatus == 'Accepted'){
|
if( $newStatus == 'Accepted'){
|
||||||
|
|||||||
@ -61,7 +61,7 @@ if (!function_exists('trigger_email')) {
|
|||||||
$agentData = $agentModel->where(['id' => $quotationData['agent_id'] ])->first();
|
$agentData = $agentModel->where(['id' => $quotationData['agent_id'] ])->first();
|
||||||
|
|
||||||
$to_email = $agentData['email'];
|
$to_email = $agentData['email'];
|
||||||
$subject = "Quotation Created";
|
$subject = "Proposal Created";
|
||||||
$message = "<p>A new quotation #{$data['quotation_id']} has been created for you.</p>";
|
$message = "<p>A new quotation #{$data['quotation_id']} has been created for you.</p>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ if (!function_exists('trigger_email')) {
|
|||||||
$staffData = $staffModel->where(['id' => $quotationData['assigned_to'] , 'role_id' => 2 ])->first();
|
$staffData = $staffModel->where(['id' => $quotationData['assigned_to'] , 'role_id' => 2 ])->first();
|
||||||
|
|
||||||
$to_email = $staffData['email']; // assigned staff
|
$to_email = $staffData['email']; // assigned staff
|
||||||
$subject = "Quotation Accepted";
|
$subject = "Proposal Accepted";
|
||||||
$message = "<p>Quotation #{$data['quotation_id']} was accepted.</p>";
|
$message = "<p>Proposal #{$data['quotation_id']} was accepted.</p>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'quotation_rejected':
|
case 'quotation_rejected':
|
||||||
@ -79,8 +79,8 @@ if (!function_exists('trigger_email')) {
|
|||||||
$staffData = $staffModel->where(['id' => $quotationData['assigned_to'] , 'role_id' => 2 ])->first();
|
$staffData = $staffModel->where(['id' => $quotationData['assigned_to'] , 'role_id' => 2 ])->first();
|
||||||
|
|
||||||
$to_email = $staffData['email']; // assigned staff
|
$to_email = $staffData['email']; // assigned staff
|
||||||
$subject = "Quotation Rejected";
|
$subject = "Proposal Rejected";
|
||||||
$message = "<p>Quotation #{$data['quotation_id']} was rejected.</p>";
|
$message = "<p>Proposal #{$data['quotation_id']} was rejected.</p>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'policy_created':
|
case 'policy_created':
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class EnquiryModel extends Model
|
|||||||
->join('partner_agent A', 'A.id = partner_enquiry.agent_id', 'left')
|
->join('partner_agent A', 'A.id = partner_enquiry.agent_id', 'left')
|
||||||
->join('partner_staff S', 'S.id = partner_enquiry.assigned_to', 'left')
|
->join('partner_staff S', 'S.id = partner_enquiry.assigned_to', 'left')
|
||||||
->join('partner_quotation Q', 'Q.enquiry_id = partner_enquiry.id AND Q.status = "Accepted"', 'left')
|
->join('partner_quotation Q', 'Q.enquiry_id = partner_enquiry.id AND Q.status = "Accepted"', 'left')
|
||||||
->join('insurers I', 'I.id = Q.insurer_id', 'left')
|
->join('insurers I', 'I.id = partner_enquiry.insurer_id', 'left')
|
||||||
->join('partner_policy P', 'P.quotation_id = Q.id', 'left')
|
->join('partner_policy P', 'P.quotation_id = Q.id', 'left')
|
||||||
->where('partner_enquiry.is_active', 1)
|
->where('partner_enquiry.is_active', 1)
|
||||||
->orderBy('partner_enquiry.created_on', 'ASC');
|
->orderBy('partner_enquiry.created_on', 'ASC');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user