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