(function($)
{
$.effects.fade = function(o) {
return this.queue(function() {
// Create element
var el = $(this);
// Set options
var speed = o.options.speed || 230;
var mode = o.options.mode || 'show'; // Set Mode
// Animate
if (mode == 'show') {
el.fadeIn(speed);
} else {
el.fadeOut(speed);
};
el.queue('fx', function() { el.dequeue(); });
el.dequeue();
});
};
})(jQuery);
$('.modalPayment').live('click',function(){
$("#dialogDiv").dialog('close');
$("#dialogDiv").data("title.dialog", 'Betalning');
$("#dialogDiv").data("width.dialog", 400);
$("#dialogDiv").data("height.dialog", 300);
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$('.modalMember').live('click',function(){
$("#dialogDiv").dialog('close');
$("#dialogDiv").data("title.dialog", 'Medlem');
$("#dialogDiv").data("width.dialog", 400);
$("#dialogDiv").data("height.dialog", 640);
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$('.modalClass').live('click',function(){
//alert($(this).attr('href'));
$("#dialogDiv").dialog('close');
// $("#dialogDiv").fadeTo("slow", 0.33);
$("#dialogDiv").data("title.dialog", 'Schema');
// $("#dialogDiv").data("width.dialog", 400);
$("#dialogDiv").data("height.dialog", 900);
$('#dialogDiv .body').width('800px');
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$('.modalSmall').live('click',function(){
$("#dialogDiv").dialog('close');
// $("#dialogDiv").fadeTo("slow", 0.33);
$("#dialogDiv").data("title.dialog", 'Schema');
$("#dialogDiv").data("width.dialog", 400);
$("#dialogDiv").data("height.dialog", 500);
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$('.modal').live('click',function(){
//alert($(this).attr('href'));
$("#dialogDiv").dialog('close');
// $("#dialogDiv").fadeTo("slow", 0.33);
$("#dialogDiv").data("title.dialog", 'Schema');
$("#dialogDiv").data("width.dialog", 400);
$("#dialogDiv").data("height.dialog", 200);
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$('.modalTiny').live('click',function(){
//alert($(this).attr('href'));
$("#dialogDiv").dialog('close');
// $("#dialogDiv").fadeTo("slow", 0.33);
$("#dialogDiv").data("title.dialog", 'Schema');
$("#dialogDiv").data("width.dialog", 300);
$("#dialogDiv").data("height.dialog", 200);
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$('.modalSchedule').live('click',function(){
// alert($(this).attr('href'));
$("#dialogDiv").dialog('close');
// $("#dialogDiv").fadeTo("slow", 0.33);
$("#dialogDiv").data("title.dialog", 'Schema');
$("#dialogDiv").data("width.dialog", 500);
$("#dialogDiv").data("height", 200);
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$('.modalPaymentType').live('click',function(){
//alert($(this).attr('href'));
$("#dialogDiv").dialog('close');
// $("#dialogDiv").fadeTo("slow", 0.33);
$("#dialogDiv").data("title.dialog", 'Schema');
$("#dialogDiv").data("width.dialog", 490);
$("#dialogDiv").data("height.dialog", 910);
$("#dialogDiv").load($(this).attr('href'));
$("#dialogDiv").dialog("open");
return false;
});
$(document).ready(function() {
$("#dialogDiv").dialog({
show: 'fade',
hide: 'fade',
autoOpen: false,
modal: true,
height: 'auto',
width: 'auto'
});
});
$(function() {
$("#tabs").tabs({cookie: {expires: 7}});
});
$('a[rel*=facebox]').live('mousedown', function() {
//$('a[rel*=calendarfacebox]').facebox();
jQuery.get($(this).attr('href'), function(data) {
jQuery.facebox(data)
})
});
jQuery(document).ready(function($) {
//$('a[rel*=facebox]').facebox();
$("table").tablesorter({
// sort on the first column and third column, order asc
sortList: [[0,0],[2,0]]
});
$(document).bind('reveal.facebox', function() {
// $('#scheduleTabs').tabs(fxFade: true, fxSpeed: 'fast');
$('#scheduleTabs').tabs();
$('#memberTabs').tabs();
} );
})
function addTableRow(jQtable){
jQtable.each(function(){
var $table = $(this);
// Number of td's in the last table row
var n = $('tr:last td', this).length;
var tds = '
';
for(var i = 0; i < n; i++){
tds += ' | ';
}
tds += '
';
if($('tbody', this).length > 0){
$('tbody', this).append(tds);
}else {
$(this).append(tds);
}
});
}
function nullify(value)
{
if (value==''){value='null';}
return value;
}
function UpdateTest(testID, descr, resultTypeID, testCategoryID, level, relativeTestID, relativeRatio){
// alert('testID='+testID+'&descr=' + descr + '&resultTypeID=' + resultTypeID + '&testCategoryID=' + testCategoryID + '&level=' + level + '&relativeTestID=' + relativeTestID + '&relativeRatio=' + relativeRatio);
$.ajax({
type: "GET",
url: "/ajax/adminUpdateTest.php",
data: 'testID='+testID+'&descr=' + descr + '&resultTypeID=' + resultTypeID + '&testCategoryID=' + testCategoryID + '&level=' + level + '&relativeTestID=' + relativeTestID + '&relativeRatio=' + relativeRatio,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Test uppdaterat');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function AddTest(descr, resultTypeID, testCategoryID){
//alert('descr=' + descr + '&resultTypeID=' + resultTypeID + '&testCategoryID=' + testCategoryID);
$.ajax({
type: "GET",
url: "/ajax/addTest.php",
data: 'descr=' + descr + '&resultTypeID=' + resultTypeID + '&testCategoryID=' + testCategoryID,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Test skapat');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function DeleteTest(testID){
// alert('memberPaymentTypeID=' + memberPaymentTypeID);
if (confirm('Vill du VERKLIGEN ta bort testet? Detta går inte att ångra!'))
{
$.ajax({
type: "GET",
url: "/ajax/deleteTest.php",
data: 'testID=' + testID,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Testet borttagen');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
}
function UpdatePayment(memberPaymentTypeID, memberID, paymentTypeID, validUntil, visitsLeft, discount){
//alert('memberPaymentTypeID='+memberPaymentTypeID+'&memberID=' + memberID + '&paymentTypeID=' + paymentTypeID + '&validUntil=' + nullify(validUntil) + '&visitsLeft=' + nullify(visitsLeft) + '&discount=' + nullify(discount));
$.ajax({
type: "GET",
url: "/ajax/updatePayment.php",
data: 'memberPaymentTypeID='+memberPaymentTypeID+'&memberID=' + memberID + '&paymentTypeID=' + paymentTypeID + '&validUntil=' + nullify(validUntil) + '&visitsLeft=' + nullify(visitsLeft) + '&discount=' + nullify(discount),
success: function(XMLHttpRequest)
{
if (validUntil == '0000-00-00')
{
$("#validUntil"+memberPaymentTypeID).text('');
}
else
{
$("#validUntil"+memberPaymentTypeID).text(validUntil);
}
$("#visitsLeft"+memberPaymentTypeID).text(visitsLeft);
$("#dialogDiv").dialog('close');
jQuery.facebox('Betalning uppdaterad');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function AddPayment(memberID, paymentTypeID, validUntil, visitsLeft, discount){
//alert('memberID=' + memberID + '&paymentTypeID=' + paymentTypeID + '&validUntil=' + nullify(validUntil) + '&visitsLeft=' + nullify(visitsLeft) + '&discount=' + nullify(discount));
$.ajax({
type: "GET",
url: "/ajax/addPayment.php",
data: 'memberID=' + memberID + '&paymentTypeID=' + paymentTypeID + '&validUntil=' + nullify(validUntil) + '&visitsLeft=' + nullify(visitsLeft) + '&discount=' + nullify(discount),
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Betalning inlagd');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function DeletePayment(memberPaymentTypeID){
// alert('memberPaymentTypeID=' + memberPaymentTypeID);
if (confirm('Vill du VERKLIGEN ta bort betalningen? Detta går inte att ångra!'))
{
$.ajax({
type: "GET",
url: "/ajax /deletePayment.php",
data: 'memberPaymentTypeID=' + memberPaymentTypeID,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Betalning borttagen');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
}
function AddClassType(descr, places, booking, foundation, typeID, classesToBookInFuture){
//alert('classID='+id+'&descr=' + descr + '&places=' + places + '&booking=' + booking + '&foundation=' + foundation + '&typeID=' + typeID + '&classesToBookInFuture=' + classesToBookInFuture);
$.ajax({
type: "GET",
url: "/ajax/addClassType.php",
data: 'descr=' + descr + '&places=' + places + '&booking=' + booking + '&foundation=' + foundation + '&typeID=' + typeID + '&classesToBookInFuture=' + classesToBookInFuture,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Passtyp inlagd');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function UpdateClassType(id, descr, places, booking, foundation, typeID, classesToBookInFuture, classStyle){
//alert('classID='+id+'&descr=' + descr + '&places=' + places + '&booking=' + booking + '&foundation=' + foundation + '&typeID=' + typeID + '&classesToBookInFuture=' + classesToBookInFuture + '&classStyle=' + classStyle);
$.ajax({
type: "GET",
url: "/ajax/updateClassType.php",
data: 'classID='+id+'&descr=' + descr + '&places=' + places + '&booking=' + booking + '&foundation=' + foundation + '&typeID=' + typeID + '&classesToBookInFuture=' + classesToBookInFuture + '&classStyle=' + classStyle,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Passtyp uppdaterad');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function DeleteClassType(classID){
//alert('classID=' + classID);
if (confirm('Vill du VERKLIGEN ta bort betalningen? Detta går inte att ångra!'))
{
$.ajax({
type: "GET",
url: "/ajax /deleteClassType.php",
data: 'classID=' + classID,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Passtyp borttagen');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
}
function AddPaymentType(descr, price, length, type, numberOfVisits, divided, longTerm, buyOnce, visible, viewOrder, exclusiveMemberID, longDescr, notDirectPayment,notDirectPaymentMessage,limitedBookingsPerWeek,limitedBookingsPerMonth){
//alert('descr=' + descr + '&price=' + price + '&length=' + length + '&type=' + type + '&numberOfVisits='+ nullify(numberOfVisits) +'÷d='+ nullify(divided)+'&longTerm='+ nullify(longTerm) +'&buyOnce='+ buyOnce +'&visible='+ visible +'&viewOrder='+ nullify(viewOrder) +'&exclusiveMemberID='+ nullify(exclusiveMemberID)+'&longDescr='+ longDescr+ '¬DirectPayment=' + notDirectPayment +'¬DirectPaymentMessage='+notDirectPaymentMessage+'&limitedBookingsPerWeek='+limitedBookingsPerWeek+'&limitedBookingsPerMonth='+limitedBookingsPerMonth);
$.ajax({
type: "GET",
url: "/ajax/addPaymentType.php",
data: 'descr=' + descr + '&price=' + price + '&length=' + length + '&type=' + type + '&numberOfVisits='+ nullify(numberOfVisits) +'÷d='+ nullify(divided)+'&longTerm='+ nullify(longTerm) +'&buyOnce='+ buyOnce +'&visible='+ visible +'&viewOrder='+ nullify(viewOrder) +'&exclusiveMemberID='+ nullify(exclusiveMemberID)+'&longDescr='+ longDescr+ '¬DirectPayment=' + notDirectPayment +'¬DirectPaymentMessage='+notDirectPaymentMessage+'&limitedBookingsPerWeek='+limitedBookingsPerWeek+'&limitedBookingsPerMonth='+limitedBookingsPerMonth,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Träningskort inlagt');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function DeletePayment(memberPaymentTypeID){
// alert('memberPaymentTypeID=' + memberPaymentTypeID);
if (confirm('Vill du VERKLIGEN ta bort betalningen? Detta går inte att ångra!'))
{
$.ajax({
type: "GET",
url: "/ajax /deletePayment.php",
data: 'memberPaymentTypeID=' + memberPaymentTypeID,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Betalning borttagen');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
}
function UpdatePaymentType(paymentTypeID, descr, price, length, type, numberOfVisits, divided, longTerm, buyOnce, visible, viewOrder, exclusiveMemberID, longDescr,notDirectPayment,notDirectPaymentMessage,limitedBookingsPerWeek,limitedBookingsPerMonth){
//alert('paymentTypeID=' + paymentTypeID +'&descr=' + descr + '&price=' + price + '&length=' + length + '&type=' + type + '&numberOfVisits='+ nullify(numberOfVisits) +'÷d='+ nullify(divided)+'&longTerm='+ nullify(longTerm) +'&buyOnce='+ buyOnce +'&visible='+ visible +'&viewOrder='+ nullify(viewOrder) +'&exclusiveMemberID='+ nullify(exclusiveMemberID)+'&longDescr='+ longDescr+ '¬DirectPayment=' + notDirectPayment +'¬DirectPaymentMessage='+notDirectPaymentMessage+'&limitedBookingsPerWeek='+limitedBookingsPerWeek+'&limitedBookingsPerMonth='+limitedBookingsPerMonth);
$.ajax({
type: "GET",
url: "/ajax/updatePaymentType.php",
data: 'paymentTypeID=' + paymentTypeID +'&descr=' + descr + '&price=' + price + '&length=' + length + '&type=' + type + '&numberOfVisits='+ nullify(numberOfVisits) +'÷d='+ nullify(divided)+'&longTerm='+ nullify(longTerm) +'&buyOnce='+ buyOnce +'&visible='+ visible +'&viewOrder='+ nullify(viewOrder) +'&exclusiveMemberID='+ nullify(exclusiveMemberID)+'&longDescr='+ longDescr+ '¬DirectPayment=' + notDirectPayment +'¬DirectPaymentMessage='+notDirectPaymentMessage+'&limitedBookingsPerWeek='+limitedBookingsPerWeek+'&limitedBookingsPerMonth='+limitedBookingsPerMonth,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Träningskort inlagt');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function DeletePaymentType(paymentTypeID)
{
if (confirm('Vill du VERKLIGEN ta bort träningskortet? Detta går inte att ångra! Notera att du BEHÖVER ha kvar kortet om du har medlemmar som använder det för att boka, eller om du vill behålla din historik över tidigare köp. Bara i undantag ska du ta bort ett kort som använts tidigare!'))
{
//alert('paymentTypeID='+paymentTypeID);
$.ajax({
type: "GET",
url: "/ajax/deletePaymentType.php",
data: 'paymentTypeID='+paymentTypeID,
success: function(XMLHttpRequest)
{
/*TODO: remove from table*/
$("#dialogDiv").dialog('close');
jQuery.facebox('Träningskort borttaget');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
}
function UpdateCustomer(administratorEmail, paysonID, paypalID, contactURL, sendWelcomeEmail, bookingURL, paysonAgentID, paysonMD5key, paypalAsPrimary, useMobileCss, classesToBookInFuture, welcomeEmailSubject, welcomeEmailText, waiver, calendarSortMethodID, coloredSchedules)
{
//alert('administratorEmail='+administratorEmail+'&paysonID='+paysonID+'&paypalID='+paypalID+'&contactURL='+contactURL+'&sendWelcomeEmail='+sendWelcomeEmail+'&bookingURL='+bookingURL+'&paysonAgentID='+paysonAgentID+'&paysonMD5key='+paysonMD5key+'&paypalAsPrimary='+paypalAsPrimary+'&useMobileCss='+useMobileCss+'&classesToBookInFuture='+classesToBookInFuture+'&welcomeEmailSubject='+welcomeEmailSubject+'&welcomeEmailText='+welcomeEmailText+'&waiver='+waiver+'&calendarSortMethodID='+calendarSortMethodID+'&coloredSchedules='+coloredSchedules);
$.ajax({
type: "POST",
url: "/ajax/updateCustomer.php",
data: 'administratorEmail='+administratorEmail+'&paysonID='+paysonID+'&paypalID='+paypalID+'&contactURL='+contactURL+'&sendWelcomeEmail='+sendWelcomeEmail+'&bookingURL='+bookingURL+'&paysonAgentID='+paysonAgentID+'&paysonMD5key='+paysonMD5key+'&paypalAsPrimary='+paypalAsPrimary+'&useMobileCss='+useMobileCss+'&classesToBookInFuture='+classesToBookInFuture+'&welcomeEmailSubject='+welcomeEmailSubject+'&welcomeEmailText='+welcomeEmailText+'&waiver='+waiver+'&calendarSortMethodID='+calendarSortMethodID+'&coloredSchedules='+coloredSchedules,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Kundinformation uppdaterad');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function UpdatePaymentClosed(boolClosed, numberofDaysToRenew, closedText)
{
//alert('closed='+boolClosed+'&numberofDaysToRenew='+numberofDaysToRenew+'&closedText='+closedText);
$.ajax({
type: "GET",
url: "/ajax/updatePaymentClosed.php",
data: 'closed='+boolClosed+'&numberofDaysToRenew='+numberofDaysToRenew+'&closedText='+closedText,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Kundinformation uppdaterad');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function UpdateLateBookings(lateUnbookMinutes, lateUnbookUntilFreeze, freezeCardDays, freezeUnbookTimeframe, lateUnbookMessage)
{
//alert('lateUnbookMinutes='+lateUnbookMinutes+'&lateUnbookUntilFreeze='+lateUnbookUntilFreeze+'&freezeCardDays='+freezeCardDays+'&freezeUnbookTimeframe='+freezeUnbookTimeframe+'&lateUnbookMessage='+lateUnbookMessage);
$.ajax({
type: "GET",
url: "/ajax/updateLateBookings.php",
data: 'lateUnbookMinutes='+lateUnbookMinutes+'&lateUnbookUntilFreeze='+lateUnbookUntilFreeze+'&freezeCardDays='+freezeCardDays+'&freezeUnbookTimeframe='+freezeUnbookTimeframe+'&lateUnbookMessage='+lateUnbookMessage,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Kundinformation uppdaterad');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function UpdateMember(memberID, name, pnr, phone, address1, address2, email, password, timestamp, memberTypeID, canBuyMembershipIfClosed, completedOnramp, frozenTo, taggNumber)
{
//alert('memberID='+memberID+'&name='+name+'&pnr='+pnr+'&phone='+phone+'&address1='+address1+'&address2='+address2+'&email='+email+'&password='+password+'×tamp='+timestamp+'&memberTypeID='+memberTypeID+'&canBuyMembershipIfClosed='+canBuyMembershipIfClosed+'&completedOnramp='+completedOnramp+'&frozenTo='+frozenTo+'&taggNumber='+taggNumber);
$.ajax({
type: "GET",
url: "/ajax/updateMember.php",
data: 'memberID='+memberID+'&name='+name+'&pnr='+pnr+'&phone='+phone+'&address1='+address1+'&address2='+address2+'&email='+email+'&password='+password+'×tamp='+timestamp+'&memberTypeID='+memberTypeID+'&canBuyMembershipIfClosed='+canBuyMembershipIfClosed+'&completedOnramp='+completedOnramp+'&frozenTo='+frozenTo+'&taggNumber='+taggNumber,
success: function(XMLHttpRequest)
{
//alert(document.getElementById('name'+memberID).innerHTML);
$("#name"+memberID).text(name);
$("#pnr"+memberID).text(pnr);
$("#phone"+memberID).text(phone);
$("#address1"+memberID).text(address1);
$("#address2"+memberID).text(address2);
$("#email"+memberID).text(email);
$("#timestamp"+memberID).text(timestamp);
$("#dialogDiv").dialog('close');
jQuery.facebox('Medlem Uppdaterad');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function AddMember(name, pnr, phone, address1, address2, email, timestamp, password, memberTypeID, canBuyMembershipIfClosed, completedOnramp)
{
//alert('name='+name+'&pnr='+pnr+'&phone='+phone+'&address1='+address1+'&address2='+address2+'&email='+email+'×tamp='+timestamp+'&password='+password+'&memberTypeID='+memberTypeID);
$.ajax({
type: "GET",
url: "/ajax/addMember.php",
data: 'name='+name+'&pnr='+pnr+'&phone='+phone+'&address1='+address1+'&address2='+address2+'&email='+email+'×tamp='+timestamp+'&password='+password+'&memberTypeID='+memberTypeID+'&canBuyMembershipIfClosed='+canBuyMembershipIfClosed+'&completedOnramp='+completedOnramp,
success: function(XMLHttpRequest)
{
/*TODO: insert new member in table*/
//alert(document.getElementById('name'+memberID).innerHTML);
/*$("#name"+memberID).text(name);
$("#pnr"+memberID).text(pnr);
$("#phone"+memberID).text(phone);
$("#address1"+memberID).text(address1);
$("#address2"+memberID).text(address2);
$("#email"+memberID).text(email);
$("#timestamp"+memberID).text(timestamp);*/
$("#dialogDiv").dialog('close');
jQuery.facebox('Medlem skapad!');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function DeleteMember(memberID)
{
if (confirm('Vill du VERKLIGEN ta bort medlemmen? Detta går inte att ångra!'))
{
//alert('paymentTypeID='+paymentTypeID);
$.ajax({
type: "GET",
url: "/ajax/deleteMember.php",
data: 'memberID='+memberID,
success: function(XMLHttpRequest)
{
/*TODO: remove from table*/
$("#dialogDiv").dialog('close');
jQuery.facebox('Medlem borttagen');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
}
/* calendar */
/*$(document).ready(function(){
$("div.box").corner();
$("div.bookedbox").corner();
});*/
$(function() {
$("#datepicker").datepicker();
});
$(document).bind('reveal.facebox', function() {
$("#dateStart").datepicker();
} );
//var reg = /^(.*)(.*)( platser|places.*)$/i;
var reg = /^(.*)(.*)( platser|places|Plätze|ledige.*)/i;
function deleteSchedule(scheduleID){
$.ajax({
type: "GET",
url: "/ajax/deleteClass.php",
data: 'scheduleID='+scheduleID,
success: function(XMLHttpRequest)
{
$("#tableCellScheduleID"+scheduleID).remove();
jQuery.facebox('Pass borttaget');
setTimeout('$.facebox.close();',2000);
location.reload();
// $("#tabs").tabs('load',2);
// $("#tabs").tabs( 'select' , 2 )
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function addSchedule(dateStart, timeStart, classID, trainerID, WOD, reoccuringDateStop, length){
//alert('dateStart=' + dateStart + '&timeStart=' + timeStart + '&classID=' + classID + '&trainerID=' + trainerID + '&WOD=' + WOD + '&reoccuringDateStop=' + reoccuringDateStop + '&length=' + length);
$.ajax({
type: "GET",
url: "/ajax/addClass.php",
data: 'dateStart=' + dateStart + '&timeStart=' + timeStart + '&classID=' + classID + '&trainerID=' + trainerID + '&WOD=' + WOD + '&reoccuringDateStop=' + reoccuringDateStop + '&length=' + length,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Pass uppdaterat');
setTimeout('$.facebox.close();',2000);
location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function unbook(scheduleID, places, memberID){
//alert('scheduleID='+scheduleID+'&memberID='+memberID);
$.ajax({
type: "GET",
url: "/ajax/unbookClass.php",
data: 'scheduleID='+scheduleID+'&memberID='+memberID,
success: function(XMLHttpRequest)
{
var ar = reg.exec($("#scheduleID"+scheduleID).html());
var newPlacesLeft = parseInt(ar[2])+1;
$("#scheduleID"+scheduleID).html(ar[1]+newPlacesLeft+ar[3]);
$("#scheduleID"+scheduleID).attr('href', '/calendar/bookClass.php?id='+scheduleID );
$("#divscheduleID"+scheduleID).attr('class','nobox');
$("#dialogDiv").dialog('close');
jQuery.facebox('');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function unbookAdmin(scheduleID, places, memberID){
//alert('scheduleID='+scheduleID+'&memberID='+memberID);
$.ajax({
type: "GET",
url: "/ajax/unbookClass.php",
data: 'scheduleID='+scheduleID+'&memberID='+memberID,
success: function(XMLHttpRequest)
{
var ar = reg.exec($("#scheduleID"+scheduleID).html());
var newPlacesLeft = parseInt(ar[2])+1;
$("#scheduleID"+scheduleID).html(ar[1]+newPlacesLeft+ar[3]);
$("#divscheduleID"+scheduleID).attr('class','nobox');
$("#dialogDiv").dialog('close');
jQuery.facebox('');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function editSchedule(scheduleID, dateStart, timeStart, classID, trainerID, WOD, changeDate, day, length,modality,warmup,strength,conditioning){
//alert('scheduleID='+scheduleID+'&dateStart=' + dateStart + '&timeStart=' + timeStart + '&classID=' + classID + '&trainerID=' + trainerID + '&WOD=' + WOD + '&length=' + length + '&modality=' + modality + '&warmup=' + warmup + '&strength=' + strength+ '&conditioning=' + conditioning);
$.ajax({
type: "GET",
url: "/ajax/editSchedule.php",
data: 'scheduleID='+scheduleID+'&dateStart=' + dateStart + '&timeStart=' + timeStart + '&classID=' + classID + '&trainerID=' + trainerID + '&WOD=' + WOD + '&length=' + length + '&modality=' + modality + '&warmup=' + warmup + '&strength=' + strength+ '&conditioning=' + conditioning,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Pass uppdaterat');
setTimeout('$.facebox.close();',2000);
//var ar = reg.exec($("#tableCell"+scheduleID).html());
//Do we need to move the schedule?
if (changeDate == 1)
{
var tableCell = $("#tableCellScheduleID"+scheduleID).html();
$("#tableCellScheduleID"+scheduleID).remove();
var regDay = /-.*-(.*)$/;
var ar = regDay.exec(dateStart);
var newDay = parseInt(ar[1]);
var tableRow = ''+tableCell+'
';
$("#table"+newDay).append(tableRow);
}
$("#warmup"+scheduleID).text(warmup);
$("#strength"+scheduleID).text(strength);
$("#conditioning"+scheduleID).text(conditioning);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function addMemberToSchedule(memberID, places, scheduleID, bookingMemberID)
{
//alert('scheduleID='+scheduleID+'&memberID=' + memberID + '&bookingMemberID=' + bookingMemberID);
$.ajax({
type: "GET",
url: "/ajax/bookClass.php",
data: 'scheduleID='+scheduleID+'&memberID=' + memberID + '&bookingMemberID=' + bookingMemberID,
success: function(XMLHttpRequest)
{
var ar = reg.exec($("#scheduleID"+scheduleID).html());
var newPlacesLeft = parseInt(ar[2])-1;
$("#scheduleID"+scheduleID).html(ar[1]+newPlacesLeft+ar[3]);
$("#dialogDiv").dialog('close');
jQuery.facebox('');
setTimeout('$.facebox.close();',2000);
//location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function addToOnHoldList(scheduleID, memberID)
{
//alert('scheduleID='+scheduleID+'&memberID=' + memberID);
$.ajax({
type: "GET",
url: "/ajax/addToOnHold.php",
data: 'scheduleID='+scheduleID+'&memberID=' + memberID,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Tillagd på väntelistan');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
function book(scheduleID, places, memberID){
//alert('scheduleID='+scheduleID+'&memberID=' + memberID);
$.ajax({
type: "GET",
url: "/ajax/bookClass.php",
data: 'scheduleID='+scheduleID+'&memberID=' + memberID,
success: function(XMLHttpRequest)
{
var ar = reg.exec($("#scheduleID"+scheduleID).html());
//alert(reg);
var newPlacesLeft = parseInt(ar[2])-1;
$("#scheduleID"+scheduleID).html(ar[1]+newPlacesLeft+ar[3]);
//if (memberID==1) /* kolla på det här senare */
{
$("#scheduleID"+scheduleID).attr('href', '/calendar/unbookClass.php?id='+scheduleID );
$("#divscheduleID"+scheduleID).attr('class','box');
$("#divscheduleID"+scheduleID).corner();
}
$("#dialogDiv").dialog('close');
jQuery.facebox('');
setTimeout('$.facebox.close();',2000);
//location.reload();
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}
/*AJAX*/
// here we define global variable
var ajaxdestination="";
function getdata(what,where) { // get data from source (what)
try {
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) { /* do nothing */ }
//document.getElementById(where).innerHTML ="
";
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
ajaxdestination=where;
xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
xmlhttp.open("GET", what);
xmlhttp.send(null);
return false;
}
function triggered() { // put data returned by requested URL to selected DIV
// alert(xmlhttp.status);
if (xmlhttp.readyState == 4) if (xmlhttp.status == 200)
document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
$("div.box").corner();
//$("div.bookedbox").corner();
}
function waiver()
{
$("#dialogDiv").dialog('close');
$("#dialogDiv").data("title.dialog", '');
$("#dialogDiv").data("width.dialog", 700);
$("#dialogDiv").data("height.dialog", 700);
$("#dialogDiv").load("/waiver.php");
$("#dialogDiv").dialog("open");
//jQuery.facebox({ ajax: '/waiver.php'});
}
function signWaiver(memberID){
$.ajax({
type: "GET",
url: "/ajax/signWaiver.php",
data: 'memberID='+memberID,
success: function(XMLHttpRequest)
{
$("#dialogDiv").dialog('close');
jQuery.facebox('Medlemskapsregler godkända');
setTimeout('$.facebox.close();',2000);
},
error: function(XMLHttpRequest,textStatus,error){
alert("ERROR:\n" + textStatus, + "\n" + error)
}
});
}