Better code quality for [ task #531 ] Add a duration on tasks
This commit is contained in:
parent
b280bff809
commit
be525ad0e8
@ -3518,10 +3518,13 @@ class Form
|
||||
* @param string $prefix prefix
|
||||
* @param int $iSecond Default preselected duration (number of seconds)
|
||||
* @param int $disabled Disable the combo box
|
||||
* @param string $typehour if select then hour in select if text input in text
|
||||
* @return void
|
||||
*/
|
||||
function select_duration($prefix,$iSecond='',$disabled=0)
|
||||
function select_duration($prefix,$iSecond='',$disabled=0,$typehour='select')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if ($iSecond)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
@ -3529,19 +3532,27 @@ class Form
|
||||
$hourSelected = convertSecondToTime($iSecond,'hour');
|
||||
$minSelected = convertSecondToTime($iSecond,'min');
|
||||
}
|
||||
|
||||
print '<select class="flat" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').'>';
|
||||
for ($hour = 0; $hour < 24; $hour++)
|
||||
|
||||
if ($typehour=='select')
|
||||
{
|
||||
print '<option value="'.$hour.'"';
|
||||
if ($hourSelected == $hour)
|
||||
{
|
||||
print " selected=\"true\"";
|
||||
}
|
||||
print ">".$hour."</option>";
|
||||
print '<select class="flat" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').'>';
|
||||
for ($hour = 0; $hour < 24; $hour++)
|
||||
{
|
||||
print '<option value="'.$hour.'"';
|
||||
if ($hourSelected == $hour)
|
||||
{
|
||||
print " selected=\"true\"";
|
||||
}
|
||||
print ">".$hour."</option>";
|
||||
}
|
||||
print "</select>";
|
||||
}
|
||||
print "</select>";
|
||||
print "H ";
|
||||
elseif ($typehour=='text')
|
||||
{
|
||||
$fullhours=convertSecondToTime($iSecond,'fullhour');
|
||||
print '<input type="text" size="3" name="'.$prefix.'hour" class="flat" value="'.$fullhours.'">';
|
||||
}
|
||||
print $langs->trans('Hours'). " ";
|
||||
print '<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').'>';
|
||||
for ($min = 0; $min <= 55; $min=$min+5)
|
||||
{
|
||||
@ -3550,7 +3561,7 @@ class Form
|
||||
print '>'.$min.'</option>';
|
||||
}
|
||||
print "</select>";
|
||||
print "M ";
|
||||
print $langs->trans('Minutes'). " ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -287,6 +287,16 @@ function convertSecondToTime($iSecond,$format='all',$lengthOfDay=86400,$lengthOf
|
||||
{
|
||||
$sTime=dol_print_date($iSecond,'%H',true);
|
||||
}
|
||||
else if ($format == 'fullhour')
|
||||
{
|
||||
if (!empty($iSecond)) {
|
||||
$iSecond=$iSecond/3600;
|
||||
}
|
||||
else {
|
||||
$iSecond=0;
|
||||
}
|
||||
$sTime=$iSecond;
|
||||
}
|
||||
else if ($format == 'min')
|
||||
{
|
||||
$sTime=dol_print_date($iSecond,'%M',true);
|
||||
|
||||
@ -422,12 +422,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
|
||||
// Planned Workload
|
||||
print '<td align="center">';
|
||||
if (!empty($lines[$i]->planned_workload)) {
|
||||
$planned_workload_hours = intval($lines[$i]->planned_workload / 3600);
|
||||
}else {
|
||||
$planned_workload_hours = 0;
|
||||
}
|
||||
print $planned_workload_hours.' '.$langs->trans('Hours');
|
||||
if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'all');
|
||||
else print '--:--';
|
||||
print '</td>';
|
||||
|
||||
// Progress
|
||||
|
||||
@ -164,6 +164,7 @@ $sql.= " ORDER BY u.rowid, t.dateo, t.datee";
|
||||
|
||||
$userstatic=new User($db);
|
||||
|
||||
dol_syslog('projet:index.php: affectationpercent sql='.$sql,LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ( $resql )
|
||||
{
|
||||
@ -192,7 +193,7 @@ if ( $resql )
|
||||
} else {
|
||||
$percentcompletion = intval(($obj->task_duration*100)/$obj->planned_workload);
|
||||
}
|
||||
print '<td>'.$percentcompletion.' %</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">'.$percentcompletion.' %</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
|
||||
@ -71,7 +71,7 @@ $hookmanager->initHooks(array('projecttaskcard'));
|
||||
$progress=GETPOST('progress', 'int');
|
||||
$label=GETPOST('label', 'alpha');
|
||||
$description=GETPOST('description');
|
||||
$planned_workload=GETPOST('planned_workload');
|
||||
$planned_workload=GETPOST('planned_workloadhour');
|
||||
|
||||
$userAccess=0;
|
||||
|
||||
@ -294,14 +294,9 @@ 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
|
||||
// planned workload
|
||||
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
|
||||
if (!empty($object->planned_workload)) {
|
||||
$planned_workload_hours = intval($object->planned_workload / 3600);
|
||||
}else {
|
||||
$planned_workload_hours = 0;
|
||||
}
|
||||
print '<input type="text" size="7" name="planned_workload" class="flat" value="'.$planned_workload.'"> '.$langs->trans('Hours');
|
||||
print $form->select_duration('planned_workload',$object->planned_workload,0,'text');
|
||||
print '</td></tr>';
|
||||
|
||||
// Progress
|
||||
@ -403,7 +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("PlannedWorkload").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PlannedWorkload").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Progress").'</td>';
|
||||
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
|
||||
print '<td> </td>';
|
||||
|
||||
@ -109,7 +109,7 @@ print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" class="flat" name="search_project" value="'.$search_project.'" size="8">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" colspan="5">';
|
||||
print '<td class="liste_titre" colspan="6">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
|
||||
|
||||
@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
$id=GETPOST('id','int');
|
||||
$ref=GETPOST('ref','alpha');
|
||||
@ -36,7 +37,7 @@ $action=GETPOST('action','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$withproject=GETPOST('withproject','int');
|
||||
$project_ref=GETPOST('project_ref','alpha');
|
||||
$planned_workload=GETPOST('planned_workload');
|
||||
$planned_workload=GETPOST('planned_workloadhour');
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
@ -285,14 +286,9 @@ if ($id > 0 || ! empty($ref))
|
||||
print $form->select_date($object->date_end?$object->date_end:-1,'datee');
|
||||
print '</td></tr>';
|
||||
|
||||
// Duration planned
|
||||
// workload planned
|
||||
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
|
||||
if (!empty($object->planned_workload)) {
|
||||
$planned_workload_hours = intval($object->planned_workload / 3600);
|
||||
}else {
|
||||
$planned_workload_hours = 0;
|
||||
}
|
||||
print '<input type="text" size="7" name="planned_workload" class="flat" value="'.$planned_workload_hours.'"> '.$langs->trans('Hours');
|
||||
print $form->select_duration('planned_workload',$object->planned_workload,0,'text');
|
||||
print '</td></tr>';
|
||||
|
||||
// Progress
|
||||
@ -380,14 +376,9 @@ if ($id > 0 || ! empty($ref))
|
||||
print dol_print_date($object->date_end,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
// Duration planned
|
||||
// planned Workload
|
||||
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">';
|
||||
if (!empty($object->planned_workload)) {
|
||||
$planned_workload_hours = intval($object->planned_workload / 3600);
|
||||
}else {
|
||||
$planned_workload_hours = 0;
|
||||
}
|
||||
print $planned_workload_hours.' '.$langs->trans('Hours');
|
||||
print convertSecondToTime($object->planned_workload,'all');
|
||||
print '</td></tr>';
|
||||
|
||||
// Progress
|
||||
|
||||
@ -56,7 +56,9 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
|
||||
{
|
||||
$error=0;
|
||||
|
||||
if (empty($_POST["timespent_durationhour"]) && empty($_POST["timespent_durationmin"]))
|
||||
$timespent_durationhour = GETPOST('timespent_durationhour','int');
|
||||
$timespent_durationmin = GETPOST('timespent_durationmin','int');
|
||||
if (empty($timespent_durationhour) && empty($timespent_durationmin))
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>';
|
||||
$error++;
|
||||
@ -264,13 +266,8 @@ if ($id > 0 || ! empty($ref))
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->label.'</td></tr>';
|
||||
|
||||
// Duration planned
|
||||
if (!empty($object->planned_workload)) {
|
||||
$planned_workload_hours = intval($object->planned_workload / 3600);
|
||||
}else {
|
||||
$planned_workload_hours = 0;
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">'.$planned_workload_hours.' '.$langs->trans('Hours').'</td></tr>';
|
||||
// planned workload
|
||||
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">'.convertSecondToTime($object->planned_workload,'all').'</td></tr>';
|
||||
|
||||
// Project
|
||||
if (empty($withproject))
|
||||
@ -336,7 +333,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Duration
|
||||
print '<td class="nowrap" align="right">';
|
||||
print $form->select_duration('timespent_duration',($_POST['timespent_duration']?$_POST['timespent_duration']:''));
|
||||
print $form->select_duration('timespent_duration',($_POST['timespent_duration']?$_POST['timespent_duration']:''),0,'text');
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center">';
|
||||
@ -443,7 +440,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
|
||||
{
|
||||
print '<input type="hidden" name="old_duration" value="'.$task_time->task_duration.'">';
|
||||
print $form->select_duration('new_duration',$task_time->task_duration);
|
||||
print $form->select_duration('new_duration',$task_time->task_duration,0,'text');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user