Fix autocalculation of timespent in monthy mode
This commit is contained in:
parent
063cf15bcb
commit
f56de9f177
@ -120,7 +120,11 @@ function updateTotal(days,mode)
|
||||
total.setHours(0);
|
||||
total.setMinutes(0);
|
||||
var nbline = document.getElementById('numberOfLines').value;
|
||||
for (var i=-1; i<nbline; i++)
|
||||
var startline = 0;
|
||||
if (document.getElementById('numberOfFirstLine')) {
|
||||
startline = parseInt(document.getElementById('numberOfFirstLine').value);
|
||||
}
|
||||
for (var i=-1; i < nbline; i++)
|
||||
{
|
||||
var id='timespent['+i+']['+days+']';
|
||||
var taskTime= new Date(0);
|
||||
@ -213,17 +217,27 @@ function updateTotal(days,mode)
|
||||
console.log(total.getMinutes())
|
||||
}
|
||||
});
|
||||
|
||||
if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+days).addClass("bold");
|
||||
else jQuery('.totalDay'+days).removeClass("bold");
|
||||
jQuery('.totalDay'+days).text(pad(total.getHours())+':'+pad(total.getMinutes()));
|
||||
|
||||
var stringdays = days;
|
||||
if (startline >= 1 && startline <= 9 && stringdays < 10) {
|
||||
stringdays = '0'+stringdays;
|
||||
}
|
||||
|
||||
if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+stringdays).addClass("bold");
|
||||
else jQuery('.totalDay'+stringdays).removeClass("bold");
|
||||
jQuery('.totalDay'+stringdays).text(pad(total.getHours())+':'+pad(total.getMinutes()));
|
||||
|
||||
var totalhour = 0;
|
||||
var totalmin = 0;
|
||||
for (var i=0; i<7; i++)
|
||||
{
|
||||
stringdays = (i + startline);
|
||||
if (startline >= 1 && startline <= 9 && stringdays < 10) {
|
||||
stringdays = '0'+stringdays;
|
||||
}
|
||||
|
||||
var taskTime= new Date(0);
|
||||
result=parseTime(jQuery('.totalDay'+i).text(),taskTime);
|
||||
result=parseTime(jQuery('.totalDay'+stringdays).text(),taskTime);
|
||||
if (result >= 0)
|
||||
{
|
||||
totalhour = totalhour + taskTime.getHours();
|
||||
@ -273,8 +287,14 @@ function updateTotal(days,mode)
|
||||
}
|
||||
}
|
||||
|
||||
if (total) jQuery('.totalDay'+days).addClass("bold");
|
||||
else jQuery('.totalDay'+days).removeClass("bold");
|
||||
jQuery('.totalDay'+days).text(total);
|
||||
var stringdays = days;
|
||||
if (startline >= 1 && startline <= 9 && stringdays < 10) {
|
||||
stringdays = '0'+stringdays;
|
||||
console.log(stringdays);
|
||||
}
|
||||
|
||||
if (total) jQuery('.totalDay'+stringdays).addClass("bold");
|
||||
else jQuery('.totalDay'+stringdays).removeClass("bold");
|
||||
jQuery('.totalDay'+stringdays).text(total);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1910,12 +1910,12 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
|
||||
$placeholder = '';
|
||||
if ($alreadyspent)
|
||||
{
|
||||
$tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$weekNb.']" name="task['.$lines[$i]->id.']['.$weekNb.']" value="'.$alreadyspent.'"></span>';
|
||||
$tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.((int) $weekNb).']" name="task['.$lines[$i]->id.']['.$weekNb.']" value="'.$alreadyspent.'"></span>';
|
||||
//$placeholder=' placeholder="00:00"';
|
||||
//$tableCell.='+';
|
||||
}
|
||||
|
||||
$tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$TFirstDay[$weekNb].']" name="task['.$lines[$i]->id.']['.$TFirstDay[$weekNb].']" value="" cols="2" maxlength="5"';
|
||||
$tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.((int) $weekNb).']" name="task['.$lines[$i]->id.']['.$TFirstDay[$weekNb].']" value="" cols="2" maxlength="5"';
|
||||
$tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
|
||||
$tableCell .= ' onkeyup="updateTotal('.$weekNb.',\''.$modeinput.'\')"';
|
||||
$tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$weekNb.',\''.$modeinput.'\')" />';
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
/**
|
||||
* \file htdocs/projet/activity/permonth.php
|
||||
* \ingroup projet
|
||||
* \brief List activities of tasks (per week entry)
|
||||
* \brief List activities of tasks (per month entry)
|
||||
*/
|
||||
|
||||
require "../../main.inc.php";
|
||||
@ -480,8 +480,7 @@ print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
$countWeek = count($TWeek);
|
||||
for ($idw=0;$idw<$countWeek;$idw++)
|
||||
foreach ($TWeek as $week_number)
|
||||
{
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
@ -516,6 +515,8 @@ $colspan=5;
|
||||
// By default, we can edit only tasks we are assigned to
|
||||
$restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0);
|
||||
|
||||
$isavailable = array();
|
||||
|
||||
if (count($tasksarray) > 0)
|
||||
{
|
||||
//var_dump($tasksarray); // contains only selected tasks
|
||||
@ -616,6 +617,7 @@ print "</table>";
|
||||
print '</div>';
|
||||
|
||||
print '<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).'"/>'."\n";
|
||||
print '<input type="hidden" id="numberOfFirstLine" name="numberOfFirstLine" value="'.(reset($TWeek)).'"/>'."\n";
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
@ -639,11 +641,9 @@ if ($conf->use_javascript_ajax)
|
||||
}
|
||||
});'."\n";
|
||||
|
||||
$idw=0;
|
||||
while ($idw < 7)
|
||||
foreach ($TWeek as $week_number)
|
||||
{
|
||||
print ' updateTotal('.$idw.',\''.$modeinput.'\');';
|
||||
$idw++;
|
||||
print ' updateTotal('.$week_number.',\''.$modeinput.'\');';
|
||||
}
|
||||
print "\n});\n";
|
||||
print '</script>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user