Fix condition to show time spent on project overview
This commit is contained in:
parent
f07c741176
commit
064f38b89e
@ -58,6 +58,7 @@ TaskDateEnd=Task end date
|
|||||||
TaskDescription=Task description
|
TaskDescription=Task description
|
||||||
NewTask=New task
|
NewTask=New task
|
||||||
AddTask=Create task
|
AddTask=Create task
|
||||||
|
AddTimeSpent=Create time spent
|
||||||
Activity=Activity
|
Activity=Activity
|
||||||
Activities=Tasks/activities
|
Activities=Tasks/activities
|
||||||
MyActivities=My tasks/activities
|
MyActivities=My tasks/activities
|
||||||
|
|||||||
@ -1039,12 +1039,12 @@ class Task extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate value of time consumed using the thm (hourly amount value of work for user entering time)
|
* Calculate quantity and value of time consumed using the thm (hourly amount value of work for user entering time)
|
||||||
*
|
*
|
||||||
* @param User $fuser Filter on a dedicated user
|
* @param User $fuser Filter on a dedicated user
|
||||||
* @param string $dates Start date (ex 00:00:00)
|
* @param string $dates Start date (ex 00:00:00)
|
||||||
* @param string $datee End date (ex 23:59:59)
|
* @param string $datee End date (ex 23:59:59)
|
||||||
* @return array Array of info for task array('amount')
|
* @return array Array of info for task array('amount','nbseconds','nblinesnull')
|
||||||
*/
|
*/
|
||||||
function getSumOfAmount($fuser='', $dates='', $datee='')
|
function getSumOfAmount($fuser='', $dates='', $datee='')
|
||||||
{
|
{
|
||||||
@ -1055,6 +1055,7 @@ class Task extends CommonObject
|
|||||||
$result=array();
|
$result=array();
|
||||||
|
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
|
$sql.= " SUM(t.task_duration) as nbseconds,";
|
||||||
$sql.= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull";
|
$sql.= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
|
||||||
$sql.= " WHERE t.fk_task = ".$id;
|
$sql.= " WHERE t.fk_task = ".$id;
|
||||||
@ -1081,6 +1082,7 @@ class Task extends CommonObject
|
|||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$result['amount'] = $obj->amount;
|
$result['amount'] = $obj->amount;
|
||||||
|
$result['nbseconds'] = $obj->nbseconds;
|
||||||
$result['nblinesnull'] = $obj->nblinesnull;
|
$result['nblinesnull'] = $obj->nblinesnull;
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|||||||
@ -370,6 +370,18 @@ $listofreferent=array(
|
|||||||
'buttonnew'=>'AddDonation',
|
'buttonnew'=>'AddDonation',
|
||||||
'testnew'=>$user->rights->don->creer,
|
'testnew'=>$user->rights->don->creer,
|
||||||
'test'=>$conf->don->enabled && $user->rights->don->lire),
|
'test'=>$conf->don->enabled && $user->rights->don->lire),
|
||||||
|
'project_task'=>array(
|
||||||
|
'name'=>"TaskTimeValorised",
|
||||||
|
'title'=>"ListTaskTimeUserProject",
|
||||||
|
'class'=>'Task',
|
||||||
|
'margin'=>'minus',
|
||||||
|
'table'=>'projet_task',
|
||||||
|
'datefieldname'=>'task_date',
|
||||||
|
'disableamount'=>0,
|
||||||
|
'urlnew'=>DOL_URL_ROOT.'/projet/tasks.php?id='.$id,
|
||||||
|
'buttonnew'=>'AddTimeSpent',
|
||||||
|
'testnew'=>$user->rights->projet->creer,
|
||||||
|
'test'=>($conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))),
|
||||||
'agenda'=>array(
|
'agenda'=>array(
|
||||||
'name'=>"Agenda",
|
'name'=>"Agenda",
|
||||||
'title'=>"ListActionsAssociatedProject",
|
'title'=>"ListActionsAssociatedProject",
|
||||||
@ -382,15 +394,6 @@ $listofreferent=array(
|
|||||||
'buttonnew'=>'AddEvent',
|
'buttonnew'=>'AddEvent',
|
||||||
'testnew'=>$user->rights->agenda->myactions->create,
|
'testnew'=>$user->rights->agenda->myactions->create,
|
||||||
'test'=>$conf->agenda->enabled && $user->rights->agenda->myactions->read),
|
'test'=>$conf->agenda->enabled && $user->rights->agenda->myactions->read),
|
||||||
'project_task'=>array(
|
|
||||||
'name'=>"TaskTimeValorised",
|
|
||||||
'title'=>"ListTaskTimeUserProject",
|
|
||||||
'class'=>'Task',
|
|
||||||
'margin'=>'minus',
|
|
||||||
'table'=>'projet_task',
|
|
||||||
'datefieldname'=>'task_date',
|
|
||||||
'disableamount'=>0,
|
|
||||||
'test'=>$conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS)),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$parameters=array('listofreferent'=>$listofreferent);
|
$parameters=array('listofreferent'=>$listofreferent);
|
||||||
@ -691,6 +694,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
print '<td'.(($tablename != 'actioncomm' && $tablename != 'projet_task') ? ' style="width: 200px"':'').'>'.$langs->trans("Ref").'</td>';
|
print '<td'.(($tablename != 'actioncomm' && $tablename != 'projet_task') ? ' style="width: 200px"':'').'>'.$langs->trans("Ref").'</td>';
|
||||||
// Date
|
// Date
|
||||||
print '<td'.(($tablename != 'actioncomm' && $tablename != 'projet_task') ? ' style="width: 200px"':'').' align="center">';
|
print '<td'.(($tablename != 'actioncomm' && $tablename != 'projet_task') ? ' style="width: 200px"':'').' align="center">';
|
||||||
|
if (in_array($tablename, array('projet_task'))) print $langs->trans("TimeSpent");
|
||||||
if (! in_array($tablename, array('projet_task'))) print $langs->trans("Date");
|
if (! in_array($tablename, array('projet_task'))) print $langs->trans("Date");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// Thirdparty or user
|
// Thirdparty or user
|
||||||
@ -784,9 +788,9 @@ foreach ($listofreferent as $key => $value)
|
|||||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '">' . img_picto($langs->trans('Unlink'), 'editdelete') . '</a>';
|
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '">' . img_picto($langs->trans('Unlink'), 'editdelete') . '</a>';
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<td align="left">';
|
print '<td align="left">';
|
||||||
|
|
||||||
if ($tablename == 'expensereport_det')
|
if ($tablename == 'expensereport_det')
|
||||||
{
|
{
|
||||||
print $expensereport->getNomUrl(1);
|
print $expensereport->getNomUrl(1);
|
||||||
@ -822,10 +826,9 @@ foreach ($listofreferent as $key => $value)
|
|||||||
// Show customer ref
|
// Show customer ref
|
||||||
if (! empty($element->ref_customer)) print ' - '.$element->ref_customer;
|
if (! empty($element->ref_customer)) print ' - '.$element->ref_customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
// Date
|
// Date or TimeSpent
|
||||||
$date='';
|
$date='';
|
||||||
if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines
|
if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines
|
||||||
elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status))
|
elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status))
|
||||||
@ -851,7 +854,12 @@ foreach ($listofreferent as $key => $value)
|
|||||||
print dol_print_date($element->datep,'dayhour');
|
print dol_print_date($element->datep,'dayhour');
|
||||||
if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef,'dayhour');
|
if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef,'dayhour');
|
||||||
}
|
}
|
||||||
else print dol_print_date($date,'day');
|
else if (in_array($tablename, array('projet_task')))
|
||||||
|
{
|
||||||
|
$tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty
|
||||||
|
print convertSecondToTime($tmpprojtime['nbseconds'], 'allhourmin');
|
||||||
|
}
|
||||||
|
else print 'e'.dol_print_date($date,'day');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Third party or user
|
// Third party or user
|
||||||
@ -885,14 +893,13 @@ foreach ($listofreferent as $key => $value)
|
|||||||
$total_ht_by_line=null;
|
$total_ht_by_line=null;
|
||||||
$othermessage='';
|
$othermessage='';
|
||||||
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
||||||
elseif ($tablename == 'projet_task')
|
elseif (in_array($tablename, array('projet_task')))
|
||||||
{
|
{
|
||||||
if (! empty($conf->salaries->enabled))
|
if (! empty($conf->salaries->enabled))
|
||||||
{
|
{
|
||||||
// TODO Permission to read daily rate
|
// TODO Permission to read daily rate to show value
|
||||||
$tmp = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty
|
$total_ht_by_line = price2num($tmpprojtime['amount'],'MT');
|
||||||
$total_ht_by_line = price2num($tmp['amount'],'MT');
|
if ($tmpprojtime['nblinesnull'] > 0)
|
||||||
if ($tmp['nblinesnull'] > 0)
|
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$warning=$langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency);
|
$warning=$langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user