{layout:default} {class:Shop.Admin.promotion.PromotionType_Edit}
<lbhead>
    <title>
        <%if (model.id != 0)
          { %>
        <%=Tag("编辑促销")%>
        <%}
          else
          { %><%=Tag("添加促销")%>
        <%}%>-<%=Tag("优惠促销")%>-<%=site.title%></title>
</lbhead>
<lbfile>
    <link href="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.css" rel="stylesheet">
</lbfile>
<lbpath>
    <h3 class="text-themecolor m-b-0 m-t-0"><%=model.id ==0?Tag("添加规则"):Tag("编辑规则")%></h3>
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=MenuJump&pid=0"><%=Tag("管理首页")%></a></li>
        <li class="breadcrumb-item"><a href="Default.aspx"><%=Tag("优惠促销")%></a></li>
        <li class="breadcrumb-item active"><%=model.id == 0 ? Tag("添加促销") : Tag("编辑促销")%></li>
    </ol>
</lbpath>
<lbbody>
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <form action="javascript:SaveObj();" novalidate>
                    <div class="row">
                        <div class="col-12 m-b-10">
                            <%if (PageReturnMsg == ""){%>
                            <button type="submit" class="btn btn-success"><i class="ti-check"></i> <%=Tag("保存")%></button>
                            <button class="btn btn-default" onclick="PromotionEdit(<%=model.id %>);"><i class="ti-settings"></i> <%=Tag("编辑规则")%></button>
                            <%}%>
                        </div>
                    </div>
                    <ul class="nav nav-tabs customtab" role="tablist">
                        <%
                        List<DB.LebiShop.Lebi_Language_Code> tab_langs = Shop.Bussiness.Language.Languages();foreach (DB.LebiShop.Lebi_Language_Code lang in tab_langs){
                        %>
                        <li class="nav-item"> <a class="nav-link <%if (tab_langs.FirstOrDefault().Code == lang.Code){%>active show<%}%>" data-toggle="tab" href="#lang_<%=lang.Code %>" role="tab" aria-selected="true"><%=lang.Name %></a> </li>
                        <%
                        }
                        %>
                    </ul>
                    <div class="tab-content m-t-20">
                        <%foreach (DB.LebiShop.Lebi_Language_Code lang in tab_langs){%>
                        <div class="tab-pane <%if (tab_langs.FirstOrDefault().Code == lang.Code){%>active show<%}%>" id="lang_<%=lang.Code %>" role="tabpanel">
                            <div class="form-group">
                                <label for="Name<%=lang.Code %>"><%=Tag("名称")%>：</label>
                                <input type="text" id="Name<%=lang.Code %>" name="Name<%=lang.Code %>" value="<%=Shop.Bussiness.Language.Content(model.Name,lang.Code) %>" <%if (tab_langs.FirstOrDefault().Code == lang.Code){%>required<%}%> class="form-control" shop="true">
                            </div>
                            <div class="form-group">
                                <label for="Content<%=lang.Code %>"><%=Tag("介绍")%>：</label>
                                <textarea id="Content<%=lang.Code %>" name="Content<%=lang.Code %>" class="form-control" style="height: 200px;" shop="true"><%=Shop.Bussiness.Language.Content(model.Content, lang.Code)%></textarea>
                            </div>
                        </div>
                        <%}%>
                    </div>
                    <h5 class="box-title m-t-20 m-b-20"><%=Tag("通用信息")%></h5>
                    <div class="form-group">
                        <label for="UserLevel_ids"><%=Tag("会员分组")%>：</label>
                        <div class="input-group">
                            <%foreach (DB.LebiShop.Lebi_UserLevel l in userlevels){ %>
                            <label class="custom-control custom-radio m-r-20">
                                <input type="radio" id="UserLevel_ids<%=l.id %>" name="UserLevel_ids" value="<%=l.id %>" class="custom-control-input" shop="true" <%=CheckStatus(model.UserLevel_ids,l.id) %>>
                                <span class="custom-control-label"><%=Lang(l.Name) %></span>
                            </label>
                            <%} %>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Time_Start"><%=Tag("时间")%>：</label>
                        <div class="input-daterange input-group">
                            <input type="text" id="Time_Start" name="Time_Start" value="<%=FormatTime(model.Time_Start) %>" class="form-control" shop="true">
                            <div class="input-group-append">
                                <span class="input-group-text bg-info b-0 text-white">-</span>
                            </div>
                            <input type="text" id="Time_End" name="Time_End" value="<%=FormatTime(model.Time_End) %>" class="form-control" shop="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Type_id_PromotionType"><%=Tag("类型")%>：</label>
                        <div class="input-group">
                            <%=Shop.Bussiness.EX_Type.TypeRadio("PromotionType", "Type_id_PromotionType", model.Type_id_PromotionType, "shop=\"true\" onclick=\"ChangeType();\"")%>
                            <select style="display:none;" shop="true" id="Supplier_id" name="Supplier_id"><%=GetShops(model.Supplier_id)%></select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Type_id_PromotionStatus"><%=Tag("状态")%>：</label>
                        <div class="input-group">
                            <%=Shop.Bussiness.EX_Type.TypeRadio("PromotionStatus", "Type_id_PromotionStatus", model.Type_id_PromotionStatus, "shop=\"true\"")%>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="IsRefuseOther_1"><%=Tag("排斥其它")%>：</label>
                        <div class="input-group">
                            <label class="custom-control custom-radio m-r-20">
                                <input type="radio" id="IsRefuseOther_1" name="IsRefuseOther" value="1" class="custom-control-input" shop="true" <%=model.IsRefuseOther==1?"checked":"" %>>
                                <span class="custom-control-label"><%=Tag("是")%></span>
                            </label>
                            <label class="custom-control custom-radio">
                                <input type="radio" id="IsRefuseOther_0" name="IsRefuseOther" value="0" class="custom-control-input" shop="true" <%=model.IsRefuseOther==0?"checked":"" %>>
                                <span class="custom-control-label"><%=Tag("否")%></span>
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Sort"><%=Tag("优先级")%>：</label>
                        <input type="text" id="Sort" name="Sort" value="<%=model.Sort %>" class="form-control" shop="true" onkeyup="value=value.replace(/[^\d]/g,'')">
                    </div>
                    <div class="form-group">
                        <label for="Remark"><%=Tag("内部备注")%>：</label>
                        <textarea id="Remark" name="Remark" class="form-control" style="height: 60px;" shop="true"><%=model.Remark%></textarea>
                        <div class="button-group m-t-5">
                            <button type="button" class="btn btn-default btn-xs btn-sm" onclick="javascript:resizeEditor('Remark',100);"><%=Tag("展开")%></button>
                            <button type="button" class="btn btn-default btn-xs btn-sm" onclick="javascript:resizeEditor('Remark',-100);"><%=Tag("收缩")%></button>
                        </div>
                    </div>
                    <%if (PageReturnMsg == ""){%>
                    <button type="submit" class="btn btn-success"><i class="ti-check"></i> <%=Tag("保存")%></button>
                    <%}%>
                </form>
            </div>
        </div>
    </div>
