<div class="container-fluid">
    <div class="row">
        <div class="col-md-1">

        </div>
        <div class="col-md-9">
            <h4>广告管理   <small><a href="<?php echo site_url('thirdparty/recommend/tips/add'); ?>">添加广告</a></small></h4>
            <form id="searchForm" method="post" action="<?php echo site_url('thirdparty/recommend/index/search'); ?>" class="navbar-form navbar-left">
          <div class="input-group">
            <input type="text" class="form-control input-sm" name="keywords" id="keywords" value="<?php if (!empty($lastKeyword)) {echo $lastKeyword;} ?>" style="min-width:450px;">
            <input type="hidden" name="byWhat" id="byWhatInput" >
          </div>
            <span class="input-group-btn">
              <button class="btn btn-default btn-sm" id="searchByTitleBtn" type="button">搜索标题</button>
              <button class="btn btn-default btn-sm" id="searchByLabelBtn" type="button">搜索标签</button>
              <button class="btn btn-default btn-sm" id="searchByContentBtn" type="button">搜索内容</button>
            </span>
        </form>
        <script>
          var searchForm = document.getElementById('searchForm');
          var searchByTitleBtn = document.getElementById('searchByTitleBtn');
          var searchByLabelBtn = document.getElementById('searchByLabelBtn');
          var searchByContentBtn = document.getElementById('searchByContentBtn');
          var byWhatInput = document.getElementById('byWhatInput');

          function submitSearch(byWhat) {
            byWhatInput.value = byWhat;
            searchForm.submit();
          }
          searchByTitleBtn.addEventListener('click', function(event) {
            submitSearch('byTitle');
          });
          searchByLabelBtn.addEventListener('click', function(event) {
            submitSearch('byLabel');
          });
          searchByContentBtn.addEventListener('click', function(event) {
            submitSearch('byContent');
          });

        </script>
            <table class="table table-striped">

                <thead>
                <tr>
                    <th class="col-md-2">#</th>
                    <th class="col-md-9">标题</th>
                    <th class="col-md-9">标签</th>
                    <th class="col-md-4">过期时间</th>
                </tr>
                </thead>
                <tbody>

                <?php foreach ($tipsList as $key=>$item){ ?>
                <tr class="<?php if($item->it_expires<time()){echo 'danger';} ?>">
                    <td><?php echo ++$key; ?></td>
                    <td>
                        <a href="<?php echo site_url('thirdparty/recommend/tips/edit/'.$item->it_id); ?>"><?php echo $item->it_title; ?></a>
                    </td>
                    <td><?php echo htmlspecialchars($item->it_code); ?></td>
                    <td><?php echo date('m/d/Y', $item->it_expires); ?></td>
                </tr>
            <?php } ?>



                </tbody>
            </table>
        </div>
        <div class="col-md-14">
            <h4>广告和信息推荐绑定设置</h4>
            <?php foreach ($groupList as $item) {
                if ($item->is_level == 0) { ?>
                    <div class="row">
                        <div class="col-md-24">
                            <div class="panel panel-default">
                                <div class="panel-heading"><a
                                            href="<?php echo site_url('thirdparty/recommend/index/bind/' . $item->is_id) ?>"> <?php echo $item->ic_title; ?></a>
                                </div>
                                <div class="panel-body">
                                    <ul class="list-inline">
                                        <?php if ($item->is_level == 0) {
                                            foreach ($groupList as $item_child) {
                                                if ($item_child->is_parent_id == $item->is_id) {
                                                    echo ' <li><a href="' . site_url('thirdparty/recommend/index/bind/' . $item_child->is_id) . '">' . $item_child->ic_url_title . '</a></li> ';
                                                }
                                            }
                                        } ?>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php }
            } ?>
        </div>
    </div>
</div>