diff --git a/htaccess-denyall b/htaccess-denyall new file mode 100644 index 00000000..dbc7e668 --- /dev/null +++ b/htaccess-denyall @@ -0,0 +1,8 @@ + + Order deny,allow + Deny from all + + + + Require all denied + \ No newline at end of file diff --git a/js/mlinvoice.js b/js/mlinvoice.js index 66ba45ba..7b267426 100644 --- a/js/mlinvoice.js +++ b/js/mlinvoice.js @@ -364,7 +364,14 @@ var MLInvoice = (function CreateMLInvoice() { '{date}': formatDate(data.date) } ); - var $span = $('').attr('title', title).text(translate('UpdateAvailable') + ' '); + var text = translate( + 'UpdateAvailable', + { + '{version}': data.version, + '{date}': formatDate(data.date) + } + ); + var $span = $('').attr('title', title).text(text + ' '); $('').appendTo($span); $('').attr('href', data.url).attr('target', '_blank').text(translate('UpdateInformation')).appendTo($span); $('').appendTo($span); diff --git a/js/mlinvoice.min.js b/js/mlinvoice.min.js index 8a12b38f..536adeec 100644 --- a/js/mlinvoice.min.js +++ b/js/mlinvoice.min.js @@ -1,3 +1,3 @@ -/*! mlinvoice 2023-10-29 */ -var MLInvoice=function(){var a=[],n=!1,o={},t="none",i=[],r=!0,c=2,d={},s="DD.MM.YYYY";function l(e,t){o[e]=t}function p(e,t,a){var n=o[e]||e;return n===e&&void 0!==a&&(n=a),"object"==typeof t&&$.each(t,function(e,t){n=n.replace(new RegExp(e,"g"),t)}),n}function u(e,t){var t=void 0===t?c:t,a=p("DecimalSeparator"),n=p("ThousandSeparator",[],""),e=parseFloat(e).toFixed(t).replace(".",a);if(n){for(var o=e.split(a),i=new RegExp("(\\d+)(\\d{3})"+a+"?");i.test(o[0]);)o[0]=o[0].replace(i,"$1"+n+"$2");e=o[0],1'),a=(void 0!==a?n.addClass(a):n.addClass("text-white bg-success"),$('').appendTo(n)),e=($('').text(e).appendTo(a),$('').attr("aria-label",p("Close")).appendTo(a),$("#toasts")),a=(0===e.length&&(e=$('').appendTo($("body"))),n.appendTo(e),{autohide:void 0!==t,delay:void 0!==t?t:0});new bootstrap.Toast(n.get(0),a).show()}function _(e,t){h(e,t,"text-white bg-danger")}function g(e){var t;void 0!==e.version&&(t=p("UpdateAvailableTitle",{"{version}":e.version,"{date}":b(e.date)}),t=$("").attr("title",t).text(p("UpdateAvailable")+" "),$("").appendTo(t),$("").attr("href",e.url).attr("target","_blank").text(p("UpdateInformation")).appendTo(t),$("").appendTo(t),$("").attr("href","index.php?func=system&operation=update").text(p("UpdateNow")).appendTo(t),t.appendTo("#version")),Cookies.set("updateversion",JSON.stringify(e),{expires:1})}function y(e){var t=$("#popup_dlg .modal-body");t.html(e),t.find("form").on("submit",function(e){var t=$(this),a=t.attr("method")||"GET",t=t.attr("action")||"",n=new FormData(this);return $.ajax({type:a,url:t,processData:!1,contentType:!1,data:n,success:function(e){y(e)},error:function(){MLInvoice.errormsg("Request failed")}}),e.preventDefault(),!1}),t.find("a").off("click").on("click",function(e){var t=$(this).attr("href");return $.get(t,y).fail(function(){MLInvoice.errormsg("Request failed")}),e.preventDefault(),!1})}function b(e){e=new String(e);return 8===e.length&&(e=e.substr(0,4)+"-"+e.substr(4,2)+"-"+e.substr(6,2)),moment(e).format(s)}function w(e,t){var e=$(e),a="primary";e.hasClass("btn-secondary")&&(a="secondary"),t?e.removeClass("btn-outline-"+a).addClass("btn-"+a).addClass("text-light"):e.removeClass("btn-"+a).removeClass("text-light").addClass("btn-outline-"+a)}function T(e){e=$(e);return e.hasClass("btn-primary")||e.hasClass("btn-secondary")}return{init:function(){$('input[class~="hasDateRangePicker"]').each(function(){var a=$(this);a.daterangepicker(MLInvoice.getDateRangePickerDefaults()).val(""),a.on("apply.daterangepicker",function(e,t){a.val(t.startDate.format(MLInvoice.getDateFormat())+" - "+t.endDate.format(MLInvoice.getDateFormat())),a.trigger("change")}),a.on("cancel.daterangepicker",function(){a.val("")})}),$("#form").find('input[type="text"],input[type="date"],input[type="hidden"]:not(.select-default-text),input[type="checkbox"],select:not(.dropdownmenu),textarea').on("change",function(){w(".save_button",!0)}),$(window).on("beforeunload",function(e){if(T(".save_button")||T(".row-add-button"))return e.returnValue=p("UnsavedData"),e.returnValue}),$(document).ajaxStart(function(){$("#spinner").removeClass("hidden")}),$(document).ajaxStop(function(){$("#spinner").addClass("hidden")}),$(document).ajaxError(function(e,t){m(t)}),$(document).on("select2:open",()=>{var e=document.querySelector(".select2-container--open .select2-search__field");e&&e.focus()}),r&&window.setTimeout(e,6e4),$(".cb-select-all").off("click").on("click",function(){var e=$(this).closest("table");e.find(".cb-select-row").prop("checked",$(this).prop("checked")),v(e.closest(".list_container"))}),$("#cover-letter-button").on("click",function(){$("#cover-letter-form").toggleClass("hidden")}),$("#cover-letter-form .close-btn").on("click",function(){$("#cover-letter-form").addClass("hidden")}),$("#add-custom-prices").on("click",function(){$("#no-custom-prices").addClass("hidden"),$("#custom-prices-form").removeClass("hidden")}),$("#custom-prices-form .save-button").on("click",function(){var e=$("#custom-prices-form"),e={company_id:$("#company_id").val(),discount:f(e.find("#discount").val()),multiplier:f(e.find("#multiplier").val()),valid_until:e.find("#valid_until").val()};return $.ajax({url:"json.php?func=put_custom_prices",type:"POST",dataType:"json",data:JSON.stringify(e),contentTypes:"application/json; charset=utf-8",success:function(){h(p("RecordSaved"),2e3),window.location.reload()}}),!1}),$("#custom-prices-form .delete-button").on("click",function(){var e={company_id:$("#company_id").val()};return $.ajax({url:"json.php?func=delete_custom_prices",type:"POST",dataType:"json",data:JSON.stringify(e),contentType:"application/json; charset=utf-8",success:function(){h(p("RecordDeleted"),2e3),window.location.reload()}}),!1}),$(".print-selected-rows .print-selected-item").on("click",function(){var e=$(this).closest(".list_container").find(".cb-select-row:checked").map(function(){return"id[]="+encodeURIComponent(this.value)}).get(),e="invoice.php?template="+encodeURIComponent($(this).data("templateId"))+"&"+e.join("&");return"openwindow"===$(this).data("style")?window.open(e):window.location.href=e,!1}),$(".form-submit").on("click",function(){var e,t,a=$(this),n=a.data("confirm");return n&&!confirm(p(n))||(n=(n=a.data("form"))?$("#"+n):$("form"),void 0!==(e=a.data("formTarget"))&&n.attr("target",e),void 0!==(e=a.data("setField"))&&(a="1",2===(t=e.split("=",2)).length&&(e=t[0],a=t[1]),n.find("[name="+e+"]").val(a)),w(".save_button",!1),n.trigger("submit")),!1}),$("button.popup-close").on("click",function(){return window.close(),!1}),$("[data-form-submit-on-change").on("change",function(){var e=$(this).data("form");return(e?$("#"+e):$("form")).trigger("submit"),!1}),$("[data-form-cancel]").on("click",function(){window.opener?window.close():history.back()}),$(".update-dates").on("click",function(){return $.getJSON("json.php?func=get_invoice_defaults",{id:$("#record_id").val(),invoice_no:$("#invoice_no").val(),invoice_date:$("#invoice_date").val(),base_id:$("#base_id").val(),company_id:$("#company_id").val(),interval_type:$("#interval_type").val()},function(e){$("#invoice_date").val(e.date),$("#due_date").val(e.due_date),$("#next_interval_date").val(e.next_interval_date||""),w(".save_button",!0)}),!1}),$("a.update-invoice-nr").on("click",function(){return $.getJSON("json.php?func=get_invoice_defaults",{id:$("#record_id").val(),invoice_no:$("#invoice_no").val(),invoice_date:$("#invoice_date").val(),base_id:$("#base_id").val(),company_id:$("#company_id").val(),interval_type:$("#interval_type").val()},function(e){$("#invoice_no").val(e.invoice_no),$("#ref_number").val(e.ref_no),w(".save_button",!0)}),!1}),$("[data-save-search]").on("click",function(){var t=window.location.href.split("?");if(void 0===t[1])MLInvoice.errormsg("Cannot save an empty search");else{let e="?"+t[1];e=e.replace(/([?&]func=)results/,"$1save_search"),e+="&name="+encodeURIComponent($("#search_name").val()),$.getJSON("json.php"+e,function(e){e.errors?MLInvoice.errormsg(e.errors):MLInvoice.infomsg(MLInvoice.translate("SearchSaved"))})}return!1}),n=!0},addTranslation:l,addTranslations:function(e){for(var t in e)"string"==typeof e[t]&&l(t,e[t])},setDispatchNotePrintStyle:function(e){t=e},getDispatchNotePrintStyle:function(){return t},setDateRangePickerDefaults:function(e){d=e},getDateRangePickerDefaults:function(){var e=Object.assign({},d);return e.autoApply=!1,e.autoUpdateInput=!1,e.alwaysShowCalendars=!0,e},setOfferStates:function(e){i=e},isOfferStatus:function(e){return-1!==i.indexOf(e)},translate:p,formatCurrency:u,parseDecimal:f,setKeepAlive:function(e){r=e},updateRowSelectedState:v,infomsg:h,errormsg:_,editUnitPrice:function(){return i=this,a=$(i),r=a.parents("tr"),c=a.parents("table").dataTable(),d=a.text(),s=c.fnGetData(r),e=$("").attr("type","text").attr("value",d).css("width",a.innerWidth()-24+"px").on("keydown",function(e){if(13===e.which)$(this).data("handled",!0),o();else if(27===e.which)$(this).data("handled",!0),n();else{var t,a;if(9===e.which)return a=(t=$("td.editable")).index(i),e.shiftKey?0a+1&&$(t[a+1]).trigger("click"),!1}}).on("click",function(){return!1}).on("blur",function(){$(this).data("handled")||o()}),a.empty().addClass("editing").append(e),e.trigger("select").trigger("focus"),!1;function n(){a.text(d),a.removeClass("editing")}function o(){var e=a.find("input"),t=(e.css("width",a.innerWidth()-36+"px"),a.append(''),String(e.val()));t===d?n():(e={company_id:$("#company_id").val(),product_id:s[0],unit_price:f(t)},$.ajax({url:"json.php?func="+(""===t?"delete_custom_price":"put_custom_price"),type:"POST",dataType:"json",data:JSON.stringify(e),contentType:"application/json; charset=utf-8",success:function(e){a.removeClass("editing");e=null!==e.unit_price?u(e.unit_price):c.fnGetData(a.prev().get(0));""===t?(a.text(e),r.removeClass("custom-price")):(a.text(e),r.addClass("custom-price"))},error:function(){a.text(t),a.removeClass("editing")}}))}var i,a,r,c,d,s,e},setCurrencyDecimals:function(e){c=e},getDateFormat:function(){return s},setDateFormat:function(e){s=e.toUpperCase()},checkForUpdates:function(t){Cookies.get("updateversion")&&Cookies.get("currentversion")===t?g(JSON.parse(Cookies.get("updateversion"))):$.getJSON("json.php?func=get_update_info",function(e){g(e),Cookies.set("currentversion",t)})},calcRowSum:function(e){var t=e.partial_payment?1:e.pcs,a=e.price,n=e.discount||0,o=e.discount_amount||0,i=e.vat,n=(a=a*(1-n/100)-o,0),o=0,r=0;return 1===Number(e.vat_included)?r=(o=t*a)-(n=o/(1+i/100)):o=(n=t*a)+(r=n*(i/100)),{sum:n,VAT:r,sumVAT:o}},popupDialog:function(e,t,a,n){var o=$("#popup_dlg");return o.find(".modal-body").html(''),o.find(".modal-title").text(a),o.off("hidden.bs.modal"),null!==t&&o.on("hidden.bs.modal",t),new bootstrap.Modal(o.get(0)).show(),null!==e?$.get(e,y).fail(function(){MLInvoice.errormsg("Dialog contents could not be loaded")}):void 0!==n&&y(n),!0},clearMessages:function(){$("#toasts").html("")},ajaxErrorHandler:m,formatDate:b,addModule:function(e,t){void 0===this[e]&&(a.push(e),this[e]="function"==typeof t?t():t,n)&&this[e].init&&this[e].init()},initTableExportButtons:function(e){new $.fn.dataTable.Buttons(e,{buttons:["copy","csv",$.extend(!0,{},{exportOptions:{format:{body:function(e,t,a,n){var o=$(n).data("export");return void 0!==o||void 0!==(o=$(n).data("sort"))?o:e}}}},{extend:"excelHtml5"}),"pdf"]}).container().appendTo($("#DataTables_Table_0_length"))},highlightButton:w,updateBaseLogo:function(){var t=$("#logo"),a=$("#no_logo"),e=$("#record_id").val();e&&$.get("json.php?func=get_base&id="+e,function(e){e.logo_filename&&e.logo_filesize&&e.logo_filetype&&e.logo_filedata?(t.find("img").attr("src","data:image/"+e.logo_filetype+";base64,"+e.logo_filedata),t.removeClass("hidden"),a.addClass("hidden")):(t.addClass("hidden"),a.removeClass("hidden"))})},createDataTablesTotalFooter:function(e,t){function o(e){return e=parseFloat(String(e).replace(/,/g,"")),isNaN(e)?0:e}var i=e.api();$(t).each(function(e,t){var a=0,n=(i.column(t).nodes().to$().each(function(){a+=o($(this).data("export"))}),0);i.column(t,{page:"current"}).nodes().to$().each(function(){n+=o($(this).data("export"))}),n=MLInvoice.formatCurrency(n,2),a=MLInvoice.formatCurrency(a,2),$(i.column(t).footer()).html('