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 $respm=db_query("SELECT pgl.group_project_id,g.group_name || '**' || pgl.project_name
119 FROM groups g, project_group_list pgl, user_group ug
120 WHERE ug.user_id='".user_getid()."'
121 AND ug.group_id=g.group_id
122 AND g.group_id=pgl.group_id
123 ORDER BY group_name,project_name");
126 <h3><?php echo $Language->getText('reporting_ta','time_entries',date('Y-m-d',$week)); ?></h3>
129 $res=db_query("SELECT pt.project_task_id, pgl.project_name || '**' || pt.summary AS name,
130 rtt.hours, rtt.report_date, rtc.category_name, rtt.time_code
131 FROM groups g, project_group_list pgl, project_task pt, rep_time_tracking rtt,
132 rep_time_category rtc
133 WHERE rtt.week='$week'
134 AND rtt.time_code=rtc.time_code
135 AND rtt.user_id='".user_getid()."'
136 AND g.group_id=pgl.group_id
137 AND pgl.group_project_id=pt.group_project_id
138 AND pt.project_task_id=rtt.project_task_id
139 ORDER BY rtt.report_date");
140 $rows=db_numrows($res);
141 if ($group_project_id || $rows) {
143 $title_arr[]=_('Project/Task');
144 $title_arr[]=_('Date');
145 $title_arr[]=_('Hours');
146 $title_arr[]=_('Category');
149 echo $HTML->listTableTop ($title_arr);
151 while ($r=&db_fetch_array($res)) {
152 echo '<form action="'.getStringFromServer('PHP_SELF').'?week='.$week.'&project_task_id='.$r['project_task_id'].'" method="post" />
153 <input type="hidden" name="submit" value="1" />
154 <input type="hidden" name="report_date" value="'.$r['report_date'] .'" />
155 <input type="hidden" name="old_time_code" value="'.$r['time_code'] .'" />
156 <tr '.$HTML->boxGetAltRowStyle($xi++).'>
157 <td align="middle">'.$r['name'].'</td>
158 <td align="middle">'. date( 'D, M d, Y',$r['report_date']) .'</td>
159 <td align="middle"><!-- <input type="text" name="hours" value="'. $r['hours'] .'" size="3" maxlength="3" /> -->'.$r['hours'].'</td>
160 <td align="middle"><!-- '.report_time_category_box('time_code',$r['time_code']).' -->'.$r['category_name'].'</td>
161 <td align="middle"><!-- <input type="submit" name="update" value="Update" /> -->
162 <input type="submit" name="delete" value="'. _('Delete').'" /></td>
164 $total_hours += $r['hours'];
166 if ($group_project_id) {
168 $respt=db_query("SELECT project_task_id,summary FROM project_task WHERE group_project_id='$group_project_id'");
170 echo '<form action="'.getStringFromServer('PHP_SELF').'?week='.$week.'" method="post" />
171 <input type="hidden" name="submit" value="1" />
172 <tr '.$HTML->boxGetAltRowStyle($xi++).'>
173 <td align="middle">'. html_build_select_box ($respt,'project_task_id',false,false) .'</td>
174 <td align="middle"><input type="text" name="report_date" value="'. date('Y-m-d',$week) .'" size="10" maxlength="10" /></td>
175 <td align="middle"><input type="text" name="hours" value="" size="3" maxlength="3" /></td>
176 <td align="middle">'.report_time_category_box('time_code',false).'</td>
177 <td align="middle"><input type="submit" name="add" value="'.
178 _('Add').'" /><input type="submit" name="cancel" value="'._('Add').'" /></td>
182 echo '<tr '.$HTML->boxGetAltRowStyle($xi++).'><td colspan="2"><strong>'._('Total Hours').':</strong></td><td><strong>'.$total_hours.'</strong></td><td colspan="2"></td></tr>';
183 echo $HTML->listTableBottom();
186 if (!$group_project_id) {
189 <h3><?php echo _('Add Entry'); ?></h3>
191 <?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.'); ?>
193 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get" />
194 <input type="hidden" name="week" value="<?php echo $week; ?>" />
197 <td><strong><?php echo _('Task Manager Project'); ?>:</strong></td>
198 <td><?php echo html_build_select_box ($respm,'group_project_id',false,false); ?></td>
199 <td><input type="submit" name="submit" value="<?php echo _('Next'); ?>" /></td>
206 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get" />
207 <?php echo report_weeks_box($report,'week'); ?><input type="submit" name="submit" value="<?php echo _('Change Week'); ?>" />
212 // First Choose A Week to add/update/delete time sheet info
216 report_header(_('Time Tracking'));
219 <h3><?php echo _('Choose A Week to Record Or Edit Your Time.'); ?></h3>
221 <?php echo _('After you choose a week, you will be prompted to choose a Project/Subproject in the Task Manager.'); ?>
223 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="get" />
224 <strong><?php echo _('Week Starting'); ?>:</strong><br />
225 <?php echo report_weeks_box($report,'week'); ?>
227 <input type="submit" name="submit" value="<?php echo _('Next'); ?>" />