Check In Time: "+curclockin.loginTime.format("longTime")+"
";msg+="";msg+="Clock Out";
msg+="
";}$("#gs-pos-taStart").html(msg);};this.clockIn=function(uid){var pwd=$("#gs-pos-tapwd").val();if(pwd.length==0){TK.actions.alert("Password cannot be blank.");}else{if(TK.actions.getLock()){TKClub.clockin(uid,pwd,TK.clubCheckOut.getLatestClockinReturn);}}};this.setCloseCallBack=function(func){closeCallBack=func;
};this.showPOS=function(){if(loaded){$("#gs-admin-dlgPOS-txtError").hide();WebObj=new Object();if(TK.actions.getLock()){TKAdmin.createInvoiceForClub(TK.clubCheckOut.getInvoiceForPOSReturn);}}};this.queryCustomer=function(request,response){var callMetaData={callback:TK.clubCheckOut.queryCustomerReturn,callbackArg:response};
TKClub.getACQueryForCustomer(request.term,10,callMetaData);};this.queryCustomerReturn=function(data,response){response(data);};this.queryReturns=function(request,response){var callMetaData={callback:TK.clubCheckOut.queryReturnsReturn,callbackArg:response};TKClub.getACQueryForReturns(request.term,10,callMetaData);
};this.queryReturnsReturn=function(data,response){if(data[0].misc=="upc"){$("#tk-club-pos-return-ac").val("");TK.clubCheckOut.showInvoiceDetailView(data[0].value);}else{response(data);}};this.updateInventory=function(inv){var found=false;for(var i=0;i0&&data[0].matchType=="upc"){$("#gs-admin-clubbillingitem-ac").val("");$("#gs-admin-clubbillingitem-ac").data().uiAutocomplete.term=null;if(data[0].error==TK.constants.SUCCESS){TK.clubCheckOut.updateInventory(data[0]);
TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data[0].misc);}}else{response(data);}};this.addItemsToInvoiceReturn=function(data){TK.actions.releaseLock();if(data!=null){if(data.error==TK.constants.SUCCESS){WebObj.invoiceDTO.encryptedId=data.encryptedInvoiceId;TK.clubCheckOut.fillInvoiceData(data.misc);
TK.clubCheckOut.updateInventory(data);TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);}};this.saveInvoice=function(){if(TK.actions.getLock()){TKAdmin.saveInvoiceForClub(TK.clubCheckOut.getInvoiceForPOSReturn);}};this.getInvoiceForPOSReturn=function(data){TK.actions.releaseLock();
if(data!=null){if(data.error==TK.constants.SUCCESS){WebObj=data;$("#gs-admin-dlgPOS").dialog("open");$("#gs-admin-clubbillingitem-ac").focus();TK.clubCheckOut.showCheckout();}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);}};this.deleteInvoice=function(){if(WebObj!=null&&WebObj.invoiceDTO.encryptedId!="7c2d1a0105c02a79"){TKAdmin.deleteInvoice(WebObj.invoiceDTO.encryptedId,TK.clubCheckOut.getInvoiceForPOSReturn);
}};this.taxToggle=function(){if(TK.actions.getLock()){TKAdmin.setInvoiceTaxes(TK.clubCheckOut.taxToggleReturn);}};this.taxToggleReturn=function(data){TK.actions.releaseLock();if(data!=null){if(data.error==TK.constants.SUCCESS){WebObj.invoiceDTO.taxes=data.taxes;TK.clubCheckOut.fillInvoiceData(data.misc);
TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);}};this.completeTransaction=function(){if(cartbalance==0){if(TK.actions.getLock()){TKAdmin.markTransactionComplete(false,TK.clubCheckOut.markTransactionCompleteReturn);}}else{TK.actions.alert("Balance is not 0.");
}};this.markTransactionCompleteReturn=function(data){TK.actions.releaseLock();if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.getInvoiceForPOSReturn(data);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert("Server error, try again.");}};this.setBadDebt=function(){if(WebObj.invoiceInventoryDTOs.length>0||WebObj.bookDTO!=null){TK.actions.showConfirm("Set As Bad Debt","Is this invoice an unrecoverable accounts receivable? Set this as a bad debt if the balance due is unrecoverable.",this.setBadDebtSubmit,"Set As Bad Debt","Cancel");
}else{TK.actions.alert("There are no items on this invoice to claim as bad debt.");}};this.setBadDebtSubmit=function(){if(TK.actions.getLock()){TKAdmin.markTransactionComplete(true,TK.clubCheckOut.markTransactionCompleteReturn);}};this.emailTransaction=function(){TK.actions.showConfirm("Email Invoice","Enter the reciept email: ",this.emailTransactionSubmit,"Send Email","Cancel");
};this.emailTransactionSubmit=function(){var email=$("#gs-emailinvoice").val();if(email==null||email.length==0){TK.actions.alert("Email is empty.");}else{if(TK.actions.getLock()){TKAdmin.emailInvoice(email,TK.clubCheckOut.emailTransactionReturn);}}};this.emailTransactionReturn=function(data){TK.actions.releaseLock();
if(data!=null){if(data.error==TK.constants.SUCCESS){TK.actions.alert("Email sent successfully.");}else{TK.actions.alert(data.misc);}}else{TK.actions.alert("Server error, try again.");}};this.fieldSwap=function(elem){TK.clubCheckOut.tid=$(elem).data("id");$(elem).hide();var value=$(elem).html();$("#"+TK.clubCheckOut.tid).val(value);
$("#"+TK.clubCheckOut.tid).show();setTimeout("document.getElementById(TK.clubCheckOut.tid).focus();",1);};this.inputBlur=function(elem){var id=$(elem).data("id");var eid=$(elem).data("eid");var value=parseInt($(elem).val());if(isNaN(value)||value==null||value<0){value=1;}var val2=$("#"+id).html();if(val2!=null&&val2.length!=0){val2=parseInt($.trim(val2));
}if(value>9999){TK.actions.alert("Quantity can not be greater than 9999");return;}if(val2!==value){$("#"+id).html(value);if(value==0){TK.clubCheckOut.removeInvoiceItem(eid);}else{if(TK.actions.getLock()){TKAdmin.updateInvoiceQty(eid,value,TK.clubCheckOut.updateInvoiceQtyReturn);}}}$(elem).hide();$("#"+id).show();
};this.updateInvoiceQtyReturn=function(data){TK.actions.releaseLock();if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.fillInvoiceData(data.misc);TK.clubCheckOut.updateInventory(data);TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);TK.clubCheckOut.loadInvoiceTable(WebObj);
}}else{TK.actions.alert(data.misc);}};this.removeSuspendedCart=function(cartId){if(TK.actions.getLock()){TKClub.deleteSuspendedCart(cartId,TK.clubCheckOut.showSuspendedListReturn);}};this.removeInvoiceItem=function(itemId){if(TK.actions.getLock()){TKAdmin.removeInvoiceItem(itemId,TK.clubCheckOut.removeInvoiceItemReturn);
}};this.removeInvoiceItemReturn=function(data){TK.actions.releaseLock();if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.fillInvoiceData(data.misc);TK.clubCheckOut.deleteInventory(data);TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);
}};this.posPayNow=function(){if(cartbalance==0){TK.actions.alert("There is no balance due, payments are not required.");return;}$("#gs-admin-dlgPOSPaymentSelect-step1").show();$("#gs-admin-dlgPOSPaymentSelect-step2").hide();$("#gs-admin-dlgPOSPaymentSelect").dialog("open");};this.cancelPayment=function(){$("#gs-admin-dlgPOSPaymentSelect").dialog("close");
};this.refundPayment=function(){var value=$("#gs-refundamount").val();if(TK.actions.getLock()){TKAdmin.refundPayment(curpayment.encryptedId,value,TK.clubCheckOut.refundPaymentReturn);}};this.showRefundConfirm=function(id){curpayment=null;for(var i=0;iRefund Amount: "+TK.constants.CURRENCY+"",this.refundPayment,"Yes","No");
}else{TK.actions.alert("Error, please refresh the page and try again");}};this.refundPaymentReturn=function(data){TK.actions.releaseLock();$("#gs-admin-dlgPOSPaymentSelect").dialog("close");$("#gs-pos-stripeForm").dialog("close");if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.fillInvoiceData(data.misc);
for(var i=0;i");
}else{$("#gs-pos-clubdiscount").dialog("close");sdate=nsDate;edate=neDate;if(TK.actions.getLock()){$("#invoice-list").hide();TKAdmin.addMonthlyDiscount(sdate,edate,TK.clubCheckOut.addDiscountToInvoiceReturn);}}};this.addDiscountToInvoiceReturn=function(data){TK.actions.releaseLock();if(data!=null){if(data.error==TK.constants.SUCCESS){WebObj.invoiceDiscountsDTOs[WebObj.invoiceDiscountsDTOs.length]=data;
TK.clubCheckOut.fillInvoiceData(data.misc);TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);}};this.calcCustomDiscount=function(val){var subTotal=0;if(WebObj.bookDTO!=null){subTotal=TK.clubCheckOut.getBookingTotal(WebObj);}subTotal+=TK.clubCheckOut.getInvTotal(WebObj);
subTotal=subTotal*(val/100);if(searchByCat){$("#gs-pos-txtDiscounts2").val(subTotal.toFixed(2));}else{$("#gs-pos-txtDiscounts").val(subTotal.toFixed(2));}};this.hideCustomDiscount=function(){$("#gs-pos-discounts").hide();$("#gs-pos-discounts2").hide();};this.addCustomDiscount=function(){var disc=$("#gs-pos-txtDiscounts").val();
if(searchByCat){disc=$("#gs-pos-txtDiscounts2").val();}if(TK.actions.getLock()){TKAdmin.addCustomDiscount(disc,TK.clubCheckOut.addCustomDiscountReturn);}};this.clearCustomDiscount=function(){if(TK.actions.getLock()){TKAdmin.addCustomDiscount(0,TK.clubCheckOut.addCustomDiscountReturn);}};this.addCustomDiscountReturn=function(data){TK.actions.releaseLock();
if(data!=null){if(data.error==TK.constants.SUCCESS){WebObj.invoiceDTO.discount=data.discount;TK.clubCheckOut.hideCustomDiscount();TK.clubCheckOut.fillInvoiceData(data.misc);TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);}};this.removeDiscountInvoiceReturn=function(data){TK.actions.releaseLock();
if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.fillInvoiceData(data.misc);for(var i=0;i0||(WebObj.invoiceDTO.encryptedBookingId!=null&&WebObj.invoiceDTO.encryptedBookingId.length>0)){if(TK.actions.getLock()){TKClub.suspendCart(TK.clubCheckOut.suspendCartReturn);
}}};this.suspendCartReturn=function(data){TK.actions.releaseLock();TK.clubCheckOut.getInvoiceForPOSReturn(data);};this.showSuspendedListReturn=function(data){TK.actions.releaseLock();if(data!=null){var msg="";msg+="
";
var costDisplay=parseFloat(result.totalCost);if(WebObj.invoiceDTO.feeApplied){costDisplay-=WebObj.invoiceDTO.feePaid;}msg+="
"+TK.constants.CURRENCY+costDisplay.toFixed(2)+"
";
msg+="";msg+="
";return msg;};this.unsuspendCart=function(cartId){if(TK.actions.getLock()){TKClub.getInvoiceForPOS(cartId,TK.clubCheckOut.getInvoiceForPOSReturn);}};this.confirmVoidTransaction=function(){TK.actions.showConfirm("Void Transaction","Are you SURE you want to void this transaction?",this.voidTransaction,"Yes","No");
};this.voidTransaction=function(){if(TK.actions.getLock()){TKAdmin.voidTransaction(TK.clubCheckOut.voidTransactionReturn);}};this.voidTransactionReturn=function(data){TK.actions.releaseLock();TK.clubCheckOut.getInvoiceForPOSReturn(data);};this.showCheckout=function(){$("#gs-pos-returns").hide();$("#gs-pos-btnSales").removeClass("alink");
$("#gs-pos-discounts-add").show();if(WebObj.invoiceDTO.finishedFlag){$("#gs-admin-dlgPOS-searchbox").hide();$("#gs-pos-customerDiv").hide();$("#gs-pos-btnFinish").hide();$("#gs-pos-btnBadDebt").hide();$("#gs-pos-btnEmail").show();if(WebObj.invoiceDTO.voided){$("#gs-pos-btnVoid").hide();}else{$("#gs-pos-btnVoid").show();
}$("#gs-pos-discounts-add").hide();$("#gs-pos-btnPay").hide();$("#gs-pos-btnSuspend").hide();$("#gs-pos-btnMemberBilling").hide();}else{$("#gs-admin-dlgPOS-searchbox").show();$("#gs-pos-btnVoid").show();$("#gs-pos-btnPay").show();$("#gs-pos-btnSuspend").show();$("#gs-pos-customerDiv").show();$("#gs-pos-btnFinish").hide();
$("#gs-pos-btnBadDebt").show();$("#gs-pos-btnEmail").hide();}$("#gs-admin-pos-club-ac").blur();$("#gs-admin-clubbillingitem-ac").focus();TK.clubCheckOut.loadInvoiceTable(WebObj);};this.toggleSearchByCat=function(){searchByCat=!searchByCat;TK.clubCheckOut.renderSearchByDiv();TK.clubCheckOut.loadInvoiceTable(WebObj);
};this.renderSearchByDiv=function(){if(searchByCat){$("#gs-pos-sales").hide();$("#gs-pos-search").show();TK.clubCheckOut.loadCats();$("#btnSearchByCats").switchClass("tk-blue-button","tk-orange-button");$("#btnSearchByCats").html("Search By Category On");}else{$("#gs-pos-sales").show();$("#gs-pos-search").hide();
$("#btnSearchByCats").switchClass("tk-orange-button","tk-blue-button");$("#btnSearchByCats").html("Search By Category Off");}};this.loadCats=function(){if(categories!=null){TK.clubCheckOut.renderCats();}else{if(TK.actions.getLock()){TKClub.getClubCategories(TK.clubCheckOut.loadCatsReturn);}}};this.loadCatsReturn=function(data){TK.actions.releaseLock();
categories=data;TK.clubCheckOut.renderCats();};this.renderCats=function(){$("#gs-pos-cats").html("");var msg="";if(categories==null||categories.length==0){msg+="
Member Discount for Player "+(i+1)+": "+disc.name;if(disc.discountTypeCode==2){var amount=booking.price*(disc.discount/100);msg+=" "+disc.discount+"%";msg+=" ("+TK.constants.CURRENCY+amount.toFixed(2)+")
";}}return msg;};this.addItemForReturn=function(eId){for(var i=0;icartCount){TK.actions.alert("Can not return more items than purchased.");
}else{if(TK.actions.getLock()){TKClub.addItemForReturn(eId,qty,TK.clubCheckOut.addItemForReturnReturn);}}}};this.addItemForReturnReturn=function(data){TK.actions.releaseLock();if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.fillInvoiceData(data.misc);TK.clubCheckOut.updateInventory(data);
TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);}};this.removeReturnItem=function(itemId){if(TK.actions.getLock()){TKClub.removeReturnItem(itemId,TK.clubCheckOut.removeReturnItemReturn);}};this.removeReturnItemReturn=function(data){TK.actions.releaseLock();
if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.fillInvoiceData(data.misc);TK.clubCheckOut.updateInventory(data);TK.clubCheckOut.loadInvoiceTable(WebObj);}else{TK.actions.alert(data.misc);}}else{TK.actions.alert(data.misc);}};this.printInvoiceReturn=function(data){if(data!=null){if(data.error==TK.constants.SUCCESS){TK.clubCheckOut.loadReceipt(WebObj);
var msg="";$("#gs-pos-qrcode").attr("src",data.misc);msg+=WebObj.invoiceDTO.encryptedId;$("#tk-club-invoice-id").html(msg);msg="";msg+=WebObj.dateDisplay;$("#tk-club-invoice-date").html(msg);var content_vlue=document.getElementById("print_content").innerHTML;content_vlue+="
";msg+="Mark As Claimed ";
msg+='Print ';}msg+='Back
';$("#gs-pos-raincheckView").html(msg);
};this.claimRainCheckConfirm=function(){TK.actions.showConfirm("Claim Raincheck","Do you wish to claim this rain check? This action CANNOT be reversed.",this.claimRainCheck,"Yes","No");};this.claimRainCheck=function(){if(TK.actions.getLock()){TKClub.claimRainCheck(curraincheck.encryptedId,TK.clubCheckOut.claimRainCheckReturn);
}};this.claimRainCheckReturn=function(data){TK.actions.releaseLock();curraincheck=data;TK.clubCheckOut.renderRainCheck();};this.printRainCheck=function(){TKClub.printRainCheck(curraincheck.encryptedId,TK.clubCheckOut.printRainCheckReturn);};this.printRainCheckReturn=function(data){if(data!=null){if(data.error==TK.constants.SUCCESS){var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
disp_setting+="scrollbars=yes,width=750, height=740, left=100, top=25";var content_vlue="
";content_vlue+="
Rain Check for "+CLUB_NAME+"
";content_vlue+="
Date: "+curraincheck.createdDate+"
";content_vlue+="
Thank you for your patronage! This Raincheck is good for ";
if(curraincheck.rainCheckTypeCode==1){content_vlue+="an 18 hole round.";}else{if(curraincheck.rainCheckTypeCode==2){content_vlue+="an 9 hole round.";}else{if(curraincheck.rainCheckTypeCode==3){content_vlue+="a value of "+TK.constants.CURRENCY+curraincheck.amount.toFixed(2)+".";}}}content_vlue+=" The barcode at the bottom is used to verify the rain check.";
content_vlue+="
This gift card is good for ";content_vlue+="a value of "+TK.constants.CURRENCY+curgc.amount.toFixed(2)+". ";content_vlue+="There is a remaining balance of "+TK.constants.CURRENCY+curgc.balance.toFixed(2)+". ";content_vlue+="Expires on: ";if(curgc.expirationDate!=null){content_vlue+=curgc.expirationDate.format("shortDate")+" ";
}else{content_vlue+="No Expiration ";}content_vlue+="Can be used by: ";if(TK.actions.isNotBlank(curgc.customerId)){content_vlue+=curgc.customerName+" ";}else{content_vlue+="Anyone ";}content_vlue+="The barcode at the bottom is used to verify the gift card.";content_vlue+="