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
...@@ -61,6 +61,11 @@ $titleBlock->show(); ...@@ -61,6 +61,11 @@ $titleBlock->show();
f.submit(); f.submit();
} }
function workedHoursChange(val) {
var f=document.editFrm;
f.timesheet_worked.value=val;
}
</script> </script>
<?php <?php
// use the css-style 'std' of the UI style theme to format the table // use the css-style 'std' of the UI style theme to format the table
...@@ -111,6 +116,13 @@ else { ...@@ -111,6 +116,13 @@ else {
$creation_date = new CDate(); $creation_date = new CDate();
$obj->timesheet_date = $creation_date->getTime(); $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"> <table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
<form name="editFrm" action="./index.php?m=timesheet" method="post"> <form name="editFrm" action="./index.php?m=timesheet" method="post">
...@@ -136,6 +148,7 @@ else { ...@@ -136,6 +148,7 @@ else {
<input type="hidden" name="timesheet_id" value="<?php echo $timesheet_id;?>" /> <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_date" value="<?php echo $obj->timesheet_date;?>" />
<input type="hidden" name="timesheet_creator" value="<?php echo $obj->timesheet_creator;?>" /> <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 <?php
// please notice that html tags that have no </closing tag> should be closed // please notice that html tags that have no </closing tag> should be closed
...@@ -254,6 +267,7 @@ $q->addQuery('project_status'); ...@@ -254,6 +267,7 @@ $q->addQuery('project_status');
$q->addTable('projects'); $q->addTable('projects');
$q->addOrder('project_name ASC'); $q->addOrder('project_name ASC');
$projects = $q->LoadList(); $projects = $q->LoadList();
$timesheet_worked = 0;
foreach ($projects as $row) { foreach ($projects as $row) {
?> ?>
<tr> <tr>
...@@ -302,12 +316,17 @@ foreach ($projects as $row) { ...@@ -302,12 +316,17 @@ foreach ($projects as $row) {
} }
} }
echo $amount; echo $amount;
$timesheet_worked = $timesheet_worked + $amount;
?> ?>
</td> </td>
<td><?php echo $row["project_status"]; ?></td> <td><?php echo $row["project_status"]; ?></td>
</tr> </tr>
<?php <?php
} }
?>
$obj->timesheet_worked = $timesheet_worked;
?>
<script language="javascript">
workedHoursChange(<?php echo $obj->timesheet_worked; ?>);
</script>
</table> </table>
...@@ -61,7 +61,8 @@ else if ($period) { ...@@ -61,7 +61,8 @@ else if ($period) {
$AppUI->redirect(); $AppUI->redirect();
} else { } else {
$AppUI->setMsg( "Timesheet period changed", UI_MSG_ALERT); $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 { else {
......
...@@ -73,6 +73,7 @@ class CSetupTimesheet { ...@@ -73,6 +73,7 @@ class CSetupTimesheet {
" `timesheet_status` int(4) NOT NULL default '0', " . " `timesheet_status` int(4) NOT NULL default '0', " .
" `timesheet_date` int(11) 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`), " . " PRIMARY KEY (`timesheet_id`), " .
" UNIQUE KEY `timesheet_id` (`timesheet_id`) " . " UNIQUE KEY `timesheet_id` (`timesheet_id`) " .
") TYPE=MyISAM"; ") TYPE=MyISAM";
......
...@@ -15,12 +15,12 @@ if (!$canRead) { // lock out users that do not have at least readPermission on ...@@ -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">&nbsp;</th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Date' );?></th> <th nowrap="nowrap"><?php echo $AppUI->_( 'Date' );?></th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Month' );?></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->_( 'Submitter' );?></th>
<th nowrap="nowrap"><?php echo $AppUI->_( 'Status' );?></th> <th nowrap="nowrap"><?php echo $AppUI->_( 'Status' );?></th>
<th nowrap="nowrap">&nbsp;</th> <th nowrap="nowrap">&nbsp;</th>
</tr> </tr>
<?php <?php
// retrieving some dynamic content using an easy database query
//Pull all users //Pull all users
$q = new DBQuery; $q = new DBQuery;
$q->addQuery('user_id, contact_first_name, contact_last_name'); $q->addQuery('user_id, contact_first_name, contact_last_name');
...@@ -35,12 +35,13 @@ while ( $row = $q->fetchRow()) { ...@@ -35,12 +35,13 @@ while ( $row = $q->fetchRow()) {
} }
$q->Clear(); $q->Clear();
$sql = "SELECT * FROM `timesheet`"; $q->addQuery('timesheet_id, timesheet_date, timesheet_status, timesheet_period, timesheet_creator, timesheet_worked');
$month = db_loadList( $sql ); $q->addTable('timesheet');
//$q->addWhere('timesheet_status = 1');
$month = $q->loadList();
// add/show now gradually the timesheet // add/show now gradually the timesheet
foreach ($month as $row) {
foreach ($month as $row) { //parse the array of timesheet
?> ?>
<tr> <tr>
<td nowrap="nowrap" width="20"> <td nowrap="nowrap" width="20">
...@@ -60,6 +61,7 @@ foreach ($month as $row) { //parse the array of timesheet ...@@ -60,6 +61,7 @@ foreach ($month as $row) { //parse the array of timesheet
echo "</a>"; echo "</a>";
?> </td> ?> </td>
<td> <?php <td> <?php
echo "\n".'<a href="?m=timesheet&a=addedit&timesheet_id=' . $row["timesheet_id"] . '">';
$month = new CDate(); $month = new CDate();
$month->setMonth($row["timesheet_period"]); $month->setMonth($row["timesheet_period"]);
if ($month->GetMonth() == 1) if ($month->GetMonth() == 1)
...@@ -86,8 +88,10 @@ foreach ($month as $row) { //parse the array of timesheet ...@@ -86,8 +88,10 @@ foreach ($month as $row) { //parse the array of timesheet
echo dPformSafe('November'); echo dPformSafe('November');
else if ($month->getMonth() == 12) else if ($month->getMonth() == 12)
echo dPformSafe('December'); echo dPformSafe('December');
echo "\n</a>";
?> ?>
</td> </td>
<td> <?php echo $row["timesheet_worked"]; ?> </td>
<td> <?php echo $users[$row["timesheet_creator"]]; ?> </td> <td> <?php echo $users[$row["timesheet_creator"]]; ?> </td>
<td> <?php <td> <?php
$status = $row["timesheet_status"]; $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