Commit 671e0a07 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Read configuration from file and use it in addedit.php to determine if current...

Read configuration from file and use it in addedit.php to determine if current user has "Timesheet approval rights". If it does, then allow setting "Approved" for this user.
parent 585f1ef1
......@@ -31,6 +31,22 @@ if (!$canEdit) {
}
$canDelete = $perms->checkModule( $m, 'delete' );
// Read in all configuration data
// $TIMESHEET_CONFIG = array();
$CONFIG_FILE = "./modules/timesheet/config.php";
require_once( $CONFIG_FILE );
//Read the current config values from the config file and update the array.
$config_options = array(
"approval_by" => array( "value" => '' )
);
foreach ($config_options as $key=>$value){
if(isset($TIMESHEET_CONFIG[$key])){
$config_options[$key]['value']=$TIMESHEET_CONFIG[$key];
}
}
// use the object oriented design of dP for loading the timesheet that should be edited
// therefore create a new instance of the Timesheet Class
$obj = new CTimesheet();
......@@ -69,9 +85,9 @@ $titleBlock->show();
}
function changeIt() {
var f=document.editFrm;
f.stat.value='1';
f.submit();
var f=document.editFrm;
f.stat.value='1';
f.submit();
}
function periodChange() {
......@@ -185,7 +201,8 @@ else {
<td align="right" nowrap="nowarp"><?php echo $AppUI->_('Period'); ?>:&nbsp;</td>
<td width="100%">
<?php
if ( ($canEdit) && ($status < 1) ) {
if ( ($canEdit) && ($status < 1) )
{
?>
<select name="timesheet_period" size="1' class="text" onChange="periodChange();">
<option <?php if ($period->getMonth() == 1) echo "selected"; ?> value="1"><? echo dPformSafe('January'); ?></option>
......@@ -203,7 +220,8 @@ else {
</select>
<?php
}
else {
else
{
if ($period->getMonth() == 1) echo dPformSafe('January');
else if ($period->getMonth() == 2) echo dPformSafe('February');
else if ($period->getMonth() == 3) echo dPformSafe('March');
......@@ -224,7 +242,6 @@ else {
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Creation date'); ?>:&nbsp;</td>
<td width="100%">
<?php
// echo $creation_date ? $creation_date->format( FMT_TIMESTAMP_DATE ) : "" ;
echo $creation_date->getYear() . "-" . $creation_date->getMonth() . "-" .
$creation_date->getDay();
?>
......@@ -232,7 +249,9 @@ else {
<td align="right" nowrap="nowarp"><?php echo $AppUI->_('Status'); ?>:&nbsp;</td>
<td width="100%" align="right"">
<?php
if ( ($canEdit) && ($status == 0) ) {
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 ($status == 0) echo "selected"; ?> value="0"><? echo dPformSafe('Open for Editing');?></option>
......@@ -244,7 +263,7 @@ else {
else {
if ($status == 1)
echo dPformSafe('Submitted');
else if ($status == 1)
else if ($status == 2)
echo dPformSafe('Approved');
}
?>
......@@ -258,17 +277,19 @@ else {
<?php
// If $status is not "Open for Editing" then don't allow to change the status.
// There is one exception to this rule the 'administrator' can always change the status.
if ($status == 0)
if ( ($canEdit) &&
(($status == 0) ||
($config_options['approval_by']['value'] == $AppUI->user_id)) )
{
?>
<input class="button" type="button" name="cancel" value="<?php echo $AppUI->_('cancel');?>" onClick="javascript:if(confirm('Are you sure you want to cancel.')){location.href = './index.php?m=timesheet';}" />
</td>
<td align="right">
<input class="button" type="submit" name="btnFuseAction" value="<?php echo $AppUI->_('submit');?>"/>
<?php }
else {
echo '&nbsp;</td><td align="right">&nbsp;';
}
<?php
}
else
echo '&nbsp;</td><td align="right">&nbsp;';
?>
</td>
</tr>
......@@ -333,7 +354,6 @@ function showproject()
}
}
$timesheet_worked = $timesheet_worked + $amount;
if( $amount > 0 )
{
echo '<tr>';
......@@ -342,6 +362,7 @@ function showproject()
echo '</td>';
echo '<td>';
echo $amount;
$timesheet_worked = $timesheet_worked + $amount;
echo '</td>';
echo '<td>' . $project_types[$row['project_status']] . '</td>';
echo '</tr>';
......
......@@ -185,7 +185,7 @@ class CTimesheet extends CDpObject {
}
}
function change_status($stat)
function change_status($stat)
{
$msg = $this->check();
$this->_action='updated';
......
......@@ -150,7 +150,7 @@ foreach ($month as $row) {
if ($status == 0)
echo dPformSafe("Open for Editing");
else if ($status == 1)
echo dPformSafe("Submitted"); // closed
echo dPformSafe("Submitted"); // closed for normal users
else if ($status == 2)
echo dPformSafe("Approved");
?>
......
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