Hi there … we have a paid licence… Is it possible to show a total of the hours added to each day into the headers… like this:
Thanks!
Hello,
you can redefine a template for column headers and make sure that calendar layout is refreshed each time data changes (so totals will be recalculated).
The code (JS) can look like following:
[code](function(){
function dayTotal(date){
var from = scheduler.date.day_start(new Date(date)),
to = scheduler.date.add(from, 1, “day”);
var evs = scheduler.getEvents(from, to);
var total = 0;
for(var i = 0; i < evs.length; i++){
total += evs[i].end_date - evs[i].start_date;
}
return total;
}
var dateTemplate = scheduler.date.date_to_str(scheduler.config.day_date);
scheduler.templates.week_scale_date = function(date){
var total = dayTotal(date);
return dateTemplate(date) + “, TOTAL:” + Math.floor(total/(10006060)) + “hrs”;
};
scheduler.attachEvent(“onXLE”, function(){
scheduler.setCurrentView();
});
scheduler.attachEvent(“onDragEnd”, function(){
scheduler.setCurrentView();
});
scheduler.attachEvent(“onAfterLightbox”, function(){
scheduler.setCurrentView();
});
})();[/code]
Aliaksandr - this looks great but is it possible to have the minutes total also?
For example: total 7:45hrs
Hello,
function dayTotal(date) from my sample returns total duration in milliseconds. Then it is formatted in week_scale_date template:
return dateTemplate(date) + ", TOTAL:" + Math.floor(total/(1000*60*60)) + "hrs";
You can modify the formatting as you like