Heera/public/assets/js/pages/ecommerce-order.init.js

1 line
13 KiB
JavaScript
Raw Normal View History

2024-05-16 03:46:08 +00:00
var str_dt=function(e){var e=new Date(e),t=(e.getHours()+":"+e.getMinutes()).split(":"),a=12<=(n=t[0])?"PM":"AM",n=(n%=12)||12,t=(t=t[1])<10?"0"+t:t;return month=""+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],day=""+e.getDate(),year=e.getFullYear(),month.length<2&&(month="0"+month),[(day=day.length<2?"0"+day:day)+" "+month+","+year+" <small class='text-muted'>"+n+":"+t+" "+a+"</small>"]},isChoiceEl=document.getElementById("idStatus"),choices=new Choices(isChoiceEl,{searchEnabled:!1}),isPaymentEl=document.getElementById("idPayment"),choices=new Choices(isPaymentEl,{searchEnabled:!1}),checkAll=document.getElementById("checkAll"),perPage=(checkAll&&(checkAll.onclick=function(){for(var e=document.querySelectorAll('.form-check-all input[type="checkbox"]'),t=document.querySelectorAll('.form-check-all input[type="checkbox"]:checked').length,a=0;a<e.length;a++)e[a].checked=this.checked,e[a].checked?e[a].closest("tr").classList.add("table-active"):e[a].closest("tr").classList.remove("table-active");document.getElementById("remove-actions").style.display=0<t?"none":"block"}),8),editlist=!1,options={valueNames:["id","customer_name","product_name","date","amount","payment","status"],page:perPage,pagination:!0,plugins:[ListPagination({left:2,right:2})]},orderList=new List("orderList",options).on("updated",function(e){0==e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="block":document.getElementsByClassName("noresult")[0].style.display="none";var t=1==e.i,a=e.i>e.matchingItems.length-e.page;document.querySelector(".pagination-prev.disabled")&&document.querySelector(".pagination-prev.disabled").classList.remove("disabled"),document.querySelector(".pagination-next.disabled")&&document.querySelector(".pagination-next.disabled").classList.remove("disabled"),t&&document.querySelector(".pagination-prev").classList.add("disabled"),a&&document.querySelector(".pagination-next").classList.add("disabled"),e.matchingItems.length<=perPage?document.querySelector(".pagination-wrap").style.display="none":document.querySelector(".pagination-wrap").style.display="flex",e.matchingItems.length==perPage&&document.querySelector(".pagination.listjs-pagination").firstElementChild.children[0].click(),0<e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="none":document.getElementsByClassName("noresult")[0].style.display="block"});const xhttp=new XMLHttpRequest;xhttp.onload=function(){var e=JSON.parse(this.responseText);Array.from(e).forEach(function(e){orderList.add({id:'<a href="apps-ecommerce-order-details.html" class="fw-medium link-primary">#VZ'+e.id+"</a>",customer_name:e.customer_name,product_name:e.product_name,date:str_dt(e.date),amount:e.amount,payment:e.payment,status:isStatus(e.status)}),orderList.sort("id",{order:"desc"}),refreshCallbacks()}),orderList.remove("id",'<a href="apps-ecommerce-order-details.html" class="fw-medium link-primary">#VZ2101</a>')},xhttp.open("GET","assets/json/orders-list.init.json"),xhttp.send();var isValue=(isCount=(new DOMParser).parseFromString(orderList.items.slice(-1)[0]._values.id,"text/html")).body.firstElementChild.innerHTML,idField=document.getElementById("orderId"),customerNameField=document.getElementById("customername-field"),productNameField=document.getElementById("productname-field"),dateField=document.getElementById("date-field"),amountField=document.getElementById("amount-field"),paymentField=document.getElementById("payment-field"),statusField=document.getElementById("delivered-status"),addBtn=document.getElementById("add-btn"),editBtn=document.getElementById("edit-btn"),removeBtns=document.getElementsByClassName("remove-item-btn"),editBtns=document.getElementsByClassName("edit-item-btn"),tabEl=(refreshCallbacks(),document.querySelectorAll('a[data-bs-toggle="tab"]'));function filterOrder(e){var t=e;orderList.filter(function(e){e=(matchData=(new DOMParser).parseFromString(e.values().status,"text/html")).body.firstElementChild.innerHTML;return"All"==e||"All"==t||e==t}),orderList.update()}function