Commit 07386af7 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Bugs fixed:

- Changing status and period of timesheet doesn't create 2 timesheet now. It only creates one timesheet or updates the current timesheet.

Feature added:
- Added a new row timesheet_worked to database for keeping a total of hours worked that timesheet_period.
- Added row timesheet_worked to inteface.
parent ae9ecf4a
......@@ -52,7 +52,7 @@ $titleBlock->show();
function changeIt() {
var f=document.editFrm;
f.stat.value='1';
f.submit();
f.submit();
}
function periodChange() {
......@@ -61,6 +61,11 @@ $titleBlock->show();
f.submit();
}
function workedHoursChange(val) {
var f=document.editFrm;
f.timesheet_worked.value=val;
}
</script>
<?php
// use the css-style 'std' of the UI style theme to format the table
......@@ -111,6 +116,13 @@ else {
$creation_date = new CDate();
$obj->timesheet_date = $creation_date->getTime();
}
if (intval($obj->timesheet_worked)) {
$timesheet_worked = $obj->timesheet_worked;
}
else {
$obj->timesheet_worked = 0;
}
?>
<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
<form name="editFrm" action="./index.php?m=timesheet" method="post">
......@@ -136,6 +148,7 @@ else {
<input type="hidden" name="timesheet_id" value="<?php echo $timesheet_id;?>" />
<input type="hidden" name="timesheet_date" value="<?php echo $obj->timesheet_date;?>" />
<input type="hidden" name="timesheet_creator" value="<?php echo $obj->timesheet_creator;?>" />
<input type="hidden" name="timesheet_worked" value="<?php echo $obj->timesheet_worked;?>" />
<?php
// please notice that html tags that have no </closing tag> should be closed
......@@ -254,6 +267,7 @@ $q->addQuery('project_status');
$q->addTable('projects');
$q->addOrder('project_name ASC');
$projects = $q->LoadList();
$timesheet_worked = 0;
foreach ($projects as $row) {
?>
<tr>
......@@ -302,12 +316,17 @@ foreach ($projects as $row) {
}
}
echo $amount;
$timesheet_worked = $timesheet_worked + $amount;
?>
</td>
<td><?php echo $row["project_status"]; ?></td>
</tr>
<?php
}
?>
$obj->timesheet_worked = $timesheet_worked;
?>
<script language="javascript">
workedHoursChange(<?php echo $obj->timesheet_worked; ?>);
</script>
</table>
......@@ -61,7 +61,8 @@ else if ($period) {
$AppUI->redirect();
} else {
$AppUI->setMsg( "Timesheet period changed", UI_MSG_ALERT);
$AppUI->redirect( "m=timesheet&a=addedit&timesheet_id=".$obj->timesheet_id );
//$AppUI->redirect( "m=timesheet&a=addedit&timesheet_id=".$obj->timesheet_id );
$AppUI->redirect();
}
}
else {
......
......@@ -28,7 +28,7 @@ if (@$a == 'setup') {
class CSetupTimesheet {
function configure() { // configure this module
global $AppUI;
global $AppUI;
$AppUI->redirect( 'm=timesheet&a=configure' ); // load module specific configuration page
return true;
}
......@@ -72,7 +72,8 @@ class CSetupTimesheet {
" `timesheet_period` int(11), " .
" `timesheet_status` int(4) NOT NULL default '0', " .
" `timesheet_date` int(11) NOT NULL default '0', " .
" `timesheet_creator` int(11) NOT NULL default '0', " .
" `timesheet_creator` int(11) NOT NULL default '0', " .
" `timesheet_worked` int(11) NOT NULL default '0', " .
" PRIMARY KEY (`timesheet_id`), " .
" UNIQUE KEY `timesheet_id` (`timesheet_id`) " .
") TYPE=MyISAM";
......
......@@ -15,12 +15,12 @@ if (!$canRead) { // lock out users that do not have at least readPermission on
<th nowrap="nowrap">&nbsp;</th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Date' );?></th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Month' );?></th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Worked' );?></th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Submitter' );?></th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Status' );?></th>
<th nowrap="nowrap">&nbsp;</th>
</tr>
<?php
// retrieving some dynamic content using an easy database query
//Pull all users
$q = new DBQuery;
$q->addQuery('user_id, contact_first_name, contact_last_name');
......@@ -34,13 +34,14 @@ while ( $row = $q->fetchRow()) {
$users[$row['user_id']] = $row['contact_last_name'] . ', ' . $row['contact_first_name'];
}
$q->Clear();
$sql = "SELECT * FROM `timesheet`";
$month = db_loadList( $sql );
$q->addQuery('timesheet_id, timesheet_date, timesheet_status, timesheet_period, timesheet_creator, timesheet_worked');
$q->addTable('timesheet');
//$q->addWhere('timesheet_status = 1');
$month = $q->loadList();
// add/show now gradually the timesheet
foreach ($month as $row) { //parse the array of timesheet
foreach ($month as $row) {
?>
<tr>
<td nowrap="nowrap" width="20">
......@@ -60,6 +61,7 @@ foreach ($month as $row) { //parse the array of timesheet
echo "</a>";
?> </td>
<td> <?php
echo "\n".'<a href="?m=timesheet&a=addedit&timesheet_id=' . $row["timesheet_id"] . '">';
$month = new CDate();
$month->setMonth($row["timesheet_period"]);
if ($month->GetMonth() == 1)
......@@ -86,8 +88,10 @@ foreach ($month as $row) { //parse the array of timesheet
echo dPformSafe('November');
else if ($month->getMonth() == 12)
echo dPformSafe('December');
echo "\n</a>";
?>
</td>
<td> <?php echo $row["timesheet_worked"]; ?> </td>
<td> <?php echo $users[$row["timesheet_creator"]]; ?> </td>
<td> <?php
$status = $row["timesheet_status"];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment