FEAT_DOM_PDF_E_CARD : RV
This commit is contained in:
parent
8683d8ff70
commit
682af10085
@ -678,8 +678,8 @@ $routes->get("ticketHistoryList", "ThzController::ticketHistoryList");
|
|||||||
$routes->group('test', function($routes) {
|
$routes->group('test', function($routes) {
|
||||||
$routes->post('api/saveForm', 'TestingController::saveForm');
|
$routes->post('api/saveForm', 'TestingController::saveForm');
|
||||||
$routes->get('insurerRFQRemainder', 'LeadsController::remainderForQcr');
|
$routes->get('insurerRFQRemainder', 'LeadsController::remainderForQcr');
|
||||||
$routes->get('ecard/generate-pdf', 'TestingController::generatePDF');
|
$routes->get('generatePDF', 'TestingController::generatePDF');
|
||||||
$routes->get('view-pdf', 'TestingController::viewPDF');
|
$routes->get('viewPDF', 'TestingController::viewPDF');
|
||||||
$routes->get('generate-pdf-view', 'TestingController::generatePDFWithView');
|
$routes->get('generate-pdf-view', 'TestingController::generatePDFWithView');
|
||||||
});
|
});
|
||||||
$routes->cli('cli/testcli', 'TestingController::testcli');
|
$routes->cli('cli/testcli', 'TestingController::testcli');
|
||||||
|
|||||||
@ -1180,8 +1180,10 @@ class EmployeeController extends AdminController
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
//E-CARD DOWNLOAD FUNCTION
|
// --------------- For E-Card Download -----------------------------------------------------------------------------------------------------
|
||||||
public function generateIDCardForEmployee($rand_string, $people = 0)
|
|
||||||
|
//E-CARD DOWNLOAD FUNCTION USING HTML PRINT
|
||||||
|
public function generateIDCardForEmployeeUsingHtml($rand_string, $people = 0)
|
||||||
{
|
{
|
||||||
// dd($rand_string, $people);
|
// dd($rand_string, $people);
|
||||||
try {
|
try {
|
||||||
@ -1316,6 +1318,241 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Preview E-Card Template function
|
||||||
|
public function previewTemplate($id = null)
|
||||||
|
{
|
||||||
|
$value = [
|
||||||
|
'tpa_id' => 'TPA12345',
|
||||||
|
'name' => 'John Doe',
|
||||||
|
'uhid' => 'UHID67890',
|
||||||
|
'gender' => 'Male',
|
||||||
|
'dob' => '1985-05-15',
|
||||||
|
'self' => 'John Doe',
|
||||||
|
'policy_end_date' => '2024-12-31',
|
||||||
|
'policy_start_date' => '2023-01-01',
|
||||||
|
'policy_no' => 'POL1234567890',
|
||||||
|
'insurer_name' => 'Example Insurance Company',
|
||||||
|
'emp_code' => 'EMP001122',
|
||||||
|
'client_name' => 'Corporate Client Inc.',
|
||||||
|
'emp_age' => 39,
|
||||||
|
'tpa_name' => 'Example TPA',
|
||||||
|
'insurer_branch_city' => 'New York',
|
||||||
|
'relationship' => 'Self',
|
||||||
|
'basic_cover_si' => '5,00,000',
|
||||||
|
];
|
||||||
|
|
||||||
|
$tpa_id = $this->TPAModel->where('id', $id)->first();
|
||||||
|
|
||||||
|
$template_data_path = WRITEPATH . 'e_card_template/';
|
||||||
|
$tpa_short_name = strtolower(str_replace(' ', '_', $tpa_id['short_name'])) . '.html';
|
||||||
|
$final_path = $template_data_path . $tpa_short_name;
|
||||||
|
|
||||||
|
if (!file_exists($final_path)) {
|
||||||
|
|
||||||
|
$data['message'] = 'Record Not Found';
|
||||||
|
return view('errors/404', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmplt_data = file_get_contents($final_path);
|
||||||
|
|
||||||
|
$placeholders = [
|
||||||
|
'{TPA_ID}' => $value['tpa_id'],
|
||||||
|
'{NAME}' => $value['name'],
|
||||||
|
'{UHID}' => $value['uhid'],
|
||||||
|
'{GENDER}' => $value['gender'],
|
||||||
|
'{DOB}' => date('d-M-Y', strtotime($value['dob'])),
|
||||||
|
'{SELF_NAME}' => $value['self'] ?? $value['name'],
|
||||||
|
'{POLICY_DATE}' => date('d-M-Y', strtotime($value['policy_end_date'])),
|
||||||
|
'{POLICY_START_DATE}' => date('d-M-Y', strtotime($value['policy_start_date'])),
|
||||||
|
'{POLICY_NO}' => $value['policy_no'],
|
||||||
|
'{INSURER_NAME}' => strtoupper($value['insurer_name']),
|
||||||
|
'{EMP_ID}' => $value['emp_code'],
|
||||||
|
'{SI_AMT}' => $value['basic_cover_si'],
|
||||||
|
'{CORPORATE_NAME}' => $value['client_name'],
|
||||||
|
'{AGE}' => $value['emp_age'],
|
||||||
|
'{TPA_NAME}' => $value['tpa_name'],
|
||||||
|
'{INSURER_BRANCH}' => $value['insurer_branch_city'],
|
||||||
|
'{RELATION}' => $value['relationship'],
|
||||||
|
'{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $tpa_id['front_card'],
|
||||||
|
'{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $tpa_id['back_card'],
|
||||||
|
'{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $tpa_id['tpa_logo'],
|
||||||
|
'{INSURER_LOGO}' => base_url() . 'public/assets/images/sample_logo_3.png',
|
||||||
|
'{MEDI_USER}' => base_url() . 'public/e_card_imgs/medi_uesr.jpg',
|
||||||
|
'{MEDI_INSURER}' => base_url() . 'public/e_card_imgs/Magma.png',
|
||||||
|
'{MEDI_BARCODE}' => base_url() . 'public/e_card_imgs/borcode.jpeg',
|
||||||
|
'{QR_ANDROID}' => base_url() . 'public/e_card_imgs/android.png',
|
||||||
|
'{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png',
|
||||||
|
'{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png',
|
||||||
|
'{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$placeholders['{LEVELS}'] = '
|
||||||
|
<span style="font-family: sans-serif;">Level 1</span><br><br>
|
||||||
|
<span style="font-family: sans-serif;">1. Gowtham / 8754081806 / gowtham@gmail.com</span><br>
|
||||||
|
<span style="font-family: sans-serif;">2. Gowtham / 8754081806 / gowtham@gmail.com</span><br><br>';
|
||||||
|
|
||||||
|
// dd($placeholders);
|
||||||
|
|
||||||
|
// Get the values to replace the placeholders
|
||||||
|
$replaceValues = array_values($placeholders);
|
||||||
|
|
||||||
|
// Get the placeholders to search for
|
||||||
|
$searchPlaceholders = array_keys($placeholders);
|
||||||
|
|
||||||
|
// Replace placeholders with values in HTML content
|
||||||
|
$htmlContent = str_replace($searchPlaceholders, $replaceValues, $tmplt_data);
|
||||||
|
|
||||||
|
|
||||||
|
echo $htmlContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
//E-CARD DOWNLOAD FUNCTION USING DOM PDF ( CURRENTLY USING THIS )
|
||||||
|
public function generateIDCardForEmployee($rand_string, $people = 0, $mode = 0)
|
||||||
|
{
|
||||||
|
// dd($rand_string, $people);
|
||||||
|
$this->myLogger->logme('error', 'generateIDCardForEmployee params .' . json_encode(["rand_string" => $rand_string, "people" => $people, "mode" => $mode]));
|
||||||
|
try {
|
||||||
|
$this->myLogger->logme('error', 'generateIDCardForEmployee function started.');
|
||||||
|
|
||||||
|
// Step 1: Attempt to fetch employee code and client policy ID
|
||||||
|
$this->myLogger->logme('error', 'Fetching employee code and client policy ID.');
|
||||||
|
|
||||||
|
$get_emp_code_and_client_policy_id = $this->employeePolicyModel
|
||||||
|
->select('employee_polices.client_policy_id, employees.emp_code, tpa.short_name,employees.client_id')
|
||||||
|
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||||
|
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||||
|
->join('tpa', 'tpa.id = client_policy.tpa_id')
|
||||||
|
->where('employees.emp_status', 'active')
|
||||||
|
->where('employees.is_active', '1')
|
||||||
|
->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''")
|
||||||
|
->where('employee_polices.status', 'active')
|
||||||
|
->where('employee_polices.is_active', '1')
|
||||||
|
->where('employee_polices.rand_string', $rand_string)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
// dd($this->employeePolicyModel->getLastQuery());
|
||||||
|
|
||||||
|
// dd($rand_string, $get_emp_code_and_client_policy_id);
|
||||||
|
|
||||||
|
if ($get_emp_code_and_client_policy_id == null || $get_emp_code_and_client_policy_id == "") {
|
||||||
|
$this->myLogger->logme('error', 'Member not found in this rand_string: ' . $rand_string);
|
||||||
|
$data['message'] = 'Record Not Found';
|
||||||
|
return view('errors/404', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->myLogger->logme('error', 'Member found. Client policy ID: ' . $get_emp_code_and_client_policy_id['client_policy_id']);
|
||||||
|
|
||||||
|
$client_policy_id = $get_emp_code_and_client_policy_id['client_policy_id'];
|
||||||
|
$emp_code = $get_emp_code_and_client_policy_id['emp_code'];
|
||||||
|
$client_id = $get_emp_code_and_client_policy_id['client_id'];
|
||||||
|
|
||||||
|
// Step 2: Fetch ECard data
|
||||||
|
$this->myLogger->logme('error', 'Fetching ECard data using client_policy_id: ' . $client_policy_id . ' and emp_code: ' . $emp_code);
|
||||||
|
$data = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code,$client_id);
|
||||||
|
|
||||||
|
if ($people == 0) {
|
||||||
|
$this->myLogger->logme('error', 'Fetching single ECard data using rand_string: ' . $rand_string . ' and emp_code: ' . $emp_code);
|
||||||
|
$data = $this->employeePolicyModel->getECardSingleData($rand_string, $emp_code,$client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 3: Prepare template path
|
||||||
|
$template_data_path = WRITEPATH . 'e_card_template/';
|
||||||
|
// $tpa_short_name = strtolower(str_replace(' ', '_', $get_emp_code_and_client_policy_id['short_name'])) . '.html';
|
||||||
|
$tpa_short_name = 'common.html';
|
||||||
|
$final_path = $template_data_path . $tpa_short_name;
|
||||||
|
|
||||||
|
$this->myLogger->logme('error', 'Checking if template file exists at: ' . $final_path);
|
||||||
|
|
||||||
|
if (!file_exists($final_path)) {
|
||||||
|
$this->myLogger->logme('error', 'Template file not found: ' . $final_path);
|
||||||
|
$data['message'] = 'Template File Not Found';
|
||||||
|
return view('errors/404', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->myLogger->logme('error', 'Template file found. Reading template data.');
|
||||||
|
$tmplt_data = file_get_contents($final_path);
|
||||||
|
|
||||||
|
// Step 4: Generate HTML content
|
||||||
|
$this->myLogger->logme('error', 'Generating HTML content from template.');
|
||||||
|
$html = "";
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
$htmlContent = $tmplt_data;
|
||||||
|
|
||||||
|
$value['front_card'] = "Nhance_Ecard_working_1_front.png";
|
||||||
|
$value['back_card'] = "Nhance_Ecard_working_1_Back.png";
|
||||||
|
|
||||||
|
$placeholders = [
|
||||||
|
'{CLIENT_NAME}' => $value['client_name'],
|
||||||
|
'{TPA_ID}' => $value['tpa_id'],
|
||||||
|
'{NAME}' => $value['name'],
|
||||||
|
'{UHID}' => $value['uhid'],
|
||||||
|
'{GENDER}' => $value['gender'],
|
||||||
|
'{DOB}' => date('d-M-Y', strtotime($value['dob'])),
|
||||||
|
'{SELF_NAME}' => $value['self'] ?? $value['name'],
|
||||||
|
'{POLICY_DATE}' => date('d-M-Y', strtotime($value['policy_end_date'])),
|
||||||
|
'{POLICY_START_DATE}' => date('d-M-Y', strtotime($value['policy_start_date'])),
|
||||||
|
'{POLICY_NO}' => $value['policy_no'],
|
||||||
|
'{INSURER_NAME}' => strtoupper($value['insurer_name']),
|
||||||
|
'{INSURER_LOGO}' => base_url() . 'public/uploads/logo/' . $value['insurer_logo'],
|
||||||
|
'{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['front_card'],
|
||||||
|
'{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['back_card'],
|
||||||
|
'{EMP_ID}' => $value['emp_code'],
|
||||||
|
'{SI_AMT}' => $value['basic_cover_si'],
|
||||||
|
'{CORPORATE_NAME}' => $value['client_name'],
|
||||||
|
'{AGE}' => $value['emp_age'],
|
||||||
|
'{TPA_NAME}' => $value['tpa_name'],
|
||||||
|
'{INSURER_BRANCH}' => $value['insurer_branch_city'],
|
||||||
|
'{RELATION}' => $value['relationship'],
|
||||||
|
'{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $value['tpa_logo'],
|
||||||
|
'{MEDI_USER}' => base_url() . 'public/e_card_imgs/medi_uesr.jpg',
|
||||||
|
'{MEDI_INSURER}' => base_url() . 'public/e_card_imgs/Magma.png',
|
||||||
|
'{MEDI_BARCODE}' => base_url() . 'public/e_card_imgs/borcode.jpeg',
|
||||||
|
'{QR_ANDROID}' => base_url() . 'public/e_card_imgs/android.png',
|
||||||
|
'{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png',
|
||||||
|
'{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png',
|
||||||
|
'{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png',
|
||||||
|
];
|
||||||
|
|
||||||
|
$placeholders['{LEVELS}'] = $this->generateAcmAndMForEcard($client_id);
|
||||||
|
|
||||||
|
foreach ($placeholders as $placeholder => $replaceValue) {
|
||||||
|
$htmlContent = str_replace($placeholder, $replaceValue, $htmlContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= $htmlContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DomPdf
|
||||||
|
$options = new Options();
|
||||||
|
$options->set('isRemoteEnabled', true);
|
||||||
|
$options->set('isHtml5ParserEnabled', true);
|
||||||
|
|
||||||
|
$dompdf = new Dompdf($options);
|
||||||
|
$dompdf->loadHtml('<style>@page { margin: 0; }</style>' . $html); // remove the margin
|
||||||
|
$dompdf->setPaper('A4', 'portrait');
|
||||||
|
$dompdf->render();
|
||||||
|
|
||||||
|
$filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf';
|
||||||
|
|
||||||
|
if($mode == 1){
|
||||||
|
$dompdf->stream($filename, ['Attachment' => false]); // Inline view
|
||||||
|
}else{
|
||||||
|
$dompdf->stream($filename, ['Attachment' => true]); // Force download
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->myLogger->logme('error', 'generateIDCardForEmployee function completed successfully.');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->myLogger->logme('error', 'Exception occurred: ' . $e->getMessage());
|
||||||
|
$data['message'] = 'Record Not Found';
|
||||||
|
return view('errors/404', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
public function viewECard()
|
public function viewECard()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1883,95 +2120,6 @@ class EmployeeController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preview E-Card Template function
|
|
||||||
public function previewTemplate($id = null)
|
|
||||||
{
|
|
||||||
$value = [
|
|
||||||
'tpa_id' => 'TPA12345',
|
|
||||||
'name' => 'John Doe',
|
|
||||||
'uhid' => 'UHID67890',
|
|
||||||
'gender' => 'Male',
|
|
||||||
'dob' => '1985-05-15',
|
|
||||||
'self' => 'John Doe',
|
|
||||||
'policy_end_date' => '2024-12-31',
|
|
||||||
'policy_start_date' => '2023-01-01',
|
|
||||||
'policy_no' => 'POL1234567890',
|
|
||||||
'insurer_name' => 'Example Insurance Company',
|
|
||||||
'emp_code' => 'EMP001122',
|
|
||||||
'client_name' => 'Corporate Client Inc.',
|
|
||||||
'emp_age' => 39,
|
|
||||||
'tpa_name' => 'Example TPA',
|
|
||||||
'insurer_branch_city' => 'New York',
|
|
||||||
'relationship' => 'Self',
|
|
||||||
'basic_cover_si' => '5,00,000',
|
|
||||||
];
|
|
||||||
|
|
||||||
$tpa_id = $this->TPAModel->where('id', $id)->first();
|
|
||||||
|
|
||||||
$template_data_path = WRITEPATH . 'e_card_template/';
|
|
||||||
$tpa_short_name = strtolower(str_replace(' ', '_', $tpa_id['short_name'])) . '.html';
|
|
||||||
$final_path = $template_data_path . $tpa_short_name;
|
|
||||||
|
|
||||||
if (!file_exists($final_path)) {
|
|
||||||
|
|
||||||
$data['message'] = 'Record Not Found';
|
|
||||||
return view('errors/404', $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmplt_data = file_get_contents($final_path);
|
|
||||||
|
|
||||||
$placeholders = [
|
|
||||||
'{TPA_ID}' => $value['tpa_id'],
|
|
||||||
'{NAME}' => $value['name'],
|
|
||||||
'{UHID}' => $value['uhid'],
|
|
||||||
'{GENDER}' => $value['gender'],
|
|
||||||
'{DOB}' => date('d-M-Y', strtotime($value['dob'])),
|
|
||||||
'{SELF_NAME}' => $value['self'] ?? $value['name'],
|
|
||||||
'{POLICY_DATE}' => date('d-M-Y', strtotime($value['policy_end_date'])),
|
|
||||||
'{POLICY_START_DATE}' => date('d-M-Y', strtotime($value['policy_start_date'])),
|
|
||||||
'{POLICY_NO}' => $value['policy_no'],
|
|
||||||
'{INSURER_NAME}' => strtoupper($value['insurer_name']),
|
|
||||||
'{EMP_ID}' => $value['emp_code'],
|
|
||||||
'{SI_AMT}' => $value['basic_cover_si'],
|
|
||||||
'{CORPORATE_NAME}' => $value['client_name'],
|
|
||||||
'{AGE}' => $value['emp_age'],
|
|
||||||
'{TPA_NAME}' => $value['tpa_name'],
|
|
||||||
'{INSURER_BRANCH}' => $value['insurer_branch_city'],
|
|
||||||
'{RELATION}' => $value['relationship'],
|
|
||||||
'{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $tpa_id['front_card'],
|
|
||||||
'{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $tpa_id['back_card'],
|
|
||||||
'{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $tpa_id['tpa_logo'],
|
|
||||||
'{INSURER_LOGO}' => base_url() . 'public/assets/images/sample_logo_3.png',
|
|
||||||
'{MEDI_USER}' => base_url() . 'public/e_card_imgs/medi_uesr.jpg',
|
|
||||||
'{MEDI_INSURER}' => base_url() . 'public/e_card_imgs/Magma.png',
|
|
||||||
'{MEDI_BARCODE}' => base_url() . 'public/e_card_imgs/borcode.jpeg',
|
|
||||||
'{QR_ANDROID}' => base_url() . 'public/e_card_imgs/android.png',
|
|
||||||
'{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png',
|
|
||||||
'{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png',
|
|
||||||
'{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png',
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
$placeholders['{LEVELS}'] = '
|
|
||||||
<span style="font-family: sans-serif;">Level 1</span><br><br>
|
|
||||||
<span style="font-family: sans-serif;">1. Gowtham / 8754081806 / gowtham@gmail.com</span><br>
|
|
||||||
<span style="font-family: sans-serif;">2. Gowtham / 8754081806 / gowtham@gmail.com</span><br><br>';
|
|
||||||
|
|
||||||
// dd($placeholders);
|
|
||||||
|
|
||||||
// Get the values to replace the placeholders
|
|
||||||
$replaceValues = array_values($placeholders);
|
|
||||||
|
|
||||||
// Get the placeholders to search for
|
|
||||||
$searchPlaceholders = array_keys($placeholders);
|
|
||||||
|
|
||||||
// Replace placeholders with values in HTML content
|
|
||||||
$htmlContent = str_replace($searchPlaceholders, $replaceValues, $tmplt_data);
|
|
||||||
|
|
||||||
|
|
||||||
echo $htmlContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function errorListExportImport($file_id)
|
public function errorListExportImport($file_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,8 @@ class TestingController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testcli()
|
public function testcli()
|
||||||
{ echo "hi";
|
{
|
||||||
|
echo "hi";
|
||||||
$this->myLogger->logme('error', "test log");
|
$this->myLogger->logme('error', "test log");
|
||||||
echo "hi 2";
|
echo "hi 2";
|
||||||
log_message('error', 'test message for log_message_function');
|
log_message('error', 'test message for log_message_function');
|
||||||
@ -97,6 +98,22 @@ class TestingController extends BaseController
|
|||||||
{
|
{
|
||||||
// Same as generatePDF but with inline view
|
// Same as generatePDF but with inline view
|
||||||
$data = [
|
$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<br>Level 2: support@company.com'
|
||||||
|
];
|
||||||
|
|
||||||
|
$data2 = [
|
||||||
'NAME' => 'John Doe',
|
'NAME' => 'John Doe',
|
||||||
'GENDER' => 'Male',
|
'GENDER' => 'Male',
|
||||||
'DOB' => '01/01/1990',
|
'DOB' => '01/01/1990',
|
||||||
@ -107,23 +124,30 @@ class TestingController extends BaseController
|
|||||||
'POLICY_DATE' => '31/12/2024',
|
'POLICY_DATE' => '31/12/2024',
|
||||||
'INSURER_NAME' => 'ABC Insurance Co.',
|
'INSURER_NAME' => 'ABC Insurance Co.',
|
||||||
'TPA_NAME' => 'XYZ TPA Ltd.',
|
'TPA_NAME' => 'XYZ TPA Ltd.',
|
||||||
'FRONT_CARD' => base_url('assets/images/front-card.jpg'),
|
'FRONT_CARD' => base_url() .('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'),
|
||||||
'BACK_CARD' => base_url('assets/images/back-card.jpg'),
|
'BACK_CARD' => base_url() . ('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'),
|
||||||
'LEVELS' => 'Level 1: 1800-XXX-XXXX<br>Level 2: support@company.com'
|
'LEVELS' => 'Level 1: 1800-XXX-XXXX<br>Level 2: support@company.com'
|
||||||
];
|
];
|
||||||
|
|
||||||
$html = $this->loadTemplate($data);
|
$employeeController = new EmployeeController();
|
||||||
|
// $html = $employeeController->generateIDCardForEmployeeUsingDom('LfpH3R');
|
||||||
|
$html = $this->loadTemplate($data2);
|
||||||
|
// print_r($html); die;
|
||||||
$options = new Options();
|
$options = new Options();
|
||||||
$options->set('isRemoteEnabled', true);
|
$options->set('isRemoteEnabled', true);
|
||||||
$options->set('isHtml5ParserEnabled', true);
|
$options->set('isHtml5ParserEnabled', true);
|
||||||
|
|
||||||
$dompdf = new Dompdf($options);
|
$dompdf = new Dompdf($options);
|
||||||
$dompdf->loadHtml($html);
|
// $dompdf->loadHtml($html);
|
||||||
|
$dompdf->loadHtml('<style>@page { margin: 0; }</style>' . $html);
|
||||||
$dompdf->setPaper('A4', 'portrait');
|
$dompdf->setPaper('A4', 'portrait');
|
||||||
|
// $dompdf->setPaper('A4', 'landscape');
|
||||||
$dompdf->render();
|
$dompdf->render();
|
||||||
|
|
||||||
$filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf';
|
$filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf';
|
||||||
$dompdf->stream($filename, ['Attachment' => false]); // Inline view
|
// $dompdf->stream($filename, ['Attachment' => true]); // Inline view
|
||||||
|
$dompdf->stream($filename, ['Attachment' => false]); // Force download
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadTemplate($data)
|
private function loadTemplate($data)
|
||||||
@ -139,79 +163,57 @@ class TestingController extends BaseController
|
|||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alternative method using CodeIgniter's view system
|
// not using and not working
|
||||||
public function generatePDFWithView()
|
public function viewPdfUsingMpdf()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'NAME' => 'John Doe',
|
'NAME' => 'Korukonda Naga Venkata Ramalinga Satya Swarna Kumari',
|
||||||
'GENDER' => 'Male',
|
'GENDER' => 'Male',
|
||||||
'DOB' => '01/01/1990',
|
'DOB' => '01/01/1990',
|
||||||
'RELATION' => 'Self',
|
'RELATION' => 'Self',
|
||||||
'POLICY_NO' => 'POL123456789',
|
'POLICY_NO' => '97000034230400000109_EX_Parental',
|
||||||
'TPA_ID' => 'TPA987654321',
|
'TPA_ID' => 'TPA987654321',
|
||||||
'POLICY_START_DATE' => '01/01/2024',
|
'POLICY_START_DATE' => '01/01/2024',
|
||||||
'POLICY_DATE' => '31/12/2024',
|
'POLICY_DATE' => '31/12/2024',
|
||||||
'INSURER_NAME' => 'ABC Insurance Co.',
|
'INSURER_NAME' => 'ZURICH KOTAK GTNERAL INSURANCE COIIPANY lNDlA LIMITED',
|
||||||
'TPA_NAME' => 'XYZ TPA Ltd.',
|
'TPA_NAME' => 'HealthIndia Insurance TPA Services Pvt. Ltd.',
|
||||||
'FRONT_CARD' => base_url('assets/images/front-card.jpg'),
|
'FRONT_CARD' => base_url('public/uploads/template_bg/Nhance_Ecard_working_1_front_3.png'),
|
||||||
'BACK_CARD' => base_url('assets/images/back-card.jpg'),
|
'BACK_CARD' => base_url('public/uploads/template_bg/Nhance_Ecard_working_1_Back_3.png'),
|
||||||
'LEVELS' => 'Level 1: 1800-XXX-XXXX<br>Level 2: support@company.com'
|
'LEVELS' => 'Level 1: 1800-XXX-XXXX<br>Level 2: support@company.com'
|
||||||
];
|
];
|
||||||
|
|
||||||
// Load view with data
|
$html = $this->loadTemplate($data);
|
||||||
$html = view('ecard_template', $data);
|
|
||||||
|
// Load mPDF
|
||||||
$options = new Options();
|
$mpdf = "";
|
||||||
$options->set('isRemoteEnabled', true);
|
|
||||||
$options->set('isHtml5ParserEnabled', true);
|
// $mpdf = new \Mpdf\Mpdf([
|
||||||
|
// 'mode' => 'utf-8',
|
||||||
$dompdf = new Dompdf($options);
|
// 'format' => 'A4',
|
||||||
$dompdf->loadHtml($html);
|
// 'margin_left' => 0,
|
||||||
$dompdf->setPaper('A4', 'portrait');
|
// 'margin_right' => 0,
|
||||||
$dompdf->render();
|
// 'margin_top' => 0,
|
||||||
|
// 'margin_bottom' => 0,
|
||||||
$filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf';
|
// 'tempDir' => __DIR__ . '/writable/mpdf'
|
||||||
$dompdf->stream($filename, ['Attachment' => true]);
|
// ]);
|
||||||
|
|
||||||
|
// Optional: Stretch background or images fully
|
||||||
|
// $html = '
|
||||||
|
// <style>
|
||||||
|
// body { margin:0; padding:0; }
|
||||||
|
// @page { margin:0; }
|
||||||
|
// </style>' . $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 generatePDFById($id)
|
|
||||||
{
|
|
||||||
// Get data from database
|
|
||||||
$ecardData = [];
|
|
||||||
|
|
||||||
if (!$ecardData) {
|
|
||||||
throw new \CodeIgniter\Exceptions\PageNotFoundException('E-card not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'NAME' => $ecardData['name'],
|
|
||||||
'GENDER' => $ecardData['gender'],
|
|
||||||
'DOB' => $ecardData['dob'],
|
|
||||||
'RELATION' => $ecardData['relation'],
|
|
||||||
'POLICY_NO' => $ecardData['policy_no'],
|
|
||||||
'TPA_ID' => $ecardData['tpa_id'],
|
|
||||||
'POLICY_START_DATE' => $ecardData['policy_start_date'],
|
|
||||||
'POLICY_DATE' => $ecardData['policy_end_date'],
|
|
||||||
'INSURER_NAME' => $ecardData['insurer_name'],
|
|
||||||
'TPA_NAME' => $ecardData['tpa_name'],
|
|
||||||
'FRONT_CARD' => base_url('assets/images/front-card.jpg'),
|
|
||||||
'BACK_CARD' => base_url('assets/images/back-card.jpg'),
|
|
||||||
'LEVELS' => 'Level 1: 1800-XXX-XXXX<br>Level 2: support@company.com'
|
|
||||||
];
|
|
||||||
|
|
||||||
$html = view('ecard_template', $data);
|
|
||||||
|
|
||||||
$options = new Options();
|
|
||||||
$options->set('isRemoteEnabled', true);
|
|
||||||
$options->set('isHtml5ParserEnabled', true);
|
|
||||||
|
|
||||||
$dompdf = new Dompdf($options);
|
|
||||||
$dompdf->loadHtml($html);
|
|
||||||
$dompdf->setPaper('A4', 'landscape');
|
|
||||||
$dompdf->render();
|
|
||||||
|
|
||||||
$filename = 'ecard_' . $ecardData['policy_no'] . '_' . date('Y-m-d') . '.pdf';
|
|
||||||
$dompdf->stream($filename, ['Attachment' => true]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -195,7 +195,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||||
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
|
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] . "/0/1" ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if($employee['relationship'] == 'Self' && in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
<?php if($employee['relationship'] == 'Self' && in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user