//REQUIRED AREA STARTS HERE FOR CALENDAR LIBRARY var CalendarSecurityView = true; //PUBLIC SITE IF NO LOGIN IS REQUIRED var CalendarSecurityEdit = false; var CalendarSecurityAdmin = false; /* NOTE THE FOLLOWING FUNCTIONS MUST BE SETUP IN CALENDERS USING THIS LIBRARY function dayClickProcess(info) { } function eventClickProcess(event, jsEvent, view) { } function eventDropProcess(event, delta) { } function setCalendarData(){}; NOTE: ONLY INCLUDE DATA IN A DATE RANGE BETWEEN 2 WEEKS BEFORE MONTH AND 2 WEEKS AFTER MONTH. CLICKING THE NEXT MONTH BUTTONS REFRESHES TO THE SELECTED MONTH. { id: UNIQUE ID TIED TO DATA start: '10/02/2023', //Start date for event end: '10/02/2023', //End date for event (event actually goes through previous day) title: 'Calendar For Customer', //Text that shows up on event on calendar color: '#ff00ff', //Background color for event on calendar borderColor: '#000000', //Border color for event on calendar textColor: '#ffffff' //Text color for event on calendar }, //Comma separated records There are 3 sections in the HTML module that can be changed from the specific screen js file. CalendarTitle - The title for the calendar CalendarSelections - Drop Downs for changing calendar data CalendarButtons - Buttons for changing calendar data or popping up additional screens. initialView: dayGridMonth, multiMonthYear, dayGridYear, dayGridFourWeek, resourceTimeline views: additional properties for initialView eventColor: default color for events editable: true/false (drag/drop stuff) headerToolbar: format and call backs for tool bar FUNCTIONS: dateClick, eventDrop, eventClick, nextMonth, prevMonth, setToday eventInfo object passed to functions: - eventInfo.event.[EVENT FIELD] - eventInfo.el HTML ELEMENT FOR THIS EVENT INFORMATION - eventInfo.jsEvent NATIVE JAVASCRIPT EVENT INFORMATION - eventInfo.view[CALENDAR INFO FIELD] - eventInfo.delta.[DROP EVENTS: years, months, days, milliseconds] dateInfo object passed to functions: - dateInfo.dateStr SELECTED DATE IN FORMAT YYYY-MM-DD - dateInfo.el HTML ELEMENT FOR THIS EVENT INFORMATION - dateInfo.jsEvent NATIVE JAVASCRIPT EVENT INFORMATION - dateInfo.view[CALENDAR INFO FIELD] */ //NOTE THAT THESE NEED TO BE SET BY MODULE CALLING THIS //LIBRARY BEFORE INCLUDING LIBRARY. //var CalendarSecurityView = false; //var CalendarSecurityEdit = false; //var CalendarSecurityAdmin = false; //NOTE THAT ANY DATA WILL BE DOMAIN SPECIFIC AND WILL REQUIRE //THE SELECTED DOMAIN FOR FILTERING var calendarEdit = false; var calendar = null; function loadCalendar(iDate) { var calendarEl = document.getElementById('calendar'); calendar = new FullCalendar.Calendar(calendarEl, { initialView: 'dayGridMonth', initialDate: iDate, schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives', eventColor: '#000000', editable: true, headerToolbar: { left: 'PrevMonth NextMonth SetToday', center: 'title', right: 'dayGridMonth dayGridWeek' }, dateClick: function(dateInfo) { dayClickProcess(dateInfo); }, eventDrop: function(eventInfo) { eventDropProcess(eventInfo.event, eventInfo.delta); }, eventClick: function(eventInfo) { eventClickProcess(eventInfo.event, eventInfo.jsEvent, eventInfo.view); }, customButtons: { NextMonth: { icon: 'chevron-right', click: function() { var curDate = unWrapDate(rollDate(calendar.getDate(), "yyyyMMdd", "MONTH", 1, null)); calendar.destroy(); loadCalendar(new Date(curDate)); setCalendarData(curDate); } }, PrevMonth: { icon: 'chevron-left', click: function() { var curDate = unWrapDate(rollDate(calendar.getDate(), "yyyyMMdd", "MONTH", -1, null)); calendar.destroy(); loadCalendar(new Date(curDate)); setCalendarData(curDate); } }, SetToday: { text: 'Today', click: function() { var curDate = unWrapDate(formatDateObject("yyyyMMdd", new Date())); calendar.destroy(); loadCalendar(new Date()); setCalendarData(curDate); } } } }); calendar.render(); } loadCalendar(new Date()); $(document).ready(function() { $('#ModalEmailText').summernote({ tabsize: 2, height: 175, toolbar: [ ['style', ['style']], ['font', ['bold', 'underline', 'clear', 'fontname', 'fontsize']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video']], ['view', ['fullscreen', 'codeview', 'help']] ] }); }); /* Screens that include email must include this JS file and prepare an array as follows: Element 0: - list = "on/off" If ON then listname is used. - listname = "The Name of the List if emailing more than one recipent" - role = "Role required to send this email" - from = "Name of Email Sender like NVblu Service" - replyto = "Reply To Email Address" - direct = "on/off" If bypassing pop up screen -- subject/text required for this to work - codes = array of codes that match fields in recipent objects. codes can be selected in email pop up screen to insert matching data from recipient - bcc = BCC Email - subject = Email Subject - text = Email Text - attachment = Description of attachment file for list Element 1: First recipient (always required whether list is on or not) Element 2-n: Rest of recipents for a list....only used if list is on - email: Email for this recipent (required) - name: Name for this recipent (required) - attachment: URI with recipient parms for file being attached - CODES: Object of codes matching codes in Element 0 {CODE_NAME:"VALUE",CODE_NAME:"VALUE"} */ var modal_emails = []; function prepareEmail(emails) { //SET MASTER FOR SENDING modal_emails = emails; if ( emails[0].direct && emails[0].direct.toUpperCase() == "ON" ) { if ( (!emails[0].subject || emails[0].subject == "") || (!emails[0].text || emails[0].text == "") ) { alertMsg("You must provide a subject and email text for a direct email request."); } else { modalEmailSendEmail(); } return; } $("#ModalEmailCodes").html(""); var email_codes = ""; for ( var i=0; i < emails[0].codes.length; i++ ) { email_codes = email_codes + "[[" + emails[0].codes[i] + "]]

