<?php
/***
Auth: Vastvikta Nishad
Date: 08 Feb 2024
Description:Add or Update Knowledge Base
*/
$msg = '';
$id = isset($_GET['id']) ? base64_decode($_GET['id']) : '';
$baseData = getBaseDataset($link, $id);
$qus = isset($baseData['v_qus']) ? $baseData['v_qus'] : '';
$ans = isset($baseData['v_ans']) ? $baseData['v_ans'] : '';
?>
<div id="success"><?php echo $msg; ?></div>
<div class="style-title2 st-title2-wth-lable" style="width:100%">
    <a href="admin_index.php?token=<?php echo $view_base; ?>" class="button-orange1">View Knowledge Base</a>
</div>
<form id="mastersrcat" method="post" action="">
    <input name="id" id="id" type="hidden" value="<?= $id ?>">
    <span class="breadcrumb_head" style="height:37px;padding:9px 16px"><?php echo (!empty($id) ? "Edit" : "New") ?> Knowledge Base </span>
    <div class="style2-table">
        <div class="table">
            <table class="tableview tableview-2 main-form">
                <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 align="right">
                        <td width="27%" align="center" class="normaltextabhi">Question:</td>
                        <td>
                            <input type="text" id="qus" name="qus" class="input-style1" style="width:100%;" value="<?php echo $qus; ?>" required>
                        </td>
                    </tr>
                    <tr align="right">
                        <td width="27%" align="center" class="normaltextabhi">Answer:</td>
                        <td>
                            <textarea class="input-style1" id="ans" name="ans" style="width:100%; height:200px" required=""><?php echo $ans ?></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <center>
                                <?php if ($id !== false && $id !== '') { ?>
                                    <input name="Update" type="submit" value="Update" class="button-orange1" id="submitclkbase" style="float: inherit;" />
                                <?php } else { ?>
                                    <input name="Submit" type="submit" value="Create" class="button-orange1" id="submitclkbase" style="float: inherit;" />
                                <?php } ?>
                            </center>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</form>