var allgroups=[];var customers=[];var decpoint=".";var currency="";var payments=[];function getGeneralConfigItemsCus(){$("#customersearch").val("");$("#groupsearch").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("");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:
";for(var b=0;b";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()});$("#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().trim();if(a===""){alert(GROUP_EMPTY_NAME[l])}else{var b={name:a,remark:d};doAjax("POST","php/contenthandler.php?module=customers&command=createNewGroup",b,handleCreateGroupResult,"Gruppe anlegen unmöglich",true)}});$("#customerlog").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();window.open("php/contenthandler.php?module=customers&command=exportLog","_blank")});$("#reportbills").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();window.open("php/contenthandler.php?module=customers&command=reportbills","_blank")})}function bindOnDynamicCustomersBtn(){$(".applycustomer").off("click").on("click",function(g){g.stopImmediatePropagation();g.preventDefault();var j=this.id.split("_")[1];var a=[];for(var b=0;b200){cusAlertTextLength("Bemerkung");return false}var c=$("#cusfield_cusfield_newroom_"+a).val();if(c.length>50){cusAlertTextLength("Zimmer");return false}var b={id:a,checkin:g.checkin,checkout:g.checkout,room:c,remark:f};doAjax("POST","php/contenthandler.php?module=customers&command=newVacation",b,handleChangeVacationResult,"Aufenthalt anlegen unmöglich",true)});$(".delvacation").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();var b=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=delVacation",{id:b},handleChangeVacationResult,"Aufenthalt löschen unmöglich",true)});$(".unpaybill").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];$("#stornocode").val("");$("#stornoreason").val("");areYouSureCancel(CUS_STORNO_QUEST_TITLE[l],CUS_STORNO_QUEST_TEXT[l],CUS_YES[l],function(){var c={id:a,code:$("#stornocode").val(),remark:$("#stornoreason").val()};doAjax("POST","php/contenthandler.php?module=customers&command=unpay",c,handleChangeBillResult,"Deklaration als unbezahlt unmöglich",true)})});$(".paymentpay").off("click").on("click",function(d){d.stopImmediatePropagation();d.preventDefault();var g=this.id;var c=g.split("_");var a=c[2];var f=c[3];var b=c[4];if(b!="all"){doAjax("POST","php/contenthandler.php?module=customers&command=pay",{id:b,paymentid:f},handleChangeBillResult,"Deklaration als bezahlt unmöglich",true)}else{doAjax("POST","php/contenthandler.php?module=customers&command=payallbills",{id:a,paymentid:f},handleChangeBillResult,"Deklaration alle unmöglich",true)}});$(".printbill").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=printbill",{id:a},null,"Drucken unmöglich",true)});$(".printallbills").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=printallbills",{id:a},null,"Drucken alle unmöglich",true)});$(".reportallbillsofsinglecus").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];window.open("php/contenthandler.php?module=customers&command=reportcustomerbills&cusid="+a,"_blank")})}function updateVacationsOfCustomer(a){doAjax("GET","php/contenthandler.php?module=customers&command=getVacations",{cusid:a},handleVacationsResult,null,true)}function updateBillsOfCustomer(a){doAjax("GET","php/contenthandler.php?module=customers&command=getBills",{cusid:a},handleBillsResult,null,true)}function handleVacationsResult(e){if(e.status==="OK"){var f=e.msg.vacations;var b=e.msg.cusid;var a="";for(var d=0;d0){if(g){d+="
"+CUS_DECLARE_ALL_PAY[l]+":
";for(var c=0;cCheck-in: "+d;a+="

Check-out: "+c;a+="

"+CUS_ROOM_LABEL[l]+": "+f;a+="

"+CUS_REMARK_LABEL[l]+g;a+=createDeleteButton(h+"_delvacation",CUS_DEL[l],"d","delvacation");a+="";return a}function renderABill(j,c,d,h,i,k,a){var b=h.replace(".",decpoint)+" "+currency;var f="c";if(k==1){f="f"}var g="";if(a){g=" - "+CUS_CLOSED[l]+" - "}var e=createCollapsibleStartGeneral("billentry_"+j,d+" - "+b+g,f,"billentry",true);e+="

"+CUS_BILLID[l]+": "+c;e+="

"+CUS_BILLDATE[l]+": "+d;e+="

"+CUS_BILLBRUTTO[l]+": "+d;if(!a){if(k==0){e+=createPaymentsArea(j,c,CUS_DECLAREPAY[l])}else{e+=createApplyButton(c+"_unpaybill",CUS_DECLAREUNPAY[l],"d","unpaybill")}}e+=createApplyButton(c+"_printbill",CUS_PRINTBILL[l],"f","printbill");e+="";return e}function handleEmailResult(a){if(a.status==="OK"){alert("Aktion abgeschlossen")}else{alert("Error: "+a.msg)}}function handleChangeVacationResult(b){if(b.status==="OK"){var a=b.cusid;$("#cusfield_newcheckin_"+a).val("");$("#cusfield_newcheckout_"+a).val("");$("#cusfield_cusfield_newroom_"+a).val("");$("#cusfield_vacremark_"+a).val("");updateVacationsOfCustomer(a)}else{alert("Error: "+b.msg)}}function handleChangeBillResult(b){if(b.status==="OK"){var a=b.cusid;updateBillsOfCustomer(a)}else{alert("Error: "+b.msg)}}function handlePayAllResult(a){if(a.status==="OK"){startCustomerSearch()}else{alert("Error: "+a.msg)}}function deleteCustomerCore(b){var a={id:b};doAjax("POST","php/contenthandler.php?module=customers&command=deleteCustomer",a,handleDeleteCustomerResult,"Gast löschen unmöglich",true)}function deleteGroupCore(b){var a={id:b};doAjax("POST","php/contenthandler.php?module=customers&command=deleteGroup",a,handleDeleteGroupResult,"Gruppe löschen unmöglich",true)}function areYouSureCus(c,b,a,d){$("#sure .sure-1").text(c);$("#sure .sure-2").text(b);$("#sure .sure-do").text(a).off("click.sure").on("click.sure",function(){d()});$(this).off("click.sure");$.mobile.changePage("#sure")}function startSearch(){var a={search:$("#groupsearch").val().trim()};doAjax("POST","php/contenthandler.php?module=customers&command=getGroups",a,handleGetGroupsResult,"Gästeabfrage unmöglich",true)}function startCustomerSearch(){var c=$("#customersearch").val().trim();var a=getDate("#customerdate");var d="";if((a!=null)&&(a!="")){d=a.year+"-"+a.month+"-"+a.day}var b=0;if($("#customeropenbills").is(":checked")){b=1}var e={search:c,date:d,onlyopenbills:b};doAjax("POST","php/contenthandler.php?module=customers&command=getCustomers",e,handleGetCustomerResult,"Gästeabfrage unmöglich",true)}function clearNewCustomerFields(){$("#newcustomername").val("");$("#newcustomeremail").val("");$("#newcustomeraddress").val("");$("#newcustomerremark").val("");$("#newcustomerphone").val("");$("#newcustomermobil").val("");$("#newcustomerwww").val("");$("#newcustomerhello").val("");$("#newcustomerregards").val("");$("#newcustomercheckin").val("");$("#newcustomercheckout").val("");$("#newcustomerroom").val("")}function handleCreateCustomerResult(a){if(a.status==="OK"){clearNewCustomerFields();if(a.code==1){var b=CUS_ALREADY_CUS_NAME[l];b=b.replace("%number%",a.value);alert(b)}startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function clearNewGroupFields(){$("#newgroupname").val("");$("#newgroupremark").val("")}function handleCreateGroupResult(a){if(a.status==="OK"){clearNewGroupFields();startSearch()}else{if(a.code==1){alert(CUS_GROUP_EXISTS[l])}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}}function handleChangeCustomerResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleDeleteCustomerResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleDeleteGroupResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleChangeGroupResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function createInputTextField(f,d,e,b,c){var a='

';a+=' ";a+=' ';a+="
";return a}function createTextAreaField(f,d,e,b,c){var a='
';a+=' ";a+=' ";a+="
";return a}function createDateTimePicker(d,b,c){var a='
';a+=' ";a+=' ';a+="
";return a}function createCollapsibleStartNew(d,b,c){var a='
';a+="

"+toHtml(b)+"

";return a}function createCollapsibleStartGeneral(g,c,e,f,b){var d=" ";if(b===false){d=' style="display:none;" '}var a='
";a+="

"+toHtml(c)+"

";return a}function createApplyButton(e,b,d,c){var a='";return a}function createDeleteButton(e,b,d,c){var a='";return a}function createApplyDeleteButtons(d,c,b){var a='
';a+='
'+createApplyButton(d,CUS_APPLY[l],"f",c)+"
";a+='
'+createDeleteButton(d,CUS_DEL[l],"d",b)+"
";a+="
";return a}function renderACustomer(d){var b=d.id;var c="";if((d.openbillsum!=null)&&(d.openbillsum!="")){c=" ("+d.openbillsum;c=c.replace(".",decpoint)+" "+currency+")"}var a=createCollapsibleStartNew(b,d.name+c,"c");a+="

";a+=createInputTextField(b,"cus","name","Name",d.name);a+=createTextAreaField(b,"cus","address",CUS_ADR_LABEL[l],d.address);a+=createInputTextField(b,"cus","phone",CUS_PHONE_LABEL[l],d.phone);a+=createInputTextField(b,"cus","mobil",CUS_MOBIL_LABEL[l],d.mobil);a+=createInputTextField(b,"cus","email","E-Mail",d.email);a+=createInputTextField(b,"cus","www",CUS_WWW_LABEL[l],d.www);a+=createInputTextField(b,"cus","hello",CUS_HELLO_LABEL[l],d.hello);a+=createTextAreaField(b,"cus","regards",CUS_REGARDS_LABEL[l],d.regards);a+=createTextAreaField(b,"cus","remark",CUS_REMARK_LABEL[l],d.remark);a+=createGroupList(d);a+="

";a+=CUS_CREATED[l]+": "+d.created+"
";a+=CUS_LAST_MODIFIED[l]+": "+d.lastmodified;a+="
";a+=createApplyDeleteButtons(b,"applycustomer","deletecustomer");a+="

";a+=createCollapsibleStartGeneral("allbills_"+b,CUS_BILLS[l],"e","billscollapsible",true);a+='

';a+="
";a+=createCollapsibleStartGeneral("allvacations_"+b,CUS_VACATIONS[l],"e","vacationcollapsible",true);a+='

';a+=createCollapsibleStartGeneral("newvacations_"+b,CUS_NEWVACATIONS[l],"c","newvacationscollapsible",true);a+=createDateTimePicker("cusfield_newcheckin_"+b,"Check-in","a");a+=createDateTimePicker("cusfield_newcheckout_"+b,"Check-out","a");a+=createInputTextField(b,"cus","cusfield_newroom",CUS_ROOM_LABEL[l],"");a+=createInputTextField(b,"cus","vacremark",CUS_REMARK_LABEL[l],"");a+=createApplyButton(b+"_newvacation",CUS_APPLY[l],"f","newvacation");a+="
";a+="";return a}function renderCustomers(b){var a="";for(var c=0;c
";a+=createInputTextField(b,"grp","name","Name",e.name);a+=createTextAreaField(b,"grp","remark",CUS_REMARK_LABEL[l],e.remark);var c=e.customers;if(c.length>0){a+="

";a+=CUS_CONTAINED_IN_GRP[l]+":
";for(var d=0;d"}a+="
"}a+="

