diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php index 6a6600d4d..a4776e14d 100644 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -2,25 +2,70 @@ $filterWidgetArray = array( 'query' => ' + SELECT * + FROM ( SELECT p.person_id AS "PersonId", p.vorname AS "Vorname", p.nachname AS "Nachname", p.gebdatum AS "Gebdatum", - l.zeitpunkt AS "LastAction", - l.insertvon AS "User/Operator" - FROM public.tbl_person p INNER JOIN system.tbl_log l USING(person_id) + (SELECT zeitpunkt + FROM system.tbl_log + WHERE app = \'aufnahme\' + AND person_id = p.person_id + ORDER BY zeitpunkt DESC + LIMIT 1) AS "LastAction", + (SELECT insertvon + FROM system.tbl_log + WHERE app = \'aufnahme\' + AND person_id = p.person_id + ORDER BY zeitpunkt DESC + LIMIT 1) AS "User/Operator", + (SELECT pss.studiensemester_kurzbz + FROM public.tbl_prestudentstatus pss + INNER JOIN public.tbl_prestudent ps USING(prestudent_id) + WHERE pss.status_kurzbz = \'Interessent\' + AND pss.bestaetigtam IS NULL + AND pss.bestaetigtvon IS NULL + AND ps.person_id = p.person_id + ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC + LIMIT 1) AS "Studiensemester", + (SELECT pss.bewerbung_abgeschicktamum + FROM public.tbl_prestudentstatus pss + INNER JOIN public.tbl_prestudent ps USING(prestudent_id) + WHERE pss.status_kurzbz = \'Interessent\' + AND pss.bestaetigtam IS NULL + AND pss.bestaetigtvon IS NULL + AND ps.person_id = p.person_id + ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC + LIMIT 1) AS "SendDate" + FROM public.tbl_person p WHERE p.aktiv = TRUE - AND l.app = \'aufnahme\' + AND p.person_id IN ( + SELECT person_id + FROM public.tbl_prestudent + INNER JOIN public.tbl_prestudentstatus USING(prestudent_id) + WHERE status_kurzbz = \'Interessent\' + AND bestaetigtam IS NULL + AND bestaetigtvon IS NULL) + GROUP BY 1, 2, 4, 5, 6, 7 + ORDER BY "LastAction" DESC + ) tbl_infocenter + WHERE "Studiensemester" IN ( + SELECT studiensemester_kurzbz + FROM public.tbl_studiensemester + WHERE (NOW() >= start AND NOW() <= ende) + OR start > NOW() + ) ', 'hideHeader' => false, 'hideSave' => false, 'additionalColumns' => array('Details'), 'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) { - $link = 'Details'; - if ($fieldName == 'Details') { + $link = 'Details'; + $datasetRaw->{$fieldName} = sprintf( $link, base_url('index.ci.php/system/infocenter/infocenterDetails/showDetails/'), @@ -28,6 +73,30 @@ ); } + if ($fieldName == 'SendDate') + { + if ($datasetRaw->{$fieldName} == '1970.01.01 01:00:00') + { + $datasetRaw->{$fieldName} = 'Not sent'; + } + } + + if ($fieldName == 'LastAction') + { + if ($datasetRaw->{$fieldName} == '1970.01.01 01:00:00') + { + $datasetRaw->{$fieldName} = 'Not logged'; + } + } + + if ($fieldName == 'User/Operator') + { + if ($datasetRaw->{$fieldName} == '') + { + $datasetRaw->{$fieldName} = 'NA'; + } + } + return $datasetRaw; } ); diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 59a4ae334..438862eb1 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -51,6 +51,8 @@ class FilterWidget extends Widget const OP_IS_FALSE = 'false'; const OP_CONTAINS = 'contains'; const OP_NOT_CONTAINS = 'ncontains'; + const OP_SET = 'set'; + const OP_NOT_SET = 'nset'; const OPT_DAYS = 'days'; const OPT_MONTHS = 'months'; @@ -95,9 +97,17 @@ class FilterWidget extends Widget */ public function display($widgetData) { + // $filterSessionArray = $this->session->userdata(self::SESSION_NAME); - if ((isset($filterSessionArray[self::SELECTED_FIELDS]) && count($filterSessionArray[self::SELECTED_FIELDS]) == 0) - && (isset($filterSessionArray[self::SELECTED_FILTERS]) && count($filterSessionArray[self::SELECTED_FILTERS]) == 0)) + + // + if ($this->filterId == null && isset($filterSessionArray[self::FILTER_ID])) + { + $this->filterId = $filterSessionArray[self::FILTER_ID]; + } + + // + if ($filterSessionArray[self::FILTER_ID] != $this->filterId) { // $this->_loadFilter(); @@ -281,6 +291,8 @@ class FilterWidget extends Widget @@ -492,6 +504,11 @@ class FilterWidget extends Widget $filterSessionArray[self::ADDITIONAL_COLUMNS] = array(); } + if (!isset($filterSessionArray[self::FILTER_ID])) + { + $filterSessionArray[self::FILTER_ID] = -1; + } + $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); } @@ -962,6 +979,8 @@ class FilterWidget extends Widget $filterSessionArray[self::ACTIVE_FILTERS_OPTION] ); + $filterSessionArray[self::FILTER_ID] = $this->filterId; + $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); } @@ -1001,61 +1020,68 @@ class FilterWidget extends Widget foreach ($activeFilters as $field => $activeFilterValue) { - if (trim($activeFilterValue) != '') + if ($first) { - if ($first) + $first = false; + } + else + { + $where .= ' AND '; + } + + if (isset($activeFiltersOperation[$field])) + { + $where .= '"'.$field.'"'; + $condition = ''; + + switch ($activeFiltersOperation[$field]) { - $first = false; - } - else - { - $where .= ' AND '; + case self::OP_EQUAL: + if (!is_numeric($activeFilterValue)) $activeFilterValue = 0; + $condition = ' = '.$activeFilterValue; + break; + case self::OP_NOT_EQUAL: + if (!is_numeric($activeFilterValue)) $activeFilterValue = 0; + $condition = ' != '.$activeFilterValue; + break; + case self::OP_GREATER_THAN: + if (!is_numeric($activeFilterValue)) $activeFilterValue = 0; + $condition = ' > '.$activeFilterValue; + break; + case self::OP_LESS_THAN: + if (!is_numeric($activeFilterValue)) $activeFilterValue = 0; + if (isset($activeFiltersOption[$field]) + && ($activeFiltersOption[$field] == self::OPT_DAYS + || $activeFiltersOption[$field] == self::OPT_MONTHS)) + { + $condition = ' < (NOW() - \''.$activeFilterValue.' '.$activeFiltersOption[$field].'\'::interval)'; + } + else + { + $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; + case self::OP_SET: + $condition = ' IS NOT NULL'; + break; + case self::OP_NOT_SET: + $condition = ' IS NULL'; + break; } - 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: - if (isset($activeFiltersOption[$field]) - && ($activeFiltersOption[$field] == self::OPT_DAYS - || $activeFiltersOption[$field] == self::OPT_MONTHS)) - { - $condition = ' < (NOW() - \''.$activeFilterValue.' '.$activeFiltersOption[$field].'\'::interval)'; - } - else - { - $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; - } + $where .= $condition; } }