mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-22 09:22:22 +00:00
Merge branch 'filters'
This commit is contained in:
@@ -198,6 +198,7 @@ $config['fhc_acl'] = array
|
||||
'system.tbl_appdaten' => 'system/appdaten',
|
||||
'system.tbl_benutzerrolle' => 'basis/benutzerrolle',
|
||||
'system.tbl_berechtigung' => 'basis/berechtigung',
|
||||
'system.tbl_filters' => 'system/filters',
|
||||
'system.tbl_cronjob' => 'basis/cronjob',
|
||||
'system.tbl_phrase' => 'system/phrase',
|
||||
'system.tbl_phrasentext' => 'system/phrase',
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class TestFilterWidget extends VileSci_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->library('WidgetLib');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function sql()
|
||||
{
|
||||
echo $this->widgetlib->widget(
|
||||
'FilterWidget',
|
||||
array(
|
||||
'app' => 'core',
|
||||
'datasetName' => 'kontakts',
|
||||
'filterKurzbz' => 'This filter filters',
|
||||
'query' => '
|
||||
SELECT p.person_id AS "PersonId",
|
||||
p.nachname AS "Nachname",
|
||||
p.vorname AS "Vorname",
|
||||
k.kontakt AS "Email",
|
||||
p.aktiv AS "Aktiv",
|
||||
k.updateamum AS "Update date"
|
||||
FROM public.tbl_person p INNER JOIN public.tbl_kontakt k USING(person_id)
|
||||
WHERE p.aktiv = TRUE
|
||||
AND p.person_id = k.person_id
|
||||
AND k.kontakttyp = \'email\'
|
||||
AND p.person_id < 1000
|
||||
',
|
||||
'hideFilters' => true,
|
||||
'checkboxes' => array('PersonId'),
|
||||
'additionalColumns' => array('Delete', 'Edit'),
|
||||
'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) {
|
||||
|
||||
if ($fieldName == 'PersonId')
|
||||
{
|
||||
$datasetRaw->{$fieldName} = '<a href="view/'.$datasetRaw->PersonId.'">'.$fieldValue.'</a>';
|
||||
}
|
||||
elseif ($fieldName == 'Delete')
|
||||
{
|
||||
$datasetRaw->{$fieldName} = '<a href="delete/'.$datasetRaw->PersonId.'">Delete</a>';
|
||||
}
|
||||
elseif ($fieldName == 'Edit')
|
||||
{
|
||||
$datasetRaw->{$fieldName} = '<a href="edit/'.$datasetRaw->PersonId.'">Edit</a>';
|
||||
}
|
||||
|
||||
return $datasetRaw;
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,9 @@ class DB_Model extends FHC_Model
|
||||
protected $hasSequence; // False if this table has a composite primary key that is not using a sequence
|
||||
// True if this table has a primary key that uses a sequence
|
||||
|
||||
private $executedQueryMetaData;
|
||||
private $executedQueryListFields;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -670,6 +673,48 @@ class DB_Model extends FHC_Model
|
||||
return $this->fieldExists(UDFLib::COLUMN_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of the fields after having executed a query
|
||||
*/
|
||||
public function getExecutedQueryListFields()
|
||||
{
|
||||
return $this->executedQueryListFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get meda data info about the retrived fields after having executed a query
|
||||
*/
|
||||
public function getExecutedQueryMetaData()
|
||||
{
|
||||
return $this->executedQueryMetaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like execQuery, but it allows only to perform queries to read data
|
||||
*/
|
||||
public function execReadOnlyQuery($query, $parametersArray = null)
|
||||
{
|
||||
$result = error('You are allowed to run only query for reading data'); //
|
||||
$cleanedQuery = trim(preg_replace('/\t|\n|\r|;/', '', $query)); //
|
||||
|
||||
//
|
||||
if (stripos($cleanedQuery, 'SELECT') == 0
|
||||
&& (stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false)
|
||||
&& (stripos($cleanedQuery, 'UPDATE') > 0 || stripos($cleanedQuery, 'UPDATE') == false)
|
||||
&& (stripos($cleanedQuery, 'CREATE') > 0 || stripos($cleanedQuery, 'CREATE') == false)
|
||||
&& (stripos($cleanedQuery, 'DELETE') > 0 || stripos($cleanedQuery, 'DELETE') == false)
|
||||
&& (stripos($cleanedQuery, 'ALTER') > 0 || stripos($cleanedQuery, 'ALTER') == false)
|
||||
&& (stripos($cleanedQuery, 'GRANT') > 0 || stripos($cleanedQuery, 'GRANT') == false)
|
||||
&& (stripos($cleanedQuery, 'DROP') > 0 || stripos($cleanedQuery, 'DROP') == false))
|
||||
{
|
||||
$queryToExec = str_replace(';', '', $query); //
|
||||
|
||||
$result = $this->execQuery($queryToExec, $parametersArray);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Protected methods
|
||||
|
||||
@@ -809,20 +854,23 @@ class DB_Model extends FHC_Model
|
||||
if (is_object($result))
|
||||
{
|
||||
$toBeConverterdArray = array(); // Fields to be converted
|
||||
$metaDataArray = $result->field_data(); // Fields information
|
||||
for ($i = 0; $i < count($metaDataArray); $i++) // Looking for booleans and arrays
|
||||
|
||||
$this->executedQueryMetaData = $result->field_data(); // Fields information
|
||||
$this->executedQueryListFields = $result->list_fields(); // List of the retrived fields
|
||||
|
||||
for ($i = 0; $i < count($this->executedQueryMetaData); $i++) // Looking for booleans and arrays
|
||||
{
|
||||
// If array type, boolean type OR a UDF
|
||||
if (strpos($metaDataArray[$i]->type, DB_Model::PGSQL_ARRAY_TYPE) !== false
|
||||
|| $metaDataArray[$i]->type == DB_Model::PGSQL_BOOLEAN_TYPE
|
||||
|| $this->udflib->isUDFColumn($metaDataArray[$i]->name, $metaDataArray[$i]->type))
|
||||
if (strpos($this->executedQueryMetaData[$i]->type, DB_Model::PGSQL_ARRAY_TYPE) !== false
|
||||
|| $this->executedQueryMetaData[$i]->type == DB_Model::PGSQL_BOOLEAN_TYPE
|
||||
|| $this->udflib->isUDFColumn($this->executedQueryMetaData[$i]->name, $this->executedQueryMetaData[$i]->type))
|
||||
{
|
||||
// Name and type of the field to be converted
|
||||
$toBeConverted = new stdClass();
|
||||
// Set the type of the field to be converted
|
||||
$toBeConverted->type = $metaDataArray[$i]->type;
|
||||
$toBeConverted->type = $this->executedQueryMetaData[$i]->type;
|
||||
// Set the name of the field to be converted
|
||||
$toBeConverted->name = $metaDataArray[$i]->name;
|
||||
$toBeConverted->name = $this->executedQueryMetaData[$i]->name;
|
||||
// Add the field to be converted to $toBeConverterdArray
|
||||
array_push($toBeConverterdArray, $toBeConverted);
|
||||
}
|
||||
|
||||
@@ -625,7 +625,7 @@ class UDFLib
|
||||
elseif (isset($jsonSchema->{UDFLib::LIST_VALUES}->sql))
|
||||
{
|
||||
// UDFModel is loaded in method _loadUDF that is called before the current method
|
||||
$queryResult = $this->_ci->UDFModel->execQuery($jsonSchema->{UDFLib::LIST_VALUES}->sql);
|
||||
$queryResult = $this->_ci->UDFModel->execReadOnlyQuery($jsonSchema->{UDFLib::LIST_VALUES}->sql);
|
||||
if (hasData($queryResult))
|
||||
{
|
||||
$parameters = $queryResult->retval;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
class Filters_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_filters';
|
||||
$this->pk = 'filter_id';
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ class UDF_model extends DB_Model
|
||||
const STRING_NULL = 'null';
|
||||
const STRING_TRUE = 'true';
|
||||
const STRING_FALSE = 'false';
|
||||
|
||||
|
||||
const UDF_DROPDOWN_TYPE = 'dropdown';
|
||||
const UDF_MULTIPLEDROPDOWN_TYPE = 'multipledropdown';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -20,41 +20,14 @@ class UDF_model extends DB_Model
|
||||
$this->pk = array('schema', 'table');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override DB_Model method execQuery to allow only to perform queries to read data
|
||||
*/
|
||||
public function execQuery($query, $parametersArray = null)
|
||||
{
|
||||
//
|
||||
if (
|
||||
(
|
||||
substr($query, 0, 6) == 'SELECT'
|
||||
|| substr($query, 0, 4) == 'WITH'
|
||||
)
|
||||
&&
|
||||
(
|
||||
!stripos($query, 'INSERT')
|
||||
&& !stripos($query, 'UPDATE')
|
||||
&& !stripos($query, 'DELETE')
|
||||
)
|
||||
)
|
||||
{
|
||||
return parent::execQuery($query, $parametersArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
return error('You are allowed to run only query for reading data');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all the UDF for this table
|
||||
*/
|
||||
public function getUDFsDefinitions($schemaAndTable)
|
||||
{
|
||||
$st = $this->getSchemaAndTable($schemaAndTable);
|
||||
|
||||
|
||||
$this->addSelect(UDFLib::COLUMN_JSON_DESCRIPTION);
|
||||
$udfResults = $this->loadWhere(
|
||||
array(
|
||||
@@ -62,13 +35,13 @@ class UDF_model extends DB_Model
|
||||
'table' => $st->table
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
return $udfResults;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// These methods work only with the this version of FAS, not with the future versions
|
||||
|
||||
|
||||
/**
|
||||
* Methods to save data from FAS
|
||||
*/
|
||||
@@ -77,53 +50,53 @@ class UDF_model extends DB_Model
|
||||
$result = error('No way man!');
|
||||
$resultPerson = success('person');
|
||||
$resultPrestudent = success('prestudent');
|
||||
|
||||
|
||||
$person_id = $udfs['person_id'];
|
||||
unset($udfs['person_id']);
|
||||
|
||||
|
||||
$prestudent_id = $udfs['prestudent_id'];
|
||||
unset($udfs['prestudent_id']);
|
||||
|
||||
|
||||
$jsons = array();
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
if (isset($person_id))
|
||||
{
|
||||
// Load model Person_model
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
|
||||
$result = $this->load(array('public', 'tbl_person'));
|
||||
if (isSuccess($result) && count($result->retval) == 1)
|
||||
{
|
||||
$jsons = json_decode($result->retval[0]->jsons);
|
||||
}
|
||||
|
||||
|
||||
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
|
||||
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
|
||||
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
|
||||
|
||||
|
||||
$resultPerson = $this->PersonModel->update($person_id, $udfs);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
if (isset($prestudent_id))
|
||||
{
|
||||
// Load model Prestudent_model
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
|
||||
$result = $this->load(array('public', 'tbl_prestudent'));
|
||||
if (isSuccess($result) && count($result->retval) == 1)
|
||||
{
|
||||
$jsons = json_decode($result->retval[0]->jsons);
|
||||
}
|
||||
|
||||
|
||||
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
|
||||
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
|
||||
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
|
||||
|
||||
|
||||
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
|
||||
}
|
||||
|
||||
|
||||
if (isSuccess($resultPerson) && isSuccess($resultPrestudent))
|
||||
{
|
||||
$result = success(array($resultPerson->retval, $resultPrestudent->retval));
|
||||
@@ -136,17 +109,17 @@ class UDF_model extends DB_Model
|
||||
{
|
||||
$result = $resultPrestudent;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function _fillMissingChkboxUDF($udfs, $jsons)
|
||||
{
|
||||
$_fillMissingChkboxUDF = $udfs;
|
||||
|
||||
|
||||
foreach($jsons as $udfDescription)
|
||||
{
|
||||
if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE)
|
||||
@@ -168,17 +141,17 @@ class UDF_model extends DB_Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $_fillMissingChkboxUDF;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function _fillMissingDropdownUDF($udfs, $jsons)
|
||||
{
|
||||
$_fillMissingDropdownUDF = $udfs;
|
||||
|
||||
|
||||
foreach($jsons as $udfDescription)
|
||||
{
|
||||
if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE
|
||||
@@ -194,17 +167,17 @@ class UDF_model extends DB_Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $_fillMissingDropdownUDF;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function _fillMissingTextUDF($udfs, $jsons)
|
||||
{
|
||||
$_fillMissingTextUDF = $udfs;
|
||||
|
||||
|
||||
foreach($jsons as $udfDescription)
|
||||
{
|
||||
if ($udfDescription->{UDFLib::TYPE} == 'textarea'
|
||||
@@ -220,7 +193,7 @@ class UDF_model extends DB_Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $_fillMissingTextUDF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +69,17 @@ if($jqueryV1 && $jqueryCurrent)
|
||||
<script language="Javascript" type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
$("#<?php echo $tableid; ?>").tablesorter(
|
||||
// Checks if the table contains data (rows)
|
||||
if ($('#<?php echo $tableid; ?>').find('tbody:empty').length == 0
|
||||
&& $('#<?php echo $tableid; ?>').find('tr:empty').length == 0)
|
||||
{
|
||||
sortList: [[<?php echo $sortList; ?>]],
|
||||
widgets: ["<?php echo $widgets; ?>"],
|
||||
headers: {<?php echo $headers; ?>}
|
||||
});
|
||||
$("#<?php echo $tableid; ?>").tablesorter(
|
||||
{
|
||||
sortList: [[<?php echo $sortList; ?>]],
|
||||
widgets: ["<?php echo $widgets; ?>"],
|
||||
headers: {<?php echo $headers; ?>}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php endif ?>
|
||||
@@ -108,4 +113,5 @@ if($jqueryV1 && $jqueryCurrent)
|
||||
<?php if($widgetsCSS) : ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('skin/widgets.css'); ?>" />
|
||||
<?php endif ?>
|
||||
|
||||
</head>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
$this->load->view(
|
||||
'templates/header',
|
||||
array('title' => 'Filters', 'tablesort' => true, 'tableid' => 'tableDataset', 'widgets' => 'zebra')
|
||||
);
|
||||
?>
|
||||
<script language="Javascript" type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#addField").change(function() {
|
||||
$("#filterForm").submit();
|
||||
});
|
||||
|
||||
$(".remove-field").each(function() {
|
||||
$(this).click(function() {
|
||||
$("#rmField").val($(this).attr('fieldToRemove'));
|
||||
$("#filterForm").submit();
|
||||
});
|
||||
});
|
||||
|
||||
$("#addFilter").change(function() {
|
||||
$("#filterForm").submit();
|
||||
});
|
||||
|
||||
$(".remove-filter").each(function() {
|
||||
$(this).click(function() {
|
||||
$("#rmFilter").val($(this).attr('filterToRemove'));
|
||||
$("#filterForm").submit();
|
||||
});
|
||||
});
|
||||
|
||||
$(".select-filter-operation").change(function() {
|
||||
$("#filterForm").submit();
|
||||
});
|
||||
|
||||
$(".select-filter-operation-value").keydown(function(event) {
|
||||
if (event.which == 13)
|
||||
{
|
||||
$("#filterForm").submit();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<body>
|
||||
<form id="filterForm" method="POST" action="<?php echo current_url(); ?>">
|
||||
<div>
|
||||
<?php FilterWidget::loadViewSelectFields($listFields); ?>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<?php FilterWidget::loadViewSelectFilters($metaData); ?>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<?php FilterWidget::loadViewTableDataset($dataset); ?>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
<?php
|
||||
$this->load->view('templates/footer');
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<div>
|
||||
<?php
|
||||
$selectedFields = FilterWidget::getSelectedFields();
|
||||
|
||||
for ($selectedFieldsCounter = 0; $selectedFieldsCounter < count($selectedFields); $selectedFieldsCounter++)
|
||||
{
|
||||
$selectedField = $selectedFields[$selectedFieldsCounter];
|
||||
?>
|
||||
<input type="button" value="<?php echo $selectedField; ?> X" class="remove-field" fieldToRemove="<?php echo $selectedField; ?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<input type="hidden" id="<?php echo FilterWidget::CMD_REMOVE_FIELD; ?>" name="<?php echo FilterWidget::CMD_REMOVE_FIELD; ?>" value="">
|
||||
</div>
|
||||
<div>
|
||||
<span>
|
||||
Add field:
|
||||
</span>
|
||||
<span>
|
||||
<select id="<?php echo FilterWidget::CMD_ADD_FIELD; ?>" name="<?php echo FilterWidget::CMD_ADD_FIELD; ?>">
|
||||
<option value="">Select a field to add..</option>
|
||||
<?php
|
||||
for ($listFieldsCounter = 0; $listFieldsCounter < count($listFields); $listFieldsCounter++)
|
||||
{
|
||||
$listField = $listFields[$listFieldsCounter];
|
||||
?>
|
||||
<option value="<?php echo $listField; ?>"><?php echo $listField; ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
@@ -0,0 +1,47 @@
|
||||
<div>
|
||||
<?php
|
||||
$selectedFilters = FilterWidget::getSelectedFilters();
|
||||
|
||||
for ($filtersCounter = 0; $filtersCounter < count($selectedFilters); $filtersCounter++)
|
||||
{
|
||||
$selectedFilter = $selectedFilters[$filtersCounter];
|
||||
|
||||
$md = FilterWidget::getFilterMetaData($selectedFilter, $metaData);
|
||||
?>
|
||||
<div>
|
||||
|
||||
<span>
|
||||
<?php echo $md->name; ?>
|
||||
</span>
|
||||
|
||||
<?php echo FilterWidget::renderFilterType($md); ?>
|
||||
|
||||
<span>
|
||||
<input type="button" value="X" class="remove-filter" filterToRemove="<?php echo $md->name; ?>">
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<input type="hidden" id="<?php echo FilterWidget::CMD_REMOVE_FILTER; ?>" name="<?php echo FilterWidget::CMD_REMOVE_FILTER; ?>" value="">
|
||||
</div>
|
||||
<div>
|
||||
<span>
|
||||
Add filter:
|
||||
</span>
|
||||
<span>
|
||||
<select id="<?php echo FilterWidget::CMD_ADD_FILTER; ?>" name="<?php echo FilterWidget::CMD_ADD_FILTER; ?>">
|
||||
<option value="">Select a filter to add...</option>
|
||||
<?php
|
||||
for ($listFieldsCounter = 0; $listFieldsCounter < count($listFields); $listFieldsCounter++)
|
||||
{
|
||||
$field = $listFields[$listFieldsCounter];
|
||||
?>
|
||||
<option value="<?php echo $field; ?>"><?php echo $field; ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
$results = $dataset->retval;
|
||||
|
||||
$selectedFields = FilterWidget::getSelectedFields();
|
||||
$additionalColumns = FilterWidget::getAdditionalColumns();
|
||||
$checkboxes = FilterWidget::getCheckboxes();
|
||||
?>
|
||||
|
||||
<div>
|
||||
<table class="tablesorter" id="tableDataset">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
if ($checkboxes != null)
|
||||
{
|
||||
?>
|
||||
<th title="Select">Select</th>
|
||||
<?php
|
||||
}
|
||||
|
||||
for ($selectedFieldsCounter = 0; $selectedFieldsCounter < count($selectedFields); $selectedFieldsCounter++)
|
||||
{
|
||||
$selectedField = $selectedFields[$selectedFieldsCounter];
|
||||
?>
|
||||
<th title="<?php echo $selectedField; ?>"><?php echo $selectedField; ?></th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
for ($additionalColumnsCounter = 0; $additionalColumnsCounter < count($additionalColumns); $additionalColumnsCounter++)
|
||||
{
|
||||
$additionalColumn = $additionalColumns[$additionalColumnsCounter];
|
||||
?>
|
||||
<th title="<?php echo $additionalColumn; ?>"><?php echo $additionalColumn; ?></th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
for ($resultsCounter = 0; $resultsCounter < count($results); $resultsCounter++)
|
||||
{
|
||||
$result = $results[$resultsCounter];
|
||||
?>
|
||||
<tr>
|
||||
<?php
|
||||
if ($checkboxes != null)
|
||||
{
|
||||
?>
|
||||
<td>
|
||||
<input type="checkbox" name="<?php echo $checkboxes[0]; ?>[]" value="<?php echo $result->{$checkboxes[0]}; ?>">
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
|
||||
for ($selectedFieldsCounter = 0; $selectedFieldsCounter < count($selectedFields); $selectedFieldsCounter++)
|
||||
{
|
||||
$selectedField = $selectedFields[$selectedFieldsCounter];
|
||||
|
||||
if (array_key_exists($selectedField, $result))
|
||||
{
|
||||
$formattedResult = FilterWidget::formatRaw($selectedField, $result->{$selectedField}, $result);
|
||||
?>
|
||||
<td>
|
||||
<?php
|
||||
echo $formattedResult->{$selectedField};
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
for ($additionalColumnsCounter = 0; $additionalColumnsCounter < count($additionalColumns); $additionalColumnsCounter++)
|
||||
{
|
||||
$additionalColumn = $additionalColumns[$additionalColumnsCounter];
|
||||
$formattedResult = FilterWidget::formatRaw($additionalColumn, null, $result);
|
||||
?>
|
||||
<td>
|
||||
<?php
|
||||
echo $formattedResult->{$additionalColumn};
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,864 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class FilterWidget extends Widget
|
||||
{
|
||||
const APP_PARAMETER = 'app';
|
||||
const DATASET_NAME_PARAMETER = 'datasetName';
|
||||
const FILTER_KURZBZ = 'filterKurzbz';
|
||||
const FILTER_ID = 'filterId';
|
||||
const QUERY_PARAMETER = 'query';
|
||||
const DB_RESULT = 'dbResult';
|
||||
const ADDITIONAL_COLUMNS = 'additionalColumns';
|
||||
const FORMAT_RAW = 'formatRaw';
|
||||
const CHECKBOXES = 'checkboxes';
|
||||
|
||||
const DATASET_PARAMETER = 'dataset';
|
||||
const METADATA_PARAMETER = 'metaData';
|
||||
const LIST_FIELDS_PARAMETER = 'listFields';
|
||||
|
||||
const WIDGET_URL_FILTER = 'widgets/filter/filter';
|
||||
const WIDGET_URL_SELECT_FIELDS = 'widgets/filter/selectFields';
|
||||
const WIDGET_URL_TABLE_DATASET = 'widgets/filter/tableDataset';
|
||||
const WIDGET_URL_SELECT_FILTERS = 'widgets/filter/selectFilters';
|
||||
|
||||
const SESSION_NAME = 'FILTER';
|
||||
|
||||
const SELECTED_FIELDS = 'selectedFields';
|
||||
const SELECTED_FILTERS = 'selectedFilters';
|
||||
const ACTIVE_FILTERS = 'activeFilters';
|
||||
const ACTIVE_FILTERS_OPERATION = 'activeFiltersOperation';
|
||||
|
||||
const ACTIVE_FILTER_OPERATION_POSTFIX = '-operation';
|
||||
|
||||
const CMD_ADD_FILTER = 'addFilter';
|
||||
const CMD_REMOVE_FILTER = 'rmFilter';
|
||||
const CMD_ADD_FIELD = 'addField';
|
||||
const CMD_REMOVE_FIELD = 'rmField';
|
||||
|
||||
const OP_EQUAL = 'equal';
|
||||
const OP_NOT_EQUAL = 'nequal';
|
||||
const OP_GREATER_THAN = 'gt';
|
||||
const OP_LESS_THAN = 'ld';
|
||||
const OP_IS_TRUE = 'true';
|
||||
const OP_IS_FALSE = 'false';
|
||||
const OP_CONTAINS = 'contains';
|
||||
const OP_NOT_CONTAINS = 'ncontains';
|
||||
|
||||
const DEFAULT_DATE_FORMAT = 'd.m.Y H:i:s';
|
||||
|
||||
private $app;
|
||||
private $query;
|
||||
private $datasetName;
|
||||
private $filterKurzbz;
|
||||
private $filterId;
|
||||
private $additionalColumns;
|
||||
private $formatRaw;
|
||||
private $checkboxes;
|
||||
|
||||
private $metaData;
|
||||
|
||||
private static $FilterWidgetInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct($name, $args = array())
|
||||
{
|
||||
parent::__construct($name, $args); //
|
||||
|
||||
$this->_initFilterWidget($args); //
|
||||
|
||||
$this->_initSession(); //
|
||||
|
||||
//
|
||||
$this->load->model('system/Filters_model', 'FiltersModel');
|
||||
|
||||
self::$FilterWidgetInstance = $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function display($widgetData)
|
||||
{
|
||||
//
|
||||
$this->_loadFilter();
|
||||
|
||||
//
|
||||
$this->_setSessionFilterData();
|
||||
|
||||
//
|
||||
$this->FiltersModel->resetQuery();
|
||||
|
||||
//
|
||||
$dataset = @$this->FiltersModel->execReadOnlyQuery($this->_generateQuery());
|
||||
|
||||
//
|
||||
$listFields = $this->FiltersModel->getExecutedQueryListFields();
|
||||
|
||||
//
|
||||
$this->metaData = $this->FiltersModel->getExecutedQueryMetaData();
|
||||
|
||||
//
|
||||
$this->loadViewFilters($listFields, $this->metaData, $dataset);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getSelectedFields()
|
||||
{
|
||||
return self::_getFromSession(self::SELECTED_FIELDS);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getSelectedFilters()
|
||||
{
|
||||
return self::_getFromSession(self::SELECTED_FILTERS);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getAdditionalColumns()
|
||||
{
|
||||
return self::_getFromSession(self::ADDITIONAL_COLUMNS);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function loadViewTableDataset($dataset)
|
||||
{
|
||||
self::_loadView(
|
||||
self::WIDGET_URL_TABLE_DATASET,
|
||||
array(
|
||||
self::DATASET_PARAMETER => $dataset
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function loadViewSelectFilters($metaData)
|
||||
{
|
||||
self::_loadView(self::WIDGET_URL_SELECT_FILTERS, array(self::METADATA_PARAMETER => $metaData));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function loadViewSelectFields($listFields)
|
||||
{
|
||||
self::_loadView(self::WIDGET_URL_SELECT_FIELDS, array(self::LIST_FIELDS_PARAMETER => $listFields));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getFilterMetaData($filter, $metaData)
|
||||
{
|
||||
$md = null;
|
||||
|
||||
for ($metaDataCounter = 0; $metaDataCounter < count($metaData); $metaDataCounter++)
|
||||
{
|
||||
if ($metaData[$metaDataCounter]->name == $filter)
|
||||
{
|
||||
$md = $metaData[$metaDataCounter];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $md;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function renderFilterType($filterMetaData)
|
||||
{
|
||||
$html = '';
|
||||
$activeFilterValue = self::_getActiveFilterValue($filterMetaData->name);
|
||||
$activeFilterOperationValue = self::_getActiveFilterOperationValue($filterMetaData->name);
|
||||
|
||||
if ($filterMetaData->type == 'int4')
|
||||
{
|
||||
$html = '
|
||||
<span>
|
||||
<select name="%s" class="select-filter-operation">
|
||||
<option value="'.self::OP_EQUAL.'" '.($activeFilterOperationValue == self::OP_EQUAL ? 'selected' : '').'>equal</option>
|
||||
<option value="'.self::OP_NOT_EQUAL.'" '.($activeFilterOperationValue == self::OP_NOT_EQUAL ? 'selected' : '').'>not equal</option>
|
||||
<option value="'.self::OP_GREATER_THAN.'" '.($activeFilterOperationValue == self::OP_GREATER_THAN ? 'selected' : '').'>greater than</option>
|
||||
<option value="'.self::OP_LESS_THAN.'" '.($activeFilterOperationValue == self::OP_LESS_THAN ? 'selected' : '').'>less than</option>
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
<input type="number" name="%s" value="%s" class="select-filter-operation-value">
|
||||
</span>
|
||||
';
|
||||
}
|
||||
elseif ($filterMetaData->type == 'varchar')
|
||||
{
|
||||
$html = '
|
||||
<span>
|
||||
<select name="%s" class="select-filter-operation">
|
||||
<option value="'.self::OP_CONTAINS.'" '.($activeFilterOperationValue == self::OP_CONTAINS ? 'selected' : '').'>contains</option>
|
||||
<option value="'.self::OP_NOT_CONTAINS.'" '.($activeFilterOperationValue == self::OP_NOT_CONTAINS ? 'selected' : '').'>does not contain</option>
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
<input type="text" name="%s" value="%s" class="select-filter-operation-value">
|
||||
</span>
|
||||
';
|
||||
}
|
||||
elseif ($filterMetaData->type == 'bool')
|
||||
{
|
||||
$html = '
|
||||
<span>
|
||||
<select name="%s" class="select-filter-operation">
|
||||
<option value="'.self::OP_IS_TRUE.'" '.($activeFilterOperationValue == self::OP_IS_TRUE ? 'selected' : '').'>is true</option>
|
||||
<option value="'.self::OP_IS_FALSE.'" '.($activeFilterOperationValue == self::OP_IS_FALSE ? 'selected' : '').'>is false</option>
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
<input type="hidden" name="%s" value="%s">
|
||||
</span>
|
||||
';
|
||||
}
|
||||
elseif ($filterMetaData->type == 'timestamp')
|
||||
{
|
||||
$html = '
|
||||
<span>
|
||||
<select name="%s" class="select-filter-operation">
|
||||
<option value="'.self::OP_LESS_THAN.'" '.($activeFilterOperationValue == self::OP_LESS_THAN ? 'selected' : '').'>less than</option>
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
<input type="text" name="%s" value="%s" class="select-filter-operation-value">
|
||||
</span>
|
||||
<select name="" class="select-filter-">
|
||||
<option value="">Days</option>
|
||||
<option value="">Months</option>
|
||||
</select>
|
||||
';
|
||||
}
|
||||
|
||||
return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $activeFilterValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function formatRaw($fieldName, $fieldValue, $datasetRaw)
|
||||
{
|
||||
$tmpDatasetRaw = null;
|
||||
|
||||
if (is_object($datasetRaw))
|
||||
{
|
||||
$tmpDatasetRaw = clone $datasetRaw;
|
||||
$tmpMetaData = self::getFilterMetaData($fieldName, self::$FilterWidgetInstance->metaData);
|
||||
|
||||
if (is_bool($fieldValue))
|
||||
{
|
||||
$tmpDatasetRaw->{$fieldName} = $fieldValue === true ? 'true' : 'false';
|
||||
}
|
||||
elseif ($tmpMetaData != null && $tmpMetaData->type == 'timestamp')
|
||||
{
|
||||
$tmpDatasetRaw->{$fieldName} = date(self::DEFAULT_DATE_FORMAT, strtotime($fieldValue));
|
||||
}
|
||||
|
||||
$formatRaw = self::$FilterWidgetInstance->getFormatRaw();
|
||||
|
||||
if ($formatRaw != null)
|
||||
{
|
||||
$tmpDatasetRaw = $formatRaw($fieldName, $fieldValue, $tmpDatasetRaw);
|
||||
}
|
||||
}
|
||||
|
||||
return $tmpDatasetRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getCheckboxes()
|
||||
{
|
||||
return self::$FilterWidgetInstance->_getCheckboxes();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Protected
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function loadViewFilters($listFields, $metaData, $dataset)
|
||||
{
|
||||
// Loads views
|
||||
$this->view(
|
||||
self::WIDGET_URL_FILTER,
|
||||
array(
|
||||
self::DATASET_PARAMETER => $dataset,
|
||||
self::METADATA_PARAMETER => $metaData,
|
||||
self::LIST_FIELDS_PARAMETER => $listFields
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function getFormatRaw()
|
||||
{
|
||||
return $this->formatRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function _getCheckboxes()
|
||||
{
|
||||
return $this->checkboxes;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static function _getFromSession($key)
|
||||
{
|
||||
$_getFromSession = null;
|
||||
$ci =& get_instance();
|
||||
$filterSessionArray = $ci->session->userdata(self::SESSION_NAME);
|
||||
|
||||
if (isset($filterSessionArray[$key]))
|
||||
{
|
||||
$_getFromSession = $filterSessionArray[$key];
|
||||
}
|
||||
|
||||
return $_getFromSession;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static function _getActiveFilterValue($filterName)
|
||||
{
|
||||
$getActiveFilterValue = '';
|
||||
|
||||
$activeFields = self::_getFromSession(self::ACTIVE_FILTERS);
|
||||
|
||||
if (isset($activeFields[$filterName]))
|
||||
{
|
||||
$getActiveFilterValue = $activeFields[$filterName];
|
||||
}
|
||||
|
||||
return $getActiveFilterValue;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static function _getActiveFilterOperationValue($filterName)
|
||||
{
|
||||
$getActiveFilterOperationValue = '';
|
||||
|
||||
$activeFieldsOperation = self::_getFromSession(self::ACTIVE_FILTERS_OPERATION);
|
||||
|
||||
if (isset($activeFieldsOperation[$filterName]))
|
||||
{
|
||||
$getActiveFilterOperationValue = $activeFieldsOperation[$filterName];
|
||||
}
|
||||
|
||||
return $getActiveFilterOperationValue;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static function _loadView($viewName, $parameters)
|
||||
{
|
||||
$ci =& get_instance();
|
||||
$ci->load->view($viewName, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _initSession()
|
||||
{
|
||||
$filterSessionArray = array();
|
||||
|
||||
if (isset($_SESSION[self::SESSION_NAME]))
|
||||
{
|
||||
$filterSessionArray = $_SESSION[self::SESSION_NAME];
|
||||
}
|
||||
|
||||
if (!isset($filterSessionArray[self::SELECTED_FIELDS]))
|
||||
{
|
||||
$filterSessionArray[self::SELECTED_FIELDS] = array();
|
||||
}
|
||||
|
||||
if (!isset($filterSessionArray[self::SELECTED_FILTERS]))
|
||||
{
|
||||
$filterSessionArray[self::SELECTED_FILTERS] = array();
|
||||
}
|
||||
|
||||
if (!isset($filterSessionArray[self::ACTIVE_FILTERS]))
|
||||
{
|
||||
$filterSessionArray[self::ACTIVE_FILTERS] = array();
|
||||
}
|
||||
|
||||
if (!isset($filterSessionArray[self::ACTIVE_FILTERS_OPERATION]))
|
||||
{
|
||||
$filterSessionArray[self::ACTIVE_FILTERS_OPERATION] = array();
|
||||
}
|
||||
|
||||
if (!isset($filterSessionArray[self::ADDITIONAL_COLUMNS]))
|
||||
{
|
||||
$filterSessionArray[self::ADDITIONAL_COLUMNS] = array();
|
||||
}
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _initFilterWidget($args)
|
||||
{
|
||||
$this->app = null;
|
||||
$this->query = null;
|
||||
$this->datasetName = null;
|
||||
$this->filterKurzbz = null;
|
||||
$this->filterId = null;
|
||||
$this->additionalColumns = null;
|
||||
$this->formatRaw = null;
|
||||
$this->checkboxes = null;
|
||||
|
||||
if (!is_array($args) || (is_array($args) && count($args) == 0))
|
||||
{
|
||||
show_error('Second parameter must be a not empty associative array');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((
|
||||
!isset($args[self::APP_PARAMETER])
|
||||
&& !isset($args[self::DATASET_NAME_PARAMETER])
|
||||
&& !isset($args[self::FILTER_KURZBZ])
|
||||
)
|
||||
&& !isset($args[self::FILTER_ID]))
|
||||
{
|
||||
show_error('At least one parameters must be specified 1');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($args[self::QUERY_PARAMETER]) && !isset($args[self::DB_RESULT]))
|
||||
{
|
||||
show_error('At least one parameters must be specified 2');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($args[self::APP_PARAMETER])
|
||||
&& isset($args[self::DATASET_NAME_PARAMETER])
|
||||
&& isset($args[self::FILTER_KURZBZ]))
|
||||
{
|
||||
$this->app = $args[self::APP_PARAMETER];
|
||||
$this->datasetName = $args[self::DATASET_NAME_PARAMETER];
|
||||
$this->filterKurzbz = $args[self::FILTER_KURZBZ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->filterId = $args[self::FILTER_ID];
|
||||
}
|
||||
|
||||
if (isset($args[self::QUERY_PARAMETER]))
|
||||
{
|
||||
$this->query = $args[self::QUERY_PARAMETER];
|
||||
}
|
||||
elseif (isset($args[self::DB_RESULT]))
|
||||
{
|
||||
$this->query = $args[self::DB_RESULT];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($args[self::ADDITIONAL_COLUMNS])
|
||||
&& is_array($args[self::ADDITIONAL_COLUMNS])
|
||||
&& count($args[self::ADDITIONAL_COLUMNS]) > 0)
|
||||
{
|
||||
$this->additionalColumns = $args[self::ADDITIONAL_COLUMNS];
|
||||
}
|
||||
|
||||
if (isset($args[self::FORMAT_RAW]) && is_callable($args[self::FORMAT_RAW]))
|
||||
{
|
||||
$this->formatRaw = $args[self::FORMAT_RAW];
|
||||
}
|
||||
|
||||
if (isset($args[self::CHECKBOXES])
|
||||
&& is_array($args[self::CHECKBOXES])
|
||||
&& count($args[self::CHECKBOXES]) > 0)
|
||||
{
|
||||
$this->checkboxes = $args[self::CHECKBOXES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _loadFilter()
|
||||
{
|
||||
//
|
||||
$this->FiltersModel->resetQuery();
|
||||
|
||||
//
|
||||
$this->FiltersModel->addJoin('public.tbl_benutzer', 'person_id');
|
||||
|
||||
//
|
||||
$this->FiltersModel->addSelect('system.tbl_filters.*');
|
||||
|
||||
//
|
||||
$this->FiltersModel->addOrder('sort', 'ASC');
|
||||
|
||||
//
|
||||
$this->FiltersModel->addLimit(1);
|
||||
|
||||
$whereParameters = null;
|
||||
|
||||
if ($this->filterId == null)
|
||||
{
|
||||
$whereParameters = array(
|
||||
'app' => $this->app,
|
||||
'dataset_name' => $this->datasetName,
|
||||
'filter_kurzbz' => $this->filterKurzbz,
|
||||
'uid' => getAuthUID(),
|
||||
'default_filter' => true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$whereParameters = array(
|
||||
'filter_id' => $this->filter_id,
|
||||
'uid' => getAuthUID(),
|
||||
'default_filter' => true
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
$filter = $this->FiltersModel->loadWhere($whereParameters);
|
||||
|
||||
$jsonEncodedFilter = null;
|
||||
|
||||
if (hasData($filter))
|
||||
{
|
||||
if (isset($filter->retval[0]->filter) && trim($filter->retval[0]->filter) != '')
|
||||
{
|
||||
$jsonEncodedFilter = json_decode($filter->retval[0]->filter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($jsonEncodedFilter != null)
|
||||
{
|
||||
$selectedFields = array();
|
||||
$selectedFilters = array();
|
||||
$activeFilters = array();
|
||||
$activeFiltersOperation = array();
|
||||
|
||||
if (isset($jsonEncodedFilter->columns))
|
||||
{
|
||||
$columns = $jsonEncodedFilter->columns;
|
||||
|
||||
for($columnsCounter = 0; $columnsCounter < count($columns); $columnsCounter++)
|
||||
{
|
||||
if (isset($columns[$columnsCounter]->name))
|
||||
{
|
||||
$selectedFields[] = $columns[$columnsCounter]->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($jsonEncodedFilter->filters))
|
||||
{
|
||||
$filters = $jsonEncodedFilter->filters;
|
||||
|
||||
for($filtersCounter = 0; $filtersCounter < count($filters); $filtersCounter++)
|
||||
{
|
||||
if (isset($filters[$filtersCounter]->name))
|
||||
{
|
||||
$selectedFilters[] = $filters[$filtersCounter]->name;
|
||||
$activeFilters[$filters[$filtersCounter]->name] = $filters[$filtersCounter]->condition;
|
||||
$activeFiltersOperation[$filters[$filtersCounter]->name] = $filters[$filtersCounter]->operation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filterSessionArray = array(
|
||||
self::SELECTED_FIELDS => $selectedFields,
|
||||
self::SELECTED_FILTERS => $selectedFilters,
|
||||
self::ACTIVE_FILTERS => $activeFilters,
|
||||
self::ACTIVE_FILTERS_OPERATION => $activeFiltersOperation
|
||||
);
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _getSelectedFieldsFromPost()
|
||||
{
|
||||
// Selected fields
|
||||
$selectedFields = array();
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
if (isset($filterSessionArray[self::SELECTED_FIELDS]))
|
||||
{
|
||||
$selectedFields = $filterSessionArray[self::SELECTED_FIELDS];
|
||||
}
|
||||
|
||||
if (is_array($_POST))
|
||||
{
|
||||
if (array_key_exists(self::CMD_ADD_FIELD, $_POST) && trim($_POST[self::CMD_ADD_FIELD]) != '')
|
||||
{
|
||||
if (!in_array($_POST[self::CMD_ADD_FIELD], $selectedFields))
|
||||
{
|
||||
$selectedFields[] = $_POST[self::CMD_ADD_FIELD];
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists(self::CMD_REMOVE_FIELD, $_POST) && trim($_POST[self::CMD_REMOVE_FIELD]) != '')
|
||||
{
|
||||
$selectedFields = $this->_removeElementFromArray($selectedFields, $_POST[self::CMD_REMOVE_FIELD]);
|
||||
}
|
||||
}
|
||||
|
||||
return $selectedFields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _getSelectedFiltersFromPost()
|
||||
{
|
||||
// Selected filters
|
||||
$selectedFilters = array();
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
if (isset($filterSessionArray[self::SELECTED_FILTERS]))
|
||||
{
|
||||
$selectedFilters = $filterSessionArray[self::SELECTED_FILTERS];
|
||||
}
|
||||
|
||||
if (is_array($_POST))
|
||||
{
|
||||
if (array_key_exists(self::CMD_ADD_FILTER, $_POST) && trim($_POST[self::CMD_ADD_FILTER]) != '')
|
||||
{
|
||||
if (!in_array($_POST[self::CMD_ADD_FILTER], $selectedFilters))
|
||||
{
|
||||
$selectedFilters[] = $_POST[self::CMD_ADD_FILTER];
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists(self::CMD_REMOVE_FILTER, $_POST) && trim($_POST[self::CMD_REMOVE_FILTER]) != '')
|
||||
{
|
||||
$selectedFilters = $this->_removeElementFromArray($selectedFilters, $_POST[self::CMD_REMOVE_FILTER]);
|
||||
}
|
||||
}
|
||||
|
||||
return $selectedFilters;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _setActiveFiltersFromPost(&$activeFilters, &$activeFiltersOperation)
|
||||
{
|
||||
$selectedFilters = array();
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
|
||||
if (isset($filterSessionArray[self::ACTIVE_FILTERS]))
|
||||
{
|
||||
$activeFilters = $filterSessionArray[self::ACTIVE_FILTERS];
|
||||
}
|
||||
|
||||
if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPERATION]))
|
||||
{
|
||||
$activeFiltersOperation = $filterSessionArray[self::ACTIVE_FILTERS_OPERATION];
|
||||
}
|
||||
|
||||
if (isset($filterSessionArray[self::SELECTED_FILTERS]))
|
||||
{
|
||||
$selectedFilters = $filterSessionArray[self::SELECTED_FILTERS];
|
||||
}
|
||||
|
||||
if (is_array($_POST))
|
||||
{
|
||||
if (array_key_exists(self::CMD_REMOVE_FILTER, $_POST) && trim($_POST[self::CMD_REMOVE_FILTER]) != '')
|
||||
{
|
||||
if (isset($activeFilters[$_POST[self::CMD_REMOVE_FILTER]]))
|
||||
{
|
||||
unset($activeFilters[$_POST[self::CMD_REMOVE_FILTER]]);
|
||||
}
|
||||
|
||||
if (isset($activeFiltersOperation[$_POST[self::CMD_REMOVE_FILTER]]))
|
||||
{
|
||||
unset($activeFiltersOperation[$_POST[self::CMD_REMOVE_FILTER]]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ($selectedFiltersCounter = 0; $selectedFiltersCounter < count($selectedFilters); $selectedFiltersCounter++)
|
||||
{
|
||||
$selectedFilter = $selectedFilters[$selectedFiltersCounter];
|
||||
|
||||
if (isset($_POST[$selectedFilter]))
|
||||
{
|
||||
$activeFilters[$selectedFilter] = $_POST[$selectedFilter];
|
||||
}
|
||||
|
||||
if (isset($_POST[$selectedFilter.self::ACTIVE_FILTER_OPERATION_POSTFIX]))
|
||||
{
|
||||
$activeFiltersOperation[$selectedFilter] = $_POST[$selectedFilter.self::ACTIVE_FILTER_OPERATION_POSTFIX];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _setSessionFilterData()
|
||||
{
|
||||
$filterSessionArray = array(
|
||||
self::SELECTED_FIELDS => $this->_getSelectedFieldsFromPost(),
|
||||
self::SELECTED_FILTERS => $this->_getSelectedFiltersFromPost(),
|
||||
self::ADDITIONAL_COLUMNS => $this->additionalColumns
|
||||
);
|
||||
|
||||
$filterSessionArray[self::ACTIVE_FILTERS] = array();
|
||||
$filterSessionArray[self::ACTIVE_FILTERS_OPERATION] = array();
|
||||
|
||||
$this->_setActiveFiltersFromPost(
|
||||
$filterSessionArray[self::ACTIVE_FILTERS],
|
||||
$filterSessionArray[self::ACTIVE_FILTERS_OPERATION]
|
||||
);
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _generateQuery()
|
||||
{
|
||||
$query = $this->query;
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
|
||||
if (isset($filterSessionArray[self::ACTIVE_FILTERS]))
|
||||
{
|
||||
$activeFilters = $filterSessionArray[self::ACTIVE_FILTERS];
|
||||
}
|
||||
|
||||
if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPERATION]))
|
||||
{
|
||||
$activeFiltersOperation = $filterSessionArray[self::ACTIVE_FILTERS_OPERATION];
|
||||
}
|
||||
|
||||
//
|
||||
if (count($activeFilters) > 0)
|
||||
{
|
||||
$where = '';
|
||||
$first = true;
|
||||
|
||||
foreach ($activeFilters as $field => $activeFilterValue)
|
||||
{
|
||||
if (trim($activeFilterValue) != '')
|
||||
{
|
||||
if ($first)
|
||||
{
|
||||
$first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$where .= ' AND ';
|
||||
}
|
||||
|
||||
if (isset($activeFiltersOperation[$field]))
|
||||
{
|
||||
$where .= '"'.$field.'"';
|
||||
$condition = '';
|
||||
|
||||
switch ($activeFiltersOperation[$field])
|
||||
{
|
||||
case self::OP_EQUAL:
|
||||
$condition = ' = '.$activeFilterValue;
|
||||
break;
|
||||
case self::OP_NOT_EQUAL:
|
||||
$condition = ' != '.$activeFilterValue;
|
||||
break;
|
||||
case self::OP_GREATER_THAN:
|
||||
$condition = ' > '.$activeFilterValue;
|
||||
break;
|
||||
case self::OP_LESS_THAN:
|
||||
$condition = ' < '.$activeFilterValue;
|
||||
break;
|
||||
case self::OP_CONTAINS:
|
||||
$condition = ' ILIKE \'%'.$activeFilterValue.'%\'';
|
||||
break;
|
||||
case self::OP_NOT_CONTAINS:
|
||||
$condition = ' NOT ILIKE \'%'.$activeFilterValue.'%\'';
|
||||
break;
|
||||
case self::OP_IS_TRUE:
|
||||
$condition = ' IS TRUE';
|
||||
break;
|
||||
case self::OP_IS_FALSE:
|
||||
$condition = ' IS FALSE';
|
||||
break;
|
||||
}
|
||||
|
||||
$where .= $condition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($where != '')
|
||||
{
|
||||
$query = 'SELECT * FROM ('.$this->query.') tableFilters WHERE '.$where;
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _removeElementFromArray($array, $element)
|
||||
{
|
||||
$_removeElementFromArray = array();
|
||||
|
||||
for ($arrayCounter = 0; $arrayCounter < count($array); $arrayCounter++)
|
||||
{
|
||||
$arrayElement = $array[$arrayCounter];
|
||||
if ($arrayElement != $element)
|
||||
{
|
||||
$_removeElementFromArray[] = $arrayElement;
|
||||
}
|
||||
}
|
||||
|
||||
return $_removeElementFromArray;
|
||||
}
|
||||
}
|
||||
@@ -841,6 +841,225 @@ if (!$result = @$db->db_query("SELECT 1 FROM system.tbl_log LIMIT 1"))
|
||||
echo ' system.tbl_log hinzugefügt<br>';
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// Start filters
|
||||
|
||||
// SEQUENCE tbl_filters_id_seq
|
||||
if ($result = $db->db_query("SELECT 0 FROM pg_class WHERE relname = 'tbl_filters_id_seq'"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = '
|
||||
CREATE SEQUENCE system.tbl_filters_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
';
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_filters_id_seq '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Created sequence: system.tbl_filters_id_seq';
|
||||
|
||||
// GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO vilesci;
|
||||
$qry = 'GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO vilesci;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_filters_id_seq '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>vilesci</strong> on system.tbl_filters_id_seq';
|
||||
|
||||
// GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO fhcomplete;
|
||||
$qry = 'GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO fhcomplete;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_filters_id_seq '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>vilesci</strong> on system.tbl_filters_id_seq';
|
||||
}
|
||||
}
|
||||
|
||||
// TABLE system.tbl_filters
|
||||
if (!@$db->db_query("SELECT 0 FROM system.tbl_filters WHERE 0 = 1"))
|
||||
{
|
||||
$qry = '
|
||||
CREATE TABLE system.tbl_filters (
|
||||
filter_id integer NOT NULL DEFAULT nextval(\'system.tbl_filters_id_seq\'::regclass),
|
||||
app character varying(32) NOT NULL,
|
||||
dataset_name character varying(128) NOT NULL,
|
||||
filter_kurzbz character varying(64) NOT NULL,
|
||||
person_id integer,
|
||||
description character varying(128)[] NOT NULL,
|
||||
sort integer,
|
||||
default_filter boolean DEFAULT FALSE,
|
||||
filter jsonb NOT NULL,
|
||||
oe_kurzbz character varying(16)
|
||||
);';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_filters '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Created table system.tbl_filters';
|
||||
|
||||
// GRANT SELECT ON TABLE system.tbl_filters TO web;
|
||||
$qry = 'GRANT SELECT ON TABLE system.tbl_filters TO web;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_filters '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>web</strong> on system.tbl_filters';
|
||||
|
||||
// GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_filters TO vilesci;
|
||||
$qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_filters TO vilesci;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_filters '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Granted privileges to <strong>vilesci</strong> on system.tbl_filters';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters
|
||||
$qry = 'COMMENT ON TABLE system.tbl_filters IS \'Table to manage filters\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.app
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.app IS \'Application which this filter belongs to\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.app: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.app';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.dataset_name
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.dataset_name IS \'Name that identifies the data set to be filtered\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.dataset_name: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.dataset_name';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.filter_kurzbz
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.filter_kurzbz IS \'Short description of the filter, unique for this application and this data set\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.filter_kurzbz: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.filter_kurzbz';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.person_id
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.person_id IS \'Person identifier which this filter belongs to. If null it is global\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.person_id: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.person_id';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.description
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.description IS \'Long description for this filter\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.description: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.description';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.sort
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.sort IS \'Indicates the order in which the filters appear in a list\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.sort: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.sort';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.default_filter
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.default_filter IS \'If it is the default filter for that data set\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.default_filter: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.default_filter';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.filter
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.filter IS \'Cointains json that define the filter\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.filter: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.filter';
|
||||
|
||||
// COMMENT ON TABLE system.tbl_filters.oe_kurzbz
|
||||
$qry = 'COMMENT ON COLUMN system.tbl_filters.oe_kurzbz IS \'Organisation unit which this filter belongs to. If null it is for all the organisation units\';';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Adding comment to system.tbl_filters.oe_kurzbz: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Added comment to system.tbl_filters.oe_kurzbz';
|
||||
|
||||
// ALTER SEQUENCE system.tbl_filters_id_seq OWNED BY system.tbl_filters.filter_id;
|
||||
$qry = 'ALTER SEQUENCE system.tbl_filters_id_seq OWNED BY system.tbl_filters.filter_id;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_filters_id_seq '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Altered sequence system.tbl_filters_id_seq';
|
||||
}
|
||||
|
||||
// UNIQUE INDEX uidx_filters_app_dataset_name_filter_kurzbz
|
||||
if ($result = $db->db_query("SELECT 0 FROM pg_class WHERE relname = 'uidx_filters_app_dataset_name_filter_kurzbz'"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = 'CREATE UNIQUE INDEX uidx_filters_app_dataset_name_filter_kurzbz ON system.tbl_filters USING btree (app, dataset_name, filter_kurzbz);';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>uidx_filters_app_dataset_name_filter_kurzbz '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Created unique uidx_filters_app_dataset_name_filter_kurzbz';
|
||||
}
|
||||
}
|
||||
|
||||
// Add permission for filters
|
||||
if ($result = @$db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berechtigung_kurzbz = 'system/filters';"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "INSERT INTO system.tbl_berechtigung (berechtigung_kurzbz, beschreibung) VALUES('system/filters', 'To manage core filters');";
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_berechtigung '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo ' system.tbl_berechtigung: Added permission for filters<br>';
|
||||
}
|
||||
}
|
||||
|
||||
// FOREIGN KEY tbl_filters_app_fkey
|
||||
if ($result = $db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'tbl_filters_app_fkey'"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = 'ALTER TABLE system.tbl_filters ADD CONSTRAINT tbl_filters_app_fkey FOREIGN KEY (app) REFERENCES system.tbl_app(app) ON UPDATE CASCADE ON DELETE RESTRICT;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>tbl_filters_app_fkey '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Created foreign key tbl_filters_app_fkey';
|
||||
}
|
||||
}
|
||||
|
||||
// FOREIGN KEY tbl_filters_person_id_fkey
|
||||
if ($result = $db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'tbl_filters_person_id_fkey'"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = 'ALTER TABLE system.tbl_filters ADD CONSTRAINT tbl_filters_person_id_fkey FOREIGN KEY (person_id) REFERENCES public.tbl_person(person_id) ON UPDATE CASCADE ON DELETE RESTRICT;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>tbl_filters_person_id_fkey '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Created foreign key tbl_filters_person_id_fkey';
|
||||
}
|
||||
}
|
||||
|
||||
// FOREIGN KEY tbl_filters_oe_kurzbz_fkey
|
||||
if ($result = $db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'tbl_filters_oe_kurzbz_fkey'"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = 'ALTER TABLE system.tbl_filters ADD CONSTRAINT tbl_filters_oe_kurzbz_fkey FOREIGN KEY (oe_kurzbz) REFERENCES public.tbl_organisationseinheit(oe_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT;';
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>tbl_filters_oe_kurzbz_fkey '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Created foreign key tbl_filters_oe_kurzbz_fkey';
|
||||
}
|
||||
}
|
||||
|
||||
// End filters
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
|
||||
@@ -1092,6 +1311,7 @@ $tabellen=array(
|
||||
"system.tbl_extensions" => array("extension_id","name","version","description","license","url","core_version","dependencies","enabled"),
|
||||
"system.tbl_log" => array("log_id","person_id","zeitpunkt","app","oe_kurzbz","logtype_kurzbz","logdata","insertvon"),
|
||||
"system.tbl_logtype" => array("logtype_kurzbz", "data_schema"),
|
||||
"system.tbl_filters" => array("filter_id","app","dataset_name","filter_kurzbz","person_id","description","sort","default_filter","filter","oe_kurzbz"),
|
||||
"system.tbl_phrase" => array("phrase_id","app","phrase","insertamum","insertvon"),
|
||||
"system.tbl_phrasentext" => array("phrasentext_id","phrase_id","sprache","orgeinheit_kurzbz","orgform_kurzbz","text","description","insertamum","insertvon"),
|
||||
"system.tbl_rolle" => array("rolle_kurzbz","beschreibung"),
|
||||
|
||||
Reference in New Issue
Block a user