Commit aec085e4 authored by Jean-Paul Saman's avatar Jean-Paul Saman

addedit.php: read configuration values from the timesheet_config table

parent 3f6e6356
<?php
/*
* Copyright (C) 2007-2008, M2X
* Copyright (C) 2007-2014, M2X BV
*
* Authors: Jean-Paul Saman
*
......@@ -19,55 +19,56 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
$perms =& $AppUI->acl();
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
// Create new timesheet or edit an existing one.
$timesheet_id = intval( dPgetParam( $_GET, "timesheet_id", 0 ) );
$timesheet_id = (int)w2PgetParam($_GET, "timesheet_id", 0);
// Timesheet object
$timesheet = new CTimesheet();
$timesheet->timesheet_id = $timesheet_id;
$obj = $timesheet;
$canEdit = $obj->canEdit();
$canDelete = $obj->canDelete();
// check permissions for this record
$canEdit = !getDenyEdit( $m, $timesheet_id );
if (!$canEdit) {
$AppUI->redirect( "m=public&a=access_denied" );
$AppUI->redirect(ACCESS_DENIED);
}
$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" => '' ),
"book_year" => array( "value" => '' ),
"sort_order" => array( "value" => '' )
);
foreach ($config_options as $key=>$value){
if(isset($TIMESHEET_CONFIG[$key])){
$config_options[$key]['value']=$TIMESHEET_CONFIG[$key];
}
$obj = $AppUI->restoreObject();
if ($obj) {
$timesheet = $obj;
$timesheet_id = $timesheet->timesheet_id;
}
else {
$timesheet->load(null, $timesheet_id);
}
// 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();
// load the record data in case of that this script is used to edit the timesheet qith timesheet_id (transmitted via GET)
if (!$obj->load( $timesheet_id, false ) && ($timesheet_id > 0) ) {
// show some error messages using the dPFramework if loadOperation failed
// these error messages are nicely integrated with the frontend of dP
// use detailed error messages as often as possible
$AppUI->setMsg( 'Timesheet' );
$AppUI->setMsg( "invalidID", UI_MSG_ERROR, true );
// load the record data in case of that this script is used to edit the timesheet(timesheet_id(
if (!$timesheet && $timesheet_id > 0) {
$AppUI->setMsg('Timesheet');
$AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
$AppUI->redirect(); // go back to the calling location
}
// Read in all configuration data from timesheet_config
print "configuration options loading";
$config_options = $obj->get_config();
if (!$config_options) {
$AppUI->setMsg('no configuration options found', UI_MSG_ERROR);
$AppUI->redirect();
}
print "configuration options loaded";
// setup the title block
// Fill the title block either with 'Edit' or with 'New' depending on
// if timesheet_id has been transmitted via GET or is empty
$ttl = ( $timesheet_id > 0 ) ? "Edit Timesheet" : "New Timesheet";
$titleBlock = new CTitleBlock( $ttl, 'timesheet.png', $m, "$m.$a" );
$titleBlock = new w2p_Theme_TitleBlock( $ttl, 'timesheet.png', $m, '$m' . '.' . '$a' );
$titleBlock->addCrumb( "?m=timesheet", "view all timesheets" );
if ($canDelete && ($timesheet_id > 0) ) {
$titleBlock->addCrumbDelete( 'delete timesheet', $canDelete, $msg );
......@@ -288,6 +289,7 @@ if (intval($obj->timesheet_worked)) {
// Get Project Status information.
$project_types = dPgetSysVal("ProjectStatus");
// FIXME: Move this function to the Timesheet class
// Find all tasks in this timesheet period and account them to the project.
function showproject()
{
......
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