var MOCA_HOME_ID = 225; var MOCA_BASE_URL = 'https://v2.bookingrooster.nz/'; var MOCA_BASE_DIR = '/'; var MOCA_HOME_URL = 'https://v2.bookingrooster.nz/home'; var MOCA_BASE_ENTITY = 'Course'; var MOCA_BASE_ENTITYL = 'course'; var MOCA_HOST_ENTITY = 'Presenter'; var MOCA_HOST_ENTITYL = 'presenter'; var MOCA_TICKET_ENTITY = 'Ticket'; var MOCA_TICKET_ENTITYL = 'ticket'; var MOCA_TICKET_HOLDER_ENTITY = 'Attendee'; var MOCA_TICKET_HOLDER_ENTITYL = 'attendee'; var MOCA_ROADSHOW_ENTITY = 'Series'; var MOCA_ROADSHOW_ENTITYL = 'series'; var MOCA_USE_MIDDLE_NAME = '1'; var MOCA_USE_TYPES = '2'; var MOCA_USE_QUALS = '1'; var MOCA_USE_CERTS = '1'; var MOCA_ACCESS_LINK_ENTITY = 'Access Link'; var BR_CURRENT_COUNTRY = {"timezone":"NZDT","currency":"NZD","ccode":"NZ","icode":"64","name":"New Zealand"}; var MOCA_USE_PARTNERS = '1'; // Default table listing row bg colour var MOCA_TABLE_BG_DEFAULT = '#fff'; // Used to stripe listing tables for readability var MOCA_TABLE_BG = '#f3f3f3'; // Back-end var MOCA_SITE_TABLE_BG = '#e5e5e5'; // Front-end var MOCA_TABLE_BG_BLUE = '#e5e5e5'; // Highlight record being edited var MOCA_TABLE_HIGHLIGHT = '#ffc'; // Highlight just-created field var MOCA_TABLE_NEW_ROW = 'pink'; // Deprecated! [multiple currencies for orgs now pos // var MOCA_GST_RATE = 15; // eg: Optional ticket holder fields var MOCA_FIELD_EXISTS = 1; var MOCA_FIELD_REQUIRED = 2; var MOCA_BR_ADMIN_PRICE_TYPE_DOLLARS = 'dollars'; var MOCA_BR_ADMIN_PRICE_TYPE_PERCENTAGE = 'percentage'; var MOCA_FUNC_UPDATE = 'update'; var MOCA_FUNC_ADD = 'add'; var MOCA_FUNC_DELETE = 'delete'; var MOCA_FUNC_PROGRESS = 'progress'; var MOCA_CURRENT_YEAR = 2024; var MOCA_AGE_LIMIT = 16; var MOCA_MAX_ATTENDEE_YEAR = 2008; var MOCA_ECOMMERCE_TRACKING = ''; var MOCA_SHARED_SITE = false; /* Common Stylesheet colours: */ var MOCA_BR_CSS_ORANGE = '#d76927'; var MOCA_BR_CSS_BROWN = '#6B4936'; var MOCA_BR_CSS_DISABLED = '#9a9a9a'; // ckeditor window.WEBSPELLCHECKER_CONFIG = { autoSearch: true, lang: 'en_NZ', serviceId: 'UpGWdGRTXqi7SoK' }; var MOCA_MONTHS = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var MOCA_MONTH_NAMES = ['January','February','March','April','May','June','July','August','September','October','November','December']; $.ajaxSetup({ //cache:false, error:function(x,e){ unthrob(); if(x.status==0){ // mocaAlert('No network found','Please try again'); }else if(x.status==404){ mocaAlert('Requested url not found','Whoops!'); }else if(x.status==500){ mocaAlert('A server error '+x.responseText+' - please contact the administrator','Whoops!'); }else if(e=='parsererror'){ //console.log(dump(x)); var msg = '
Houston, we have a problem!
For help, please call 07 575 6903 or brendon@actrix.co.nz.
If you\'re a technology whiz it\'s ideal to send a screenshot of this page when you contact us
'; false ? frontEndAlert(msg,'Whoops!') : mocaAlert(msg,'Whoops!'); }else if(e=='timeout'){ mocaAlert('Request time out','Please Try Again'); }else { //mocaAlert('Unknown Ajax Error: '+x.responseText); } } }); function fethrob(){ $('#throbber').show(); return true; } function feunthrob(){ $('#throbber').hide(); return true; } function throb(el){ if(el){ $('#ajaxBusy').css('top',(el.offset()).top); $('#ajax-busy').css('top',(el.offset()).top); } $('.ajax-busy').show(); $('.ajaxBusy').show(); return true; } function unthrob(){$('.ajaxBusy').hide();return $('.ajax-busy').hide(); } // For ajax calls var Func = { add:'add', edit:'edit', delete:'delete', status:'status', update:'update', progress:'progress', search:'search', costs: 'costs' }; // Dismiss status messages when anything clicked: // $(document).ready(function(){$("*", document.body).bind('click',function(){$('#statusMessage').text('');});}); // Populated by MocaForm::initJavascript() var Help = {}; // Whether fckeditor should use default fe stylesheet var MocaFckStyles = true; function logout(){ window.location.href = MOCA_BASE_URL + 'sitemgr/logout.php'; } function highlightRows(table_id, no_header_row,skip){ /* Given the ID of a table element, set every alternate row's background colour to MOCA_TABLE_BG colour. Unless no_header_row is set, the first row will be left untouched. Apply the class 'nonList' to any rows you want skipped */ var odd = false; var first = true; $('TABLE#' + table_id + ' TR:not(.nonList)').map( function(){ if(!no_header_row && first){skip--;first = false;return;} if(skip){odd=true;skip--;return;} if($(this).css('display')!='none'){ $('*:not(.nonList)',$(this)).map(function(){this.style.backgroundColor = odd ? MOCA_TABLE_BG : '';}); odd = !odd; } }) } function feHighlightRows(table_id, no_header_row,skip,colour){ /* Same for front-end */ var odd = true; var first = true; var clr = colour ? colour : MOCA_SITE_TABLE_BG; $('TABLE#' + table_id + '>TBODY>TR:not(.nonList)').map( function(){ if(!no_header_row && first){skip--;first = false;return;} if(skip){odd=true;skip--;return;} if($(this).css('display')!='none' && $(this).is(':visible')){ $('TD:not(.nonList)',$(this)).map(function(){this.style.backgroundColor = odd ? clr : '';}); odd = !odd; } }) } function highlightOptions(select_id,colour ){ /* Given the ID of a select element, set every alternate option's background colour to given colour.MOCA_TABLE_BG colour. */ colour = colour ? colour : MOCA_TABLE_BG; var odd = false; $('SELECT#' + select_id + ' OPTION:not(.nonList)').map( function(){ if($(this).css('display')!='none'){ this.style.backgroundColor = odd ? colour : ''; odd = !odd; } }) } function feHighlightOptions(select_id,colour ){ /* Given the ID of a select element, set every alternate option's background colour to given colour.MOCA_TABLE_BG colour. */ colour = colour ? colour : MOCA_SITE_TABLE_BG; var odd = false; $('SELECT#' + select_id + ' OPTION:not(.nonList)').map( function(){ if($(this).css('display')!='none'){ this.style.backgroundColor = odd ? colour : ''; odd = !odd; } }) } function FCKeditor_OnComplete(ed){ // Called by editor onLoad, change internal // stylesheet to that initialised by moca.form if(!MocaFckStyles){return;} //var ht = ed.GetData(); if($('#moca_browser').val()){ ed.Config['ImageBrowserWindowWidth'] = ed.Config['ScreenWidth'] * 0.4; ed.Config['ImageBrowserWindowHeight'] = ed.Config['ScreenHeight'] * 0.4; ed.Config['LinkBrowserWindowWidth'] = ed.Config['ScreenWidth'] * 0.5; ed.Config['LinkBrowserWindowHeight'] = ed.Config['ScreenHeight'] * 0.5; ed.Config['LinkBrowserURL'] = ed.Config['BasePath'] + 'filemanager/browser/link/fe_browser.php' ; } } function deleteFromListing(frm,ids){ // Delete records from listing page - ids is either array or // comma-separated string of ids. Form is DOM element frm.id_list.value = typeof ids == 'string' ? ids : ids.join(','); frm.func.value = 'delete'; frm.submit(); } // Convenience func for use in mocaConfirm & ilk function goto(href){window.location.href=href;} function showHelp(id){ if((Help == undefined) || !Help[id]){return;} mocaAlert(Help[id],'Help'); } function initHelp(){ $('.mfHelp').click(function() { if($(this).data("qtip")) $(this).qtip("destroy"); var n = this.id.substr(7)=='mfHelp_' ? this.id.substr(7) : this.id; if((Help == undefined) || !Help[n]){return;} var pos = $(this).hasClass('topLeft') ? {corner:{target:'topLeft',tooltip:'topRight'}} : ($(this).hasClass('bottomLeft') ? {corner:{target:'bottomLeft',tooltip:'topRight'}} : {corner:{target:'topRight',tooltip:'leftBottom'}}); $(this).qtip({ content:Help[n], position:pos, show:{when:false, ready:true}, hide:{when:'unfocus'}, style: { border:{width:5,radius:10,color:'#002b73'}, padding:10, background:'#002b73', color:'#ffffff', textAlign: 'left', tip: true, name: 'cream' } }); }); } // Front-end BR help $(document).ready(function(){ initHelp(); return false;}); function mocaPrompt(str,func,title) { str = str.indexOf('<')>-1 ? str : '' + str + '
'; str += ''; $('BODY').append('' + str + '
'; $('BODY').append(''+str+'
'); } if(el_id){ $('#'+el_id).scrollAboveHere(); } $('#mocaModalAlert').modal(); } function mocaAlert(str,title,pos,append){ console.log("title = " + title); /* Custom alert. First arg is message string. Second is title. Third is function to be executed on close. Only the first is mandatory */ title = title ? title : ''; var func = arguments[2] ? arguments[2] : null; var target_element = arguments[3] ? arguments[3] : null; switch('jquidialog'){ case 'jquidialog': if ($('body.kiosk').length>0 || $('body.public').length>0){return frontEndAlert(str,title);} str = str.includes('<') ? str : '' + str + '
'; if($('#mocaDialog').length==0){ var cont = target_element ? target_element : 'body'; $(cont).append(' '); } else{ $('#mocaDialog').attr('title',title).html(str); } !pos ? $('#mocaDialog').dialog({title:title,buttons:{'Ok':function(){$(this).dialog('close');}}}) : $('#mocaDialog').dialog({title:title, position:{my:'left top',at:'left top',of: pos}, buttons:{'Ok':function(){$(this).dialog('close');}}}); return false; /*{ appendTo:'body', 'close':function(){if(func){func();}else{$(this).remove();}}, 'buttons': { 'Ok': function() { if(func){func();} else {$(this).remove();} } } }); if(jQuery().easydrag){ $('.ui-dialog').easydrag(); } */ break; case 'jqalert': return jAlert(str,title); break; default: return alert(str); break; } } function initIcheck(){ var sel = arguments[0] ? arguments[0] : 'input.fchk'; $(sel).iCheck({ checkboxClass: 'icheckbox_square-aero' }); } var BrAudioContext = null; function beep(vol, freq, duration){ if(!BrAudioContext){BrAudioContext = new AudioContext();} vol = vol ? vol : 2000; freq = freq ? freq : 800; duration = duration ? duration : 60; v=BrAudioContext.createOscillator() u=BrAudioContext.createGain() v.connect(u) v.frequency.value=freq v.type="sine" u.connect(BrAudioContext.destination) u.gain.value=vol*0.01 v.start(BrAudioContext.currentTime) v.stop(BrAudioContext.currentTime+duration*0.001) } function burp(){ console.log('burp()'); beep(0,500,300); } function validateDob(dob){ // Implementation of age limit if(!MOCA_AGE_LIMIT || MOCA_AGE_LIMIT==0){return true;} dob = dob.mocaReverseDate(); var now = new Date(); var born = new Date(Date.parse(dob)); var birthday = new Date(now.getFullYear(), born.getMonth(), born.getDate()); var age = now >= birthday ? now.getFullYear() - born.getFullYear() : now.getFullYear() - born.getFullYear() - 1; return age >= MOCA_AGE_LIMIT; } function is_numeric(el){ return (typeof(el) === 'number' || typeof(el) === 'string') && el !== '' && !isNaN(el); } function to_decimal(n){ n = new Number(n); return n.toFixed(2); } function bidf(id){ // Apply prefix and pad booking id if(!is_numeric(id)){return id;} if(id < 10000){ id = String(id); id = id.mocaPad(5); } return 'BRN' + id; } String.prototype.mocaEnglishify = function(){ var last = this[this.length-1]; if ((this[this.length-2]=='1' && last=='1') || (this[this.length-2]=='1' && last=='2')){ return this+'th'; } switch (last) { case '1': return this + 'st'; case '2': return this + 'nd'; case '3': return this+'rd'; default: return this+'th'; } }; String.prototype.mocaStartsWithVowel = function(){ var v=['a','e','i','o','u','A','E','I','O','U']; for(i=0; i