[ task #531 ] Add a duration on tasks

This commit is contained in:
fhenry 2013-05-13 17:08:36 +02:00
parent 9bfb22ad49
commit 760ae88f39
10 changed files with 143 additions and 21 deletions

View File

@ -6,7 +6,8 @@ English Dolibarr ChangeLog
For users:
- New: [ task #877 ] Reorganize menus
- New: [ task #858 ] Holiday module: note on manual holiday assignation
- New : [ task #892 ] Add option in thridparty customer/supplier admin to hide non active in select_company method
- New: [ task #892 ] Add option in thridparty customer/supplier admin to hide non active in select_company method
- New: [ task #531 ] Add a duration on tasks
***** ChangeLog for 3.4 compared to 3.3.2 *****

View File

@ -420,6 +420,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print dol_print_date($lines[$i]->date_end,'day');
print '</td>';
// Duration
print '<td align="center">';
print $lines[$i]->duration_planned.' '.$langs->trans('Hours');
print '</td>';
// Progress
print '<td align="right">';
print $lines[$i]->progress.' %';
@ -438,7 +443,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
// Tick to drag and drop
if ($addordertick)
{
print '<td align="center" class="tdlineupdown hideonsmartphone">&nbsp;</td>';
print '<td align="center" class="tdlineupdown">&nbsp;</td>';
}
print "</tr>\n";
@ -466,6 +471,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
if ($addordertick) print '<td class="hideonsmartphone"></td>';
print '<td align="right" class="nowrap liste_total">'.convertSecondToTime($total).'</td>';
print '</tr>';
@ -549,6 +555,11 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
print dol_print_date($lines[$i]->date_end,'day');
print '</td>';
// Duration
print '<td align="center">';
print $lines[$i]->duration_planned.' '.$langs->trans('Hours');
print '</td>';
// Progress
print '<td align="right">';
print $lines[$i]->progress.' %';

View File

@ -18,4 +18,8 @@
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
DELETE FROM llx_menu where module='holiday';
DELETE FROM llx_menu where module='holiday';
ALTER TABLE llx_projet_task ADD COLUMN duration_planned real DEFAULT 0 NOT NULL AFTER duration_effective;

View File

@ -29,7 +29,8 @@ create table llx_projet_task
datev datetime, -- date validation
label varchar(255) NOT NULL,
description text,
duration_effective real DEFAULT 0 NOT NULL,
duration_effective real DEFAULT 0 NOT NULL,
duration_planned real DEFAULT 0 NOT NULL,
progress integer DEFAULT 0, -- percentage increase
priority integer DEFAULT 0, -- priority
fk_user_creat integer, -- user who created the task

View File

@ -41,6 +41,7 @@ class Task extends CommonObject
var $label;
var $description;
var $duration_effective;
var $duration_planned;
var $date_c;
var $date_start;
var $date_end;
@ -101,6 +102,7 @@ class Task extends CommonObject
$sql.= ", fk_user_creat";
$sql.= ", dateo";
$sql.= ", datee";
$sql.= ", duration_planned";
$sql.= ", progress";
$sql.= ") VALUES (";
$sql.= $this->fk_project;
@ -111,6 +113,7 @@ class Task extends CommonObject
$sql.= ", ".$user->id;
$sql.= ", ".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null');
$sql.= ", ".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null');
$sql.= ", ".($this->duration_planned!=''?$this->duration_planned:0);
$sql.= ", ".($this->progress!=''?$this->progress:0);
$sql.= ")";
@ -183,6 +186,7 @@ class Task extends CommonObject
$sql.= " t.label,";
$sql.= " t.description,";
$sql.= " t.duration_effective,";
$sql.= " t.duration_planned,";
$sql.= " t.datec,";
$sql.= " t.dateo,";
$sql.= " t.datee,";
@ -211,6 +215,7 @@ class Task extends CommonObject
$this->label = $obj->label;
$this->description = $obj->description;
$this->duration_effective = $obj->duration_effective;
$this->duration_planned = $obj->duration_planned;
$this->date_c = $this->db->jdate($obj->datec);
$this->date_start = $this->db->jdate($obj->dateo);
$this->date_end = $this->db->jdate($obj->datee);
@ -254,6 +259,7 @@ class Task extends CommonObject
if (isset($this->label)) $this->label=trim($this->label);
if (isset($this->description)) $this->description=trim($this->description);
if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective);
if (isset($this->duration_planned)) $this->duration_planned=trim($this->duration_planned);
// Check parameters
// Put here code to add control on parameters values
@ -265,6 +271,7 @@ class Task extends CommonObject
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
$sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").",";
$sql.= " duration_planned=".(isset($this->duration_planned)?$this->duration_planned:"0").",";
$sql.= " dateo=".($this->date_start!=''?$this->db->idate($this->date_start):'null').",";
$sql.= " datee=".($this->date_end!=''?$this->db->idate($this->date_end):'null').",";
$sql.= " progress=".$this->progress;
@ -524,7 +531,7 @@ class Task extends CommonObject
// List of tasks (does not care about permissions. Filtering will be done later)
$sql = "SELECT p.rowid as projectid, p.ref, p.title as plabel, p.public,";
$sql.= " t.rowid as taskid, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress,";
$sql.= " t.dateo as date_start, t.datee as date_end";
$sql.= " t.dateo as date_start, t.datee as date_end, t.duration_planned";
if ($mode == 0)
{
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
@ -586,6 +593,7 @@ class Task extends CommonObject
$tasks[$i]->description = $obj->description;
$tasks[$i]->fk_parent = $obj->fk_task_parent;
$tasks[$i]->duration = $obj->duration_effective;
$tasks[$i]->duration_planned= $obj->duration_planned;
$tasks[$i]->progress = $obj->progress;
$tasks[$i]->public = $obj->public;
$tasks[$i]->date_start = $this->db->jdate($obj->date_start);
@ -997,6 +1005,7 @@ class Task extends CommonObject
$clone_task->fk_project = $project_id;
$clone_task->fk_task_parent = $parent_task_id;
$clone_task->date_c = $datec;
$clone_task->duration_planned = $clone_task->duration_planned;
//Manage Task Date
if ($clone_change_dt)

View File

@ -1,21 +1,21 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/projet/index.php
@ -44,7 +44,7 @@ $sortorder = GETPOST("sortorder",'alpha');
/*
* View
*/
*/
$socstatic=new Societe($db);
$projectstatic=new Project($db);
@ -132,10 +132,82 @@ else
}
print "</table>";
print '</td></tr></table>';
print '</div></div></div>';
print '<div class="fichecenter">';
print '<BR>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
print '<th>'.$langs->trans('Projects').'</th>';
print '<th>'.$langs->trans('Task').'</th>';
print '<th>'.$langs->trans('DateStart').'</th>';
print '<th>'.$langs->trans('DateEnd').'</th>';
print '<th>'.$langs->trans('TaskRessourceLinks').' %</th>';
print '</tr>';
$sql = "SELECT p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.duration_planned, t.dateo, t.datee, (tasktime.task_duration/3600) as totaltime";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " ORDER BY u.rowid, t.dateo, t.datee";
$userstatic=new User($db);
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
$username='';
$userstatic->fetch($obj->userid);
if (!empty($userstatic->id)) {
$username = $userstatic->getNomUrl(0,0);
}
print "<tr $bc[$var]>";
print '<td>'.$username.'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id="'.$obj->projectid.'">'.$obj->title.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>';
print '<td>'.dol_print_date($db->jdate($obj->dateo)).'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datee)).'</td>';
if (empty($obj->duration_planned)) {
$percentcompletion = '0';
} else {
$percentcompletion = intval(($obj->totaltime*100)/$obj->duration_planned);
}
print '<td>'.$percentcompletion.' %</td>';
print "</tr>\n";
$i++;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print "</table></div>";
llxFooter();
$db->close();

View File

@ -71,6 +71,7 @@ $hookmanager->initHooks(array('projecttaskcard'));
$progress=GETPOST('progress', 'int');
$label=GETPOST('label', 'alpha');
$description=GETPOST('description');
$duration_planned=GETPOST('duration_planned');
$userAccess=0;
@ -115,6 +116,7 @@ if ($action == 'createtask' && $user->rights->projet->creer)
$task->fk_project = $projectid;
$task->label = $label;
$task->description = $description;
$task->duration_planned = $duration_planned;
$task->fk_task_parent = $task_parent;
$task->date_c = dol_now();
$task->date_start = $date_start;
@ -292,6 +294,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
print $form->select_date(($date_end?$date_end:-1),'datee',0,0,0,'',1,1);
print '</td></tr>';
// Duration planned
print '<tr><td>'.$langs->trans("Duration").'</td><td>';
print '<input type="text" size="7" name="duration_planned" class="flat" value="'.$duration_planned.'"> '.$langs->trans('Hours');
print '</td></tr>';
// Progress
print '<tr><td>'.$langs->trans("Progress").'</td><td colspan="3">';
print $formother->select_percent($progress,'progress');
@ -391,6 +398,7 @@ else
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="right">'.$langs->trans("Duration").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td>&nbsp;</td>';

View File

@ -100,6 +100,7 @@ print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="center">'.$langs->trans("Duration").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n";

View File

@ -36,6 +36,7 @@ $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$withproject=GETPOST('withproject','int');
$project_ref=GETPOST('project_ref','alpha');
$duration_planned=GETPOST('duration_planned');
// Security check
$socid=0;
@ -75,6 +76,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
$object->label = $_POST["label"];
$object->description = $_POST['description'];
$object->fk_task_parent = $task_parent;
$object->duration_planned = $duration_planned;
$object->date_start = dol_mktime(0,0,0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']);
$object->date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']);
$object->progress = $_POST['progress'];
@ -283,6 +285,11 @@ if ($id > 0 || ! empty($ref))
print $form->select_date($object->date_end?$object->date_end:-1,'datee');
print '</td></tr>';
// Duration planned
print '<tr><td>'.$langs->trans("Duration").'</td><td>';
print '<input type="text" size="7" name="duration_planned" class="flat" value="'.$object->duration_planned.'"> '.$langs->trans('Hours');
print '</td></tr>';
// Progress
print '<tr><td>'.$langs->trans("Progress").'</td><td colspan="3">';
print $formother->select_percent($object->progress,'progress');
@ -368,6 +375,11 @@ if ($id > 0 || ! empty($ref))
print dol_print_date($object->date_end,'day');
print '</td></tr>';
// Duration planned
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
print $object->duration_planned.' '.$langs->trans('Hours');
print '</td></tr>';
// Progress
print '<tr><td>'.$langs->trans("Progress").'</td><td colspan="3">';
print $object->progress.' %';

View File

@ -264,6 +264,9 @@ if ($id > 0 || ! empty($ref))
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->label.'</td></tr>';
// Duration planned
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">'.$object->duration_planned.' '.$langs->trans('Hours').'</td></tr>';
// Project
if (empty($withproject))
{