GWM : proceed quot api
This commit is contained in:
parent
9bcfd21af5
commit
1622552d8f
@ -41,13 +41,15 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
||||
$routes->get('master/getInsurersMaster', 'MasterController::getInsurersMaster');
|
||||
$routes->get('master/getStaffMaster', 'MasterController::getStaffMaster');
|
||||
$routes->get('master/getAllBrokers', 'MasterController::getAllBrokers');
|
||||
$routes->post('master/createBroker', 'PartnerPaymentModeController::createBroker');
|
||||
$routes->post('master/updateBroker/(:num)', 'PartnerPaymentModeController::updateBroker/$1');
|
||||
$routes->post('master/updateBrokerStatus/(:num)', 'PartnerPaymentModeController::updateBrokerStatus/$1');
|
||||
$routes->get('master/getAllPaymentModelist', 'getAllPaymentModelist::list');
|
||||
$routes->post('master/createPaymentMode', 'PartnerPaymentModeController::createPaymentMode');
|
||||
$routes->post('master/updatePaymentMode/(:num)', 'PartnerPaymentModeController::updatePaymentMode/$1');
|
||||
$routes->post('master/updatePaymentModeStatus/(:num)', 'PartnerPaymentModeController::updatePaymentModeStatus/$1');
|
||||
$routes->post('master/createBroker', 'MasterController::createBroker');
|
||||
$routes->post('master/updateBroker/(:num)', 'MasterController::updateBroker/$1');
|
||||
$routes->post('master/updateBrokerStatus/(:num)', 'MasterController::updateBrokerStatus/$1');
|
||||
$routes->get('master/getAllPaymentModelist', 'MasterController::getAllPaymentModelist');
|
||||
$routes->post('master/createPaymentMode', 'MasterController::createPaymentMode');
|
||||
$routes->post('master/updatePaymentMode/(:num)', 'MasterController::updatePaymentMode/$1');
|
||||
$routes->post('master/updatePaymentModeStatus/(:num)', 'MasterController::updatePaymentModeStatus/$1');
|
||||
|
||||
|
||||
|
||||
//Agent
|
||||
$routes->get('agent/agentList', 'AgentController::agentList');
|
||||
@ -93,6 +95,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
||||
$routes->post('quotation/updateQuotation', 'QuotationController::updateQuotation');
|
||||
$routes->post('quotation/acceptOrRejectQuotation', 'QuotationController::acceptOrRejectQuotation');
|
||||
$routes->get('quotation/downloadAdditionalUploadedFile', 'QuotationController::downloadAdditionalUploadedFile');
|
||||
$routes->post('quotation/proceedQuotation', 'QuotationController::proceedQuotation');
|
||||
|
||||
|
||||
//policy
|
||||
|
||||
@ -4,11 +4,13 @@ namespace App\Controllers;
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
use App\Models\QuotationModel;
|
||||
use App\Models\EnquiryModel;
|
||||
use App\Models\PolicyModel;
|
||||
|
||||
class QuotationController extends ResourceController
|
||||
{
|
||||
protected $QuotationModel;
|
||||
protected $EnquiryModel;
|
||||
protected $PolicyModel;
|
||||
protected $db;
|
||||
|
||||
public function __construct()
|
||||
@ -16,6 +18,7 @@ class QuotationController extends ResourceController
|
||||
$this->db = db_connect();
|
||||
$this->QuotationModel = new QuotationModel();
|
||||
$this->EnquiryModel = new EnquiryModel();
|
||||
$this->PolicyModel = new PolicyModel();
|
||||
}
|
||||
|
||||
// List quotations
|
||||
@ -246,4 +249,97 @@ class QuotationController extends ResourceController
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function proceedQuotation()
|
||||
{
|
||||
try {
|
||||
$data = $this->request->getPost();
|
||||
|
||||
|
||||
//get insurer_branch_id
|
||||
$query = $this->db->query("SELECT id FROM insurer_branch WHERE insurer_id = ? LIMIT 1", [$data['insurer_id']]);
|
||||
$insurerBranchresult = $query->getRowArray();
|
||||
|
||||
// create quotation
|
||||
$insertData = [
|
||||
'enquiry_id' => $data['enquiry_id'],
|
||||
'insured_declared_value' => $data['insured_declared_value'],
|
||||
'premium_amount' => $data['premium_amount'],
|
||||
'insurance_plan_type_id' => $data['insurance_plan_type_id'],
|
||||
'insurer_id' => $data['insurer_id'],
|
||||
'insurer_branch_id' => $insurerBranchresult['id'] ?? 0,
|
||||
'created_by' => $data['created_by'],
|
||||
'status' => 'Accepted',
|
||||
'manager_id' => $data['manager_id'],
|
||||
'payment_mode_id' => $data['payment_mode_id'] ?? 0 ,
|
||||
];
|
||||
|
||||
$quotationId = $this->QuotationModel->insert($insertData, true);
|
||||
|
||||
// update enquiry
|
||||
$enquiryArray = [
|
||||
'broker_id' => $data['broker_id'] ?? 0 ,
|
||||
'vehicle_type_id' => $data['vehicle_type_id'] ?? 0 ,
|
||||
'status'=> 'Proposal Accepted'
|
||||
];
|
||||
$this->EnquiryModel->update($data['enquiry_id'], $enquiryArray );
|
||||
|
||||
|
||||
//create policy file
|
||||
$uploadPath = WRITEPATH . 'uploads/policy/';
|
||||
$policyPdf = $this->request->getFile('policy_pdf_file_name');
|
||||
$pdfFileName = null;
|
||||
// PDF Upload
|
||||
if ($policyPdf && $policyPdf->isValid()) {
|
||||
$pdfPath = $uploadPath . 'policy_pdf/';
|
||||
if (!is_dir($pdfPath)) {
|
||||
mkdir($pdfPath, 0777, true);
|
||||
}
|
||||
$pdfFileName = time() . '_' . $policyPdf->getRandomName();
|
||||
$policyPdf->move($pdfPath, $pdfFileName);
|
||||
|
||||
|
||||
//fetch enquiry_id & agent_id
|
||||
$quotData = $this->QuotationModel->select('partner_quotation.*,E.agent_id,E.name')
|
||||
->join('partner_enquiry E', 'E.id = partner_quotation.enquiry_id', 'left')
|
||||
->where('partner_quotation.id',$quotationId)
|
||||
->first();
|
||||
$insertPolicyData = [
|
||||
'enquiry_id' => $quotData['enquiry_id'],
|
||||
'quotation_id' => $quotationId,
|
||||
'insured_name' => $quotData['name'],
|
||||
'manager_id' => $quotData['manager_id'],
|
||||
'agent_id' => $quotData['agent_id'],
|
||||
'policy_pdf_file_name' => $pdfFileName,
|
||||
'created_by' => $data['created_by']
|
||||
];
|
||||
|
||||
$policyId = $this->PolicyModel->insert($insertPolicyData);
|
||||
|
||||
//update enquiry status
|
||||
if (!empty($quotData)){
|
||||
$this->EnquiryModel->update($quotData['enquiry_id'], ['status'=> 'Policy Created'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,8 @@ class QuotationModel extends Model
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'action_by',
|
||||
'action_user'
|
||||
'action_user',
|
||||
'payment_mode_id'
|
||||
];
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user