5 * Copyright 2003-2004 (c) GForge LLC
6 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
7 * Copyright 2016, Franck Villaume - TrivialDev
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'reporting/report_utils.php';
29 require_once $gfcommon.'reporting/ReportSetup.class.php';
31 session_require_global_perm ('forge_stats', 'admin') ;
33 $time_code = getIntFromRequest('time_code');
34 $category_name = trim(getStringFromRequest('category_name'));
36 if (getStringFromRequest('submit')) {
37 if (getStringFromRequest('add')) {
39 $r = new ReportSetup();
40 if (!$r->addTimeCode($category_name)) {
41 $error_msg = $r->getErrorMessage();
43 $feedback = _('Successfully Added');
46 } elseif (getStringFromRequest('update')) {
48 $r = new ReportSetup();
50 if (!$r->updateTimeCode($time_code,$category_name)) {
51 $error_msg = $r->getErrorMessage();
53 $feedback = _('Successfully Updated');
61 report_header(_('Manage Time Tracker Categories'));
64 $res1=db_query_params ('SELECT * FROM rep_time_category WHERE time_code=$1',
66 $category_name=db_result($res1,0,'category_name');
68 $res = db_query_params('SELECT * FROM rep_time_category ORDER BY time_code', array());
70 $arr[]=_('Time Code');
71 $arr[]=_('Category Name');
73 echo $HTML->listTableTop($arr);
75 for ($i=0; $i<db_numrows($res); $i++) {
76 echo '<tr><td>'.db_result($res,$i,'time_code').'</td>
77 <td><a href="timecategory.php?time_code='.db_result($res,$i,'time_code').'">'.db_result($res,$i,'category_name').'</a></td></tr>';
80 echo $HTML->listTableBottom();
84 <?php echo _('You can create categories for how time might be spent when completing a particular task. Examples of categories include “Meeting”, “Coding”, “Testing”.'); ?>
86 <?php echo $HTML->openForm(array('action' => getStringFromServer('PHP_SELF'), 'method' => 'post')); ?>
88 <input type="hidden" name="submit" value="1" />
89 <input type="hidden" name="time_code" value="<?php echo $time_code; ?>" />
90 <label for="category_name">
91 <strong><?php echo _('Category Name')._(':'); ?></strong><br />
92 <input required="required" type="text" id="category_name" name="category_name"
93 value="<?php echo $category_name; ?>" />
100 echo '<input type="submit" name="update" value="'._('Update').'" />';
102 echo '<input type="submit" name="add" value="'._('Add').'" />';
108 echo $HTML->closeForm();
114 // c-file-style: "bsd"