<?php

/**
 * iCMS - i Content Management System
 * Copyright (c) 2007-2017 iCMSdev.com. All rights reserved.
 *
 * @author icmsdev <master@icmsdev.com>
 * @site https://www.icmsdev.com
 * @licence https://www.icmsdev.com/LICENSE.html
 */
defined('iPHP') or exit('What are you doing?');
self::head();
?>
<script type="text/javascript">
    $(function() {
        <?php if ($_GET['cid']) {  ?>
            iCMS.select('cid', "<?php echo $_GET['cid']; ?>");
        <?php } ?>
    });
</script>

<div class="content" id="<?php echo APP_MAINID; ?>">
    <div class="block">
        <div class="block-header block-header-default">
            <h3 class="block-title">搜索</h3>
        </div>
        <div class="block-content block-content-full">
            <form action="<?php echo iPHP_SELF; ?>" method="get">
                <input type="hidden" name="app" value="<?php echo Admincp::$APP_NAME; ?>" />
                <input type="hidden" name="do" value="<?php echo Admincp::$APP_DO; ?>" />
                <input type="hidden" name="rid" value="<?php echo $_GET['rid']; ?>" />
                <div class="form-row">
                    <div class="input-group input-group-sm col-sm-6 col-lg-6 mt-1">
                        <div class="input-group-prepend">
                            <div class="input-group-text">栏目</div>
                        </div>
                        <select v-model="cid" id="cid" name="cid" class="form-control">
                            <option value="0">所有栏目</option>
                            <?php echo Node::select(); ?>
                        </select>
                        <div class="input-group-append">
                            <div class="input-group-text">
                                <div class="custom-control custom-checkbox">
                                    <input v-model="sub" type="checkbox" class="custom-control-input" id="sub" name="sub">
                                    <label class="custom-control-label" for="sub">子栏目</label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-6 mt-1">
                        <div class="input-group-prepend">
                            <div class="input-group-text">规则</div>
                        </div>
                        <select v-model="rid" id="rid" name="rid" class="form-control">
                            <option value="0">所有规则</option>
                            <?php echo SpiderRule::option(0, $ruleArray); ?>
                        </select>
                    </div>
                </div>
                <div class="form-row">
                    <div class="input-group input-group-sm col-sm-6 col-lg-4 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="orderby">时间</label>
                        </div>
                        <input type="text" name="days" id="days" class="form-control" value="<?php echo $_GET['days'] ? $_GET['days'] : 7; ?>" />
                        <div class="input-group-append">
                            <div class="input-group-text">
                                天内
                            </div>
                        </div>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-2 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="orderby">排序</label>
                        </div>
                        <select v-model="orderby" name="orderby" id="orderby" class="form-control">
                            <option value="">默认排序</option>
                            <optgroup label="降序">
                                <?php echo self::$orderBy['DESC']; ?>
                            </optgroup>
                            <optgroup label="升序">
                                <?php echo self::$orderBy['ASC']; ?>
                            </optgroup>
                        </select>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-3 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="pageSize">每页</label>
                        </div>
                        <input class="form-control" type="text" name="pageSize" id="pageSize" value="<?php echo Paging::$pageSize; ?>" />
                        <div class="input-group-append">
                            <label class="input-group-text" for="pageSize">条记录</label>
                        </div>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-3 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="keywords">关键字</label>
                        </div>
                        <input type="text" name="keywords" class="form-control" id="keywords" value="<?php echo $_GET['keywords']; ?>" />
                        <div class="input-group-append">
                            <button class="btn btn-primary" type="submit"><i class="fa fa-fw fa-search"></i> 搜 索</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="block">
        <div class="block-header">
            <h3 class="block-title">采集错误信息</h3>
        </div>
        <div class="block-content p-0">
            <form action="<?php echo APP_URL; ?>&action=batch" method="POST" id="<?php echo APP_FORMID; ?>" target="iPHP_FRAME">
                <div class="table-responsive">
                    <table class="dataTable table text-nowrap table-hover table-striped table-vcenter font-size-sm mb-0">
                        <thead class="bg-light text-black">
                            <tr>
                                <td>方案ID</td>
                                <td>方案管理</td>
                                <td>规则ID</td>
                                <td>规则管理</td>
                                <td>错误数</td>
                                <td>日期</td>
                                <td>操作</td>
                            </tr>
                        </thead>
                        <?php foreach ((array) $rs as $key => $value) { ?>
                            <tr>
                                <td><?php echo $value['pid']; ?></td>
                                <td>
                                    <div class="btn-group">
                                        <a href="<?php echo ADMINCP_URL; ?>=spiderRule&do=test&pid=<?php echo $value['pid']; ?>" class="btn btn-alt-primary" data-toggle="modal" title="测试方案"><i class="fa fa-fw fa-bug"></i> 测试</a>
                                        <a href="<?php echo ADMINCP_URL; ?>=spiderProject&do=add&pid=<?php echo $value['pid']; ?>" class="btn btn-alt-primary" target="_blank"><i class="fa fa-fw fa-pencil-alt"></i>编辑</a>
                                    </div>
                                </td>
                                <td>
                                    <a href="<?php echo ADMINCP_URL; ?>=spider_error&do=manage&rid=<?php echo $value['rid']; ?>" class="btn btn-alt-primary"><?php echo $ruleArray[$value['rid']]; ?>[<?php echo $value['rid']; ?>]</a>
                                </td>
                                <td>
                                    <div class="btn-group">
                                        <a href="<?php echo ADMINCP_URL; ?>=spiderRule&do=test&rid=<?php echo $value['rid']; ?>" class="btn btn-alt-primary" data-toggle="modal" title="测试<?php echo $ruleArray[$value['rid']]; ?>规则"><i class="fa fa-fw fa-bug"></i> 测试</a>
                                        <a href="<?php echo ADMINCP_URL; ?>=spiderRule&do=add&rid=<?php echo $value['rid']; ?>" class="btn btn-alt-primary" target="_blank"><i class="fa fa-fw fa-pencil-alt"></i> 编辑</a>
                                        <a href="<?php echo ADMINCP_URL; ?>=spiderProject&do=manage&rid=<?php echo $value['rid']; ?>" class="btn btn-alt-primary" target="_blank"><i class="fa fa-fw fa-list"></i> 所有方案</a>
                                    </div>
                                </td>
                                <td>
                                    <?php echo $value['ct']; ?>
                                </td>
                                <td><?php echo $value['date']; ?></td>
                                <td>
                                    <div class="btn-group">
                                        <a href="<?php echo ADMINCP_URL; ?>=spider_error&do=view&pid=<?php echo $value['pid']; ?>" class="btn btn-alt-primary" data-toggle="modal" title="查看错误信息"><i class="fa fa-fw fa-eye"></i> 查看错误信息</a>
                                        <a href="<?php echo ADMINCP_URL; ?>=spider_error&action=delete&pid=<?php echo $value['pid']; ?>" class="btn btn-alt-danger" target="iPHP_FRAME"><i class="fa fa-fw fa-close"></i> 删除</a>
                                    </div>
                                </td>
                            </tr>
                        <?php } ?>
                    </table>
                </div>
            </form>
        </div>
    </div>
</div>
<?php self::foot(); ?>