<!-- **********************************************************************************************************************************************************
    MAIN CONTENT
    *********************************************************************************************************************************************************** -->
<!--main content start-->
<section id="main-content">
    <section class="wrapper">
        <div class="row mt">
            <div class="col-lg-12">
                <div class="form-panel">
                    <h4 class="mb"><i class="fa fa-angle-right"></i>Change Order Main Menu</h4>
                    <section id="unseen">
                        <div id="pesan"></div>
                        <table class="table table-bordered table-striped table-condensed">
                            <thead>
                                <tr>
                                    <th>Menu Name</th>
                                    <th>No Urut</th>
                                    <th>&nbsp;</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                foreach ($data_menu->result() as $menu) {
                                    ?>
                                    <tr>
                                        <td><?= $menu->menu_name ?></td>
                                        <td class="numeric">
                                            <input type="text" value="<?= $menu->order ?>" name="order" id="order_<?= $menu->id_menu ?>">
                                        </td>
                                        <td class="numeric">
                                            <button type="button" class="btn btn-primary btn-xs" onclick="return changeOrder('<?= $menu->id_menu ?>')">Update</button>
                                        </td>
                                    </tr>
                                    <?php
                                }
                                ?>
                            </tbody>
                        </table>
                        <a href="<?= base_url() ?>admin/menu">
                            <button type="button" class="btn btn-default"><i class="fa fa-arrow-left"></i> Back Main Menu</button>
                        </a>
                    </section>
                    <div style="clear: both"></div>
                </div>
            </div>
        </div><!--row -->
    </section>
</section>
<script>
    function changeOrder(id_menu) {
        var order = $("#order_"+id_menu).val();
        $.ajax({
            type: "POST",
            data: "id_menu=" + id_menu + "&order=" + order,
            url: "<?= base_url() ?>admin/menu/updateOrder",
            success: function(data) {
                $("#unseen").load();
                $("#pesan").html(data);
            }
        });
    }
</script>
