/* UPVENUEELM */
var draftInd='Y';
//2024 dates
currDate = new Date("2023/12/25"); // Monday - Last week of the current year
startTime = new Date("2024/01/1 08:00"); // Monday - With week in the next year (Check the start/end dates in the UPTMTBL query)
endTime = new Date("2024/01/6 19:00"); // Saturday - First full week of the year
workEnd = new Date("2024/01/6 18:00"); // Saturday - First full week of the year
extendEnd = new Date("2024/01/6 21:00"); // Saturday - First full week of the year
if(draftInd=='Y') {
//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"]) {
selectunits=getUrlVars()["selectunits"]; }
$("#ventt div:first").hide();
$("#ventt div:first").after("
");
var refreshdt = 'N';
var noacthtml = 'No activities have been scheduled for your unit selection.
';
$("#splittery").before(noacthtml);
noacthtml = ' Check All ';
$("#showtt").after(noacthtml);
var allwkArr = ["All weeks"];
for(i=1;i<53;i++) {
allwkArr.push(i);
}
var activities = [
{actCode:"Lect", activityDesc:"Lecture", key:"#0038A8"}, //blue
{actCode:"Tut", activityDesc:"Tutorial", key:"#E8112D"}, //red
{actCode:"Lab", activityDesc:"Laboratory", key:"#009EA0"}, //green
{actCode:"Prac", activityDesc:"Practical", key:"#AA72BF"}, //purple
{actCode:"PracClas", activityDesc:"Practical Class", key:"#632D00"}, //brown
{actCode:"Sem", activityDesc:"Seminar", key:"#F74902"}, //orange
{actCode:"Film", activityDesc:"Film", key:"#3A75C4"}, //blue
{actCode:"Wshp", activityDesc:"Workshop", key:"#F98972"}, //orange
{actCode:"Fwk", activityDesc:"Field Work", key:"#BA7CBC"}, //purple
{actCode:"Stu", activityDesc:"Studio", key:"#93DDDB"}, //green
{actCode:"Ltut", activityDesc:"Lecture_Tutorial", key:"#FC5E72"}, //red
{actCode:"Con", activityDesc:"Conversation", key:"#75AADB"}, //blue
{actCode:"SmGp", activityDesc:"Small Group", key:"#F9BAAA"}, //orange
{actCode:"LangClas", activityDesc:"Language Class", key:"#C687D1"}, //purple
{actCode:"Clinic", activityDesc:"Clinic", key:"#93DDDB"}, //green
{actCode:"LangSem", activityDesc:"Language Seminar", key:"#FC8C99"}, //red
{actCode:"Maint", activityDesc:"Maintenance", key:"#9BC4E2"}, //blue
{actCode:"Ensemble", activityDesc:"Ensemble", key:"#D3A5C9"}, //purple
{actCode:"Exam", activityDesc:"Examination", key:"#C9E8DD"}, //green
{actCode:"Oth", activityDesc:"Other", key:"#F9BFC1"}, //red
{actCode:"Ass", activityDesc:"Assessment", key:"#3A75C4"}, //blue
{actCode:"Tch", activityDesc:"Teaching", key:"#F9BAAA"}, //orange
{actCode:"Tst", activityDesc:"Test", key:"#9BC4E2"}, //blue
{actCode:"InfoSess", activityDesc:"Information Session", key:"#FFCCCC"}, //red
{actCode:"PLab", activityDesc:"PostLab", key:"#CCFFCC"} //green
];
var activityTypes = new kendo.data.DataSource({ data: activities });
var actLst = new kendo.data.DataSource({
transport: {
read: {
url: "https://applicant.sims.uwa.edu.au/connect/webconnect?pagecd=UPTMTBL",
dataType: "jsonp"
}
},
filter : { field: "venue", operator: "neq", value : "venue" },
sort: [
{ field: "startTime", dir: "asc" },
{ field: "day", dir: "asc" },
{ field: "wks", dir: "desc" }
]
});
var actGrid = new kendo.data.SchedulerDataSource({
transport: {
read: {
url: "https://applicant.sims.uwa.edu.au/connect/webconnect?pagecd=UPTMTBL",
dataType: "jsonp"
}
},
schema: {
model: {
//id: 1,
fields: {
title: { from: "actUoo" },
start: { type: "date", from: "startTime" },
end: { type: "date", from: "endTime" },
venue: { from: "venue" },
classType: { from: "actType" },
recurrenceRule: {from: "recRule" }
}
}
},
requestEnd: function(e){
var unitData = e.response;
//console.log(unitData.length);
if(selectunits!="" && unitData) {
var uooArr=new Array();
//var unitData = unitList.data();
for(i=1;i Select All"+["excel"],
toolbar: [
{ name: "excel" },
{ template: " Select All" }
],
excel: {
allPages:true,
fileName:"Timetable_list_export.xlsx"
},
columns: [
{ field: "unitTitle", title: "Unit",
template: kendo.template("#if(actUoo.length==0){#\
-\
#}else{#\
#= kendo.toString(actUoo.substr(0,8))# (#= kendo.toString(actUoo.substr(9,5))#)\
#}#"),
groupHeaderTemplate: "Unit: #= value # Select Group" ,
width: "120px"
},
{ field: "actType", title: "Activity", width: "80px", aggregates: ["count"],
groupHeaderTemplate: "Activity: #= value # (#= count#) Select Group" },
{ field: "othdtl", title: "Other Detail", width: "150px", groupable:false },
{ field: "day", title: "Day", width: "80px", sortable: { compare: function(a,b) { return days[a.day] - days[b.day]; } } },
{ field: "sttoend", title: "Time", width: "80px", groupable:false },
{ field: "venue", title: "Venue", width: "100px", template: "#= kendo.toString(venue.substring(0,venue.indexOf(']')+1))#",
groupHeaderTemplate: "Venue: #= value # Select Group" },
//{ field: "wks", title: "Weeks" , width: "100px", template:kendo.template($("#wkval-template").html()), groupable:false}
{ field: "wknos", title: "Weeks" , width: "100px", template:kendo.template("Wks #= kendo.toString(wkTot(wknos))#"), groupable:false}
],
excelExport: function(e) {
var sheet = e.workbook.sheets[0];
var template = kendo.template(this.columns[6].template);
var grouped='N';
if(this.columns.lengthtr"));
this.blur();
}
else {
grid.clearSelection(); }
});
var actArr = new Array;
var venArr = new Array;
var extview = 'N';
var k=0;
for(j=0;j 18) {
extview='Y'; } }
actArr[j] = schedulerdat[j].actType;
if(venArr.indexOf(schedulerdat[j].venue)<0) {
venArr[k] = schedulerdat[j].venue;
k++;
}
}
var scheduler = $("#scheduler").data("kendoScheduler");
if(scheduler.viewName()!='day' || refreshWkBx=='Y') {
if(extview=='Y' && scheduler.viewName() != "week") {
scheduler.view("SchedulerWeekView");
//console.log('changing view to week');
}
if(extview=='N' && scheduler.viewName() != "workWeek") {
scheduler.view("SchedulerwWeekView");
//console.log('changing view to work week');
} }
else { scheduler.view("day");
//console.log('changing view to day');
}
venArr.sort();
if(venArr.length==0) {
$("#venueLst").empty();
$("#venueLst").append("No venues returned
");
}
if(venArr[0]) {
$("#venueLst").empty();
for(i=0;i"+venArr[i]+"");
}
}
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
var SchedulerWeekView = kendo.ui.WeekView.extend({
dateForTitle: function() {
return "Week " + kendo.recurrence.weekInYear(this.startDate(), this.calendarInfo().firstDay);
}
});
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)+")";
}
});
function weekExist(week) {
var wkclass = "";
if(wklstArr.indexOf(week) < 0) {
wkclass = 'class="weeknone"'; }
return wkclass;
}
function filtWks(weeksel) {
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.dataSource.filter({
operator: function(task) {
return (getWeekFilter(task.wknos,weeksel,task.day));
}
});
var grid = $("#ttlist").data("kendoGrid");
grid.dataSource.filter({
logic: "and",
filters: [
{field: "venue", operator: "neq", value : "venue"},
{
field: "wknos",
operator: function(item, value) {
return (getWeekFilter(item+",All weeks",weeksel,"Monday"));
},
value: "blah"
}
]
});
}
$("#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, //can also be defined at the view level
//timezone: "Australia/Perth", //this seems to make it hang for some reason?
dateHeaderTemplate: kendo.template("#=kendo.toString(date, 'dddd')# "),
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"];
$("#weeklst").data("kendoComboBox").select(0); }
},
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",
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();
}
})
});
//$("#weeklst").data("kendoComboBox").refresh();
$("#weeklst").data("kendoComboBox").setDataSource(allwkArr);
//console.log('Databound');
//console.log(wklstArr);
if(refreshWkBx=='Y') {
//filtWks("All weeks");
$("#weeklst").data("kendoComboBox").setDataSource(allwkArr);
$("#weeklst").data("kendoComboBox").trigger("change");
}
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';
}
},
footer: {
command: false
}
});
var window_width = $(window).width()
var scheduler = $("#scheduler").data("kendoScheduler");
if(draftInd =='N'){
create_day_switch();
}
else{
create_draft_day_switch();
}
/* Hides header and footer
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.wrapper.children("div").hide(); */
$("#splitter").kendoSplitter({
orientation: "vertical",
panes: [
{ collapsible: true },
{ size: "500px" },
{}
]
});
$("#showtt").click(function(e) {
var multiselect = $("#venueList").data("kendoMultiSelect");
var vens = multiselect.value();
$("#intro").hide();
$("#ventt").show();
//console.log(multiselect.value());
refreshWkBx='Y';
//console.log('reading now');
actLst.read({ dataname: "|p_mode|p_ret|p_draft_ind|p_uoos", datavalue: "|VENUE|DTL|"+draftInd+"|"+vens });
actGrid.read({ dataname: "|p_mode|p_ret|p_draft_ind|p_uoos", datavalue: "|VENUE|GRD|"+draftInd+"|"+vens });
//$("#weeklst").data("kendoComboBox").trigger("change");
});
$("#clearvens").click(function() {
var multiselect = $("#venueList").data("kendoMultiSelect");
multiselect.value("");
//$("#ventt").hide();
//$("#intro").show();
$("#showtt").prop('disabled',true);
});
var selLst = new kendo.data.DataSource();
$(document).ready(function(){
$("#venueList").kendoMultiSelect({
dataSource: venuLst,
dataTextField: "venText",
dataValueField: "venCode",
autoClose: false,
change: function(e) {
if(this.value().length > 0) {
$("#showtt").prop('disabled',false); }
else {
$("#showtt").prop('disabled',true); }
}
});
var multiselect = $("#venueList").data("kendoMultiSelect");
multiselect.list.width(400);
$("#weeklst").kendoComboBox({
//dataSource: wklstArr,
dataSource: allwkArr,
placeholder: "Jump to week...",
animation: {
close: {
//effects: "zoom:out",
duration: 300
}
},
template: ' \
#if(draftInd=="Y"){#\
#= kendo.toString(get_draft_week_ranges(data,"option"))# \
#}else{#\
#= kendo.toString(get_week_ranges(data,"option"))#\
#}#\
',
change: function(e) {
//console.log('week change');
refreshWkBx='N';
var weeksel=this.value();
//console.log(weeksel);
if(weeksel.length > 2) {
var value=0; }
else {
var value = weeksel*7; }
var date = currDate;
if(draftInd=='Y') {
$("#weekDesc").html(get_draft_week_ranges(weeksel,"label")); }
else {
$("#weekDesc").html(get_week_ranges(weeksel,"label")); }
filtWks(weeksel);
},
index: 0
});
$("div.k-multiselect-wrap").find("input.k-input").before("Click here to select venues ");
});