FIX_RFQ_MODULE

This commit is contained in:
Srinivas-Saravanan 2025-02-15 11:40:17 +05:30
parent ea9fb8dbc7
commit 91cc9f812c
3 changed files with 1494 additions and 1006 deletions

View File

@ -64,6 +64,9 @@ class LeadsController extends BaseController
protected $clientType; protected $clientType;
protected $leadType; protected $leadType;
protected $leadsStatus; protected $leadsStatus;
protected $claim_type_for_gpa;
protected $cause_of_death;
public function __construct() public function __construct()
{ {
@ -96,6 +99,19 @@ class LeadsController extends BaseController
'completed_with_corrections' => 'Completed with Corrections', 'completed_with_corrections' => 'Completed with Corrections',
'completed_without_corrections' => 'Completed w/o Corrections', 'completed_without_corrections' => 'Completed w/o Corrections',
]; ];
$this->claim_type_for_gpa = [
'accident_death' => 'Accident Death',
'permanent_total_disablement' => 'Permanent Total Disablement',
'permanent_partial_disablement' => 'Permanent Partial Disablement',
'temporary_total_disablement_benefit' => 'Temporary Total Disablement benefit'
];
$this->cause_of_death = [
'natural_death' => 'Natural Death',
'suicide' => 'Suicide',
'accident' => 'Accident'
];
} }
public function viewLeadsList() public function viewLeadsList()
@ -123,7 +139,7 @@ class LeadsController extends BaseController
// Fetch insurer and TPA branch data // Fetch insurer and TPA branch data
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
$data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
// print_r($data['tpa']);die();
// Fetch sales team members who are active in team 5 // Fetch sales team members who are active in team 5
$data['salse_team'] = $this->userModel $data['salse_team'] = $this->userModel
->select('user_profiles.*') ->select('user_profiles.*')
@ -134,7 +150,10 @@ class LeadsController extends BaseController
->findAll(); ->findAll();
// dd($data); // dd($data);
$data['lastFiveYears'] = $this->getLastFiveFinancialYears();
$data['gpaClaimType'] = $this->claim_type_for_gpa;
$data['causeOfDeath'] = $this->cause_of_death;
// dd($lastFiveYears);
if ($this->request->is('get')) { if ($this->request->is('get')) {
// Fetch leads data // Fetch leads data
$data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising(); $data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising();
@ -270,7 +289,25 @@ class LeadsController extends BaseController
$last_3_years_claims = null; $last_3_years_claims = null;
if($value != 2){ if($value != 2){
$last_3_years_claims = $data['finyear']; $last_3_years_claims = [];
$finyear = json_decode($data['finyear']);
foreach ($finyear as $year){
$received_policy_type = ($year->finyear[0]->policy_type);
if ($value == $received_policy_type){
array_push($last_3_years_claims,$year);
}else{
continue;
}
// print_r($last_3_years_claims);
// $last_3_years_claims = json_encode($last_3_years_claims);
}
$last_3_years_claims = json_encode($last_3_years_claims);
// print_r($last_3_years_claims);
// die();
// $last_3_years_claims = $data['finyear'];
} }
$processedData[] = [ $processedData[] = [
@ -338,7 +375,7 @@ class LeadsController extends BaseController
'notes' => $data['notes'] ?? null, 'notes' => $data['notes'] ?? null,
]; ];
} }
// print_r($processedData);die();
return $processedData; return $processedData;
} }
@ -2103,4 +2140,26 @@ class LeadsController extends BaseController
} }
function getLastFiveFinancialYears() {
$currentYear = date('Y');
$currentMonth = date('m');
// In India, the financial year starts from April (04)
if ($currentMonth < 4) {
$currentYear--; // Adjust year if it's Jan-Mar
}
$financialYears = [];
for ($i = 0; $i < 5; $i++) {
$startYear = $currentYear - $i - 1;
$endYear = $currentYear - $i;
$financialYears[] = "$startYear-$endYear";
}
return $financialYears;
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -161,28 +161,29 @@ table.dataTable tbody td {
<script> <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table"); const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) { function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu'); const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null; if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment // Clone the items but remove their original click handlers
customDropdown.innerHTML = originalDropdown.innerHTML; const items = originalDropdown.querySelectorAll('.dropdown-item');
items.forEach(item => {
const newItem = item.cloneNode(true);
// Preserve the attributes but remove the onclick
newItem.removeAttribute('onclick');
customDropdown.appendChild(newItem);
});
return customDropdown; return customDropdown;
} }
let activeDropdown = null; let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => { table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row); const customDropdown = createCustomDropdown(row);
if (!customDropdown) return; if (!customDropdown) return;
@ -195,46 +196,49 @@ document.addEventListener("DOMContentLoaded", function () {
return; return;
} }
// Hide any active dropdown
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
} }
// Get click position
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block'; customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed'; customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`; customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown; activeDropdown = customDropdown;
event.stopPropagation(); event.stopPropagation();
}); });
// Preserve click handlers and add auto-close // Handle clicks on dropdown items
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick'); e.preventDefault();
if (onclickAttr) { e.stopPropagation();
eval(onclickAttr);
// Get the data-id and other attributes from the original button
const originalItem = row.querySelector(`.dropdown-item[data-id="${this.getAttribute('data-id')}"]`);
// For edit functionality
if (this.classList.contains('btnEdit')) {
const id = this.getAttribute('data-id');
if (id) {
getLeadsDataForEdit(id);
}
} }
// For RFQ links
const href = this.getAttribute('href'); const href = this.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#' && !this.classList.contains('btnEdit')) {
window.location.href = href; window.location.href = href;
} }
// Close the dropdown after handling the click // Close the dropdown
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
activeDropdown = null; activeDropdown = null;
} }
e.stopPropagation();
}); });
}); });
}); });
@ -281,7 +285,7 @@ $(document).ready(function(){
$('#client_id').select2(); $('#client_id').select2();
$('#client_branch_id').select2(); $('#client_branch_id').select2();
$('#source_policy_id').select2(); // $('#source_policy_id').select2();
$('#salse_person_id').select2({ $('#salse_person_id').select2({
placeholder: "Select Salse Person", placeholder: "Select Salse Person",
}); });