1 line
9.8 KiB
JavaScript
1 line
9.8 KiB
JavaScript
var MAN_CLS_COINS_NOTES_FIELDS_NOT_CORRECTLY_FILLED=["Entweder müssen alle oder gar kein Feld des Zählprotokolls korrekt ausgefüllt sein.","Either all or no fields of the counting protocol must be filled in correctly.","Todos o ninguno de los campos del protocolo de conteo deben ser llenados."];var MAN_COUNTING_SUM=["Summe","Sum","Total"];var MAN_NO_COUNTING_DONE=["Zählprotokoll wurde nicht erfasst.","No counting protocol available.","No hay ningun protocolo de conteo."];var MAN_NOTES_VALUE=["Wert","Value","Valor"];var MAN_COIN_NOTE_TYPE=["Typ","Type","Typo"];var MAN_COIN_NOTE_SUM=["Summe","Sum","Total"];var MAN_COIN_NOTE_COUNT=["Anzahl","Number","Numero"];function Closing(b,c,a){this.closingListExpanded=false;this.areaHeader="";this.coinsHeader="";this.notesHeader="";this.hint="";this.l=c;this.coins=[];this.notes=[];this.decpoint=b;this.currency=a;this.bindNewClosingExpand=function(g,f,e,h){var d=this;this.areaHeader=g;this.coinsHeader=f;this.notesHeader=e;this.hint=h;$("#closinglist").off("collapsibleexpand").on("collapsibleexpand",function(i){i.stopImmediatePropagation();i.preventDefault();if(!d.closingListExpanded){d.closingListExpanded=true;d._createGui()}})};this._createGui=function(){var d=this;doAjax("GET","php/contenthandler.php?module=admin&command=getcoinsandnotes",null,d._handleCoinsAndNotesAndCreateGui.bind(d),"Fehler Münzen/Banknoten")};this._handleCoinsAndNotesAndCreateGui=function(e){var d='<p /><span class="areaheader">'+this.areaHeader+"</span>";if(e.status=="OK"){this.coins=e.msg.coins;this.notes=e.msg.notes;var g=e.msg.coinvalname;var f=e.msg.notevalname;d+="<p />"+this._createGuiCore(this.coins,this.coinsHeader,g,"c");d+=this._createGuiCore(this.notes,this.notesHeader,f,"n")}d+='<p /><span class="coinsnotesheader">'+MAN_COUNTING_SUM[lang]+"</span><br>";d+='<input id="countingsum" value="" type="text" readonly /> '+f;d+='<p /><div class="hint">'+this.hint+"</div>";$("#countingprotocol").html(d);this._bindCountingChange()};this._bindCountingChange=function(){var d=this;$(".countingfield").off("keyup").on("keyup",function(f){d._calcSum()})};this._calcSum=function(){var d=0;this.coins.forEach(function(i,g){var f="#coinnote_c_"+i;var h=$(f).val().trim();if(h!=""){h=parseInt(h);if(isInt(h)){d+=h*i}else{$("#countingsum").val("?")}}});this.notes.forEach(function(i,g){var f="#coinnote_n_"+i;var h=$(f).val().trim();if(h!=""){h=parseInt(h);if(isInt(h)){d+=h*100*i}else{$("#countingsum").val("?")}}});var e=(d/100).toFixed(2).replace(".",this.decpoint);$("#countingsum").val(e)};this._createGuiCore=function(g,f,h,e){var d='<p /><span class="coinsnotesheader">'+f+"</span><br>";g.forEach(function(j,i){d+='<input id="coinnote_'+e+"_"+j+'" type="number" min="0" class="countingfield" />';d+=" * "+j+" "+h+"<br>"});return d};this.checkCoinsNotesValues=function(){var d=this._checkCoinNoteFieldsAreFilled("c",this.coins);var g=this._checkCoinNoteFieldsAreFilled("n",this.notes);var f=d.filled+g.filled;var h=d.unfilled+g.unfilled;var e=this._getCounted();if((f>0)&&(h>0)){return{status:false,msg:MAN_CLS_COINS_NOTES_FIELDS_NOT_CORRECTLY_FILLED[this.l]}}else{if(f>0){coinscount=this._getCountOfCoinNoteFields("c",this.coins);notescount=this._getCountOfCoinNoteFields("n",this.notes);return{status:true,msg:"OK",counting:1,coinscount:coinscount,notescount:notescount,counted:e}}else{return{status:true,msg:"OK",counting:0}}}};this._checkCoinNoteFieldsAreFilled=function(d,e){var f=0;var g=0;e.forEach(function(j,i){var h="#coinnote_"+d+"_"+j;var k=$(h).val().trim();if(k==""){g++}else{f++}});return{filled:f,unfilled:g}};this._getCountOfCoinNoteFields=function(d,e){var f=[];e.forEach(function(j,h){var g="#coinnote_"+d+"_"+j;var i=$(g).val().trim();f[f.length]={value:j,count:i}});return f};this.clearCountingFields=function(){this.coins.forEach(function(f,e){var d="#coinnote_c_"+f;$(d).val("")});this.notes.forEach(function(f,e){var d="#coinnote_n_"+f;$(d).val("")});$("#countingsum").val("")};this._getCounted=function(){this._calcSum();var d=$("#countingsum").val();if(d==""){return 0}else{return d.replace(",",".")}};this._createSubPartCategorySums=function(e){var d="";if(e.length>0){d+='<br><table class="categorysums clostable">';d+="<tr><th>"+MAN_CATEGORY[lang]+"<th>"+MAN_BILLSUMALL[lang]+" ("+this.currency+")</tr>";for(var f=0;f<e.length;f++){var g=e[f];if(g.kind==0){d+="<tr><td>"+MAN_FOOD_CAT[lang]}else{if(g.kind==1){d+="<tr><td>"+MAN_DRINKS_CAT[lang]}else{continue}}d+="<td>"+g.brutto.replace(".",this.decpoint);d+="</tr>"}d+="</table><br>"}return d};this._createSubPartUserSums=function(n){var k="";if(n.length>0){var e=0;var f=0;var l=0;var g=0;k+='<table class="usersums clostable">';k+="<tr><th>"+MAN_USERNAME[lang]+"<th>Umsätze (Bar)<th>Umsätze (Unbar)<th>Ein-/Auslagen<th>Summe</tr>";for(var j=0;j<n.length;j++){var d=n[j];var m=(d.sumonlybar-d.sumcash).toFixed(2);var h=(d.billsumall-d.sumonlybar).toFixed(2);k+="<tr><td>"+d.username;k+="<td>"+m.toString().replace(".",this.decpoint);k+="<td>"+h.toString().replace(".",this.decpoint);k+="<td>"+d.sumcash.replace(".",this.decpoint);k+="<td>"+d.billsumall.replace(".",this.decpoint);e+=parseFloat(m);f+=parseFloat(h);l+=parseFloat(d.sumcash);g+=parseFloat(d.billsumall)}k+="<tr><td>Summe<td>"+e.toFixed(2).replace(".",this.decpoint)+"<td>"+f.toFixed(2).replace(".",this.decpoint)+"<td>"+l.toFixed(2).replace(".",this.decpoint)+"<td>"+g.toFixed(2).replace(".",this.decpoint)+"</tr>";k+="</table><br>"}return k};this._createSubPartTaxesSums=function(h,k){var d="";if(h.length>0){d+='<br><table class="taxessums clostable">';d+="<tr><th>"+MAN_TAX[lang]+"<th>"+MAN_BILLSUMNETTO[lang]+" ("+this.currency+")<th>"+MAN_BILLSUMALL[lang]+" ("+this.currency+")</tr>";var f=0;var e=0;for(var g=0;g<h.length;g++){var j=h[g];d+="<tr><td>"+j.tax;d+="<td>"+j.netto.replace(".",this.decpoint);d+="<td>"+j.brutto.replace(".",this.decpoint);d+="</tr>";f+=parseFloat(j.netto);e+=parseFloat(j.brutto)}d+="<tr><td>Summen (alle Steuersätze)<td>"+f.toFixed(2).replace(".",this.decpoint)+"<td><b>"+e.toFixed(2).replace(".",this.decpoint)+"</b></tr>";if(k!=null){d+="<tr><td>"+MAN_BILLSUMCASH[lang]+"<td colspan=2>"+k.replace(".",this.decpoint)+"</tr>"}d+="</table><br>"}return d};this._createSubPartCountingProtocol=function(f,d,e){var l="<br>"+MAN_COUNTING_PROTOCOL[lang]+": ";if(f.length>0){l+='<br><table class="coutingsums clostable">';l+="<tr><th>"+MAN_COIN_NOTE_COUNT[lang]+"<th>"+MAN_NOTES_VALUE[lang]+"<th>"+MAN_COIN_NOTE_SUM[lang]+" ("+this.currency+")<th>"+MAN_COIN_NOTE_TYPE[lang]+"</tr>";var o=0;for(var k=0;k<f.length;k++){var q=f[k];var n=q.count;var g=q.sum;var m=MAN_COINS[lang];var j=d;if(q.iscoin==0){m=MAN_NOTES[lang];j=e}o+=parseFloat(g);var h=g.replace(".",this.decpoint);l+="<tr><td>"+n+"<td>"+q.value+" "+j+"<td>"+h+"<td>"+m+"</tr>"}var p=o.toFixed(2).replace(".",this.decpoint);l+='<tr><td colspan="4">'+MAN_COIN_NOTE_SUM[lang]+": "+p+" "+this.currency+"</tr>";l+="</table><br>"}else{l+=MAN_NO_COUNTING_DONE[lang]}return l};this._createClosingPart=function(j,g){var d=$("#admin-page").data("decpoint");var i=$("#admin-page").data("currency");var e=g.id;var f='<div id="clospart_'+e+'" + data-role="collapsible" data-theme="e" data-content-theme="e">';f+="<h3>"+toHtml(j)+"</h3>";f+="<p />Alle Angaben in "+i;var d=$("#admin-page").data("decpoint");var k=g.barTotalBeforeTE;var h=g.barTotalAfterTE;f+="<p /><h3>Gesamtdaten zur Erfassung</h3>";f+="<p /><table class='closingsums clostable'>";f+="<tr><td>Bargeld in Kasse vor TE<td>"+k.replace(".",d)+"</tr>";f+="<tr><td>Bargeld in Kasse nach TE (errechnet)<td>"+h.replace(".",d)+"</tr>";if(g.countingprotocol.length>0){f+="<tr><td>Bargeld in Kasse nach TE (gezählt)<td>"+g.counted.replace(".",d)+"</tr>";f+="<tr><td>Bargelddifferenz<td>"+g.diffsollist.toFixed(2).replace(".",d)+"</tr>"}f+="</table>";f+="<p /><h3>Änderungen mit dieser Erfassung</h3>";f+=this._createSubPartUserSums(g.usersums);f+=this._createSubPartTaxesSums(g.taxessums,g.cashops);f+=this._createSubPartCategorySums(g.categorysums);f+=this._createSubPartCountingProtocol(g.countingprotocol,g.coinname,g.notename);f+="<p>"+MAN_CLOSING_DET_TXT[lang]+"</p>";f+="<p>";f+='<div class="ui-grid-a" class="noprint">';f+=' <div class="ui-block-a">';f+=' <button type="submit" data-theme="f" class="csvExportButton" data-icon="check" id="csvexport_'+e+'">'+MAN_CSV_EXP_RECEIPTS[lang]+"</button>";f+=" </div>";f+=' <div class="ui-block-b">';f+=' <button type="submit" data-theme="f" class="xlsxExportButton" data-icon="check" id="xlsxexport_'+e+'">'+MAN_XLSX_EXP_RECEIPTS[lang]+"</button>";f+=" </div>";f+="</div>";f+='<button type="submit" data-theme="f" class="csvExportAllButton" data-icon="check" id="csvallexport_'+e+'">'+MAN_CSV_EXP_ALL[lang]+"</button>";var l=$("#receiveremail").val();f+='<fieldset class="ui-grid-a" id="emailfieldset'+e+'">';f+='<div class="ui-block-a">';f+='<input type="email" name="email_'+e+'" id="email_'+e+'" value="'+l+'" class="whiteinput" /></div>';f+='<div class="ui-block-b"><button type="submit" data-theme="c" class="csvEmailAllButton" data-icon="arrow-r" id="csvallemail_'+e+'">'+MAN_EMAIL_DATA[lang]+"</button></div>";f+='<button type="submit" data-theme="f" class="printButton" data-icon="check" id="printexport_'+e+'">'+MAN_PRINT_ALL[lang]+"</button>";f+='<button type="submit" data-theme="f" class="printsummary" data-icon="check" id="printsummary_'+e+'">'+MAN_PRINT_RECEIPT[lang]+"</button>";f+='<button type="submit" data-theme="f" class="closhtml" data-icon="check" id="closhtml_'+e+'">'+MAN_CLOS_HTML[lang]+"</button>";f+='<button type="submit" data-theme="f" class="csvExportGuestButton" data-icon="check" id="csvguestexport_'+e+'">'+MAN_CSV_EXP_GUEST[lang]+"</button>";f+="</p>";f+="</div>";return f};this.displayClosings=function(f){var d=this;var e="";$.each(f,function(j,l){var k=l.closingDate;var h=MAN_DAYNAMES[l.daynameno-1][lang];var m=l.remark;var g=k+" ("+h+")";if(m!=""){e+=d._createClosingPart(l.id+": "+g+": "+m,l)}else{e+=d._createClosingPart(l.id+": "+g,l)}});$("#partofclosings").html(e);$("#partofclosings").trigger("create")};this._displayCountingOfAClosing=function(d){}}; |