";a+=CUS_CREATED[l]+": "+e.created+"
";a+="
";a+=createApplyDeleteButtons(b,"applygroup","deletegroup");a+=createCollapsibleStartGeneral("groupemail_"+b,"Email","e","groupemailentry",true);a+=createInputTextField(b,"grpemailsubject","grpemailsubject","Subject","");a+=createInputTextField(b,"grpemailbcc","grpemailbcc","BCC","");a+=createTextAreaField(b,"grpemailtext","grpemailtext","Text","");a+="

"+CUS_PLACEHOLDER_HINT[l]+" "+CUS_EMAIL_WARNING[l]+"";a+="

"+createApplyButton(b+"_groupsendemail",CUS_SEND_EMAIL[l],"f","groupsendemail");a+="";a+="

";a+="";return a}function renderGroups(b){var a="";for(var c=0;c';e+='
  • '+CUS_GRP_ASS_LIST[l]+"
  • ";for(var d=0;d'+toHtml(c.name)+""}e+="";return e}function cusAlertTextLength(a){alert(CUS_ALERT_TEXT_LEN[l]+a)}function cusCheckTextLengths(a){if(a.name.length>50){cusAlertTextLength("Name");return false}if(a.addr.length>200){cusAlertTextLength(CUS_ADR_LABEL[l]);return false}if(a.phone.length>30){cusAlertTextLength(CUS_PHONE_LABEL[l]);return false}if(a.mobil.length>30){cusAlertTextLength(CUS_MOBIL_LABEL[l]);return false}if(a.email.length>50){cusAlertTextLength("Email");return false}if(a.www.length>50){cusAlertTextLength(CUS_WWW_LABEL[l]);return false}if(a.remark.length>500){cusAlertTextLength(CUS_REMARK_LABEL[l]);return false}return true}function customizeDatePicker(e,b){var d="de";if(l==1){d="en"}else{if(l==2){d="es"}}var a=new Date().getFullYear();var c=(a-10)+":"+(a+3);$(e).datepicker($.datepicker.regional[d]).datepicker("option",{changeMonth:true,changeYear:true,yearRange:c});if((b!=null)&&(b!="")){$(e).datepicker("setDate",new Date(b))}else{$(e).val("")}}function getDate(d){var c=$(d).val();if((c==undefined)||(c.trim()=="")){return null}var a=$(d).datepicker("getDate");var b={day:("0"+a.getDate()).slice(-2),month:("0"+(a.getMonth()+1)).slice(-2),year:a.getFullYear(),date:a};return b}function getCheckinouts(b,h){var d=getDate(b);var c=getDate(h);var a="";if((d!=null)&&(d!="")){a=d.year+"-"+d.month+"-"+d.day}var f="";if((c!=null)&&(c!="")){f=c.year+"-"+c.month+"-"+c.day}var e=true;if((d!=null)&&(d!="")&&(c!=null)&&(c!="")){if(d.date>c.date){e=false}}var g={checkin:a,checkout:f,valid:e};return g}function areYouSureCancel(c,b,a,d){$("#cancelsure .sure-1").text(c);$("#cancelsure .sure-2").text(b);$("#cancelsure .sure-do").text(a).off("click.cancelsure").on("click.cancelsure",function(f){f.stopImmediatePropagation();f.preventDefault();$("#nocancelbtn").off("click");$("#cancelsure").dialog("close");$.mobile.changePage("#info-page");d();$(this).off("click.cancelsure")});$("#nocancelbtn").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();$("#cancelsure .sure-do").text(a).off("click.cancelsure");$("#cancelsure").dialog("close");$.mobile.changePage("#info-page")});$.mobile.changePage("#cancelsure");setTimeout(function(){$("#stornocode").val("");$("#stornoreason").val("")},1000)};