text: if($(idTableList).length>0){var statusStr=":Tất cả;active:Hiện;inactive:Ẩn",hotStr=":Tất cả;1:Nổi bật;0:Thường";caption=captionButton(!0,!0),caption+=captionImport(currentModule.module),jQuery(idTableList).jqGrid({url:bUrl+currentModule.url+"/ajax_list?q=2",datatype:"json",height:"auto",autowidth:!0,shrinkToFit:!1,gridResize:!0,autoResizeAllColumns:!0,iconSet:"fontAwesome",colNames:["Status","Nổi bật","Nhãn","Danh mục","Chủng loại","Mã SP","Tên SP","Đơn vị","Giá","Giá KM","Thứ tự","Hình","Action"],colModel:[{name:"status",index:"status",align:"center",width:"80",stype:"select",searchoptions:{sopt:["eq"],value:statusStr}},{name:"hot_flg",index:"hot_flg",align:"center",width:"80",stype:"select",searchoptions:{sopt:["eq"],value:hotStr}},{name:"manufacturer",index:"manufacturer",search:!0,width:"100"},{name:"main_category",index:"main_category",search:!0,width:"100"},{name:"category",index:"category",search:!0,width:"100"},{name:"code",index:"code",search:!0,align:"center",width:"60"},{name:"name",index:"name",align:"left",search:!0,width:"150"},{name:"unit",index:"unit",align:"center",search:!0,width:"60"},{name:"price",index:"price",align:"right",search:!0,width:"60"},{name:"price_sale",index:"price_sale",align:"right",search:!0,width:"60"},{name:"order",index:"order",align:"center",search:!0,width:"60",editable:!0,editoptions:{dataInit:function(e){setTimeout(function(){$(e).numeric()},100)}}},{name:"pictures",index:"pictures",align:"center",search:!1,width:"100"},{name:"act",index:"act",editable:!1,search:!1,width:"80",align:"center"}],rownumbers:!0,rowNum:defaultNumRows,rowList:[10,20,defaultNumRows],pager:idPager,sortname:"code",sortorder:"asc",toolbarfilter:!0,viewrecords:!0,gridComplete:function(){for(var e=jQuery(idTableList).jqGrid("getDataIDs"),t=0;t<e.length;t++){var a=e[t],r=jQuery(idTableList).jqGrid("getRowData",a),n=formatButton(a,r.status,"btnStatus",bUrl+currentModule.url+"/ajax_status","modalStatus"),i=formatButton(a,r.hot_flg,"btnHot",bUrl+currentModule.url+"/ajax_hot","modalStatus"),o="",c=r.pictures.split(",");void 0!=c&&c.length>0&&$.each(c,function(e,a){""!=a&&(o+='<a class="groupFancyBox" href="/'+a+'" rel="image-'+t+'"><img src="/'+a+'" class="smalThumbInTable" /></a>')});var l=btnEditInline(a)+bntDeleteInline(a);jQuery(idTableList).jqGrid("setRowData",e[t],{status:n,hot_flg:i,pictures:o,act:l})}click_btnInGrid("modalStatus",function(){location.reload()})},ajaxRowOptions:{async:!0},caption:caption,multiselect:!0,loadBeforeSend:function(){$(this).closest("div.ui-jqgrid-view").find("table.ui-jqgrid-htable>thead>tr>th").css({"text-align":"center"})}}),tableCommon(),$("body").on("click",".btnDelete",function(e){e.preventDefault();var t=$(this).attr("href");showSmartAlert("Warning","<p>Are you sure delete this data ?</p>","[YES][NO]",function(){window.location.href=t},function(){})}),$("body").on("click","#btnMultiDelete",function(e){e.preventDefault();var t=$(this).attr("href"),a=jQuery(idTableList).jqGrid("getGridParam","selarrrow");0==a.length?showSmartAlert("Error","Please select data.","[YES]"):showSmartAlert("Warning","<p>Are you sure delete this data ?</p>","[YES][NO]",function(){$("#ids").val(a),$("#frmTopButtons").submit()},function(){})}),$(".tree").find("span").each(function(){$(this).click(function(){var e=$(this).attr("data-path"),t='{"groupOp":"AND", "rules":[{"field":"path","op":"cn","data": "'+e+'"}]}';jQuery(idTableList).jqGrid("setGridParam",{datatype:"json",postData:{filters:t},search:!0}).trigger("reloadGrid")})}),$("a.groupFancyBox").fancybox()}if($("#frmProduct").length>0){gen_url($('input[name="name_product"]'),$('input[name="url_product"]')),preventBeginWith("input[name=price_product]",48),preventBeginWith("input[name=price_product_sale]",48),preventBeginWith("input[name=price_product_sale_percent]",48),preventBeginWith("input[name=quantity_product]",48),$('input[name="code_product"]').limit("20","#code_product_limit"),$('input[name="manufacturer_product"]').limit("200","#manufacturer_product_limit"),$('input[name="name_product"]').limit("200","#name_product_limit"),$('input[name="url_product"]').limit("200","#url_product_limit"),$('textarea[name="desc_product"]').limit("1000","#desc_product_limit"),$("#have_sale").is(":checked")?($("#sale_wrap").show(),$('input[name="have_sale"]').val(1),$("input[name=price_product]").addClass("strikethrough")):($("#sale_wrap").hide(),$('input[name="have_sale"]').val(0),$("input[name=price_product]").removeClass("strikethrough"),$("input[name=price_product_sale]").val(""),$("input[name=price_product_sale_percent]").val("")),$("label[for=have_sale]").click(function(){$("#have_sale").is(":checked")?($("#sale_wrap").hide(),$('input[name="have_sale"]').val(0),$("input[name=price_product]").removeClass("strikethrough"),$("input[name=price_product_sale]").val(""),$("input[name=price_product_sale_percent]").val("")):($("#sale_wrap").show(),$('input[name="have_sale"]').val(1),$("input[name=price_product]").addClass("strikethrough"))}),preventLongMore_Number("input[name=price_product_sale_percent]",2),selectFile(".btnSelectThumbnail","images",!0,!1),$("body").on("click",".thumbnailDel",function(e){e.preventDefault();var t=$(this).parent(".thumbnailItem"),a=t.parent(".thumbnailWrapper"),r=a.prev().children(".inputThumbnail"),n=JSON.parse(r.val());if(1==n.length)r.val("");else{var i=t.find("img").attr("src"),o=n.indexOf(i);n.splice(o,1),n.length>0&&r.val(JSON.stringify(n))}t.remove(),0==$(".thumbnailItem").length&&a.html("").html(defaultIMG)});var editor=CKEDITOR.replace("content_product",{entities_latin:!1,entities_greek:!1,toolbar:"Full"}),$validator=$("#frmProduct").validate({rules:{code_product:{required:!0,maxlength:20},name_product:{required:!0,maxlength:200},url_product:{required:!0,maxlength:200},desc_product:{maxlength:1e3}},messages:{code_product:{required:"Mã sản phẩm bắt buộc nhập",maxlength:"Tối đa 20 ký tự"},name_product:{required:"Name bắt buộc nhập",maxlength:"Tối đa 200 ký tự"},url_product:{required:"URL bắt buộc nhập",maxlength:"Tối đa 200 ký tự"},desc_product:{maxlength:"Tối đa 1000 ký tự"}},highlight:function(e){$(e).closest(".form-group").removeClass("has-success").addClass("has-error")},unhighlight:function(e){$(e).closest(".form-group").removeClass("has-error").addClass("has-success")},errorElement:"span",errorClass:"help-block",errorPlacement:function(e,t){t.parent(".input-group").length?e.insertAfter(t.parent()):e.insertAfter(t)},submitHandler:function(e){return $.ajax({url:bUrl+"product/update",type:"POST",cache:!1,dataType:"json",data:{csrf_hash:$.cookie("csrf_cookie_ci"),post_id:$('input[name="post_id"]').val(),code:$('input[name="code_product"]').val(),manufacturer:$('input[name="manufacturer_product"]').val(),name:$('input[name="name_product"]').val(),url:$('input[name="url_product"]').val(),desc:$('textarea[name="desc_product"]').val(),price:$('input[name="price_product"]').val(),price_sale:$('input[name="price_product_sale"]').val(),price_sale_percent:$('input[name="price_product_sale_percent"]').val(),quantity:$('input[name="quantity_product"]').val(),unit:$('input[name="unit_product"]').val(),thumbnail:$('input[name="thumbnail"]').val(),order:$('input[name="order"]').val(),status:$('input[name="status"]:checked').val(),category_id:$('select[name="parent_id"]').val(),category_name:$('select[name="parent_id"] option:selected').text(),detail:editor.getData()},success:function(e){"1"==e.err?showSmartAlert("Error",e.msg,"[YES]"):window.location.href=bUrl+currentModule.url},error:function(){showSmartAlert("Error","Can send data. Please contact to admin.","[YES]")}}),!1}})}