Commit 199e1d2e authored by Jean-Paul Saman's avatar Jean-Paul Saman

Fix changing of timesheet_status.

Timesheet status kept defaulting to "Open for Editing" and the value toggled between 0 and selected value. The combobox now works as expected again.
parent 540ef431
......@@ -136,12 +136,7 @@ if (intval($obj->timesheet_period)) {
}
// Get the current timesheet status
$status = 0;
if (intval($obj->timesheet_status))
$status = $obj->timesheet_status;
else {
$obj->timesheet_status = $status;
}
$status = $obj->timesheet_status;
// Get the current timesheet creation date
$creation_date = new CDate();
......@@ -263,19 +258,20 @@ if (intval($obj->timesheet_worked)) {
echo '<td align="right" nowrap="nowarp">' . $AppUI->_('Status') . ':&nbsp;</td>';
echo '<td width="100%" align="right"">';
echo 'STATUS: '.$status;
if ( ($canEdit) &&
($config_options['approval_by']['value'] == $AppUI->user_id ) ) {
echo '<select name="timesheet_status" size="1" class="text" onChange="changeIt()">';
echo '<option '; if ($status == 0) echo "selected"; echo 'value="0">' . dPformSafe('Open for Editing') . '</option>';
echo '<option '; if ($status == 1) echo "selected"; echo 'value="1">' . dPformSafe('Submitted') . '</option>';
if ( ($canEdit) && (($status == 0) ||
($config_options['approval_by']['value'] == $AppUI->user_id)) ) {
?>
<select name="timesheet_status" size="1" class="text" onChange="changeIt()">
<option <?php if (intval($status) == '0') { echo "selected"; } ?> value="0"> <?php echo dPformSafe('Open for Editing'); ?> </option>
<option <?php if (intval($status) == '1') { echo "selected"; } ?> value="1"> <?php echo dPformSafe('Submitted'); ?> </option>
<?php
// Only the user with Timesheet Approval rights may set a timesheet to approved status.
if ( $config_options['approval_by']['value'] == $AppUI->user_id ) {
echo '<option '; if ($status == 2) echo "selected"; echo 'value="2">' . dPformSafe('Approved') . '</option>';
?>
<option <?php if ($status == '2') { echo "selected"; } ?> value="2"> <?php echo dPformSafe('Approved'); ?> </option>
<?php
}
echo '</select>';
echo "</select>";
} else {
if ($status == 1)
echo dPformSafe('Submitted');
......
......@@ -41,11 +41,6 @@ $obj->timesheet_date = $_POST["timesheet_date"];
$obj->timesheet_creator = $_POST["timesheet_creator"];
$obj->timesheet_worked = $_POST["timesheet_worked"];
// sanity checking
if (!intval($obj->timesheet_status)) {
$obj->timesheet_status = 0;
}
$AppUI->setMsg( 'Timesheet' );
if ($del) {
// check if there are dependencies on this object
......@@ -63,7 +58,7 @@ if ($del) {
$AppUI->redirect( "m=timesheet" );
}
} else if ($stat) {
if ($msg = $obj->change_status($obj->timesheet_status)) {
if ($msg = $obj->change_status()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect();
} else {
......
......@@ -42,7 +42,7 @@ class CTimesheet extends CDpObject {
//use null for a new object, so the database automatically assigns an unique id by 'not null'-functionality
var $timesheet_id = null;
var $timesheet_period = null;
var $timesheet_status = null;
var $timesheet_status = 0;
var $timesheet_date = null;
var $timesheet_creator = null;
var $timesheet_worked = null;
......@@ -54,8 +54,6 @@ class CTimesheet extends CDpObject {
}
function check() {
if (!intval($this->timesheet_status))
$this->timesheet_status=0;
if ( $this->timesheet_id == "0" ) {
$this->init();
}
......@@ -160,8 +158,6 @@ class CTimesheet extends CDpObject {
}
}
else {
if (!intval($this->timesheet_status))
$this->timesheet_status=0;
$q = new DBQuery;
$q->addTable('timesheet');
$q->addInsert('timesheet_period,timesheet_status,timesheet_date,timesheet_creator,timesheet_worked',
......@@ -191,7 +187,7 @@ class CTimesheet extends CDpObject {
}
}
function change_status($stat)
function change_status()
{
$msg = $this->check();
$this->_action='updated';
......@@ -203,10 +199,8 @@ class CTimesheet extends CDpObject {
return db_error();
}
// Why is this needed ??
if ($stat>0) {
$this->project_purge();
$this->project_store();
}
/* $this->project_purge();
$this->project_store();*/
}
function change_period($period)
......
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