FEAT_RFQ_MAIL_GET_FROM_MODAL_DATA : RV
This commit is contained in:
parent
e910797ea0
commit
de8049eaed
@ -300,6 +300,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("send_manual_reminder/(:any)", "DashboardController::sendManualReminder/$1");
|
||||
$routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1");
|
||||
$routes->get("get_client_branch_data/(:any)", "ClientController::get_client_branch_data/$1");
|
||||
$routes->get("getLevelContects", "LeadsController::getLevelContects");
|
||||
|
||||
});
|
||||
|
||||
@ -348,6 +349,13 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||
});
|
||||
|
||||
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create", "LeadsController::createRFQ");
|
||||
$routes->post("createQCR", "LeadsController::createQCR");
|
||||
$routes->get("list/(:any)", "LeadsController::viewRFQ/$1");
|
||||
});
|
||||
|
||||
|
||||
$routes->get("driveListFiles", "GoogleDriveController::listFiles");
|
||||
$routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
|
||||
$routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
|
||||
|
||||
@ -344,7 +344,7 @@ class LeadsController extends BaseController
|
||||
$data['page_name'] = isset($data['rfq_data']['type']) && $data['rfq_data']['type'] == 2 ? 'QCR' : 'RFQ';
|
||||
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
|
||||
|
||||
$data['lead_data'] = $this->leadsModel->where('leads.id', $id)->where('leads.is_active', 1)->first();
|
||||
// dd($data);
|
||||
$this->loadLayout('view_rfq.php', $data);
|
||||
}
|
||||
@ -642,5 +642,17 @@ class LeadsController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function getLevelContects(){
|
||||
|
||||
$data = $this->levelContactModel->getContectForRFQ();
|
||||
|
||||
if($data){
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -25,4 +25,28 @@ class LevelContactModel extends Model
|
||||
"token_time_out"
|
||||
];
|
||||
|
||||
|
||||
public function getContectForRFQ(){
|
||||
|
||||
$result = $this
|
||||
|
||||
->select('
|
||||
level_contacts.id,
|
||||
insurers.short_name as insurer_name,
|
||||
insurer_branch.branch_code,
|
||||
level_contacts.name as contect_person_name,
|
||||
level_contacts.email as contect_person_email,
|
||||
')
|
||||
->join('insurer_branch', 'level_contacts.ref_id = insurer_branch.id')
|
||||
->join('insurers', 'insurer_branch.insurer_id = insurers.id')
|
||||
->where('level_contacts.contact_type', 'insurer')
|
||||
->where('level_contacts.is_active', 1)
|
||||
->where('insurer_branch.is_active', 1)
|
||||
->where('insurers.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -278,6 +278,8 @@
|
||||
|
||||
//SELECT2 document ready function
|
||||
$(document).ready(function() {
|
||||
|
||||
getURLParamsForReport()
|
||||
addHTMLInput()
|
||||
setTimeout(function() {
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
@ -870,19 +872,20 @@ function tpaChange(input, unique_id) {
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
function getURLParamsForReport() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const pt_id = params.get('pt_id') ?? 0;
|
||||
|
||||
if (pt_id != 0) {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const lead_id = params.get('lead_id') ?? 0;
|
||||
|
||||
if (lead_id != 0) {
|
||||
hide_list_show_add();
|
||||
setTimeout(() =>
|
||||
getPolicyTransactionDataForEdit(pt_id),
|
||||
getLeadsDataForEdit(lead_id),
|
||||
1500); // Reduced timeout
|
||||
} else {
|
||||
show_list_hide_add();
|
||||
}
|
||||
|
||||
console.log('pt_id', pt_id); // Retain the log if necessary
|
||||
console.log('lead_id', lead_id); // Retain the log if necessary
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -202,7 +202,7 @@ body {
|
||||
<button id="submitData" class="btn btn-primary">Save</button>
|
||||
<button id="submitQCRData"class="btn btn-primary">Save QCR</button>
|
||||
<a id="submitExcel"class="btn btn-primary" id>Export Excel</a>
|
||||
<button id="submitMail"class="btn btn-primary">Send Mail</button>
|
||||
<button id="submitMail"class="btn btn-primary" onclick="showModal()">Send Mail</button>
|
||||
|
||||
<input type="hidden" id="lead_id" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
|
||||
<!-- <button id="openDialogBtn">Open Dialog</button> -->
|
||||
@ -316,6 +316,29 @@ body {
|
||||
</div>
|
||||
<!-- familiy floater dialog end -->
|
||||
|
||||
|
||||
<!-- Center modal content -->
|
||||
<div class="modal fade" id="list_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel"></h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<div class="form-row" id="input_for_row">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL()">Send Mail</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
|
||||
var suggestionKeys = []; // Local variable to store keys
|
||||
@ -2093,6 +2116,156 @@ function hideQCR(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showModal(){
|
||||
|
||||
var url = '';
|
||||
var lead_id = $('#lead_id').val();
|
||||
|
||||
if(RFQ_or_QCR == 2){
|
||||
$('#myCenterModalLabel').text('Client Data')
|
||||
url = '<?= base_url('leads/list/') ?>' + lead_id;
|
||||
}else{
|
||||
$('#myCenterModalLabel').text('Insurer Data')
|
||||
url = '<?= base_url('util/getLevelContects') ?>'
|
||||
}
|
||||
|
||||
ajaxRequestForGetMailData(url);
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('list_model'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
function ajaxRequestForGetMailData(url){
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
appendInput(res.data)
|
||||
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendInput(data) {
|
||||
|
||||
console.log(data);
|
||||
var lead_id = $('#lead_id').val();
|
||||
$('#input_for_row').empty();
|
||||
let html = '';
|
||||
|
||||
if (RFQ_or_QCR == 2) {
|
||||
|
||||
const url = '<?= base_url('leads/list') ?>?lead_id=' +lead_id;
|
||||
|
||||
html = `
|
||||
<div class="form-group col-md-8">
|
||||
<label for="contact_mail">Client Contact Mail</label>
|
||||
<input value="${data.contact_person_email || ''}" type="text" id="contact_mail" class="form-control" placeholder="Contact Mail">
|
||||
</div>
|
||||
`;
|
||||
|
||||
if (!data.contact_person_email) {
|
||||
html += `
|
||||
<div class="form-group col-md-8">
|
||||
<a href="${url}">Click here to add mail</a>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
} else {
|
||||
// Assuming `data.contacts` is an array of contact objects within the main data object
|
||||
const contacts = data || {};
|
||||
|
||||
html = `
|
||||
<div class="form-group col-md-12">
|
||||
<label for="insurerContact">Insurers</label>
|
||||
<select id="insurerContact" class="form-control" name="insurerContact[]" multiple>
|
||||
<option></option>
|
||||
`;
|
||||
|
||||
// Loop through each contact property within the `contacts` object
|
||||
for (const id in contacts) {
|
||||
const contact = contacts[id];
|
||||
html += `
|
||||
<option value="${contact.id}">${contact.insurer_name} - ${contact.branch_code} - ${contact.contect_person_name} - ${contact.contect_person_email}</option>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `
|
||||
</select>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
$('#input_for_row').append(html);
|
||||
|
||||
// Initialize select2 for the dropdown if insurerContact is present
|
||||
if ($('#insurerContact').length) {
|
||||
$('#insurerContact').select2();
|
||||
}
|
||||
}
|
||||
|
||||
function constructURL() {
|
||||
|
||||
var lead_id = $('#lead_id').val();
|
||||
var apiURL;
|
||||
|
||||
if (RFQ_or_QCR == 2) {
|
||||
apiURL = '<?= base_url('leads/sendMail') ?>?lead_id=' + encodeURIComponent(lead_id) +
|
||||
'&file_type=qcr' +
|
||||
'&recipient_type=client' +
|
||||
'&recipient_mail=';
|
||||
} else {
|
||||
|
||||
var insurerContact = $('#insurerContact').val();
|
||||
insurerContact = insurerContact.map(Number);
|
||||
console.log(insurerContact);
|
||||
|
||||
apiURL = '<?= base_url('leads/sendMail') ?>?lead_id=' + encodeURIComponent(lead_id) +
|
||||
'&file_type=rfq' +
|
||||
'&recipient_type=insurer' +
|
||||
'&recipient_mail=' + JSON.stringify(insurerContact);
|
||||
}
|
||||
|
||||
console.log(apiURL);
|
||||
ajaxRequest(apiURL);
|
||||
}
|
||||
|
||||
function ajaxRequest(url){
|
||||
console.log(url);
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
console.log(res);
|
||||
if(res.status == 'success' && res.code == 200){
|
||||
toastr.success('Mail send Successfully', 'SUCCESS')
|
||||
}else{
|
||||
if(res.messgae){
|
||||
toastr.error(res.messgae, 'ERROR')
|
||||
}else{
|
||||
toastr.error('Mail send failed', 'ERROR')
|
||||
}
|
||||
}
|
||||
|
||||
$('.close').click()
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function tableToJson() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user