{layout:default} {class:Shop.Admin.product.product_batch_edit}
<lbhead>
    <title><%=Tag("批量修改")%>-<%=site.title%></title>
</lbhead>
<lbfile>
    <link href="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.css" rel="stylesheet">
    <link href="<%=site.AdminAssetsPath %>/plugins/lightbox/css/lightbox.min.css" rel="stylesheet" />

</lbfile>
<lbpath>
    <h3 class="text-themecolor m-b-0 m-t-0"><%=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="<%=site.AdminPath %>/product/"><%=Tag("商品列表")%></a></li>
        <li class="breadcrumb-item active"><%=Tag("批量修改")%></li>
    </ol>
</lbpath>
<lbbody>
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-9 m-b-10">
                        <%if (PageReturnMsg == ""){%>
                        <button class="btn btn-success" onclick="Update()"><i class="ti-check"></i> <%=Tag("保存")%></button>
                        <button class="btn btn-default" onclick="Product_Status_Edit_muti(1);"><i class="ti-arrow-up"></i> <%=Tag("上架")%></button>
                        <button class="btn btn-default" onclick="Product_Status_Edit_muti(0);"><i class="ti-arrow-down"></i> <%=Tag("下架")%></button>
                        <%}%>
                    </div>
                    <div class="col-md-3 m-b-10">
                        <div class="input-group">
                            <input type="text" id="key" name="key" value="<%=key %>" class="form-control" onkeydown="if(event.keyCode==13){search_();}">
                            <div class="input-group-append">
                                <button type="button" class="btn btn-primary" onclick="search_();"><i class="ti-search"></i></button>
                                <button class="btn btn-default" data-toggle="modal" data-target="#SearchModal"><i class="ti-filter"></i></button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="table-responsive sorttable">
                    <table class="table table-hover no-wrap">
                        <thead>
                            <tr>
                                <th width="40" class="selectAll">
                                    <a href="javascript:void(0);" onclick="$('input[name=\'sonproductid\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));"><%=Tag("全选")%></a>
                                </th>
                                <th>
                                    <%=Tag("图片")%>
                                </th>
                                <th style="width:7%">
                                    <%=Tag("编号")%>
                                </th>
                                <th>
                                    <%=Tag("商品名称")%>
                                </th>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"Price_MarketDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"Price_MarketDesc","icon")%>"><%=Tag("市场价")%></div>
                                </th>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"PriceDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"PriceDesc","icon")%>"><%=Tag("销售价")%></div>
                                </th>
                                <%if (Shop.Bussiness.EX_Admin.CheckPower("product_price_cost")){ %>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"Price_CostDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"Price_CostDesc","icon")%>"><%=Tag("成本价")%></div>
                                </th>
                                <%} %>
                                <%if (Shop.LebiAPI.Service.Instanse.Check("plugin_product_price")){ %>
                                <%foreach(DB.LebiShop.Lebi_UserLevel ul in userlevels){ %>
                                <th>
                                    <%=Lang(ul.Name) %>
                                </th>
                                <%} %>
                                <%}%>
                                <%if (!IsEditStock){ %>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"CountDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"CountDesc","icon")%>"><%=Tag("库存")%></div>
                                </th>
                                <%}%>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"FreezeDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"FreezeDesc","icon")%>"><%=Tag("冻结库存")%></div>
                                </th>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"SalesDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"SalesDesc","icon")%>"><%=Tag("销量")%></div>
                                </th>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"ViewsDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"ViewsDesc","icon")%>"><%=Tag("浏览量")%></div>
                                </th>
                                <th style="width:7%" onclick="OrderBy('<%=OrderByName(OrderBy,"SortDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"SortDesc","icon")%>"><%=Tag("排序")%></div>
                                </th>
                                <th style="width:10%" onclick="OrderBy('<%=OrderByName(OrderBy,"StatusDesc")%>');">
                                    <div class="th-inner sort <%=OrderByName(OrderBy,"StatusDesc","icon")%>"><%=Tag("状态")%></div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <%foreach (DB.LebiShop.Lebi_Product model in models){
                            List<Shop.Model.ProductUserLevelPrice> ulps = Shop.Bussiness.EX_Product.UserLevelPrice(model.UserLevelPrice);
                            %>
                                <tr>
                                    <td>
                                        <label class="custom-control custom-checkbox">
                                            <input type="checkbox" id="checkbox<%=model.id %>" name="sonproductid" value="<%=model.id %>" class="custom-control-input" ShopKeyID="true">
                                            <span class="custom-control-label"></span>
                                        </label>
                                        <input type="hidden" name="IDS" shop="true" value="<%=model.id %>" />
                                    </td>
                                    <td>
                                        <a href="<%=Image(model.ImageOriginal,"big") %>" data-lightbox="image<%=model.id %>"><img style="height: 30px;width: 30px;vertical-align:middle" src="<%=Image(model.ImageOriginal,50,50) %>" /></a>
                                    </td>
                                    <td>
                                        <input type="text" id="Number<%=model.id %>" name="Number<%=model.id %>" value="<%=model.Number%>" class="form-control form-control-sm" shop="true">
                                    </td>
                                    <td>
                                        <div class="input-group">
                                            <%int i = 0; foreach (DB.LebiShop.Lebi_Language_Code batchlang in Shop.Bussiness.Language.Languages())
                                            {%><input type="<%if (lang == batchlang.Code){%>text<%}else{ %>hidden<%} %>" id="Name<%=batchlang.Code %><%=model.id %>" name="Name<%=model.id %><%=batchlang.Code %>" value="<%=Shop.Bussiness.Language.Content(model.Name, batchlang.Code)%>" class="form-control form-control-sm" shop="true"><%i = i+1;
                                            } %>
                                            <div class="input-group-append">
                                                <span class="input-group-text" onclick="Product_Name_Edit(<%=model.id %>);" style="cursor:pointer"><i class="ti-pencil-alt"></i>
                                                </span>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <input type="text" id="Price_Market<%=model.id %>" name="Price_Market<%=model.id %>" value="<%=FormatMoney(model.Price_Market," Number") %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                    </td>
                                    <td>
                                        <input type="text" id="Price<%=model.id %>" name="Price<%=model.id %>" value="<%=FormatMoney(model.Price,"Number") %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                    </td>
                                    <%if (Shop.Bussiness.EX_Admin.CheckPower("product_price_cost")){ %>
                                    <td>
                                        <input type="text" id="Price_Cost<%=model.id %>" name="Price_Cost<%=model.id %>" value="<%=FormatMoney(model.Price_Cost,"Number") %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                    </td>
                                    <%} %>
                                    <%if (Shop.LebiAPI.Service.Instanse.Check("plugin_product_price")){ %>
                                    <%foreach(DB.LebiShop.Lebi_UserLevel ul in userlevels){ %>
                                    <td>
                                        <input type="text" id="UserLevelPrice<%=model.id %>_<%=ul.id %>" name="UserLevelPrice<%=model.id %>_<%=ul.id %>" value="<%=FormatMoney(GetUserLevelPrice(ulps,ul.id),"Number") %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                    </td>
                                    <%} %>
                                    <%} %>
                                    <%if (!IsEditStock){ %>
                                    <td>
                                        <%if (CountSon(model.id) == 0){ %>
                                        <input type="text" id="Count_Stock<%=model.id %>" name="Count_Stock<%=model.id %>" value="<%=model.Count_Stock %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                        <%}else{ %>
                                        <input type="hidden" id="Count_Stock<%=model.id %>" name="Count_Stock<%=model.id %>" value="<%=model.Count_Stock %>" shop="true"><%=model.Count_Stock %>
                                        <%} %>
                                    </td>
                                    <%}%>
                                    <td>
                                        <input type="text" id="Count_Freeze<%=model.id %>" name="Count_Freeze<%=model.id %>" value="<%=model.Count_Freeze %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                    </td>
                                    <td>
                                        <input type="text" id="Count_Sales_Show<%=model.id %>" name="Count_Sales_Show<%=model.id %>" value="<%=model.Count_Sales_Show %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                    </td>
                                    <td>
                                        <input type="text" id="Count_Views_Show<%=model.id %>" name="Count_Views_Show<%=model.id %>" value="<%=model.Count_Views_Show %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d\.]/g,'')">
                                    </td>
                                    <td>
                                        <input type="text" id="Sort<%=model.id %>" name="Sort<%=model.id %>" value="<%=model.Sort %>" class="form-control form-control-sm" shop="true" onkeyup="value=value.replace(/[^\d]/g,'')">
                                    </td>
                                    <td>
                                        <select id="ProductStatus<%=model.id %>" name="ProductStatus<%=model.id %>" class="form-control form-control-sm" shop="true">
                                            <%=Shop.Bussiness.EX_Type.TypeOption("ProductStatus", model.Type_id_ProductStatus, CurrentLanguage)%>
                                        </select>
                                    </td>
                                </tr>
                                <%} %>
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-12">
                        <nav aria-label="Page navigation">
                            <%=PageString%>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="SearchModal" tabindex="-1" role="dialog" aria-labelledby="SearchModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title"><%=Tag("高级搜索")%></h4>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <select id="lang" name="lang" class="form-control">
                                <option value=""><%=Tag("语言")%></option>
                                <%=Shop.Bussiness.Language.LanguageOption(lang) %>
                            </select>
                        </div>
                        <div class="form-group">
                            <select id="status" name="status" class="form-control">
                                <option value="0"><%=Tag("状态")%></option>
                                <%=Shop.Bussiness.EX_Type.TypeOption("ProductStatus", status, CurrentLanguage)%>
                            </select>
                        </div>
                        <div class="form-group">
                            <select id="Type_id_ProductType" name="Type_id_ProductType" class="form-control">
                                <option value="320"><%=Tag("商品类型")%></option>
                                <%=Shop.Bussiness.EX_Type.TypeOption("ProductType", Type_id_ProductType, CurrentLanguage)%>
                            </select>
                        </div>
                        <div class="form-group">
                            <select id="Pro_Type_id" name="Pro_Type_id" class="form-control">
                                <option value=""><%=Tag("全部类别")%></option>
                                <%=Shop.Bussiness.EX_Product.TypeOption(0,Pro_Type_id,0,CurrentLanguage.Code,Shop.Bussiness.EX_Admin.Project().Pro_Type_ids)%>
                            </select>
                        </div>
                        <div class="form-group">
                            <select id="brand" name="brand" class="form-control">
                                <option value="0"><%=Tag("商品品牌")%></option>
                                <%=Shop.Bussiness.EX_Product.BrandOption(brand, CurrentLanguage.Code)%>
                            </select>
                        </div>
                        <div class="form-group">
                            <select id="tag" name="tag" class="form-control">
                                <option value="0"><%=Tag("商品标签")%></option>
                                <%=Shop.Bussiness.EX_Product.Pro_TagOption(tag, CurrentLanguage.Code)%>
                            </select>
                        </div>
                        <div class="form-group">
                            <div class="input-group">
                                <input type="text" name="daterange" id="daterange" class="form-control">
                                <div class="input-group-append">
                                    <span class="input-group-text">
                                        <span class="ti-calendar"></span>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <input type="text" id="key" name="key" class="form-control" value="<%=key %>" onkeydown="if(event.keyCode==13){modal_search_();}">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><i class="ti-close"></i> <%=Tag("关闭")%></button>
                    <button type="button" class="btn btn-success" onclick="modal_search_();"><i class="ti-search"></i> <%=Tag("搜索")%></button>
                </div>
            </div>
        </div>
    </div>
