Start fix for #14689
This commit is contained in:
parent
f78cbdefe8
commit
b3fe61e77b
@ -91,6 +91,7 @@ function pad(n) {
|
|||||||
|
|
||||||
/* function from http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/ */
|
/* function from http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/ */
|
||||||
/* timeStr must be a duration with format XX:YY (AM/PM not supported) */
|
/* timeStr must be a duration with format XX:YY (AM/PM not supported) */
|
||||||
|
/* return: nbofextradays (0, 1, ...) */
|
||||||
function parseTime(timeStr, dt)
|
function parseTime(timeStr, dt)
|
||||||
{
|
{
|
||||||
if (!dt) {
|
if (!dt) {
|
||||||
@ -103,14 +104,14 @@ function parseTime(timeStr, dt)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
var hours = parseInt(time[1], 10);
|
var hours = parseInt(time[1], 10);
|
||||||
|
|
||||||
dt.setHours(hours);
|
dt.setHours(hours);
|
||||||
dt.setMinutes(parseInt(time[2], 10) || 0);
|
dt.setMinutes(parseInt(time[2], 10) || 0);
|
||||||
dt.setSeconds(0, 0);
|
dt.setSeconds(0, 0);
|
||||||
return 0;
|
//console.log("hours="+hours+" => return nbofextradays="+Math.floor(hours / 24)+" hours="+dt.getHours());
|
||||||
|
return Math.floor(hours / 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update total. days = column nb staring from 0 */
|
/* Update total. days = column nb starting from 0 */
|
||||||
function updateTotal(days,mode)
|
function updateTotal(days,mode)
|
||||||
{
|
{
|
||||||
console.log('updateTotal days='+days+' mode='+mode);
|
console.log('updateTotal days='+days+' mode='+mode);
|
||||||
@ -124,12 +125,15 @@ function updateTotal(days,mode)
|
|||||||
if (document.getElementById('numberOfFirstLine')) {
|
if (document.getElementById('numberOfFirstLine')) {
|
||||||
startline = parseInt(document.getElementById('numberOfFirstLine').value);
|
startline = parseInt(document.getElementById('numberOfFirstLine').value);
|
||||||
}
|
}
|
||||||
|
var nbextradays = 0;
|
||||||
for (var i=-1; i < nbline; i++)
|
for (var i=-1; i < nbline; i++)
|
||||||
{
|
{
|
||||||
|
/* get value into timespent cell */
|
||||||
|
|
||||||
var id='timespent['+i+']['+days+']';
|
var id='timespent['+i+']['+days+']';
|
||||||
var taskTime= new Date(0);
|
var taskTime = new Date(0);
|
||||||
var element=document.getElementById(id);
|
var element = document.getElementById(id);
|
||||||
if(element)
|
if (element)
|
||||||
{
|
{
|
||||||
/* alert(element.value);*/
|
/* alert(element.value);*/
|
||||||
if (element.value)
|
if (element.value)
|
||||||
@ -142,11 +146,16 @@ function updateTotal(days,mode)
|
|||||||
}
|
}
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
{
|
{
|
||||||
total.setHours(total.getHours()+taskTime.getHours());
|
nbextradays = nbextradays + Math.floor((total.getHours()+taskTime.getHours() + result*24) / 24);
|
||||||
|
//console.log("i="+i+" result="+result);
|
||||||
|
total.setHours(total.getHours()+taskTime.getHours());
|
||||||
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
|
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
|
||||||
|
//console.log("i="+i+" nbextradays cumul="+nbextradays+" h="+total.getHours()+" "+taskTime.getHours());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get value into timeadded cell */
|
||||||
|
|
||||||
var id='timeadded['+i+']['+days+']';
|
var id='timeadded['+i+']['+days+']';
|
||||||
var taskTime= new Date(0);
|
var taskTime= new Date(0);
|
||||||
var element=document.getElementById(id);
|
var element=document.getElementById(id);
|
||||||
@ -163,8 +172,11 @@ function updateTotal(days,mode)
|
|||||||
}
|
}
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
{
|
{
|
||||||
|
nbextradays = nbextradays + Math.floor((total.getHours()+taskTime.getHours() + result*24) / 24);
|
||||||
|
//console.log("i="+i+" result="+result);
|
||||||
total.setHours(total.getHours()+taskTime.getHours());
|
total.setHours(total.getHours()+taskTime.getHours());
|
||||||
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
|
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
|
||||||
|
//console.log("i="+i+" nbextradays cumul="+nbextradays+" h="+total.getHours()+" "+taskTime.getHours());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,9 +235,14 @@ function updateTotal(days,mode)
|
|||||||
stringdays = '0'+stringdays;
|
stringdays = '0'+stringdays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Output total in top of column */
|
||||||
|
|
||||||
if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+stringdays).addClass("bold");
|
if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+stringdays).addClass("bold");
|
||||||
else jQuery('.totalDay'+stringdays).removeClass("bold");
|
else jQuery('.totalDay'+stringdays).removeClass("bold");
|
||||||
jQuery('.totalDay'+stringdays).text(pad(total.getHours())+':'+pad(total.getMinutes()));
|
var texttoshow = pad(nbextradays * 24 + total.getHours())+':'+pad(total.getMinutes());
|
||||||
|
jQuery('.totalDay'+stringdays).text(texttoshow);
|
||||||
|
|
||||||
|
/* Output total of all total */
|
||||||
|
|
||||||
var totalhour = 0;
|
var totalhour = 0;
|
||||||
var totalmin = 0;
|
var totalmin = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user