"; } $("#ModalEmailCodes").html(email_codes); if ( email_codes != "" ) $("#ModalEmailCodesBlock").show(); else $("#ModalEmailCodesBlock").hide(); $("#ModalEmails").empty(); if ( emails[0].list && emails[0].list.toUpperCase() == "ON" ) { $("#ModalEmailLabel").html("" + emails[0].listname + ":"); $("#ModalEmail").hide(); $("#ModalEmails").show(); for ( var i=1; i < emails.length; i++ ) { $("#ModalEmails").append(''); } } else { $("#ModalEmailLabel").html("Email " + emails[1].name + ":"); $("#ModalEmail").show(); $("#ModalEmails").hide(); $("#ModalEmail").val(emails[1].email); } if ( emails[0].attachment ) { $("#ModalEmailAttachment").html("Attachment: " + emails[0].attachment ); $("#ModalEmailAttachment").show(); } else { $("#ModalEmailAttachment").html(""); $("#ModalEmailAttachment").hide(); } if ( emails[0].bcc ) $("#ModalBCCEmail").val(emails[0].bcc); else $("#ModalBCCEmail").val(""); if ( emails[0].subject ) $("#ModalEmailSubject").val(emails[0].subject); else $("#ModalEmailSubject").val(""); if ( emails[0].text ) $('#ModalEmailText').summernote('code', emails[0].text); else $('#ModalEmailText').summernote('code', ''); //PRE PREPARED EMAILS CAN SKIP THE MODAL POPUP $("#ModalEmailModule").modal(); } function modalEmailSendEmailPrepare() { if ( $("#ModalEmailSubject").val() == "" || $('#ModalEmailText').summernote('code') == "" ) { alertMsg("EMAIL FAILED! Emails require a Subject and Text!"); return; } if ( emails[0].list && emails[0].list.toUpperCase() == "ON" ) { modal_emails[0].email = ""; } else { if ( $("#ModalEmail").val() == "" ) { alertMsg("EMAIL FAILED! You need to enter an email address!"); return; } emails[1].email = $("#ModalEmail").val(); } modal_emails[0].bcc = $("#ModalBCCEmail").val(); modal_emails[0].subject = $("#ModalEmailSubject").val(); modal_emails[0].text = $('#ModalEmailText').summernote('code'); modalEmailSendEmail(); } function modalEmailSendEmail() { var email_codes = ""; for ( var i=0; i < modal_emails[0].codes.length; i++ ) { if ( i > 0 ) email_codes = email_codes + "|"; email_codes = email_codes + modal_emails[0].codes[i]; } var emails = ""; for ( var i=1; i < modal_emails.length; i++ ) { if ( i > 1 ) emails = emails + "|"; var user_codes = ""; if ( modal_emails[i].codes ) { for ( var ii=0; ii < modal_emails[0].codes.length; ii++ ) { if ( ii > 0 ) user_codes = user_codes + ":"; if ( modal_emails[i].codes[modal_emails[0].codes[ii]] ) { user_codes = user_codes + modal_emails[0].codes[ii] + "=" + modal_emails[i].codes[modal_emails[0].codes[ii]]; } else { user_codes = user_codes + modal_emails[0].codes[ii] + "="; } } } if ( !modal_emails[i].attachment ) modal_emails[i].attachment = ""; emails = emails + modal_emails[i].email + ";" + modal_emails[i].name + ";" + modal_emails[i].attachment + ";" + user_codes; } if ( !modal_emails[0].role ) modal_emails[0].role = "ROOT"; if ( !modal_emails[0].replyto ) modal_emails[0].replyto = "eric@nvblu.com"; if ( !modal_emails[0].from ) modal_emails[0].from = "NVblu Service"; var data = {}; data['sf'] = 'sendemail'; data['Subject'] = modal_emails[0].subject; data['EmailText'] = modal_emails[0].text; data['BCC'] = modal_emails[0].bcc; data['Role'] = modal_emails[0].role; data['ReplyTo'] = modal_emails[0].replyto; data['From'] = modal_emails[0].from; data['Attachment'] = modal_emails[0].attachment; data['CODES'] = email_codes; data['EMAILS'] = emails; $.ajax({ url: '/data/calendar/', type: 'post', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) { alertMsg(data.message); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } function modalEmailSelectEmail() { if ( $("#ModalEmailID").val() == "" ) { $("#ModalEmailSubject").val(""); $('#ModalEmailText').summernote('code', ""); return; } var data = {}; data['sf'] = 'emailtemplate'; data['EmailTemplateID'] = $("#ModalEmailID").val(); $.ajax({ url: '/data/configuration/', type: 'get', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) alertMsg(data.message); else { $("#ModalEmailSubject").val(data.emailtemplate.Subject); $('#ModalEmailText').summernote('code', data.emailtemplate.EmailText); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } $(document).ready(function() { $('#ModalEmailText').summernote({ tabsize: 2, height: 175, toolbar: [ ['style', ['style']], ['font', ['bold', 'underline', 'clear', 'fontname', 'fontsize']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video']], ['view', ['fullscreen', 'codeview', 'help']] ] }); }); /* Screens that include email must include this JS file and prepare an array as follows: Element 0: - list = "on/off" If ON then listname is used. - listname = "The Name of the List if emailing more than one recipent" - role = "Role required to send this email" - from = "Name of Email Sender like NVblu Service" - replyto = "Reply To Email Address" - direct = "on/off" If bypassing pop up screen -- subject/text required for this to work - codes = array of codes that match fields in recipent objects. codes can be selected in email pop up screen to insert matching data from recipient - bcc = BCC Email - subject = Email Subject - text = Email Text - attachment = Description of attachment file for list Element 1: First recipient (always required whether list is on or not) Element 2-n: Rest of recipents for a list....only used if list is on - email: Email for this recipent (required) - name: Name for this recipent (required) - attachment: URI with recipient parms for file being attached - CODES: Object of codes matching codes in Element 0 {CODE_NAME:"VALUE",CODE_NAME:"VALUE"} */ var modal_emails = []; function prepareEmail(emails) { //SET MASTER FOR SENDING modal_emails = emails; if ( emails[0].direct && emails[0].direct.toUpperCase() == "ON" ) { if ( (!emails[0].subject || emails[0].subject == "") || (!emails[0].text || emails[0].text == "") ) { alertMsg("You must provide a subject and email text for a direct email request."); } else { modalEmailSendEmail(); } return; } $("#ModalEmailCodes").html(""); var email_codes = ""; for ( var i=0; i < emails[0].codes.length; i++ ) { email_codes = email_codes + "[[" + emails[0].codes[i] + "]]