</lbbody>
<lbscripts>
    <script src="<%=site.AdminAssetsPath %>/plugins/lightbox/lightbox.min.js"></script>
    {MOD:DateRangePicker}
    <script>
        function search_() {
            var key = $("#key").val();
            window.location = "?key=" + escape(key) + "&OrderBy=<%=OrderBy%>";
        }
        function modal_search_() {
            $("#SearchModal").modal("hide");
            var lang = $("#lang").val();
            var key = $("#key").val();
            var brand = $("#brand").val();
            var Pro_Type_id = $("#Pro_Type_id").val();
            var tag = $("#tag").val();
            var dateFrom = $("#dateFrom").val();
            var dateTo = $("#dateTo").val();
            var status = $("#status").val();
            var Type_id_ProductType = $("#Type_id_ProductType").val();
            window.location = "?key=" + escape(key) + "&brand=" + brand + "&tag=" + tag + "&Pro_Type_id=" + Pro_Type_id + "&dateFrom=" + dateFrom + "&dateTo=" + dateTo + "&status=" + status + "&lang=" + lang + "&Type_id_ProductType=" + Type_id_ProductType + "&OrderBy=<%=OrderBy%>";
        }
        function Update() {
            var postData = GetFormJsonData("shop");
            var url = "<%=site.AdminPath %>/ajax/ajax_product.aspx?__Action=Product_Batch_Update";
            RequestAjax(url, postData, function () { MsgBox(1, "<%=Tag("操作成功")%>", "?") });
        }
        function Product_Name_Edit(id) {
            var lang = $("#lang").val();
            $("#EditModal").modal("show");
            $.ajax({
                url: "product_name_edit_window.aspx",
                type: "GET",
                cache: false,
                data: { id: id, removelang: lang },
            }).done(function (result) {
                $("#EditModal .modal-content").html(result);
            });
        }
        function OrderBy(url) {
            MsgBox(4, "<%=Tag("正在排序，请稍后")%> ……", url);
        }
        function Product_Status_Edit_muti(status) {
            var postData = GetFormJsonData("ShopKeyID");
            var url = "<%=site.AdminPath %>/ajax/ajax_product.aspx?__Action=Product_Status_Edit_muti&status=" + status;
            RequestAjax(url, postData, function () { MsgBox(1, "<%=Tag("操作成功")%>", "?") });
        }
    </script>
</lbscripts>