ordersprinter/webapp/elements/customers.js

1 line
28 KiB
JavaScript
Raw Permalink Normal View History

2020-11-19 23:14:07 +01:00
var allgroups=[];var customers=[];var decpoint=".";var currency="";var payments=[];var selGroupForAssigment=-1;function getGeneralConfigItemsCus(){$("#customersearch").val("");$("#customersearchremark").val("");$("#groupsearch").val("");$("#grpAssignmentSelection").val("");clearNewCustomerFields();clearNewGroupFields();doAjax("GET","php/contenthandler.php?module=admin&command=getGeneralConfigItems",null,insertConfigDoRest,"Fehler Konfigurationsdaten");doAjax("GET","php/contenthandler.php?module=customers&command=getPaymentsForGuest",null,insertPayments,"Fehler Zahlungswege",true);customizeDatePicker("#newcustomercheckin",null);customizeDatePicker("#newcustomercheckout",null);customizeDatePicker("#customerdate","")}function insertConfigDoRest(b){if(b.status==="OK"){var a=b.msg;$("#customersearch").val("");$("#customersearchremark").val("");$("#customersearchaddress").val("");setLanguage(a.userlanguage);decpoint=a.decpoint;currency=a.currency;bindGroupsOrCustomerBtns();showCustomersArea();startSearch()}else{setTimeout(function(){document.location.href="index.html"},250)}}function insertPayments(d){if(d.status=="OK"){var c=d.msg;payments=[];for(var b=0;b<c.length;b++){var a=c[b];payments[payments.length]={id:a.id,name:a.name}}setPaymentsInAllGuestActions()}}function setPaymentsInAllGuestActions(){var a="";a+="<br><b>"+CUS_DECLARE_ALL_PAY[l]+"</b>:<br>";for(var b=0;b<payments.length;b++){var c=payments[b];a+=createApplyButton("paymentallguests_"+c.id,c.name,"e","paymentpayallguests")}$("#payalldiv").html(a);$("#payalldiv").trigger("create")}function createPaymentsArea(b,e,f){var a=createCollapsibleStartGeneral("paymentsarea_"+b,f,"f","paymentsarea",true);for(var c=0;c<payments.length;c++){var d=payments[c];a+=createApplyButton("payment_"+b+"_"+d.id+"_"+e,d.name,"e","paymentpay")}a+="</div>";return a}function showCustomersArea(){$("#customersarea").show();$("#groupsarea").hide();$("#customersbtn").buttonMarkup({theme:"f"});$("#customersbtn").buttonMarkup({icon:"arrow-d"});$("#groupsbtn").buttonMarkup({theme:"c"});$("#groupsbtn").buttonMarkup({icon:"arrow-r"})}function showGroupsArea(){$("#customersarea").hide();$("#groupsarea").show();$("#customersbtn").buttonMarkup({theme:"c"});$("#customersbtn").buttonMarkup({icon:"arrow-r"});$("#groupsbtn").buttonMarkup({theme:"f"});$("#groupsbtn").buttonMarkup({icon:"arrow-d"})}function bindGroupsOrCustomerBtns(){$("#customersbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();showCustomersArea()});$("#groupsbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();showGroupsArea()});$("#newcustomerbtn").off("click").on("click",function(i){i.stopImmediatePropagation();i.preventDefault();var b=$("#newcustomername").val().trim();var m=$("#newcustomeremail").val().trim();var o=$("#newcustomeraddress").val().trim();var g=$("#newcustomerremark").val().trim();var j=$("#newcustomerphone").val().trim();var k=$("#newcustomermobil").val().trim();var c=$("#newcustomerwww").val().trim();var n=$("#newcustomerhello").val().trim();var h=$("#newcustomerregards").val().trim();var a=$("#newcustomerroom").val().trim();if(b===""){alert(CUS_EMPTY_NAME[l])}else{var f=getCheckinouts("#newcustomercheckin","#newcustomercheckout");if(!f.valid){alert(CUS_CHECKIN_AFTER_OUT[l]);return}var d={name:b,email:m,addr:o,remark:g,phone:j,mobil:k,www:c,hello:n,regards:h,checkin:f.checkin,checkout:f.checkout,room:a};if(!cusCheckTextLengths(d)){return}doAjax("POST","php/contenthandler.php?module=customers&command=createNewCustomer",d,handleCreateCustomerResult,"Gast anlegen unmöglich",true)}});$("#customersearch").off("keyup").on("keyup",function(a){startSearch()});$("#customersearchremark").off("keyup").on("keyup",function(a){startSearch()});$("#customersearchaddress").off("keyup").on("keyup",function(a){startSearch()});$("#groupsearch").off("keyup").on("keyup",function(a){startSearch()});$("#newgroupbtn").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();var a=$("#newgroupname").val().trim();var d=$("#newgroupremark").val