diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4fc57ef..1f807d4 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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'); diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 114cbc8..9455626 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -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(); diff --git a/app/Controllers/EnquiryController.php b/app/Controllers/EnquiryController.php index b71e83e..3c7e792 100644 --- a/app/Controllers/EnquiryController.php +++ b/app/Controllers/EnquiryController.php @@ -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(); diff --git a/app/Controllers/QuotationController.php b/app/Controllers/QuotationController.php index cfd8a4c..1b4d552 100644 --- a/app/Controllers/QuotationController.php +++ b/app/Controllers/QuotationController.php @@ -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'){ diff --git a/app/Helpers/mail_helper.php b/app/Helpers/mail_helper.php index f7da95f..4ba67cc 100644 --- a/app/Helpers/mail_helper.php +++ b/app/Helpers/mail_helper.php @@ -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 = "
A new quotation #{$data['quotation_id']} has been created for you.
"; 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 = "Quotation #{$data['quotation_id']} was accepted.
"; + $subject = "Proposal Accepted"; + $message = "Proposal #{$data['quotation_id']} was accepted.
"; 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 = "Quotation #{$data['quotation_id']} was rejected.
"; + $subject = "Proposal Rejected"; + $message = "Proposal #{$data['quotation_id']} was rejected.
"; break; case 'policy_created': diff --git a/app/Models/EnquiryModel.php b/app/Models/EnquiryModel.php index 8db533d..2aa2117 100644 --- a/app/Models/EnquiryModel.php +++ b/app/Models/EnquiryModel.php @@ -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');