Commit 62f685f0 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Added user selection to vw_idx_inc.php. This makes it possible to view the...

Added user selection to vw_idx_inc.php. This makes it possible to view the timesheets of other people besides those of yourself. This feature is not restricted to the admin.
parent a93fa7d4
...@@ -6,16 +6,12 @@ ...@@ -6,16 +6,12 @@
// we check for permissions on this module // we check for permissions on this module
$canRead = !getDenyRead( $m ); // retrieve module-based readPermission bool flag $canRead = !getDenyRead( $m ); // retrieve module-based readPermission bool flag
$canEdit = !getDenyEdit( $m ); // retrieve module-based writePermission bool flag $canEdit = !getDenyEdit( $m ); // retrieve module-based writePermission bool flag
// lock out users that do not have at least readPermission on this module // lock out users that do not have at least readPermission on this module
if (!$canRead) { if (!$canRead) {
$AppUI->redirect( "m=public&a=access_denied" ); $AppUI->redirect( "m=public&a=access_denied" );
} }
//save the workplace state (have a footprint on this site) //save the workplace state (have a footprint on this site)
$AppUI->savePlace(); $AppUI->savePlace();
// retrieve any state parameters (temporary session variables that are not stored in db)
// saves the current tab box state // saves the current tab box state
if (isset( $_GET['tab'] )) { if (isset( $_GET['tab'] )) {
$AppUI->setState( 'TimesheetIdxTab', $_GET['tab'] ); $AppUI->setState( 'TimesheetIdxTab', $_GET['tab'] );
......
...@@ -27,11 +27,11 @@ if (@$a == 'setup') { ...@@ -27,11 +27,11 @@ if (@$a == 'setup') {
class CSetupTimesheet { class CSetupTimesheet {
function configure() { // configure this module // function configure() { // configure this module
global $AppUI; // global $AppUI;
$AppUI->redirect( 'm=timesheet&a=configure' ); // load module specific configuration page // $AppUI->redirect( 'm=timesheet&a=configure' ); // load module specific configuration page
return true; // return true;
} // }
function remove() { function remove() {
$q = new DBQuery; $q = new DBQuery;
......
...@@ -19,7 +19,27 @@ if (!$canRead) { // lock out users that do not have at least readPermission on ...@@ -19,7 +19,27 @@ if (!$canRead) { // lock out users that do not have at least readPermission on
<th nowrap="nowrap">&nbsp;</th> <th nowrap="nowrap">&nbsp;</th>
</tr> </tr>
<?php <?php
//Pull all users // Retrieve the list of users that may access this module.
if(isset($_REQUEST["user_filter_id"])){
$AppUI->setState("user_filter_id", $_REQUEST["user_filter_id"]);
$user_filter_id = $_REQUEST["user_filter_id"];
} else {
$user_filter_id = $AppUI->getState( 'user_filter_id');
if (! isset($user_filter_id)) {
$user_filter_id = $AppUI->user_id;
$AppUI->setState('user_filter_id', $user_filter_id);
}
}
$perms =& $AppUI->acl();
$user_list = array( 0 => $AppUI->_("All", UI_OUTPUT_RAW)) + $perms->getPermittedUsers("timesheet"); // db_loadHashList($sql);
$user_combo = arraySelect($user_list, "user_filter_id", "class='text' onchange='javascript:document.searchform.submit()'", $user_filter_id, false);
echo "<tr><form name='searchform' action='?m=timesheet' method='post'>
".$AppUI->_("Show timesheets for ").": $user_combo
</form></tr>";
// Pull all users
$q = new DBQuery; $q = new DBQuery;
$q->addQuery('user_id, contact_first_name, contact_last_name'); $q->addQuery('user_id, contact_first_name, contact_last_name');
$q->addTable('users'); $q->addTable('users');
...@@ -31,11 +51,18 @@ $users = array(); ...@@ -31,11 +51,18 @@ $users = array();
while ( $row = $q->fetchRow()) { while ( $row = $q->fetchRow()) {
$users[$row['user_id']] = $row['contact_last_name'] . ', ' . $row['contact_first_name']; $users[$row['user_id']] = $row['contact_last_name'] . ', ' . $row['contact_first_name'];
} }
$q->Clear();
$q->Clear();
$q->addQuery('timesheet_id, timesheet_date, timesheet_status, timesheet_period, timesheet_creator, timesheet_worked'); $q->addQuery('timesheet_id, timesheet_date, timesheet_status, timesheet_period, timesheet_creator, timesheet_worked');
$q->addTable('timesheet'); $q->addTable('timesheet');
$q->addWhere('timesheet_creator = ' . $AppUI->user_id ); if ($user_filter_id > 0) {
$q->addWhere('timesheet_creator = ' . $user_filter_id );
}
else {
$q->addOrder('timesheet_creator');
}
$q->addOrder('timesheet_period');
if ($type >= 0) if ($type >= 0)
$q->addWhere('timesheet_status = '. $type ); $q->addWhere('timesheet_status = '. $type );
$month = $q->loadList(); $month = $q->loadList();
......
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