<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
include('code/db.php');
if (isset($_GET['referral_id'])) {
    $referral_id = $_GET['referral_id'] ? base64_decode($_GET['referral_id']) : '';
    $query = $db->query("select * from wp_referral_form where id = '$referral_id' ");
    $data = $query->fetch();
    $results = !empty($data['form_data']) ? unserialize(html_entity_decode($data['form_data'])) : [];
    $first_name = isset($results['first_name']) ? $results['first_name'] : '';
    $last_name = isset($results['last_name']) ? $results['last_name'] : '';
    $patient_phone_number = isset($results['patient_phone_number']) ? $results['patient_phone_number'] : '';
    $date_of_birth = isset($results['date_of_birth']) ? $results['date_of_birth'] : ''; 
    $date_of_xray = isset($results['date_of_xray']) ? $results['date_of_xray'] : '';    
    $referring_doctor_first_name = isset($results['referring_doctor_first_name']) ? $results['referring_doctor_first_name'] : '';
    $referring_doctor_last_name = isset($results['referring_doctor_last_name']) ? $results['referring_doctor_last_name'] : '';
    $referring_doctor_phone_number = isset($results['referring_doctor_phone_number']) ? $results['referring_doctor_phone_number'] : '';
    $is_3rd_moral_evaluation = isset($results['is_3rd_moral_evaluation']) ? $results['is_3rd_moral_evaluation'] : '';
    $is_fill_arch_solution = isset($results['is_fill_arch_solution']) ? $results['is_fill_arch_solution'] : '';
    $is_implant_evaluation = isset($results['is_implant_evaluation']) ? $results['is_implant_evaluation'] : '';
    $is_extractions_only = isset($results['is_extractions_only']) ? $results['is_extractions_only'] : '';
    $is_expose_bond = isset($results['is_expose_bond']) ? $results['is_expose_bond'] : '';
    $is_evaluate_for_grafting = isset($results['is_evaluate_for_grafting']) ? $results['is_evaluate_for_grafting'] : '';
    $is_pathology_evaluation = isset($results['is_pathology_evaluation']) ? $results['is_pathology_evaluation'] : '';
    $comments = isset($results['comments']) ? $results['comments'] : '';
    $diagnosis = isset($results['diagnosis']) ? $results['diagnosis'] : '';
    $diagnosis_other = isset($results['diagnosis_other']) ? $results['diagnosis_other'] : '';
    $permanent_teeth = isset($results['permanent_teeth']) ? $results['permanent_teeth'] : [];
    $primary_teeth = isset($results['primary_teeth']) ? $results['primary_teeth'] : [];
} else {
    $first_name = $last_name = $patient_phone_number = $date_of_birth = $date_of_xray = $referring_doctor_first_name = $referring_doctor_last_name = $referring_doctor_phone_number = $is_3rd_moral_evaluation = $is_fill_arch_solution = $is_implant_evaluation = $is_extractions_only = $is_expose_bond = $is_evaluate_for_grafting = $is_pathology_evaluation = $comments = $diagnosis = $diagnosis_other = '';
    $permanent_teeth = $primary_teeth = [];
}
$contact_name = $first_name .' '. $last_name;
$referring_doctor_name = $referring_doctor_first_name .' '. $referring_doctor_last_name;
function url()
{
    return sprintf(
        "%s://%s",
        isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
        $_SERVER['SERVER_NAME']
    );
}
$html = '';
$html .= '
<style>
    @page{
        // size: 1230px 12.5in;
        margin: 20px 30px 0;
    }