"; } $("#ModalEmailCodes").html(email_codes); if ( email_codes != "" ) $("#ModalEmailCodesBlock").show(); else $("#ModalEmailCodesBlock").hide(); $("#ModalEmails").empty(); if ( emails[0].list && emails[0].list.toUpperCase() == "ON" ) { $("#ModalEmailLabel").html("" + emails[0].listname + ":"); $("#ModalEmail").hide(); $("#ModalEmails").show(); for ( var i=1; i < emails.length; i++ ) { $("#ModalEmails").append(''); } } else { $("#ModalEmailLabel").html("Email " + emails[1].name + ":"); $("#ModalEmail").show(); $("#ModalEmails").hide(); $("#ModalEmail").val(emails[1].email); } if ( emails[0].attachment ) { $("#ModalEmailAttachment").html("Attachment: " + emails[0].attachment ); $("#ModalEmailAttachment").show(); } else { $("#ModalEmailAttachment").html(""); $("#ModalEmailAttachment").hide(); } if ( emails[0].bcc ) $("#ModalBCCEmail").val(emails[0].bcc); else $("#ModalBCCEmail").val(""); if ( emails[0].subject ) $("#ModalEmailSubject").val(emails[0].subject); else $("#ModalEmailSubject").val(""); if ( emails[0].text ) $('#ModalEmailText').summernote('code', emails[0].text); else $('#ModalEmailText').summernote('code', ''); //PRE PREPARED EMAILS CAN SKIP THE MODAL POPUP $("#ModalEmailModule").modal(); } function modalEmailSendEmailPrepare() { if ( $("#ModalEmailSubject").val() == "" || $('#ModalEmailText').summernote('code') == "" ) { alertMsg("EMAIL FAILED! Emails require a Subject and Text!"); return; } if ( emails[0].list && emails[0].list.toUpperCase() == "ON" ) { modal_emails[0].email = ""; } else { if ( $("#ModalEmail").val() == "" ) { alertMsg("EMAIL FAILED! You need to enter an email address!"); return; } emails[1].email = $("#ModalEmail").val(); } modal_emails[0].bcc = $("#ModalBCCEmail").val(); modal_emails[0].subject = $("#ModalEmailSubject").val(); modal_emails[0].text = $('#ModalEmailText').summernote('code'); modalEmailSendEmail(); } function modalEmailSendEmail() { var email_codes = ""; for ( var i=0; i < modal_emails[0].codes.length; i++ ) { if ( i > 0 ) email_codes = email_codes + "|"; email_codes = email_codes + modal_emails[0].codes[i]; } var emails = ""; for ( var i=1; i < modal_emails.length; i++ ) { if ( i > 1 ) emails = emails + "|"; var user_codes = ""; if ( modal_emails[i].codes ) { for ( var ii=0; ii < modal_emails[0].codes.length; ii++ ) { if ( ii > 0 ) user_codes = user_codes + ":"; if ( modal_emails[i].codes[modal_emails[0].codes[ii]] ) { user_codes = user_codes + modal_emails[0].codes[ii] + "=" + modal_emails[i].codes[modal_emails[0].codes[ii]]; } else { user_codes = user_codes + modal_emails[0].codes[ii] + "="; } } } if ( !modal_emails[i].attachment ) modal_emails[i].attachment = ""; emails = emails + modal_emails[i].email + ";" + modal_emails[i].name + ";" + modal_emails[i].attachment + ";" + user_codes; } if ( !modal_emails[0].role ) modal_emails[0].role = "ROOT"; if ( !modal_emails[0].replyto ) modal_emails[0].replyto = "eric@nvblu.com"; if ( !modal_emails[0].from ) modal_emails[0].from = "NVblu Service"; var data = {}; data['sf'] = 'sendemail'; data['Subject'] = modal_emails[0].subject; data['EmailText'] = modal_emails[0].text; data['BCC'] = modal_emails[0].bcc; data['Role'] = modal_emails[0].role; data['ReplyTo'] = modal_emails[0].replyto; data['From'] = modal_emails[0].from; data['Attachment'] = modal_emails[0].attachment; data['CODES'] = email_codes; data['EMAILS'] = emails; $.ajax({ url: '/data/calendar/', type: 'post', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) { alertMsg(data.message); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } function modalEmailSelectEmail() { if ( $("#ModalEmailID").val() == "" ) { $("#ModalEmailSubject").val(""); $('#ModalEmailText').summernote('code', ""); return; } var data = {}; data['sf'] = 'emailtemplate'; data['EmailTemplateID'] = $("#ModalEmailID").val(); $.ajax({ url: '/data/configuration/', type: 'get', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) alertMsg(data.message); else { $("#ModalEmailSubject").val(data.emailtemplate.Subject); $('#ModalEmailText').summernote('code', data.emailtemplate.EmailText); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } //INITIALIZE DATE FIELDS $( "#CalDate" ).datetimepicker({ language: 'en', format: 'mm/dd/yyyy', minView: 2, maxView: 4, autoclose: true }); $( "#RepeatUntil" ).datetimepicker({ language: 'en', format: 'mm/dd/yyyy', minView: 2, maxView: 4, autoclose: true }); $("#CalendarTitle").html("

