Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions view/timespent_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,21 @@
'p.rowid' => array('fieldalias' => 'projectid', 'type'=> 'text', 'label' => "ProjectId", 'visible' => 0),
'pt.rowid' => array('fieldalias' => 'taskid', 'type' => 'Task:projet/class/task.class.php:1', 'label' => "Task", 'checked' => 1, 'position' => 30, 'visible' => 1),
'label' => array('tablealias' => 'pt.', 'type' => 'text', 'label' => "Label", 'checked' => 1, 'position' => 40, 'visible' => 1),
'task_date' => array('tablealias' => 'ptt.', 'type' => 'datetime', 'label' => "Date", 'checked' => 1, 'position' => 50, 'visible' => 1),
'fk_user' => array('tablealias' => 'ptt.', 'fieldalias' => 'fk_user', 'type' => 'User:user/class/user.class.php', 'label' => "User", 'checked' => 1, 'position' => 60, 'visible' => 1),
'task_duration' => array('tablealias' => 'ptt.', 'type' => 'duration', 'label' => "Duration", 'checked' => 1, 'position' => 70, 'visible' => 1, 'isameasure'=>1),
'note' => array('tablealias' => 'ptt.', 'type' => 'text', 'label' => "Note", 'checked' => 1, 'position' => 80, 'visible' => 1),
'thm' => array('tablealias' => 'ptt.', 'type' => 'price', 'label' => "Value", 'checked' => 1, 'position' => 90, 'visible' => 1, 'isameasure'=>1),
'invoice_id' => array('tablealias' => 'ptt.', 'fieldalias' => 'invoice_id', 'type' => 'Facture:compta/facture/class/facture.class.php:1', 'label' => "Facture", 'checked' => 1, 'position' => 100, 'visible' => 1),
'ts.rowid' => array('fieldalias' => 'timesheetid', 'type' => 'TimeSheet:custom/dolisirh/class/timesheet.class.php:1', 'label' => "TimeSheet", 'checked' => 1, 'position' => 110, 'visible' => 1),
);

if (!empty($versionEighteenOrMore)) {
$arrayfields['element_date'] = array('tablealias' => 'ptt.', 'type' => 'datetime', 'label' => "Date", 'checked' => 1, 'position' => 50, 'visible' => 1);
$arrayfields['element_duration'] = array('tablealias' => 'ptt.', 'type' => 'duration', 'label' => "Duration", 'checked' => 1, 'position' => 70, 'visible' => 1, 'isameasure'=>1);
} else {
$arrayfields['task_date'] = array('tablealias' => 'ptt.', 'type' => 'datetime', 'label' => "Date", 'checked' => 1, 'position' => 50, 'visible' => 1);
$arrayfields['task_duration'] = array('tablealias' => 'ptt.', 'type' => 'duration', 'label' => "Duration", 'checked' => 1, 'position' => 70, 'visible' => 1, 'isameasure'=>1);
}

// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) {
if ($versionEighteenOrMore) {
Expand Down Expand Up @@ -248,7 +254,7 @@
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet_task as pt ON p.rowid = pt.fk_projet';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet_task_extrafields as ef ON pt.rowid = ef.fk_object';
if ($versionEighteenOrMore) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'element_time as ptt ON (ptt.fk_element = t.rowid AND ptt.elementtype = "task")';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'element_time as ptt ON (ptt.fk_element = pt.rowid AND ptt.elementtype = "task")';
} else {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet_task_time as ptt ON pt.rowid = ptt.fk_task';
}
Expand Down Expand Up @@ -453,7 +459,7 @@
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields[$key]['checked'])) {
if (!empty($arrayfields[$key]['checked']) && $key != 'p.rowid') {
print '<td class="liste_titre' . ($cssforfield ? ' ' . $cssforfield : '') . '">';
if (in_array($val['fieldalias'], array('socid','projectref', 'fk_user','taskid', 'invoice_id', 'timesheetid'))) {
print $form->selectForForms($val['type'], 'search_' . $keysearch, $search[$keysearch], 1, '', '', $morecss);
Expand Down Expand Up @@ -564,14 +570,26 @@
}
}
}
} elseif ($key == 'task_date') {
print dol_print_date($obj->task_date, 'day');
} elseif ($key == 'task_date' || $key == 'element_date') {
if (!empty($versionEighteenOrMore)) {
print dol_print_date($obj->element_date, 'day');
} else {
print dol_print_date($obj->task_date, 'day');
}
} elseif ($key == 'title' || $key === 'label' || $key == 'note') {
print $obj->{$key};
} elseif ($key == 'task_duration') {
print convertSecondToTime($obj->task_duration, 'allhourmin');
} elseif ($key == 'element_duration' || $key == 'task_duration') {
if (!empty($versionEighteenOrMore)) {
print convertSecondToTime($obj->element_duration, 'allhourmin');
} else {
print convertSecondToTime($obj->task_duration, 'allhourmin');
}
} elseif ($key == 'thm') {
$value = price2num($obj->thm * $obj->task_duration / 3600, 'MT', 1);
if (!empty($versionEighteenOrMore)) {
$value = price2num($obj->thm * $obj->element_duration / 3600, 'MT', 1);
} else {
$value = price2num($obj->thm * $obj->task_duration / 3600, 'MT', 1);
}
print '<span class="amount" title="'.$langs->trans("THM").': '.price($obj->thm).'">';
print price($value, 1, $langs, 1, -1, -1, $conf->currency);
}
Expand Down Expand Up @@ -640,6 +658,8 @@
}
} elseif ($totalarray['totaltask_duration'] == $i) {
print '<td class="left">'.convertSecondToTime($totalarray['val']['task_duration'], 'allhourmin').'</td>';
} elseif ($totalarray['totalelement_duration'] == $i) {
print '<td class="left">'.convertSecondToTime($totalarray['val']['element_duration'], 'allhourmin').'</td>';
} elseif ($totalarray['totalthm'] == $i) {
print '<td class="right">'.price($totalarray['val']['thm']).'</td>';
} else {
Expand Down