<?php
$menu->id = $_GET[id];
$m = $menu->menu();
?>
<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="page-header">
                <h1>
                    Data Menu
                    <small>
                        <i class="ace-icon fa fa-angle-double-right"></i>
                        Edit Menu
                    </small>
                </h1>
            </div><!-- /.page-header -->
        </div>
        <form class="form-horizontal" role="form" action="view/view/modul/mod_menu/aksi_menu.php?aksi=edit" method="post" >
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Nama Menu </label>
                    <div class="col-sm-9">
                        <input type="text" id="form-field-1" placeholder="Nama Menu" name="nama" class="col-xs-10 col-sm-5" value="<?php echo $m[nama]; ?>" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Page </label>
                    <div class="col-sm-9">
                        <select id="form-field-select-1" class="col-xs-10 col-sm-5" name="page">
                            <?php
                                if ($m[aksi]=='home') {
                                   ?> <option value="home" selected>Home</option> <?php
                                }else{
                                   ?> <option value="home">Home</option> <?php 
                                }

                                if ($m[aksi]=='list') {
                                   ?> <option value="list" selected>List Post</option> <?php
                                }else{
                                   ?> <option value="list">List Post</option> <?php 
                                }

                                if ($m[aksi]=='galery') {
                                   ?> <option value="galery" selected>Galery</option> <?php
                                }else{
                                   ?> <option value="galery">Galery</option> <?php 
                                }

                                if ($m[aksi]=='kontak') {
                                   ?> <option value="kontak" selected>Kontak</option> <?php
                                }else{
                                   ?> <option value="kontak">Kontak</option> <?php 
                                }

                                $p = $page->listpageaktif();

                                while($i<count($p)){
                                    if ($p[$i][id_page]==$m[id_page]) {
                                        ?>
                                            <option value="<?php echo $p[$i][id]; ?>" selected><?php echo $p[$i][judul]; ?></option>
                                        <?php
                                    }else{
                                        ?>
                                            <option value="<?php echo $p[$i][id]; ?>"><?php echo $p[$i][judul]; ?></option>
                                        <?php
                                    }
                                    $i++;
                                }
                                unset($i);
                            ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Kategori </label>
                    <div class="col-sm-9">
                        <select id="form-field-select-1" class="col-xs-10 col-sm-5" name="kategori">
                            <?php
                                $k = $kategori->listkategoripost();

                                while($i<count($k)){
                                    if ($k[$i][id]==$m[id_katpost]) {
                                        ?>
                                            <option value="<?php echo $k[$i][id]; ?>" selected><?php echo $k[$i][nama]; ?></option>
                                        <?php
                                    }else{
                                        ?>
                                            <option value="<?php echo $k[$i][id]; ?>"><?php echo $k[$i][nama]; ?></option>
                                        <?php
                                    }
                                    $i++;
                                }
                                unset($i);
                            ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Order </label>
                    <div class="col-sm-9">
                        <input type="text" id="form-field-1" placeholder="Order" name="order" class="col-xs-10 col-sm-5" value="<?php echo $m[nama]; ?>" />
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <h3 class="header smaller lighter blue">Sub Menu</h3>
                        <div class="clearfix">
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Nama Sub Menu </label>
                                <div class="col-sm-9">
                                    <input type="text" id="form-field-1" placeholder="Nama Sub Menu" name="nama" class="col-xs-10 col-sm-5" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Page </label>
                                <div class="col-sm-9">
                                    <select id="form-field-select-1" class="col-xs-10 col-sm-5" name="pagesub">
                                        <option value="home">Home</option>
                                        <option value="list">List Post</option>
                                        <option value="galery">Galery</option>
                                        <option value="kontak">Kontak</option>
                                        <?php
                                            $p = $page->listpageaktif();

                                            while($i<count($p)){
                                                ?>
                                                    <option value="<?php echo $p[$i][id]; ?>"><?php echo $p[$i][judul]; ?></option>
                                                <?php
                                                $i++;
                                            }
                                            unset($i);
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Kategori </label>
                                <div class="col-sm-9">
                                    <select id="form-field-select-1" class="col-xs-10 col-sm-5" name="kategorisub">
                                        <?php
                                            $k = $kategori->listkategoripost();

                                            while($i<count($k)){
                                                ?>
                                                    <option value="<?php echo $k[$i][id]; ?>"><?php echo $k[$i][nama]; ?></option>
                                                <?php
                                                $i++;
                                            }
                                            unset($i);
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Order </label>
                                <div class="col-sm-9">
                                    <input type="text" id="form-field-1" placeholder="Order" name="order" class="col-xs-10 col-sm-5" />
                                </div>
                            </div>  
                            <div class="form-group">
                                <div class="col-sm-9">
                                    <button class="btn btn-info btn-xs" type="submit" name="key" value="1">
                                        <i class="ace-icon fa fa-check bigger-110"></i>
                                        Tambah
                                    </button>
                                </div>
                            </div>      
                            <div class="pull-right tableTools-container"></div>
                        </div>
                        <div>
                            <table id="simple-table" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th>Nama</th>
                                        <th>Order</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                        $s = $menu->listsubmenu($m[id]);
                                        while($i<count($s)){
                                    ?>
                                            <tr>
                                                <td><?php echo"".$s[$i][nama].""; ?></td>
                                                <td><?php echo"".$s[$i][submenu_order].""; ?></td>
                                                <td>
                                                    <div class="hidden-sm hidden-xs action-buttons">
                                                        <a class="red" href="view/view/modul/mod_menu/aksi_menu.php?aksi=deletesub&id=<?php echo"".$s[$i][id].""; ?>">
                                                            <i class="ace-icon fa fa-trash-o bigger-130"></i>
                                                        </a>
                                                    </div>
                                                </td>
                                            </tr>
                                    <?php
                                            $i++;
                                        }
                                        unset($i);
                                    ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div><!-- /.col --> 
            <div class="col-xs-12">
                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="button" name="key" value="2">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            Simpan
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i>
                            Reset
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <a href="index.php?module=menu">
                            <button class="btn" type="button">
                                <i class="ace-icon fa fa-undo bigger-110"></i>
                                Cancel
                            </button>
                        </a>
                    </div>
                </div>
            </div>                           
        </form>
    </div><!-- /.row -->
</div><!-- /.page-content -->