5 * Copyright 2004 (c) GForge LLC
8 * @author Tim Perdue tim@gforge.org
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 require_once('../env.inc.php');
29 require_once('pre.php');
30 require_once('common/reporting/report_utils.php');
31 require_once('common/reporting/Report.class');
33 if (!session_loggedin()) {
40 if ($report->isError()) {
41 exit_error('Error',$report->getErrorMessage());
44 $week = getStringFromRequest('week');
45 $project_task_id = getStringFromRequest('project_task_id');
47 if (getStringFromRequest('submit')) {
48 $report_date = getStringFromRequest('report_date');
49 $time_code = getStringFromRequest('time_code');
50 $old_time_code = getStringFromRequest('old_time_code');
51 $hours = getStringFromRequest('hours');
54 if (getStringFromRequest('update')) {
56 if ($project_task_id && $report_date && $time_code) {
57 $res=db_query("UPDATE rep_time_tracking
58 SET time_code='$time_code', hours='$hours'
59 WHERE user_id='".user_getid()."'
60 AND report_date='$report_date'
61 AND project_task_id='$project_task_id'
62 AND time_code='$old_time_code'");
63 if (!$res || db_affected_rows($res) < 1) {
64 exit_error('Error',db_error());
66 $feedback='Successfully Updated';
72 if (getStringFromRequest('delete')) {
73 if ($project_task_id && $report_date && $old_time_code) {
74 $res=db_query("DELETE FROM rep_time_tracking
75 WHERE user_id='".user_getid()."'
76 AND report_date='$report_date'
77 AND project_task_id='$project_task_id'
78 AND time_code='$old_time_code'");
79 if (!$res || db_affected_rows($res) < 1) {
80 exit_error('Error',db_error());
82 $feedback=_('Successfully Deleted');
85 echo "$project_task_id && $report_date && $old_time_code";
88 } elseif (getStringFromRequest('add')) {
89 $days_adjust = getStringFromRequest('days_adjust');
91 if ($project_task_id && $week && $days_adjust && $time_code && $hours) {
93 //$date_list = split('[- :]',$report_date,5);
94 //$report_date = mktime($date_list[3],$date_list[4],0,$date_list[1],$date_list[2],$date_list[0]);
95 //make it 12 NOON of the report_date
96 $report_date=($week + ($days_adjust*REPORT_DAY_SPAN))+(12*60*60);
97 $res=db_query("INSERT INTO rep_time_tracking (user_id,week,report_date,project_task_id,time_code,hours)
98 VALUES ('".user_getid()."','$week','$report_date','$project_task_id','$time_code','$hours')");
99 if (!$res || db_affected_rows($res) < 1) {
100 exit_error('Error',db_error());
102 $feedback.=_('Successfully Added');
105 echo "$project_task_id && $week && $days_adjust && $time_code && $hours";
106 exit_error('Error',_('All Fields Are Required.'));
113 $group_project_id = getStringFromRequest('group_project_id');
115 report_header(_('Time Tracking'));
117 if (!$group_project_id) {
118 if ( $sys_database_type == "mysql" ) {
119 $sql="SELECT pgl.group_project_id,CONCAT(g.group_name, '**', pgl.project_name)
121 $sql="SELECT pgl.group_project_id,g.group_name || '**' || pgl.project_name ";
124 FROM groups g, project_group_list pgl, user_group ug
125 WHERE ug.user_id='".user_getid()."'
126 AND ug.group_id=g.group_id
127 AND g.group_id=pgl.group_id
128 ORDER BY group_name,project_name";
129 $respm=db_query($sql);
132 <h3><?php echo $Language->getText('reporting_ta','time_entries',date('Y-m-d',$week)); ?></h3>
135 if ( $sys_database_type == "mysql" ) {
136 $sql="SELECT pt.project_task_id, CONCAT(pgl.project_name, '**', pt.summary) AS name,
138 $sql="SELECT pt.project_task_id, pgl.project_name || '**' || pt.summary AS name, ";
141 rtt.hours, rtt.report_date, rtc.category_name, rtt.time_code
142 FROM groups g, project_group_list pgl, project_task pt, rep_time_tracking rtt,
143 rep_time_category rtc
144 WHERE rtt.week='$week'
145 AND rtt.time_code=rtc.time_code
146 AND rtt.user_id='".user_getid()."'
147 AND g.group_id=pgl.group_id
148 AND pgl.group_project_id=pt.group_project_id
149 AND pt.project_task_id=rtt.project_task_id
150 ORDER BY rtt.report_date";
153 $rows=db_numrows($res);
154 if ($group_project_id || $rows) {
156 $title_arr[]=_('Project/Task');
157 $title_arr[]=_('Date');
158 $title_arr[]=_('Hours');
159 $title_arr[]=_('Category');
162 echo $HTML->listTableTop ($title_arr);
164 while ($r=&db_fetch_array($res)) {
165 echo '<form action="'.getStringFromServer('PHP_SELF').'?week='.$week.'&project_task_id='.$r['project_task_id'].'" method="post" />
166 <input type="hidden" name="submit" value="1" />
167 <input type="hidden" name="report_date" value="'.$r['report_date'] .'" />
168 <input type="hidden" name="old_time_code" value="'.$r['time_code'] .'" />
169 <tr '.$HTML->boxGetAltRowStyle($xi++).'>
170 <td align="middle">'.$r['name'].'</td>
171 <td align="middle">'. date( 'D, M d, Y',$r['report_date']) .'</td>
172 <td align="middle"><!-- <input type="text" name="hours" value="'. $r['hours'] .'" size="3" maxlength="3" /> -->'.$r['hours'].'</td>
173 <td align="middle"><!-- '.report_time_category_box('time_code',$r['time_code']).' -->'.$r['category_name'].'</td>
174 <td align="middle"><!-- <input type="submit" name="update" value="Update" /> -->
175 <input type="submit" name="delete" value="'. _('Delete').'" /></td>
177 $total_hours += $r['hours'];
179 if ($group_project_id) {
181 $respt=db_query("SELECT project_task_id,summary FROM project_task WHERE group_project_id='$group_project_id'");
183 echo '<form action="'.getStringFromServer('PHP_SELF').'?week='.$week.'" method="post" />
184 <input type="hidden" name="submit" value="1" />
185 <tr '.$HTML->boxGetAltRowStyle($xi++).'>
186 <td align="middle">'. html_build_select_box ($respt,'project_task_id',false,false) .'</td>
187 <td align="middle"><input type="text" name="report_date" value="'. date('Y-m-d',$week) .'" size="10" maxlength="10" /></td>
188 <td align="middle"><input type="text" name="hours" value="" size="3" maxlength="3" /></td>
189 <td align="middle">'.report_time_category_box('time_code',false).'</td>
190 <td align="middle"><input type="submit" name="add" value="'.
191 _('Add').'" /><input type="submit" name="cancel" value="'._('Cancel').'" /></td>
195 echo '<tr '.$HTML->boxGetAltRowStyle($xi++).'><td colspan="2"><strong>'._('Total Hours').':</strong></td><td><strong>'.$total_hours.'</strong></td><td colspan="2"></td></tr>';
196 echo $HTML->listTableBottom();
199 if (!$group_project_id) {
202 <h3><?php echo _('Add Entry'); ?></h3>
204 <?php echo _('Choose a Project/Subproject in the Task Manager. You will then have to choose a Task and category to record your time in.'); ?>
206 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get" />
207 <input type="hidden" name="week" value="<?php echo $week; ?>" />
210 <td><strong><?php echo _('Task Manager Project'); ?>:</strong></td>
211 <td><?php echo html_build_select_box ($respm,'group_project_id',false,false); ?></td>
212 <td><input type="submit" name="submit" value="<?php echo _('Next'); ?>" /></td>
219 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get" />
220 <?php echo report_weeks_box($report,'week'); ?><input type="submit" name="submit" value="<?php echo _('Change Week'); ?>" />
225 // First Choose A Week to add/update/delete time sheet info
229 report_header(_('Time Tracking'));
232 <h3><?php echo _('Choose A Week to Record Or Edit Your Time.'); ?></h3>
234 <?php echo _('After you choose a week, you will be prompted to choose a Project/Subproject in the Task Manager.'); ?>
236 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get" />
237 <strong><?php echo _('Week Starting'); ?>:</strong><br />
238 <?php echo report_weeks_box($report,'week'); ?>
240 <input type="submit" name="submit" value="<?php echo _('Next'); ?>" />