<link rel="stylesheet" href="<?php echo base_url(); ?>public/static/backend/css/layouts/view.css?v=<?= rand(10000, 100000) ?>">
<link rel="stylesheet" href="<?php echo base_url(); ?>public/static/backend/css/drag_list.css">
<!-- Page Breadcrumb -->
<div class="page-breadcrumbs">
    <ul class="breadcrumb">
        <li>
            <i class="fa fa-home"></i>
            <a href="<?= base_url('backend/dashboard'); ?>" style="color: #797979">主頁</a>
        </li>

        <li class="active" style="color: #ef4130">主頁設定</li>
    </ul>
</div>
<!-- /Page Breadcrumb -->
<!-- Page Header -->
<div class="page-header position-relative">
    <div class="header-title">
        <h1>
            主頁設定
        </h1>
    </div>
    <!--Header Buttons-->
    <div class="header-buttons">
        <a class="sidebar-toggler" href="#">
            <i class="glyphicon glyphicon-resize-horizontal"></i>
        </a>
        <a class="refresh" id="refresh-toggler" href="#">
            <i class="glyphicon glyphicon-refresh"></i>
        </a>
        <a class="fullscreen" id="fullscreen-toggler" href="#">
            <i class="glyphicon glyphicon-fullscreen"></i>
        </a>
    </div>
    <!--Header Buttons End-->
</div>
<!-- /Page Header -->
<!-- Page Body -->
<div class="page-body">


    <div class="row">
        <!-- column -->

        <div class="col">
            <!-- body table -->
            <!-- add button -->
            <div class="dropdown">
                <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    新增
                </button>
                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                    <a class="dropdown-item add-title">標題</a>
                    <a class="dropdown-item add-picture">圖片</a>
                    <!--<a class="dropdown-item add-link">連結</a> -->
                </div>
            </div>
            <!-- end add button -->

            <!-- drag table test -->
            <section class="box-typical">

                <div class="fixed-table-toolbar">
                    <div class="bars pull-left">
                        <div id="toolbar"><strong>圖片</strong></div>
                    </div>
                    <div class="pull-right search"></div>
                </div>

                <div id="info-image" class="content">(Drag the <span style="color:red">red square</span> to re-arrange the
                    order.)
                </div>
                <!-- test drag table -->
                <table width="100%" border="1" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC" class="content">
                    <tbody>
                        <tr bgcolor="#EEEEEE">
                            <td width="30" align="center"></td>
                            <td width="100">顯示次序</td>

                            <td width="200">圖片</td>
                            <td width="50">顯示</td>
                            <td width="50"></td>
                            <td width="50"></td>
                        </tr>
                    </tbody>
                </table>

                <ul id="content-list-image" class="ui-sortable">
                    <?php
                    foreach ($objects['image'] as $image) {
                    ?>
                        <li id="listItem_<?= $image['id']; ?>" class="border border-secondary my-2">
                            <table width="100%" border="1" cellpadding="2" cellspacing="1" bgcolor="#cccccc" class="content" style="background: rgb(255, 182, 182);">
                                <tbody>
                                    <tr bgcolor="#FFFFFF" id="<?= $image['id']; ?>" data-selector='image'>
                                        <td width="30" align="center">
                                            <div class="handle"></div>
                                        </td>
                                        <td width="100">
                                            <div class="rank_no_image"><?= $image['displayorder']; ?></div>
                                        </td>


                                        <td width="200"><img class="img-fluid" style="max-height:200px;" src='<?= base_url($image['path']) ?>'></td>
                                        <td width="50"><?= $image['display'] == 1 ? "是" : "否" ?></td>
                                        <td width="50" align="center"><a href="<?php echo base_url(); ?>backend/home_setting/edit?type=image&id=<?= $image['id']; ?>" class="btn btn-primary">更改</a></td>
                                        <td width="50" align="center">
                                            <button type="submit" class="btn btn-danger remove">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </li>
                    <?php
                    }
                    ?>
                </ul>
            </section>
            <section class="box-typical">

                <div class="fixed-table-toolbar">
                    <div class="bars pull-left">
                        <div id="toolbar"><strong>標題及內容</strong></div>
                    </div>
                    <div class="pull-right search"></div>
                </div>

                <div id="info-text" class="content">(Drag the <span style="color:red">red square</span> to re-arrange the
                    order.)
                </div>
                <!-- test drag table -->
                <table width="100%" border="1" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC" class="content">
                    <tbody>
                        <tr bgcolor="#EEEEEE">
                            <td width="30" align="center"></td>
                            <td width="100">顯示次序</td>
                            <td width="200">標題</td>
                            <td width="200">內容</td>
                            <td width="50">顯示</td>
                            <td width="50"></td>
                            <td width="50"></td>
                        </tr>
                    </tbody>
                </table>

                <ul id="content-list-text" class="ui-sortable">
                    <?php
                    foreach ($objects['text'] as $text) {
                    ?>
                        <li id="listItem_<?= $text['id']; ?>" class="border border-secondary my-2">
                            <table width="100%" border="1" cellpadding="2" cellspacing="1" bgcolor="#cccccc" class="content" style="background: rgb(255, 182, 182);">
                                <tbody>
                                    <tr bgcolor="#FFFFFF" id="<?= $text['id']; ?>" data-selector="text">
                                        <td width="30" align="center">
                                            <div class="handle"></div>
                                        </td>
                                        <td width="100">
                                            <div class="rank_no_text"><?= $text['displayorder']; ?></div>
                                        </td>

                                        <td width="200"><?= $text['title'] ?></td>
                                        <td width="200"><?= $text['content'] ?></td>
                                        <td width="50"><?= $text['display'] == 1 ? "是" : "否" ?></td>
                                        <td width="50" align="center"><a href="<?php echo base_url(); ?>backend/home_setting/edit?type=title&id=<?= $text['id']; ?>" class="btn btn-primary">更改</a></td>
                                        <td width="50" align="center">
                                            <button type="submit" class="btn btn-danger remove">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </li>
                    <?php
                    }
                    ?>
                </ul>
            </section>



            <!-- end body table -->
        </div>
    </div>

</div>


</div>


<!-- /Page Body -->
<script>
    var base_url = '<?= base_url(); ?>';
    var csrf_name = '<?= $csrf['name']; ?>';
    var csrf_hash = '<?= $csrf['hash']; ?>';
</script>
<script defer="" src="<?php echo base_url(); ?>public/static/backend/js/jquery-ui-min.js"></script>
<script defer="" src="<?php echo base_url(); ?>public/static/backend/js/custom/home_setting.js"></script>