League Calendar

"); $("#CalendarSelections").html(""); $("#CalendarButtons").html(""); var selectedDate = ""; setCalendarData(formatDateObject("M/D/Y",new Date())); //REQUIRED LIBRARY FUNCTIONS function dayClickProcess(info) { if ( CalendarSecurityEdit || CalendarSecurityAdmin ) { var d = info.dateStr.substring(5,7) + "/" + info.dateStr.substring(8,10) + "/" + info.dateStr.substring(0,4) ; editEvent(null,d); } } function viewEvent(event,cDate) { var calInfo = ""; calInfo = calInfo + unWrapDate(cDate); if ( event.AllDay == 1 ) calInfo = calInfo + " All Day"; else { if ( event.CalTime != "" ) calInfo = calInfo + " at " + setTime(event.CalTime); } if ( event.Duration != "" ) { var hours = 0; var minutes = 0; var d = parseInt(event.Duration); if ( d > 0 ) { while ( d >= 60 ) { hours = hours + 1; d = d - 60; } minutes = d; } calInfo = calInfo + " for " + hours + " hours"; if ( minutes > 0 ) calInfo = calInfo + " and " + minutes + " minutes"; if ( event.Description != "" ) { calInfo = calInfo + "

"; calInfo = calInfo + event.Description; calInfo = calInfo + "
"; } } $("#ViewCalendarEventTitle").html(event.Title); $("#ViewCalendarInfo").html(calInfo); $("#ModalViewCalendar").modal(); } function editEvent(event,d) { if ( d.indexOf("/") > 0 ) selectedDate = d; else selectedDate = unWrapDate(d); $("#CalTimeSection").show(); $("#RepeatSection").hide(); $("#RepeatEverySection").hide(); $("#WeeklyRepeatOnSection").hide(); $("#MonthlyRepeatOnSection").hide(); $("#RepeatUntilSection").hide(); $("#NeverEndsSection").hide(); $("#RepeatUntilSection").hide(); $("#RemoveButton").hide(); if ( event != null ) { $("#RemoveButton").show(); $("#CalendarID").val(event.CalendarID); $("#Title").val(event.Title); $("#Description").val(event.Description); $("#AllDay").prop("checked",(event.AllDay == 1)); $("#Repeats").val(event.Repeats); $("#NeverEnds").prop("checked",(event.NeverEnds == 1)); $("#RepeatEvery").val(event.RepeatEvery); $("#WeeklyRepeatOn").val("1"); $("#MonthlyYearlyRepeatOn").val("M"); if ( event.Repeats == "2" ) { $("#WeeklyRepeatOn").val(event.RepeatOn); } else if ( event.Repeats == "3" || event.Repeats == "4" ) { $("#MonthlyYearlyRepeatOn").val(event.RepeatOn); } $("#CalDate").val(unWrapDate(event.CalDate)); $("#RepeatUntil").val(unWrapDate(event.RepeatUntil)); var ctHour = ""; var ctMin = ""; var ctXM = ""; if ( event.AllDay != 1 ) { ctHour = parseInt(event.CalTime.substring(0,2)); ctMin = event.CalTime.substring(2); ctXM = "AM"; if ( ctHour > 12 ) { ctHour = ctHour - 12; if ( ctHour < 10 ) ctHour = "0" + ctHour; else ctHour = "" + ctHour; ctXM = "PM"; } else if ( ctHour == 12 ) { ctXM = "PM"; } } $("#CalTimeHour").val(ctHour); $("#CalTimeMin").val(ctMin); $("#CalTimeXM").val(ctXM); setRepeatSection(); setTimeSection(); setRepeatUntilDate(); $("#Duration").val(event.Duration); $("#CalendarEventTitle").html("Edit Calendar Event"); } else { $("#CalendarID").val(0); $("#Title").val(""); $("#Description").val(""); $("#AllDay").prop("checked",false); $("#Repeats").val("0"); $("#NeverEnds").prop("checked",false); $("#RepeatEvery").val("1"); $("#WeeklyRepeatOn").val("1"); $("#MonthlyYearlyRepeatOn").val("M"); $("#CalDate").val(d); $("#RepeatUntil").val(d); $("#CalTimeHour").val("12"); $("#CalTimeMin").val("00"); $("#CalTimeXM").val("PM"); $("#Duration").val("60"); $("#CalendarEventTitle").html("Add Calendar Event"); } $("#ModalEditCalendar").modal(); } function eventClickProcess(event, jsEvent, view) { var cDate = getSelectedDate(event.start); cDate = prepareDate(cDate); var cYear = cDate.substring(0,4); if ( event.extendedProps["Type"] == "EVENT" ) { if ( !CalendarSecurityEdit && !CalendarSecurityAdmin ) { window.location.replace("/schedules?Date=" + cDate + "&Year=" + cYear); return; } else { return; } } var data = {}; data['sf'] = 'event'; data['CalendarID'] = event.id; $.ajax({ url: '/data/admincalendar/', type: 'get', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) { alertMsg(data.message); } else { if ( CalendarSecurityEdit || CalendarSecurityAdmin ) { editEvent(data.calendar,cDate); } else { viewEvent(data.calendar,cDate); } } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } function getSelectedDate(eStart) { var d = new Date(eStart); var cDate = ""; if ( (d.getMonth()+1) < 10 ) cDate = "0" + (d.getMonth()+1) + "/"; else cDate = "" + (d.getMonth()+1) + "/"; if ( d.getDate() < 10 ) cDate = cDate + "0" + d.getDate() + "/"; else cDate = cDate + "" + d.getDate() + "/"; cDate = cDate + d.getFullYear(); return cDate; } function eventDropProcess(event, delta) { var allowed = true; if ( CalendarSecurityEdit || CalendarSecurityAdmin ) { if ( event.extendedProps["Type"] == "EVENT" ) { alertMsg("Meet schedules cannot be changed in this calendar."); allowed = false; } } else { allowed = false; } selectedDate = getSelectedDate(event.start); if ( !allowed ) { var curDate = selectedDate; calendar.destroy(); loadCalendar(new Date(curDate)); setCalendarData(curDate); return; } var data = {}; data['sf'] = 'eventmove'; data['CalendarID'] = event.id; data['Days'] = delta.days; $.ajax({ url: '/data/admincalendar/', type: 'get', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) { alertMsg(data.message); } else { var curDate = selectedDate; calendar.destroy(); loadCalendar(new Date(curDate)); setCalendarData(curDate); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } function setCalendarData(curDate) { var data = {}; data['sf'] = 'events'; data['CurDate'] = prepareDate(curDate); $.ajax({ url: '/data/calendar/', type: 'get', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) { alertMsg(data.message); } else { setCalendar(data); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } function setCalendar(data) { for ( var i=0; i < data.events.length; i++ ) { var text_color = "#ffffff"; var bg_color = "#993366"; if ( data.events[i].Type == "EVENT" ) { text_color = "#ffffff"; bg_color = "#336699"; } calendar.addEvent( { id: data.events[i].CalendarID, title: data.events[i].Title, description: data.events[i].Description, start: data.events[i].Date, Type: data.events[i].Type, color: bg_color, textColor: text_color, borderColor: bg_color, rrule: { freq: 'weekly', interval: 5, byweekday: [ 'mo', 'fr' ], dtstart: '2023-10-01T10:30:00', // will also accept '20120201T103000' until: '2024-06-01' // will also accept '20120201' } }); } } //REQUIRED AREA ENDS HERE FOR CALENDAR LIBRARY function setTimeSection() { if ( $("#AllDay").prop("checked") ) { $("#CalTimeSection").hide(); } else { if ( $("#CalTimeHour").val() == null || $("#CalTimeHour").val() == "" ) $("#CalTimeHour").val("12") if ( $("#CalTimeMin").val() == null || $("#CalTimeMin").val() == "" ) $("#CalTimeMin").val("00"); if ( $("#CalTimeXM").val() == null || $("#CalTimeXM").val() == "" ) $("#CalTimeXM").val("PM"); if ( $("#Duration").val() == null || $("#Duration").val() == "" ) $("#Duration").val("60"); $("#CalTimeSection").show(); } } function setRepeatSection() { if ( $("#Repeats").val() == "1" || $("#Repeats").val() == "2" || $("#Repeats").val() == "3" || $("#Repeats").val() == "4") { $("#RepeatEverySection").show(); if ( $("#RepeatEvery").val() == null || $("#RepeatEvery").val() == "" ) $("#RepeatEvery").val("1"); } else { $("#RepeatEverySection").hide(); } if ( $("#Repeats").val() == "2") { $("#WeeklyRepeatOnSection").show(); } else { $("#WeeklyRepeatOnSection").hide(); } if ( $("#Repeats").val() == "3" || $("#Repeats").val() == "4" ) { $("#MonthlyRepeatOnSection").show(); } else { $("#MonthlyRepeatOnSection").hide(); } if ( $("#Repeats").val() == "0" ) { $("#NeverEndsSection").hide(); $("#RepeatUntilSection").hide(); } else { $("#RepeatUntilSection").show(); $("#NeverEndsSection").show(); } } function setRepeatUntilDate() { if ( $("#NeverEnds").prop("checked") ) { $("#RepeatUntilSection").hide(); } else { $("#RepeatUntilSection").show(); if ( $("#RepeatUntil").val() == "" ) $("#RepeatUntil").val($("#CalDate").val()); } } function removeCalendarEvent() { if ( CalendarSecurityEdit || CalendarSecurityAdmin ) { var data = {}; data['sf'] = 'calendardelete'; data['CalendarID'] = $("#CalendarID").val(); $.ajax({ url: '/data/admincalendar/', type: 'post', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) { alertMsg(data.message); } else { var curDate = selectedDate; calendar.destroy(); loadCalendar(new Date(curDate)); setCalendarData(curDate); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } else { alertMsg("You do not have access to this function!"); } } function saveCalendarEvent() { if ( CalendarSecurityEdit || CalendarSecurityAdmin ) { var data = {}; data['sf'] = 'calendarsave'; data['CalendarID'] = $("#CalendarID").val(); data['DomainID'] = 13; data['Title'] = $("#Title").val(); data['Description'] = $("#Description").val(); data['CalDate'] = prepareDate($("#CalDate").val()); data['AllDay'] = $("#AllDay").prop("checked"); data['CalTime'] = setEventTime(); data['Duration'] = $("#Duration").val(); data['Repeats'] = $("#Repeats").val(); if ( $("#Repeats").val() != "0" ) { data['NeverEnds'] = $("#NeverEnds").prop("checked"); if ( $("#NeverEnds").prop("checked") ) data['RepeatUntil'] = ''; else data['RepeatUntil'] = prepareDate($("#RepeatUntil").val()); data['RepeatEvery'] = $("#RepeatEvery").val(); data['RepeatOn'] = "1"; if ( $("#Repeats").val() == "2" ) data['RepeatOn'] = $("#WeeklyRepeatOn").val(); else if ($("#Repeats").val() == "3" || $("#Repeats").val() == "4" ) data['RepeatOn'] = $("#MonthlyYearlyRepeatOn").val(); data['DateList'] = ""; } else { data['NeverEnds'] = false data['RepeatUntil'] = ""; data['RepeatEvery'] = 0; data['RepeatOn'] = ""; data['DateList'] = ""; } $.ajax({ url: '/data/admincalendar/', type: 'post', data: data, dataType: 'json', success: function(data) { if ( data.message != "" ) { alertMsg(data.message); } else { var curDate = selectedDate; calendar.destroy(); loadCalendar(new Date(curDate)); setCalendarData(curDate); } }, error: function (jqXHR, textStatus, errorThrown) { alertMsg(jqXHR.responseText); } }); } else { alertMsg("You do not have access to this function!"); } } function setTime(calTime) { var hour = parseInt(calTime.substring(0,2)); var min = calTime.substring(2); var xm = "AM"; if ( hour > 12 ) { hour = hour - 12; xm = "PM"; } else if (hour == 12) { xm = "PM"; } return hour + ":" + min + " " + xm; } function setEventTime() { var hour = parseInt($("#CalTimeHour").val()); var min = parseInt($("#CalTimeMin").val()); var XM = $("#CalTimeXM").val(); if ( XM == "PM" ) { if ( hour < 12 ) hour = hour + 12; } var time24 = ""; if ( hour < 10 ) time24 = "0" + hour; else time24 = "" + hour; if ( min < 10 ) time24 = time24 + "0" + min; else time24 = time24 + "" + min; return time24; }