Qual: Uniformize translated label of progress on all pages.

Fix: Color of first line of documents.
Fix: The calculated progress was not calculated.
This commit is contained in:
Laurent Destailleur 2014-10-12 01:04:34 +02:00
parent 6c3c1d3a0a
commit 2b479aa0b4
9 changed files with 112 additions and 33 deletions

View File

@ -3987,7 +3987,7 @@ class Form
{
print '<input type="text" size="3" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').' class="flat" value="'.((int) $hourSelected).'">';
}
print $langs->trans('Hours');
print ' '.$langs->trans('HourShort');
if ($minunderhours) print '<br>';
else print "&nbsp;";
@ -4000,7 +4000,7 @@ class Form
print '>'.$min.'</option>';
}
print "</select>";
print $langs->trans('Minutes'). "&nbsp;";
print ' '.$langs->trans('MinuteShort'). "&nbsp;";
}

View File

@ -629,7 +629,7 @@ class FormFile
if (count($file_list) == 0 && $headershown)
{
$out.='<tr><td colspan="3">'.$langs->trans("None").'</td></tr>';
$out.='<tr '.$bc[0].'><td colspan="3">'.$langs->trans("None").'</td></tr>';
}
$this->numoffiles++;
@ -1150,7 +1150,7 @@ class FormFile
$nboflinks = count($links);
if ($nboflinks > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$var = true;
$var = false;
foreach ($links as $link)
{
$var =! $var;

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
@ -455,12 +455,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
*/
function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask=0)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
global $db, $user, $bc, $langs;
global $form, $projectstatic, $taskstatic;
global $form, $formother, $projectstatic, $taskstatic;
$formother = new FormOther($db);
if (! is_object($formother))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$formother = new FormOther($db);
}
$lastprojectid=0;

View File

@ -266,6 +266,7 @@ Afternoon=Afternoon
Quadri=Quadri
MonthOfDay=Month of the day
HourShort=H
MinuteShort=mn
Rate=Rate
UseLocalTax=Include tax
Bytes=Bytes

View File

@ -179,7 +179,7 @@ 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="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
print "</tr>\n";

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
@ -141,8 +141,9 @@ class Task extends CommonObject
}
}
//Update extrafield
if (!$error) {
// Update extrafield
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
@ -816,6 +817,47 @@ class Task extends CommonObject
return $ret;
}
/**
* Calculate total of time spent for task
*
* @param int $id Id of object (here task)
* @return array Array of info for task array('min_date', 'max_date', 'total_duration')
*/
function getSummaryOfTimeSpent($id='')
{
global $langs;
if (empty($id)) $id=$this->id;
$result=array();
$sql = "SELECT";
$sql.= " MIN(t.task_datehour) as min_date,";
$sql.= " MAX(t.task_datehour) as max_date,";
$sql.= " SUM(t.task_duration) as total_duration";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql.= " WHERE t.fk_task = ".$id;
dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$result['min_date'] = $obj->min_date;
$result['max_date'] = $obj->max_date;
$result['total_duration'] = $obj->total_duration;
$this->db->free($resql);
return $result;
}
else
{
dol_print_error($this->db);
return $result;
}
}
/**
* Load object in memory from database
*

View File

@ -320,7 +320,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
print '</td></tr>';
// Progress
print '<tr><td>'.$langs->trans("Progress").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
print $formother->select_percent($progress,'progress');
print '</td></tr>';

View File

@ -351,8 +351,8 @@ if ($id > 0 || ! empty($ref))
print $form->select_duration('planned_workload',$object->planned_workload,0,'text');
print '</td></tr>';
// Progress
print '<tr><td>'.$langs->trans("Progress").'</td><td colspan="3">';
// Progress declared
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
print $formother->select_percent($object->progress,'progress');
print '</td></tr>';
@ -383,7 +383,7 @@ if ($id > 0 || ! empty($ref))
{
/*
* Fiche tache en mode visu
*/
*/
$param=($withproject?'&withproject=1':'');
$linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
@ -440,14 +440,20 @@ if ($id > 0 || ! empty($ref))
print convertSecondToTime($object->planned_workload,'allhourmin');
print '</td></tr>';
// Progress
// Progress declared
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
print $object->progress.' %';
print '</td></tr>';
// Progress
// Progress calculated
print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
print $object->progress.' %';
if ($object->planned_workload)
{
$tmparray=$object->getSummaryOfTimeSpent();
if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %';
else print '0 %';
}
else print '';
print '</td></tr>';
// Description
@ -504,7 +510,7 @@ if ($id > 0 || ! empty($ref))
/*
* Documents generes
*/
*/
$filename=dol_sanitizeFileName($projectstatic->ref). "/". dol_sanitizeFileName($object->ref);
$filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($projectstatic->ref). "/" .dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
@ -181,7 +181,7 @@ if (! empty($project_ref) && ! empty($withproject))
/*
* View
*/
*/
llxHeader("",$langs->trans("Task"));
@ -193,7 +193,7 @@ if ($id > 0 || ! empty($ref))
{
/*
* Fiche projet en mode visu
*/
*/
if ($object->fetch($id) >= 0)
{
$result=$projectstatic->fetch($object->fk_project);
@ -292,9 +292,37 @@ if ($id > 0 || ! empty($ref))
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->label.'</td></tr>';
// Planned workload
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">'.convertSecondToTime($object->planned_workload,'allhourmin').'</td></tr>';
// Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="3">';
print dol_print_date($object->date_start,'dayhour');
print '</td></tr>';
// Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td colspan="3">';
print dol_print_date($object->date_end,'dayhour');
print '</td></tr>';
// Planned workload
print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td colspan="3">';
print convertSecondToTime($object->planned_workload,'allhourmin');
print '</td></tr>';
// Progress declared
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
print $object->progress.' %';
print '</td></tr>';
// Progress calculated
print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
if ($object->planned_workload)
{
$tmparray=$object->getSummaryOfTimeSpent();
if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %';
else print '0 %';
}
else print '';
print '</td></tr>';
// Project
if (empty($withproject))
{
@ -316,7 +344,7 @@ if ($id > 0 || ! empty($ref))
/*
* Add time spent
*/
*/
if ($user->rights->projet->creer)
{
print '<br>';
@ -333,7 +361,7 @@ if ($id > 0 || ! empty($ref))
print '<td width="100">'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("By").'</td>';
print '<td>'.$langs->trans("Note").'</td>';
print '<td>'.$langs->trans("Progress").'</td>';
print '<td>'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right">'.$langs->trans("Duration").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
@ -363,14 +391,14 @@ if ($id > 0 || ! empty($ref))
print '<textarea name="timespent_note" cols="80" rows="'.ROWS_3.'">'.($_POST['timespent_note']?$_POST['timespent_note']:'').'</textarea>';
print '</td>';
// Progress
// Progress declared
print '<td class="nowrap">';
print $formother->select_percent($object->progress,'progress');
print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress');
print '</td>';
// Duration
print '<td class="nowrap" align="right">';
print $form->select_duration('timespent_duration',($_POST['timespent_duration']?$_POST['timespent_duration']:''),0,'text');
print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text');
print '</td>';
print '<td align="center">';
@ -384,7 +412,7 @@ if ($id > 0 || ! empty($ref))
/*
* List of time spent
*/
*/
$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
$sql.= ", u.lastname, u.firstname";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";