<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <title>广告管理 - {{.SITE_NAME}}</title>

    <link href="{{$.StaticDomain}}/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="{{$.StaticDomain}}/static/font-awesome/css/font-awesome.min.css" rel="stylesheet">

    <link href="/static/css/main.css?version={{$.Version}}" rel="stylesheet">
{{/*<script src="/static/html5shiv/3.7.3/html5shiv.min.js"></script>*/}}
    <script src="{{$.StaticDomain}}/static/html5shiv/3.7.3/html5shiv.min.js"></script>
{{/*<script src="/static/respond.js/1.4.2/respond.min.js"></script>*/}}
    <script src="{{$.StaticDomain}}/static/respond.js/1.4.2/respond.min.js"></script>

    <link rel="stylesheet" href="/static/css/toast.css">
    <style>
        td{vertical-align: middle}
        .col-name{max-width: 200px;}
    </style>
</head>
<body>
<div class="manual-reader">
    {{template "widgets/header.html" .}}
    <div class="container manual-body">
        <div class="row">
            <div class="page-left">
                {{template "manager/menu.html" .}}
            </div>
            <div class="page-right">
                <div class="m-box">
                    <div class="box-head">
                        <strong class="box-title">广告管理</strong>
                        <a href="javascript:void(0);" class="pull-right btn btn-success" data-toggle="modal" data-target="#addAds"><i class="fa fa-plus"></i> 新增广告</a>
                    </div>
                </div>
                <div class="box-body" id="bookList">
                    <ul class="nav nav-tabs">
                        <li {{if eq .Mobile "0"}}class="active"{{end}}><a href="{{urlfor "ManagerController.Ads"}}?mobile=0">PC广告</a></li>
                        <li {{if eq .Mobile "1"}}class="active"{{end}}><a href="{{urlfor "ManagerController.Ads"}}?mobile=1">移动广告</a></li>
                    </ul>
                    <br>
                    <table class="table table-hover table-striped">
                        <thead>
                        <tr>
                            <th>位置/名称/起止时间</th>
                            <th>广告代码</th>
                            <th>广告状态</th>
                            <th>操作管理</th>
                        </tr>
                        </thead>
                        <tbody>
                            {{range $i,$item:=.Lists}}
                                <tr>
                                    <td class="col-name">
                                        <select data-refresh="true" data-url="{{urlfor "ManagerController.UpdateAds"}}?id={{$item.Id}}" name="pid" class="form-control change-update">
                                            {{range $idx,$p:=$.Positions}}
                                                <option  {{if eq $item.Pid $p.Id}}selected{{end}} value="{{$p.Id}}">
                                                    {{if $p.IsMobile}}【移动广告】{{else}}【PC广告】{{end}}{{$p.Title}}
                                                </option>
                                            {{end}}
                                        </select>
                                        <div class="input-group mgt-15px">
                                            <span class="input-group-addon">名称</span>
                                            <input type="text" name="title" class="form-control change-update" data-url="{{urlfor "ManagerController.UpdateAds"}}?id={{$item.Id}}" value="{{$item.Title}}">
                                        </div>
                                        <div class="input-group mgt-15px">
                                            <input type="text" readonly class="form-control" value="{{$item.StartTime}}">
                                            <span class="input-group-addon">-</span>
                                            <input type="text" readonly class="form-control" value="{{$item.EndTime}}">
                                        </div>
                                    </td>
                                    <td>
                                        <textarea name="code" class="form-control change-update" data-method="post" data-url="{{urlfor "ManagerController.UpdateAds"}}?id={{$item.Id}}" rows="6">{{$item.Code}}</textarea>
                                    </td>
                                    <td>
                                        {{if $item.Status}}
                                            <span class="text-success">启用</span>
                                        {{else}}
                                            <span class="text-danger">关闭</span>
                                        {{end}}
                                    </td>
                                    <td>
                                        {{if $item.Status}}
                                        <a href="{{urlfor "ManagerController.UpdateAds"}}?id={{$item.Id}}&field=status&value=0" class="ajax-get">关闭</a>
                                        {{else}}
                                        <a href="{{urlfor "ManagerController.UpdateAds"}}?id={{$item.Id}}&field=status&value=1" class="ajax-get">启用</a>
                                        {{end}}
                                        <br>
                                        <a href="{{urlfor "ManagerController.DelAds"}}?id={{$item.Id}}" class="ajax-get confirm">删除</a>
                                    </td>
                                </tr>
                            {{end}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="addAds" tabindex="-1" role="dialog" aria-labelledby="addAdsLabel">
    <div class="modal-dialog" role="document">
        <form method="post" autocomplete="off" class="form-horizontal ajax-form" action="{{urlfor "ManagerController.Ads"}}" id="addAdsForm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">新增广告</h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label class="col-sm-12">广告位置</label>
                    <div class="col-sm-12">
                        <select class="form-control" name="pid">
                            {{range .Positions}}
                                <option value="{{.Id}}">
                                    {{if .IsMobile}}【移动广告】{{else}}【PC广告】{{end}}{{.Title}}
                                </option>
                            {{end}}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-12">广告名称</label>
                    <div class="col-sm-12">
                        <input type="text" class="form-control" name="title">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-12">起止时间</label>
                    <div class="col-sm-12">
                        <div class="input-group input-group-sm">
                            <input type="date" name="start" value="{{.Now}}" class="form-control" placeholder="开始时间">
                            <span class="input-group-addon">-</span>
                            <input type="date" name="end" value="{{.Next}}" class="form-control" placeholder="截止时间">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-12">广告代码</label>
                    <div class="col-sm-12">
                        <textarea name="code" id="cates" rows="5" class="form-control" placeholder="多个分类名称，请用换行分隔"></textarea>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="modal-footer">
                <span id="form-error-message"></span>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-success" data-loading-text="保存中..." id="btnCreateCategory">保存</button>
            </div>
        </div>
        </form>
    </div>
</div><!--END Modal-->



{{/*<script src="/static/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>*/}}
<script src="{{$.StaticDomain}}/static/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>
{{/*<script src="/static/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>*/}}
<script src="/static/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="{{$.StaticDomain}}/static/js/toast.script.js"></script>
<script src="/static/js/main.js?version={{$.Version}}" type="text/javascript"></script>
</body>
</html>