<?php
/***
Auth: Roshni Gupta
Date: 02 Aug 2025
Description: Display and Delete Province
*/
?><div class="style2-table">
    <div class="style-title">
        <h3>Mail</h3>
        <div class="row">
            
            <?php $new_mail_sign = base64_encode('new_mail_sign');?>

            <!-- <div class="col-sm-3" style="text-align: end;">
                <a href="admin_index.php?token=<?php echo $new_mail_sign;?>" class="button-orange1">New Mail Signature</a>
            </div> -->
        </div>    
    </div>
    <div id="success"></div>
    <form name="frmService" action="" method="post">
        <div class="table" id="SRallview"> 
            <div class="">
                <div class="div2">
                    <table class="tableview tableview-2" id="admin_table">
                        <thead>
                            <tr class="background">
                                <td align="left" width="5%">S.No.</td>
                                <td align="left">Signature</td>
                                <td align="left">Signature Image</td>
                                <td align="left" width="5%">Action</td>
                            </tr>
                        </thead>
                       <tbody>
<?php
$result = tbl_mailformats();

if (mysqli_num_rows($result) == 0) {
    echo '<tr><td colspan="4" align="center" class="contentred">No records found!</td></tr>';
} else {
    $count = 1;
    while ($row_doc = mysqli_fetch_assoc($result)) {

        $id = base64_encode($row_doc['id']);
        $signatureImg = $row_doc['MailSignImage'];
        ?>
        <tr>
            <!-- S.No -->
            <td align="left"><?php echo $count; ?></td>

            <!-- Signature text -->
            <td align="left">
                <?php echo $row_doc['MailSignature']; ?>
            </td>

            <!-- Signature image preview -->
            <td align="left">
                <?php if (!empty($signatureImg)) { ?>
                    <img 
                        src="<?php echo $SiteURL . 'CRM/' . $signatureImg; ?>" 
                        width="120" 
                        style="border:1px solid #ddd; padding:4px;"
                        alt="Signature Image"
                    >
                <?php } else { ?>
                    <span style="color:#999;">No image</span>
                <?php } ?>
            </td>

            <!-- Action -->
            <td align="left">
                <a href="admin_index.php?token=<?php echo $new_mail_sign; ?>&id=<?php echo $row_doc['MailTypeID']; ?>">
                    <img src="<?php echo $SiteURL; ?>public/images/edit-icon.png" alt="Edit">
                </a>
            </td>
        </tr>
        <?php
        $count++;
    }
}
?>
</tbody>

                    </table>
                </div>
            </div>
        </div>
    </form>
</div>
