<!-- **********************************************************************************************************************************************************
    MAIN CONTENT
    *********************************************************************************************************************************************************** -->
<!--main content start-->
<?php
if ($data_sub_menu->num_rows() == 0) {
    $id_sub_menu = "";
    $main_menu = "";
    $title = "";
    $order = "";
    $active = "";
    $key_page = "";
} else {
    foreach ($data_sub_menu->result() as $sub) {
        $id_sub_menu = $sub->id_sub_menu;
        $main_menu = $sub->menu_id;
        $title = $sub->title;
        $order = $sub->order;
        $active = $sub->active;
        $key_page = $sub->key_page;
    }
}
?>
<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> Sub Menu</h4>
                    <form class="form-horizontal style-form" method="POST" action="<?= base_url() ?>admin/sub_menu/simpanData" enctype="multipart/form-data">
                        <input type="hidden" name="id_sub_menu" value="<?= $id_sub_menu ?>">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">Main Menu</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="main_menu">
                                    <option>-Choose One-</option>
                                    <?php
                                    foreach ($data_main_menu->result() as $main) {
                                        if ($main_menu == $main->id_menu) {
                                            $select = "selected";
                                        } else {
                                            $select = "";
                                        }
                                        ?>
                                        <option <?= $select ?> value="<?= $main->id_menu ?>"><?= $main->menu_name ?></option>                                    
                                        <?php
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">Sub Menu</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" value="<?= $title ?>" name="title">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">Order Number</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" value="<?= $order ?>" name="order">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">Picture</label>
                            <div class="col-sm-10">
                                <input type="file" class="form-control" name="userfile">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">Active</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="active">
                                    <option value="<?= $active ?>"><?= $active ?></option>
                                    <option>-Choose One-</option>
                                    <option value="Yes">Yes</option>
                                    <option value="No">No</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">Page</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="key_page">
                                    <option value="">-Choose One-</option>
                                    <?php
                                    foreach ($data_page as $pg) {
                                        if ($key_page == $pg->key_page) {
                                            $select = "selected";
                                        } else {
                                            $select = "";
                                        }
                                        ?>
                                        <option <?= $select ?> value="<?= $pg->key_page ?>"><?= $pg->title ?> (<?= $pg->key_page ?>)</option>
                                        <?php
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>

                        <hr/>
                        <a href="<?= base_url() ?>admin/sub_menu">
                            <button type="button" class="btn btn-default"><i class="fa fa-arrow-left"></i> Cancel</button>
                        </a>
                        <button type="submit" class="btn btn-primary pull-right"><i class="fa fa-save"></i> Save Data</button>
                    </form>
                    <div style="clear: both"></div>
                </div>
            </div>
        </div><!--row -->
    </section>
</section>
