diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e116fcd1..9c09427e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -531,6 +531,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->post('note/(:any)','TicketController::crudNote/$1'); $routes->post('reply','TicketController::saveReply'); $routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports'); + $routes->post('getPolicyStartDate','TicketController::getPolicyStartDate'); + $routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID"); // $routes->post('ticket_messages','TicketController::getTicketMessage'); }); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 6da26715..4b3a9619 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -12,6 +12,9 @@ use App\Models\TicketMailTemplateModel; use App\Models\TicketMessageModel; use App\Models\TicketNoteModel; use App\Models\UserModel; +use App\Models\ClientPolicyModel; +use App\Models\EmployeePolicyModel; + use DOMDocument; use Psr\Log\LoggerInterface; use Kint\Kint; @@ -45,6 +48,8 @@ class TicketController extends BaseController protected $triggerType; protected $userModel; protected $employeeModel; + protected $clientPolicyModel; + protected $employeePolicyModel; public function __construct() { @@ -80,10 +85,10 @@ class TicketController extends BaseController ]; $this->claimType = [ 1 => [ - 1 => "Main", + 1 => "Main Hospitalization", + 3 => "Pre / Post", 2 => "OPD", - 3 => "Pre ReOpen", - 4 => "Post ReOpen", + 4 => "ReOpen", ], 2 => [ 1 => "TTD", @@ -157,6 +162,8 @@ class TicketController extends BaseController $this->ticketMessageModel = new TicketMessageModel(); $this->userModel = new UserModel(); $this->employeeModel = new EmployeeModel(); + $this->clientPolicyModel = new ClientPolicyModel(); + $this->employeePolicyModel = new EmployeePolicyModel(); } public function ticketList() @@ -439,7 +446,6 @@ class TicketController extends BaseController $template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data); } $data = $this->ticket_form_data($ticket_data['ticket_type_id'], $ticket_data['claim_status_id']); - $data['ticket_data'] = $ticket_data; $data['reply_data'] = $template_data; $data['placeHolders'] = $this->placeHolders; $data['message_data'] = $this->getTicketMessage($ticket_id); @@ -447,6 +453,12 @@ class TicketController extends BaseController $data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']); $data['ticket_history'] = $this->ticketHistory($ticket_id); $data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray(); + if (!empty($ticket_data['client_policy_id'])){ + $ticket_data['client_policy_id_text'] = $this->clientPolicyModel->select('concat(policy_type.policy_type,"-",client_policy.policy_no) as client_policy_name')->join('policy_type','policy_type.id = client_policy.policy_type_id and policy_type.is_active = 1')->where('client_policy.id',$ticket_data['client_policy_id'])->first()['client_policy_name']; + } + // dd($ticket_data); + $data['ticket_data'] = $ticket_data; + // dd($data); return $this->loadLayout('ticket_edit_onbording', $data); @@ -841,8 +853,16 @@ class TicketController extends BaseController $replaceData = $ticket_data[$value] ?? ''; } else if ($value == "policy_type") { $replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? ""); - } else { - $replaceData = isset($ticket_data[$value]) ? strtoupper($ticket_data[$value]) : ''; + } else if ($value == 'emp_name'){ + if(empty($ticket_data['emp_id'])){ + $replaceData = $ticket_data['emp_name']??""; + } + }else if ($value == 'insured_name'){ + if(empty($ticket_data['insured_emp_id'])){ + $replaceData = $ticket_data['insured_name']?? ""; + } + }else { + $replaceData = isset($ticket_data[$value]) ? $ticket_data[$value] : ''; } $content = str_replace($key, $replaceData, $content); @@ -1433,5 +1453,73 @@ class TicketController extends BaseController return $lastMatchedStatus; } + + public function getPolicyStartDate() + { + + $data = $this->request->getPost(); + $client_policy_id = $data['policy_id']; + $policy_start_date = $this->clientPolicyModel->select('policy_start_date')->where('id', $client_policy_id)->first()['policy_start_date']; + // dd($data); + if (isset($data['employeeId']) && $data['employeeId'] != "" && $data['employeeId'] != null) { + // dd($data); + $emp_id = $data['employeeId']; + $empData = $this->employeeModel->select('dob,doj')->where('id',$emp_id)->findAll(); + + if (!empty($empData) && $empData != "" && $empData != null ) { + foreach ($empData as &$emp) { // Loop through the data + $emp['dob'] = date('d/m/Y', strtotime($emp['dob'])); + $emp['doj'] = date('d/m/Y', strtotime($emp['doj'])); + } + } + + if ($empData){ + return $this->respond(['status' => true, 'minDate' => $policy_start_date,'empData'=> $empData], 200); + }else{ + return $this->respond(['status' => false, 'message' => "Policy Not Found"]); + } + + } else { + // dd($policy_start_date); + if ($policy_start_date) { + return $this->respond(['status' => true, 'minDate' => $policy_start_date], 200); + } else { + return $this->respond(['status' => false, 'message' => "Policy Not Found"]); + } + } + } + + public function getPoliciesbyEmpID() { + $received_data = $this->request->getPost(); + $emp_id = $received_data['emp_id']; + + // Get all client policy IDs for the given employee + $policies = $this->employeePolicyModel + ->select('client_policy_id') + ->where('employee_id', $emp_id) + ->findAll(); + + if (empty($policies)) { + return []; // Return empty if no policies found + } + + // Extract client policy IDs into an array + $policy_ids = array_column($policies, 'client_policy_id'); + + // Fetch all policy names and IDs in one query + $policyNameandID = $this->clientPolicyModel + ->select('CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name, client_policy.id as client_policy_value,client_policy.policy_type_id') + ->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1') + ->whereIn('client_policy.id', $policy_ids) + ->findAll(); + + // dd($policyNameandID); + if ($policyNameandID){ + + return $this->respond(['status'=>true,'policy_data'=> $policyNameandID]); + }else{ + return $this->respond(['status'=>false,'message'=> "Policy Not Found"]); + } + } } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 878fad2e..f75cf2a6 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -72,6 +72,8 @@ class TicketMasterModel extends Model 'non_id_reason', 'head_rejection_reason', 'pay_initiate_date', + 'emp_personal_mail', + 'client_policy_id' ]; diff --git a/app/Views/ticket_auto_query.php b/app/Views/ticket_auto_query.php index 519c17e9..24dcef21 100644 --- a/app/Views/ticket_auto_query.php +++ b/app/Views/ticket_auto_query.php @@ -1,3 +1,15 @@ +
@@ -8,14 +20,27 @@
-
- - +
+ +
+ +
+ +
@@ -33,141 +58,136 @@ \ No newline at end of file diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index b23212e9..949f73ca 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -1,3 +1,17 @@ +
" style="margin-right: 23px;"> @@ -73,9 +87,8 @@ + name="policy_no" placeholder="Policy Number">
-
+
+ + +
+
@@ -108,6 +128,20 @@
+ +
+
+ + +
+
@@ -120,12 +154,12 @@
@@ -145,12 +179,12 @@
@@ -160,12 +194,12 @@
@@ -347,12 +381,12 @@
@@ -389,12 +423,23 @@ \ No newline at end of file diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php index 627a3588..3181f9bf 100644 --- a/app/Views/ticket_form_gpa.php +++ b/app/Views/ticket_form_gpa.php @@ -68,6 +68,13 @@ name="emp_mail" required>
+
+ + +
+
+ + +
+
+ + +
+
@@ -293,14 +317,22 @@ \ No newline at end of file diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index 487e885b..c39035a8 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -1,49 +1,49 @@ - \ No newline at end of file diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 13ba40c8..9f1f071e 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -13,7 +13,8 @@ word-wrap: break-word; } - th,td { + th, + td { font-size: smaller !important; } @@ -28,13 +29,13 @@ th:nth-child(1), td:nth-child(1) { - width: 150px; + width: 110px; /* Adjust first column width */ } th:nth-child(2), td:nth-child(2) { - width: 550px; + width: 720px; /* Adjust first column width */ } @@ -173,7 +174,7 @@
- +
@@ -921,7 +922,7 @@ } ], "public_liability": [{ - table_type: "append", + table_type: "new", table_name: "Public Liability Coverage", table_id: "public_liability_addOnCoverage", table_editable: true, @@ -1897,9 +1898,101 @@ element.appendChild(icon); } - $('#saveRFQ').click( () => saveRFQ()); + $('#saveRFQ').click(() => saveRFQ()); + // $("#saveRFQ").click(function (){ + // console.log("Hello the save req button is clicked"); + // }) - function saveRFQ(){ - console.log("save rfq clicked"); + function saveRFQ() { + const rfqData = { + table_data: { + headers: [], + data: [] + } + }; + + // Get all tables + const tables = document.querySelectorAll('table'); + if (tables.length === 0) return; + + // Extract headers from the first table + const headerRow1 = tables[0].querySelector('thead tr:first-child'); + const headerRow2 = tables[0].querySelector('thead tr:last-child'); + const headers = []; + + headerRow1.querySelectorAll('th').forEach((th, index) => { + const parentHeader = th.textContent.trim(); + const subHeaders = []; + const subHeaderTh = headerRow2.children[index]; + if (subHeaderTh) { + subHeaders.push(subHeaderTh.textContent.trim()); + } + headers.push({ + parentHeader, + subHeaders + }); + }); + rfqData.table_data.headers = headers; + + // Process all tables + tables.forEach(table => { + const rows = table.querySelectorAll('tbody tr'); + rows.forEach(row => { + const cells = row.querySelectorAll('td'); + const rowData = { + SNO: '', + items: '', + data: [] + }; + + // Extract SNO (first cell) + if (cells[0]) { + rowData.SNO = cells[0].textContent.replace(/\D/g, '') || '1'; + } + + // Extract items (row ID) + rowData.items = row.id || ''; + + // Process each cell + cells.forEach((cell, cellIndex) => { + const header = headers[cellIndex]; + if (!header) return; + + const parentHeader = header.parentHeader; + const subHeader = header.subHeaders[0] || '-'; + + // Get displayed value + const value = cell.textContent.trim(); + + // Get input value (hidden field or checkbox state) + let inputValue = value; + const hiddenInput = cell.querySelector('input[type="hidden"]'); + if (hiddenInput) { + inputValue = hiddenInput.value; + } + + // Handle Action column checkboxes + if (parentHeader === 'Action') { + const qcrChecked = cell.querySelector('.qcr-checkbox')?.checked ?? false; + const clientChecked = cell.querySelector('.client-checkbox')?.checked ?? false; + inputValue = { + qcr: qcrChecked ? 1 : 0, + stc: clientChecked ? 1 : 0 + }; + } + + rowData.data.push({ + parentth: parentHeader, + subth: subHeader, + value, + input_value: inputValue + }); + }); + + rfqData.table_data.data.push(rowData); + }); + }); + + console.log(JSON.stringify(rfqData, null, 2)); } \ No newline at end of file