/* UPDRAFTELM */
//2025 dates
currDate = new Date("2024/12/23"); // Monday - Last week of the current year
startTime = new Date("2024/12/27 08:00"); // Monday - With week in the next year (Check the start/end dates in the UPTMTBL query)
endTime = new Date("2025/01/11 19:00"); // Saturday - First full week of the year
workEnd = new Date("2025/01/11 18:00"); // Saturday - First full week of the year
extendEnd = new Date("2025/01/11 21:00"); // Saturday - First full week of the year
p_year='2025';
var selectunits = "";
if(getUrlVars()["selectunits"]) { //getUrlVars is in UPTMTBLSCR
selectunits=getUrlVars()["selectunits"]; }
$("#splittery div:first").hide();
//Set text for draft notice
$("#draftntce").html("2025 Timetable
\
Please note: Timetable changes may take up to an hour to display after update. This is a draft timetable and is subject to change.");
//Service unavailable message to display on main page if there's a technical issue
var tmtbldwn = "
The draft timetable is currently unavailable due to technical issues. We are currently working on the problem and expect the site to be working again soon. We apologise for any inconvenience caused.
";
//Uncomment the line below to display the unavailable message
//$("#ttsearch").find("div.panel-body").before(tmtbldwn);
//Draft unavailable message if sysdate not in date range in TMTBL_DRFT notice (SSFF5000)
var draftunavail = "
The draft timetable is currently unavailable while changes are being made. Please check the staff timetable site for availability.
";
var draftAvailable='Y'
var draftAvailDatasource = new kendo.data.DataSource({
transport: {
read: {
url: "https://applicant.sims.uwa.edu.au/connect/webconnect?pagecd=UPTMTBL&dataname=|p_mode|p_draft_ind&datavalue=|DRAFT|Y",
dataType: "jsonp"
}
}
});
draftAvailDatasource.fetch(function(){
var data = draftAvailDatasource.data();
draftAvailable = data[0].draft_avail;
if (draftAvailable == 'N'){
$("#draftntce").after(draftunavail);
$("#ttwhole").hide();
$('#unitsrch').attr("disabled", true);
}
});
var refreshdt = 'N';
var noacthtml = '
No activities have been scheduled for your unit selection.
");
}
if(venArr[0]) {
$("#venueLst").empty();
for(i=0;i"+venArr[i]+"");
}
}
//Redraw activity controls if new search has been performed
if(refreshControls=='Y' && grid.dataSource.view().length > 0) {
$("#actvts").empty();
activityTypes.fetch(function() {
var data = this.data();
$("#actvts").append("
Select All
");
$("#actvts").append("
Clear All
");
for(i=0;i -1) {
var bgcol = kendo.parseColor(data[i].key);
if(bgcol.diff(kendo.parseColor("#000000")) > 120) {
var textcol = "#000000"; }
else { var textcol = "#ffffff"; }
$("#actvts").append("
"+data[i].activityDesc+"
");
}
}
});
$("#classtype-list :checkbox").change(function(e) {
filtAct();
});
$("#selectacts").click(function() {
$("#actvts").find(":checkbox").prop('checked', true);
filtAct();
});
$("#clearacts").click(function() {
$("#actvts").find(":checkbox").prop('checked', false);
filtAct();
});
}
},
sortable: true,
dataSource: actLst,
groupable: true
});
kendo.culture().calendar.firstDay = 1; //Set week start day to Monday
//Custom week view
var SchedulerWeekView = kendo.ui.WeekView.extend({
dateForTitle: function() {
return "Week " + kendo.recurrence.weekInYear(this.startDate(), this.calendarInfo().firstDay);
}
});
//Custom work week view
var SchedulerwWeekView = kendo.ui.WorkWeekView.extend({
dateForTitle: function() {
return kendo.toString(this.startDate(), 'dd/MM/yyyy') + " - " + kendo.toString(this.endDate(), 'dd/MM/yyyy') + " (Week " + kendo.recurrence.weekInYear(this.startDate(), this.calendarInfo().firstDay)+")";
}
});
var window_width = $(window).width()
//Initiate activity calendar view
$("#scheduler").kendoScheduler({
date: currDate, // The current date of the scheduler
startTime: startTime, //can also be defined at the view level
endTime: endTime, //can also be defined at the view level
workDayEnd: workEnd, //teaching hours end at 6pm
//timezone: "Australia/Perth", //this seems to make it hang for some reason?
dateHeaderTemplate: kendo.template("#if(window_width > 800){#\
#=kendo.toString(date, 'dddd')#\
#}else{#\
#=kendo.toString(date, 'ddd')#\
#}#"),
allDaySlot: false,
currentTimeMarker: false,
editable: false,
//eventTemplate: $("#event-template").html(),
eventTemplate: eventTemplate,
views: [
{ type: "SchedulerwWeekView", title: "Week", selected:true // workWeek selected by default
},
"day",
{ type: "SchedulerWeekView", title: "Extended", endTime: extendEnd },
], //views available
messages: {
views: {
workWeek: "Week"
}
},
resources: [
{
field: "classType",
dataValueField: "activityDesc",
dataTextField: "activityDesc",
title: "Class Type",
dataColorField: "key",
dataSource: activityTypes
}
],
dataSource: actGrid,
dataBinding: function(e) {
if(refreshWkBx=='Y') {
wklstArr = ["All weeks"];
$("#eastererr").hide(); }
/* var wkbox = $("#weeklst").data("kendoComboBox");
if(wkbox) {
wkbox.destroy(); } */
},
dataBound : function (e) {
$('.k-event').each(function () {
$(this).popover({
content : $(this).find(".popup-content").html(),
title : $(this).find(".popup-title").html(),
delay : {
show : 500,
hide : 200
},
trigger : "hover click",
html : true,
placement : "auto",
container : "body"
})
//on show, remove other popover
$(this).on('show.bs.popover', function (e) {
$(".popover").remove();
})
$(this).on('shown.bs.popover', function (e) {
$(".popover-title a").click(function(){
$(".popover").remove();
})
})
//prevent hiding popover, wait until mouse out
$(this).on('hide.bs.popover', function (e) {
//e.preventDefault(); //this is preventing the popup from displaying multiple times?
$(".popover").mouseleave(function(){
$(this).fadeOut("fast",function(){
$(this).remove()
})
})
})
//if user left click anywhere, remove the popover box
$(document).click(function(e) {
if (e.button == 0) {
$(".popover").remove();
}
})
});
//Add Easter option to Week List array if activities exist during Easter break
if(easter=='Y' && wklstArr.indexOf('Easter') < 0) {
wklstArr.splice(1,0,'Easter');
$("#eastererr").show(); }
$("#weeklst").kendoComboBox({
dataSource: wklstArr,
placeholder: "Jump to week...",
animation: {
close: {
//effects: "zoom:out",
duration: 300
}
},
template: '#= kendo.toString(get_draft_week_ranges(data,"option"))#',
change: function(e) {
refreshWkBx='N';
if(this.value().length > 2) {
var value=0;
$("#weekval").html(this.value()); }
else {
var value = (this.value())*7;
$("#weekval").html("Week "+this.value()); }
var date = currDate;
$("#buttprev").data("kendoButton").enable(true);
$("#buttnext").data("kendoButton").enable(true);
if(this.select()==0) {
$("#buttprev").data("kendoButton").enable(false);
}
if(this.select()==this.items().length-1){
$("#buttnext").data("kendoButton").enable(false);
}
$("#weekDesc").html(get_draft_week_ranges(this.value(),"label"));
filtAct();
},
index: 0
});
if(navigateInit=='Y') {
easterShading($("#weeklst").data("kendoComboBox").value());
navigateInit='N'; }
},
toolbar: ["pdf"],
pdf: {
fileName: "Timetable_calendar_export.pdf",
landscape: true
},
navigate: function (e) {
if(e.action == "changeView") {
if(e.view=="day"){
var day = kendo.toString(e.date, 'dddd');
$("a.switch-date[href=#"+day+"]").addClass("active") }
navigateInit='Y';
}
//console.log(kendo.recurrence.weekInYear(e.date, new Date("2016/01/5")));
},
footer: {
command: false
}
});
var thisWeek;
function chngWk(change) {
var wkbox = $("#weeklst").data("kendoComboBox");
var oldSel = wkbox.select();
if(wkbox.select()==0 && $("#weekDesc").html()!="") {
var wklstNew = wklstArr.slice();
wklstNew.push(thisWeek);
wklstNew.sort(function(a,b){return a-b});
oldSel=wklstNew.indexOf(thisWeek);
if(change>0) {
change=0; }
}
var newSel = oldSel+change;
if(newSel < 0) {
newSel=0; }
wkbox.select(newSel);
wkbox.trigger("change");
}
$("#buttprev").kendoButton({
icon: "arrow-w",
enable: false,
click: function(e) {
chngWk(-1);
}
});
$("#buttnext").kendoButton({
icon: "arrow-e",
click: function(e) {
chngWk(1);
}
});
$("#buttfirst").kendoButton({
click: function(e) {
chngWk(-100);
}
});
$("#buttcurrent").kendoButton({
click: function(e) {
thisWeek = getCurrWk();
var wkbox = $("#weeklst").data("kendoComboBox");
if(wklstArr.indexOf(thisWeek) > -1) {
wkbox.select(wklstArr.indexOf(thisWeek));
}
else {
wklstNew = thisWeek;
wkbox.value(thisWeek);
}
wkbox.trigger("change");
}
});
var scheduler = $("#scheduler").data("kendoScheduler");
/* Hides header and footer
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.wrapper.children("div").hide(); */
$("#splitter").kendoSplitter({
orientation: "vertical",
panes: [
{ collapsible: true },
{ size: "500px" },
{}
]
});
$("#checkall").click(function(e) {
$("#unitLst input:checkbox:visible").click();
$("#checkall").hide();
});
$("#showtt").click(function(e) {
refreshControls = 'Y';
var wkbox = $("#weeklst").data("kendoComboBox");
if(wkbox) {
wkbox.select(0);
wkbox.trigger("change"); }
$("#selsrch").hide();
$("#ttsearch").hide();
$("#noacterr").hide();
$("#splittery").show();
$("#seldisp").show();
$("#venlst").show();
$("#selUnit").kendoListView({
dataSource: selLst,
template: kendo.template($("#useltemp").html())
});
if(selectunits=="") {
var uoos = $.map($("#unitSel :checked"), function(checkbox) {
return $(checkbox).attr("name");
}); }
refreshWkBx='Y';
var scheduler = $("#scheduler").data("kendoScheduler");
var grid = $("#ttlist").data("kendoGrid");
if(selectunits=="") {
actLst.read({ dataname: "|p_mode|p_ret|p_uoos", datavalue: "|DRAFT|DTL|"+uoos });
actGrid.read({ dataname: "|p_mode|p_ret|p_uoos", datavalue: "|DRAFT|GRD|"+uoos });
}
scheduler.dataSource.filter({});
grid.dataSource.filter({field: "venue", operator: "neq", value : "venue"});
actLst.fetch();
//grid.refresh();
$("#ttdisp").show();
refreshdt='Y';
//scheduler.refresh();
//$("#navhere").append($(".k-scheduler-navigation"));
});
//Hide timetable view elements when Unit Search button clicked
$("#untsrch").click(function(e) {
$("#seldisp").hide();
$("#ttdisp").hide();
$("#venlst").hide();
$("#selsrch").show();
$("#ttsearch").show();
});
//This isn't used, but keeping it here in case it's needed
$("#activity").kendoMultiSelect({
dataTextField: "activityDesc",
dataValueField: "actCode",
dataSource: activityTypes,
itemTemplate: '#: activityDesc #',
tagTemplate: '#: activityDesc #',
value: activities
});
$("#select").click(function() {
var actlst = $("#activity").data("kendoMultiSelect");
actlst.value(activities);
});
//Initiate teaching period list
$("#teachPerdLst").kendoListView({
dataSource: teachingPeriods,
template: "
#:tpDesc#
",
selectable: "multiple"
});
/*
Remove the Summer from the Teaching Period list
*/
var listTeachingPeriods = $("#teachPerdLst").data("kendoListView");
listTeachingPeriods.dataSource.fetch(function() {
var view = listTeachingPeriods.dataSource.view();
var size = listTeachingPeriods.dataSource.view().length;
for ( i=0; i#:campusDesc#",
selectable: "multiple"
});
//Initiate faculty list
$("#facLst").kendoListView({
dataSource: unitOwners,
template: "
#:facDesc#
",
selectable: "multiple"
});
//Called from the Search button
$("#unitsrch").click(function() {
$("#checkall").hide();
var searchval = $("#unit-search").val();
var facs = $("#facLst").data("kendoListView");
var facslst = facs.select();
var sems = $("#teachPerdLst").data("kendoListView");
var semlst = sems.select();
var cmps = $("#campusLst").data("kendoListView");
var cmpslst = cmps.select();
var checked = $.map($("#unitSel :checked"), function(checkbox) {
return $(checkbox).val();
});
unitList.filter( {
logic: "and",
filters: [
{field: "unitDesc", operator: "neq", value: "description" },
{field: "unitDesc", operator: "contains", value: searchval },
{
field: "unitFac",
operator: function(item, value) {
var arrchck = false;
if(facslst.length==0) { arrchck = true; }
else {
for(i=0;iYour search returned no units");
}
else {
if(ulst.length > 5) {
$("#checkall").show(); }
}
});
//clears all units from the selected units list (both selected and search results), called from the Clear button
$("#clearunits").click(function() {
var unitlst = $("#unitLst").data("kendoListView");
//unitlst.clearSelection();
unitList.filter( { field: "unitDesc", operator: "eq", value: "blah" });
unitlst.refresh();
$("#unitLst").hide();
selLst.data([]);
selst.refresh();
$("#showtt").prop('disabled',true);
});
var selLst = new kendo.data.DataSource();
$("#unitSel").kendoListView({
dataSource: selLst,
dataBound: function(e) {
if(this.dataSource.data().length == 0){
//custom logic
$("#unitSel").append("