diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index a53c3b3e925..1ecc6dc9aea 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1248,10 +1248,11 @@ class Form
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
* @param string $morefilter Add more filters into sql request
* @param string $show_every 0=default list, 1=add also a value "Everybody" at beginning of list
+ * @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty.
* @return string HTML select string
* @see select_dolgroups
*/
- function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0)
+ function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='')
{
global $conf,$user,$langs;
@@ -1347,8 +1348,8 @@ class Form
$userstatic->lastname=$obj->lastname;
$userstatic->firstname=$obj->firstname;
- $disableline=0;
- if (is_array($enableonly) && count($enableonly) && ! in_array($obj->rowid,$enableonly)) $disableline=1;
+ $disableline='';
+ if (is_array($enableonly) && count($enableonly) && ! in_array($obj->rowid,$enableonly)) $disableline=($enableonlytext?$enableonlytext:'1');
if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && $selected == $obj->rowid))
{
@@ -1398,6 +1399,10 @@ class Form
}
}
$out.=($moreinfo?')':'');
+ if ($disableline && $disableline != '1')
+ {
+ $out.=' - '.$disableline; // This is text from $enableonlytext parameter
+ }
$out.= '';
$i++;
@@ -4248,6 +4253,7 @@ class Form
$hourSelected=0; $minSelected=0;
+ // Hours
if ($iSecond != '')
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@@ -4278,6 +4284,7 @@ class Form
$retstring.=' '.$langs->trans('HourShort');
+ // Minutes
if ($minunderhours) $retstring.=' ';
else $retstring.=" ";
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 9e4ad9d1f59..681c667854f 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -147,13 +147,15 @@ class FormProjets
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
}
- if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0)
+ if (!empty($selected) && $selected == $obj->rowid)
{
- $out.= '';
+ $out.= '';
}
else
{
- if ($hideunselectables && $disabled)
+ if ($hideunselectables && $disabled && ($selected != $obj->rowid))
{
$resultat='';
}
@@ -194,12 +196,14 @@ class FormProjets
*
* @param string $table_element Table of the element to update
* @param int $socid socid to filter
- * @return string The HTML select list of element
+ * @return int|string The HTML select list of element or '' if nothing or -1 if KO
*/
function select_element($table_element,$socid=0)
{
global $conf, $langs;
+ if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done)
+
$projectkey="fk_projet";
switch ($table_element)
{
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 6a9376b57f9..f5cc4188981 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2717,6 +2717,7 @@ function print_titre($title)
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
* @param int $id To force an id on html objects
* @return void
+ * @deprecated Use print load_fiche_titre instead
*/
function print_fiche_titre($title, $mesg='', $picto='title_generic.png', $pictoisfullpath=0, $id='')
{
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index 2056ebad4bd..75e30da80a3 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -657,7 +657,10 @@ if (! empty($id) && $action != 'edit')
{
print '
';
}
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index 18c9b82de96..4fd51981a99 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -75,6 +75,7 @@ ListFichinterAssociatedProject=List of interventions associated with the project
ListExpenseReportsAssociatedProject=List of expense reports associated with the project
ListDonationsAssociatedProject=List of donations associated with the project
ListActionsAssociatedProject=List of events associated with the project
+ListTaskTimeUserProject=List of time consumed on tasks of project
ActivityOnProjectThisWeek=Activity on project this week
ActivityOnProjectThisMonth=Activity on project this month
ActivityOnProjectThisYear=Activity on project this year
@@ -145,4 +146,6 @@ InputPerWeek=Input per week
InputPerAction=Input per action
TimeAlreadyRecorded=Time spent already recorded for this task/day and user %s
ProjectsWithThisUserAsContact=Projects with this user as contact
-TasksWithThisUserAsContact=Tasks assigned to this user
\ No newline at end of file
+TasksWithThisUserAsContact=Tasks assigned to this user
+ResourceNotAssignedToProject=Not assigned to project
+ResourceNotAssignedToTask=Not assigned to task
\ No newline at end of file
diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index 791f01d5932..6a36d59b3b2 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -601,7 +601,7 @@ else
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text=$form->select_thirdparty_list($object->thirdparty->id,'socid',$filteronlist,1,1);
$texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty");
- print $form->textwithtooltip($text.' '.img_help(),$texthelp,1);
+ print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2);
print '';
// Visibility
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index a819577085f..a5ae027d2b7 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -406,31 +406,40 @@ class Project extends CommonObject
}
/**
- * Return list of elements for type linked to project
+ * Return list of elements for type, linked to project
*
- * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier'
+ * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',...
* @param string $tablename name of table associated of the type
- * @param string $datefieldname name of table associated of the type
- * @param string $dates Start date (at 00:00:00)
- * @param string $datee End date (at 23:00:00)
+ * @param string $datefieldname name of date field for filter
+ * @param string $dates Start date (ex 00:00:00)
+ * @param string $datee End date (ex 23:59:59)
* @return mixed Array list of object ids linked to project, < 0 or string if error
*/
function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='')
{
$elements = array();
- if ($type == 'agenda')
+ if ($type == 'agenda')
{
$sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id;
}
+ elseif ($type == 'expensereport')
+ {
+ $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id;
+ }
+ elseif ($type == 'project_task')
+ {
+ $sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id;
+ }
+ elseif ($type == 'project_task_time') // Case we want to duplicate line foreach user
+ {
+ $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id;
+ }
else
{
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id;
}
- if ($type == 'expensereport')
- {
- $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id;
- }
+
if ($dates > 0)
{
if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date;
@@ -458,7 +467,7 @@ class Project extends CommonObject
{
$obj = $this->db->fetch_object($result);
- $elements[$i] = $obj->rowid;
+ $elements[$i] = $obj->rowid.(empty($obj->fk_user)?'':'_'.$obj->fk_user);
$i++;
}
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 43e0a5a1114..3b2caf30ad7 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -509,7 +509,7 @@ class Task extends CommonObject
$label = '' . $langs->trans("ShowTask") . '';
if (! empty($this->ref))
$label .= ' ' . $langs->trans('Ref') . ': ' . $this->ref;
- if (! empty($this->title))
+ if (! empty($this->label))
$label .= ' ' . $langs->trans('LabelTask') . ': ' . $this->label;
if ($this->date_start || $this->date_end)
{
@@ -913,6 +913,59 @@ class Task extends CommonObject
}
}
+ /**
+ * Calculate vamue of time consumed using the thm (hourly amount value of work for user entering time)
+ *
+ * @param User $fuser Filter on a dedicated user
+ * @param string $dates Start date (ex 00:00:00)
+ * @param string $datee End date (ex 23:59:59)
+ * @return array Array of info for task array('amount')
+ */
+ function getSumOfAmount($fuser='', $dates='', $datee='')
+ {
+ global $langs;
+
+ if (empty($id)) $id=$this->id;
+
+ $result=array();
+
+ $sql = "SELECT";
+ $sql.= " SUM(t.task_duration / 3600 * thm) as amount";
+ $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
+ $sql.= " WHERE t.fk_task = ".$id;
+ if (is_object($fuser) && $fuser->id > 0)
+ {
+ $sql.=" AND fk_user = ".$fuser->id;
+ }
+ if ($dates > 0)
+ {
+ $datefieldname="task_datehour";
+ $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)";
+ }
+ if ($datee > 0)
+ {
+ $datefieldname="task_datehour";
+ $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)";
+ }
+
+ dol_syslog(get_class($this)."::getSumOfAmount", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $result['amount'] = $obj->amount;
+
+ $this->db->free($resql);
+ return $result;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return $result;
+ }
+ }
+
/**
* Load object in memory from database
*
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index c5f561b2c1c..a9089673ae6 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -28,6 +28,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@@ -257,9 +258,18 @@ $listofreferent=array(
'class'=>'Don',
'margin'=>'add',
'table'=>'don',
- 'datefieldname'=>'date',
+ 'datefieldname'=>'datedon',
'disableamount'=>0,
'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,
+ 'test'=>$conf->projet->enabled && $user->rights->projet->lire && $conf->salaries->enabled),
);
if ($action=="addelement")
@@ -281,6 +291,8 @@ if ($action=="addelement")
}
}
+$elementuser = new User($db);
+
$showdatefilter=0;
foreach ($listofreferent as $key => $value)
{
@@ -292,15 +304,19 @@ foreach ($listofreferent as $key => $value)
if ($qualified)
{
+ // If we want the project task array to have details of users
+ //if ($key == 'project_task') $key = 'project_task_time';
+
+
$element = new $classname($db);
+ // Show the filter on date on top of element list
if (! $showdatefilter)
{
print '