⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
crm.dev-unit.com
/
public
/
assets
/
js
/
sales
/
View File Name :
sales.js
(()=>{"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,a){if(!e)return;if("string"==typeof e)return t(e,a);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return t(e,a)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=new Array(t);a<t;a++)r[a]=e[a];return r}$(document).ready((function(){setTimeout((function(){$("#invoiceCurrencyId, #creditNoteCurrencyId, #proposalCurrencyId, #estimateCurrencyId").trigger("change")}),500),$("#tagId").select2({width:"calc(100% - 44px)",placeholder:Lang.get("messages.placeholder.select_tags"),multiple:!0}),$(".tax-rates").select2({width:"100%",placeholder:Lang.get("messages.placeholder.select_tax")}),$("#paymentMode").select2({width:"calc(100% - 44px)",placeholder:Lang.get("messages.placeholder.select_payment_mode"),multiple:!0}),$(".status").select2({width:"100%",placeholder:Lang.get("messages.placeholder.select_status")}),$(".currency-select-box, .sale-agent-select-box, #customerSelectBox").select2({width:"100%",placeholder:Lang.get("messages.placeholder.select_customer")}),$("#addItemSelectBox").select2({width:"87%"}),$("#billTaskSelectBox").select2({width:"87%",placeholder:Lang.get("messages.placeholder.bill_tasks")}),$("#recurringInvoiceSelect, #discountTypeSelect").select2(),window.renderOptions=function(){var e=$(".items-container>tr:last-child").find(".tax-rates");taxData.forEach((function(t){var a=new Option(t.tax_rate,t.id,!1,!1);e.select2({width:"100%",placeholder:Lang.get("messages.placeholder.select_tax")}),e.append(a).trigger("change")}))},"undefined"!=typeof isCreate&&renderOptions(),$(document).on("click","#itemAddBtn",(function(e){e.preventDefault();var t=prepareTemplateRender("#invoiceItemTemplate");$(".items-container").append(t),$("#invoiceCurrencyId, #creditNoteCurrencyId, #proposalCurrencyId, #estimateCurrencyId").trigger("change"),renderOptions(),$(".item-name").attr("placeholder",Lang.get("messages.invoice.item")),$(".item-description").attr("placeholder",Lang.get("messages.common.description")),$(".qty").attr("placeholder",Lang.get("messages.invoice.qty")),$(".rate").attr("placeholder",Lang.get("messages.products.rate"))})),$(document).on("change","#shippingAddressEnable",(function(){$(this).prop("checked"),$("#shippingAddressForm").slideToggle()})),$(document).on("click",".remove-invoice-item",(function(e){e.preventDefault(),1===$("table#itemTable tbody tr").length&&$(".tax-rates").val([]).trigger("change"),$(this).parent().parent().remove(),0===$("table#itemTable tbody tr").length&&$(".total-numbers").text("0"),calculateSubTotal()})),$(document).on("keyup",".qty",(function(){$(this).val($(this).val().replace(/[^0-9.]/g,"").replace(/(\..*)\./g,"$1"));var e=$(this).val(),t=removeCommas($(this).parent().next().find(".rate").val());calculateItemAmount(e,t,$(this)),calculateSubTotal(),$(".tax-rates").trigger("change")})),$(document).on("keyup",".rate",(function(){var e=removeCommas($(this).val()),t=0;""!=$(this).val()&&($(this).val(getFormattedPrice(e)),t=$(this).parent().prev().find(".qty").val()),calculateItemAmount(t,e,$(this)),calculateSubTotal(),$(".tax-rates").trigger("change")})),window.calculateItemAmount=function(e,t,a){var r=e*t;isNaN(r)||a.parent().siblings().children(".item-amount").text(getFormattedPrice(r))};var t=0;window.calculateSubTotal=function(){t=0,$(".items-container>tr").each((function(){var e=$(this).find(".item-amount").text();t+=parseFloat(removeCommas(e)),t=parseFloat(t)})),0==t?$("#subTotal").text(t):$("#subTotal").text(getFormattedPrice(t)),calculateFinalTotal(),checkDiscountType()&&$("#footerDiscount").trigger("change")},$(document).on("change","#discountTypeSelect",(function(){$("#footerDiscount").trigger("change"),0==$(this).val()?$("#footerDiscount").val(0):$("#footerDiscount").val(1)}));var a=1;$(document).on("change","#footerDiscount",(function(){if(checkDiscountType())return a=$(this).val(),$(".footer-discount-input").trigger("keyup"),!1;$(".footer-discount-input").val(0),$(".footer-discount-input").trigger("keyup")}));var r=0;$(document).on("keyup",".footer-discount-input",(function(){if(""!=$(this).val()){var e=$(this).val().replace(/[^0-9.]/g,"").replace(/(\..*)\./g,"$1");$(this).val(parseFloat(e))}else $(this).val(0);if(""===checkDiscountType()&&$(this).val()>0)alert("please select discount type first");else{prepareSelectedTaxes(),r=0;var o=checkDiscountType();if(1==o)if($(".footer-discount-numbers").text("0"),$(".footer-discount-numbers").text(getFormattedPrice(-$(this).val())),1==a){var n=$(this).val();n=n>100?100:n,$(this).val(n);var i=parseFloat(t)*parseFloat(n)/100;$(".footer-discount-numbers").text(getFormattedPrice(-i))}else{var c=$(".footer-discount-input").val();$(".footer-discount-numbers").val(c)}else if(2==o){if($(".footer-discount-numbers").text("0"),$(".footer-discount-numbers").text(getFormattedPrice(-$(this).val())),1==a){var l=$(this).val();l=l>100?100:l,$(this).val(l),$(".footer-discount-numbers").text(getFormattedPrice(-(t+s)*l/100));var u=parseFloat(s)+parseFloat(t);u=u*parseFloat(l)/100,$(".footer-discount-numbers").text(getFormattedPrice(-u))}}else{$(".footer-discount-numbers").text(getFormattedPrice(-$(this).val())),$(this).val(0);var d=getSubTotalIncludingTaxes();$(".footer-discount-numbers").text(getFormattedPrice(d*parseFloat(-$(this).val())/100))}r=parseFloat(removeCommas($(".footer-discount-numbers").text())),prepareSelectedTaxes(),calculateFinalTotal()}})),window.getSubTotalWithDiscount=function(){return t+r},$(document).on("mousewheel","#adjustment",(function(){$(this).blur()}));var o=0;$(document).on("keyup","#adjustment",(function(){o=""==$(this).val()?0:$(this).val(),$(".adjustment-numbers").text(0===o?0:getFormattedPrice(o)),calculateFinalTotal()})),window.checkDiscountType=function(){var e=$("#discountTypeSelect").val();if(""!=e&&0==e&&($(".footer-discount-input").val(""),$("#footerDiscount").val(0),$(".fDiscount").hide()),1==e||2==e)return $(".fDiscount").show(),e};var n=[];$(document).on("change",".tax-rates",(function(){prepareSelectedTaxes(),checkDiscountType()&&$("#footerDiscount").trigger("change"),calculateFinalTotal()}));var i={items:[]};window.prepareSelectedTaxes=function(){n=[],i.items=[],$(".items-container>tr").each((function(){var t=[];$.each($(this).find(".tax-rates option:selected"),(function(){t.push($(this).text())})),n=[].concat(e(n),t);var a,r,o,s=removeCommas($(this).find(".item-amount").text());i.items.push((o=s,(r=t)in(a={})?Object.defineProperty(a,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[r]=o,a))})),n=Array.from(new Set(n)),renderTaxList()};var s=0,c=0;window.renderTaxList=function(){c=$(".footer-discount-input").val(),s=0,$("#taxesListTable").html("");1==checkDiscountType()&&getSubTotalWithDiscount();n.forEach((function(e){var t=0;i.items.forEach((function(a){$.each(a,(function(a,r){a.split(",").forEach((function(a){a==e&&(t=parseFloat(t)+parseFloat(r))}))}))}));var r=0;if(0==$("#discountTypeSelect").val())r=getFormattedPrice(parseFloat(t)*parseFloat(e)/100);else if(1==$("#discountTypeSelect").val())if(1==a){var o=getFormattedPrice(parseFloat(t)*parseFloat(c)/100);r=getFormattedPrice((parseFloat(t)-parseFloat(o?removeCommas(o):0))*e/100)}else{var n=0;0!=c?(n=getFormattedPrice(parseFloat(t)-parseFloat(c)),r=getFormattedPrice(parseFloat(n?removeCommas(n):0)*e/100)):r=getFormattedPrice((parseFloat(t)-parseFloat(n?removeCommas(n):0))*e/100)}else 2==$("#discountTypeSelect").val()&&(r=getFormattedPrice(parseFloat(t)*parseFloat(e)/100));s+=parseFloat(r?removeCommas(r):0);var l=prepareTemplateRender("#taxesList",[{tax_name:e,tax_rate:r}]);$("#taxesListTable").append(l)}))},window.getSubTotalIncludingTaxes=function(){return t-s},window.calculateFinalTotal=function(){var e=$("#discountTypeSelect").val();if(0==e){var a=parseFloat(t)+parseFloat(s)+parseFloat(o);$(".total-numbers").text(0===a?0:getFormattedPrice(a))}else if(1==e){var n=parseFloat(t)+parseFloat(s)+parseFloat(o)+parseFloat(r);$(".total-numbers").text(0===n?0:getFormattedPrice(n))}else if(2==e){var i=parseFloat(s)+parseFloat(t),c=(i+=parseFloat(r))+parseFloat(o);$(".total-numbers").text(0===c?0:getFormattedPrice(c))}},window.getCurrencyFormatted=function(e){return getFormattedPrice(e)},window.getAddressDetail=function(e){if("undefined"!=typeof editData&&editData){var t=[{street:e.find(".street").val(),city:e.find(".city").val(),state:e.find(".state").val(),country:e.find(".country").val(),zip_code:e.find(".zip-code").val()}];return prepareTemplateRender("#addressTemplate",t)}},window.createAddressDetail=function(e){if("undefined"!=typeof createData&&createData){var t=[{street:e.find(".street").val(),city:e.find(".city").val(),state:e.find(".state").val(),country:e.find(".country").val(),zip_code:e.find(".zip-code").val()}];return prepareTemplateRender("#createAddressTemplate",t)}},setTimeout((function(){$(".address-modal").trigger("hidden.bs.modal")}),100),setTimeout((function(){$("#addModal").trigger("hidden.bs.modal")}),100);var l={qty:"qty",hours:"hours",qtyHours:"qtyHours"};$("#qty, #hours, #qtyHours").on("change",(function(){var e=l[$(this).data("quantity-for")];$(this).data("quantity-for")===e&&$(this).prop("checked")&&$(".qtyHeader").text($(this).next().text()),$(".qty").attr("placeholder",$(this).next().text())})),"undefined"!=typeof editData&&editData&&$("#qty, #hours, #qtyHours").trigger("change");var u={0:"fas fa-rupee-sign",1:"fas fa-dollar-sign",2:"fas fa-dollar-sign",3:"fas fa-euro-sign",4:"fas fa-yen-sign",5:"fas fa-pound-sign",6:"fas fa-dollar-sign"};$("#invoiceCurrencyId, #creditNoteCurrencyId, #proposalCurrencyId, #estimateCurrencyId").on("change input",(function(){var e=$(this).val();$(document).find("[data-set-currency-class='true']").attr("class",u[e])})),$(document).on("blur","#adjustment",(function(){var e=$(this).val();isEmpty(e)&&$("#adjustment").val("0")}))}))})();