2020-01-07 20:45:23 +10:00
|
|
|
function globalSearch(){$("#global-search-results").empty(),$.ajax({type:"POST",url:"/admin/searchall",data:{searchValue:$("#global-search-value").val()}}).done(e=>{$("#global-search").html('<i class="fal fa-search"></i>');let t=!1;e.customers.forEach(e=>{t=!0;let a='<li class="list-group-item global-result text-center" data-url="/admin/customer/view/'+e._id+'">';a+='<div class="row">',a+='<div class="col global-result-type gr-click"><i class="fas fa-users"></i> Customer</div>',a+='<div class="col global-result-detail gr-click">'+e.firstName+" "+e.lastName+"</div>",a+='<div class="col global-result-detail gr-click">'+e.email+"</div>",a+="</div></li>",$("#global-search-results").append(a)}),e.orders.forEach(e=>{t=!0;let a='<li class="list-group-item global-result text-center" data-url="/admin/order/view/'+e._id+'">';a+='<div class="row">',a+='<div class="col global-result-type gr-click"><i class="fas fa-cube"></i> Order</div>',a+='<div class="col global-result-detail gr-click">'+e.orderFirstname+" "+e.orderLastname+"</div>",a+='<div class="col global-result-detail gr-click">'+e.orderEmail+"</div>",a+="</div></li>",$("#global-search-results").append(a)}),e.products.forEach(e=>{t=!0;let a='<li class="list-group-item global-result text-center" data-url="/admin/product/edit/'+e._id+'">';a+='<div class="row">',a+='<div class="col global-result-type gr-click"><i class="fas fa-box-open"></i> Product</div>',a+='<div class="col global-result-detail gr-click">'+e.productTitle+"</div>",a+='<div class="col global-result-detail gr-click">'+numeral(e.productPrice).format("0.00")+"</div>",a+="</div></li>",$("#global-search-results").append(a)}),!0===t&&$("#global-search-results").removeClass("invisible")})}$(document).ready(function(){if($(document).on("click","#btnGenerateAPIkey",function(e){e.preventDefault(),$.ajax({method:"POST",url:"/admin/createApiKey"}).done(function(e){$("#apiKey").val(e.apiKey),showNotification(e.message,"success",!0)}).fail(function(e){showNotification(e.responseJSON.message,"danger")})}),$(document).on("click",".product_opt_remove",function(e){e.preventDefault();var t=$(this).closest("li").find(".opt-name").html();$.ajax({method:"POST",url:"/admin/product/removeoption",data:{productId:$("#productId").val(),optName:t}}).done(function(e){showNotification(e.message,"success",!0)}).fail(function(e){showNotification(e.responseJSON.message,"danger")})}),$(document).on("click","#product_opt_add",function(e){e.preventDefault();var t=$("#product_optName").val(),a=$("#product_optLabel").val(),o=$("#product_optType").val(),s=$("#product_optOptions").val(),i={};""!==$("#productOptions").val()&&'"{}"'!==$("#productOptions").val()&&(i=JSON.parse($("#productOptions").val()));var n='<li class="list-group-item">';n+='<div class="row">',n+='<div class="col-sm-2 opt-name">'+t+"</div>",n+='<div class="col-sm-2">'+a+"</div>",n+='<div class="col-sm-2">'+o+"</div>",n+='<div class="col-sm-4">'+s+"</div>",n+='<div class="col-sm-2 text-right">',n+='<button class="product_opt_remove btn btn-outline-danger">Remove</button>',n+="</div></div></li>",$("#product_opt_wrapper").append(n),i[t]={optName:t,optLabel:a,optType:o,optOptions:$.grep(s.split(","),function(e){return 0===e||e})},$("#productOptions").val(JSON.stringify(i)),$("#product_optName").val(""),$("#product_optLabel").val(""),$("#product_optOptions").val("")}),$("#settingsForm").validator().on("submit",function(e){e.isDefaultPrevented()||(e.preventDefault(),$("#footerHtml_input").val($(".CodeMirror")[0].CodeMirror.getValue()),$("#googleAnalytics_input").val($(".CodeMirror")[1].CodeMirror.getValue()),$("#customCss_input").val($(".CodeMirror")[2].CodeMirror.getValue()),$.ajax({method:"POST",url:"/admin/settings/update",data:$("#settingsForm").serialize()}).done(function(e){showNotification(e.message,"success")}).fail(function(e){showNotification(e.responseJSON.message,"danger")}))}),$(document).on("click","#orderStatusUpdate",function(e){$.ajax({method:"POST",url:"/admin/order/statusupdate",data:{order_id:$("#order_id").val(),status:$("#orderStatus").val()}}).done(function(e){showN
|