This commit is contained in:
hainberg
2020-01-08 15:48:36 +01:00
9 changed files with 307 additions and 155 deletions
+7
View File
@@ -188,5 +188,12 @@ $config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array(
'icon' => '',
'sort' => 1,
'requiredPermissions' => 'lehre/lehrauftrag_erteilen:r'
),
'lehrauftragLehrendeÜbersicht' => array(
'link' => site_url('lehre/lehrauftrag/Lehrauftrag/LehrendeUebersicht'),
'description' => 'Lehrendenübersicht',
'icon' => '',
'sort' => 1,
'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r')
)
);
+54 -23
View File
@@ -7,8 +7,10 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class FilterWidgetLib
{
// Session parameters names
const SESSION_NAME = 'FHC_FILTER_WIDGET'; // Filter session name
// FilterWidget session name
const SESSION_NAME = 'FHC_FILTER_WIDGET';
// Session elements
const SESSION_FILTER_NAME = 'filterName';
const SESSION_FIELDS = 'fields';
const SESSION_SELECTED_FIELDS = 'selectedFields';
@@ -17,13 +19,19 @@ class FilterWidgetLib
const SESSION_CHECKBOXES = 'checkboxes';
const SESSION_FILTERS = 'filters';
const SESSION_METADATA = 'datasetMetadata';
const SESSION_DATASET = 'dataset';
const SESSION_ROW_NUMBER = 'rowNumber';
const SESSION_RELOAD_DATASET = 'reloadDataset';
const SESSION_TIMEOUT = 'sessionTimeout';
// Session dataset elements
const SESSION_DATASET = 'dataset';
const SESSION_DATASET_RELOAD = 'reloadDataset';
const SESSION_DATASET_REPRESENTATION = 'datasetRepresentation';
const SESSION_DATASET_REP_OPTIONS = 'datasetRepresentationOptions';
const SESSION_DATASET_REP_FIELDS_DEFS = 'datasetRepresentationFieldsDefinitions';
// Default session timeout
const SESSION_DEFAULT_TIMEOUT = 30;
// Alias for the dynamic table used to retrieve the dataset
const DATASET_TABLE_ALIAS = 'datasetFilterTable';
@@ -33,16 +41,16 @@ class FilterWidgetLib
// ...to identify a single filter widget in the DB
const FILTER_ID = 'filter_id';
const APP_PARAMETER = 'app';
const DATASET_NAME_PARAMETER = 'datasetName';
const FILTER_KURZBZ_PARAMETER = 'filterKurzbz';
const DATASET_RELOAD_PARAMETER = 'reloadDataset';
const APP = 'app';
const DATASET_NAME = 'datasetName';
const FILTER_KURZBZ = 'filterKurzbz';
const DATASET_RELOAD = 'reloadDataset';
// ...to specify permissions that are needed to use this FilterWidget
const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions';
const REQUIRED_PERMISSIONS = 'requiredPermissions';
// ...stament to retrieve the dataset
const QUERY_PARAMETER = 'query';
const QUERY = 'query';
// ...to specify more columns or aliases for them
const ADDITIONAL_COLUMNS = 'additionalColumns';
@@ -131,7 +139,7 @@ class FilterWidgetLib
// Gets the required permissions from the session if they are not provided as parameter
$rq = $requiredPermissions;
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER);
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS);
return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_FILTER_METHOD, self::PERMISSION_TYPE);
}
@@ -179,6 +187,29 @@ class FilterWidgetLib
setSessionElement(self::SESSION_NAME, $this->_filterUniqueId, $session); // stores the single value
}
/**
*
*/
public function dropExpiredFilterWidgets()
{
// Loads the session for all the filter widgets
$filterWidgetsSession = getSession(self::SESSION_NAME);
// If something is present in session
if ($filterWidgetsSession != null)
{
// Loops in the session for all the filter widgets
foreach ($filterWidgetsSession as $filterWidget => $filterWidgetData)
{
// If this filter widget is not the currrent used filter widget and the it is expired...
if ($this->_filterUniqueId != $filterWidget && $filterWidgetData[self::SESSION_TIMEOUT] <= time())
{
cleanSessionElement(self::SESSION_NAME, $filterWidget); // ...remove it
}
}
}
}
/**
* Loads the definition data from DB for a filter widget
*/
@@ -471,7 +502,7 @@ class FilterWidgetLib
// Write changes into the session
$this->setSessionElement(self::SESSION_FILTERS, $filters);
$this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded
$this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded
$removeAppliedFilter = true;
}
@@ -523,7 +554,7 @@ class FilterWidgetLib
// Write changes into the session
$this->setSessionElement(self::SESSION_FILTERS, $filters);
$this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded
$this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded
$applyFilters = true;
}
@@ -537,7 +568,7 @@ class FilterWidgetLib
*/
public function reloadDataset()
{
$this->setSessionElement(self::SESSION_RELOAD_DATASET, true);
$this->setSessionElement(self::SESSION_DATASET_RELOAD, true);
}
/**
@@ -603,8 +634,8 @@ class FilterWidgetLib
// Loads the definition to check if is already present in the DB
$definition = $this->_ci->FiltersModel->loadWhere(array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'app' => $this->getSessionElement(self::APP),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME),
'description' => $descPGArray,
'person_id' => $authPersonId
));
@@ -632,8 +663,8 @@ class FilterWidgetLib
// update it
$this->_ci->FiltersModel->update(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'app' => $this->getSessionElement(self::APP),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME),
'description' => $descPGArray,
'person_id' => $authPersonId
),
@@ -648,8 +679,8 @@ class FilterWidgetLib
{
$this->_ci->FiltersModel->insert(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'app' => $this->getSessionElement(self::APP),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME),
'filter_kurzbz' => uniqid($authPersonId, true),
'description' => $descPGArray,
'person_id' => $authPersonId,
@@ -693,7 +724,7 @@ class FilterWidgetLib
public function generateFilterMenu($navigationPage)
{
// Loads the NavigationLib for the current page (given as parameter)
$this->_ci->load->library('NavigationLib', array(FilterWidgetLib::NAVIGATION_PAGE => $navigationPage));
$this->_ci->load->library('NavigationLib', array(self::NAVIGATION_PAGE => $navigationPage));
$filterMenu = null;
$currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session
@@ -706,7 +737,7 @@ class FilterWidgetLib
// Loads all the filters related to this page (same dataset_name and same app name)
$filters = $this->_ci->FiltersModel->getFiltersByAppDatasetName(
$session[self::APP_PARAMETER], $session[self::DATASET_NAME_PARAMETER]
$session[self::APP], $session[self::DATASET_NAME]
);
// If filters were loaded
@@ -775,7 +806,7 @@ class FilterWidgetLib
);
// Sets in the session only the element related to the filters menu
$this->_ci->navigationlib->setSessionElementMenu(FilterWidgetLib::NAV_MENU_FILTER_KEY, $filterMenu);
$this->_ci->navigationlib->setSessionElementMenu(self::NAV_MENU_FILTER_KEY, $filterMenu);
}
}
}
+45 -14
View File
@@ -9,33 +9,40 @@ class TableWidgetLib
{
const TABLE_UNIQUE_ID = 'tableUniqueId'; // TableWidget unique id
// Session parameters names
const SESSION_NAME = 'FHC_TABLE_WIDGET'; // Table session name
// TableWidget session name
const SESSION_NAME = 'FHC_TABLE_WIDGET';
// Session elements
const SESSION_FIELDS = 'fields';
const SESSION_COLUMNS_ALIASES = 'columnsAliases';
const SESSION_ADDITIONAL_COLUMNS = 'additionalColumns';
const SESSION_CHECKBOXES = 'checkboxes';
const SESSION_METADATA = 'datasetMetadata';
const SESSION_DATASET = 'dataset';
const SESSION_ROW_NUMBER = 'rowNumber';
const SESSION_RELOAD_DATASET = 'reloadDataset';
// Session dataset elements
const SESSION_DATASET = 'dataset';
const SESSION_DATASET_RELOAD = 'reloadDataset';
const SESSION_DATASET_REPRESENTATION = 'datasetRepresentation';
const SESSION_DATASET_REP_OPTIONS = 'datasetRepresentationOptions';
const SESSION_DATASET_REP_FIELDS_DEFS = 'datasetRepresentationFieldsDefinitions';
// Default session timeout
const SESSION_DEFAULT_TIMEOUT = 30;
// Alias for the dynamic table used to retrieve the dataset
const DATASET_TABLE_ALIAS = 'datasetTableWidget';
// Parameters names...
// ...to reload the dataset
const DATASET_RELOAD_PARAMETER = 'reloadDataset';
const DATASET_RELOAD = 'reloadDataset';
// ...to specify permissions that are needed to use this TableWidget
const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions';
const REQUIRED_PERMISSIONS = 'requiredPermissions';
// ...stament to retrieve the dataset
const QUERY_PARAMETER = 'query';
const QUERY = 'query';
// ...to specify more columns or aliases for them
const ADDITIONAL_COLUMNS = 'additionalColumns';
@@ -50,6 +57,7 @@ class TableWidgetLib
const DATASET_REPRESENTATION = 'datasetRepresentation';
const DATASET_REP_OPTIONS = 'datasetRepOptions';
const DATASET_REP_FIELDS_DEFS = 'datasetRepFieldsDefs';
const DATASET_TIMEOUT = 'datasetTimeout'; // ...and its expiring time
// Different dataset representations
const DATASET_REP_TABLESORTER = 'tablesorter';
@@ -86,13 +94,13 @@ class TableWidgetLib
// Gets the required permissions from the session if they are not provided as parameter
$rq = $requiredPermissions;
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER);
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS);
return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_TABLE_METHOD, self::PERMISSION_TYPE);
}
/**
* Wrapper method to the session helper funtions to retrieve the whole session for this filter
* Wrapper method to the session helper funtions to retrieve the whole session for this table widget
*/
public function getSession()
{
@@ -100,7 +108,7 @@ class TableWidgetLib
}
/**
* Wrapper method to the session helper funtions to retrieve one element from the session of this filter
* Wrapper method to the session helper funtions to retrieve one element from the session of this table widget
*/
public function getSessionElement($name)
{
@@ -115,7 +123,7 @@ class TableWidgetLib
}
/**
* Wrapper method to the session helper funtions to set the whole session for this filter
* Wrapper method to the session helper funtions to set the whole session for this table widget
*/
public function setSession($data)
{
@@ -123,7 +131,7 @@ class TableWidgetLib
}
/**
* Wrapper method to the session helper funtions to set one element in the session for this filter
* Wrapper method to the session helper funtions to set one element in the session for this table widget
*/
public function setSessionElement($name, $value)
{
@@ -135,7 +143,30 @@ class TableWidgetLib
}
/**
* Generate the query to retrieve the dataset for a filter
*
*/
public function dropExpiredTableWidgets()
{
// Loads the session for all the table widgets
$tableWidgetsSession = getSession(self::SESSION_NAME);
// If something is present in session
if ($tableWidgetsSession != null)
{
// Loops in the session for all the table widgets
foreach ($tableWidgetsSession as $tableWidget => $tableWidgetData)
{
// If this table widget is not the currrent used table widget and the it is expired...
if ($this->_tableUniqueId != $tableWidget && $tableWidgetData[self::SESSION_TIMEOUT] <= time())
{
cleanSessionElement(self::SESSION_NAME, $tableWidget); // ...remove it
}
}
}
}
/**
* Generate the query to retrieve the dataset for a table widget
*/
public function generateDatasetQuery($query)
{
@@ -177,7 +208,7 @@ class TableWidgetLib
}
/**
* Return an unique string that identify this filter widget
* Return an unique string that identify this table widget
* NOTE: The default value is the URI where the FilterWidget is called
* If the fhc_controller_id is present then is also used
*/
+50 -25
View File
@@ -57,6 +57,8 @@ class FilterWidget extends Widget
private $_reloadDataset; // Force Reload of Dataset
private $_sessionTimeout; // session expiring time
private static $_FilterWidgetInstance; // static property that contains the instance of itself
/**
@@ -202,27 +204,28 @@ class FilterWidget extends Widget
$this->_datasetRepresentation = null;
$this->_datasetRepresentationOptions = null;
$this->_datasetRepFieldsDefs = null;
$this->_sessionTimeout = FilterWidgetLib::SESSION_DEFAULT_TIMEOUT;
// Retrieved the required permissions parameter if present
if (isset($args[FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER]))
if (isset($args[FilterWidgetLib::REQUIRED_PERMISSIONS]))
{
$this->_requiredPermissions = $args[FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER];
$this->_requiredPermissions = $args[FilterWidgetLib::REQUIRED_PERMISSIONS];
}
// Parameters needed to retrieve univocally a filter from DB
if (isset($args[FilterWidgetLib::APP_PARAMETER]))
if (isset($args[FilterWidgetLib::APP]))
{
$this->_app = $args[FilterWidgetLib::APP_PARAMETER];
$this->_app = $args[FilterWidgetLib::APP];
}
if (isset($args[FilterWidgetLib::DATASET_NAME_PARAMETER]))
if (isset($args[FilterWidgetLib::DATASET_NAME]))
{
$this->_datasetName = $args[FilterWidgetLib::DATASET_NAME_PARAMETER];
$this->_datasetName = $args[FilterWidgetLib::DATASET_NAME];
}
if (isset($args[FilterWidgetLib::FILTER_KURZBZ_PARAMETER]))
if (isset($args[FilterWidgetLib::FILTER_KURZBZ]))
{
$this->_filterKurzbz = $args[FilterWidgetLib::FILTER_KURZBZ_PARAMETER];
$this->_filterKurzbz = $args[FilterWidgetLib::FILTER_KURZBZ];
}
if (isset($args[FilterWidgetLib::FILTER_ID]))
@@ -231,14 +234,14 @@ class FilterWidget extends Widget
}
// How to retrieve data for the filter: SQL statement or a result from DB
if (isset($args[FilterWidgetLib::QUERY_PARAMETER]))
if (isset($args[FilterWidgetLib::QUERY]))
{
$this->_query = $args[FilterWidgetLib::QUERY_PARAMETER];
$this->_query = $args[FilterWidgetLib::QUERY];
}
if (isset($args[FilterWidgetLib::DATASET_RELOAD_PARAMETER]))
if (isset($args[FilterWidgetLib::DATASET_RELOAD]))
{
$this->_reloadDataset = $args[FilterWidgetLib::DATASET_RELOAD_PARAMETER];
$this->_reloadDataset = $args[FilterWidgetLib::DATASET_RELOAD];
}
// Parameter is used to add extra columns to the dataset
@@ -332,6 +335,12 @@ class FilterWidget extends Widget
{
$this->_datasetRepFieldsDefs = $args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS];
}
// To specify the expiring session time
if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT]))
{
$this->_sessionTimeout = $args[FilterWidgetLib::SESSION_TIMEOUT];
}
}
/**
@@ -339,31 +348,36 @@ class FilterWidget extends Widget
*/
private function _checkParameters($args)
{
// If no options are given to this widget...
if (!is_array($args) || (is_array($args) && count($args) == 0))
{
show_error('Second parameter of the widget call must be a NOT empty associative array');
}
else
else // ...otherwise
{
if ((!isset($args[FilterWidgetLib::APP_PARAMETER]) && !isset($args[FilterWidgetLib::DATASET_NAME_PARAMETER]))
// Parameters (app AND dataset name) OR filter id are mandatory
if ((!isset($args[FilterWidgetLib::APP]) && !isset($args[FilterWidgetLib::DATASET_NAME]))
&& !isset($args[FilterWidgetLib::FILTER_ID]))
{
show_error(
'The parameters ("'.FilterWidgetLib::APP_PARAMETER.'" AND "'.FilterWidgetLib::DATASET_NAME_PARAMETER.') OR "'.
'The parameters ("'.FilterWidgetLib::APP.'" AND "'.FilterWidgetLib::DATASET_NAME.') OR "'.
FilterWidgetLib::FILTER_ID.'" must be specified'
);
}
if (!isset($args[FilterWidgetLib::QUERY_PARAMETER]))
// The query parameter is mandatory
if (!isset($args[FilterWidgetLib::QUERY]))
{
show_error('The parameters "'.FilterWidgetLib::QUERY_PARAMETER.'" must be specified');
show_error('The parameter "'.FilterWidgetLib::QUERY.'" must be specified');
}
// The dataset representation parameter is mandatory
if (!isset($args[FilterWidgetLib::DATASET_REPRESENTATION]))
{
show_error('The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION.'" must be specified');
}
// Checks if the dataset representation parameter is valid
if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION])
&& $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABLESORTER
&& $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_PIVOTUI
@@ -377,6 +391,12 @@ class FilterWidget extends Widget
.FilterWidgetLib::DATASET_REP_TABULATOR.'")'
);
}
// If given the session timeout parameter must be a number
if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT]))
{
show_error('The parameter "'.FilterWidgetLib::SESSION_TIMEOUT.'" must be a number');
}
}
}
@@ -385,6 +405,9 @@ class FilterWidget extends Widget
*/
private function _startFilterWidget()
{
// Looks for expired filter widgets in session and drops them
$this->filterwidgetlib->dropExpiredFilterWidgets();
// Read the all session for this filter widget
$session = $this->filterwidgetlib->getSession();
@@ -402,14 +425,14 @@ class FilterWidget extends Widget
}
else // else if the filter loaded in session is the same that is being requested
{
// Get SESSION_RELOAD_DATASET from the session
$sessionReloadDataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_RELOAD_DATASET);
// Get SESSION_DATASET_RELOAD from the session
$sessionReloadDataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD);
// if Filter changed or reload is forced by parameter then reload the Dataset
if ($this->_reloadDataset === true || $sessionReloadDataset === true)
{
// Set as false to stop changing the dataset
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_RELOAD_DATASET, false);
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD, false);
// Generate dataset query using filters from the session
$datasetQuery = $this->filterwidgetlib->generateDatasetQuery(
@@ -467,8 +490,8 @@ class FilterWidget extends Widget
$this->filterwidgetlib->setSession(
array(
FilterWidgetLib::FILTER_ID => $this->_filterId, // the current filter id
FilterWidgetLib::APP_PARAMETER => $this->_app, // the current app parameter
FilterWidgetLib::DATASET_NAME_PARAMETER => $this->_datasetName, // the carrent dataset name
FilterWidgetLib::APP => $this->_app, // the current app parameter
FilterWidgetLib::DATASET_NAME => $this->_datasetName, // the carrent dataset name
FilterWidgetLib::SESSION_FILTER_NAME => $filterName, // the current filter name
FilterWidgetLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset
FilterWidgetLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields
@@ -479,7 +502,7 @@ class FilterWidget extends Widget
FilterWidgetLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset
FilterWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter
FilterWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset
FilterWidgetLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time
FilterWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time
FilterWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation
FilterWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options
FilterWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition
@@ -489,9 +512,11 @@ class FilterWidget extends Widget
}
}
// NOTE: latest operations to be performed in the session to be shure that they are always present
// To be always stored in the session, otherwise is not possible to load data from Filters controller
// NOTE: must the latest operation to be performed in the session to be shure that is always present
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions);
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions);
// Renew or set the session expiring time
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time()));
}
/**
+40 -15
View File
@@ -38,6 +38,8 @@ class TableWidget extends Widget
private $_reloadDataset; // Force Reload of Dataset
private $_sessionTimeout; // session expiring time
private static $_TableWidgetInstance; // static property that contains the instance of itself
/**
@@ -124,22 +126,23 @@ class TableWidget extends Widget
$this->_datasetRepresentation = null;
$this->_datasetRepresentationOptions = null;
$this->_datasetRepFieldsDefs = null;
$this->_sessionTimeout = TableWidgetLib::SESSION_DEFAULT_TIMEOUT;
// Retrieved the required permissions parameter if present
if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS_PARAMETER]))
if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS]))
{
$this->_requiredPermissions = $args[TableWidgetLib::REQUIRED_PERMISSIONS_PARAMETER];
$this->_requiredPermissions = $args[TableWidgetLib::REQUIRED_PERMISSIONS];
}
// How to retrieve data for the table: SQL statement or a result from DB
if (isset($args[TableWidgetLib::QUERY_PARAMETER]))
if (isset($args[TableWidgetLib::QUERY]))
{
$this->_query = $args[TableWidgetLib::QUERY_PARAMETER];
$this->_query = $args[TableWidgetLib::QUERY];
}
if (isset($args[TableWidgetLib::DATASET_RELOAD_PARAMETER]))
if (isset($args[TableWidgetLib::DATASET_RELOAD]))
{
$this->_reloadDataset = $args[TableWidgetLib::DATASET_RELOAD_PARAMETER];
$this->_reloadDataset = $args[TableWidgetLib::DATASET_RELOAD];
}
// Parameter is used to add extra columns to the dataset
@@ -197,6 +200,12 @@ class TableWidget extends Widget
{
$this->_datasetRepFieldsDefs = $args[TableWidgetLib::DATASET_REP_FIELDS_DEFS];
}
// To specify the expiring session time
if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[TableWidgetLib::SESSION_TIMEOUT]))
{
$this->_sessionTimeout = $args[TableWidgetLib::SESSION_TIMEOUT];
}
}
/**
@@ -204,27 +213,32 @@ class TableWidget extends Widget
*/
private function _checkParameters($args)
{
// If no options are given to this widget...
if (!is_array($args) || (is_array($args) && count($args) == 0))
{
show_error('Second parameter of the widget call must be a NOT empty associative array');
}
else
else // ...otherwise
{
// The unique id parameter is mandatory
if (!isset($args[TableWidgetLib::TABLE_UNIQUE_ID]))
{
show_error('The parameter "'.TableWidgetLib::TABLE_UNIQUE_ID.'" must be specified');
}
if (!isset($args[TableWidgetLib::QUERY_PARAMETER]))
// The query parameter is mandatory
if (!isset($args[TableWidgetLib::QUERY]))
{
show_error('The parameters "'.TableWidgetLib::QUERY_PARAMETER.'" must be specified');
show_error('The parameter "'.TableWidgetLib::QUERY.'" must be specified');
}
// The dataset representation parameter is mandatory
if (!isset($args[TableWidgetLib::DATASET_REPRESENTATION]))
{
show_error('The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.'" must be specified');
}
// Checks if the dataset representation parameter is valid
if (isset($args[TableWidgetLib::DATASET_REPRESENTATION])
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABLESORTER
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_PIVOTUI
@@ -238,6 +252,12 @@ class TableWidget extends Widget
.TableWidgetLib::DATASET_REP_TABULATOR.'")'
);
}
// If given the session timeout parameter must be a number
if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[TableWidgetLib::SESSION_TIMEOUT]))
{
show_error('The parameter "'.TableWidgetLib::SESSION_TIMEOUT.'" must be a number');
}
}
}
@@ -246,20 +266,23 @@ class TableWidget extends Widget
*/
private function _startTableWidget($tableUniqueId)
{
// Looks for expired table widgets in session and drops them
$this->tablewidgetlib->dropExpiredTableWidgets();
// Read the all session for this table widget
$session = $this->tablewidgetlib->getSession();
// If session is NOT empty -> a table was already loaded
if ($session != null)
{
// Get SESSION_RELOAD_DATASET from the session
$sessionReloadDataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_RELOAD_DATASET);
// Get SESSION_DATASET_RELOAD from the session
$sessionReloadDataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD);
// if Filter changed or reload is forced by parameter then reload the Dataset
if ($this->_reloadDataset === true || $sessionReloadDataset === true)
{
// Set as false to stop changing the dataset
$this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_RELOAD_DATASET, false);
$this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD, false);
// Generate dataset query using tables from the session
$datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query);
@@ -305,7 +328,7 @@ class TableWidget extends Widget
TableWidgetLib::SESSION_METADATA => $this->tablewidgetlib->getExecutedQueryMetaData(), // the metadata of the dataset
TableWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this table
TableWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset
TableWidgetLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time
TableWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time
TableWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation
TableWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options
TableWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition
@@ -314,9 +337,11 @@ class TableWidget extends Widget
}
}
// To be always stored in the session, otherwise is not possible to load data from Filters controller
// NOTE: must the latest operation to be performed in the session to be shure that is always present
$this->tablewidgetlib->setSessionElement(TableWidgetLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions);
// To be always stored in the session, otherwise is not possible to load data from Filters controller
$this->tablewidgetlib->setSessionElement(TableWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions);
// Renew or set the session expiring time
$this->filterwidgetlib->setSessionElement(TableWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time()));
}
/**
+2 -2
View File
@@ -575,8 +575,8 @@ function saveAnmeldung(lehrveranstaltung_id, termin_id)
studienverpflichtung_id = $("#studienverpflichtung option:selected").val();
var studiengang_kz = null;
if($('#select_studiengang').length)
studiengang_kz = $('#select_studiengang option:selected').val();
if($('#prestudent_studiengang').length)
studiengang_kz = $('#prestudent_studiengang option:selected').val();
$.ajax({
dataType: 'json',
@@ -632,24 +632,11 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null)
{
foreach ($prestudenten as $ps)
{
if($ps->studiengang_kz === $studiengang_kz)
if ($ps->getLaststatus($ps->prestudent_id, $stdsem))
{
if ($ps->getLaststatus($ps->prestudent_id, $stdsem))
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
$prestudent_id = $ps->prestudent_id;
}
else
{
if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch))
{
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
$prestudent_id = $ps->prestudent_id;
}
}
}
$prestudent_id = $ps->prestudent_id;
}
else
{
@@ -662,6 +649,16 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null)
}
}
}
else
{
if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch))
{
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
$prestudent_id = $ps->prestudent_id;
}
}
}
}
}
else
+6 -2
View File
@@ -457,10 +457,14 @@ class zeitaufzeichnung extends basis_db
{
$where = "uid=".$this->db_add_param($user);
if ($days!='')
$where.= " AND ende>(now() - INTERVAL '".$days." days')";
$where.= " AND start>(now() - INTERVAL '".$days." days')";
$qry = "SELECT
*, to_char ((ende-start),'HH24:MI') as diff,
*,
CASE WHEN (ende IS NOT NULL AND ende > start)
THEN to_char ((ende-start),'HH24:MI')
ELSE '0'
END as diff,
(SELECT (to_char(sum(ende-start),'DD')::integer)*24+to_char(sum(ende-start),'HH24')::integer || ':' || to_char(sum(ende-start),'MI')
FROM campus.tbl_zeitaufzeichnung
WHERE $where ) as summe
+90 -58
View File
@@ -33,6 +33,7 @@ require_once('../../include/adresse.class.php');
require_once('../../include/nation.class.php');
require_once('../../include/firma.class.php');
require_once('../../include/preincoming.class.php');
require_once('../../include/statusgrund.class.php');
$user = get_uid();
@@ -52,61 +53,67 @@ echo '<html>
<title>PreInteressenten</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../skin/vilesci.css" type="text/css">';
include('../../include/meta/jquery.php');
include('../../include/meta/jquery-tablesorter.php');
include('../../include/meta/jquery.php');
include('../../include/meta/jquery-tablesorter.php');
echo '</head>'; ?>
<script language="JavaScript" type="text/javascript">
<script language="JavaScript" type="text/javascript">
// Add parser through the tablesorter addParser method for sorting Studiensemester
$.tablesorter.addParser({
// set a unique id
id: "studiensemester",
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format data for normalization
$.tablesorter.addParser({
// set a unique id
id: "studiensemester",
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format data for normalization
var result = s.substr(2) + s.substr(0, 2);
return result;
},
// set type, either numeric or text
type: "text"
},
// set type, either numeric or text
type: "text"
});
$(document).ready(function()
{
$(document).ready(function()
{
$(".tablesorter").tablesorter(
{
widgets: ["zebra"]
});
$(".tablePreStudent").tablesorter(
{
headers: {
1: {
sorter:"insertamum"
}},
sortList: [[1,1],[2,0],[3,0]],
widgets: ["zebra"]
});
$(".tableKontakt").tablesorter(
{
headers:
{
3:
{
sorter: "shortDate", dateFormat: "yyyy-mm-dd"
}
},
sortList: [[0,0],[2,0],[3,1]],
widgets: ["zebra"]
});
widgets: ["zebra"]
});
$(".tablePreStudent").tablesorter(
{
headers: {
1: {
sorter:"insertamum"
}},
sortList: [[1,1],[2,0],[3,0]],
widgets: ["zebra"]
});
$(".tableKontakt").tablesorter(
{
headers:
{
3:
{
sorter: "shortDate", dateFormat: "yyyy-mm-dd"
}
},
sortList: [[0,0],[2,0],[3,1]],
widgets: ["zebra"]
});
});
</script>
<body class="Background_main">
<?php
</script>
<style>
.inactive
{
color: grey;
}
</style>
<body class="Background_main">
<?php
if(!$rechte->isBerechtigt('admin') &&
!$rechte->isBerechtigt('preinteressent') &&
!$rechte->isBerechtigt('assistenz'))
!$rechte->isBerechtigt('preinteressent') &&
!$rechte->isBerechtigt('assistenz'))
die('Sie haben keine Berechtigung fuer diese Seite');
if(isset($_GET['id']) && is_numeric($_GET['id']))
@@ -134,7 +141,7 @@ foreach ($kontakt->result as $row)
$insertdatum = $row->insertamum;
}
}
else
else
continue;
}
@@ -295,7 +302,7 @@ if(count($preinteressent->result)>0)
echo '</tbody></table>';
}
*/
//PreIncoming deprecated
/*
$preincoming = new preincoming();
@@ -331,11 +338,22 @@ foreach ($prestudent->result as $row)
{
$prestudentLastStatus = new prestudent();
$prestudentLastStatus->getLastStatus($row->prestudent_id);
$row->status_kurzbz = $prestudentLastStatus->status_kurzbz;
$row->studiensemester_kurzbz = $prestudentLastStatus->studiensemester_kurzbz;
$row->ausbildungssemester = $prestudentLastStatus->ausbildungssemester;
$row->datum = $prestudentLastStatus->datum;
$row->orgform_kurzbz = $prestudentLastStatus->orgform_kurzbz;
$row->studienplan_bezeichnung = $prestudentLastStatus->studienplan_bezeichnung;
if ($prestudentLastStatus->statusgrund_id != '')
{
$statusgrund = new statusgrund($prestudentLastStatus->statusgrund_id);
$row->statusgrund = $statusgrund->bezeichnung_mehrsprachig[DEFAULT_LANGUAGE];
}
else
{
$row->statusgrund = '';
}
}
// Sortiert PreStudenten nach Studiensemester
@@ -379,14 +397,28 @@ if(count($prestudent->result)>0)
</tr>
</thead><tbody>';
}
$class = '';
if ($row->status_kurzbz == 'Abgewiesener' || $row->status_kurzbz == 'Abbrecher' || $row->status_kurzbz == 'Absolvent' )
{
$class = 'class="inactive"';
}
$status = $row->status_kurzbz;
if ($row->ausbildungssemester != '')
{
$status .= ' ('.$row->ausbildungssemester.'. Semester)';
}
if ($row->statusgrund != '')
{
$status .= ' - '.$row->statusgrund;
}
echo '<tr>';
echo "<td>$row->prestudent_id</td>";
echo "<td>$row->studiensemester_kurzbz</td>";
echo "<td>$row->priorisierung</td>";
echo "<td>".$studiengang->kuerzel_arr[$row->studiengang_kz]."</td>";
echo "<td>$row->orgform_kurzbz</td>";
echo "<td>$row->studienplan_bezeichnung</td>";
echo "<td>".($row->reihungstestangetreten?'Ja':'Nein')."</td>";
echo "<td ".$class.">$row->prestudent_id</td>";
echo "<td ".$class.">$row->studiensemester_kurzbz</td>";
echo "<td ".$class.">$row->priorisierung</td>";
echo "<td ".$class.">".$studiengang->kuerzel_arr[$row->studiengang_kz]."</td>";
echo "<td ".$class.">$row->orgform_kurzbz</td>";
echo "<td ".$class.">$row->studienplan_bezeichnung</td>";
echo "<td ".$class.">".($row->reihungstestangetreten?'Ja':'Nein')."</td>";
$uid='';
$gruppe='';
$qry ="SELECT * FROM public.tbl_student WHERE prestudent_id='$row->prestudent_id'";
@@ -405,11 +437,11 @@ if(count($prestudent->result)>0)
}
}
}
echo "<td>$uid</td>";
echo "<td>$gruppe</td>";
echo "<td>$row->status_kurzbz ".($row->ausbildungssemester!=''?"($row->ausbildungssemester. Semester)":'')."</td>";
echo "<td ".$class.">$uid</td>";
echo "<td ".$class.">$gruppe</td>";
echo "<td ".$class.">".$status."</td>";
echo '</tr>';
$studiensemester_kurzbz = $row->studiensemester_kurzbz;
}
echo '</tbody></table>';