<?php include "../../root.class.php";
$html = new html();
$html->add_styles_page();

?>

<div class="form_down">
    <h1>EDIT TABLE</h1>
    <?php

    echo $html->input_html_from_db('tables', 'name', "`record_id` = {$_GET['record_id']}", 'name', 'name', 'name')
        ?>
    <?php
    echo $html->input_html("", $_SESSION['restorant_id'], "restorant_id", "restorant_id");
    echo $html->input_html("record_id", $_GET['record_id'], "record_id", "record_id", '', '', '', '', 'hidden');

    $authentication = new authentication();
    $data_encrypt = $authentication->encrypt_password("resto_id=" . $_SESSION['restorant_id'] . "&table_id={$_GET['record_id']}");

    if (!file_exists("../../images/qr_codes/table_qr_{$_SESSION['restorant_id']}_{$_GET['record_id']}.png")) {
        echo $html->qr_code_generator("https://resto.elegantwork.co.za/active_menu/index.php?data=" . $data_encrypt, "table_qr_{$_SESSION['restorant_id']}_{$_GET['record_id']}");

    }
    echo "<img src='../../images/qr_codes/table_qr_{$_SESSION['restorant_id']}_{$_GET['record_id']}.png' alt='QR Code' />";
    echo "<a href='../../images/qr_codes/table_qr_{$_SESSION['restorant_id']}_{$_GET['record_id']}.png' download>Download QR Code</a>";

    echo $html->submit_btn("submit", 'SAVE', 'edit_table()');

    ?>

</div>

<?php
$html->html_form_ajax("edit_table", "UPDATE", "tables", "record_id = {$_GET['record_id']}", false);
?>