myLogger = \Config\Services::mylogger(); } public function saveForm() { // Get JSON input $data = $this->request->getPost(); // For testing: just return the received data return $this->respond([ 'status' => 'success', 'message' => 'Form data received successfully!', 'data' => $data ]); } public function testcli() { echo "hi"; $this->myLogger->logme('error', "test log"); echo "hi 2"; log_message('error', 'test message for log_message_function'); echo "hi 3"; } public function generatePDF() { // Sample data - replace with your actual data source $data = [ 'NAME' => 'John Doe', 'GENDER' => 'Male', 'DOB' => '01/01/1990', 'RELATION' => 'Self', 'POLICY_NO' => 'POL123456789', 'TPA_ID' => 'TPA987654321', 'POLICY_START_DATE' => '01/01/2024', 'POLICY_DATE' => '31/12/2024', 'INSURER_NAME' => 'ABC Insurance Co.', 'TPA_NAME' => 'XYZ TPA Ltd.', 'FRONT_CARD' => base_url('assets/images/front-card.jpg'), // Your card images 'BACK_CARD' => base_url('assets/images/back-card.jpg'), 'LEVELS' => 'Level 1: 1800-XXX-XXXX
Level 2: support@company.com' ]; // Load the HTML template $html = $this->loadTemplate($data); // Configure DomPDF options $options = new Options(); $options->set('isRemoteEnabled', true); // Enable loading of remote images $options->set('isHtml5ParserEnabled', true); $options->set('isPhpEnabled', true); $options->set('debugPng', false); $options->set('debugKeepTemp', false); $options->set('debugCss', false); $options->set('debugLayout', false); $options->set('debugLayoutLines', false); $options->set('debugLayoutBlocks', false); $options->set('debugLayoutInline', false); $options->set('debugLayoutPaddingBox', false); // Initialize DomPDF $dompdf = new Dompdf($options); // Load HTML content $dompdf->loadHtml($html); // Set paper size and orientation $dompdf->setPaper('A4', 'landscape'); // or 'portrait' // Render PDF $dompdf->render(); // Output PDF to browser $filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf'; $dompdf->stream($filename, ['Attachment' => true]); // Set to false for inline view } public function viewPDF() { // Same as generatePDF but with inline view $data = [ 'NAME' => 'Korukonda Naga Venkata Ramalinga Satya Swarna Kumari', 'GENDER' => 'Male', 'DOB' => '01/01/1990', 'RELATION' => 'Self', 'POLICY_NO' => '97000034230400000109_EX_Parental', 'TPA_ID' => 'TPA987654321', 'POLICY_START_DATE' => '01/01/2024', 'POLICY_DATE' => '31/12/2024', 'INSURER_NAME' => 'ZURICH KOTAK GTNERAL INSURANCE COIIPANY lNDlA LIMITED', 'TPA_NAME' => 'HealthIndia Insurance TPA Services Pvt. Ltd.', 'FRONT_CARD' => base_url() .('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'), 'BACK_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'), 'LEVELS' => 'Level 1: 1800-XXX-XXXX
Level 2: support@company.com' ]; $data2 = [ 'NAME' => 'John Doe', 'GENDER' => 'Male', 'DOB' => '01/01/1990', 'RELATION' => 'Self', 'POLICY_NO' => 'POL123456789', 'TPA_ID' => 'TPA987654321', 'POLICY_START_DATE' => '01/01/2024', 'POLICY_DATE' => '31/12/2024', 'INSURER_NAME' => 'ABC Insurance Co.', 'TPA_NAME' => 'XYZ TPA Ltd.', 'FRONT_CARD' => base_url() .('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'), 'BACK_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'), 'LEVELS' => 'Level 1: 1800-XXX-XXXX
Level 2: support@company.com' ]; $employeeController = new EmployeeController(); // $html = $employeeController->generateIDCardForEmployeeUsingDom('LfpH3R'); $html = $this->loadTemplate($data2); // print_r($html); die; $options = new Options(); $options->set('isRemoteEnabled', true); $options->set('isHtml5ParserEnabled', true); $dompdf = new Dompdf($options); // $dompdf->loadHtml($html); $dompdf->loadHtml('' . $html); $dompdf->setPaper('A4', 'portrait'); // $dompdf->setPaper('A4', 'landscape'); $dompdf->render(); $filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf'; // $dompdf->stream($filename, ['Attachment' => true]); // Inline view $dompdf->stream($filename, ['Attachment' => false]); // Force download } private function loadTemplate($data) { // Load your HTML template $template = file_get_contents(WRITEPATH . 'e_card_template/common.html'); // Replace placeholders with actual data foreach ($data as $key => $value) { $template = str_replace('{' . $key . '}', $value, $template); } return $template; } // not using and not working public function viewPdfUsingMpdf() { $data = [ 'NAME' => 'Korukonda Naga Venkata Ramalinga Satya Swarna Kumari', 'GENDER' => 'Male', 'DOB' => '01/01/1990', 'RELATION' => 'Self', 'POLICY_NO' => '97000034230400000109_EX_Parental', 'TPA_ID' => 'TPA987654321', 'POLICY_START_DATE' => '01/01/2024', 'POLICY_DATE' => '31/12/2024', 'INSURER_NAME' => 'ZURICH KOTAK GTNERAL INSURANCE COIIPANY lNDlA LIMITED', 'TPA_NAME' => 'HealthIndia Insurance TPA Services Pvt. Ltd.', 'FRONT_CARD' => base_url('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'), 'BACK_CARD' => base_url('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'), 'LEVELS' => 'Level 1: 1800-XXX-XXXX
Level 2: support@company.com' ]; $html = $this->loadTemplate($data); // Load mPDF $mpdf = ""; // $mpdf = new \Mpdf\Mpdf([ // 'mode' => 'utf-8', // 'format' => 'A4', // 'margin_left' => 0, // 'margin_right' => 0, // 'margin_top' => 0, // 'margin_bottom' => 0, // 'tempDir' => __DIR__ . '/writable/mpdf' // ]); // Optional: Stretch background or images fully // $html = ' // ' . $html; // $mpdf->WriteHTML($html); // // Output inline (no download prompt) // $filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf'; // $mpdf->Output($filename, 'D'); /* 'I' = inline view in browser (no download prompt). 'D' = force download. 'F' = save to file. 'S' = return as string. */ } public function getEmployeePolicyTypes($client_id, $emp_code, $emp_id) { $employeePolicy = new EmployeePolicyModel(); $data = $employeePolicy ->select('client_policy.policy_type_id') ->join('employees', 'employee_polices.employee_id = employees.id') ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id') ->where('employees.is_active', 1) ->where('employees.emp_status', ['active', 'expired']) ->where('employee_polices.is_active', 1) ->where('employee_polices.status', ['active', 'expired']) ->where('employees.client_id', $client_id) ->where('employees.emp_code', $emp_code) ->groupBy('employee_polices.client_policy_id') ->findAll(); } public function ptedfitdata($id){ $policy_transaction = new PolicyTransactionController(); $data = $policy_transaction->getInceptionDataForEdit($id); // dd($data); $insurerBranchModel = new InsurerBranchModel(); $insurer_branch = $insurerBranchModel->getInsurerBranchesWithInsurerNames(); $dataArray = $data['pt_co_share_details']; // Example $cd_ac_pk = 'CD12345'; $role_id = 1; $team_id = ['6']; $insurer_branch = $insurer_branch; return view('pt_calc_table', [ 'dataArray' => $dataArray, 'cd_ac_pk' => $cd_ac_pk, 'role_id' => $role_id, 'team_id' => $team_id, 'insurer_branch' => $insurer_branch ]); } function generateInsurerTable($dataArray, $cd_ac_pk, $role_id, $team_id, $insurer_branch) { $html = ''; foreach ($dataArray as $index => $data) { $disable_td = ($data['record_count'] > 0) ? 'readonly-select' : ''; $insurer = $data['insurer_branch_id'] . '-' . $data['insurer_id']; $html .= ''; // Insurer selection $html .= ''; // Leader toggle $checked = ($data['co_share_type'] == 1) ? 'checked' : ''; $html .= ''; // CD Account $html .= ''; // CD Amount $html .= ''; // Example of follower policy no $html .= ''; // Add other fields (bp_amt, tp_amt, gst, etc.) $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; } $html .= '
'; return $html; } public function viewRFQNonEb() { $insurerBranchModel = new InsurerBranchModel(); $data['page_name'] = "RFQ NON EB"; $data['insurer'] = $insurerBranchModel->getInsurerBranchesWithInsurerNames(); // dd($data); return $this->loadLayout('view_rfq_non_eb_new', $data); } public function saverfq(){ $json = $this->request->getPost('json'); $json = json_encode($json); print_r($json); // $data['lead_id'] = 10000; // $data['json'] = $json; // $rfq = new RFQModel(); // $rfq->insert($data); } public function exportExcel() { $rfq = new RFQModel(); $policy_data = $rfq->where('lead_id', 10000)->first(); // print_rr($policy_data['json']); die; $policy_data = json_decode($policy_data['json'], true); $policy_data = array_slice($policy_data, 0, -2); print_rr($policy_data); die; dd($policy_data); } }