</style>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td width="100%" align="center" cellpadding="0" cellspacing="0">
            <img src="' . url() . '/lp-asset/lp-images/header_logo.png" alt=" Header Logo">
        </td>
    </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0"><h2 style="font-size: 16px;line-height: 16px;color: #000;margin: 0 0 8px;">Demographic Information</h2></td>
    </tr>
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0">
            <table width="100%" cellpadding="0" cellspacing="0" style="box-shadow: 4px 4px 25px rgb(0 0 0 / 10%);border: 1px solid #3b598a;margin-bottom:10px;">
                <tr>
                    <td width="100%" cellpadding="0" cellspacing="0"" style="font-size: 14px;line-height: 14px;color: #3b598a;padding: 5px 8px 0; font-weight: 700;">Patient Information</td>
                </tr>
                <tr>
                    <td width="100%" style="padding: 0 5px 10px;">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="11%" style="padding: 5px 0 0;">
                                    <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Patient Name:</label>
                                </td>
                                <td width="22%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;max-width:200px;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $first_name . '">
                                </td>
                                <td width="22%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;max-width:200px;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $last_name . '">
                                </td>
                                <td width="16%" style="padding: 5px 0 0;">
                                    <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Cell Phone Number:</label>
                                </td>
                                <td width="27%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;max-width:200px;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $patient_phone_number . '">
                                </td>
                            </tr>
                        </table>
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="11%" style="padding: 5px 0 0;">
                                    <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Date of Birth:</label>
                                </td>
                                <td width="38%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $date_of_birth . '">
                                </td>
                                <td width="14%" style="padding: 5px 0 0;">
                                    <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Date of X-Ray:</label>
                                </td>
                                <td width="37%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $date_of_xray . '">
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0"><h2 style="font-size: 16px;line-height: 16px;color: #000;margin: 0 0 8px;">Referring Information</h2></td>
    </tr>
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0">
            <table width="100%" cellpadding="0" cellspacing="0" style="box-shadow: 4px 4px 25px rgb(0 0 0 / 10%);border: 1px solid #3b598a;margin-bottom:10px;">
                <tr>
                    <td width="100%" cellpadding="0" cellspacing="0"" style="font-size: 14px;line-height: 14px;color: #3b598a;padding: 5px 8px 0; font-weight: 700;">Referring Doctor Information</td>
                </tr>
                <tr>
                    <td width="100%" style="padding: 0 5px 10px;">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="14%" style="padding: 5px 0 0;">
                                    <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Referring Doctor:</label>
                                </td>
                                <td width="19%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;max-width:200px;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $referring_doctor_first_name . '">
                                </td>
                                <td width="19%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;max-width:200px;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $referring_doctor_last_name . '">
                                </td>
                                <td width="26%" style="padding: 5px 0 0;">
                                    <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Referring Doctor Phone Number:</label>
                                </td>
                                <td width="22%" style="padding: 5px 4px 0 0;" valign="bottom">
                                    <input type="text" style="border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;max-width:200px;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;vertical-align: bottom;" value="' . $referring_doctor_phone_number . '">
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0"><h2 style="font-size: 16px;line-height: 16px;color: #000;margin: 0 0 8px;">Treatment Information</h2></td>
    </tr>
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0">
            <table width="100%" cellpadding="0" cellspacing="0" style="box-shadow: 4px 4px 25px rgb(0 0 0 / 10%);border: 1px solid #3b598a;margin-bottom:10px;">
                <tr>
                    <td width="100%" cellpadding="0" cellspacing="0"" style="font-size: 14px;line-height: 14px;color: #3b598a;padding: 5px 8px 0; font-weight: 700;">Diagnosis:</td>
                </tr>
                <tr>
                    <td width="100%" style="padding: 0 5px 10px;">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="5%" style="padding: 5px 0 0;">
                                    <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Diagnosis:</label>
                                </td>
                                <td width="95%" style="padding: 5px 4px 0 0;border: none;border-bottom: 0.25px solid #212529;padding: 1px 2px;width: 100%;font-size: 12px;line-height: 1.2px;font-weight: 600;color: #000;" valign="bottom">
                                    ' . $diagnosis . '
                                </td>
                            </tr>
                        </table>';
                        if (!empty($diagnosis_other)) {
                            $html .= '
                            <table width="100%" cellpadding="0" cellspacing="0" style="margin: 10px 0;">
                                <tr>
                                    <td width="100%" cellpadding="0" cellspacing="0" style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #212529;padding: 5px 10px;border: 1px solid #6E717C;height: 70px;vertical-align: top;">
                                        ' . $diagnosis_other . '
                                    </td>
                                </tr>
                            </table>';
                        }
                        $html .= '
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
		<td width="100%" cellpadding="0" cellspacing="0">
			<table width="100%" cellpadding="0" cellspacing="0" style="box-shadow: 4px 4px 25px rgb(0 0 0 / 10%);border: 1px solid #3b598a;margin-bottom:10px;">
				<tr>
                    <td width="100%" style="padding: 0 0px 5px;">
						<table width="100%" cellpadding="0" cellspacing="0">
							<tr>
                                <td width="60%" cellpadding="0" cellspacing="0" style="font-size: 14px;line-height: 14px;color: #3b598a;padding: 5px 8px 0; font-weight: 700;">Permanent:</td>
                                <td width="40%" cellpadding="0" cellspacing="0" style="font-size: 14px;line-height: 14px;color: #3b598a;padding: 5px 8px 0; font-weight: 700;">Deciduous:</td>
                            </tr>
                        </table>
                    </td>
				</tr>
				<tr>
					<td width="100%" style="padding: 0 0px 5px;">
						<table width="100%" cellpadding="0" cellspacing="0">
							<tr>
								<td width="60%" align="center" cellpadding="0" cellspacing="0" style="padding: 5px 0 0;">
									<table width="100%" align="center" cellpadding="0" cellspacing="0">
										<tr>
											<td width="20%" cellpadding="0" cellspacing="0" style="text-align: right;font-size: 12px;line-height: 1.2;font-weight: 600;color: #000;text-transform: uppercase;">right</td>
											<td width="60%" cellpadding="0" cellspacing="0">
												<table width="190" align="center" cellpadding="0" cellspacing="0">
													<tr>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("1", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("1", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">1</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("2", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("2", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">2</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("3", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("3", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">3</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("4", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("4", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">4</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("5", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("5", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">5</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("6", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("6", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">6</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("7", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("7", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">7</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("8", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("8", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">8</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("9", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("9", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">9</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("10", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("10", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">10</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("11", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("11", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">11</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("12", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("12", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">12</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("13", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("13", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">13</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("14", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("14", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">14</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("15", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("15", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">15</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("16", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("16", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">16</div>
														</td>
													</tr>
													<tr>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("32", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("32", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">32</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("31", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("31", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">31</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("30", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("30", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">30</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("29", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("29", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">29</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("28", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("28", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">28</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("27", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("27", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">27</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("26", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("26", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">26</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("25", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("25", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">25</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("24", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("24", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">24</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("23", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("23", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">23</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("22", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("22", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">22</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("21", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("21", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">21</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("20", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("20", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">20</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("19", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("19", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">19</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("18", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("18", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">18</div>
														</td>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;color: ' . (in_array("17", $permanent_teeth) ? '#FFF' : '#000') . ';' . (in_array("17", $permanent_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">17</div>
														</td>
													</tr>
												</table>
											</td>
											<td width="20%" cellpadding="0" cellspacing="0" style="text-align: left;font-size: 12px;line-height: 1.2;font-weight: 600;color: #000;text-transform: uppercase;">left</td>
										</tr>
									</table>
								</td>
								<td width="40%" align="center" cellpadding="0" cellspacing="0" style="padding: 5px 0 0;">
									<table width="100%" align="center" cellpadding="0" cellspacing="0">
										<tr>
											<td width="20%" cellpadding="0" cellspacing="0" style="text-align: right;font-size: 12px;line-height: 1.2;font-weight: 600;color: #000;text-transform: uppercase;">right</td>
											<td width="60%" cellpadding="0" cellspacing="0">
												<table width="120" align="center" cellpadding="0" cellspacing="0">
													<tr>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("a", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("a", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">a</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("b", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("b", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">b</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("c", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("c", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">c</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("d", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("d", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">d</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("e", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("e", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">e</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("f", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("f", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">f</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("g", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("g", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">g</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("h", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("h", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">h</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("i", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("i", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">i</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("j", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("j", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">j</div>
														</td>
													</tr>
													<tr>
														<td valign="top" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("t", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("t", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">t</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("s", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("s", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">s</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("r", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("r", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">r</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("q", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("q", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">q</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("p", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("p", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">p</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("o", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("o", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">o</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("n", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("n", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">n</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("m", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("m", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">m</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("l", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("l", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">l</div>
														</td>
														<td valign="bottom" align="center" cellpadding="0" cellspacing="0" style="padding-top:1px">
															<div style="text-align: center;font-size: 12px;line-height: 14px;font-weight: 600;width: 14px;height: 14px;border-radius:2px;text-transform: uppercase;color: ' . (in_array("k", $primary_teeth) ? '#FFF' : '#000') . ';' . (in_array("k", $primary_teeth) ? 'background: #3b598a;' : 'background: #E6E9EC;') . '">k</div>
														</td>
													</tr>
												</table>
											</td>
											<td width="20%" cellpadding="0" cellspacing="0" style="text-align: left;font-size: 12px;line-height: 1.2;font-weight: 600;color: #000;text-transform: uppercase;">left</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0">
            <table width="100%" cellpadding="0" cellspacing="0" style="box-shadow: 4px 4px 25px rgb(0 0 0 / 10%);border: 1px solid #3b598a;margin-bottom:10px;">
                <tr>
                    <td width="100%" valign="top" cellpadding="0" cellspacing="0" style="padding: 0 0px 5px;">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="33.33%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="58.33%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">3rd Molar Evaluation</label>
                                            </td>
                                            <td width="41.67%" cellpadding="0" cellspacing="0">
                                                <table align="right" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_3rd_moral_evaluation == 'Yes' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">Yes</label>
                                                                <span style="display: ' . ($is_3rd_moral_evaluation == 'Yes' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_3rd_moral_evaluation == 'No' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;margin: 0 0 0 5px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">No</label>
                                                                <span style="display: ' . ($is_3rd_moral_evaluation == 'No' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="33.33%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="58.33%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Expose & Bond</label>
                                            </td>
                                            <td width="41.67%" cellpadding="0" cellspacing="0">
                                                <table align="right" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_expose_bond == 'Yes' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">Yes</label>
                                                                <span style="display: ' . ($is_expose_bond == 'Yes' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_expose_bond == 'No' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;margin: 0 0 0 5px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">No</label>
                                                                <span style="display: ' . ($is_expose_bond == 'No' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="33.33%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="58.33%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Extractions</label>
                                            </td>
                                            <td width="41.67%" cellpadding="0" cellspacing="0">
                                                <table align="right" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_extractions_only == 'Yes' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">Yes</label>
                                                                <span style="display: ' . ($is_extractions_only == 'Yes' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_extractions_only == 'No' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;margin: 0 0 0 5px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">No</label>
                                                                <span style="display: ' . ($is_extractions_only == 'No' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td width="100%" valign="top" cellpadding="0" cellspacing="0" style="padding: 0 0px 5px;">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="33.33%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="58.33%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Full Arch Solution*</label>
                                            </td>
                                            <td width="41.67%" cellpadding="0" cellspacing="0">
                                                <table align="right" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_fill_arch_solution == 'Yes' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">Yes</label>
                                                                <span style="display: ' . ($is_fill_arch_solution == 'Yes' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_fill_arch_solution == 'No' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;margin: 0 0 0 5px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">No</label>
                                                                <span style="display: ' . ($is_fill_arch_solution == 'No' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="33.33%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="58.33%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Implant Evaluation</label>
                                            </td>
                                            <td width="41.67%" cellpadding="0" cellspacing="0">
                                                <table align="right" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_implant_evaluation == 'Yes' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">Yes</label>
                                                                <span style="display: ' . ($is_implant_evaluation == 'Yes' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_implant_evaluation == 'No' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;margin: 0 0 0 5px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">No</label>
                                                                <span style="display: ' . ($is_implant_evaluation == 'No' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="33.33%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="58.33%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Evaluate for Grafting</label>
                                            </td>
                                            <td width="41.67%" cellpadding="0" cellspacing="0">
                                                <table align="right" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_evaluate_for_grafting == 'Yes' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">Yes</label>
                                                                <span style="display: ' . ($is_evaluate_for_grafting == 'Yes' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_evaluate_for_grafting == 'No' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;margin: 0 0 0 5px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">No</label>
                                                                <span style="display: ' . ($is_evaluate_for_grafting == 'No' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td width="100%" valign="top" cellpadding="0" cellspacing="0" style="padding: 0 0px 5px;">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="33.33%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="58.33%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #6E717C;padding-right: 3px;" class="input-main-label">Pathology Evaluation</label>
                                            </td>
                                            <td width="41.67%" cellpadding="0" cellspacing="0">
                                                <table align="right" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_pathology_evaluation == 'Yes' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">Yes</label>
                                                                <span style="display: ' . ($is_pathology_evaluation == 'Yes' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                        <td align="left" cellpadding="0" cellspacing="0" >
                                                            <div style="background: ' . ($is_pathology_evaluation == 'No' ? '#373c4e' : '#3b598a') . ';padding: 4px 8px;border-radius: 2px;margin: 0 0 0 5px;">
                                                                <input type="radio" style="display: none" value="">
                                                                <label style="line-height: 13px;font-size: 12px;color: #fff;margin: 0;font-weight: 600;display: inline-block;">No</label>
                                                                <span style="display: ' . ($is_pathology_evaluation == 'No' ? 'inline-block' : 'none') . '; width: 10px;text-align: left;"><img width="10" src="' . url() . '/lp-asset/lp-images/check-solid.png" alt="check-solid" style="margin: 0 0 0 2px;"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="66.66%" cellpadding="0" cellspacing="0" style="padding: 5px 5px 0;">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="100%" cellpadding="0" cellspacing="0">
                                                <label style="font-size: 12px;line-height: 1.5;font-weight: 600;color: #6E717C;display: inline-block;" class="input-main-label">*A full arch solution requires a conference between doctors.</label>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0"><h2 style="font-size: 16px;line-height: 16px;color: #000;margin: 0 0 8px;">Conclusion</h2></td>
    </tr>
    <tr>
        <td width="100%" cellpadding="0" cellspacing="0">
            <table width="100%" cellpadding="0" cellspacing="0" style="box-shadow: 4px 4px 25px rgb(0 0 0 / 10%);border: 1px solid #3b598a;margin-bottom:10px;">
                <tr>
                    <td width="100%" cellpadding="0" cellspacing="0"" style="font-size: 14px;line-height: 14px;color: #3b598a;padding: 5px 8px 0; font-weight: 700;">Additional Notes / Comments</td>
                </tr>
                <tr>
                    <td width="100%" style="padding: 0 5px 10px;">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="100%" cellpadding="0" cellspacing="0" style="font-size: 12px;line-height: 1.2;font-weight: 600;color: #212529;padding: 5px 10px;border: 1px solid #6E717C;height: 70px;vertical-align: top;">
                                    ' . $comments . '
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>';
if (!empty($data['attachment'])) {
    $html .= '<table width="100%" cellpadding="0" cellspacing="0">
                    <tr>';
$attachments_string = $data['attachment'] ?? '';
$base_url = url(); // Make sure this function is defined and returns the absolute base URL (REQUIRED for PDF links)

$view_xray_html = '';

if (!empty($attachments_string)) {
    // Split the string into an array of individual paths, filtering out empty entries
    $attachment_paths = array_filter(explode(',', $attachments_string));
    
    $count = count($attachment_paths);

    if ($count > 0) {
        
        // Start the table cell structure for the PDF content
        $view_xray_html .= '<td style="font-size:16px; font-weight:400; color:#3b598a;">';
        
        foreach ($attachment_paths as $index => $path) {
            
            $path = trim($path);
            
            // Determine the link text: "View X-ray" if count is 1, or "View X-ray [N]" otherwise
            $link_text = ($count === 1) ? 'View X-ray' : 'View X-ray ' . ($index + 1);
            
            // Construct the full URL using the base URL and the relative path
            $full_url = $base_url . $path;
            
            // Append the link HTML (using inline styles for reliable PDF rendering)
            $view_xray_html .= '<a href="' . htmlspecialchars($full_url) . '" target="_blank" style="';
            $view_xray_html .= 'color: #3b598a; ';
            $view_xray_html .= 'border:1px solid #3b598a; ';
            $view_xray_html .= 'border-radius: 6px; ';
            $view_xray_html .= 'padding: 10px 12px; ';
            $view_xray_html .= 'text-decoration: none; ';
            $view_xray_html .= 'display: inline-block; ';
            $view_xray_html .= 'margin:6px 6px 10px 0;';
            $view_xray_html .= '">';
            $view_xray_html .= $link_text;
            $view_xray_html .= '</a>';
        }
        
        $view_xray_html .= '</td>';
        
    }
}

// Append the generated HTML to your main $html variable
$html .= $view_xray_html;
                    $html .= '</tr>
                </table>';
}
$html .= '</td>
    </tr>
</table>';
if (empty($data['attachment'])) {
    $html .= '<table>
    <tbody>
        <tr>
            <td style="font-size:20px; font-weight:600; color:#6E717C; padding-bottom:20px;">Thank You For Your Referral</td>
        </tr>
        <tr>
            <td style="font-size:14px; font-weight:400; color:#6E717C; padding-bottom:8px;">Please email xrays to:</td>
        </tr>
        <tr>
            <td style="font-size:14px; font-weight:400; color:#3b598a; padding-bottom:8px;">info@niagaraoms.com</td>
        </tr>
        <tr>
            <td style="font-size:14px; font-weight:400; color:#3b598a;">Fax - (716) 276-3552</td>
        </tr>
    </tbody>
</table>';
}
$html .= '
    <table width="100%" align="center" cellpadding="0" cellspacing="0" style="box-shadow: 4px 4px 35px rgb(0 0 0 / 10%);margin: 10px 0 0;border-top: 1px dashed #efefef;">
        <tr>
            <td>
                <label style="width: 100%;font-size: 12px;line-height: 1.5;font-weight: 600;color: #6E717C;margin: 10px 0;display: inline-block;" class="row-label">All patients must have a pre-surgical consultation with Dr. Nigalye before scheduling surgery.</label><br>
                <label style="width: 100%;font-size: 12px;line-height: 1.5;font-weight: 600;color: #6E717C;margin: 10px 0;display: inline-block;" class="row-label">Please notify our office 72 hours in advance if you are unable to keep your appointment.</label><br>
                <label style="width: 100%;font-size: 12px;line-height: 1.5;font-weight: 600;color: #6E717C;margin: 10px 0;display: inline-block;" class="row-label"><a style="color: #3b598a; text-decoration: none" href="https://maps.app.goo.gl/NE9SfbnjLK7JD3868" target="_blank">6490 Main Street, Suite 5, Williamsville, New York 14221</a></label>
                <label style="width: 100%;font-size: 12px;line-height: 1.5;font-weight: 600;color: #6E717C;margin: 10px 0;display: inline-block;" class="row-label">Phone/SMS: <a style="color: #3b598a; text-decoration: none" href="tel:(716) 276-3553">(716) 276-3553</a> • Fax: <a style="color: #3b598a; text-decoration: none" href="fax:(716) 276-3552">(716) 276-3552</a> <br><a style="color: #3b598a; text-decoration: none" href="www.niagaraoms.com" target="_blank">www.niagaraoms.com</a></label>
            </td>
        </tr>
    </table>
';
// print_r($html);
// die;
$filename = "Referral - $contact_name by $referring_doctor_name";
$path = $_SERVER['DOCUMENT_ROOT'] . "/dompdf/autoload.inc.php";
require($path);
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->set_option('isRemoteEnabled', true);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream($filename, array("Attachment" => 0));