GWM : Quotation name changed to Proposal

This commit is contained in:
Gowtham M 2025-10-15 10:32:39 +05:30
parent bf6a914ded
commit f02c9b67ba
6 changed files with 33 additions and 32 deletions

View File

@ -74,7 +74,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
$routes->post('enquiry/updateEnquiry', 'EnquiryController::updateEnquiry');
$routes->get('enquiry/downloadEnquiryFile', 'EnquiryController::downloadEnquiryFile');
//Quotation
//Proposal
$routes->get('quotation/quotationList', 'QuotationController::quotationList');
$routes->get('quotation/findQuotation', 'QuotationController::findQuotation');
$routes->post('quotation/createQuotation', 'QuotationController::createQuotation');

View File

@ -92,7 +92,7 @@ class DashboardController extends ResourceController
// // --- Staff level Quotations Pending ---
// $quotationsPending = $this->db->table('partner_staff ps')
// ->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.manager_id',$manager_id)
// ->groupBy('ps.id, ps.name')
@ -101,7 +101,7 @@ class DashboardController extends ResourceController
// // --- 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')
// ->join('partner_enquiry pe', "pe.assigned_to = ps.id AND pe.status = 'Proposal Created'", 'left')
// ->where('ps.role_id', 2)
// ->where('ps.manager_id',$manager_id)
// ->groupBy('ps.id, ps.name')
@ -112,7 +112,7 @@ class DashboardController extends ResourceController
// // --- Staff level Policies Pending ---
// $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')
// ->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')
// ->where('ps.role_id', 2)
// ->where('ps.manager_id',$manager_id)
@ -126,9 +126,9 @@ class DashboardController extends ResourceController
ps.id AS staff_id,
ph.name AS handler_name,
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 = 'Awaiting Proposal' THEN 1 ELSE 0 END) AS awaiting_quotation,
SUM(CASE WHEN pe.status = 'Proposal Created' THEN 1 ELSE 0 END) AS pending_quotation_approval,
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
")
->join('partner_staff ps', 'ps.id = pe.assigned_to', 'left')
@ -185,9 +185,9 @@ class DashboardController extends ResourceController
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 = 'Awaiting Proposal' THEN 1 ELSE 0 END) AS awaiting_quotation,
SUM(CASE WHEN pe.status = 'Proposal Created' THEN 1 ELSE 0 END) AS pending_quotation_approval,
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
")
->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');
// --- Quotation pending for staff (last 30 days) ---
// --- Proposal pending for staff (last 30 days) ---
$quotationsPending = $this->db->table('partner_enquiry pe')
->select('pe.* ')
->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')
->get()
->getResultArray();
// --- Quotation Approval pending for staff (last 30 days) ---
// --- Proposal Approval pending for staff (last 30 days) ---
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
->select('pe.* ')
->where('pe.assigned_to',$staff_id)
->whereIn('pe.status',["Quotation Created"])
->whereIn('pe.status',["Proposal Created"])
->orderBy('pe.created_on', 'DESC')
->get()
->getResultArray();
@ -262,7 +262,7 @@ class DashboardController extends ResourceController
->join('partner_quotation Q', 'Q.enquiry_id = pe.id AND Q.status = "Accepted"', 'left')
->join('insurers I', 'I.id = Q.insurer_id', 'left')
->where('pe.assigned_to',$staff_id)
->whereIn('pe.status',["Quotation Accepted"])
->whereIn('pe.status',["Proposal Accepted"])
->orderBy('pe.created_on', 'DESC')
->get()
->getResultArray();
@ -332,17 +332,17 @@ class DashboardController extends ResourceController
$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')
->select('pe.* ')
->where('pe.created_on >=', $last30)
->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')
->get()
->getResultArray();
// --- Quotation approval pending for agent (last 30 days) ---
// --- Proposal approval pending for agent (last 30 days) ---
$quotationsApprovalPending = $this->db->table('partner_enquiry pe')
->select('pe.* ')
->where('pe.created_on >=', $last30)
@ -359,7 +359,7 @@ class DashboardController extends ResourceController
->join('insurers I', 'I.id = Q.insurer_id', 'left')
->where('pe.created_on >=', $last30)
->where('pe.agent_id',$agent_id)
->where('pe.status','Quotation Accepted')
->where('pe.status','Proposal Accepted')
->orderBy('pe.created_on', 'DESC')
->get()
->getResultArray();

View File

@ -88,7 +88,8 @@ class EnquiryController extends ResourceController
}
//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.is_active', 1)
->first();

View File

@ -99,8 +99,8 @@ class QuotationController extends ResourceController
trigger_email('quotation_created', ['quotation_id' => $id]);
//update enquiry status
$enquiryData = $this->EnquiryModel->where('id',$data['enquiry_id'])->where('status','Awaiting Quotation')->first();
if (!empty($enquiryData)){ $this->EnquiryModel->update($data['enquiry_id'], ['status'=>'Quotation Created']); }
$enquiryData = $this->EnquiryModel->where('id',$data['enquiry_id'])->where('status','Awaiting Proposal')->first();
if (!empty($enquiryData)){ $this->EnquiryModel->update($data['enquiry_id'], ['status'=>'Proposal Created']); }
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()
{
try {
@ -184,11 +184,11 @@ class QuotationController extends ResourceController
//update enquiry status
$enquiryData = $this->EnquiryModel->where('id',$quotation['enquiry_id'])
->groupStart()
->where('status', 'Quotation Created')
->orWhere('status', 'Quotation Rejected')
->where('status', 'Proposal Created')
->orWhere('status', 'Proposal Rejected')
->groupEnd()
->first();
$enqStatus = 'Quotation '.$data['status'];
$enqStatus = 'Proposal '.$data['status'];
if (!empty($enquiryData)){
$this->EnquiryModel->update($quotation['enquiry_id'], ['status'=> $enqStatus]);
if( $newStatus == 'Accepted'){

View File

@ -61,7 +61,7 @@ if (!function_exists('trigger_email')) {
$agentData = $agentModel->where(['id' => $quotationData['agent_id'] ])->first();
$to_email = $agentData['email'];
$subject = "Quotation Created";
$subject = "Proposal Created";
$message = "<p>A new quotation #{$data['quotation_id']} has been created for you.</p>";
break;
@ -70,8 +70,8 @@ if (!function_exists('trigger_email')) {
$staffData = $staffModel->where(['id' => $quotationData['assigned_to'] , 'role_id' => 2 ])->first();
$to_email = $staffData['email']; // assigned staff
$subject = "Quotation Accepted";
$message = "<p>Quotation #{$data['quotation_id']} was accepted.</p>";
$subject = "Proposal Accepted";
$message = "<p>Proposal #{$data['quotation_id']} was accepted.</p>";
break;
case 'quotation_rejected':
@ -79,8 +79,8 @@ if (!function_exists('trigger_email')) {
$staffData = $staffModel->where(['id' => $quotationData['assigned_to'] , 'role_id' => 2 ])->first();
$to_email = $staffData['email']; // assigned staff
$subject = "Quotation Rejected";
$message = "<p>Quotation #{$data['quotation_id']} was rejected.</p>";
$subject = "Proposal Rejected";
$message = "<p>Proposal #{$data['quotation_id']} was rejected.</p>";
break;
case 'policy_created':

View File

@ -53,7 +53,7 @@ class EnquiryModel extends Model
->join('partner_agent A', 'A.id = partner_enquiry.agent_id', '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('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')
->where('partner_enquiry.is_active', 1)
->orderBy('partner_enquiry.created_on', 'ASC');