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) { ...@@ -31,6 +31,22 @@ if (!$canEdit) {
} }
$canDelete = $perms->checkModule( $m, 'delete' ); $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 // use the object oriented design of dP for loading the timesheet that should be edited
// therefore create a new instance of the Timesheet Class // therefore create a new instance of the Timesheet Class
$obj = new CTimesheet(); $obj = new CTimesheet();
...@@ -185,7 +201,8 @@ else { ...@@ -185,7 +201,8 @@ else {
<td align="right" nowrap="nowarp"><?php echo $AppUI->_('Period'); ?>:&nbsp;</td> <td align="right" nowrap="nowarp"><?php echo $AppUI->_('Period'); ?>:&nbsp;</td>
<td width="100%"> <td width="100%">
<?php <?php
if ( ($canEdit) && ($status < 1) ) { if ( ($canEdit) && ($status < 1) )
{
?> ?>
<select name="timesheet_period" size="1' class="text" onChange="periodChange();"> <select name="timesheet_period" size="1' class="text" onChange="periodChange();">
<option <?php if ($period->getMonth() == 1) echo "selected"; ?> value="1"><? echo dPformSafe('January'); ?></option> <option <?php if ($period->getMonth() == 1) echo "selected"; ?> value="1"><? echo dPformSafe('January'); ?></option>
...@@ -203,7 +220,8 @@ else { ...@@ -203,7 +220,8 @@ else {
</select> </select>
<?php <?php
} }
else { else
{
if ($period->getMonth() == 1) echo dPformSafe('January'); if ($period->getMonth() == 1) echo dPformSafe('January');
else if ($period->getMonth() == 2) echo dPformSafe('February'); else if ($period->getMonth() == 2) echo dPformSafe('February');
else if ($period->getMonth() == 3) echo dPformSafe('March'); else if ($period->getMonth() == 3) echo dPformSafe('March');
...@@ -224,7 +242,6 @@ else { ...@@ -224,7 +242,6 @@ else {
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Creation date'); ?>:&nbsp;</td> <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Creation date'); ?>:&nbsp;</td>
<td width="100%"> <td width="100%">
<?php <?php
// echo $creation_date ? $creation_date->format( FMT_TIMESTAMP_DATE ) : "" ;
echo $creation_date->getYear() . "-" . $creation_date->getMonth() . "-" . echo $creation_date->getYear() . "-" . $creation_date->getMonth() . "-" .
$creation_date->getDay(); $creation_date->getDay();
?> ?>
...@@ -232,7 +249,9 @@ else { ...@@ -232,7 +249,9 @@ else {
<td align="right" nowrap="nowarp"><?php echo $AppUI->_('Status'); ?>:&nbsp;</td> <td align="right" nowrap="nowarp"><?php echo $AppUI->_('Status'); ?>:&nbsp;</td>
<td width="100%" align="right""> <td width="100%" align="right"">
<?php <?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()"> <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> <option <?php if ($status == 0) echo "selected"; ?> value="0"><? echo dPformSafe('Open for Editing');?></option>
...@@ -244,7 +263,7 @@ else { ...@@ -244,7 +263,7 @@ else {
else { else {
if ($status == 1) if ($status == 1)
echo dPformSafe('Submitted'); echo dPformSafe('Submitted');
else if ($status == 1) else if ($status == 2)
echo dPformSafe('Approved'); echo dPformSafe('Approved');
} }
?> ?>
...@@ -258,17 +277,19 @@ else { ...@@ -258,17 +277,19 @@ else {
<?php <?php
// If $status is not "Open for Editing" then don't allow to change the status. // 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. // 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';}" /> <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>
<td align="right"> <td align="right">
<input class="button" type="submit" name="btnFuseAction" value="<?php echo $AppUI->_('submit');?>"/> <input class="button" type="submit" name="btnFuseAction" value="<?php echo $AppUI->_('submit');?>"/>
<?php } <?php
else {
echo '&nbsp;</td><td align="right">&nbsp;';
} }
else
echo '&nbsp;</td><td align="right">&nbsp;';
?> ?>
</td> </td>
</tr> </tr>
...@@ -333,7 +354,6 @@ function showproject() ...@@ -333,7 +354,6 @@ function showproject()
} }
} }
$timesheet_worked = $timesheet_worked + $amount;
if( $amount > 0 ) if( $amount > 0 )
{ {
echo '<tr>'; echo '<tr>';
...@@ -342,6 +362,7 @@ function showproject() ...@@ -342,6 +362,7 @@ function showproject()
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';
echo $amount; echo $amount;
$timesheet_worked = $timesheet_worked + $amount;
echo '</td>'; echo '</td>';
echo '<td>' . $project_types[$row['project_status']] . '</td>'; echo '<td>' . $project_types[$row['project_status']] . '</td>';
echo '</tr>'; echo '</tr>';
......
...@@ -150,7 +150,7 @@ foreach ($month as $row) { ...@@ -150,7 +150,7 @@ foreach ($month as $row) {
if ($status == 0) if ($status == 0)
echo dPformSafe("Open for Editing"); echo dPformSafe("Open for Editing");
else if ($status == 1) else if ($status == 1)
echo dPformSafe("Submitted"); // closed echo dPformSafe("Submitted"); // closed for normal users
else if ($status == 2) else if ($status == 2)
echo dPformSafe("Approved"); 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