</lbbody>
<lbscripts>
    <script src="<%=site.WebPath %>/Editor/ckeditor/ckeditor.js"></script>
    <script src="<%=site.WebPath %>/Editor/ckfinder/ckfinder.js"></script>
    <script src="<%=site.AdminAssetsPath %>/plugins/moment/moment.js"></script>
    <script src="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.js"></script>
    <script>
        $('#Time_Start').daterangepicker({
            singleDatePicker: true,
            showDropdowns: true,
            locale: {format: 'YYYY-MM-DD'}
        });
        $('#Time_End').daterangepicker({
            singleDatePicker: true,
            showDropdowns: true,
            locale: {format: 'YYYY-MM-DD'}
        });
        ! function(window, document, $) {
            "use strict";
            $("input,select,textarea").not("[type=submit]").jqBootstrapValidation()
        }(window, document, jQuery);
        var langs = "<%=Shop.Bussiness.Language.LanguageCodes()%>"
        var Arrlangs = langs.split(",");
        for (var i = 0; i < Arrlangs.length; i++){
            CKEDITOR.replace('Content'+ Arrlangs[i] +'', {
                height: '150',
                toolbar: 'Basic',
                language: '<%=Tag("CKEditor语言")%>'
            });
        }
        function SaveObj() {
            var postData = GetFormJsonData("shop");
            var url="<%=site.AdminPath %>/ajax/ajax_sale.aspx?__Action=PromotionType_Edit&id=<%=model.id %>";
            RequestAjax(url,postData,function(res){MsgBox(1, "<%=Tag("操作成功")%>", "?id="+res.id)});
        }
        function PromotionEdit(id)
        {
            window.location="promotion.aspx?tid="+id;
        }
        function ChangeType()
        {
            var t=$("input[name='Type_id_PromotionType']:checked").val();
            if(t==422)
                $('#Supplier_id').show();
            else
                $('#Supplier_id').hide();
        }
        ChangeType();
    </script>
</lbscripts>