<?php
/***
Auth: Vastvikta Nishad
Date: 29 Jan 2024
Description: To Create and Update New Mail Format
*/

$msg = '';
$MailTypeID = isset($_GET['MailTypeID']) ? base64_decode($_GET['MailTypeID']) : '';
//function defined in web_admin_function.php 
$mailFormatData = getMailFormatData($link, $MailTypeID);
$template_name = $mailFormatData['MailTemplateName'] ?? '';
$type = $mailFormatData['MailType'] ?? '';
$subject = $mailFormatData['MailSubject'] ?? '';
$greeting = $mailFormatData['MailGreeting'] ?? '';
$body = $mailFormatData['MailBody'] ?? '';
$description = $mailFormatData['MailDescription'] ?? '';
$signature = $mailFormatData['MailSignature'] ?? '';
$expiry = $mailFormatData['MailExpiry'] ?? '';
$isEdit = !empty($MailTypeID);
?>
<div id="success"><?php echo $msg; ?></div>
<form id="mastersrcat" method="post" action="">
<input name="id" id="id" type="hidden" value="<?php echo $MailTypeID ?>">
     <span class="breadcrumb_head" style="height:37px;padding:9px 16px"><?php echo ($isEdit ? "Edit" : "New") ?> User Registration Mail Format </span>
    <div class="style2-table">

        <div class="table">
            <table class="tableview tableview-2 main-form" width="100%">
                <tbody>
                <?php if ($msg != '') { ?>
                        <tr>
                            <td colspan="2" style="color:#ffffff; width:100%; background:#00CC66; padding:5px; border:1px solid #02944b; text-align:center;">
                                <?php echo $msg; ?>
                            </td>
                        </tr>
                    <?php } ?>
                    <tr>
                        <td>
                            <label>Template Name<em>*</em></label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <input name="template_name" id="template_name" type="text" value="<?php echo $template_name ?>" class="input-style1">
                            </div>
                        </td>
                        <td><label>Mail Type <em>*</em></label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <input name="type" id="type" type="text" value="<?php echo $type ?>" class="input-style1">
                            </div>
                        </td>

                    </tr>
                    <tr>
                        <td><label>Mail Subject<em>*</em></label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <input name="subject" id="subject" type="text" value="<?php echo $subject ?>" class="input-style1">
                            </div>
                        </td>

                        <td><label>Mail Greeting<em>*</em></label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <input name="greeting" id="greeting" type="text" value="<?php echo $greeting ?>" class="input-style1">
                            </div>
                        </td>

                    </tr>
                    <tr>
                        <td><label>Mail Body</label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <textarea name="body" id="body" cols="" rows="4" class="text-area1"><?php echo $body ?></textarea>
                            </div>
                        </td>
                        <td><label>Description<em>*</em></label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <input name="description" id="description" type="text" value="<?php echo $description ?>" class="input-style1">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <!-- <td><label>Mail Signature</label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <textarea name="signature" id="signature" cols="" rows="4" class="text-area1"><?php echo $signature ?></textarea>
                            </div>
                        </td> -->
                        <td><label>Mail Expiry (In hours)</label></td>
                        <td class="left boder0-right">

                            <div class="log-case">
                                <input name="expiry" id="expiry" type="text" value="<?php echo $expiry ?>" class="input-style1" maxlength="4">
                            </div>
                        </td>
                    </tr>

                    <tr>
                    <td class="left boder0-right" colspan="4">
                    <center>
                        <?php if ($isEdit) { ?>
                            <input name="Update" type="submit" value="Update" class="button-orange1" id="submitclkmail" style="float:inherit">
                        <?php } else { ?>
                            <input name="addbtn" type="submit" value="Create" class="button-orange1" id="submitclkmail" style="float:inherit">
                        <?php } ?>
                    </center>
                </td>
                    </tr>
                </tbody>
            </table>

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