MERGE_TEST_RFQ_FOR_REVIEW

This commit is contained in:
Venba 2024-11-11 11:05:00 +00:00
commit da589deb5f
7 changed files with 248 additions and 112 deletions

View File

@ -248,7 +248,7 @@ class ClientController extends AdminController
$headerData['page_name'] = 'Client List'; $headerData['page_name'] = 'Client List';
$data['clientList'] = $this->clientModel->getCreatedByUserName(); $data['clientList'] = $this->clientModel->getCreatedByUserName();
$data['client_rm'] = $this->clientRMModel->getAllClientRM(); $data['client_rm'] = $this->clientRMModel->getAllClientRM();
$data['lead_data'] = $this->leadsModel->getLeadForInsertClientList(); // $data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
// dd($data); // dd($data);

View File

@ -302,7 +302,7 @@ class EmpDataServiceController extends BaseController
], ],
[ [
'column_index' => 18, 'column_index' => 18,
'column_name' => 'PR0 RATA PREMIUM', 'column_name' => 'PRO RATA PREMIUM',
'db_column_name' => 'rata_premimum' 'db_column_name' => 'rata_premimum'
], ],
[ [
@ -1281,7 +1281,7 @@ class EmpDataServiceController extends BaseController
unset($excel_data[0]); unset($excel_data[0]);
// array_pop($excel_data); // array_pop($excel_data);
$inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATIONSHIP CODE','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PR0 RATA PREMIUM','GST','TOTAL AMOUNT']; $inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATIONSHIP CODE','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PRO RATA PREMIUM','GST','TOTAL AMOUNT'];
foreach ($inceptionHeader as $key => $value) { foreach ($inceptionHeader as $key => $value) {
if($excel_header[$key] != $value){ if($excel_header[$key] != $value){

View File

@ -87,22 +87,31 @@ class EmployeeController extends AdminController
{ {
// $model = new UserModel(); // $model = new UserModel();
$data = []; $data = [];
$data['status'] = ['draft' => 'Draft', 'active' => 'Active', 'inactive' => 'In-Active', 'pending' => 'Pending']; $data['status'] = ['draft' => 'Draft', 'enrolled' => 'Enrolled', 'active' => 'Active', 'inactive' => 'In-Active', 'pending' => 'Pending'];
if (count($this->request->getGet())) { if (count($this->request->getGet())) {
$filterData = $this->request->getGet(); $filterData = $this->request->getGet();
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(
client_id: $filterData['client_id'],
policy_id: $filterData['policy_id'],
branch_id: $filterData['branch_id'],
emp_code : $filterData['emp_code'],
emp_name : $filterData['emp_name'],
status : $filterData['status'],
);
// dd($this->employeePolicyModel->getLastQuery());
// Convert the status field to an array if it exists in the request data
if (isset($filterData['status'])) {
$filterData['status'] = explode(",", $filterData['status']);
}
// Fetch employees with the modified $filterData array
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(
client_id: $filterData['client_id'] ?? null,
policy_id: $filterData['policy_id'] ?? null,
branch_id: $filterData['branch_id'] ?? null,
emp_code : $filterData['emp_code'] ?? null,
emp_name : $filterData['emp_name'] ?? null,
status : $filterData['status'] ?? [],
);
// Set getData in $data array with the processed $filterData
$data['getData'] = $filterData; $data['getData'] = $filterData;
} }
// dd($this->employeeModel->getLastQuery());
// dd( $data['getData']); // dd( $data['getData']);
// dd($this->request->getGet()); // dd($this->request->getGet());

View File

@ -509,18 +509,23 @@ class LeadsController extends BaseController
$subHeaderRow = $rowNumber + 1; $subHeaderRow = $rowNumber + 1;
$columnLetter = 'A'; $columnLetter = 'A';
// Add headers in the first row and subheaders in the second row // Set column width and apply word wrap to headers and subheaders
foreach ($headers as $header) { foreach ($headers as $header) {
if ($header['parentHeader'] === 'Item Key' || $header['parentHeader'] == 'Action') { if ($header['parentHeader'] === 'Item Key' || $header['parentHeader'] == 'Action') {
continue; // Skip "Item Key" and "Action" columns continue; // Skip "Item Key" and "Action" columns
} }
if($header['parentHeader'] === 'Sno'){ if ($header['parentHeader'] === 'Sno') {
$header['parentHeader'] = 'S.No.'; $header['parentHeader'] = 'S.No.';
} }
// Set the header cell value
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $header['parentHeader']); $sheet->setCellValue("{$columnLetter}{$rowNumber}", $header['parentHeader']);
// Set column width for header
$sheet->getColumnDimension($columnLetter)->setWidth(20); // Adjust width as needed
$sheet->getStyle("{$columnLetter}{$rowNumber}")->getAlignment()->setWrapText(true);
// Apply bold style to the header // Apply bold style to the header
$sheet->getStyle("{$columnLetter}{$rowNumber}")->applyFromArray([ $sheet->getStyle("{$columnLetter}{$rowNumber}")->applyFromArray([
'font' => [ 'font' => [
@ -528,9 +533,13 @@ class LeadsController extends BaseController
], ],
]); ]);
// Add subheaders in the second row
foreach ($header['subHeaders'] as $subHeader) { foreach ($header['subHeaders'] as $subHeader) {
$sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader); $sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader);
// Enable word wrap for subheaders
$sheet->getStyle("{$columnLetter}{$subHeaderRow}")->getAlignment()->setWrapText(true);
// Apply bold style to the subheader // Apply bold style to the subheader
$sheet->getStyle("{$columnLetter}{$subHeaderRow}")->applyFromArray([ $sheet->getStyle("{$columnLetter}{$subHeaderRow}")->applyFromArray([
'font' => [ 'font' => [
@ -545,7 +554,7 @@ class LeadsController extends BaseController
// Move to next row for data entries // Move to next row for data entries
$rowNumber = $subHeaderRow + 1; $rowNumber = $subHeaderRow + 1;
// Add data rows // Add data rows and enable word wrap for data cells
foreach ($data['table_data']['data'] as $dataRow) { foreach ($data['table_data']['data'] as $dataRow) {
$columnLetter = 'A'; $columnLetter = 'A';
foreach ($dataRow['data'] as $cellData) { foreach ($dataRow['data'] as $cellData) {
@ -553,11 +562,20 @@ class LeadsController extends BaseController
continue; // Skip "Item Key" data continue; // Skip "Item Key" data
} }
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['value']); $sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['value']);
// Enable word wrap for data cells
$sheet->getStyle("{$columnLetter}{$rowNumber}")->getAlignment()->setWrapText(true);
$columnLetter++; $columnLetter++;
} }
$rowNumber++; $rowNumber++;
} }
// Auto-size all columns after data is entered
foreach ($sheet->getColumnIterator() as $column) {
$sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true);
}
// Set filename based on type // Set filename based on type
$string = ($type == 2) ? 'QCR' : 'RFQ'; $string = ($type == 2) ? 'QCR' : 'RFQ';
$filename = $string . '_' . $rfq_data['client_short_name'] . '_' . $rfq_data['policy_type'] . '_' . date('Ymdhis') . '.xlsx'; $filename = $string . '_' . $rfq_data['client_short_name'] . '_' . $rfq_data['policy_type'] . '_' . date('Ymdhis') . '.xlsx';
@ -586,7 +604,8 @@ class LeadsController extends BaseController
$recipient_type = $params['recipient_type'];//insurer or client $recipient_type = $params['recipient_type'];//insurer or client
$recipient_mail = $params['recipient_mail'];// - only primary key of contacts $recipient_mail = $params['recipient_mail'];// - only primary key of contacts
$recipient_mail = json_decode($params['recipient_mail'], true);;// - only primary key of contacts $recipient_mail = json_decode($params['recipient_mail'], true);;// - only primary key of contacts
$cc = 'velz1990@gmail.com,vitvelz@gmail.com'; // $cc = 'velz1990@gmail.com,vitvelz@gmail.com';
$cc = "";
$result_data = []; $result_data = [];
// dd($recipient_mail); // dd($recipient_mail);

View File

@ -78,6 +78,7 @@ class EmployeePolicyModel extends Model
// ---------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------
public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="") public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="")
{ {
// dd($status);
$result = $this->select([ $result = $this->select([
'employee_polices.*', 'employee_polices.*',
@ -132,17 +133,39 @@ class EmployeePolicyModel extends Model
if ($policy_id !=0 && !empty($policy_id)) { if ($policy_id !=0 && !empty($policy_id)) {
$result->where('employee_polices.client_policy_id', $policy_id); $result->where('employee_polices.client_policy_id', $policy_id);
} }
if ($status !=0 && !empty($status)) {
if($status == 'active'){ if (is_array($status) && count($status) > 0) {
$result->where('employee_polices.status !=', 'expired');
if (in_array("active", $status)) {
$result->where('employee_polices.tpa_id IS NOT NULL'); $result->where('employee_polices.tpa_id IS NOT NULL');
$result->where('employee_polices.uhid IS NOT NULL'); $result->where('employee_polices.uhid IS NOT NULL');
}else if($status == 'pending'){ $result->whereIn('employee_polices.status', $status);
$status = 'active';
$result->where('employee_polices.status', $status); } elseif (in_array("pending", $status)) {
}else{
$result->where('employee_polices.status', $status); $result->where('employee_polices.tpa_id IS NULL');
$result->where('employee_polices.uhid IS NULL');
$result->whereIn('employee_polices.status', array_merge($status, ['active']));
} else {
$result->whereIn('employee_polices.status', $status);
} }
// if($status == 'active'){
// $result->where('employee_polices.tpa_id IS NOT NULL');
// $result->where('employee_polices.uhid IS NOT NULL');
// }else if($status == 'pending'){
// $status = 'active';
// $result->where('employee_polices.status', $status);
// }else{
// $result->where('employee_polices.status', $status);
// }
} }
if (!empty($emp_code)) { if (!empty($emp_code)) {
$result->where('emp.emp_code', $emp_code); $result->where('emp.emp_code', $emp_code);
} }
@ -568,10 +591,10 @@ class EmployeePolicyModel extends Model
deletiondata.reasonforexit, deletiondata.reasonforexit,
deletiondata.status, deletiondata.status,
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) AS no_of_days, DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1 AS no_of_days,
ROUND((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365, 2) AS pro_rata_premium, ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365, 2) AS pro_rata_premium,
ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18, 2) AS gst, ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365) * 0.18, 2) AS gst,
ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) + (((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18), 2) AS total ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365) + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365) * 0.18), 2) AS total
FROM FROM
emp_endorsement a emp_endorsement a
LEFT JOIN LEFT JOIN

View File

@ -7,6 +7,17 @@
table.dataTable tbody td { table.dataTable tbody td {
padding: 4px 4px !important; padding: 4px 4px !important;
} }
.select2-selection__choice {
background-color: #0a8794 !important;
color: white !important;
font-weight: bold;
}
.select2-selection__choice__remove {
color: white !important;
margin-right: 5px;
}
</style> </style>
<div class="row"> <div class="row">
@ -48,17 +59,22 @@ table.dataTable tbody td {
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label>Status</label> <br /> <label>Status</label> <br />
<select class="form-control" id="status2"> <select class="form-control" name="status2[]" id="status2" multiple>
<option value="0">Select</option> <option value="0">Select</option>
<?php foreach($status as $key => $value) { ?> <?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>" <option value="<?= $key ?>"
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>> <?php
if ((!isset($getData) || count($getData['status']) == 0) && $key == 'active') {
echo 'selected';
}
?>>
<?= $value ?> <?= $value ?>
</option> </option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label>Employee Code</label> <br /> <label>Employee Code</label> <br />
<input type="text" class="form-control" id="emp_code" name="emp_code" value="<?= isset($getData['emp_code']) && !empty($getData['emp_code']) ? $getData['emp_code'] : '' ?>"> <input type="text" class="form-control" id="emp_code" name="emp_code" value="<?= isset($getData['emp_code']) && !empty($getData['emp_code']) ? $getData['emp_code'] : '' ?>">
@ -106,6 +122,13 @@ $(document).ready(function() {
$("#policies").select2(); $("#policies").select2();
$("#branch_id").select2(); $("#branch_id").select2();
$("#status2").select2({
placeholder : 'Select Status'
});
$("textarea.select2-search__field").attr('rows', '1');
$("textarea.select2-search__field").css('resize', 'none');
// if ($('.select2-selection__arrow').length > 0) { // if ($('.select2-selection__arrow').length > 0) {
// $('.select2-selection__arrow').removeClass('select2-selection__arrow').addClass('fa fa-chevron-down'); // $('.select2-selection__arrow').removeClass('select2-selection__arrow').addClass('fa fa-chevron-down');
// } // }
@ -119,11 +142,22 @@ var clientPoliciesWithBranch = {
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>'; var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>'; var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
var statusData = <?= json_encode(isset($getData['status']) ? $getData['status'] : []) ?>;
$(document).ready(function() {
// Loop through each item in statusData and set the option as selected.
statusData.forEach(function(status) {
$('#status2 option[value="' + status + '"]').prop('selected', true);
});
// Refresh the select element (necessary if you are using a plugin like Select2).
$('#status2').trigger('change');
});
$(document).ready(function() { $(document).ready(function() {
console.log("document loaded"); console.log("document loaded");
//fetchClientPolicies(); //fetchClientPolicies();
}); });
$(window).on("load", function() { $(window).on("load", function() {
@ -330,6 +364,11 @@ function fetchEmpolyeeList(event) {
var emp_code = $('#emp_code').val(); var emp_code = $('#emp_code').val();
var emp_name = $('#emp_name').val(); var emp_name = $('#emp_name').val();
var statusArray = [];
$('#status2 option:selected').each(function() {
statusArray.push($(this).val());
});
// console.log(client_id + '-' + policy_id); // console.log(client_id + '-' + policy_id);
// if (client_id == '0' || policy_id == '0') { // if (client_id == '0' || policy_id == '0') {
// alert('Please select values in both dropdowns.'); // alert('Please select values in both dropdowns.');
@ -343,7 +382,7 @@ function fetchEmpolyeeList(event) {
branch_id: branch_id, branch_id: branch_id,
emp_code : emp_code, emp_code : emp_code,
emp_name : emp_name, emp_name : emp_name,
status : status, status : statusArray,
}; };
const queryString = objectToQueryString(queryParams); const queryString = objectToQueryString(queryParams);

View File

@ -216,6 +216,7 @@ body {
<button id="submitMail"class="btn btn-primary" onclick="showModal()">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 : '' ?>"> <input type="hidden" id="lead_id" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
<input type="hidden" id="qcr_count" value="<?= isset($qcr_count) ? $qcr_count : 0 ?>">
<!-- <button id="openDialogBtn">Open Dialog</button> --> <!-- <button id="openDialogBtn">Open Dialog</button> -->
<div class="table-container"> <div class="table-container">
@ -765,6 +766,7 @@ function moveAddRowButton() {
// Event listener to handle row removal // Event listener to handle row removal
rfqTable.addEventListener('click', function(e) { rfqTable.addEventListener('click', function(e) {
if (e.target.classList.contains('removeRow')) { if (e.target.classList.contains('removeRow')) {
const row = e.target.closest('tr'); // Get the row to be removed const row = e.target.closest('tr'); // Get the row to be removed
const rowKey = row.getAttribute('id'); const rowKey = row.getAttribute('id');
@ -778,6 +780,7 @@ rfqTable.addEventListener('click', function(e) {
moveAddRowButton(); // Move the add row button to the last row moveAddRowButton(); // Move the add row button to the last row
realignSpecialConditions(); realignSpecialConditions();
} }
}); });
// Function to add new columns // Function to add new columns
@ -1670,8 +1673,16 @@ function changeInsurer(event) {
function changeState(event) { function changeState(event) {
var type = event.target.className; let type = event.target.className;
console.log(type); console.log('1 : ', type);
// if (type.includes('sendClientProposal') && type.includes('fa fa-check-square')) {
// type = 'sendClientProposal';
// } else if (type.includes('qcrProposal') && type.includes('fa fa-check-square')) {
// type = 'qcrProposal';
// }
// console.log('2 : ',type);
if (['qcrProposal', 'sendClientProposal'].includes(type)) { if (['qcrProposal', 'sendClientProposal'].includes(type)) {
@ -2175,6 +2186,7 @@ function showModal(){
} }
function ajaxRequestForGetMailData(url){ function ajaxRequestForGetMailData(url){
$.ajax({ $.ajax({
url: url, url: url,
type: "GET", type: "GET",
@ -2212,7 +2224,7 @@ function appendInput(data) {
if (!data.contact_person_email) { if (!data.contact_person_email) {
html += ` html += `
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<a href="${url}">Click here to add mail</a> <a href="${url}">Click here to update mail ID</a>
</div> </div>
`; `;
} }
@ -2282,36 +2294,49 @@ function constructURL() {
} }
function ajaxRequest(url){ function ajaxRequest(url){
console.log(url); console.log(url);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({ $.ajax({
url: url, url: url,
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
success: function (res) { success: function (res) {
console.log(res); $('.loader').fadeOut();
if(res.status == 'success' && res.code == 200){ $('.loader-mask').delay(350).fadeOut('slow');
toastr.success('Mail send Successfully', 'SUCCESS')
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{ }else{
if(res.messgae){ toastr.error('Mail send failed', 'ERROR')
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);
} }
$('.close').click()
},
error: function (xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error(xhr.responseText);
console.error(status, error);
}
}); });
} }
//-------------------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------------------------
// not in use do not remove this function
function tableToJson() { function tableToJson() {
const headers = []; const headers = [];
@ -2522,14 +2547,14 @@ function jsonToTable(json) {
proposel_count++; proposel_count++;
// Extract qcr and stc status for the main headers // Extract qcr and stc status for the main headers
const dropdown_data_qcr = proposels[header.parentHeader]?.qcr === 1 ? const dropdown_data_qcr = proposels[header.parentHeader]?.qcr == 1 ?
'style="background-color: rgb(221, 221, 221);"' : ''; 'style="background-color: rgb(221, 221, 221);"' : '';
const dropdown_data_stc = proposels[header.parentHeader]?.stc === 1 ? const dropdown_data_stc = proposels[header.parentHeader]?.stc == 1 ?
'style="background-color: rgb(221, 221, 221);"' : ''; 'style="background-color: rgb(221, 221, 221);"' : '';
const check_icon_qcr = proposels[header.parentHeader]?.qcr === 1 ? const check_icon_qcr = proposels[header.parentHeader]?.qcr == 1 ?
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : ''; `<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : '';
const check_icon_stc = proposels[header.parentHeader]?.stc === 1 ? const check_icon_stc = proposels[header.parentHeader]?.stc == 1 ?
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : ''; `<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : '';
@ -2539,7 +2564,7 @@ function jsonToTable(json) {
<div class="dropdown-content"> <div class="dropdown-content">
<a href="#" class="addInsurer">Add Insurer</a> <a href="#" class="addInsurer">Add Insurer</a>
<a href="#" class="qcrProposal" ${dropdown_data_qcr}>QCR${check_icon_qcr}</a> <a href="#" class="qcrProposal" ${dropdown_data_qcr}>QCR${check_icon_qcr}</a>
<a href="#" class="sendClientProposal" ${dropdown_data_stc}>Send to Client${check_icon_qcr}</a> <a href="#" class="sendClientProposal" ${dropdown_data_stc}>Send to Client${check_icon_stc}</a>
<a href="#" class="removeProposal">Remove</a> <a href="#" class="removeProposal">Remove</a>
</div> </div>
</span>`; </span>`;
@ -2603,15 +2628,15 @@ function jsonToTable(json) {
const insurerData = proposels[header.parentHeader]?.insurers[index - 1] || {}; const insurerData = proposels[header.parentHeader]?.insurers[index - 1] || {};
dropdownDataQCRForInsurer = insurerData.qcr === 1 ? dropdownDataQCRForInsurer = insurerData.qcr == 1 ?
'style="background-color: rgb(221, 221, 221);"' : ''; 'style="background-color: rgb(221, 221, 221);"' : '';
dropdownDataSTCForInsurer = insurerData.stc === 1 ? dropdownDataSTCForInsurer = insurerData.stc == 1 ?
'style="background-color: rgb(221, 221, 221);"' : ''; 'style="background-color: rgb(221, 221, 221);"' : '';
checkDropdownDataQCRForInsurer = insurerData.qcr === 1 ? checkDropdownDataQCRForInsurer = insurerData.qcr == 1 ?
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : `<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` :
''; '';
checkDropdownDataSTCForInsurer = insurerData.stc === 1 ? checkDropdownDataSTCForInsurer = insurerData.stc == 1 ?
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : `<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` :
''; '';
@ -2814,57 +2839,72 @@ function jsonToTable(json) {
console.log(over_all_column_data); console.log(over_all_column_data);
try { let qcr_count = $('#qcr_count').val()
let lead_id = $('#lead_id').val()
$('.loader').fadeIn(); if(qcr_count != 0){
$('.loader-mask').fadeIn();
const jsonData = await convertJsonForQCR(); // Construct the JSON data console.log('qcr found')
// Create a FormData object url = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2;
const formData = new FormData(); window.location.href = url;
let lead_id = $('#lead_id').val(); }else{
formData.append('json', JSON.stringify(jsonData)); console.log('qcr not found')
formData.append('lead_id', lead_id);
const postUrl = '<?= base_url('rfq/createQCR')?>'; try {
console.log(postUrl);
const response = await $.ajax({ $('.loader').fadeIn();
url: postUrl, $('.loader-mask').fadeIn();
type: 'POST',
data: formData,
processData: false, // Important to prevent jQuery from processing the data
contentType: false, // Important to set this to false to let jQuery set the content type correctly
});
console.log('Data sent successfully:', response); const jsonData = await convertJsonForQCR(); // Construct the JSON data
if(response.status == true){
toastr.success(response.message, 'SUCCESS');
}else{
toastr.warning(response.message, 'WARNING');
}
window.location.href = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2; // Create a FormData object
const formData = new FormData();
} catch (error) { let lead_id = $('#lead_id').val();
console.error('An error occurred during the AJAX request:');
if (error.responseText) { formData.append('json', JSON.stringify(jsonData));
try { formData.append('lead_id', lead_id);
const errorResponse = JSON.parse(error.responseText);
console.error('Server Response:', errorResponse); const postUrl = '<?= base_url('rfq/createQCR')?>';
} catch (parseError) { console.log(postUrl);
console.error('Error Message:', error.message);
console.error('Could not parse error response:', error.responseText); const response = await $.ajax({
url: postUrl,
type: 'POST',
data: formData,
processData: false, // Important to prevent jQuery from processing the data
contentType: false, // Important to set this to false to let jQuery set the content type correctly
});
console.log('Data sent successfully:', response);
if(response.status == true){
toastr.success(response.message, 'SUCCESS');
}else{
toastr.warning(response.message, 'WARNING');
} }
} else {
console.error('Error Message:', error.message);
}
console.error('Full Error Object:', error); window.location.href = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2;
} catch (error) {
console.error('An error occurred during the AJAX request:');
if (error.responseText) {
try {
const errorResponse = JSON.parse(error.responseText);
console.error('Server Response:', errorResponse);
} catch (parseError) {
console.error('Error Message:', error.message);
console.error('Could not parse error response:', error.responseText);
}
} else {
console.error('Error Message:', error.message);
}
console.error('Full Error Object:', error);
}
} }
}); });
}); });
@ -2882,15 +2922,21 @@ function jsonToTable(json) {
let headerIndex = 0; let headerIndex = 0;
parentHeaders.forEach((header) => { parentHeaders.forEach((header) => {
console.log('header names', header);
console.log('header header.innerText', header.innerText);
const colspan = header.getAttribute('colspan') || 1; const colspan = header.getAttribute('colspan') || 1;
const subHeaderArray = []; const subHeaderArray = [];
for (let i = 0; i < colspan; i++) { for (let i = 0; i < colspan; i++) {
subHeaderArray.push(subHeaders[headerIndex].innerText.replace('⋮', '').trim()); const cleanedText = subHeaders[headerIndex].innerText.split('⋮')[0].trim();
subHeaderArray.push(cleanedText);
headerIndex++; headerIndex++;
} }
headers.push({ headers.push({
parentHeader: header.innerText.replace('⋮', '').trim(), parentHeader: header.innerText.split('⋮')[0].trim(),
subHeaders: subHeaderArray subHeaders: subHeaderArray
}); });
}); });