[evolvis-commits] r18674: [#3324] Add "Hours Worked" as display column

mirabilos at evolvis.org mirabilos at evolvis.org
Tue Oct 2 16:06:48 CEST 2012


Author: mirabilos
Date: 2012-10-02 16:06:47 +0200 (Tue, 02 Oct 2012)
New Revision: 18674

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/pm/ProjectTask.class.php
   trunk/gforge_base/evolvisforge-5.1/src/www/pm/browse_task.php
   trunk/gforge_base/evolvisforge-5.1/src/www/pm/include/pm_columns.php
Log:
[#3324] Add "Hours Worked" as display column

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/pm/ProjectTask.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/pm/ProjectTask.class.php	2012-10-02 14:06:41 UTC (rev 18673)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/pm/ProjectTask.class.php	2012-10-02 14:06:47 UTC (rev 18674)
@@ -1264,6 +1264,25 @@
 		return true;
 	}
 
+	function getHoursWorked($user=0) {
+		$qpa = db_construct_qpa();
+		$qpa = db_construct_qpa($qpa,
+		    'SELECT SUM(hours) AS hrs FROM rep_time_tracking
+			WHERE project_task_id=$1',
+		    array($this->data_array['project_task_id']));
+		if ($user) {
+			$qpa = db_construct_qpa($qpa,
+			    ' AND user_id=$1',
+			    array($user));
+		}
+		$res = db_query_qpa($qpa);
+		if (!$res || db_numrows($res) < 1) {
+			return 0;
+		}
+		$rv = db_result($res, 0, 'hrs');
+		db_free_result($res);
+		return $rv;
+	}
 }
 
 // Local Variables:

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/pm/browse_task.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/pm/browse_task.php	2012-10-02 14:06:41 UTC (rev 18673)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/pm/browse_task.php	2012-10-02 14:06:47 UTC (rev 18674)
@@ -255,6 +255,7 @@
 $parentId = pm_ispref("parentId");
 $details = pm_ispref("details");
 $hours = pm_ispref("hours");
+$hworked = pm_ispref("hworked");
 $statusId = pm_ispref("statusId");
 $categoryId = pm_ispref("categoryId");
 $lastModifiedDate = pm_ispref("lastModDat");
@@ -385,6 +386,7 @@
 		'parent_id'          => ($parentId ? true : false),
 		'details'            => ($details ? true : false),
 		'hours'              => ($hours ? true : false),
+		'hworked'            => ($hworked ? true : false),
 		'status_id'          => ($statusId ? true : false),
 		'category_id'        => ($categoryId ? true : false),
 		'last_modified_date' => ($lastModifiedDate ? true : false),
@@ -425,6 +427,8 @@
 		$title_arr[]=_('Details');
 	if ($display_col['hours'])
 		$title_arr[]=_('Estimated Hours');
+	if ($display_col['hworked'])
+		$title_arr[]=_('Hours Worked');
 	if ($display_col['status_id'])
 		$title_arr[]=_('Status Id');
 	if ($display_col['category_id'])
@@ -532,6 +536,13 @@
 			echo '<td class="separateRowsForPrinting">'. util_html_secure($pt_arr[$i]->getDetails()) .'</td>';
 		if ($display_col['hours'])
 			echo '<td class="separateRowsForPrinting">'. util_html_secure($pt_arr[$i]->getHours()) .'</td>';
+		if ($display_col['hworked']) {
+			$hw = $pt_arr[$i]->getHoursWorked();
+			$fw = $hw - (int)$hw;
+			echo '<td class="separateRowsForPrinting">' .
+			    sprintf(($fw == 0) ? "%d" :
+			    (($fw == 0.5) ? "%.1f" : "%.2f"), $hw) . '</td>';
+		}
 		if ($display_col['status_id'])
 			echo '<td class="separateRowsForPrinting">'. util_html_secure($pt_arr[$i]->getStatusID()) .'</td>';
 		if ($display_col['category_id'])

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/pm/include/pm_columns.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/pm/include/pm_columns.php	2012-10-02 14:06:41 UTC (rev 18673)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/pm/include/pm_columns.php	2012-10-02 14:06:47 UTC (rev 18674)
@@ -42,6 +42,7 @@
 	array("parentId", 0, _('Parent Id')),
 	array("details", 0, _('Details')),
 	array("hours", 0, _('Estimated Hours')),
+	array("hworked", 0, _('Hours Worked')),
 	array("statusId", 0, _('Status Id')),
 	array("categoryId", 0, _('Category Id')),
 	array("lastModDat", 0, _('Last Modified Date')),



More information about the evolvis-commits mailing list