Merge branch 'NEW_13.0_project_block_timesheet' of github.com:marc-dll/dolibarr into develop
This commit is contained in:
commit
4c6dfd8d5c
@ -1306,6 +1306,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
|
|||||||
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break
|
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$restrictBefore = null;
|
||||||
|
|
||||||
|
if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
$restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
|
||||||
|
}
|
||||||
|
|
||||||
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
|
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
|
||||||
for ($i = 0; $i < $numlines; $i++) {
|
for ($i = 0; $i < $numlines; $i++) {
|
||||||
if ($parent == 0) {
|
if ($parent == 0) {
|
||||||
@ -1551,6 +1558,10 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
|
|||||||
$disabledtask = 1;
|
$disabledtask = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($restrictBefore && $preselectedday < $restrictBefore) {
|
||||||
|
$disabledtask = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Form to add new time
|
// Form to add new time
|
||||||
print '<td class="nowrap leftborder center">';
|
print '<td class="nowrap leftborder center">';
|
||||||
$tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask);
|
$tableCell = $form->selectDate($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, $disabledtask);
|
||||||
@ -1699,6 +1710,13 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
|||||||
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
|
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$restrictBefore = null;
|
||||||
|
|
||||||
|
if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
$restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $numlines; $i++) {
|
for ($i = 0; $i < $numlines; $i++) {
|
||||||
if ($parent == 0) {
|
if ($parent == 0) {
|
||||||
$level = 0;
|
$level = 0;
|
||||||
@ -1977,6 +1995,12 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
|||||||
$cssweekend = 'weekend';
|
$cssweekend = 'weekend';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$disabledtaskday = $disabledtask;
|
||||||
|
|
||||||
|
if (! $disabledtask && $restrictBefore && $tmpday < $restrictBefore) {
|
||||||
|
$disabledtaskday = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$tableCell = '<td class="center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
|
$tableCell = '<td class="center hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
|
||||||
//$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday;
|
//$tableCell .= 'idw='.$idw.' '.$conf->global->MAIN_START_WEEK.' '.$numstartworkingday.'-'.$numendworkingday;
|
||||||
$placeholder = '';
|
$placeholder = '';
|
||||||
@ -1985,7 +2009,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
|||||||
//$placeholder=' placeholder="00:00"';
|
//$placeholder=' placeholder="00:00"';
|
||||||
//$tableCell.='+';
|
//$tableCell.='+';
|
||||||
}
|
}
|
||||||
$tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
|
$tableCell .= '<input type="text" alt="'.($disabledtaskday ? '' : $alttitle).'" title="'.($disabledtaskday ? '' : $alttitle).'" '.($disabledtaskday ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
|
||||||
$tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
|
$tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
|
||||||
$tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
|
$tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
|
||||||
$tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
|
$tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
|
||||||
@ -2079,6 +2103,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
|
|||||||
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
|
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$restrictBefore = null;
|
||||||
|
|
||||||
|
if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
$restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $numlines; $i++) {
|
for ($i = 0; $i < $numlines; $i++) {
|
||||||
if ($parent == 0) {
|
if ($parent == 0) {
|
||||||
$level = 0;
|
$level = 0;
|
||||||
@ -2231,10 +2262,11 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
|
|||||||
$modeinput = 'hours';
|
$modeinput = 'hours';
|
||||||
$TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
|
$TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
|
||||||
$TFirstDay[reset($TWeek)] = 1;
|
$TFirstDay[reset($TWeek)] = 1;
|
||||||
foreach ($TFirstDay as &$fday) {
|
|
||||||
$fday--;
|
$firstdaytoshowarray = dol_getdate($firstdaytoshow);
|
||||||
}
|
$year = $firstdaytoshowarray['year'];
|
||||||
foreach ($TWeek as $weekNb) {
|
$month = $firstdaytoshowarray['mon'];
|
||||||
|
foreach ($TWeek as $weekIndex => $weekNb) {
|
||||||
$weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
|
$weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
|
||||||
$totalforeachweek[$weekNb] += $weekWorkLoad;
|
$totalforeachweek[$weekNb] += $weekWorkLoad;
|
||||||
|
|
||||||
@ -2244,6 +2276,12 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
|
|||||||
}
|
}
|
||||||
$alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
|
$alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
|
||||||
|
|
||||||
|
$disabledtaskweek = $disabledtask;
|
||||||
|
$firstdayofweek = dol_mktime(0, 0, 0, $month, $TFirstDay[$weekIndex], $year);
|
||||||
|
|
||||||
|
if (! $disabledtask && $restrictBefore && $firstdayofweek < $restrictBefore) {
|
||||||
|
$disabledtaskweek = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$tableCell = '<td class="center hide weekend">';
|
$tableCell = '<td class="center hide weekend">';
|
||||||
$placeholder = '';
|
$placeholder = '';
|
||||||
@ -2253,7 +2291,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
|
|||||||
//$tableCell.='+';
|
//$tableCell.='+';
|
||||||
}
|
}
|
||||||
|
|
||||||
$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 .= '<input type="text" alt="'.($disabledtaskweek ? '' : $alttitle).'" title="'.($disabledtaskweek ? '' : $alttitle).'" '.($disabledtaskweek ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.((int) $weekNb).']" name="task['.$lines[$i]->id.']['.($TFirstDay[$weekNb] - 1).']" value="" cols="2" maxlength="5"';
|
||||||
$tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
|
$tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"';
|
||||||
$tableCell .= ' onkeyup="updateTotal('.$weekNb.',\''.$modeinput.'\')"';
|
$tableCell .= ' onkeyup="updateTotal('.$weekNb.',\''.$modeinput.'\')"';
|
||||||
$tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$weekNb.',\''.$modeinput.'\')" />';
|
$tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$weekNb.',\''.$modeinput.'\')" />';
|
||||||
|
|||||||
@ -84,6 +84,7 @@ NumberOfBytes=Number of Bytes
|
|||||||
SearchString=Search string
|
SearchString=Search string
|
||||||
NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
|
NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
|
||||||
AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party
|
AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party
|
||||||
|
TimesheetPreventAfterFollowingMonths=Prevent recording time spent after the following number of months
|
||||||
JavascriptDisabled=JavaScript disabled
|
JavascriptDisabled=JavaScript disabled
|
||||||
UsePreviewTabs=Use preview tabs
|
UsePreviewTabs=Use preview tabs
|
||||||
ShowPreview=Show preview
|
ShowPreview=Show preview
|
||||||
|
|||||||
@ -140,6 +140,7 @@ NoTasks=No tasks for this project
|
|||||||
LinkedToAnotherCompany=Linked to other third party
|
LinkedToAnotherCompany=Linked to other third party
|
||||||
TaskIsNotAssignedToUser=Task not assigned to user. Use button '<strong>%s</strong>' to assign task now.
|
TaskIsNotAssignedToUser=Task not assigned to user. Use button '<strong>%s</strong>' to assign task now.
|
||||||
ErrorTimeSpentIsEmpty=Time spent is empty
|
ErrorTimeSpentIsEmpty=Time spent is empty
|
||||||
|
TimeRecordingRestrictedToNMonthsBack=Time recording is restricted to %s months back
|
||||||
ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (<b>%s</b> tasks at the moment) and all inputs of time spent.
|
ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (<b>%s</b> tasks at the moment) and all inputs of time spent.
|
||||||
IfNeedToUseOtherObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties.
|
IfNeedToUseOtherObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties.
|
||||||
CloneTasks=Clone tasks
|
CloneTasks=Clone tasks
|
||||||
|
|||||||
@ -219,6 +219,10 @@ if ($action == 'updateMaskTask') {
|
|||||||
$projectToSelect = GETPOST('projectToSelect', 'alpha');
|
$projectToSelect = GETPOST('projectToSelect', 'alpha');
|
||||||
dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value
|
dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value
|
||||||
}
|
}
|
||||||
|
if (GETPOST('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
|
||||||
|
$timesheetFreezeDuration = GETPOST('timesheetFreezeDuration', 'alpha');
|
||||||
|
dolibarr_set_const($db, 'PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS', intval($timesheetFreezeDuration), 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value
|
||||||
|
}
|
||||||
} elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
|
} elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
|
||||||
// Set boolean (on/off) constants
|
// Set boolean (on/off) constants
|
||||||
if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
|
if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
@ -797,6 +801,7 @@ print '<input type="text" id="projectToSelect" name="projectToSelect" value="'.$
|
|||||||
print $form->textwithpicto('', $langs->trans('AllowToLinkFromOtherCompany'));
|
print $form->textwithpicto('', $langs->trans('AllowToLinkFromOtherCompany'));
|
||||||
print '<input type="submit" class="button" name="PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY" value="'.$langs->trans("Modify").'">';
|
print '<input type="submit" class="button" name="PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY" value="'.$langs->trans("Modify").'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
$key = 'PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE';
|
$key = 'PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE';
|
||||||
echo '<tr class="oddeven">',
|
echo '<tr class="oddeven">',
|
||||||
@ -808,6 +813,14 @@ echo '<tr class="oddeven">',
|
|||||||
'</td>',
|
'</td>',
|
||||||
'</tr>';
|
'</tr>';
|
||||||
|
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
print '<td>'.$langs->trans("TimesheetPreventAfterFollowingMonths").'</td>';
|
||||||
|
|
||||||
|
print '<td class="right" width="60" colspan="2">';
|
||||||
|
print '<input type="number" id="timesheetFreezeDuration" name="timesheetFreezeDuration" min="0" step="1" value="'.$conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS.'"/> ';
|
||||||
|
print '<input type="submit" class="button" name="PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1158,6 +1158,18 @@ class Task extends CommonObject
|
|||||||
$this->timespent_datehour = $this->timespent_date;
|
$this->timespent_datehour = $this->timespent_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
$restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
|
||||||
|
|
||||||
|
if ($this->timespent_date < $restrictBefore) {
|
||||||
|
$this->error = $langs->trans('TimeRecordingRestrictedToNMonthsBack', $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS);
|
||||||
|
$this->errors[] = $this->error;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user