From ee3998f62ed25ce07fe5cbc9bb98f69fbb025320 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 22 Nov 2017 12:08:54 +0100 Subject: [PATCH 01/45] - Changed system/dbupdate_3.3.php to create table system.tbl_filters and what its needed - Added model system/Filters_model to manage system.tbl_filters - Removed method execQuery from model system/UDF_model - Added property executedQueryMetaData to DB_Model - Added property executedQueryListFields to DB_Model - Added method getExecutedQueryListFields to DB_Model - Added method getExecutedQueryMetaData to DB_Model - Added method execReadOnlyQuery to DB_Model to execute read only queries from outside a model - Changed DB_Model method _toPhp to store infos about an executed query into properties executedQueryMetaData and executedQueryListFields - Updated library UDFLib to use execReadOnlyQuery - Added widget FilterWidget to render and manage a filter into VileSci - Added views widgets/filter/selectFields, widgets/filter/selectFilters and widgets/filter/tableDataset used by FilterWidget --- application/controllers/system/Test.php | 38 +++ application/core/DB_Model.php | 58 ++++- application/libraries/UDFLib.php | 2 +- application/models/system/Filters_model.php | 14 ++ application/models/system/UDF_model.php | 95 +++----- .../views/widgets/filter/selectFields.php | 20 ++ .../views/widgets/filter/selectFilters.php | 20 ++ .../views/widgets/filter/tableDataset.php | 9 + application/widgets/FilterWidget.php | 61 +++++ system/dbupdate_3.3.php | 220 ++++++++++++++++++ 10 files changed, 468 insertions(+), 69 deletions(-) create mode 100644 application/controllers/system/Test.php create mode 100644 application/models/system/Filters_model.php create mode 100644 application/views/widgets/filter/selectFields.php create mode 100644 application/views/widgets/filter/selectFilters.php create mode 100644 application/views/widgets/filter/tableDataset.php create mode 100644 application/widgets/FilterWidget.php diff --git a/application/controllers/system/Test.php b/application/controllers/system/Test.php new file mode 100644 index 000000000..f22898a34 --- /dev/null +++ b/application/controllers/system/Test.php @@ -0,0 +1,38 @@ +load->library('WidgetLib'); + } + + /** + * + */ + public function index() + { + echo $this->widgetlib->widget( + 'FilterWidget', + array( + 'app' => 'OpenProject', + 'datasetName' => 'Arbeitspakete', + 'query' => ' + SELECT p.person_id AS PersonId, + p.nachname AS Nachname, + p.vorname AS Vorname, + k.kontakt AS Email + 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 + ' + ) + ); + } +} diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index ab5ab2768..e6bd31114 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -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,44 @@ 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) + { + // + if (!stripos($query, 'INSERT') + && !stripos($query, 'UPDATE') + && !stripos($query, 'DELETE') + && !stripos($query, 'CREATE') + && !stripos($query, 'ALTER') + && !stripos($query, 'GRANT') + && !stripos($query, 'DROP')) + { + return $this->execQuery($query, $parametersArray); + } + else + { + return error('You are allowed to run only query for reading data'); + } + } + // ------------------------------------------------------------------------------------------ // Protected methods @@ -809,20 +850,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); } diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php index 1e16c11ac..2d453f068 100644 --- a/application/libraries/UDFLib.php +++ b/application/libraries/UDFLib.php @@ -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; diff --git a/application/models/system/Filters_model.php b/application/models/system/Filters_model.php new file mode 100644 index 000000000..546e2a5fd --- /dev/null +++ b/application/models/system/Filters_model.php @@ -0,0 +1,14 @@ +dbTable = 'system.tbl_filters'; + $this->pk = 'filter_id'; + } +} diff --git a/application/models/system/UDF_model.php b/application/models/system/UDF_model.php index e9bef54f6..ae9a91a69 100644 --- a/application/models/system/UDF_model.php +++ b/application/models/system/UDF_model.php @@ -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; } -} \ No newline at end of file +} diff --git a/application/views/widgets/filter/selectFields.php b/application/views/widgets/filter/selectFields.php new file mode 100644 index 000000000..a4f11dbfb --- /dev/null +++ b/application/views/widgets/filter/selectFields.php @@ -0,0 +1,20 @@ +
+ $value) + { + echo ''; + } + ?> +
+
+ Add: + +
diff --git a/application/views/widgets/filter/selectFilters.php b/application/views/widgets/filter/selectFilters.php new file mode 100644 index 000000000..72f963b57 --- /dev/null +++ b/application/views/widgets/filter/selectFilters.php @@ -0,0 +1,20 @@ +
+ $value) + { + echo $value->name.' - '.$value->type.'
'; + } + ?> +
+
+ Add filter: + +
diff --git a/application/views/widgets/filter/tableDataset.php b/application/views/widgets/filter/tableDataset.php new file mode 100644 index 000000000..6927a0923 --- /dev/null +++ b/application/views/widgets/filter/tableDataset.php @@ -0,0 +1,9 @@ +
+ retval; + foreach ($result as $key => $value) + { + var_dump($value); + } + ?> +
diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php new file mode 100644 index 000000000..721fd7c55 --- /dev/null +++ b/application/widgets/FilterWidget.php @@ -0,0 +1,61 @@ +load->model('system/Filters_model', 'FiltersModel'); + + $this->app = $widgetData['app']; + $this->datasetName = $widgetData['datasetName']; + + $dataset = $this->FiltersModel->execReadOnlyQuery($widgetData['query']); + + $this->loadViewSelectFields($this->FiltersModel->getExecutedQueryListFields()); + + $this->loadViewSelectFilters($this->FiltersModel->getExecutedQueryMetaData()); + + $this->loadViewTableDataset($dataset); + } + + /** + * + */ + private function loadViewSelectFields($listFields) + { + $this->view('widgets/filter/selectFields', array('listFields' => $listFields)); + } + + /** + * + */ + private function loadViewSelectFilters($metaData) + { + $this->view('widgets/filter/selectFilters', array('metaData' => $metaData)); + } + + /** + * + */ + private function loadViewTableDataset($result) + { + $this->view('widgets/filter/tableDataset', array('dataset' => $result)); + } +} diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 55b272bab..771a3f5e7 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -674,6 +674,225 @@ if ($result = @$db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berech //--------------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------------- +// 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 'system.tbl_filters_id_seq '.$db->db_last_error().'
'; + else + echo '
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 'system.tbl_filters_id_seq '.$db->db_last_error().'
'; + else + echo '
Granted privileges to vilesci 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 'system.tbl_filters_id_seq '.$db->db_last_error().'
'; + else + echo '
Granted privileges to vilesci 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 'system.tbl_filters '.$db->db_last_error().'
'; + else + echo '
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 'system.tbl_filters '.$db->db_last_error().'
'; + else + echo '
Granted privileges to web 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 'system.tbl_filters '.$db->db_last_error().'
'; + else + echo '
Granted privileges to vilesci 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 'Adding comment to system.tbl_filters: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.app: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.dataset_name: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.filter_kurzbz: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.person_id: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.description: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.sort: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.default_filter: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.filter: '.$db->db_last_error().'
'; + else + echo '
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 'Adding comment to system.tbl_filters.oe_kurzbz: '.$db->db_last_error().'
'; + else + echo '
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 'system.tbl_filters_id_seq '.$db->db_last_error().'
'; + else + echo '
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 'uidx_filters_app_dataset_name_filter_kurzbz '.$db->db_last_error().'
'; + else + echo '
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 'system.tbl_berechtigung '.$db->db_last_error().'
'; + else + echo ' system.tbl_berechtigung: Added permission for filters
'; + } +} + +// 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 'tbl_filters_app_fkey '.$db->db_last_error().'
'; + else + echo '
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 'tbl_filters_person_id_fkey '.$db->db_last_error().'
'; + else + echo '
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 'tbl_filters_oe_kurzbz_fkey '.$db->db_last_error().'
'; + else + echo '
Created foreign key tbl_filters_oe_kurzbz_fkey'; + } +} + +// End filters +//--------------------------------------------------------------------------------------------------------------------- + + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -923,6 +1142,7 @@ $tabellen=array( "system.tbl_benutzerrolle" => array("benutzerberechtigung_id","rolle_kurzbz","berechtigung_kurzbz","uid","funktion_kurzbz","oe_kurzbz","art","studiensemester_kurzbz","start","ende","negativ","updateamum", "updatevon","insertamum","insertvon","kostenstelle_id","anmerkung"), "system.tbl_berechtigung" => array("berechtigung_kurzbz","beschreibung"), "system.tbl_extensions" => array("extension_id","name","version","description","license","url","core_version","dependencies","enabled"), + "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"), From c105363fd034290c0502d3007d17e924f8f899d3 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 22 Nov 2017 15:33:44 +0100 Subject: [PATCH 02/45] First preview completed --- application/controllers/system/Test.php | 9 +-- application/views/widgets/filter/filter.php | 15 +++++ .../views/widgets/filter/selectFilters.php | 41 +++++++++++++- .../views/widgets/filter/tableDataset.php | 55 ++++++++++++++++--- application/widgets/FilterWidget.php | 21 +++++-- 5 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 application/views/widgets/filter/filter.php diff --git a/application/controllers/system/Test.php b/application/controllers/system/Test.php index f22898a34..67e82c7d3 100644 --- a/application/controllers/system/Test.php +++ b/application/controllers/system/Test.php @@ -22,10 +22,11 @@ class Test extends VileSci_Controller 'app' => 'OpenProject', 'datasetName' => 'Arbeitspakete', 'query' => ' - SELECT p.person_id AS PersonId, - p.nachname AS Nachname, - p.vorname AS Vorname, - k.kontakt AS Email + SELECT p.person_id AS "PersonId", + p.nachname AS "Nachname", + p.vorname AS "Vorname", + k.kontakt AS "Email", + p.aktiv AS "Aktiv" 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 diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php new file mode 100644 index 000000000..542708900 --- /dev/null +++ b/application/views/widgets/filter/filter.php @@ -0,0 +1,15 @@ +
+ view('widgets/filter/selectFields', array('listFields' => $listFields)); ?> +
+ +
+ +
+ view('widgets/filter/selectFilters', array('metaData' => $metaData)); ?> +
+ +
+ +
+ view('widgets/filter/tableDataset', array('dataset' => $dataset)); ?> +
diff --git a/application/views/widgets/filter/selectFilters.php b/application/views/widgets/filter/selectFilters.php index 72f963b57..ff3995727 100644 --- a/application/views/widgets/filter/selectFilters.php +++ b/application/views/widgets/filter/selectFilters.php @@ -2,7 +2,46 @@ $value) { - echo $value->name.' - '.$value->type.'
'; + echo '
'; + echo $value->name; + + if ($value->type == 'int4') + { + ?> + + + + + type == 'varchar') + { + ?> + + + + type == 'bool') + { + ?> + + + '; } ?>
diff --git a/application/views/widgets/filter/tableDataset.php b/application/views/widgets/filter/tableDataset.php index 6927a0923..83ca7b95f 100644 --- a/application/views/widgets/filter/tableDataset.php +++ b/application/views/widgets/filter/tableDataset.php @@ -1,9 +1,50 @@ + + + + + + + + + + + +
- retval; - foreach ($result as $key => $value) - { - var_dump($value); - } - ?> + + + + + + + + + + + + retval; + foreach ($result as $key => $value) + { + ?> + + + + + + + + + +
PersonIdNachnameVornameEmailAktiv
PersonId; ?>Nachname; ?>Vorname; ?>Email; ?>Aktiv === true ? 'True' : 'False'; ?>
diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 721fd7c55..a7715aa57 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -28,11 +28,22 @@ class FilterWidget extends Widget $dataset = $this->FiltersModel->execReadOnlyQuery($widgetData['query']); - $this->loadViewSelectFields($this->FiltersModel->getExecutedQueryListFields()); + $listFields = $this->FiltersModel->getExecutedQueryListFields(); - $this->loadViewSelectFilters($this->FiltersModel->getExecutedQueryMetaData()); + $metaData = $this->FiltersModel->getExecutedQueryMetaData(); - $this->loadViewTableDataset($dataset); + $this->loadViewFilters($listFields, $metaData, $dataset); + } + + /** + * + */ + private function loadViewFilters($listFields, $metaData, $dataset) + { + $this->view( + 'widgets/filter/filter', + array('listFields' => $listFields, 'metaData' => $metaData, 'dataset' => $dataset) + ); } /** @@ -54,8 +65,8 @@ class FilterWidget extends Widget /** * */ - private function loadViewTableDataset($result) + private function loadViewTableDataset($dataset) { - $this->view('widgets/filter/tableDataset', array('dataset' => $result)); + $this->view('widgets/filter/tableDataset', array('dataset' => $dataset)); } } From 1638bfdff2a1b51241c97fede33c4476c7d85a18 Mon Sep 17 00:00:00 2001 From: oesi Date: Fri, 24 Nov 2017 14:22:24 +0100 Subject: [PATCH 03/45] Mitarbeiter mit negativer Personalnummer werden nicht mehr im Verteiler tw_lkt aufgenommen --- system/mlists/mlists_generate.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/mlists/mlists_generate.php b/system/mlists/mlists_generate.php index b1e024ac9..55454c322 100644 --- a/system/mlists/mlists_generate.php +++ b/system/mlists/mlists_generate.php @@ -134,7 +134,8 @@ $error_msg=''; FROM public.tbl_mitarbeiter JOIN public.tbl_benutzer ON (mitarbeiter_uid=uid) WHERE lektor - AND aktiv"; + AND aktiv + AND personalnummer >=0"; //MitarbeiterInnen mit gueltiger Funktion "ass" (assistenz) $verteilerArray['tw_sek']['bezeichnung'] = 'Alle Sekretariate'; $verteilerArray['tw_sek']['beschreibung'] = 'Alle Sekretariate an der FH Technikum Wien'; From 73ae230cf03109fa3753975e8ff3bc455621c315 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 24 Nov 2017 14:31:43 +0100 Subject: [PATCH 04/45] =?UTF-8?q?Added=20"Notenspiegel=5Ferweitert"=20exce?= =?UTF-8?q?l=20export=20for=20color=20highlighting=20of=20negative=20marks?= =?UTF-8?q?=20and=20Nachpr=C3=BCfungen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/fas.xul.php | 7 + content/fasoverlay.js.php | 26 + content/statistik/notenspiegel_erweitert.php | 639 +++++++++++++++++++ include/note.class.php | 66 +- include/pruefungstermin.class.php | 21 +- locale/de-AT/fas.dtd | 4 + locale/de-SFU/fas.dtd | 4 + system/dbupdate_3.3.php | 69 +- 8 files changed, 803 insertions(+), 33 deletions(-) create mode 100644 content/statistik/notenspiegel_erweitert.php diff --git a/content/fas.xul.php b/content/fas.xul.php index 282a6580a..fd1eb09e9 100644 --- a/content/fas.xul.php +++ b/content/fas.xul.php @@ -109,6 +109,7 @@ foreach($addon_obj->result as $addon) + @@ -357,6 +358,12 @@ foreach($addon_obj->result as $addon) label = "&menu-statistic-notenspiegel-excel.label;" command = "menu-statistic-notenspiegel-excel:command" accesskey = "&menu-statistic-notenspiegel-excel.accesskey;"/> + content/statistik/notenspiegel.php?studiengang_kz='+studiengang_kz+'&semester='+semester+'&typ='+typ+'&orgform='+orgform,'Notenspiegel'); } +// **** +// * Liefert eine HTML Liste mit Uebersicht ueber die eingetragenen Noten +// * Studiengang und optional Semester muss gewaehlt sein. +// **** +function StatistikPrintNotenspiegelErweitert(typ) +{ + tree = document.getElementById('tree-verband'); + + if(tree.currentIndex==-1) + { + alert('Bitte zuerst einen Studiengang auswaehlen'); + return; + } + + //Studiengang und Semester holen + var col; + col = tree.columns ? tree.columns["stg_kz"] : "stg_kz"; + var studiengang_kz=tree.view.getCellText(tree.currentIndex,col); + col = tree.columns ? tree.columns["sem"] : "sem"; + var semester=tree.view.getCellText(tree.currentIndex,col); + col = tree.columns ? tree.columns["tree-verband-col-orgform"] : "tree-verband-col-orgform"; + var orgform=tree.view.getCellText(tree.currentIndex,col); + + window.open('content/statistik/notenspiegel_erweitert.php?studiengang_kz='+studiengang_kz+'&semester='+semester+'&typ='+typ+'&orgform='+orgform,'Notenspiegel'); +} + // **** // * Liefert eine statistik ueber die Anzahl der Interessenten/Bewerber Studenten // **** diff --git a/content/statistik/notenspiegel_erweitert.php b/content/statistik/notenspiegel_erweitert.php new file mode 100644 index 000000000..700148b74 --- /dev/null +++ b/content/statistik/notenspiegel_erweitert.php @@ -0,0 +1,639 @@ +, + * Andreas Oesterreicher , + * Rudolf Hangl and + * Alexei Karpenko + */ +/** + * Erstellt einen Notenspiegel + * + * Parameter: studiengang_kz ... Studiengang der angezeigt werden soll + * semester ... Semester das angezeigt werden soll + * orgform ... Filter für Organisationsform (VZ | BB | FST | etc) + * typ ... Output format (xls | html) + * + * Listet alle Noten der Studierenden des Studiengangs/Semester im eingestellten Studiensemester + * und berechnet den Notendurchschnitt und gewichteten Notendurchschnitt. + * + * Gewichteter Notendurchschnitt = (Note der LV) * (ECTS der LV) / (Summe aller ECTS) + */ +require_once('../../config/vilesci.config.inc.php'); +require_once('../../include/functions.inc.php'); +require_once('../../include/studiengang.class.php'); +require_once('../../include/person.class.php'); +require_once('../../include/benutzer.class.php'); +require_once('../../include/student.class.php'); +require_once('../../include/prestudent.class.php'); +require_once('../../include/note.class.php'); +require_once('../../include/lehrveranstaltung.class.php'); +require_once('../../include/pruefungstermin.class.php'); +require_once('../../include/benutzerberechtigung.class.php'); +require_once('../../include/Excel/excel.php'); + +$db = new basis_db(); +$user = get_uid(); +loadVariables($user); + +$rechte = new benutzerberechtigung(); +$rechte->getBerechtigungen($user); + +if (!isset($_GET['studiengang_kz'])) + die('Falsche Parameteruebergabe'); +else + $studiengang_kz = $_GET['studiengang_kz']; + +if (!$rechte->isBerechtigt('student/noten', $studiengang_kz, 's')) + die('Sie haben keine Berechtigung fuer diese Seite'); + +$semester = isset($_GET['semester']) ? $_GET['semester'] : ''; +$typ = isset($_GET['typ']) ? $_GET['typ'] : ''; + +if ($semester == '') + die('Bitte ein Semester auswaehlen'); + +$orgform = isset($_GET['orgform']) ? $_GET['orgform'] : ''; + +$stg = new studiengang(); +$stg_arr = array(); +$stg->getAll(false); +foreach ($stg->result as $studiengang) + $stg_arr[$studiengang->studiengang_kz] = $studiengang->kuerzel; + +$stg = new studiengang(); +$stg->load($studiengang_kz); + +$student = new student(); +$result_student = $student->getStudents($studiengang_kz, $semester, null, null, null, $semester_aktuell); +$uids = ''; +foreach ($result_student as $row) +{ + if ($uids != '') + $uids .= ','; + $uids .= $db->db_add_param($row->uid); +} +if ($uids == '') + die('Es befinden sich keine Studierende in diesem Semester'); + +$qry = "SELECT + lehrveranstaltung_id, bezeichnung, studiengang_kz, semester, ects + FROM + lehre.tbl_lehrveranstaltung + WHERE + lehrveranstaltung_id IN + ( + SELECT + distinct lehrveranstaltung_id + FROM + campus.vw_student_lehrveranstaltung, public.tbl_studentlehrverband + WHERE + tbl_studentlehrverband.studiengang_kz=".$db->db_add_param($studiengang_kz, FHC_INTEGER)." AND + tbl_studentlehrverband.semester=".$db->db_add_param($semester, FHC_INTEGER)." AND + vw_student_lehrveranstaltung.studiensemester_kurzbz=".$db->db_add_param($semester_aktuell)." AND + uid=student_uid AND + vw_student_lehrveranstaltung.studiensemester_kurzbz=tbl_studentlehrverband.studiensemester_kurzbz + ) + AND studiengang_kz<>0 + UNION + SELECT + lehrveranstaltung_id, bezeichnung, studiengang_kz, semester, ects + FROM + lehre.tbl_lehrveranstaltung JOIN lehre.tbl_zeugnisnote USING(lehrveranstaltung_id) + WHERE + tbl_lehrveranstaltung.studiengang_kz=".$db->db_add_param($studiengang_kz, FHC_INTEGER)." AND + tbl_zeugnisnote.student_uid in($uids) AND + tbl_zeugnisnote.studiensemester_kurzbz=".$db->db_add_param($semester_aktuell)." + ORDER BY bezeichnung"; + +if (!$result_lva = $db->db_query($qry)) + die('Fehler beim Ermitteln der Lehrveranstaltungen'); + +$noten = new note(); +$noten->getActive(); +$noten_arr = $noten_bezeichnungen = $noten_farben = $noten_positiv = array(); + +$pruefungstermin = new pruefungstermin(); + +$termine = $pruefungstermin->getAllPruefungstypen(false, true); + +$terminbez = 'Termin'; +$kommPruef = 'kommPruef'; +$zusKommPruef = 'zusKommPruef'; + +//null Werte und undefiniert rausfiltern +$termine = array_filter($termine, function ($termin) +{ + return !(is_null($termin->beschreibung) || $termin->pruefungstyp_kurzbz == 'undefiniert'); +}); + +$termineWithSort = array_filter($termine, function ($termin) +{ + return is_numeric($termin->sort); +}); + +$nulltermine = array_filter($termine, function ($termin) +{ + return is_null($termin->sort); +}); + +//keine Werte in sort Spalte - es wird versucht, Reihenfolge aufgrund Strings zu bestimmen +//zuerst Termine 1 - n, dann kommissionelle und zusätzliche kommissionelle +$max = 0; +foreach ($nulltermine as $termin) +{ + if (preg_match('/^'.$terminbez.'\d+$/', $termin->pruefungstyp_kurzbz)) + { + if (preg_match_all('/\d+/', $termin->pruefungstyp_kurzbz, $numbers)) + { + $number = intval(end($numbers[0])); + $termin->sort = $number; + if ($number > $max) + $max = $number; + } + } +} + +foreach ($nulltermine as $termin) +{ + if ($termin->pruefungstyp_kurzbz == $kommPruef || $termin->pruefungstyp_kurzbz == $zusKommPruef) + { + $termin->sort = ++$max; + } +} + +usort($nulltermine, function ($termina, $terminb) +{ + return is_null($termina->sort) ? 1 : (is_null($terminb->sort) ? -1 : $termina->sort - $terminb->sort); +}); + +$termine = array_merge($termineWithSort, $nulltermine); + +//Farben für Prüfungsantritte (1. Termin, 2., kommissionelle...) +$colors = array('ffff00', 'fa9200', 'ff1500', '800000', '9400D3', '1500ff', '305041', '00fff2', '00ff2b'); +$colorsForPositiv = array('ffffff', 'ffdfb3', 'ffb9b3', 'ff9494', 'ddb3ff', '7366ff', '80b39b', 'b3fffb', 'b3ffbf'); + +$counter = 0; +foreach ($termine as $termin) +{ + $terminkurzbz = $termin->pruefungstyp_kurzbz; + $pruefungsart_farben[$terminkurzbz] = $colors[$counter]; + $pruefungsart_farben[$terminkurzbz.'Pos'] = $colorsForPositiv[$counter]; + $counter++; +} + +foreach ($noten->result as $row) +{ + $noten_arr[$row->note] = $row->anmerkung; + $noten_wert[$row->note] = $row->notenwert; + $noten_bezeichnungen[$row->note] = $row->bezeichnung; + $noten_farben[$row->note] = $row->farbe; + $noten_positiv[$row->note] = $row->positiv; +} + +if ($typ == 'xls') +{ + // Creating a workbook + $workbook = new Spreadsheet_Excel_Writer(); + $workbook->setVersion(8); + // sending HTTP headers + $workbook->send("Notenliste_".$semester_aktuell."_".$stg->kuerzel.($semester != '' ? '_'.$semester : '').".xls"); + + // Creating a worksheet + $worksheet =& $workbook->addWorksheet("Notenliste"); + $worksheet->setInputEncoding('utf-8'); + + //Formate Definieren + $format_bold =& $workbook->addFormat(); + $format_bold->setBold(); + $format_bold->setBorder(1); + + $format_bold_wrap =& $workbook->addFormat(); + $format_bold_wrap->setBold(); + $format_bold_wrap->setBorder(1); + $format_bold_wrap->setTextWrap(); + + $format_rotate =& $workbook->addFormat(); + $format_rotate->setTextRotation(270); + $format_rotate->setAlign('center'); + + $format_bold_center =& $workbook->addFormat(); + $format_bold_center->setBold(); + $format_bold_center->setAlign('center'); + $format_bold_center->setBorder(1); + + $format_bold_noborder =& $workbook->addFormat(); + $format_bold_noborder->setBold(); + + $format_number =& $workbook->addFormat(); + $format_number->setNumFormat('0.00'); + $format_number->setBorder(1); + + //Farben ueberschreiben + foreach ($noten_farben as $note => $farbe) + { + if ($farbe != '') + { + $workbook->setCustomColor( + $note + 10, + hexdec(substr($farbe, 0, 2)), + hexdec(substr($farbe, 2, 2)), + hexdec(substr($farbe, 4, 2)) + ); + } + else + { + $workbook->setCustomColor($note + 10, 255, 255, 255); + } + + $format_colored[$note] =& $workbook->addFormat(); + $format_colored[$note]->setFgColor($note + 10); + $format_colored[$note]->setBorder(1); + $format_colored[$note]->setAlign('center'); + } + + $counter = 1; + + foreach ($pruefungsart_farben as $art => $farbe) + { + //eigene Farben für Indizes 40 + definieren + $colornumber = 40 + $counter; + $workbook->setCustomColor( + $colornumber, + hexdec(substr($farbe, 0, 2)), + hexdec(substr($farbe, 2, 2)), + hexdec(substr($farbe, 4, 2)) + ); + $format_colored[$art] =& $workbook->addFormat(); + $format_colored[$art]->setFgColor($colornumber); + $format_colored[$art]->setBorder(1); + $format_colored[$art]->setAlign('center'); + $counter++; + } + + //30 = Grau = Nicht teilgenommen + $workbook->setCustomColor(30, 90, 90, 90); + + $format_colored_nichtzugeteilt =& $workbook->addFormat(); + $format_colored_nichtzugeteilt->setFgColor(30); + $format_colored_nichtzugeteilt->setBorder(1); + $format_colored_nichtzugeteilt->setAlign('center'); + + $format_colored_nichteingetragen =& $workbook->addFormat(); + $format_colored_nichteingetragen->setFgColor(19); + $format_colored_nichteingetragen->setBorder(1); + $format_colored_nichteingetragen->setAlign('center'); + + $spalte = 0; + $zeile = 1; + + $worksheet->write($zeile, $spalte, 'Nachname', $format_bold); + $maxlength[$spalte] = 10; + $worksheet->write($zeile, ++$spalte, 'Vorname', $format_bold); + $maxlength[$spalte] = 10; + $worksheet->write($zeile, ++$spalte, 'Personenkennzeichen', $format_bold); + $maxlength[$spalte] = 30; + $maxheaderheight = 20; + + while ($row_lva = $db->db_fetch_object($result_lva)) + { + $value = $stg_arr[$row_lva->studiengang_kz].$row_lva->semester.' '.$row_lva->bezeichnung.' ('.$row_lva->ects.' ECTS)'; + $worksheet->write($zeile, ++$spalte, $value, $format_rotate); + $maxlength[$spalte] = 3; + + if (mb_strlen($value) > $maxheaderheight) + $maxheaderheight = mb_strlen($value); + } + $anzahl_lvspalten = $spalte - 2; + + $worksheet->write($zeile, ++$spalte, 'Notendurchschnitt', $format_bold); + $maxlength[$spalte] = 15; + $worksheet->write($zeile, ++$spalte, "Gewichteter\nNotendurchschnitt", $format_bold_wrap); + $maxlength[$spalte] = 15; + + $anzahl_lv = array(); + $summe_lv = array(); + $summegewichtet = 0; + $anzahlgewichtet = 0; + foreach ($result_student as $row_student) + { + if ($orgform != '') + { + //Wenn der Student nicht die passende orgform hat (VZ,BB,FST, etc) + //dann nicht anzeigen + $prestudent = new prestudent(); + $prestudent->getLastStatus($row_student->prestudent_id); + + if ($prestudent->orgform_kurzbz != $orgform) + continue; + } + $zeile++; + $spalte = 0; + + $worksheet->write($zeile, $spalte, $row_student->nachname, $format_bold); + if ($maxlength[$spalte] < strlen($row_student->nachname)) + $maxlength[$spalte] = strlen($row_student->nachname); + $worksheet->write($zeile, ++$spalte, $row_student->vorname, $format_bold); + if ($maxlength[$spalte] < strlen($row_student->vorname)) + $maxlength[$spalte] = strlen($row_student->vorname); + $worksheet->write($zeile, ++$spalte, $row_student->matrikelnr, $format_bold); + + //Alle Zeugnisnoten des Studierenden holen + $noten = array(); + $qry = "SELECT * FROM lehre.tbl_zeugnisnote WHERE student_uid=".$db->db_add_param($row_student->uid)." AND studiensemester_kurzbz=".$db->db_add_param($semester_aktuell); + if ($result = $db->db_query($qry)) + while ($row = $db->db_fetch_object($result)) + $noten[$row->lehrveranstaltung_id] = $row->note; + + //Zu jeder Lehrveranstaltungsnote Prüfungstyp (Anzahl der Antritte) holen + $pruefungstypen = array(); + $qry = "SELECT tbl_lehrveranstaltung.lehrveranstaltung_id, pruefungstyp_kurzbz, sort, datum + FROM + lehre.tbl_pruefung + JOIN + lehre.tbl_lehreinheit using(lehreinheit_id) + JOIN + lehre.tbl_lehrveranstaltung using(lehrveranstaltung_id) + WHERE + student_uid=".$db->db_add_param($row_student->uid)." AND studiensemester_kurzbz=".$db->db_add_param($semester_aktuell)." + ORDER BY lehrveranstaltung_id, sort, datum"; + if ($result = $db->db_query($qry)) + { + while ($row = $db->db_fetch_object($result)) + { + $pruefungstypen[$row->lehrveranstaltung_id] = $row->pruefungstyp_kurzbz; + } + } + + //Alle LVs holen zu denen der Studierende zugeteilt ist + $zugeteilte_lvs = array(); + $qry = "SELECT distinct lehrveranstaltung_id + FROM + campus.vw_student_lehrveranstaltung + WHERE + uid=".$db->db_add_param($row_student->uid)." AND + studiensemester_kurzbz=".$db->db_add_param($semester_aktuell); + + if ($result = $db->db_query($qry)) + while ($row = $db->db_fetch_object($result)) + $zugeteilte_lvs[] = $row->lehrveranstaltung_id; + + $anzahl = 0; + $summe = 0; + $rowcount = 0; + $summeects = 0; + $gewichtetenote = 0; + + while ($rowcount < $db->db_num_rows($result_lva)) + { + $row_lva = $db->db_fetch_object($result_lva, $rowcount); + $rowcount++; + //wenn es eine Note gibt + if (isset($noten[$row_lva->lehrveranstaltung_id])) + { + $note = $noten[$row_lva->lehrveranstaltung_id]; + $format = 0; + + //wenn für die LV der Studierende eine Nachprüfung hat (z.B. 2 Termin, kommissionelle...) + if (isset($pruefungstypen[$row_lva->lehrveranstaltung_id])) + { + $pruefungstyp = $pruefungstypen[$row_lva->lehrveranstaltung_id]; + if (isset($format_colored[$pruefungstyp])) + { + //wenn es eine Farbe für die Art der Nachprüfung gibt, diese verwenden (positiv oder negativ) + $format = ($noten_positiv[$note]) ? $format_colored[$pruefungstyp."Pos"] : $format_colored[$pruefungstyp]; + } + } + //keine Nachprüfung aber negativ - 1. Antritt Farbe wenn es eine Notenanmerkung gibt + else if (!$noten_positiv[$note] && $noten_arr[$note] != '' && isset($noten_arr[$note])) + { + reset($pruefungsart_farben); + $format = $format_colored[key($pruefungsart_farben)]; + } + else if (isset($format_colored[$note])) + $format = $format_colored[$note]; + + $worksheet->write($zeile, ++$spalte, $noten_arr[$note], $format); + + if ($noten_wert[$noten[$row_lva->lehrveranstaltung_id]] != '') + { + if (!isset($summe_lv[$row_lva->lehrveranstaltung_id])) + { + $summe_lv[$row_lva->lehrveranstaltung_id] = 0; + $anzahl_lv[$row_lva->lehrveranstaltung_id] = 0; + } + $summe_lv[$row_lva->lehrveranstaltung_id] += $noten_wert[$noten[$row_lva->lehrveranstaltung_id]]; + $anzahl_lv[$row_lva->lehrveranstaltung_id]++; + $summe += $noten_wert[$noten[$row_lva->lehrveranstaltung_id]]; + if (is_numeric($row_lva->ects)) + { + $gewichtetenote += $noten_wert[$noten[$row_lva->lehrveranstaltung_id]] * $row_lva->ects; + $summeects += $row_lva->ects; + } + $anzahl++; + } + } + else + { + //Keine Note fuer diese LV vorhanden + if (in_array($row_lva->lehrveranstaltung_id, $zugeteilte_lvs)) + { + $worksheet->write($zeile, ++$spalte, '', $format_colored_nichteingetragen); + } + else + { + $worksheet->write($zeile, ++$spalte, '', $format_colored_nichtzugeteilt); + } + } + } + + if ($anzahl != 0) + $schnitt = $summe / $anzahl; + else + $schnitt = 0; + + if ($summeects != 0) + $gewichtetenote /= $summeects; + + $worksheet->write($zeile, ++$spalte, sprintf("%.2f", $schnitt), $format_number); + $worksheet->write($zeile, ++$spalte, sprintf("%.2f", $gewichtetenote), $format_number); + if ($gewichtetenote != 0) + { + $summegewichtet += $gewichtetenote; + $anzahlgewichtet++; + } + } + $zeile++; + $spalte = 2; + $worksheet->write($zeile, $spalte, 'Notendurchschnitt', $format_bold); + + $summe_schnitt = 0; + $anzahl_schnitt = 0; + $rowcount = 0; + while ($rowcount < $db->db_num_rows($result_lva)) + { + $row_lva = $db->db_fetch_object($result_lva, $rowcount); + $rowcount++; + if (isset($summe_lv[$row_lva->lehrveranstaltung_id])) + { + if ($anzahl_lv[$row_lva->lehrveranstaltung_id] != 0) + $schnitt = $summe_lv[$row_lva->lehrveranstaltung_id] / $anzahl_lv[$row_lva->lehrveranstaltung_id]; + else + $schnitt = 0; + } + else + $schnitt = 0; + if ($schnitt != 0) + { + $summe_schnitt += $schnitt; + $anzahl_schnitt++; + } + $worksheet->write($zeile, ++$spalte, sprintf("%.2f", $schnitt), $format_number); + } + + if ($anzahl_schnitt != 0) + $schnitt = $summe_schnitt / $anzahl_schnitt; + else + $schnitt = 0; + $worksheet->write($zeile, ++$spalte, sprintf("%.2f", $schnitt), $format_number); + if ($anzahlgewichtet != 0) + $summegewichtet = $summegewichtet / $anzahlgewichtet; + $worksheet->write($zeile, ++$spalte, sprintf("%.2f", $summegewichtet), $format_number); + + $zeile += 5; + $legendzeile = $zeile; + $startcolumn = 2; + + //Farblegende + $bezeichnungen = array(); + foreach ($termine as $termin) + $bezeichnungen[$termin->pruefungstyp_kurzbz] = $termin->beschreibung; + + $worksheet->setMerge($legendzeile, $startcolumn, $legendzeile, $startcolumn + 4); + $worksheet->write($legendzeile, $startcolumn, "Farblegende Prüfungsantritte", $format_bold_center); + $worksheet->write($legendzeile, $startcolumn + 4, "", $format_bold_center); + $legendzeile++; + $worksheet->write($legendzeile, $startcolumn, "Termin", $format_bold_center); + $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 2); + $worksheet->write($legendzeile, $startcolumn + 1, "positiv", $format_bold_center); + $worksheet->setMerge($legendzeile, $startcolumn + 3, $legendzeile, $startcolumn + 4); + $worksheet->write($legendzeile, $startcolumn + 3, "negativ", $format_bold_center); + $worksheet->write($legendzeile, $startcolumn + 4, "", $format_bold_center); + $legendzeile++; + foreach ($bezeichnungen as $name => $bezeichnung) + { + if (strstr($bezeichnung, PHP_EOL)) + $worksheet->setRow($legendzeile, 25); + $worksheet->write($legendzeile, $startcolumn, $bezeichnung, $format_bold); + $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 2); + $worksheet->write($legendzeile, $startcolumn + 1, "", $format_colored[$name.'Pos']); + $worksheet->setMerge($legendzeile, $startcolumn + 3, $legendzeile, $startcolumn + 4); + $worksheet->write($legendzeile, $startcolumn + 3, "", $format_colored[$name]); + $worksheet->write($legendzeile, $startcolumn + 4, "", $format_colored[$name]); + $legendzeile++; + } + $worksheet->write($legendzeile, $startcolumn, "nicht eingetragen", $format_bold); + $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 4); + $worksheet->write($legendzeile, $startcolumn + 1, "", $format_colored_nichteingetragen); + $worksheet->write($legendzeile, $startcolumn + 4, "", $format_colored_nichteingetragen); + $legendzeile++; + $worksheet->write($legendzeile, $startcolumn, "nicht zugeteilt", $format_bold); + $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 4); + $worksheet->write($legendzeile, $startcolumn + 1, "", $format_colored_nichtzugeteilt); + $worksheet->write($legendzeile, $startcolumn + 4, "", $format_colored_nichtzugeteilt); + + $startcolumn = $currentcolumn = 9; + + //Notenlegende + //optimale Länge in kleinsten Einheiten - Notenspalten + $optimalLengthBeschr = 6; + $groesse = $toMerge = 0; + $beschrColumnMerges = array(0, 0); + $index = 0; + + foreach ($beschrColumnMerges as $toMerge) + { + $groesse = 0; + while ($groesse < $optimalLengthBeschr) + { + if ($currentcolumn < 3 + $anzahl_lvspalten) + { + $groesse++; + } + else if ($currentcolumn < 3 + $anzahl_lvspalten + 2) + { + $groesse += 4; + } + else + { + $groesse += 2; + } + $currentcolumn++; + $beschrColumnMerges[$index]++; + } + $currentcolumn++; + $index++; + } + + $allmerges = array($beschrColumnMerges[0], 1, $beschrColumnMerges[1], 1); + $headingmerge = array_sum($allmerges) - 1; + $positivmerge = $allmerges[0] + $allmerges[1] - 1; + $negativmerge = $allmerges[1] + $allmerges[2] - 1; + + $worksheet->setMerge($zeile, $startcolumn, $zeile, $startcolumn + $headingmerge); + $worksheet->write($zeile, $startcolumn, "Notenlegende", $format_bold_center); + $worksheet->write($zeile++, $startcolumn + $headingmerge, "", $format_bold_center); + $worksheet->setMerge($zeile, $startcolumn, $zeile, $startcolumn + $positivmerge); + $worksheet->write($zeile, $startcolumn, "positiv", $format_bold_center); + $worksheet->setMerge($zeile, $startcolumn + $positivmerge + 1, $zeile, $startcolumn + $headingmerge); + $worksheet->write($zeile, $startcolumn + $headingmerge, "", $format_bold_center); + $worksheet->write($zeile++, $startcolumn + $positivmerge + 1, "negativ", $format_bold_center); + $tempzeile = $zeile; + foreach ($noten_arr as $note => $anmerkung) + { + if (is_null($noten_bezeichnungen[$note]) || $noten_bezeichnungen[$note] == "" || is_null($anmerkung) || $anmerkung == "") + continue; + if ($noten_positiv[$note]) + { + $worksheet->setMerge($zeile, $startcolumn, $zeile, $startcolumn + $positivmerge - 1); + $worksheet->write($zeile, $startcolumn, $noten_bezeichnungen[$note], $format_bold); + $worksheet->write($zeile++, $startcolumn + $positivmerge, $anmerkung, $format_bold_center); + } + else + { + $worksheet->setMerge($tempzeile, $startcolumn + $positivmerge + 1, $tempzeile, $startcolumn + $headingmerge - 1); + $worksheet->write($tempzeile, $startcolumn + $positivmerge + 1, $noten_bezeichnungen[$note], $format_bold); + $worksheet->write($tempzeile++, $startcolumn + $headingmerge, $anmerkung, $format_bold_center); + } + } + + //Die Breite der Spalten setzen + foreach ($maxlength as $i => $breite) + $worksheet->setColumn($i, $i, $breite + 2); + + $worksheet->write(0, 0, $semester_aktuell." ".$stg->kuerzel.($semester != '' ? ' '.$semester.'. Semester' : '').' Stand: '.date('d.m.Y'), $format_bold_center); + //Zellen der 1. Zeile verbinden + $worksheet->setMerge(0, 0, 0, $spalte); + + //Hoehe der 2. Zeile anpassen damit die LVs alle sichtbar sind + $worksheet->setRow(1, $maxheaderheight * 5); + + //Ausdruck auf 1 Seite anpassen + $worksheet->fitToPages(1, 1); + $workbook->close(); +} + diff --git a/include/note.class.php b/include/note.class.php index 6c119cae9..9994c0b38 100644 --- a/include/note.class.php +++ b/include/note.class.php @@ -36,9 +36,9 @@ class note extends basis_db public $bezeichnung; // varchar(32) public $anmerkung; // varchar(256) public $farbe; // varchar(6) - public $positiv=true; // boolean - public $notenwert; // boolean - public $aktiv; // boolean + public $positiv=true; // boolean + public $notenwert; // boolean + public $aktiv; // boolean public $lehre; // boolean /** @@ -75,10 +75,10 @@ class note extends basis_db $this->note = $row->note; $this->bezeichnung = $row->bezeichnung; $this->anmerkung = $row->anmerkung; - $this->farbe = $row->farbe; + $this->farbe = $row->farbe; $this->notenwert = $row->notenwert; - $this->positiv = $this->db_parse_bool($row->positiv); - $this->lehre = $this->db_parse_bool($row->lehre); + $this->positiv = $this->db_parse_bool($row->positiv); + $this->lehre = $this->db_parse_bool($row->lehre); $this->aktiv = $this->db_parse_bool($row->aktiv); return true; } @@ -130,10 +130,10 @@ class note extends basis_db $this->db_add_param($this->note).', '. $this->db_add_param($this->bezeichnung).', '. $this->db_add_param($this->anmerkung).', '. - $this->db_add_param($this->positiv, FHC_BOOLEAN).','. - $this->db_add_param($this->notenwert).','. - $this->db_add_parma($this->aktiv, FHC_BOOLEAN).','. - $this->db_add_param($htis->lehre, FHC_BOOLEAN).');'; + $this->db_add_param($this->positiv, FHC_BOOLEAN).','. + $this->db_add_param($this->notenwert).','. + $this->db_add_parma($this->aktiv, FHC_BOOLEAN).','. + $this->db_add_param($this->lehre, FHC_BOOLEAN).');'; } else { @@ -141,9 +141,9 @@ class note extends basis_db 'note='.$this->db_add_param($this->note).', '. 'bezeichnung='.$this->db_add_param($this->bezeichnung).', '. 'anmerkung='.$this->db_add_param($this->anmerkung).', '. - 'positiv='.$this->db_add_param($this->positiv, FHC_BOOLEAN).', '. - 'notenwert='.$this->db_add_param($this->notenwert).', '. - 'aktiv='.$this->db_add_param($this->aktiv, FHC_BOOLEAN).', '. + 'positiv='.$this->db_add_param($this->positiv, FHC_BOOLEAN).', '. + 'notenwert='.$this->db_add_param($this->notenwert).', '. + 'aktiv='.$this->db_add_param($this->aktiv, FHC_BOOLEAN).', '. 'lehre='.$this->db_add_param($this->lehre, FHC_BOOLEAN).' '. 'WHERE note='.$this->db_add_param($this->note).';'; } @@ -177,9 +177,43 @@ class note extends basis_db $n->bezeichnung = $row->bezeichnung; $n->anmerkung = $row->anmerkung; $n->farbe = $row->farbe; - $n->positiv = $this->db_parse_bool($row->positiv); - $n->notenwert = $row->notenwert; - $n->aktiv = $this->db_parse_bool($row->aktiv); + $n->positiv = $this->db_parse_bool($row->positiv); + $n->notenwert = $row->notenwert; + $n->aktiv = $this->db_parse_bool($row->aktiv); + $n->lehre = $this->db_parse_bool($row->lehre); + + $this->result[] = $n; + } + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + + /** + * Laedt alle aktive Noten + * @return true wenn ok, false wenn Fehler + */ + public function getActive() + { + $qry = "SELECT * FROM lehre.tbl_note WHERE aktiv = TRUE ORDER BY note"; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $n = new note(); + + $n->note = $row->note; + $n->bezeichnung = $row->bezeichnung; + $n->anmerkung = $row->anmerkung; + $n->farbe = $row->farbe; + $n->positiv = $this->db_parse_bool($row->positiv); + $n->notenwert = $row->notenwert; + $n->aktiv = $this->db_parse_bool($row->aktiv); $n->lehre = $this->db_parse_bool($row->lehre); $this->result[] = $n; diff --git a/include/pruefungstermin.class.php b/include/pruefungstermin.class.php index c3ff1badb..74222cceb 100644 --- a/include/pruefungstermin.class.php +++ b/include/pruefungstermin.class.php @@ -104,19 +104,22 @@ class pruefungstermin extends basis_db{ } } - - /** - * Lädt alle Prüfungstypen aus der Datenbank - * @return Array/Boolean Ein Array mit den Daten, wenn ok; ansonsten false - */ - public function getAllPruefungstypen($abschluss = null) + + /** + * Lädt alle Prüfungstypen aus der Datenbank + * @param null $abschluss gibt an, ob Abschlussprüfungen ausgegeben werden sollen. default: Abschlussprüfungen und andere Prüfungen + * @return array /Boolean Ein Array mit den Daten, wenn ok; ansonsten false + */ + public function getAllPruefungstypen($abschluss = null, $sort = false) { $qry = 'SELECT * FROM lehre.tbl_pruefungstyp'; - if(!is_null($abschluss)) + if(is_bool($abschluss)) { - $qry .= ' WHERE abschluss='.$this->db_add_param($abschluss); + $qry .= ' WHERE abschluss='.$this->db_add_param($abschluss, FHC_BOOLEAN); } + if($sort) + $qry .= ' ORDER BY (sort IS NULL), sort, pruefungstyp_kurzbz'; $qry .=';'; if($this->db_query($qry)) @@ -128,6 +131,7 @@ class pruefungstermin extends basis_db{ $obj->pruefungstyp_kurzbz = $row->pruefungstyp_kurzbz; $obj->beschreibung = $row->beschreibung; $obj->abschluss = $row->abschluss; + $obj->sort = $row->sort; array_push($result, $obj); } } @@ -137,7 +141,6 @@ class pruefungstermin extends basis_db{ return false; } return $result; - } /** diff --git a/locale/de-AT/fas.dtd b/locale/de-AT/fas.dtd index 03b9966f4..11c8dd171 100644 --- a/locale/de-AT/fas.dtd +++ b/locale/de-AT/fas.dtd @@ -106,6 +106,10 @@ + + + + diff --git a/locale/de-SFU/fas.dtd b/locale/de-SFU/fas.dtd index df67cfe7f..3742f1a4b 100644 --- a/locale/de-SFU/fas.dtd +++ b/locale/de-SFU/fas.dtd @@ -102,6 +102,10 @@ + + + + diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index bea94d3e1..f905ab35e 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -358,8 +358,8 @@ if(!$result = @$db->db_query("SELECT mailversand FROM campus.tbl_coodle LIMIT 1; if(!$db->db_query($qry)) echo 'campus.tbl_coodle: '.$db->db_last_error().'
'; - else - echo '
campus.tbl_coodle: Spalten mailversand, teilnehmer_anonym und termine_anonym hinzugefuegt!
'; + else + echo '
campus.tbl_coodle: Spalten mailversand, teilnehmer_anonym und termine_anonym hinzugefuegt!
'; } // Spalte onlinebewerbung_studienplan in lehre.tbl_studienplan @@ -369,8 +369,61 @@ if(!$result = @$db->db_query("SELECT onlinebewerbung_studienplan FROM lehre.tbl_ if(!$db->db_query($qry)) echo 'lehre.tbl_studienplan: '.$db->db_last_error().'
'; + else + echo '
lehre.tbl_studienplan: Spalte onlinebewerbung_studienplan hinzugefuegt!
'; +} + +// Spalte sort in lehre.tbl_pruefungstyp (gibt Reihenfolge der Prüfungsantritte an) +if(!$result = @$db->db_query("SELECT sort FROM lehre.tbl_pruefungstyp LIMIT 1;")) +{ + $qry = "ALTER TABLE lehre.tbl_pruefungstyp ADD COLUMN sort smallint;"; + + if(!$db->db_query($qry)) + echo 'lehre.tbl_pruefungstyp: '.$db->db_last_error().'
'; + else + echo '
lehre.tbl_pruefungstyp: Spalte sort hinzugefuegt!
'; +} + +// zusätzliche kommissionelle Prüfung (4.Termin) als Zeile hinzufügen +if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_pruefungstyp WHERE pruefungstyp_kurzbz= 'zusKommPruef';")) +{ + if($db->db_num_rows($result) == 0) + { + $qry = "INSERT INTO lehre.tbl_pruefungstyp(pruefungstyp_kurzbz, beschreibung, abschluss) VALUES ('zusKommPruef', 'zusätzliche kommissionelle Prüfung', FALSE);"; + + if(!$db->db_query($qry)) + echo 'lehre.tbl_pruefungstyp: '.$db->db_last_error().'
'; else - echo '
lehre.tbl_studienplan: Spalte onlinebewerbung_studienplan hinzugefuegt!
'; + echo '
lehre.tbl_pruefungstyp: Zeile zusKommPruef hinzugefuegt!
'; + } +} + +// Note "entschuldigt" hinzufügen +if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'en' AND bezeichnung = 'entschuldigt' OR bezeichnung = 'Entschuldigt';")) +{ + if($db->db_num_rows($result) == 0) + { + $qry = "INSERT INTO lehre.tbl_note(note, bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES(17, 'entschuldigt', 'en', NULL, TRUE, NULL, TRUE, TRUE);"; + + if(!$db->db_query($qry)) + echo 'lehre.tbl_note: '.$db->db_last_error().'
'; + else + echo '
lehre.tbl_note: Zeile entschuldigt hinzugefuegt!
'; + } +} + +// Note "unentschuldigt" hinzufügen +if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'ue' AND bezeichnung = 'unentschuldigt' OR bezeichnung = 'Unentschuldigt';")) +{ + if($db->db_num_rows($result) == 0) + { + $qry = "INSERT INTO lehre.tbl_note(note, bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES(18, 'unentschuldigt', 'ue', NULL, FALSE, NULL, TRUE, TRUE);"; + + if(!$db->db_query($qry)) + echo 'lehre.tbl_note: '.$db->db_last_error().'
'; + else + echo '
lehre.tbl_note: Zeile unentschuldigt hinzugefuegt!
'; + } } // Column design_uid, betrieb_uid and operativ_uid to tbl_service @@ -385,8 +438,8 @@ if(!$result = @$db->db_query("SELECT design_uid FROM public.tbl_service LIMIT 1; if(!$db->db_query($qry)) echo 'public.tbl_service: '.$db->db_last_error().'
'; - else - echo '
public.tbl_service: Spalten design_uid,betrieb_uid,operativ_uid hinzugefuegt!
'; + else + echo '
public.tbl_service: Spalten design_uid,betrieb_uid,operativ_uid hinzugefuegt!
'; } // FOREIGN KEY tbl_phrasentext_sprache_fkey: system.tbl_phrasentext.sprache references public.tbl_sprache.sprache @@ -527,7 +580,7 @@ if(!@$db->db_query("SELECT campus.get_highest_content_version(0)")) $_$; ALTER FUNCTION campus.get_highest_content_version(bigint) OWNER TO fhcomplete;'; - + if(!$db->db_query($qry)) echo 'campus.get_highest_content_version(content_id): '.$db->db_last_error().'
'; else @@ -543,7 +596,7 @@ if(!@$db->db_query("SELECT ausstellungsnation FROM public.tbl_akte LIMIT 1")) COMMENT ON COLUMN public.tbl_akte.ausstellungsnation IS 'Nation-Code des Landes, in dem das Dokument ausgestellt wurde'; COMMENT ON COLUMN public.tbl_akte.formal_geprueft_amum IS 'Bestaetigungsdatum, an dem das Dokument inhaltlich auf Formalkriterien (Leserlichkeit, Vollständigkeit, etc) geprueft wurde'; "; - + if(!$db->db_query($qry)) echo 'public.tbl_rt_person '.$db->db_last_error().'
'; else @@ -556,7 +609,7 @@ if(!@$db->db_query("SELECT ausstellungsdetails FROM public.tbl_dokument LIMIT 1" $qry = "ALTER TABLE public.tbl_dokument ADD COLUMN ausstellungsdetails boolean NOT NULL DEFAULT false; COMMENT ON COLUMN public.tbl_dokument.ausstellungsdetails IS 'Sollen beim Dokument weitere Felder (zB Ausstellungsnation) angezeigt werden?'; "; - + if(!$db->db_query($qry)) echo 'public.tbl_dokument '.$db->db_last_error().'
'; else From ef418e70f844796118ebc886d313f3eda1873173 Mon Sep 17 00:00:00 2001 From: oesi Date: Fri, 24 Nov 2017 14:59:22 +0100 Subject: [PATCH 05/45] =?UTF-8?q?Filterfunktion=20f=C3=BCr=20Vilesci=20Sta?= =?UTF-8?q?tistiken=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vilesci/statistik/statistik_sql.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/vilesci/statistik/statistik_sql.php b/vilesci/statistik/statistik_sql.php index 99883bfb9..3f148d638 100644 --- a/vilesci/statistik/statistik_sql.php +++ b/vilesci/statistik/statistik_sql.php @@ -37,7 +37,7 @@ if (!isset($outputformat)) { $outputformat='html'; } - + if($statistik->berechtigung_kurzbz != '') { $uid = get_uid(); @@ -102,15 +102,14 @@ foreach($_REQUEST as $name=>$value) - - - - - - From 1b2cc47efd6b9decbb2ecd0a04ae022907b621eb Mon Sep 17 00:00:00 2001 From: oesi Date: Fri, 24 Nov 2017 16:04:51 +0100 Subject: [PATCH 06/45] =?UTF-8?q?Inkonsistenz=20beim=20Trennzeichen=20f?= =?UTF-8?q?=C3=BCr=20EMailversand=20behoben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/functions.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/functions.inc.php b/include/functions.inc.php index d63aa8f5f..cf6e2bad3 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -320,7 +320,10 @@ function loadVariables($user) if (!isset($emailadressentrennzeichen)) { global $emailadressentrennzeichen; - $emailadressentrennzeichen=','; + if(defined('DEFAULT_EMAILADRESSENTRENNZEICHEN')) + $emailadressentrennzeichen = DEFAULT_EMAILADRESSENTRENNZEICHEN; + else + $emailadressentrennzeichen=','; } if(!isset($alle_unr_mitladen)) @@ -1066,7 +1069,7 @@ function cutString($string, $limit, $placeholderSign = '', $keepFilextension = f { return '$placeholderSign must not be shorter than $limit'; } - + if(strlen($string) > ($limit - $offset)) { return substr($string, 0, ($limit - $offset)).$placeholderSign.$extension; From d3d4e01afc7c90654c2d8a27610f0602a370a9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 24 Nov 2017 17:11:18 +0100 Subject: [PATCH 07/45] isBerechtigt is now a Public Method of PermissionLib --- application/libraries/PermissionLib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index 075203c96..3000aceea 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -75,7 +75,7 @@ class PermissionLib if (isset($this->acl[$sourceName])) { // Checks permission - $isEntitled = $this->_isBerechtigt($this->acl[$sourceName], $permissionType); + $isEntitled = $this->isBerechtigt($this->acl[$sourceName], $permissionType); } } else @@ -104,7 +104,7 @@ class PermissionLib /** * Checks user's (API caller) rights */ - private function _isBerechtigt($berechtigung_kurzbz, $art = null, $oe_kurzbz = null, $kostenstelle_id = null) + public function isBerechtigt($berechtigung_kurzbz, $art = null, $oe_kurzbz = null, $kostenstelle_id = null) { $isBerechtigt = false; From 5b54217733cc4cb18ce82aa496979af8d94c7bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 24 Nov 2017 18:45:51 +0100 Subject: [PATCH 08/45] Added new Logging System for Persons Added a Wrapper to call CI functions from outside Codeigniter --- application/config/fhcomplete.php | 1 + application/libraries/CallerLib.php | 57 ++++++++--------- application/libraries/PersonLogLib.php | 47 ++++++++++++++ application/models/system/PersonLog_model.php | 61 +++++++++++++++++++ ci_loader.php | 11 ++++ include/functions.inc.php | 6 ++ index.ci.php | 7 +-- system/dbupdate_3.3.php | 59 ++++++++++++++++-- 8 files changed, 213 insertions(+), 36 deletions(-) create mode 100644 application/libraries/PersonLogLib.php create mode 100644 application/models/system/PersonLog_model.php create mode 100644 ci_loader.php diff --git a/application/config/fhcomplete.php b/application/config/fhcomplete.php index b1fd96f0f..0802ed411 100644 --- a/application/config/fhcomplete.php +++ b/application/config/fhcomplete.php @@ -209,6 +209,7 @@ $config['fhc_acl'] = array 'system.tbl_webservicetyp' => 'basis/webservicetyp', 'system.tbl_udf' => 'system/udf', 'system.tbl_extensions' => 'system/extensions', + 'system.tbl_log' => 'basis/log', 'testtool.tbl_ablauf' => 'basis/ablauf', 'testtool.tbl_antwort' => 'basis/antwort', 'testtool.tbl_frage' => 'basis/frage', diff --git a/application/libraries/CallerLib.php b/application/libraries/CallerLib.php index 856f0855a..d2387a723 100644 --- a/application/libraries/CallerLib.php +++ b/application/libraries/CallerLib.php @@ -14,16 +14,17 @@ class CallerLib const LIB_FILE_EXTENSION = '.php'; const LIBS_PATH = 'libraries'; const MODEL_PREFIX = '_model'; - + // Black list of resources that are no allowed to be used private static $RESOURCES_BLACK_LIST = array( 'CallerLib', // disabled self loading 'LogLib', // hardly usefull and virtually dangerous 'MigrationLib', // virtually dangerous, DB manipulation 'FilesystemLib', // virtually dangerous, direct access to file system - 'PermissionLib' // usefull? + 'PermissionLib', // usefull? + 'PersonLogLib' ); - + /** * Object initialization */ @@ -31,14 +32,14 @@ class CallerLib { // Gets CI instance $this->ci =& get_instance(); - + // Loads helper message to manage returning messages $this->ci->load->helper('Message'); - + // Loads permission library $this->ci->load->library('PermissionLib'); } - + /** * Wrapper method for _call */ @@ -46,7 +47,7 @@ class CallerLib { return $this->_call($callParameters, $permissionType); } - + /** * Wrapper method for _call */ @@ -54,7 +55,7 @@ class CallerLib { return $this->_call($callParameters, $permissionType); } - + /** * Everything starts here... */ @@ -63,7 +64,7 @@ class CallerLib $result = null; $parameters = $this->_getParameters($callParameters); $validation = $this->_validateCall($parameters); - + // If the validation was passed if (isSuccess($validation)) { @@ -119,7 +120,7 @@ class CallerLib { $result = error('Neither a lib nor model: '.$parameters->resourcePath.$parameters->resourceName); } - + // If the resource was found and loaded if (!is_null($loaded)) { @@ -134,10 +135,10 @@ class CallerLib { $result = $validation; } - + return $result; } - + /** * Gets the parameters from the http call * Search for parameters and @@ -181,7 +182,7 @@ class CallerLib return $parameters; } - + /** * Validate the given parameters */ @@ -224,7 +225,7 @@ class CallerLib { $loaded = null; $result = null; - + try { $loaded = $this->ci->load->model($resourcePath.$resourceName); @@ -234,15 +235,15 @@ class CallerLib // Errors while loading the model $result = error('Errors while loading the model: '.$e->getMessage()); } - + if (!is_null($loaded)) { $result = success($loaded); } - + return $result; } - + /** * Search for a valid permission for this library that should be present with this format: * '..' => '' @@ -251,14 +252,14 @@ class CallerLib { $result = null; $permissionPath = ''; - + if ($resourcePath != '') { $permissionPath = $resourcePath; } - + $permissionPath .= $resourceName.'.'.$function; - + if ($this->ci->permissionlib->isEntitled($permissionPath, $permissionType) === false) { $result = error(FHC_NORIGHT, FHC_NORIGHT); @@ -267,10 +268,10 @@ class CallerLib { $result = success('Has permission'); } - + return $result; } - + /** * Loads a library using the given path and name * @@ -286,7 +287,7 @@ class CallerLib private function _loadLibrary($resourcePath, $resourceName) { $loaded = null; - + try { // Gets all the configured resources paths @@ -328,15 +329,15 @@ class CallerLib // Errors while loading the library $result = error('Errors while loading the library: '.$e->getMessage()); } - + if (!is_null($loaded)) { $result = success($loaded); } - + return $result; } - + /** * Calls a method of a class with the given parameters and returns its result * @@ -347,7 +348,7 @@ class CallerLib private function _callThis($resourceName, $function, $parameters) { $result = null; - + try { // Get informations about the function @@ -402,7 +403,7 @@ class CallerLib { $result = error($e->getMessage()); } - + return $result; } } diff --git a/application/libraries/PersonLogLib.php b/application/libraries/PersonLogLib.php new file mode 100644 index 000000000..5eb8013f2 --- /dev/null +++ b/application/libraries/PersonLogLib.php @@ -0,0 +1,47 @@ +ci =& get_instance(); + $this->ci->load->model('system/PersonLog_model', 'PersonLogModel'); + } + + /** + * Writes a Log for a Person + * @param int $person_id ID of the Person. + * @param string $logtype_kurzbz Type of Log. + * @param array $logdata Array of the JSON Data to save. + * @param string $app Application that log belongs to. + * @param string $oe_kurzbz Organisation Unit the Log belongs to. + * @param string $user User who created the log. + * @return boolean true if success + */ + public function log($person_id, $logtype_kurzbz, $logdata, $app = 'core', $oe_kurzbz = null, $user = null) + { + $data = array( + 'person_id' => $person_id, + 'zeitpunkt' => date('Y-m-d H:i:s'), + 'app' => $app, + 'oe_kurzbz' => $oe_kurzbz, + 'logtype_kurzbz' => $logtype_kurzbz, + 'logdata' => json_encode($logdata), + 'insertvon' => $user + ); + + $result = $this->ci->PersonLogModel->insert($data); + if (isSuccess($result)) + return true; + else + show_error($result->retval); + } +} diff --git a/application/models/system/PersonLog_model.php b/application/models/system/PersonLog_model.php new file mode 100644 index 000000000..2d7ff15cc --- /dev/null +++ b/application/models/system/PersonLog_model.php @@ -0,0 +1,61 @@ +load->database(); + + $this->dbTable = 'system.tbl_log'; + } + + /** + * Inserts a Log for a Person + * @param array $data Data of Log Entry to save. + * @return success object if true + */ + public function insert($data) + { + $result = $this->db->insert($this->dbTable, $data); + if ($result) + return success($this->db->insert_id()); + else + return error(); + } + + /** + * Loads the last Log Entry of a Person + * @param int $person_id ID of the Person. + * @param string $app Name of the App. + * @param string $oe_kurzbz Organisations Unit. + * @return object $result + */ + public function getLastLog($person_id, $app = null, $oe_kurzbz = null) + { + // Check Permissions + $this->load->library('PermissionLib'); + if(!$this->permissionlib->isEntitled('system.tbl_log',PermissionLib::SELECT_RIGHT)) + show_error('Permission denied - You need Access to system.tbl_log'); + + $this->db->order_by('zeitpunkt', 'DESC'); + $this->db->order_by('log_id', 'DESC'); + $this->db->limit(1); + if (!is_null($app)) + $this->db->where('app='.$this->db->escape($app)); + if (!is_null($oe_kurzbz)) + $this->db->where('oe_kurzbz='.$this->db->escape($oe_kurzbz)); + + $result = $this->db->get_where($this->dbTable, "person_id=".$this->db->escape($person_id)); + + return success($result->result()); + } +} diff --git a/ci_loader.php b/ci_loader.php new file mode 100644 index 000000000..7466739a9 --- /dev/null +++ b/ci_loader.php @@ -0,0 +1,11 @@ +load->library('xxx'); + */ +ob_start(); +require_once('index.ci.php'); +ob_get_clean(); +return $CI; diff --git a/include/functions.inc.php b/include/functions.inc.php index cf6e2bad3..ed3175b5a 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1079,4 +1079,10 @@ function cutString($string, $limit, $placeholderSign = '', $keepFilextension = f return $string; } } + +function PersonLog($ci, $person_id, $logtype_kurzbz, $logdata, $app, $oe_kurzbz = null, $user=null) +{ + $ci->load->library('PersonLogLib'); + $ci->personloglib->log($person_id, $logtype_kurzbz, $logdata, $app, $oe_kurzbz, $user); +} ?> diff --git a/index.ci.php b/index.ci.php index f6905f940..043acb111 100644 --- a/index.ci.php +++ b/index.ci.php @@ -54,7 +54,7 @@ * NOTE: If you change these, also change the error_reporting() code below * */ - + define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); /* @@ -102,7 +102,7 @@ switch (ENVIRONMENT) * as this file. * */ - $system_path = 'vendor/codeigniter/framework/system'; + $system_path = dirname(__FILE__).'/vendor/codeigniter/framework/system'; /* *--------------------------------------------------------------- @@ -118,7 +118,7 @@ switch (ENVIRONMENT) * NO TRAILING SLASH! * */ - $application_folder = 'application'; + $application_folder = dirname(__FILE__).'/application'; /* *--------------------------------------------------------------- @@ -308,4 +308,3 @@ include_once 'vendor/autoload.php'; // Now the bootstrap file require_once BASEPATH.'core/CodeIgniter.php'; - diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index f905ab35e..9a2fc7744 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -578,7 +578,7 @@ if(!@$db->db_query("SELECT campus.get_highest_content_version(0)")) RETURN rec.version; END; $_$; - + ALTER FUNCTION campus.get_highest_content_version(bigint) OWNER TO fhcomplete;'; if(!$db->db_query($qry)) @@ -753,6 +753,55 @@ if ($result = @$db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berech // End extensions //--------------------------------------------------------------------------------------------------------------------- +if (!$result = @$db->db_query("SELECT 1 FROM system.tbl_log LIMIT 1")) +{ + $qry = "CREATE TABLE system.tbl_log + ( + log_id bigint NOT NULL, + person_id integer, + zeitpunkt timestamp NOT NULL DEFAULT now(), + app varchar(32) NOT NULL, + oe_kurzbz varchar(32), + logtype_kurzbz varchar(32) NOT NULL, + logdata jsonb NOT NULL, + insertvon varchar(32) + ); + ALTER TABLE system.tbl_log ADD CONSTRAINT pk_log PRIMARY KEY (log_id); + + CREATE SEQUENCE system.tbl_log_log_id_seq + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; + ALTER TABLE system.tbl_log ALTER COLUMN log_id SET DEFAULT nextval('system.tbl_log_log_id_seq'); + + GRANT SELECT, INSERT ON system.tbl_log TO vilesci; + GRANT SELECT, INSERT ON system.tbl_log TO web; + GRANT SELECT, UPDATE ON system.tbl_log_log_id_seq TO vilesci; + GRANT SELECT, UPDATE ON system.tbl_log_log_id_seq TO web; + + CREATE TABLE system.tbl_logtype + ( + logtype_kurzbz varchar(32), + data_schema jsonb NOT NULL + ); + ALTER TABLE system.tbl_logtype ADD CONSTRAINT pk_logtype PRIMARY KEY (logtype_kurzbz); + GRANT SELECT ON system.tbl_logtype TO vilesci; + GRANT SELECT ON system.tbl_logtype TO web; + + ALTER TABLE system.tbl_log ADD CONSTRAINT fk_log_person_id FOREIGN KEY (person_id) REFERENCES public.tbl_person(person_id) ON UPDATE CASCADE ON DELETE RESTRICT; + ALTER TABLE system.tbl_log ADD CONSTRAINT fk_log_app FOREIGN KEY (app) REFERENCES system.tbl_app(app) ON UPDATE CASCADE ON DELETE RESTRICT; + ALTER TABLE system.tbl_log ADD CONSTRAINT fk_log_oe_kurzbz FOREIGN KEY (oe_kurzbz) REFERENCES public.tbl_organisationseinheit(oe_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT; + ALTER TABLE system.tbl_log ADD CONSTRAINT fk_log_logtype_kurzbz FOREIGN KEY (logtype_kurzbz) REFERENCES system.tbl_logtype(logtype_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT; + + INSERT INTO system.tbl_logtype VALUES ('Action', '{\"type\": \"object\", \"title\": \"Action\", \"required\": [\"name\", \"success\", \"message\"], \"properties\": {\"name\": {\"type\": \"string\"}, \"message\": {\"type\": \"string\"}, \"success\": {\"type\": \"string\"}}}'); + INSERT INTO system.tbl_logtype VALUES ('Processstate', '{\"type\": \"object\", \"title\": \"Processstate\", \"required\": [\"name\"], \"properties\": {\"name\": {\"type\": \"string\"}}}'); + "; + if (!$db->db_query($qry)) + echo 'system.tbl_log '.$db->db_last_error().'
'; + else + echo ' system.tbl_log hinzugefügt
'; +} // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -881,7 +930,7 @@ $tabellen=array( "lehre.tbl_projektbetreuer" => array("person_id","projektarbeit_id","betreuerart_kurzbz","note","faktor","name","punkte","stunden","stundensatz","updateamum","updatevon","insertamum","insertvon","ext_id","vertrag_id"), "lehre.tbl_projekttyp" => array("projekttyp_kurzbz","bezeichnung"), "lehre.tbl_pruefung" => array("pruefung_id","lehreinheit_id","student_uid","mitarbeiter_uid","note","pruefungstyp_kurzbz","datum","anmerkung","insertamum","insertvon","updateamum","updatevon","ext_id","pruefungsanmeldung_id","vertrag_id", "punkte"), - "lehre.tbl_pruefungstyp" => array("pruefungstyp_kurzbz","beschreibung","abschluss"), + "lehre.tbl_pruefungstyp" => array("pruefungstyp_kurzbz","beschreibung","abschluss","sort"), "lehre.tbl_studienordnung" => array("studienordnung_id","studiengang_kz","version","gueltigvon","gueltigbis","bezeichnung","ects","studiengangbezeichnung","studiengangbezeichnung_englisch","studiengangkurzbzlang","akadgrad_id","insertamum","insertvon","updateamum","updatevon","ext_id", "status_kurzbz", "standort_id"), "lehre.tbl_studienordnungstatus" => array("status_kurzbz","bezeichnung","reihenfolge"), "lehre.tbl_studienordnung_semester" => array("studienordnung_semester_id","studienordnung_id","studiensemester_kurzbz","semester"), @@ -902,7 +951,7 @@ $tabellen=array( "lehre.tbl_zeugnisnote" => array("lehrveranstaltung_id","student_uid","studiensemester_kurzbz","note","uebernahmedatum","benotungsdatum","bemerkung","updateamum","updatevon","insertamum","insertvon","ext_id","punkte"), "public.ci_apikey" => array("apikey_id","key","level","ignore_limits","date_created"), "public.tbl_adresse" => array("adresse_id","person_id","name","strasse","plz","ort","gemeinde","nation","typ","heimatadresse","zustelladresse","firma_id","updateamum","updatevon","insertamum","insertvon","ext_id","rechnungsadresse","anmerkung"), - "public.tbl_akte" => array("akte_id","person_id","dokument_kurzbz","uid","inhalt","mimetype","erstelltam","gedruckt","titel","bezeichnung","updateamum","updatevon","insertamum","insertvon","ext_id","dms_id","nachgereicht","anmerkung","titel_intern","anmerkung_intern","nachgereicht_am"), + "public.tbl_akte" => array("akte_id","person_id","dokument_kurzbz","uid","inhalt","mimetype","erstelltam","gedruckt","titel","bezeichnung","updateamum","updatevon","insertamum","insertvon","ext_id","dms_id","nachgereicht","anmerkung","titel_intern","anmerkung_intern","nachgereicht_am","ausstellungsnation","formal_geprueft_amum"), "public.tbl_ampel" => array("ampel_id","kurzbz","beschreibung","benutzer_select","deadline","vorlaufzeit","verfallszeit","insertamum","insertvon","updateamum","updatevon","email","verpflichtend","buttontext"), "public.tbl_ampel_benutzer_bestaetigt" => array("ampel_benutzer_bestaetigt_id","ampel_id","uid","insertamum","insertvon"), "public.tbl_aufmerksamdurch" => array("aufmerksamdurch_kurzbz","beschreibung","ext_id","bezeichnung", "aktiv"), @@ -915,7 +964,7 @@ $tabellen=array( "public.tbl_benutzergruppe" => array("uid","gruppe_kurzbz","studiensemester_kurzbz","updateamum","updatevon","insertamum","insertvon","ext_id"), "public.tbl_bewerbungstermine" => array("bewerbungstermin_id","studiengang_kz","studiensemester_kurzbz","beginn","ende","nachfrist","nachfrist_ende","anmerkung", "insertamum", "insertvon", "updateamum", "updatevon","studienplan_id"), "public.tbl_buchungstyp" => array("buchungstyp_kurzbz","beschreibung","standardbetrag","standardtext","aktiv","credit_points"), - "public.tbl_dokument" => array("dokument_kurzbz","bezeichnung","ext_id","bezeichnung_mehrsprachig","dokumentbeschreibung_mehrsprachig"), + "public.tbl_dokument" => array("dokument_kurzbz","bezeichnung","ext_id","bezeichnung_mehrsprachig","dokumentbeschreibung_mehrsprachig","ausstellungsdetails"), "public.tbl_dokumentprestudent" => array("dokument_kurzbz","prestudent_id","mitarbeiter_uid","datum","updateamum","updatevon","insertamum","insertvon","ext_id"), "public.tbl_dokumentstudiengang" => array("dokument_kurzbz","studiengang_kz","ext_id", "onlinebewerbung", "pflicht","beschreibung_mehrsprachig","nachreichbar"), "public.tbl_erhalter" => array("erhalter_kz","kurzbz","bezeichnung","dvr","logo","zvr"), @@ -1003,6 +1052,8 @@ $tabellen=array( "system.tbl_benutzerrolle" => array("benutzerberechtigung_id","rolle_kurzbz","berechtigung_kurzbz","uid","funktion_kurzbz","oe_kurzbz","art","studiensemester_kurzbz","start","ende","negativ","updateamum", "updatevon","insertamum","insertvon","kostenstelle_id","anmerkung"), "system.tbl_berechtigung" => array("berechtigung_kurzbz","beschreibung"), "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_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"), From a4a9bcda4685e32ad4667322cd2c39cb6107bedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 24 Nov 2017 18:56:41 +0100 Subject: [PATCH 09/45] Added errormessage when extension permission is missing on installation --- application/libraries/ExtensionsLib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/libraries/ExtensionsLib.php b/application/libraries/ExtensionsLib.php index 4fa0778e9..0008ba087 100644 --- a/application/libraries/ExtensionsLib.php +++ b/application/libraries/ExtensionsLib.php @@ -313,7 +313,7 @@ class ExtensionsLib if (isError($result)) { $this->_errorOccurred = true; - $this->_printFailure('data base error'); + $this->_printFailure('data base error: '.$result->retval); } else { From 6c62196acb8ac846d39a900662f6542d68dc98f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 28 Nov 2017 14:08:29 +0100 Subject: [PATCH 10/45] Added Library for document conversion and merging Added function for loading documents of Akte --- application/libraries/DmsLib.php | 105 +++++++++++---- application/libraries/DocumentLib.php | 182 ++++++++++++++++++++++++++ 2 files changed, 261 insertions(+), 26 deletions(-) create mode 100644 application/libraries/DocumentLib.php diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php index 7ee160f85..f592eaa0e 100644 --- a/application/libraries/DmsLib.php +++ b/application/libraries/DmsLib.php @@ -12,18 +12,21 @@ class DmsLib public function __construct() { $this->ci =& get_instance(); - + $this->ci->load->model('crm/Akte_model', 'AkteModel'); $this->ci->load->model('content/Dms_model', 'DmsModel'); $this->ci->load->model('content/DmsVersion_model', 'DmsVersionModel'); $this->ci->load->model('content/DmsFS_model', 'DmsFSModel'); - + // Loads helper message to manage returning messages $this->ci->load->helper('message'); } /** - * read + * Read a DMS Document from the Filesystem + * @param int $dms_id ID of the Document. + * @param int $version The version of the Document (latest if null). + * @return object success or error */ public function read($dms_id, $version = null) { @@ -44,7 +47,7 @@ class DmsLib $result = $this->ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version)); } } - + if (hasData($result)) { $resultFS = $this->ci->DmsFSModel->read($result->retval[0]->filename); @@ -57,20 +60,26 @@ class DmsLib $result = $resultFS; } } - + return $result; } - + /** - * getAktenAcceptedDms + * Get all accepted Documents of a Person + * + * @param int $person_id ID of the person. + * @param string $dokument_kurzbz Type of document. + * @param bool $no_file If null then loads also the content. + * @return object success or error */ public function getAktenAcceptedDms($person_id, $dokument_kurzbz = null, $no_file = null) { $result = $this->ci->AkteModel->getAktenAcceptedDms($person_id, $dokument_kurzbz); - + if (hasData($result) && $no_file == null) { - for ($i = 0; $i < count($result->retval); $i++) + $cnt = count($result->retval); + for ($i = 0; $i < $cnt; $i++) { $resultFS = $this->ci->DmsFSModel->read($result->retval[$i]->filename); if (isSuccess($resultFS)) @@ -83,12 +92,14 @@ class DmsLib } } } - + return $result; } /** - * save + * Saves a Document + * @param object $dms DMS Object ot be saved. + * @return object */ public function save($dms) { @@ -142,30 +153,34 @@ class DmsLib return $result; } - + /** - * delete + * Deletes a Akte of a Person + * @param int $person_id ID of the person. + * @param int $dms_id Id of the Document. + * @return object */ public function delete($person_id, $dms_id) { $result = null; - + // If the parameters are valid if (is_numeric($person_id) && is_numeric($dms_id)) { // Start DB transaction $this->ci->db->trans_start(false); - + // Get akte_id from table tbl_akte $result = $this->ci->AkteModel->loadWhere(array('person_id' => $person_id, 'dms_id' => $dms_id)); if (isSuccess($result)) { // Delete all entries in tbl_akte - for ($i = 0; $i < count($result->retval); $i++) + $cnt = count($result->retval); + for ($i = 0; $i < $cnt; $i++) { $this->ci->AkteModel->delete($result->retval[$i]->akte_id); } - + // Get all filenames related to this dms $resultFileNames = $this->ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id)); if (isSuccess($resultFileNames)) @@ -179,10 +194,10 @@ class DmsLib } } } - + // Transaction complete! $this->ci->db->trans_complete(); - + // Check if everything went ok during the transaction if ($this->ci->db->trans_status() === false || isError($result)) { @@ -194,12 +209,13 @@ class DmsLib $this->ci->db->trans_commit(); $result = success('Dms successfully removed from DB'); } - + // If everything is ok if (isSuccess($result)) { + $cnt = count($resultFileNames->retval); // Remove all files related to this person and dms - for ($i = 0; $i < count($resultFileNames->retval); $i++) + for ($i = 0; $i < $cnt; $i++) { $this->ci->DmsFSModel->remove($resultFileNames->retval[$i]->filename); } @@ -209,17 +225,52 @@ class DmsLib { $result = error('Invalid parameters'); } - + return $result; } - + /** - * _saveFileOnInsert + * Loads the Content of an akte + * @param int $akte_id Id of the akte. + * @return object with document content or error + */ + public function getAkteContent($akte_id) + { + $akte = $this->ci->AkteModel->load($akte_id); + if (hasData($akte)) + { + if ($akte->retval[0]->inhalt != '') + { + return success(base64_decode($akte->retval[0]->inhalt)); + } + elseif ($akte->retval[0]->dms_id != '') + { + $dmscontent = $this->read($akte->retval[0]->dms_id); + if (isSuccess($dmscontent)) + { + return success(base64_decode($dmscontent->retval[0]->file_content)); + } + } + else + { + return error('No Content available'); + } + } + else + { + return error($akte->retval); + } + } + + /** + * Saves the Content of a DMS in the Filesystem + * @param object $dms DMS object to be saved. + * @return object */ private function _saveFileOnInsert($dms) { $filename = uniqid().'.'.pathinfo($dms['name'], PATHINFO_EXTENSION); - + $result = $this->ci->DmsFSModel->write($filename, $dms['file_content']); if (isSuccess($result)) { @@ -230,7 +281,9 @@ class DmsLib } /** - * _saveFileOnUpdate + * Updates the File in the Filesystem + * @param object $dms DMS object to update. + * @return object */ private function _saveFileOnUpdate($dms) { diff --git a/application/libraries/DocumentLib.php b/application/libraries/DocumentLib.php new file mode 100644 index 000000000..ba76eca6c --- /dev/null +++ b/application/libraries/DocumentLib.php @@ -0,0 +1,182 @@ +ci =& get_instance(); + + exec('unoconv --version', $ret_arr); + if(isset($ret_arr[0])) + $this->unoconv_version = explode(' ', $ret_arr[0])[1]; + else + show_error('Unoconv not found - Please install Unoconv'); + } + + /** + * Converts a File to PDF + * @param string $filename Full path to the file. + * @return success or error object + */ + public function convertToPDF($filename) + { + if (!file_exists($filename)) + return error('Unable to Convert to PDF. File not found:'.$filename); + + $mimetype = mime_content_type($filename); + $outFile = sys_get_temp_dir().'/FHC_'.uniqid().'.pdf'; + + switch ($mimetype) + { + case 'image/jpeg': + case 'image/jpg': + case 'image/pjpeg': + $this->_jpegtopdf($filename, $outFile); + return success($outFile); + case 'application/vnd.oasis.opendocument.spreadsheet': + case 'application/msword': + case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': + case 'application/haansoftdocx': + case 'application/vnd.ms-word': + case 'application/vnd.oasis.opendocument.text': + case 'text/plain': + $this->convert($filename, $outFile, 'pdf'); + return success($outFile); + case 'application/pdf': + return success($filename); + default: + return error('Unknown Mimetype:'.$mimetype); + } + } + + /** + * Combines multiple single PDFs to one PDF + * + * @param array $files Array of Files to merge (full path to file). + * @param string $outFile Path to the Output File. + * @return success or error object + */ + public function mergePDF($files, $outFile) + { + $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outFile "; + $finfo = finfo_open(FILEINFO_MIME_TYPE); + + // add all pdf files to the command + foreach ($files as $f) + { + $cmd .= $f." "; + if (!file_exists($f)) + { + return error("File not found: '$f'"); + } + if (finfo_file($finfo, $f) != "application/pdf") + { + return error("Wrong format(".finfo_file($finfo, $f)."): '$f'"); + } + } + + finfo_close($finfo); + + exec($cmd, $out, $ret); + if ($ret != 0) + { + return error('PDF-zusammenfuegung ist derzeit nicht möglich. Bitte informieren Sie den Administrator'); + } + return success(true); + } + + /** + * Converts a Document to another format with unoconv + * + * @param string $inFile File that should be convertet. + * @param string $outFile Name of the Output File. + * @param string $format Outputformat (PDF, DOC, ...). + * @return success or error Object + */ + public function convert($inFile, $outFile, $format) + { + if ($this->unoconv_version == '0.6') + $command = 'unoconv -f %1$s %3$s > %2$s'; + else + $command = 'unoconv -f %s --output %s %s 2>&1'; + $command = sprintf($command, $format, $outFile, $inFile); + + exec($command, $out, $ret); + + if ($ret != 0) + { + return error('Dokumentenkonvertierung ist derzeit nicht möglich. Bitte informieren Sie den Administrator'); + } + + return success(true); + } + + /** + * Converts a JPG to PDF + * + * @param string $filename Path to JPG. + * @param string $outfile Path to Output (pdf) File. + * @return success or error object + */ + private function _jpegtopdf($filename, $outfile) + { + if (!file_exists($filename)) + return error('File does not exists'); + + $size = getimagesize($filename); + + $margin_left_right = 18; + $margin_bottom = 18; + + /* + * längere Seite ermitteln + * Hochformat wenn die Seiten gleich lang sind oder das Bild schmäler ist als die Seitenbreite + */ + if ($size[0] > $size[1] && $size[0] > 595) + { + $page_height = 595; + $page_width = 842; + //Wenn Bild kleiner oder gleich Seitenbreite, dann margin erhoehen + if ($size[0] <= $page_width) + { + $margin_left_right = ($page_width - $size[0]) / 2; + $margin_bottom = ($page_height - $size[1]); + } + } + else + { + $page_height = 842; + $page_width = 595; + //Wenn Bild kleiner oder gleich Seitenbreite, dann margin erhoehen + if ($size[0] <= $page_width) + { + $margin_left_right = ($page_width - $size[0]) / 2; + $margin_bottom = ($page_height - $size[1]); + } + } + + // -r300 = 300 ppi + $cmd = 'gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -r100 '; + $cmd .= '-o '.$outfile.' viewjpeg.ps -c "('.$filename.') '; + $cmd .= '<< /PageSize ['.$page_width.' '.$page_height.'] '; + $cmd .= '/.HWMargins ['.$margin_left_right.' '.$margin_bottom.' '.$margin_left_right.' 18] '; + $cmd .= '/countspaces { [ exch { dup 32 ne { pop } if } forall ] length } bind def >> '; + $cmd .= 'setpagedevice viewJPEG"'; + + exec($cmd, $out, $ret); + if ($ret != 0) + { + $this->errormsg = 'jpegToPdf ist derzeit nicht möglich. Bitte informieren Sie den Administrator'; + return false; + } + return true; + } +} From 3f3479abaabe59d55a9834477c7e927529304436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 28 Nov 2017 16:43:51 +0100 Subject: [PATCH 11/45] Fixed Problem when adding Grades --- system/dbupdate_3.3.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 9a2fc7744..c1b448219 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -403,7 +403,7 @@ if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'en' { if($db->db_num_rows($result) == 0) { - $qry = "INSERT INTO lehre.tbl_note(note, bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES(17, 'entschuldigt', 'en', NULL, TRUE, NULL, TRUE, TRUE);"; + $qry = "INSERT INTO lehre.tbl_note(bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES('entschuldigt', 'en', NULL, TRUE, NULL, TRUE, TRUE);"; if(!$db->db_query($qry)) echo 'lehre.tbl_note: '.$db->db_last_error().'
'; @@ -417,7 +417,7 @@ if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'ue' { if($db->db_num_rows($result) == 0) { - $qry = "INSERT INTO lehre.tbl_note(note, bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES(18, 'unentschuldigt', 'ue', NULL, FALSE, NULL, TRUE, TRUE);"; + $qry = "INSERT INTO lehre.tbl_note(bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES('unentschuldigt', 'ue', NULL, FALSE, NULL, TRUE, TRUE);"; if(!$db->db_query($qry)) echo 'lehre.tbl_note: '.$db->db_last_error().'
'; @@ -1069,15 +1069,14 @@ $tabellen=array( "wawi.tbl_betriebsmittelstatus" => array("betriebsmittelstatus_kurzbz","beschreibung"), "wawi.tbl_betriebsmitteltyp" => array("betriebsmitteltyp","beschreibung","anzahl","kaution","typ_code","mastershapename"), "wawi.tbl_budget" => array("geschaeftsjahr_kurzbz","kostenstelle_id","budget"), - "wawi.tbl_zahlungstyp" => array("zahlungstyp_kurzbz","bezeichnung","reihenfolge"), - "wawi.tbl_konto" => array("konto_id","kontonr","beschreibung","kurzbz","aktiv","person_id","insertamum","insertvon","updateamum","updatevon","ext_id","person_id","hilfe"), + "wawi.tbl_zahlungstyp" => array("zahlungstyp_kurzbz","bezeichnung"), + "wawi.tbl_konto" => array("konto_id","kontonr","beschreibung","kurzbz","aktiv","person_id","insertamum","insertvon","updateamum","updatevon","ext_id","person_id"), "wawi.tbl_konto_kostenstelle" => array("konto_id","kostenstelle_id","insertamum","insertvon"), "wawi.tbl_kostenstelle" => array("kostenstelle_id","oe_kurzbz","bezeichnung","kurzbz","aktiv","insertamum","insertvon","updateamum","updatevon","ext_id","kostenstelle_nr","deaktiviertvon","deaktiviertamum"), "wawi.tbl_bestellungtag" => array("tag","bestellung_id","insertamum","insertvon"), "wawi.tbl_bestelldetailtag" => array("tag","bestelldetail_id","insertamum","insertvon"), "wawi.tbl_projekt_bestellung" => array("projekt_kurzbz","bestellung_id","anteil"), "wawi.tbl_bestellung" => array("bestellung_id","besteller_uid","kostenstelle_id","konto_id","firma_id","lieferadresse","rechnungsadresse","freigegeben","bestell_nr","titel","bemerkung","liefertermin","updateamum","updatevon","insertamum","insertvon","ext_id","zahlungstyp_kurzbz","zuordnung_uid","zuordnung_raum","zuordnung","auftragsbestaetigung","auslagenersatz","iban","wird_geleast","nicht_bestellen","empfehlung_leasing"), - "wawi.tbl_bestellung_angebot" => array("angebot_id","bestellung_id","dms_id"), "wawi.tbl_bestelldetail" => array("bestelldetail_id","bestellung_id","position","menge","verpackungseinheit","beschreibung","artikelnummer","preisprove","mwst","erhalten","sort","text","updateamum","updatevon","insertamum","insertvon"), "wawi.tbl_bestellung_bestellstatus" => array("bestellung_bestellstatus_id","bestellung_id","bestellstatus_kurzbz","uid","oe_kurzbz","datum","insertamum","insertvon","updateamum","updatevon"), "wawi.tbl_bestellstatus" => array("bestellstatus_kurzbz","beschreibung"), From 13ddee4748f7cc5efffabd033b14d93204c6a951 Mon Sep 17 00:00:00 2001 From: Gerald Raab Date: Wed, 29 Nov 2017 16:10:52 +0100 Subject: [PATCH 12/45] Darstellung Services optimiert, wenn ext_id vorhanden wird ein link zum Moodle-Kurs dargestellt --- cis/private/info/service_uebersicht.php | 74 ++++++++++++++--------- include/service.class.php | 8 ++- locale/de-AT/services.php | 4 +- vilesci/stammdaten/service_uebersicht.php | 30 ++++----- 4 files changed, 69 insertions(+), 47 deletions(-) mode change 100644 => 100755 cis/private/info/service_uebersicht.php mode change 100644 => 100755 include/service.class.php mode change 100644 => 100755 locale/de-AT/services.php mode change 100644 => 100755 vilesci/stammdaten/service_uebersicht.php diff --git a/cis/private/info/service_uebersicht.php b/cis/private/info/service_uebersicht.php old mode 100644 new mode 100755 index 5d5d5a01b..60a751927 --- a/cis/private/info/service_uebersicht.php +++ b/cis/private/info/service_uebersicht.php @@ -26,12 +26,12 @@ require_once('../../../include/phrasen.class.php'); require_once('../../../include/person.class.php'); $user = get_uid(); -$sprache = getSprache(); +$sprache = getSprache(); $p=new phrasen($sprache); //$rechte = new benutzerberechtigung(); //$rechte->getBerechtigungen($user); - + //if(!$rechte->isBerechtigt('basis/service')) // die('Sie haben keine Berechtigung fuer diese Seite'); @@ -42,7 +42,7 @@ echo ' '.$p->t("services/service").' - + @@ -50,20 +50,36 @@ echo ' - +'; + +// Load Addons to get Moodle_Path +$addon_obj = new addon(); +if ($addon_obj->loadAddons()) +{ + if (count($addon_obj->result) > 0) + { + foreach ($addon_obj->result as $row) + { + if (file_exists('../../../addons/'.$row->kurzbz.'/config.inc.php')) + include_once('../../../addons/'.$row->kurzbz.'/config.inc.php'); + } + } +} + +echo ' @@ -108,4 +113,5 @@ if($jqueryV1 && $jqueryCurrent) + From 34329edb74dd6d6dcadb848778f5ecb35f793e2c Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 29 Nov 2017 18:26:43 +0100 Subject: [PATCH 15/45] - Better code style - Clened views structure - Use session to store the filter state --- application/views/widgets/filter/filter.php | 58 ++- .../views/widgets/filter/selectFields.php | 9 +- .../views/widgets/filter/selectFilters.php | 90 ++-- .../views/widgets/filter/tableDataset.php | 59 ++- application/widgets/FilterWidget.php | 452 +++++++++++++++++- 5 files changed, 556 insertions(+), 112 deletions(-) diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php index 542708900..2be9bd405 100644 --- a/application/views/widgets/filter/filter.php +++ b/application/views/widgets/filter/filter.php @@ -1,15 +1,51 @@ -
- view('widgets/filter/selectFields', array('listFields' => $listFields)); ?> -
+load->view( + 'templates/header', + array('title' => 'Filters', 'tablesort' => true, 'tableid' => 'tableDataset', 'widgets' => 'zebra') + ); +?> + + +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +load->view('templates/footer'); +?> diff --git a/application/views/widgets/filter/selectFields.php b/application/views/widgets/filter/selectFields.php index a4f11dbfb..5129b9829 100644 --- a/application/views/widgets/filter/selectFields.php +++ b/application/views/widgets/filter/selectFields.php @@ -1,14 +1,17 @@
$value) + $selectedFields = FilterWidget::getSelectedFields(); + + foreach ($selectedFields as $key => $value) { - echo ''; + echo ''; } ?> +
Add: - $value) diff --git a/application/views/widgets/filter/selectFilters.php b/application/views/widgets/filter/selectFilters.php index ff3995727..bea5d7f00 100644 --- a/application/views/widgets/filter/selectFilters.php +++ b/application/views/widgets/filter/selectFilters.php @@ -1,59 +1,47 @@
+ +
+ + + name; ?> + + + + + + + + +
+ + +
+
+ + Add filter: + + + - - - - - - - - + type == 'varchar') - { - ?> - - - - type == 'bool') - { - ?> - - - '; } ?> -
-
- Add filter: - + +
diff --git a/application/views/widgets/filter/tableDataset.php b/application/views/widgets/filter/tableDataset.php index 83ca7b95f..402041ff8 100644 --- a/application/views/widgets/filter/tableDataset.php +++ b/application/views/widgets/filter/tableDataset.php @@ -1,48 +1,43 @@ - +retval; - - - - - - - - - + $selectedFields = FilterWidget::getSelectedFields(); +?>
- +
- - - - - + $value) + { + if (array_key_exists($value, $result[0])) + { + ?> + + retval; foreach ($result as $key => $value) { + echo ""; + + foreach ($selectedFields as $key2 => $value2) + { + if (array_key_exists($value2, $value)) + { ?> - - - - - - - + "; } ?> diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index a7715aa57..bf8efbf27 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -5,7 +5,33 @@ */ class FilterWidget extends Widget { + const APP_PARAMETER = 'app'; + const QUERY_PARAMETER = 'query'; + const DATASET_NAME_PARAMETER = 'datasetName'; + + 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 CMD_ADD_FILTER = 'addFilter'; + const CMD_REMOVE_FILTER = 'rmFilter'; + const CMD_ADD_FIELD = 'addField'; + const CMD_REMOVE_FIELD = 'rmField'; + const CMD_APPLY_FILTERS = 'applyFilters'; + private $app; + private $query; private $datasetName; /** @@ -13,7 +39,14 @@ class FilterWidget extends Widget */ public function __construct($name, $args = array()) { - parent::__construct($name, $args); + parent::__construct($name, $args); // + + $this->_initFilterWidget($args); // + + $this->_initSession(); // + + // + $this->load->model('system/Filters_model', 'FiltersModel'); } /** @@ -21,52 +54,441 @@ class FilterWidget extends Widget */ public function display($widgetData) { - $this->load->model('system/Filters_model', 'FiltersModel'); + // + $this->_setSessionFilterData(); - $this->app = $widgetData['app']; - $this->datasetName = $widgetData['datasetName']; - - $dataset = $this->FiltersModel->execReadOnlyQuery($widgetData['query']); + // + $dataset = $this->FiltersModel->execReadOnlyQuery($this->_generateQuery()); + // $listFields = $this->FiltersModel->getExecutedQueryListFields(); + // $metaData = $this->FiltersModel->getExecutedQueryMetaData(); + // $this->loadViewFilters($listFields, $metaData, $dataset); } /** * */ - private function loadViewFilters($listFields, $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 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 = ''; + $value = self::_getActiveFilterValue($filterMetaData->name); + + if ($filterMetaData->type == 'int4') + { + $html = ' + + + + + + + '; + } + elseif ($filterMetaData->type == 'varchar') + { + $html = ' + + + + + + + '; + } + elseif ($filterMetaData->type == 'bool') + { + $html = ' + + + + + + + '; + } + + return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $value); + } + + /** + * + */ + protected function loadViewFilters($listFields, $metaData, $dataset) + { + // Loads views $this->view( - 'widgets/filter/filter', - array('listFields' => $listFields, 'metaData' => $metaData, 'dataset' => $dataset) + self::WIDGET_URL_FILTER, + array( + self::DATASET_PARAMETER => $dataset, + self::METADATA_PARAMETER => $metaData, + self::LIST_FIELDS_PARAMETER => $listFields + ) ); } /** * */ - private function loadViewSelectFields($listFields) + private static function _getFromSession($key) { - $this->view('widgets/filter/selectFields', array('listFields' => $listFields)); + $_getFromSession = null; + $ci =& get_instance(); + $filterSessionArray = $ci->session->userdata(self::SESSION_NAME); + + if (isset($filterSessionArray[$key])) + { + $_getFromSession = $filterSessionArray[$key]; + } + + return $_getFromSession; } /** * */ - private function loadViewSelectFilters($metaData) + private static function _getActiveFilterValue($filterName) { - $this->view('widgets/filter/selectFilters', array('metaData' => $metaData)); + $getActiveFilterValue = ''; + + $activeFields = self::_getFromSession(self::ACTIVE_FILTERS); + + if (isset($activeFields[$filterName])) + { + $getActiveFilterValue = $activeFields[$filterName]; + } + + return $getActiveFilterValue; } /** * */ - private function loadViewTableDataset($dataset) + private static function _loadView($viewName, $parameters) { - $this->view('widgets/filter/tableDataset', array('dataset' => $dataset)); + $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(); + } + + $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); + } + + /** + * + */ + private function _initFilterWidget($args) + { + if (is_array($args) && count($args) > 0) + { + if (isset($args[self::APP_PARAMETER])) + { + $this->app = $args[self::APP_PARAMETER]; + } + else + { + show_error('The "'.self::APP_PARAMETER.'" parameter must be specified'); + } + + if (isset($args[self::DATASET_NAME_PARAMETER])) + { + $this->datasetName = $args[self::DATASET_NAME_PARAMETER]; + } + else + { + show_error('The "'.self::DATASET_NAME_PARAMETER.'" parameter must be specified'); + } + + if (isset($args[self::QUERY_PARAMETER])) + { + $this->query = $args[self::QUERY_PARAMETER]; + } + else + { + show_error('The "'.self::QUERY_PARAMETER.'" parameter must be specified'); + } + } + else + { + show_error('Second parameter must be an associative array'); + } + } + + /** + * + */ + 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]) != '') + { + $tmpArray = array(); + foreach ($selectedFields as $key => $value) + { + if ($_POST[self::CMD_REMOVE_FIELD] != $value) + { + $tmpArray[] = $value; + } + } + + $selectedFields = $tmpArray; + } + } + + return $selectedFields; + } + + /** + * + */ + private function _getSelectedFiltersFromPost() + { + // Selected filters + $selectedFilters = array(); + $activeFilters = array(); + + $filterSessionArray = $this->session->userdata(self::SESSION_NAME); + + if (isset($filterSessionArray[self::SELECTED_FILTERS])) + { + $selectedFilters = $filterSessionArray[self::SELECTED_FILTERS]; + } + + if (isset($filterSessionArray[self::ACTIVE_FILTERS])) + { + $activeFilters = $filterSessionArray[self::ACTIVE_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]) != '') + { + $tmpArray = array(); + foreach ($selectedFilters as $key => $value) + { + if ($_POST[self::CMD_REMOVE_FILTER] != $value) + { + $tmpArray[] = $value; + } + } + + $selectedFilters = $tmpArray; + + if (isset($activeFilters[$_POST[self::CMD_REMOVE_FILTER]])) + { + + } + } + } + + return $selectedFilters; + } + + /** + * + */ + private function _getActiveFiltersFromPost() + { + // Selected fields + $activeFilters = array(); + $selectedFilters = array(); + + $filterSessionArray = $this->session->userdata(self::SESSION_NAME); + + if (isset($filterSessionArray[self::ACTIVE_FILTERS])) + { + $activeFilters = $filterSessionArray[self::ACTIVE_FILTERS]; + } + + if (isset($filterSessionArray[self::SELECTED_FILTERS])) + { + $selectedFilters = $filterSessionArray[self::SELECTED_FILTERS]; + } + + if (is_array($_POST)) + { + for ($selectedFiltersCounter = 0; $selectedFiltersCounter < count($selectedFilters); $selectedFiltersCounter++) + { + $selectedFilter = $selectedFilters[$selectedFiltersCounter]; + + if (isset($_POST[$selectedFilter])) + { + $activeFilters[$selectedFilter] = $_POST[$selectedFilter]; + } + } + } + + return $activeFilters; + } + + /** + * + */ + private function _setSessionFilterData() + { + $filterSessionArray = array( + self::SELECTED_FIELDS => $this->_getSelectedFieldsFromPost(), + self::SELECTED_FILTERS => $this->_getSelectedFiltersFromPost(), + self::ACTIVE_FILTERS => $this->_getActiveFiltersFromPost(), + ); + + $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); + } + + /** + * + */ + private function _generateQuery() + { + $query = $this->query; + // Filters dataset + if (is_array($_POST) + && array_key_exists(self::CMD_APPLY_FILTERS, $_POST) + && $_POST[self::CMD_APPLY_FILTERS] == 'true') + { + if (is_array($_POST) && array_key_exists(self::SELECTED_FILTERS, $_POST)) + { + $selectedFilters = $_POST[self::SELECTED_FILTERS]; + } + + for ($filtersCounter = 0; $filtersCounter < count($selectedFilters); $filtersCounter++) + { + $selectedFilter = $selectedFilters[$filtersCounter]; + + if (isset($_POST[$selectedFilter])) + { + } + } + + $query = 'SELECT * FROM ('.$this->query.') tableFilters WHERE "Vorname" ILIKE \'%Oliver%\''; + } + + return $query; } } From ec00c93d04fd0389fe87a7fbceae36727f4584ce Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 1 Dec 2017 15:15:16 +0100 Subject: [PATCH 16/45] Better check if a table contains data before using the tablesorter --- application/views/templates/header.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/templates/header.php b/application/views/templates/header.php index 0cb3a9fad..47befaac7 100644 --- a/application/views/templates/header.php +++ b/application/views/templates/header.php @@ -69,9 +69,9 @@ if($jqueryV1 && $jqueryCurrent) '; } } - + if ($work=='del') { if(!$veranstaltung=$Jahresplan->deleteVeranstaltung($veranstaltung_id)) - { + { $error=$p->t("global/fehlerBeimLoeschenDesEintrags").$Jahresplan->errormsg; } else @@ -137,34 +137,34 @@ if (window.opener && !window.opener.closed) { if (confirm("'.$p->t("eventkalender/sollDieHauptseiteNeuAufgebautWerden").'?")) { window.opener.location.reload(); - } + } this.close(); } --> - - '; + + '; } } } // ------------------------------------------------------------------------------------------ -// Kategorie - Daten lesen fuer Kategorieselect +// Kategorie - Daten lesen fuer Kategorieselect // Veranstaltungskategorien ohne Selektionsbedingung // ------------------------------------------------------------------------------------------ $Jahresplan->InitVeranstaltungskategorie(); - // Nur Berechtigte duerfen auch noch nicht freigegebene Sehen + // Nur Berechtigte duerfen auch noch nicht freigegebene Sehen $Jahresplan->show_only_public_kategorie=($is_mitarbeiter?false:true); if (!$veranstaltungskategorie=$Jahresplan->loadVeranstaltungskategorie()) die($Jahresplan->errormsg); - + // ------------------------------------------------------------------------------------------ // Daten lesen fuer Anzeige der // Veranstaltungen mit Selektionsbedingung // ------------------------------------------------------------------------------------------ if (!empty($veranstaltung_id)) { - $Jahresplan->InitVeranstaltung(); - // Nur Berechtigte duerfen auch noch nicht freigegebene Sehen + $Jahresplan->InitVeranstaltung(); + // Nur Berechtigte duerfen auch noch nicht freigegebene Sehen $Jahresplan->show_only_public_kategorie=($is_mitarbeiter?false:true); $Jahresplan->freigabe=($is_wartungsberechtigt?false:true); @@ -175,7 +175,7 @@ if ($veranstaltungen=$Jahresplan->loadVeranstaltung()) { $veranstaltungen=jahresplan_funk_veranstaltung_extend($veranstaltungen); - while (list($key, $value) = each($veranstaltungen)) + while (list($key, $value) = each($veranstaltungen)) { $veranstaltung[$key]=$value; } @@ -187,16 +187,16 @@ die($Jahresplan->errormsg); } // Plausib - if (!is_array($veranstaltung) || count($veranstaltung)<1 || !isset($veranstaltung["veranstaltung_id"])) + if (!is_array($veranstaltung) || count($veranstaltung)<1 || !isset($veranstaltung["veranstaltung_id"])) { $work='new'; - } + } } else // Reload ohne Datenverarbeitung , die Aufrufparameter in die Datentabelle uebertragen fuer Value der Inputfelder { $veranstaltung=$_REQUEST; } -?> +?> @@ -208,11 +208,11 @@ - + + -" method="post" enctype="multipart/form-data">
PersonIdNachnameVornameEmailAktiv
PersonId; ?>Nachname; ?>Vorname; ?>Email; ?>Aktiv === true ? 'True' : 'False'; ?>
{$value2}; ?>
- + - + - + @@ -482,18 +482,30 @@  t("eventkalender/ganztaegigeVeranstaltung")?>   type="checkbox" value="1" onclick="if (this.checked!=false) {window.document.selVeranstaltung.Zeit1.options.selectedIndex=0;window.document.selVeranstaltung.Zeit2.options.selectedIndex=(window.document.selVeranstaltung.Zeit2.options.length - 1); }; var time_stamp=TimestampDatumZeit(window.document.selVeranstaltung.Datum1.value,window.document.selVeranstaltung.Zeit1.value); if (time_stamp) {window.document.selVeranstaltung.start.value=time_stamp; }; time_stamp=TimestampDatumZeit(window.document.selVeranstaltung.Datum2.value,window.document.selVeranstaltung.Zeit2.value); if (time_stamp) {window.document.selVeranstaltung.ende.value=time_stamp; };" name="tmpGanztag" > - - + + - - - + + + - - + + - + + + + + + + + "; + } + else + { + echo ' + + + '; + } + echo '
@@ -408,9 +408,9 @@ " class="cursor_hand" onclick="self.location.href='';" >t("eventkalender/neuanlage")?> Neuanlage
+ + +
+ + +
@@ -521,7 +533,7 @@
@@ -548,12 +560,12 @@ '.$error.'

'; - + $veranstaltung_id=(isset($veranstaltung['veranstaltung_id'])?$veranstaltung['veranstaltung_id']:$veranstaltung_id); if (!empty($veranstaltung_id)) { echo '
'.jahresplan_veranstaltung_detail_user($veranstaltung,$is_wartungsberechtigt); - echo ''.$p->t("eventkalender/reservierungenInEinemNeuenFensterAnzeigen").'.'; + echo ''.$p->t("eventkalender/reservierungenInEinemNeuenFensterAnzeigen").'.'; echo ''; } else @@ -562,4 +574,4 @@ } ?> - + From e2908cc1d7c1cdf5640231dc78ca1b10e1ee77ef Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 1 Dec 2017 16:57:18 +0100 Subject: [PATCH 19/45] - Sets correctly the selected filter operation - Use enter to set a filter - Replaced submit buttons with buttons --- application/views/widgets/filter/filter.php | 9 ++++- .../views/widgets/filter/selectFields.php | 2 +- .../views/widgets/filter/selectFilters.php | 2 +- application/widgets/FilterWidget.php | 38 ++++++++++++++----- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php index 23d3981d7..271b5a224 100644 --- a/application/views/widgets/filter/filter.php +++ b/application/views/widgets/filter/filter.php @@ -14,6 +14,7 @@ $(".remove-field").each(function() { $(this).click(function() { $("#rmField").val($(this).attr('fieldToRemove')); + $("#filterForm").submit(); }); }); @@ -24,6 +25,7 @@ $(".remove-filter").each(function() { $(this).click(function() { $("#rmFilter").val($(this).attr('filterToRemove')); + $("#filterForm").submit(); }); }); @@ -31,8 +33,11 @@ $("#filterForm").submit(); }); - $(".select-filter-operation-value").keyup(function() { - $("#filterForm").submit(); + $(".select-filter-operation-value").keydown(function(event) { + if (event.which == 13) + { + $("#filterForm").submit(); + } }); }); diff --git a/application/views/widgets/filter/selectFields.php b/application/views/widgets/filter/selectFields.php index 94ee75267..8bc988125 100644 --- a/application/views/widgets/filter/selectFields.php +++ b/application/views/widgets/filter/selectFields.php @@ -6,7 +6,7 @@ { $selectedField = $selectedFields[$selectedFieldsCounter]; ?> - + diff --git a/application/views/widgets/filter/selectFilters.php b/application/views/widgets/filter/selectFilters.php index 4f9d65340..9a4aa0ffd 100644 --- a/application/views/widgets/filter/selectFilters.php +++ b/application/views/widgets/filter/selectFilters.php @@ -17,7 +17,7 @@ - + diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index b5e5bb766..0c456365e 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -146,17 +146,18 @@ class FilterWidget extends Widget public static function renderFilterType($filterMetaData) { $html = ''; - $value = self::_getActiveFilterValue($filterMetaData->name); + $activeFilterValue = self::_getActiveFilterValue($filterMetaData->name); + $activeFilterOperationValue = self::_getActiveFilterOperationValue($filterMetaData->name); if ($filterMetaData->type == 'int4') { $html = ' @@ -169,8 +170,8 @@ class FilterWidget extends Widget $html = ' @@ -183,8 +184,8 @@ class FilterWidget extends Widget $html = ' @@ -193,7 +194,7 @@ class FilterWidget extends Widget '; } - return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $value); + return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $activeFilterValue); } /** @@ -246,6 +247,23 @@ class FilterWidget extends Widget return $getActiveFilterValue; } + /** + * + */ + private static function _getActiveFilterOperationValue($filterName) + { + $getActiveFilterOperationValue = ''; + + $activeFieldsOperation = self::_getFromSession(self::ACTIVE_FILTERS_OPERATION); + + if (isset($activeFieldsOperation[$filterName])) + { + $getActiveFilterOperationValue = $activeFieldsOperation[$filterName]; + } + + return $getActiveFilterOperationValue; + } + /** * */ From 749aa4525a299222c6d45ef76a36ec0312dfb263 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 4 Dec 2017 10:03:34 +0100 Subject: [PATCH 20/45] beautified links (links are only on words) CSV Export, Import... --- cis/private/tools/zeitaufzeichnung.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index 609e3f9f5..8b145092e 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -720,13 +720,13 @@ if($projekt->getProjekteMitarbeiter($user, true)) echo " + + - + + + + @@ -27,29 +45,43 @@ ?> + + {$selectedField}, $result); ?> + + load->model('system/Filters_model', 'FiltersModel'); + + self::$FilterWidgetInstance = $this; } /** @@ -107,12 +118,25 @@ class FilterWidget extends Widget 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)); + self::_loadView( + self::WIDGET_URL_TABLE_DATASET, + array( + self::DATASET_PARAMETER => $dataset + ) + ); } /** @@ -207,6 +231,39 @@ class FilterWidget extends Widget return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $activeFilterValue); } + /** + * + */ + public static function formatRaw($fieldName, $fieldValue, $datasetRaw) + { + $tmpDatasetRaw = clone $datasetRaw; + + if (is_bool($fieldValue)) + { + $tmpDatasetRaw->{$fieldName} = $fieldValue === true ? 'true' : 'false'; + } + + $formatRaw = self::$FilterWidgetInstance->getFormatRaw(); + + if ($formatRaw != null) + { + $tmpDatasetRaw = $formatRaw($fieldName, $fieldValue, $tmpDatasetRaw); + } + + return $tmpDatasetRaw; + } + + /** + * + */ + public static function getCheckboxes() + { + return self::$FilterWidgetInstance->_getCheckboxes(); + } + + //------------------------------------------------------------------------------------------------------------------ + // Protected + /** * */ @@ -223,6 +280,25 @@ class FilterWidget extends Widget ); } + /** + * + */ + protected function getFormatRaw() + { + return $this->formatRaw; + } + + /** + * + */ + protected function _getCheckboxes() + { + return $this->checkboxes; + } + + //------------------------------------------------------------------------------------------------------------------ + // Private + /** * */ @@ -315,6 +391,11 @@ class FilterWidget extends Widget $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); } @@ -323,48 +404,80 @@ class FilterWidget extends Widget */ private function _initFilterWidget($args) { - if (is_array($args) && count($args) > 0) + $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)) { - if (isset($args[self::APP_PARAMETER])) - { - $this->app = $args[self::APP_PARAMETER]; - } - else - { - show_error('The "'.self::APP_PARAMETER.'" parameter must be specified'); - } - - if (isset($args[self::DATASET_NAME_PARAMETER])) - { - $this->datasetName = $args[self::DATASET_NAME_PARAMETER]; - } - else - { - show_error('The "'.self::DATASET_NAME_PARAMETER.'" parameter must be specified'); - } - - if (isset($args[self::QUERY_PARAMETER])) - { - $this->query = $args[self::QUERY_PARAMETER]; - } - else - { - show_error('The "'.self::QUERY_PARAMETER.'" parameter must be specified'); - } - - if (isset($args[self::FILTER_KURZBZ])) - { - $this->filterKurzbz = $args[self::FILTER_KURZBZ]; - } - - if (isset($args[self::FILTER_ID])) - { - $this->filterId = $args[self::FILTER_ID]; - } + show_error('Second parameter must be a not empty associative array'); } else { - show_error('Second parameter must be an associative array'); + 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]; + } } } @@ -388,15 +501,29 @@ class FilterWidget extends Widget // $this->FiltersModel->addLimit(1); - // - $filter = $this->FiltersModel->loadWhere( - array( + $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; @@ -585,7 +712,8 @@ class FilterWidget extends Widget { $filterSessionArray = array( self::SELECTED_FIELDS => $this->_getSelectedFieldsFromPost(), - self::SELECTED_FILTERS => $this->_getSelectedFiltersFromPost() + self::SELECTED_FILTERS => $this->_getSelectedFiltersFromPost(), + self::ADDITIONAL_COLUMNS => $this->additionalColumns ); $filterSessionArray[self::ACTIVE_FILTERS] = array(); @@ -626,49 +754,52 @@ class FilterWidget extends Widget foreach ($activeFilters as $field => $activeFilterValue) { - if ($first) + if (trim($activeFilterValue) != '') { - $first = false; - } - else - { - $where .= ' AND '; - } - - if (isset($activeFiltersOperation[$field])) - { - $where .= '"'.$field.'"'; - $condition = ''; - - switch ($activeFiltersOperation[$field]) + if ($first) { - 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; + $first = false; + } + else + { + $where .= ' AND '; } - $where .= $condition; + 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; + } } } From 5d7477c4941526cf39714c8783af704acce0fff0 Mon Sep 17 00:00:00 2001 From: oesi Date: Tue, 5 Dec 2017 17:01:11 +0100 Subject: [PATCH 25/45] =?UTF-8?q?=C3=96ffnen=20von=20gesperrten=20Verteile?= =?UTF-8?q?r=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/private/open_grp.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cis/private/open_grp.php b/cis/private/open_grp.php index 9b9bd2038..db526c396 100644 --- a/cis/private/open_grp.php +++ b/cis/private/open_grp.php @@ -104,8 +104,8 @@ if(isset($_REQUEST['token']) && isset($_REQUEST['grp'])) /* Generate an random String */ $mail_id=mail_id_generator(); - /* call the shellpart at polyxena */ - $command = "ssh -p 22022 root@polyxena sudo /root/bin/mlistin.sh " . $_REQUEST['grp'] . " " . $mail_id . " 2>&1"; + /* Command to unlock Mailgroup */ + $command = "ssh -i /etc/apache2/id_mail_provisioning mailadmins@bifrost2 ".$_REQUEST['grp'] . " " . $mail_id; exec($command); /* ffe, 20051020 - do a little logging */ From a7582c88683e016a9831d72f517e433d6ecf0444 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 5 Dec 2017 17:39:31 +0100 Subject: [PATCH 26/45] - Method execReadOnlyQuery of DB_Model has a less strict check about the query statement - Added a first management of the type date --- .../controllers/system/TestFilterWidget.php | 8 +-- application/core/DB_Model.php | 28 +++++----- application/widgets/FilterWidget.php | 51 +++++++++++++++---- 3 files changed, 62 insertions(+), 25 deletions(-) diff --git a/application/controllers/system/TestFilterWidget.php b/application/controllers/system/TestFilterWidget.php index e269e4cf9..1984ddb15 100644 --- a/application/controllers/system/TestFilterWidget.php +++ b/application/controllers/system/TestFilterWidget.php @@ -27,13 +27,15 @@ class TestFilterWidget extends VileSci_Controller p.nachname AS "Nachname", p.vorname AS "Vorname", k.kontakt AS "Email", - p.aktiv AS "Aktiv" + 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) { @@ -42,11 +44,11 @@ class TestFilterWidget extends VileSci_Controller { $datasetRaw->{$fieldName} = ''.$fieldValue.''; } - if ($fieldName == 'Delete') + elseif ($fieldName == 'Delete') { $datasetRaw->{$fieldName} = 'Delete'; } - if ($fieldName == 'Edit') + elseif ($fieldName == 'Edit') { $datasetRaw->{$fieldName} = 'Edit'; } diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index e6bd31114..3dc5e85ac 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -694,21 +694,25 @@ class DB_Model extends FHC_Model */ 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($query, 'INSERT') - && !stripos($query, 'UPDATE') - && !stripos($query, 'DELETE') - && !stripos($query, 'CREATE') - && !stripos($query, 'ALTER') - && !stripos($query, 'GRANT') - && !stripos($query, 'DROP')) + 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)) { - return $this->execQuery($query, $parametersArray); - } - else - { - return error('You are allowed to run only query for reading data'); + $queryToExec = str_replace(';', '', $query); // + + $result = $this->execQuery($queryToExec, $parametersArray); } + + return $result; } // ------------------------------------------------------------------------------------------ diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index f8c2881c2..3a5e93247 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -47,6 +47,8 @@ class FilterWidget extends Widget 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; @@ -56,6 +58,8 @@ class FilterWidget extends Widget private $formatRaw; private $checkboxes; + private $metaData; + private static $FilterWidgetInstance; /** @@ -96,10 +100,10 @@ class FilterWidget extends Widget $listFields = $this->FiltersModel->getExecutedQueryListFields(); // - $metaData = $this->FiltersModel->getExecutedQueryMetaData(); + $this->metaData = $this->FiltersModel->getExecutedQueryMetaData(); // - $this->loadViewFilters($listFields, $metaData, $dataset); + $this->loadViewFilters($listFields, $this->metaData, $dataset); } /** @@ -227,6 +231,23 @@ class FilterWidget extends Widget '; } + elseif ($filterMetaData->type == 'timestamp') + { + $html = ' + + + + + + + + '; + } return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $activeFilterValue); } @@ -236,18 +257,28 @@ class FilterWidget extends Widget */ public static function formatRaw($fieldName, $fieldValue, $datasetRaw) { - $tmpDatasetRaw = clone $datasetRaw; + $tmpDatasetRaw = null; - if (is_bool($fieldValue)) + if (is_object($datasetRaw)) { - $tmpDatasetRaw->{$fieldName} = $fieldValue === true ? 'true' : 'false'; - } + $tmpDatasetRaw = clone $datasetRaw; + $tmpMetaData = self::getFilterMetaData($fieldName, self::$FilterWidgetInstance->metaData); - $formatRaw = self::$FilterWidgetInstance->getFormatRaw(); + 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)); + } - if ($formatRaw != null) - { - $tmpDatasetRaw = $formatRaw($fieldName, $fieldValue, $tmpDatasetRaw); + $formatRaw = self::$FilterWidgetInstance->getFormatRaw(); + + if ($formatRaw != null) + { + $tmpDatasetRaw = $formatRaw($fieldName, $fieldValue, $tmpDatasetRaw); + } } return $tmpDatasetRaw; From 543e4a8fedce5025264d578d488c4502530229a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 6 Dec 2017 08:03:33 +0100 Subject: [PATCH 27/45] =?UTF-8?q?TicketIDs=20k=C3=B6nnen=20im=20Jahresplan?= =?UTF-8?q?=20mit=20#1234=20verlinkt=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jahresplan/jahresplan_funktionen.inc.php | 17 +++++++++++++++++ config/cis.config-default.inc.php | 3 +++ 2 files changed, 20 insertions(+) diff --git a/cis/private/jahresplan/jahresplan_funktionen.inc.php b/cis/private/jahresplan/jahresplan_funktionen.inc.php index 72277f22b..a2b8699c4 100644 --- a/cis/private/jahresplan/jahresplan_funktionen.inc.php +++ b/cis/private/jahresplan/jahresplan_funktionen.inc.php @@ -1100,6 +1100,7 @@ function jahresplan_date_to_timestamp($string="") function printlinks($text) { + // Volle Links $pattern = '~[a-z]+://\S+~'; if($num_found = preg_match_all($pattern, $text, $out)) @@ -1109,5 +1110,21 @@ function printlinks($text) echo ''.$link.'
'; } } + + if(defined('JAHRESPLAN_TICKET_LINK')) + { + // TicketsIds mit #1234 + $pattern = '~\#[0-9]+~'; + + if($num_found = preg_match_all($pattern, $text, $out)) + { + foreach($out[0] as $ticketnr) + { + $id = mb_substr($ticketnr,1); + $link = JAHRESPLAN_TICKET_LINK.$id; + echo ''.$link.'
'; + } + } + } } ?> diff --git a/config/cis.config-default.inc.php b/config/cis.config-default.inc.php index 49af7cdd6..063518284 100644 --- a/config/cis.config-default.inc.php +++ b/config/cis.config-default.inc.php @@ -232,4 +232,7 @@ define('CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN', serialize(array("Studiengebuehr"))) //Gibt an bei welcher Länge die LV-Bezeichnungen im Menü abgeschnitten werden. Default: 21 define('CIS_LVMENUE_CUTLENGTH', 21); + +// Gibt an, auf welche Seite TicketIds ala #1234 im Jahresplan verlinkt werden zB zur Verlinkung in Bugtracker +define('JAHRESPLAN_TICKET_LINK','https://bug.technikum-wien.at/otrs/index.pl?Action=AgentTicketZoom;TicketID='); ?> From ec58b3eea157f5a975486299fd29e122c20bb5af Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 11 Dec 2017 15:12:51 +0100 Subject: [PATCH 28/45] Added full date filter support --- .../controllers/system/TestFilterWidget.php | 4 +- application/widgets/FilterWidget.php | 138 ++++++++++++++---- 2 files changed, 110 insertions(+), 32 deletions(-) diff --git a/application/controllers/system/TestFilterWidget.php b/application/controllers/system/TestFilterWidget.php index 1984ddb15..45c5d36bf 100644 --- a/application/controllers/system/TestFilterWidget.php +++ b/application/controllers/system/TestFilterWidget.php @@ -28,14 +28,14 @@ class TestFilterWidget extends VileSci_Controller p.vorname AS "Vorname", k.kontakt AS "Email", p.aktiv AS "Aktiv", - k.updateamum AS "Update date" + k.updateamum AS "UpdateDate" 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, + 'hideHeader' => false, 'checkboxes' => array('PersonId'), 'additionalColumns' => array('Delete', 'Edit'), 'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) { diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 3a5e93247..56b83304b 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -14,6 +14,7 @@ class FilterWidget extends Widget const ADDITIONAL_COLUMNS = 'additionalColumns'; const FORMAT_RAW = 'formatRaw'; const CHECKBOXES = 'checkboxes'; + const HIDE_HEADER = 'hideHeader'; const DATASET_PARAMETER = 'dataset'; const METADATA_PARAMETER = 'metaData'; @@ -29,8 +30,10 @@ class FilterWidget extends Widget const SELECTED_FIELDS = 'selectedFields'; const SELECTED_FILTERS = 'selectedFilters'; const ACTIVE_FILTERS = 'activeFilters'; + const ACTIVE_FILTERS_OPTION = 'activeFiltersOption'; const ACTIVE_FILTERS_OPERATION = 'activeFiltersOperation'; + const ACTIVE_FILTER_OPTION_POSTFIX = '-option'; const ACTIVE_FILTER_OPERATION_POSTFIX = '-operation'; const CMD_ADD_FILTER = 'addFilter'; @@ -41,13 +44,16 @@ class FilterWidget extends Widget const OP_EQUAL = 'equal'; const OP_NOT_EQUAL = 'nequal'; const OP_GREATER_THAN = 'gt'; - const OP_LESS_THAN = 'ld'; + const OP_LESS_THAN = 'lt'; 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'; + const OPT_DAYS = 'days'; + const OPT_MONTHS = 'months'; + + const DEFAULT_DATE_FORMAT = 'Y.m.d H:i:s'; private $app; private $query; @@ -58,7 +64,9 @@ class FilterWidget extends Widget private $formatRaw; private $checkboxes; + private $dataset; private $metaData; + private $listFields; private static $FilterWidgetInstance; @@ -94,16 +102,16 @@ class FilterWidget extends Widget $this->FiltersModel->resetQuery(); // - $dataset = @$this->FiltersModel->execReadOnlyQuery($this->_generateQuery()); + $this->dataset = @$this->FiltersModel->execReadOnlyQuery($this->_generateQuery()); // - $listFields = $this->FiltersModel->getExecutedQueryListFields(); + $this->listFields = $this->FiltersModel->getExecutedQueryListFields(); // $this->metaData = $this->FiltersModel->getExecutedQueryMetaData(); // - $this->loadViewFilters($listFields, $this->metaData, $dataset); + $this->loadViewFilters(); } /** @@ -133,30 +141,31 @@ class FilterWidget extends Widget /** * */ - public static function loadViewTableDataset($dataset) + public static function loadViewSelectFields() { - self::_loadView( - self::WIDGET_URL_TABLE_DATASET, - array( - self::DATASET_PARAMETER => $dataset - ) - ); + if (self::$FilterWidgetInstance->hideHeader != true) + { + self::_loadView(self::WIDGET_URL_SELECT_FIELDS, array(self::LIST_FIELDS_PARAMETER => self::$FilterWidgetInstance->listFields)); + } } /** * */ - public static function loadViewSelectFilters($metaData) + public static function loadViewSelectFilters() { - self::_loadView(self::WIDGET_URL_SELECT_FILTERS, array(self::METADATA_PARAMETER => $metaData)); + if (self::$FilterWidgetInstance->hideHeader != true) + { + self::_loadView(self::WIDGET_URL_SELECT_FILTERS, array(self::METADATA_PARAMETER => self::$FilterWidgetInstance->metaData)); + } } /** * */ - public static function loadViewSelectFields($listFields) + public static function loadViewTableDataset() { - self::_loadView(self::WIDGET_URL_SELECT_FIELDS, array(self::LIST_FIELDS_PARAMETER => $listFields)); + self::_loadView(self::WIDGET_URL_TABLE_DATASET, array(self::DATASET_PARAMETER => self::$FilterWidgetInstance->dataset)); } /** @@ -186,6 +195,7 @@ class FilterWidget extends Widget $html = ''; $activeFilterValue = self::_getActiveFilterValue($filterMetaData->name); $activeFilterOperationValue = self::_getActiveFilterOperationValue($filterMetaData->name); + $activeFilterOptionValue = self::_getActiveFilterOptionValue($filterMetaData->name); if ($filterMetaData->type == 'int4') { @@ -242,14 +252,14 @@ class FilterWidget extends Widget - + + '; } - return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $activeFilterValue); + return sprintf($html, $filterMetaData->name.'-operation', $filterMetaData->name, $activeFilterValue, $filterMetaData->name.'-option'); } /** @@ -298,15 +308,14 @@ class FilterWidget extends Widget /** * */ - protected function loadViewFilters($listFields, $metaData, $dataset) + protected function loadViewFilters() { // Loads views - $this->view( - self::WIDGET_URL_FILTER, + $this->view(self::WIDGET_URL_FILTER, array( - self::DATASET_PARAMETER => $dataset, - self::METADATA_PARAMETER => $metaData, - self::LIST_FIELDS_PARAMETER => $listFields + self::DATASET_PARAMETER => $this->dataset, + self::METADATA_PARAMETER => $this->metaData, + self::LIST_FIELDS_PARAMETER => $this->listFields ) ); } @@ -381,6 +390,23 @@ class FilterWidget extends Widget return $getActiveFilterOperationValue; } + /** + * + */ + private static function _getActiveFilterOptionValue($filterName) + { + $getActiveFilterOptionValue = ''; + + $activeFieldsOption = self::_getFromSession(self::ACTIVE_FILTERS_OPTION); + + if (isset($activeFieldsOption[$filterName])) + { + $getActiveFilterOptionValue = $activeFieldsOption[$filterName]; + } + + return $getActiveFilterOptionValue; + } + /** * */ @@ -422,6 +448,11 @@ class FilterWidget extends Widget $filterSessionArray[self::ACTIVE_FILTERS_OPERATION] = array(); } + if (!isset($filterSessionArray[self::ACTIVE_FILTERS_OPTION])) + { + $filterSessionArray[self::ACTIVE_FILTERS_OPTION] = array(); + } + if (!isset($filterSessionArray[self::ADDITIONAL_COLUMNS])) { $filterSessionArray[self::ADDITIONAL_COLUMNS] = array(); @@ -443,6 +474,7 @@ class FilterWidget extends Widget $this->additionalColumns = null; $this->formatRaw = null; $this->checkboxes = null; + $this->hideHeader = false; if (!is_array($args) || (is_array($args) && count($args) == 0)) { @@ -509,6 +541,11 @@ class FilterWidget extends Widget { $this->checkboxes = $args[self::CHECKBOXES]; } + + if (isset($args[self::HIDE_HEADER]) && is_bool($args[self::HIDE_HEADER])) + { + $this->hideHeader = $args[self::HIDE_HEADER]; + } } } @@ -573,6 +610,7 @@ class FilterWidget extends Widget $selectedFilters = array(); $activeFilters = array(); $activeFiltersOperation = array(); + $activeFiltersOption = array(); if (isset($jsonEncodedFilter->columns)) { @@ -598,6 +636,10 @@ class FilterWidget extends Widget $selectedFilters[] = $filters[$filtersCounter]->name; $activeFilters[$filters[$filtersCounter]->name] = $filters[$filtersCounter]->condition; $activeFiltersOperation[$filters[$filtersCounter]->name] = $filters[$filtersCounter]->operation; + if (isset($filters[$filtersCounter]->option)) + { + $activeFiltersOption[$filters[$filtersCounter]->name] = $filters[$filtersCounter]->option; + } } } } @@ -606,7 +648,8 @@ class FilterWidget extends Widget self::SELECTED_FIELDS => $selectedFields, self::SELECTED_FILTERS => $selectedFilters, self::ACTIVE_FILTERS => $activeFilters, - self::ACTIVE_FILTERS_OPERATION => $activeFiltersOperation + self::ACTIVE_FILTERS_OPERATION => $activeFiltersOperation, + self::ACTIVE_FILTERS_OPTION => $activeFiltersOption ); $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); @@ -682,7 +725,7 @@ class FilterWidget extends Widget /** * */ - private function _setActiveFiltersFromPost(&$activeFilters, &$activeFiltersOperation) + private function _setActiveFiltersFromPost(&$activeFilters, &$activeFiltersOperation, &$activeFiltersOption) { $selectedFilters = array(); $filterSessionArray = $this->session->userdata(self::SESSION_NAME); @@ -697,6 +740,11 @@ class FilterWidget extends Widget $activeFiltersOperation = $filterSessionArray[self::ACTIVE_FILTERS_OPERATION]; } + if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPTION])) + { + $activeFiltersOption = $filterSessionArray[self::ACTIVE_FILTERS_OPTION]; + } + if (isset($filterSessionArray[self::SELECTED_FILTERS])) { $selectedFilters = $filterSessionArray[self::SELECTED_FILTERS]; @@ -715,6 +763,11 @@ class FilterWidget extends Widget { unset($activeFiltersOperation[$_POST[self::CMD_REMOVE_FILTER]]); } + + if (isset($activeFiltersOption[$_POST[self::CMD_REMOVE_FILTER]])) + { + unset($activeFiltersOption[$_POST[self::CMD_REMOVE_FILTER]]); + } } else { @@ -731,6 +784,11 @@ class FilterWidget extends Widget { $activeFiltersOperation[$selectedFilter] = $_POST[$selectedFilter.self::ACTIVE_FILTER_OPERATION_POSTFIX]; } + + if (isset($_POST[$selectedFilter.self::ACTIVE_FILTER_OPTION_POSTFIX])) + { + $activeFiltersOption[$selectedFilter] = $_POST[$selectedFilter.self::ACTIVE_FILTER_OPTION_POSTFIX]; + } } } } @@ -749,10 +807,12 @@ class FilterWidget extends Widget $filterSessionArray[self::ACTIVE_FILTERS] = array(); $filterSessionArray[self::ACTIVE_FILTERS_OPERATION] = array(); + $filterSessionArray[self::ACTIVE_FILTERS_OPTION] = array(); $this->_setActiveFiltersFromPost( $filterSessionArray[self::ACTIVE_FILTERS], - $filterSessionArray[self::ACTIVE_FILTERS_OPERATION] + $filterSessionArray[self::ACTIVE_FILTERS_OPERATION], + $filterSessionArray[self::ACTIVE_FILTERS_OPTION] ); $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); @@ -765,6 +825,10 @@ class FilterWidget extends Widget { $query = $this->query; + $activeFilters = array(); + $activeFiltersOperation = array(); + $activeFiltersOption = array(); + $filterSessionArray = $this->session->userdata(self::SESSION_NAME); if (isset($filterSessionArray[self::ACTIVE_FILTERS])) @@ -777,6 +841,11 @@ class FilterWidget extends Widget $activeFiltersOperation = $filterSessionArray[self::ACTIVE_FILTERS_OPERATION]; } + if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPTION])) + { + $activeFiltersOption = $filterSessionArray[self::ACTIVE_FILTERS_OPTION]; + } + // if (count($activeFilters) > 0) { @@ -813,7 +882,16 @@ class FilterWidget extends Widget $condition = ' > '.$activeFilterValue; break; case self::OP_LESS_THAN: - $condition = ' < '.$activeFilterValue; + 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.'%\''; From 47cd9d41375e56bcccd24013734f426886c3498d Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 11 Dec 2017 15:44:03 +0100 Subject: [PATCH 29/45] By default the FilterWidget shows all the columns --- application/widgets/FilterWidget.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 56b83304b..a67004d4d 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -107,6 +107,18 @@ class FilterWidget extends Widget // $this->listFields = $this->FiltersModel->getExecutedQueryListFields(); + $filterSessionArray = $this->session->userdata(self::SESSION_NAME); + if (isset($filterSessionArray[self::SELECTED_FIELDS])) + { + $selectedFields = $filterSessionArray[self::SELECTED_FIELDS]; + } + + if (count($selectedFields) == 0) + { + $filterSessionArray[self::SELECTED_FIELDS] = $this->listFields; + $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); + } + // $this->metaData = $this->FiltersModel->getExecutedQueryMetaData(); From e94076b45120affd301cca72aea582c08eaf43ca Mon Sep 17 00:00:00 2001 From: oesi Date: Mon, 11 Dec 2017 16:54:25 +0100 Subject: [PATCH 30/45] UTF8 Control Characters werden bei der XML Generierung ersetzt da diese sonst Probleme machen --- include/dokument_export.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/dokument_export.class.php b/include/dokument_export.class.php index 624866ad0..e6628ceaa 100644 --- a/include/dokument_export.class.php +++ b/include/dokument_export.class.php @@ -411,7 +411,11 @@ class dokument_export } } else + { + // Remove UTF8 Control Characters (breaking XML) + $value = preg_replace('/[\x00-\x1F\x7F]/u', '', $value); $_xml_data->addChild("$key",htmlspecialchars("$value")); + } } return $_xml_data->asXML(); } From 9bb368302fd9ac7074cf671d3ecfaa5f33f341f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 11 Dec 2017 17:34:39 +0100 Subject: [PATCH 31/45] Fehler behoben beim Anlegen von StudienplanLehrveranstaltungszuordnungen wodurch booleans nicht korrekt gespeichert wurden --- include/studienplan.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/studienplan.class.php b/include/studienplan.class.php index d7833837a..1988edddd 100644 --- a/include/studienplan.class.php +++ b/include/studienplan.class.php @@ -538,9 +538,9 @@ class studienplan extends basis_db $this->db_add_param($this->studienplan_lehrveranstaltung_id_parent, FHC_INTEGER) . ', ' . $this->db_add_param($this->pflicht, FHC_BOOLEAN) . ', ' . $this->db_add_param($this->koordinator) . ', ' . - $this->db_add_param($this->curriculum) . ', ' . - $this->db_add_param($this->export) . ', ' . - $this->db_add_param($this->genehmigung) . ', ' . + $this->db_add_param($this->curriculum, FHC_BOOLEAN) . ', ' . + $this->db_add_param($this->export, FHC_BOOLEAN) . ', ' . + $this->db_add_param($this->genehmigung, FHC_BOOLEAN) . ', ' . 'now(), ' . $this->db_add_param($this->insertvon) . ');'; } From dbf643cb8d2de40b8742da141dc7c9ec355716ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 11 Dec 2017 17:43:25 +0100 Subject: [PATCH 32/45] Fixed export Bug with PHP5.4 --- include/dokument_export.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/dokument_export.class.php b/include/dokument_export.class.php index e6628ceaa..3b5b76b21 100644 --- a/include/dokument_export.class.php +++ b/include/dokument_export.class.php @@ -48,7 +48,13 @@ class dokument_export exec('unoconv --version',$ret_arr); if(isset($ret_arr[0])) - $this->unoconv_version = explode(' ',$ret_arr[0])[1]; + { + $hlp = explode(' ',$ret_arr[0]); + if(isset($hlp[1])) + $this->unoconv_version = $hlp[1]; + else + die('Could not get Unoconv Version'); + } else die('Unoconv not found'); From 0bb1d62c468409cc59166c13a5d94c0c8b0defd4 Mon Sep 17 00:00:00 2001 From: oesi Date: Wed, 13 Dec 2017 09:27:31 +0100 Subject: [PATCH 33/45] Fehlermeldung behoben beim Erstellen der Fotoliste als Nicht-Admin --- cis/private/lehre/fotoliste.pdf.php | 98 +++++++++++++++-------------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/cis/private/lehre/fotoliste.pdf.php b/cis/private/lehre/fotoliste.pdf.php index 475df926e..3390b27d1 100644 --- a/cis/private/lehre/fotoliste.pdf.php +++ b/cis/private/lehre/fotoliste.pdf.php @@ -17,12 +17,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Cristina Hainberger - * + * * Description: This file creates a studentlist with students' profile fotos * by a given studiengangs- and lehrveranstaltungs ID (and eventually a given lehreinheit ID). * If fotos are locked by student, a dummy picture is inserted instead of the students foto. * EXCEPTION: if user has admins or assitents rights, ALL students' fotos are iserted (even locked ones) - * + * */ require_once('../../../config/cis.config.inc.php'); @@ -60,7 +60,7 @@ $lv->load($lvid); $berechtigung = new benutzerberechtigung(); $berechtigung->getBerechtigungen($user); - + if (!$berechtigung->isBerechtigt('admin') && !$berechtigung->isBerechtigt('assistenz') && !$berechtigung->isBerechtigt('lehre', $lv->oe_kurzbz, 's') && !check_lektor_lehrveranstaltung($user, $lvid, $studiensemester)) die('Sie muessen LektorIn der LV sein oder das Recht "ADMIN", "ASSISTENZ" oder "LEHRE" haben, um diese Seite aufrufen zu koennen'); @@ -85,11 +85,11 @@ $qry = "SELECT DISTINCT ON gruppe, gruppe_kurzbz, stg_typ - FROM + FROM campus.vw_lehreinheit - WHERE + WHERE lehrveranstaltung_id=" . $db->db_add_param($lvid, FHC_INTEGER) . " - AND + AND studiensemester_kurzbz=" . $db->db_add_param($studiensemester); if ($lehreinheit != '') $qry .= " AND lehreinheit_id=" . $db->db_add_param($lehreinheit, FHC_INTEGER); @@ -111,8 +111,8 @@ if ($result = $db->db_query($qry)) { if ($row->gruppe_kurzbz == '') $gruppen_string = trim($row->kuerzel . '-' . $row->semester); else - $gruppen_string = $row->gruppe_kurzbz; - + $gruppen_string = $row->gruppe_kurzbz; + $gruppen_string_arr[] = $gruppen_string; } } @@ -122,10 +122,10 @@ $studiengruppe = implode(", ", array_unique($gruppen_string_arr)); //get studiengangstyp-bezeichnung $qry = "SELECT - bezeichnung - FROM - public.tbl_studiengangstyp - WHERE + bezeichnung + FROM + public.tbl_studiengangstyp + WHERE typ =" . $db->db_add_param($stg_typ); if ($result = $db->db_query($qry)) { @@ -148,43 +148,43 @@ $data = array( //**************************** students data ******************************* //load students-data $qry = 'SELECT DISTINCT ON - (nachname, vorname, person_id) - vorname, - nachname, + (nachname, vorname, person_id) + vorname, + nachname, matrikelnr, - tbl_studentlehrverband.semester, - tbl_studentlehrverband.verband, + tbl_studentlehrverband.semester, + tbl_studentlehrverband.verband, tbl_studentlehrverband.gruppe, - (SELECT - status_kurzbz - FROM - public.tbl_prestudentstatus - WHERE - prestudent_id=tbl_student.prestudent_id - ORDER BY + (SELECT + status_kurzbz + FROM + public.tbl_prestudentstatus + WHERE + prestudent_id=tbl_student.prestudent_id + ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1) as status, tbl_studiengang.kurzbz, tbl_studiengang.typ, - tbl_bisio.bisio_id, - tbl_bisio.von, - tbl_bisio.bis, + tbl_bisio.bisio_id, + tbl_bisio.von, + tbl_bisio.bis, tbl_student.studiengang_kz AS stg_kz_student, - tbl_zeugnisnote.note, - tbl_mitarbeiter.mitarbeiter_uid, - tbl_person.matr_nr, - tbl_person.geschlecht, - tbl_person.foto, + tbl_zeugnisnote.note, + tbl_mitarbeiter.mitarbeiter_uid, + tbl_person.matr_nr, + tbl_person.geschlecht, + tbl_person.foto, tbl_person.foto_sperre FROM - campus.vw_student_lehrveranstaltung + campus.vw_student_lehrveranstaltung JOIN public.tbl_benutzer USING(uid) - JOIN public.tbl_person USING(person_id) + JOIN public.tbl_person USING(person_id) LEFT JOIN public.tbl_student ON(uid=student_uid) LEFT JOIN public.tbl_studiengang ON(tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz) LEFT JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) LEFT JOIN public.tbl_studentlehrverband USING(student_uid,studiensemester_kurzbz) - LEFT JOIN lehre.tbl_zeugnisnote ON(vw_student_lehrveranstaltung.lehrveranstaltung_id=tbl_zeugnisnote.lehrveranstaltung_id - AND tbl_zeugnisnote.student_uid=tbl_student.student_uid + LEFT JOIN lehre.tbl_zeugnisnote ON(vw_student_lehrveranstaltung.lehrveranstaltung_id=tbl_zeugnisnote.lehrveranstaltung_id + AND tbl_zeugnisnote.student_uid=tbl_student.student_uid AND tbl_zeugnisnote.studiensemester_kurzbz=tbl_studentlehrverband.studiensemester_kurzbz) LEFT JOIN bis.tbl_bisio ON(uid=tbl_bisio.student_uid) WHERE @@ -214,7 +214,7 @@ if ($result = $db->db_query($qry)) { while ($row = $db->db_fetch_object($result)) { if ($row->status != 'Abbrecher' && $row->status != 'Unterbrecher') { $anzahl_studierende++; - + if ($row->status == 'Incoming') //Incoming $zusatz = '(i)'; else @@ -231,9 +231,9 @@ if ($result = $db->db_query($qry)) { if ($row->stg_kz_student == $a_o_kz) //Außerordentliche Studierende $zusatz .= '(a.o.)'; - + //allow admin and assistenz to see ALL fotos (even if locked by user) - if ($show_all_fotos) + if ($show_all_fotos) $row->foto_sperre = 'f'; //create foto (if not locked by student OR if fotolist is created by admin or assistenz) @@ -241,7 +241,7 @@ if ($result = $db->db_query($qry)) { $foto_src = $row->foto; $foto_url = sys_get_temp_dir() . '/foto' . trim($row->matrikelnr) . '.jpg'; $foto_url_arr[] = $foto_url; - + //create writeable file if (!$foto = fopen($foto_url, 'w')) die("Das Bild konnte nicht erstellt werden"); @@ -250,15 +250,19 @@ if ($result = $db->db_query($qry)) { { die("Das Bild konnte nicht erstellt werden"); } - + //add foto to document $doc->addImage($foto_url, trim($row->matrikelnr) . '.jpg', 'image/jpg'); } elseif ($row->foto == '') - { + { $foto_url = ''; - } - + } + else + { + $foto_url = ''; + } + //create studiengruppe $student_studiengruppe = strtoupper($row->typ.$row->kurzbz.'-'.$row->semester); @@ -268,7 +272,7 @@ if ($result = $db->db_query($qry)) { 'nachname' => mb_strtoupper($row->nachname, 'UTF-8'), 'personenkennzeichen' => trim($row->matrikelnr), 'geschlecht' => $row->geschlecht, - 'foto_gesperrt' => $row->foto_sperre, // f/t + 'foto_gesperrt' => $row->foto_sperre, // f/t 'foto_url' => $foto_url, 'studiengruppe' => $student_studiengruppe, 'verband' => trim($row->verband), @@ -289,7 +293,7 @@ $doc->addDataArray($data, 'fotoliste'); //set doc name $doc->setFilename('Fotoliste_'.$stg_bezeichnung.'_'.$studiensemester.'_'.$lv_bezeichnung); -//create doc in format required +//create doc in format required if (!$doc->create($output)) die($doc->errormsg); @@ -301,4 +305,4 @@ $doc->close(); //unlink fotos from tmp-folder foreach ($foto_url_arr as $foto_url) - unlink($foto_url); \ No newline at end of file + unlink($foto_url); From aeae34f4e097f9e5a6f470035e705cfe8ec16c5a Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 13 Dec 2017 13:51:38 +0100 Subject: [PATCH 34/45] - Added parameter hideSave to hide save button and fields - Correctly saves personal filters --- .../controllers/system/TestFilterWidget.php | 1 + application/views/widgets/filter/filter.php | 11 ++ .../views/widgets/filter/saveFilter.php | 7 + application/widgets/FilterWidget.php | 123 +++++++++++++++++- 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 application/views/widgets/filter/saveFilter.php diff --git a/application/controllers/system/TestFilterWidget.php b/application/controllers/system/TestFilterWidget.php index 45c5d36bf..9cdd54095 100644 --- a/application/controllers/system/TestFilterWidget.php +++ b/application/controllers/system/TestFilterWidget.php @@ -36,6 +36,7 @@ class TestFilterWidget extends VileSci_Controller AND p.person_id < 1000 ', 'hideHeader' => false, + 'hideSave' => false, 'checkboxes' => array('PersonId'), 'additionalColumns' => array('Delete', 'Edit'), 'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) { diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php index 271b5a224..1219e84f3 100644 --- a/application/views/widgets/filter/filter.php +++ b/application/views/widgets/filter/filter.php @@ -40,6 +40,11 @@ } }); + $("#saveCustomFilterButton").click(function() { + $("#saveCustomFilter").val(true); + $("#filterForm").submit(); + }); + }); @@ -56,6 +61,12 @@
+
+ +
+ +
+
diff --git a/application/views/widgets/filter/saveFilter.php b/application/views/widgets/filter/saveFilter.php new file mode 100644 index 000000000..e9e0217e6 --- /dev/null +++ b/application/views/widgets/filter/saveFilter.php @@ -0,0 +1,7 @@ +
+ Filter short description: +
+
+ + +
diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index a67004d4d..3d297bf4f 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -15,6 +15,7 @@ class FilterWidget extends Widget const FORMAT_RAW = 'formatRaw'; const CHECKBOXES = 'checkboxes'; const HIDE_HEADER = 'hideHeader'; + const HIDE_SAVE = 'hideSave'; const DATASET_PARAMETER = 'dataset'; const METADATA_PARAMETER = 'metaData'; @@ -24,6 +25,7 @@ class FilterWidget extends Widget 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 WIDGET_URL_SAVE_FILTER = 'widgets/filter/saveFilter'; const SESSION_NAME = 'FILTER'; @@ -83,6 +85,7 @@ class FilterWidget extends Widget // $this->load->model('system/Filters_model', 'FiltersModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); self::$FilterWidgetInstance = $this; } @@ -98,6 +101,9 @@ class FilterWidget extends Widget // $this->_setSessionFilterData(); + // + $this->_saveFilter(); + // $this->FiltersModel->resetQuery(); @@ -172,6 +178,17 @@ class FilterWidget extends Widget } } + /** + * + */ + public static function loadViewSaveFilter() + { + if (self::$FilterWidgetInstance->hideSave != true) + { + self::_loadView(self::WIDGET_URL_SAVE_FILTER); + } + } + /** * */ @@ -422,7 +439,7 @@ class FilterWidget extends Widget /** * */ - private static function _loadView($viewName, $parameters) + private static function _loadView($viewName, $parameters = null) { $ci =& get_instance(); $ci->load->view($viewName, $parameters); @@ -487,6 +504,7 @@ class FilterWidget extends Widget $this->formatRaw = null; $this->checkboxes = null; $this->hideHeader = false; + $this->hideSave = false; if (!is_array($args) || (is_array($args) && count($args) == 0)) { @@ -558,6 +576,11 @@ class FilterWidget extends Widget { $this->hideHeader = $args[self::HIDE_HEADER]; } + + if (isset($args[self::HIDE_SAVE]) && is_bool($args[self::HIDE_SAVE])) + { + $this->hideSave = $args[self::HIDE_SAVE]; + } } } @@ -668,6 +691,104 @@ class FilterWidget extends Widget } } + /** + * + */ + private function _saveFilter() + { + if (isset($_POST['saveCustomFilter']) && $_POST['saveCustomFilter'] == 'true') + { + $objToBeSaved = new stdClass(); + + $filterSessionArray = $this->session->userdata(self::SESSION_NAME); + + if (isset($filterSessionArray[self::SELECTED_FIELDS])) + { + $selectedFields = $filterSessionArray[self::SELECTED_FIELDS]; + $objToBeSaved->columns = array(); + + for ($selectedFieldsCounter = 0; $selectedFieldsCounter < count($selectedFields); $selectedFieldsCounter++) + { + $objToBeSaved->columns[$selectedFieldsCounter] = new stdClass(); + $objToBeSaved->columns[$selectedFieldsCounter]->name = $selectedFields[$selectedFieldsCounter]; + } + } + + if (isset($filterSessionArray[self::SELECTED_FILTERS])) + { + $selectedFilters = $filterSessionArray[self::SELECTED_FILTERS]; + $objToBeSaved->filters = array(); + + for ($selectedFiltersCounter = 0; $selectedFiltersCounter < count($selectedFilters); $selectedFiltersCounter++) + { + $objToBeSaved->filters[$selectedFiltersCounter] = new stdClass(); + $objToBeSaved->filters[$selectedFiltersCounter]->name = $selectedFilters[$selectedFiltersCounter]; + + if (isset($filterSessionArray[self::ACTIVE_FILTERS]) + && isset($filterSessionArray[self::ACTIVE_FILTERS][$selectedFilters[$selectedFiltersCounter]])) + { + $objToBeSaved->filters[$selectedFiltersCounter]->condition = $filterSessionArray[self::ACTIVE_FILTERS][$selectedFilters[$selectedFiltersCounter]]; + } + + if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPERATION]) + && isset($filterSessionArray[self::ACTIVE_FILTERS_OPERATION][$selectedFilters[$selectedFiltersCounter]])) + { + $objToBeSaved->filters[$selectedFiltersCounter]->operation = $filterSessionArray[self::ACTIVE_FILTERS_OPERATION][$selectedFilters[$selectedFiltersCounter]]; + } + + if (isset($filterSessionArray[self::ACTIVE_FILTERS_OPTION]) + && isset($filterSessionArray[self::ACTIVE_FILTERS_OPTION][$selectedFilters[$selectedFiltersCounter]])) + { + $objToBeSaved->filters[$selectedFiltersCounter]->option = $filterSessionArray[self::ACTIVE_FILTERS_OPTION][$selectedFilters[$selectedFiltersCounter]]; + } + } + } + + $result = $this->FiltersModel->loadWhere(array( + 'app' => $this->app, + 'dataset_name' => $this->datasetName, + 'filter_kurzbz' => $_POST['customFilterKurzbz'] + )); + + if (hasData($result)) + { + $this->FiltersModel->update( + array( + 'app' => $this->app, + 'dataset_name' => $this->datasetName, + 'filter_kurzbz' => $_POST['customFilterKurzbz'] + ), + array( + 'description' => '{}', + 'sort' => null, + 'default_filter' => false, + 'filter' => json_encode($objToBeSaved), + 'oe_kurzbz' => null + ) + ); + } + else + { + $result = $this->BenutzerModel->load(getAuthUID()); + + if (hasData($result)) + { + $this->FiltersModel->insert(array( + 'app' => $this->app, + 'dataset_name' => $this->datasetName, + 'filter_kurzbz' => $_POST['customFilterKurzbz'], + 'person_id' => $result->retval[0]->person_id, + 'description' => '{}', + 'sort' => null, + 'default_filter' => false, + 'filter' => json_encode($objToBeSaved), + 'oe_kurzbz' => null + )); + } + } + } + } + /** * */ From 588561b7162cefd71d44676367d774b7ce5dd4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 13 Dec 2017 17:53:22 +0100 Subject: [PATCH 35/45] Problem behoben wodurch bei langlaufenden Cronjobs diese mehrmals gestartet wurden --- include/cronjob.class.php | 5 +++++ vilesci/cronjobs/cronjob.php | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/cronjob.class.php b/include/cronjob.class.php index 7848e07dd..e892e55a0 100644 --- a/include/cronjob.class.php +++ b/include/cronjob.class.php @@ -364,6 +364,11 @@ class cronjob extends basis_db public function execute() { $return = true; + if($this->running) + { + $this->errormsg = 'Job kann nicht ausgefuehrt werden, da er bereits laeuft'; + return false; + } if($this->standalone && $this->isJobRunning()) { $this->errormsg = 'Job kann nicht ausgefuehrt werden, da noch ein anderer Job laeuft'; diff --git a/vilesci/cronjobs/cronjob.php b/vilesci/cronjobs/cronjob.php index ccfeda4ce..a952bc965 100644 --- a/vilesci/cronjobs/cronjob.php +++ b/vilesci/cronjobs/cronjob.php @@ -40,15 +40,19 @@ foreach ($cj->result as $cronjob) $timestamp = $cronjob->getNextExecutionTime(); if($timestamp && time()>=$timestamp) { - //Starten des Jobs - if($cronjob->execute()) + if(!$cronjob->running) { - echo "\n".date('d.m.Y H:i:s').' '.$cronjob->titel.'('.$cronjob->cronjob_id.') executed
'."\n"; - echo implode($cronjob->output,"\n"); - } - else - { - echo "\n".date('d.m.Y H:i:s').' '.$cronjob->titel.'('.$cronjob->cronjob_id.') failed
'."\n"; + echo "\n".date('d.m.Y H:i:s').' '.$cronjob->titel.'('.$cronjob->cronjob_id.') execute...
'."\n"; + //Starten des Jobs + if($cronjob->execute()) + { + echo "\n".date('d.m.Y H:i:s').' '.$cronjob->titel.'('.$cronjob->cronjob_id.') executed
'."\n"; + echo implode($cronjob->output,"\n"); + } + else + { + echo "\n".date('d.m.Y H:i:s').' '.$cronjob->titel.'('.$cronjob->cronjob_id.') failed:'.$cronjob->errormsg.'
'."\n"; + } } } } From 482a90b305fe3bef3aa9ac27fb6a64ff596e1067 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 14 Dec 2017 16:32:05 +0100 Subject: [PATCH 36/45] modified colors (now violet comes before dark red), fixed bug with non-continuous lines in excel versions --- content/statistik/notenspiegel_erweitert.php | 50 ++++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/content/statistik/notenspiegel_erweitert.php b/content/statistik/notenspiegel_erweitert.php index 700148b74..5975a89ea 100644 --- a/content/statistik/notenspiegel_erweitert.php +++ b/content/statistik/notenspiegel_erweitert.php @@ -184,8 +184,8 @@ usort($nulltermine, function ($termina, $terminb) $termine = array_merge($termineWithSort, $nulltermine); //Farben für Prüfungsantritte (1. Termin, 2., kommissionelle...) -$colors = array('ffff00', 'fa9200', 'ff1500', '800000', '9400D3', '1500ff', '305041', '00fff2', '00ff2b'); -$colorsForPositiv = array('ffffff', 'ffdfb3', 'ffb9b3', 'ff9494', 'ddb3ff', '7366ff', '80b39b', 'b3fffb', 'b3ffbf'); +$colors = array('ffff00', 'fa9200', 'ff1500', '9400D3', '0000FF', '800000', '305041', '00fff2', '00ff2b'); +$colorsForPositiv = array('ffffff', 'ffdfb3', 'ffb9b3', 'ddb3ff', '7366ff', 'ff9494', '80b39b', 'b3fffb', 'b3ffbf'); $counter = 0; foreach ($termine as $termin) @@ -230,6 +230,7 @@ if ($typ == 'xls') $format_rotate =& $workbook->addFormat(); $format_rotate->setTextRotation(270); $format_rotate->setAlign('center'); + $format_rotate->setBorder(1); $format_bold_center =& $workbook->addFormat(); $format_bold_center->setBold(); @@ -306,7 +307,7 @@ if ($typ == 'xls') $worksheet->write($zeile, ++$spalte, 'Vorname', $format_bold); $maxlength[$spalte] = 10; $worksheet->write($zeile, ++$spalte, 'Personenkennzeichen', $format_bold); - $maxlength[$spalte] = 30; + $maxlength[$spalte] = 32; $maxheaderheight = 20; while ($row_lva = $db->db_fetch_object($result_lva)) @@ -419,12 +420,12 @@ if ($typ == 'xls') } } //keine Nachprüfung aber negativ - 1. Antritt Farbe wenn es eine Notenanmerkung gibt - else if (!$noten_positiv[$note] && $noten_arr[$note] != '' && isset($noten_arr[$note])) + elseif (!$noten_positiv[$note] && $noten_arr[$note] != '' && isset($noten_arr[$note])) { reset($pruefungsart_farben); $format = $format_colored[key($pruefungsart_farben)]; } - else if (isset($format_colored[$note])) + elseif (isset($format_colored[$note])) $format = $format_colored[$note]; $worksheet->write($zeile, ++$spalte, $noten_arr[$note], $format); @@ -523,13 +524,18 @@ if ($typ == 'xls') foreach ($termine as $termin) $bezeichnungen[$termin->pruefungstyp_kurzbz] = $termin->beschreibung; - $worksheet->setMerge($legendzeile, $startcolumn, $legendzeile, $startcolumn + 4); + $totalmergefarb = 4; + $worksheet->write($legendzeile, $startcolumn, "Farblegende Prüfungsantritte", $format_bold_center); - $worksheet->write($legendzeile, $startcolumn + 4, "", $format_bold_center); + $worksheet->setMerge($legendzeile, $startcolumn, $legendzeile, $startcolumn + $totalmergefarb); + //In manchen Excelversionen wird border nicht dargestellt -> alle verbundenen zellen nachformatieren + for($i = 1; $i <= $totalmergefarb; $i++) + $worksheet->write($legendzeile, $startcolumn + $i, "", $format_bold_center); $legendzeile++; $worksheet->write($legendzeile, $startcolumn, "Termin", $format_bold_center); $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 2); $worksheet->write($legendzeile, $startcolumn + 1, "positiv", $format_bold_center); + $worksheet->write($legendzeile, $startcolumn + 2, "", $format_bold_center); $worksheet->setMerge($legendzeile, $startcolumn + 3, $legendzeile, $startcolumn + 4); $worksheet->write($legendzeile, $startcolumn + 3, "negativ", $format_bold_center); $worksheet->write($legendzeile, $startcolumn + 4, "", $format_bold_center); @@ -541,6 +547,7 @@ if ($typ == 'xls') $worksheet->write($legendzeile, $startcolumn, $bezeichnung, $format_bold); $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 2); $worksheet->write($legendzeile, $startcolumn + 1, "", $format_colored[$name.'Pos']); + $worksheet->write($legendzeile, $startcolumn + 2, "", $format_colored[$name.'Pos']); $worksheet->setMerge($legendzeile, $startcolumn + 3, $legendzeile, $startcolumn + 4); $worksheet->write($legendzeile, $startcolumn + 3, "", $format_colored[$name]); $worksheet->write($legendzeile, $startcolumn + 4, "", $format_colored[$name]); @@ -548,13 +555,13 @@ if ($typ == 'xls') } $worksheet->write($legendzeile, $startcolumn, "nicht eingetragen", $format_bold); $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 4); - $worksheet->write($legendzeile, $startcolumn + 1, "", $format_colored_nichteingetragen); - $worksheet->write($legendzeile, $startcolumn + 4, "", $format_colored_nichteingetragen); + for($i = 1; $i <= $totalmergefarb; $i++) + $worksheet->write($legendzeile, $startcolumn + $i, "", $format_colored_nichteingetragen); $legendzeile++; $worksheet->write($legendzeile, $startcolumn, "nicht zugeteilt", $format_bold); $worksheet->setMerge($legendzeile, $startcolumn + 1, $legendzeile, $startcolumn + 4); - $worksheet->write($legendzeile, $startcolumn + 1, "", $format_colored_nichtzugeteilt); - $worksheet->write($legendzeile, $startcolumn + 4, "", $format_colored_nichtzugeteilt); + for($i = 1; $i <= $totalmergefarb; $i++) + $worksheet->write($legendzeile, $startcolumn + $i, "", $format_colored_nichtzugeteilt); $startcolumn = $currentcolumn = 9; @@ -574,7 +581,7 @@ if ($typ == 'xls') { $groesse++; } - else if ($currentcolumn < 3 + $anzahl_lvspalten + 2) + elseif ($currentcolumn < 3 + $anzahl_lvspalten + 2) { $groesse += 4; } @@ -589,6 +596,7 @@ if ($typ == 'xls') $index++; } + // all merges for 4 columns of Notenlegende $allmerges = array($beschrColumnMerges[0], 1, $beschrColumnMerges[1], 1); $headingmerge = array_sum($allmerges) - 1; $positivmerge = $allmerges[0] + $allmerges[1] - 1; @@ -596,12 +604,18 @@ if ($typ == 'xls') $worksheet->setMerge($zeile, $startcolumn, $zeile, $startcolumn + $headingmerge); $worksheet->write($zeile, $startcolumn, "Notenlegende", $format_bold_center); + for($i = 1; $i < $headingmerge; $i++) + $worksheet->write($zeile, $startcolumn + $i, "", $format_bold_center); $worksheet->write($zeile++, $startcolumn + $headingmerge, "", $format_bold_center); $worksheet->setMerge($zeile, $startcolumn, $zeile, $startcolumn + $positivmerge); $worksheet->write($zeile, $startcolumn, "positiv", $format_bold_center); + for($i = 1; $i <= $positivmerge; $i++) + $worksheet->write($zeile, $startcolumn + $i, "", $format_bold_center); $worksheet->setMerge($zeile, $startcolumn + $positivmerge + 1, $zeile, $startcolumn + $headingmerge); - $worksheet->write($zeile, $startcolumn + $headingmerge, "", $format_bold_center); - $worksheet->write($zeile++, $startcolumn + $positivmerge + 1, "negativ", $format_bold_center); + $worksheet->write($zeile, $startcolumn + $positivmerge + 1, "negativ", $format_bold_center); + for($i = 1; $i <= $negativmerge; $i++) + $worksheet->write($zeile, $startcolumn + $positivmerge + $i + 1, "", $format_bold_center); + $worksheet->write($zeile++, $startcolumn + $headingmerge, "", $format_bold_center); $tempzeile = $zeile; foreach ($noten_arr as $note => $anmerkung) { @@ -611,12 +625,16 @@ if ($typ == 'xls') { $worksheet->setMerge($zeile, $startcolumn, $zeile, $startcolumn + $positivmerge - 1); $worksheet->write($zeile, $startcolumn, $noten_bezeichnungen[$note], $format_bold); + for($i = 1; $i <= $positivmerge; $i++) + $worksheet->write($zeile, $startcolumn + $i, "", $format_bold_center); $worksheet->write($zeile++, $startcolumn + $positivmerge, $anmerkung, $format_bold_center); } else { $worksheet->setMerge($tempzeile, $startcolumn + $positivmerge + 1, $tempzeile, $startcolumn + $headingmerge - 1); $worksheet->write($tempzeile, $startcolumn + $positivmerge + 1, $noten_bezeichnungen[$note], $format_bold); + for($i = 1; $i <= $negativmerge; $i++) + $worksheet->write($tempzeile, $startcolumn + $positivmerge + $i + 1, "", $format_bold_center); $worksheet->write($tempzeile++, $startcolumn + $headingmerge, $anmerkung, $format_bold_center); } } @@ -629,6 +647,10 @@ if ($typ == 'xls') //Zellen der 1. Zeile verbinden $worksheet->setMerge(0, 0, 0, $spalte); + //Alle verbundenen Zellen formatieren - in best. Excelversionen border sonst falsch + for($i = 1; $i <= $spalte; $i++) + $worksheet->write(0, $i, "", $format_bold_center); + //Hoehe der 2. Zeile anpassen damit die LVs alle sichtbar sind $worksheet->setRow(1, $maxheaderheight * 5); From 73fcebeb70755479ea669ec468b32e3c24130d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 14 Dec 2017 19:03:54 +0100 Subject: [PATCH 37/45] =?UTF-8?q?Oeffnen=20der=20Mailverteiler=20pr=C3=BCf?= =?UTF-8?q?t=20jetzt=20auch=20den=20Returnwert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/private/open_grp.php | 136 ++++++++++++++++++--------------- locale/de-AT/mailverteiler.php | 3 +- locale/en-US/mailverteiler.php | 1 + 3 files changed, 76 insertions(+), 64 deletions(-) diff --git a/cis/private/open_grp.php b/cis/private/open_grp.php index db526c396..2973ac7cd 100644 --- a/cis/private/open_grp.php +++ b/cis/private/open_grp.php @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Christian Paminger , - * Andreas Oesterreicher and - * Karl Burkhart . + * Andreas Oesterreicher and + * Karl Burkhart . */ require_once('../../config/cis.config.inc.php'); require_once('../../include/functions.inc.php'); @@ -29,20 +29,20 @@ $sprache = getSprache(); $p = new phrasen($sprache); $uid = get_uid(); $db = new basis_db(); -if(!isset($_REQUEST['grp'])) +if (!isset($_REQUEST['grp'])) die('Falsche Parameter'); - -if(mb_strlen($_REQUEST['grp'])>32) + +if (mb_strlen($_REQUEST['grp'])>32) die('Grp ungueltig'); - + //Pruefen ob es eine gueltige Gruppe ist $gruppe = new gruppe(); -if(!$gruppe->exists($_REQUEST['grp'])) +if (!$gruppe->exists($_REQUEST['grp'])) { //Wenn es keine Gruppe in der DB ist, kann es //noch ein Studierendenverteiler sein //bif_std - if(!preg_match('/^\D\D\D_std$/', $_REQUEST['grp'])) + if (!preg_match('/^\D\D\D_std$/', $_REQUEST['grp'])) { die('Ungueltige Gruppe'); } @@ -52,38 +52,35 @@ function mail_id_generator() mt_srand((double)microtime()*1000000); /* Laenge des Passwortes dem Zufall ueberlassen */ - $length = 6; //mt_rand(6, 6); + $length = 6; $fix_similar = ''; $valid_charset = ""; - /* Stelle ein Charset zusammen */ - if (!$valid_charset) - { - // deactivated, regarding an case sensitive issue - //$valid_charset .= 'ABCDEFGHIJKLMNOPQRSTUVXYZ'; - $valid_charset .= 'abcdefghijklmnopqrstuvxyz'; - $valid_charset .= '0123456789'; - //$valid_charset .= '!@_-'; - } - - $charset_length = mb_strlen($valid_charset); - - if ($charset_length == 0) return false; - - /* Initialisieren - Auswahl von chars bis definierte Anzahl erreicht */ - $mail_id = ""; - while(strlen($mail_id) < $length) - { - /* Waehle einen zufaelligen char aus */ - $char = $valid_charset[mt_rand(0, ($charset_length-1))]; - - /* Abgleich von gleich aussehenden chars */ - if (($fix_similar && !strpos('O01lI5S', $char)) || !$fix_similar) $mail_id .= $char; + /* Stelle ein Charset zusammen */ + if (!$valid_charset) + { + $valid_charset .= 'abcdefghijklmnopqrstuvxyz'; + $valid_charset .= '0123456789'; } - return $mail_id; + + $charset_length = mb_strlen($valid_charset); + + if ($charset_length == 0) return false; + + /* Initialisieren - Auswahl von chars bis definierte Anzahl erreicht */ + $mail_id = ''; + while (strlen($mail_id) < $length) + { + /* Waehle einen zufaelligen char aus */ + $char = $valid_charset[mt_rand(0, ($charset_length-1))]; + + /* Abgleich von gleich aussehenden chars */ + if (($fix_similar && !strpos('O01lI5S', $char)) || !$fix_similar) $mail_id .= $char; + } + return $mail_id; } -echo ' +echo ' @@ -92,48 +89,61 @@ echo ' '; -if(isset($_REQUEST['token']) && isset($_REQUEST['grp'])) +if (isset($_REQUEST['token']) && isset($_REQUEST['grp'])) { echo '
- ".$p->t("zeitaufzeichnung/neu")." | + ".$p->t("zeitaufzeichnung/neu")." | - CSV Import | + CSV Import | - CSV Export"; + CSV Export"; if($anzprojekte > 0) - echo " | Projektexport"; + echo " | Projektexport"; echo "
Select
+ + {$selectedFilter})) - { - echo $result->{$selectedFilter} === true ? 'true' : 'false'; - } - else - { - echo $result->{$selectedFilter}; - } + echo $formattedResult->{$selectedField}; ?> + {$additionalColumn}; + ?> +
- - - - '; - + + + + '; + /* Generate an random String */ - $mail_id=mail_id_generator(); + $mail_id = mail_id_generator(); /* Command to unlock Mailgroup */ $command = "ssh -i /etc/apache2/id_mail_provisioning mailadmins@bifrost2 ".$_REQUEST['grp'] . " " . $mail_id; - exec($command); - /* ffe, 20051020 - do a little logging */ - $message= date("F j G:i:s") . " mailgroup: [" . $_REQUEST['grp'] . "] (using " . $mail_id . ") requested by [" . $uid . "]\n"; + $output = array(); + exec($command, $output, $retval); - $filet = fopen(LOG_PATH.'.htmlistopen.log', "a"); - fwrite($filet, $message, mb_strlen($message)); - fclose($filet); + if ($retval === 0) + { + // Add Log Message + $message= date("F j G:i:s") . " mailgroup: [" . $_REQUEST['grp'] . "] (using " . $mail_id . ") requested by [" . $uid . "]\n"; - // for the users - echo " - - - - - - - -
'.$p->t('mailverteiler/mailverteiler').''.$p->t('mailverteiler/status').'
'.$p->t('mailverteiler/mailverteiler').''.$p->t('mailverteiler/status').'
".$db->convert_html_chars($_REQUEST['desc'])."".$p->t('mailverteiler/geoeffnet')." (Code: ".$mail_id.")
-

".$p->t('mailverteiler/klickenZumSchicken')."

+ $filet = fopen(LOG_PATH.'.htmlistopen.log', "a"); + fwrite($filet, $message, mb_strlen($message)); + fclose($filet); -

".$p->t('mailverteiler/infoBenutzung',array($_REQUEST['grp'].$mail_id."@".DOMAIN))."

-
- "; + echo " +
".$db->convert_html_chars($_REQUEST['desc'])."".$p->t('mailverteiler/geoeffnet')." (Code: ".$mail_id.")
+

".$p->t('mailverteiler/klickenZumSchicken')."

+ +

".$p->t('mailverteiler/infoBenutzung',array($_REQUEST['grp'].$mail_id."@".DOMAIN))."

+
+ '.$p->t('mailverteiler/oeffnenFehlgeschlagen').' +
'; } else { - if($_REQUEST['grp']=="") + if ($_REQUEST['grp'] == '') { exit(); } @@ -142,7 +152,7 @@ else echo $p->t('mailverteiler/bestaetigeOeffnen',array($_REQUEST['grp']))." : convert_html_chars($_REQUEST['desc'])."&token=1\">".$p->t('mailverteiler/bestaetige').""; } } - + echo ' '; ?> diff --git a/locale/de-AT/mailverteiler.php b/locale/de-AT/mailverteiler.php index e45e6cb85..73ebfc052 100644 --- a/locale/de-AT/mailverteiler.php +++ b/locale/de-AT/mailverteiler.php @@ -19,9 +19,10 @@ $this->phrasen['mailverteiler/mailverteiler']='Mailverteiler'; $this->phrasen['mailverteiler/oeffnenEinesVerteilers']='Öffnen eines Mailverteilers'; $this->phrasen['mailverteiler/status']='Status'; $this->phrasen['mailverteiler/geoeffnet']='Geöffnet'; -$this->phrasen['mailverteiler/klickenZumSchicken']='Um ein Mail an den Verteiler zu senden klicken Sie bitte auf den obigen Link. Ihr Mailprogramm öffnet automatisch eine Vorlage für ein neues Mail, welche bereits die korrekte Adresse enthält.'; +$this->phrasen['mailverteiler/klickenZumSchicken']='Um ein Mail an den Verteiler zu senden klicken Sie bitte auf den angezeigten Link. Ihr Mailprogramm öffnet automatisch eine Vorlage für ein neues Mail, welche bereits die korrekte Adresse enthält.'; $this->phrasen['mailverteiler/infoBenutzung']='Das Senden ist für den Zeitraum von 2 Stunden bzw. für die einmalige Benutzung unter der Adresse %1$s möglich.'; $this->phrasen['mailverteiler/bestaetigeOeffnen']='Bitte bestätigen Sie das Öffnen des Verteilers %1$s'; $this->phrasen['mailverteiler/bestaetige']='Bestätige'; $this->phrasen['mailverteiler/personenImVerteiler']='Personen im Mailverteiler'; +$this->phrasen['mailverteiler/oeffnenFehlgeschlagen']='Beim Freischalten des Verteilers ist ein Fehler aufgetreten.
Bitte Informieren Sie den Administrator'; ?> diff --git a/locale/en-US/mailverteiler.php b/locale/en-US/mailverteiler.php index 7c625116a..502846583 100644 --- a/locale/en-US/mailverteiler.php +++ b/locale/en-US/mailverteiler.php @@ -24,4 +24,5 @@ $this->phrasen['mailverteiler/infoBenutzung']='You can use the Mailinglist durin $this->phrasen['mailverteiler/bestaetigeOeffnen']='Please confirm to unlock the Mailing list %1$s'; $this->phrasen['mailverteiler/bestaetige']='Confirm'; $this->phrasen['mailverteiler/personenImVerteiler']='People in this mailing list'; +$this->phrasen['mailverteiler/oeffnenFehlgeschlagen']='Failed to open mailing list. Please inform your administrator.'; ?> From fb1a55c47c1040c582304fb64f838a4bc5da802d Mon Sep 17 00:00:00 2001 From: oesi Date: Fri, 15 Dec 2017 10:47:26 +0100 Subject: [PATCH 38/45] Rundung der SWS angepasst --- vilesci/bis/personalmeldung.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vilesci/bis/personalmeldung.php b/vilesci/bis/personalmeldung.php index ae1a65741..5ca6e8b52 100644 --- a/vilesci/bis/personalmeldung.php +++ b/vilesci/bis/personalmeldung.php @@ -345,7 +345,7 @@ if($result = $db->db_query($qry)) $person_content.=" ".sprintf("%04s",$row_fkt['stgkz'])." - ".number_format($row_fkt['sws']).""; + ".number_format($row_fkt['sws'],2).""; if($row_fkt['hauptberuflich']=='t') { $person_content.=" From 024035e890f7a480e54c308f4af8cb627039583b Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 15 Dec 2017 17:06:11 +0100 Subject: [PATCH 39/45] - Added directory application/controllers/system/infocenter/ - Moved controller TestFilterWidget to system/infocenter/ - Renamed controller TestFilterWidget to InfoCenter - Added directory application/views/system/infocenter/ - Added views system/infocenter/infocenter.php and system/infocenter/infocenterFilters.php - Added new header views/templates/FHC-Footer - Added new header views/templates/FHC-Header - FHC-Header still using old JQuery and missing others includes --- .../controllers/system/TestFilterWidget.php | 62 ----------- .../system/infocenter/InfoCenter.php | 95 ++++++++++++++++ .../views/system/infocenter/infocenter.php | 35 ++++++ .../system/infocenter/infocenterFilters.php | 30 +++++ application/views/templates/FHC-Footer.php | 3 + application/views/templates/FHC-Header.php | 103 ++++++++++++++++++ 6 files changed, 266 insertions(+), 62 deletions(-) delete mode 100644 application/controllers/system/TestFilterWidget.php create mode 100644 application/controllers/system/infocenter/InfoCenter.php create mode 100644 application/views/system/infocenter/infocenter.php create mode 100644 application/views/system/infocenter/infocenterFilters.php create mode 100644 application/views/templates/FHC-Footer.php create mode 100644 application/views/templates/FHC-Header.php diff --git a/application/controllers/system/TestFilterWidget.php b/application/controllers/system/TestFilterWidget.php deleted file mode 100644 index 9cdd54095..000000000 --- a/application/controllers/system/TestFilterWidget.php +++ /dev/null @@ -1,62 +0,0 @@ -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 "UpdateDate" - 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 - ', - 'hideHeader' => false, - 'hideSave' => false, - 'checkboxes' => array('PersonId'), - 'additionalColumns' => array('Delete', 'Edit'), - 'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) { - - if ($fieldName == 'PersonId') - { - $datasetRaw->{$fieldName} = ''.$fieldValue.''; - } - elseif ($fieldName == 'Delete') - { - $datasetRaw->{$fieldName} = 'Delete'; - } - elseif ($fieldName == 'Edit') - { - $datasetRaw->{$fieldName} = 'Edit'; - } - - return $datasetRaw; - } - ) - ); - } -} diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php new file mode 100644 index 000000000..d75ab4d9e --- /dev/null +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -0,0 +1,95 @@ +load->library('WidgetLib'); + } + + /** + * + */ + public function index() + { + $listFiltersSent = array( + 'Sent 1' => 100, + 'Sent 2' => 200, + 'Sent 3' => 300 + ); + + $listFiltersNotSent = array( + 'Not Sent 1' => 400, + 'Not Sent 2' => 500, + 'Not Sent 3' => 600 + ); + + $this->load->view( + 'system/infocenter/infocenter.php', + array( + 'listFiltersSent' => $listFiltersSent, + 'listFiltersNotSent' => $listFiltersNotSent + ) + ); + } + + /** + * + */ + public function filter($filterId = null) + { + $filterWidgetArray = array( + '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 "UpdateDate" + 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 + ', + 'hideHeader' => false, + 'hideSave' => false, + 'checkboxes' => array('PersonId'), + 'additionalColumns' => array('Delete', 'Edit'), + 'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) { + + if ($fieldName == 'PersonId') + { + $datasetRaw->{$fieldName} = ''.$fieldValue.''; + } + elseif ($fieldName == 'Delete') + { + $datasetRaw->{$fieldName} = 'Delete'; + } + elseif ($fieldName == 'Edit') + { + $datasetRaw->{$fieldName} = 'Edit'; + } + + return $datasetRaw; + } + ); + + if ($filterId == null) + { + $filterWidgetArray['app'] = 'core'; + $filterWidgetArray['datasetName'] = 'kontakts'; + $filterWidgetArray['filterKurzbz'] = 'This filter filters'; + } + else + { + $filterWidgetArray['filterId'] = $filterId; + } + + echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); + } +} diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php new file mode 100644 index 000000000..984005baa --- /dev/null +++ b/application/views/system/infocenter/infocenter.php @@ -0,0 +1,35 @@ +load->view('templates/FHC-Header', array('title' => 'Info Center', 'jquery3' => true)); ?> + + + + + + + + + load->view( + 'system/infocenter/infocenterFilters.php', + array( + 'listFiltersSent' => $listFiltersSent, + 'listFiltersNotSent' => $listFiltersNotSent + ) + ); + ?> + + + + + + + + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/infocenter/infocenterFilters.php b/application/views/system/infocenter/infocenterFilters.php new file mode 100644 index 000000000..e5d124aad --- /dev/null +++ b/application/views/system/infocenter/infocenterFilters.php @@ -0,0 +1,30 @@ + $filterId) + { + $toPrint = ''; + + echo sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter/filter'), $filterId, $name).PHP_EOL; + } + } + +// HTML + // body + // span +?> +
+ +
+ Abgeschickt: +
+ + + +
+ Nicht abgeschickt: +
+ + + +
diff --git a/application/views/templates/FHC-Footer.php b/application/views/templates/FHC-Footer.php new file mode 100644 index 000000000..9be2faef3 --- /dev/null +++ b/application/views/templates/FHC-Footer.php @@ -0,0 +1,3 @@ + + + diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php new file mode 100644 index 000000000..bde117a48 --- /dev/null +++ b/application/views/templates/FHC-Header.php @@ -0,0 +1,103 @@ +'; + + if (isset($CSSs)) + { + $tmpCSSs = is_array($CSSs) ? $CSSs : array($CSSs); + + for ($tmpCSSsCounter = 0; $tmpCSSsCounter < count($tmpCSSs); $tmpCSSsCounter++) + { + $toPrint = sprintf($cssLink, base_url($tmpCSSs[$tmpCSSsCounter])).PHP_EOL; + + if ($tmpCSSsCounter > 0) $toPrint = "\t\t".$toPrint; + + echo $toPrint; + } + } +} + +/** + * Generates tags for the javascripts you want to include, the parameter could by a string or an array of strings + */ +function _generateJSsInclude($JSs) +{ + $jsInclude = ''; + + if (isset($JSs)) + { + $tmpJSs = is_array($JSs) ? $JSs : array($JSs); + + for ($tmpJSsCounter = 0; $tmpJSsCounter < count($tmpJSs); $tmpJSsCounter++) + { + $toPrint = sprintf($jsInclude, base_url($tmpJSs[$tmpJSsCounter])).PHP_EOL; + + if ($tmpJSsCounter > 0) $toPrint = "\t\t".$toPrint; + + echo $toPrint; + } + } +} + +?> + + + + + <?php _printTitle($title); ?> + + + + + + + + + + From fa3daa7a577f751ec24fbf2fad45ae372af59ce6 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 18 Dec 2017 14:01:42 +0100 Subject: [PATCH 40/45] Created infocenter details page showing Person Stammdaten, Dokumente, Prestudent ZGVs, Logs and Notizen. --- .../system/infocenter/InfocenterDetails.php | 456 ++++++++++++++++++ application/libraries/DmsLib.php | 4 + application/libraries/PersonLogLib.php | 16 + application/models/person/Notiz_model.php | 37 ++ application/models/system/PersonLog_model.php | 26 + .../system/infocenter/infocenterDetails.php | 269 +++++++++++ application/widgets/Nation_widget.php | 22 + application/widgets/Statusgrund_widget.php | 22 + application/widgets/Zgv_widget.php | 22 + application/widgets/Zgvmaster_widget.php | 22 + 10 files changed, 896 insertions(+) create mode 100644 application/controllers/system/infocenter/InfocenterDetails.php create mode 100644 application/views/system/infocenter/infocenterDetails.php create mode 100644 application/widgets/Nation_widget.php create mode 100644 application/widgets/Statusgrund_widget.php create mode 100644 application/widgets/Zgv_widget.php create mode 100644 application/widgets/Zgvmaster_widget.php diff --git a/application/controllers/system/infocenter/InfocenterDetails.php b/application/controllers/system/infocenter/InfocenterDetails.php new file mode 100644 index 000000000..f65efea77 --- /dev/null +++ b/application/controllers/system/infocenter/InfocenterDetails.php @@ -0,0 +1,456 @@ +load->model('person/person_model', 'PersonModel'); + $this->load->model('person/kontakt_model', 'KontaktModel'); + $this->load->model('person/adresse_model', 'AdresseModel'); + $this->load->model('person/notiz_model', 'NotizModel'); + $this->load->model('person/notizzuordnung_model', 'NotizzuordnungModel'); + $this->load->model('crm/prestudent_model', 'PrestudentModel'); + $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); + $this->load->model('crm/akte_model', 'AkteModel'); + $this->load->model('crm/statusgrund_model', 'StatusgrundModel'); + $this->load->model('codex/nation_model', 'NationModel'); + $this->load->model('codex/zgv_model', 'ZgvModel'); + $this->load->model('codex/zgvmaster_model', 'ZgvmasterModel'); + $this->load->model('organisation/studiengang_model', 'StudiengangModel'); + + $this->load->library('DmsLib'); + $this->load->library('WidgetLib'); + $this->load->library('PersonLogLib'); + + $this->load->helper('fhcauth'); + $this->load->helper('url'); + + $this->app = 'aufnahme'; + $this->uid = getAuthUID(); + if(!$this->uid) + show_error('user authentification failed'); + } + + public function index() + { + //TODO error page + } + + private function __loadPersonData($person_id) + { + $person = $this->PersonModel->load($person_id); + + if ($person->error) + { + show_error($person->retval); + } + + $staatsbuergerschaft = $this->NationModel->load($person->retval[0]->staatsbuergerschaft); + if ($staatsbuergerschaft->error) + { + show_error($staatsbuergerschaft->retval); + } + + $geburtsnation = $this->NationModel->load($person->retval[0]->geburtsnation); + if ($geburtsnation->error) + { + show_error($geburtsnation->retval); + } + + $this->KontaktModel->addDistinct(); + $this->KontaktModel->addSelect('kontakttyp, kontakt'); + $kontakte = $this->KontaktModel->loadWhere(array('person_id' => $person_id)); + + if ($kontakte->error) + { + show_error($kontakte->retval); + } + + $adresse = $this->AdresseModel->loadWhere(array('person_id' => $person_id)); + + if ($adresse->error) + { + show_error($adresse->retval); + } + + $dokumente = $this->AkteModel->loadWhere(array('person_id' => $person_id)); + + if ($dokumente->error) + { + show_error($dokumente->retval); + } + + $logs = $this->personloglib->getLogs($person_id, $this->app); + + foreach($logs as $log) + $log->logdata = json_decode($log->logdata); + + $this->NotizzuordnungModel->addSelect('notiz_id'); + $notizzuordnung = $this->NotizzuordnungModel->loadWhere(array('person_id' => $person_id)); + + if ($notizzuordnung->error) + { + show_error($notizzuordnung->retval); + } + + $notizen = array(); + + foreach ($notizzuordnung->retval as $notiz_id) + { + $notiz = $this->NotizModel->load($notiz_id->notiz_id); + $notizen[] = $notiz->retval[0]; + } + + $data = array ( + 'person' => $person->retval[0], + 'staatsbuergerschaft' => $staatsbuergerschaft->retval[0], + 'geburtsnation' => $geburtsnation->retval[0], + 'kontakte' => $kontakte->retval, + 'adresse' => isset($adresse->retval[0]) ? $adresse->retval[0] : null, + 'dokumente' => $dokumente->retval, + 'logs' => $logs, + 'notizen' => $notizen + ); + + return $data; + } + + private function __loadPrestudentData($person_id) + { + $zgvpruefungen = []; + + $prestudenten = $this->PrestudentModel->loadWhere(array('person_id' => $person_id)); + + if ($prestudenten->error) + { + show_error($prestudenten->retval); + } + + foreach ($prestudenten->retval as $prestudent) + { + $zgvpruefung = new stdClass(); + $zgvpruefung->prestudent_id = $prestudent->prestudent_id; + + //Prestudentstatus + $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent->prestudent_id); + + if ($lastStatus->error) + { + show_error($lastStatus->retval); + } + + $zgvpruefung->prestudentstatus = $lastStatus->retval[0]; + + // Studiengang + $this->StudiengangModel->addSelect('kurzbzlang, bezeichnung, typ');//TODO need bezeichnung? + $studiengang = $this->StudiengangModel->load($prestudent->studiengang_kz); + + if ($studiengang->error) + { + show_error($studiengang->retval); + } + + $zgvpruefung->studiengang = $studiengang->retval[0]->kurzbzlang; + $zgvpruefung->studiengangtyp = $studiengang->retval[0]->typ; + + // Zgv + if (isset($prestudent->zgv_code)) + { + $this->ZgvModel->addSelect('zgv_code, zgv_bez'); + $zgv = $this->ZgvModel->load($prestudent->zgv_code); + + if ($zgv->error) + { + show_error($zgv->retval); + } + + $zgvpruefung->zgv_code = $zgv->retval[0]->zgv_code; + $zgvpruefung->zgv_bez = $zgv->retval[0]->zgv_bez; + } + else + { + $zgvpruefung->zgv_code = null; + $zgvpruefung->zgv_bez = null; + } + $zgvpruefung->zgvort = $prestudent->zgvort; + $zgvpruefung->zgvdatum = $prestudent->zgvdatum; + + // Zgv Nation + if (isset($prestudent->zgvnation)) + { + $this->NationModel->addSelect('nation_code, kurztext'); + $zgvnation = $this->NationModel->load($prestudent->zgvnation); + + if ($zgvnation->error) + { + show_error($zgvnation->retval); + } + + $zgvpruefung->zgvnation_code = $zgvnation->retval[0]->nation_code; + $zgvpruefung->zgvnation_bez = $zgvnation->retval[0]->kurztext; + } + else + { + $zgvnation = null; + $zgvpruefung->zgvnation_code = null; + $zgvpruefung->zgvnation_bez = null; + } + + // Zgv Master + if (isset($prestudent->zgvmas_code)) + { + $this->ZgvmasterModel->addSelect('zgvmas_code, zgvmas_bez'); + $zgvmas = $this->ZgvmasterModel->load($prestudent->zgvmas_code); + + if ($zgvmas->error) + { + show_error($zgvmas->retval); + } + $zgvpruefung->zgvmas_code = $zgvmas->retval[0]->zgvmas_code; + $zgvpruefung->zgvmas_bez = $zgvmas->retval[0]->zgvmas_bez; + } + else + { + $zgvpruefung->zgvmas_code = null; + $zgvpruefung->zgvmas_bez = null; + } + $zgvpruefung->zgvmaort = $prestudent->zgvmaort; + $zgvpruefung->zgvmadatum = $prestudent->zgvmadatum; + + // Zgv Master Nation + if (isset($prestudent->zgvmanation)) + { + $this->NationModel->addSelect('nation_code, kurztext'); + $zgvmanation = $this->NationModel->load($prestudent->zgvmanation); + + if ($zgvmanation->error) + { + show_error($zgvmanation->retval); + } + + $zgvpruefung->zgvmanation_code = $zgvmanation->retval[0]->nation_code; + $zgvpruefung->zgvmanation_bez = $zgvmanation->retval[0]->kurztext; + } + else + { + $zgvmanation = null; + $zgvpruefung->zgvmanation_code = null; + $zgvpruefung->zgvmanation_bez = null; + } + + $zgvpruefungen[] = $zgvpruefung; + } + + //TODO replace with widget + $statusgruende = $this->StatusgrundModel->load()->retval; + + $data = array ( + 'zgvpruefungen' => $zgvpruefungen, + 'statusgruende' => $statusgruende + ); + + return $data; + } + + public function showDetails($person_id) + { + $persondata = $this->__loadPersonData($person_id); + $prestudentdata = $this->__loadPrestudentData($person_id); + $this->load->view('system/infocenter/infocenterDetails.php', array_merge($persondata, $prestudentdata)); + } + + public function saveFormalGeprueft() + { + $akte_id = $this->input->get('akte_id'); + $formalgeprueft = $this->input->get('formal_geprueft'); + $person_id = $this->input->get('person_id'); + + $akte = $this->AkteModel->load($akte_id); + + if ($akte->error) + { + show_error($akte->retval); + } + + $timestamp = (isset($formalgeprueft) && $formalgeprueft === 'true')? date('Y-m-d H:i:s') : null; + $this->AkteModel->update($akte_id, array('formal_geprueft_amum' => $timestamp)); + + //write person log + $this->personloglib->log($person_id, 'Action', array('name' => 'Dokument formal geprüft', 'message' => 'Dokument'.$akte->titel.' formal geprüft, gesetzt auf '.(is_null($timestamp) ? 'NULL' : $timestamp), 'success' => 'true'), $this->app, null, $this->uid); + + redirect('/system/infocenter/InfocenterDetails/showDetails/'.$person_id); + } + + public function saveZgvPruefung($prestudent_id) + { + // prestudentdata + $studiensemester = $this->input->post('studiensemester') === 'null' ? null : $this->input->post('studiensemester'); + $ausbildungssemester = $this->input->post('ausbildungssemester'); + + // zgvdata + $zgv_code = $this->input->post('zgv') === 'null' ? null : $this->input->post('zgv'); + $zgvort = $this->input->post('zgvort'); + $zgvdatum = $this->input->post('zgvdatum'); + $zgvdatum = empty($zgvdatum) ? null : date_format(date_create($zgvdatum), 'Y-m-d'); + $zgvnation_code = $this->input->post('zgvnation') === 'null' ? null : $this->input->post('zgvnation'); + + //zgvmasterdata + $zgvmas_code = $this->input->post('zgvmas') === 'null' ? null : $this->input->post('zgvmas'); + $zgvmaort = $this->input->post('zgvmaort'); + $zgvmadatum = $this->input->post('zgvmadatum'); + $zgvmadatum = empty($zgvmadatum) ? null : date_format(date_create($zgvmadatum), 'Y-m-d'); + $zgvmanation_code = $this->input->post('zgvmanation') === 'null' ? null : $this->input->post('zgvmanation'); + + $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + + if ($lastStatus->error) + { + show_error($lastStatus->retval); + } + + $result = $this->PrestudentstatusModel->update(array('prestudent_id' => $prestudent_id, 'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz, 'ausbildungssemester' => $lastStatus->retval[0]->ausbildungssemester), array('studiensemester_kurzbz' => $studiensemester, 'ausbildungssemester' => $ausbildungssemester)); + + if ($result->error) + { + show_error($result->retval); + } + + $result = $this->PrestudentModel->update($prestudent_id, array('zgv_code' => $zgv_code, 'zgvort' => $zgvort, 'zgvdatum' => $zgvdatum, 'zgvnation' => $zgvnation_code, + 'zgvmas_code' => $zgvmas_code, 'zgvmaort' => $zgvmaort, 'zgvmadatum' => $zgvmadatum, 'zgvmanation' => $zgvmanation_code)); + + if ($result->error) + { + show_error($result->retval); + } + + $logdata = $this->__getPersonAndStudiengangFromPrestudent($prestudent_id); + + $this->personloglib->log($logdata['person_id'], 'Action', array('name' => 'Zgv gespeichert', 'message' => 'Zgv für Studiengang '.$logdata['studiengang_kurzbz'].' wurde gespeichert ', 'success' => 'true'), $this->app, null, $this->uid); + + $this->__redirectToStart($prestudent_id); + } + + public function saveAbsage($prestudent_id) + { + $statusgrund = $this->input->post('statusgrund'); + + $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + + if ($lastStatus->error) + { + show_error($lastStatus->retval); + } + + $result = $this->PrestudentstatusModel->insert(array('prestudent_id' => $prestudent_id, 'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz, 'ausbildungssemester' => $lastStatus->retval[0]->ausbildungssemester, 'datum' => date('Y-m-d'), 'orgform_kurzbz' => $lastStatus->retval[0]->orgform_kurzbz, 'studienplan_id' => $lastStatus->retval[0]->studienplan_id, 'status_kurzbz' => 'Abgewiesener', 'statusgrund_id' => $statusgrund, 'insertvon' => $this->uid, 'insertamum' => date('Y-m-d H:i:s'))); + + if ($result->error) + { + show_error($result->retval); + } + + $logdata = $this->__getPersonAndStudiengangFromPrestudent($prestudent_id); + + $this->personloglib->log($logdata['person_id'], 'Processstate', array('name' => 'Interessent abgewiesen', 'message' => 'Interessent wurde für Studiengang '.$logdata['studiengang_kurzbz'].' abgewiesen', 'success' => 'true'), $this->app, null, $this->uid); + + $this->__redirectToStart($prestudent_id); + } + + public function saveFreigabe($prestudent_id) + { + $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + + if (count($lastStatus->retval) > 0) + { + $lastStatus = $lastStatus->retval[0]; + + $result = $this->PrestudentstatusModel->update(array('prestudent_id' => $prestudent_id, 'status_kurzbz' => $lastStatus->status_kurzbz, 'studiensemester_kurzbz' => $lastStatus->studiensemester_kurzbz, 'ausbildungssemester' => $lastStatus->ausbildungssemester), + array('bestaetigtvon' => $this->uid, 'bestaetigtam' => date('Y-m-d'), 'updatevon' => $this->uid, 'updateamum' => date('Y-m-d H:i:s'))); + + if ($result->error) + { + show_error($result->retval); + } + } + + $logdata = $this->__getPersonAndStudiengangFromPrestudent($prestudent_id); + + $this->personloglib->log($logdata['person_id'], 'Processstate', array('name' => 'Interessent freigegeben', 'message' => 'Interessent wurde für Studiengang '.$logdata['studiengang_kurzbz'].' freigegeben', 'success' => 'true'), $this->app, null, $this->uid); + + $this->__redirectToStart($prestudent_id); + } + + public function saveNotiz($person_id) + { + $titel = $this->input->post('notiztitel'); + $text = $this->input->post('notiz'); + $erledigt = false; + + $this->NotizModel->addNotizForPerson($person_id, $titel, $text, $erledigt, $this->uid); + + $this->personloglib->log($person_id, 'Action', array('name' => 'Notiz hinzugefügt', 'message' => 'Notiz mit Titel '.$titel.' wurde hinzugefügt', 'success' => 'true'), $this->app, null, $this->uid); + + redirect('/system/infocenter/InfocenterDetails/showDetails/'.$person_id); + } + + public function outputAkteContent($akte_id) + { + $akte = $this->AkteModel->load($akte_id); + + if ($akte->error) + { + show_error($akte->retval); + } + + $aktecontent = $this->dmslib->getAkteContent($akte_id); + + if($aktecontent->error) + { + show_error($aktecontent->retval); + } + + header("Content-type: ".$akte->retval[0]->mimetype); + header('Content-Disposition: attachment; filename="'.$akte->retval[0]->titel.'"'); + echo $aktecontent->retval; + } + + private function __redirectToStart($prestudent_id) + { + $this->PrestudentModel->addSelect('person_id'); + $person_id = $this->PrestudentModel->load($prestudent_id)->retval[0]->person_id; + redirect('/system/infocenter/InfocenterDetails/showDetails/'.$person_id); + } + + private function __getPersonAndStudiengangFromPrestudent($prestudent_id) + { + $this->PrestudentModel->addSelect('person_id, studiengang_kz'); + $prestudent = $this->PrestudentModel->load($prestudent_id); + + if ($prestudent->error) + { + show_error($prestudent->retval); + } + + $person_id = $prestudent->retval[0]->person_id; + + $this->StudiengangModel->addSelect('kurzbzlang');//TODO need bezeichnung? + $studiengang = $this->StudiengangModel->load($prestudent->retval[0]->studiengang_kz); + + if ($studiengang->error) + { + show_error($studiengang->retval); + } + + $studiengang_kurzbz = $studiengang->retval[0]->kurzbzlang; + + return array('person_id' => $person_id, 'studiengang_kurzbz' => $studiengang_kurzbz); + } + +} \ No newline at end of file diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php index f592eaa0e..7b5eeb62e 100644 --- a/application/libraries/DmsLib.php +++ b/application/libraries/DmsLib.php @@ -250,6 +250,10 @@ class DmsLib { return success(base64_decode($dmscontent->retval[0]->file_content)); } + else + { + return error($dmscontent->retval); + } } else { diff --git a/application/libraries/PersonLogLib.php b/application/libraries/PersonLogLib.php index 5eb8013f2..34bde6145 100644 --- a/application/libraries/PersonLogLib.php +++ b/application/libraries/PersonLogLib.php @@ -44,4 +44,20 @@ class PersonLogLib else show_error($result->retval); } + + /** + * Gets Logs for a Person, filtered by Parameters + * @param int $person_id ID of the Person. + * @param string $app Name of the App. + * @param string $oe_kurzbz Organisations Unit. + * @return object $result + */ + public function getLogs($person_id, $app = null, $oe_kurzbz = null) + { + $result = $this->ci->PersonLogModel->filterLog($person_id, $app, $oe_kurzbz); + if (isSuccess($result)) + return $result->retval; + else + show_error($result->retval); + } } diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index fc41c9e40..37581def1 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -94,5 +94,42 @@ class Notiz_model extends DB_Model return $result; } + + /** + * Add a Notiz for a given person + */ + public function addNotizForPerson($person_id, $titel, $text, $erledigt, $verfasser_uid) + { + // Loads model Notizzuordnung_model + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + + // Start DB transaction + $this->db->trans_start(false); + + $result = $this->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid, + "insertvon" => $verfasser_uid)); + $notiz_id = $result->retval; + if (isSuccess($result)) + { + $result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, 'person_id' => $person_id)); + } + + // Transaction complete! + $this->db->trans_complete(); + + // Check if everything went ok during the transaction + if ($this->db->trans_status() === false || isError($result)) + { + $this->db->trans_rollback(); + $result = error($result->msg, EXIT_ERROR); + } + else + { + $this->db->trans_commit(); + $result = success($notiz_id); + } + + return $result; + } // ------------------------------------------------------------------------------------------------------ } \ No newline at end of file diff --git a/application/models/system/PersonLog_model.php b/application/models/system/PersonLog_model.php index 2d7ff15cc..4725815f3 100644 --- a/application/models/system/PersonLog_model.php +++ b/application/models/system/PersonLog_model.php @@ -58,4 +58,30 @@ class PersonLog_model extends CI_Model return success($result->result()); } + + /** + * Load logs for a person, filtered by parameters + * @param int $person_id ID of the Person. + * @param string $app Name of the App. + * @param string $oe_kurzbz Organisations Unit. + * @return object $result + */ + public function filterLog($person_id, $app = null, $oe_kurzbz = null) + { + // Check Permissions + $this->load->library('PermissionLib'); + if(!$this->permissionlib->isEntitled('system.tbl_log',PermissionLib::SELECT_RIGHT)) + show_error('Permission denied - You need Access to system.tbl_log'); + + $this->db->order_by('zeitpunkt', 'DESC'); + $this->db->order_by('log_id', 'DESC'); + if (!is_null($app)) + $this->db->where('app='.$this->db->escape($app)); + if (!is_null($oe_kurzbz)) + $this->db->where('oe_kurzbz='.$this->db->escape($oe_kurzbz)); + + $result = $this->db->get_where($this->dbTable, "person_id=".$this->db->escape($person_id)); + + return success($result->result()); + } } diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php new file mode 100644 index 000000000..b663094c7 --- /dev/null +++ b/application/views/system/infocenter/infocenterDetails.php @@ -0,0 +1,269 @@ +load->view('templates/header', array('title' => 'InfocenterDetails', 'datepicker' => true, 'datepickerclass' => 'dateinput'/*, 'tablesort' => true, 'tableid' => 't1'*/)); +?> + +

Infocenter - Person Details

+ +
+ Stammdaten + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Vorname: vorname ?>
Nachname: nachname ?>
Geburtsdatum: gebdatum), 'd.m.Y') ?>
Sozialversicherungsnr: svnr ?>
Staatsbürgerschaft: kurztext ?>
Geschlecht: geschlecht ?>
Geburtsnation: kurztext ?>
Geburtsort: gebort ?>
Kontaktdaten
kontakttyp).': '; + if ($kontakt->kontakttyp == 'email'): + ?> + + kontakt; + if ($kontakt->kontakttyp == 'email'): + ?> + + +
+ Adresse: strasse.", ".$adresse->plz." ".$adresse->ort : "" ?> +
+
+
+ Dokumentenprüfung + + + + + + + + + formal_geprueft_amum)) ? "checked" : ""; + ?> + + + + + + + + +
NameTypUploaddatumformal geprüft
titel ?> + dokument_kurzbz ?>erstelltam), 'd.m.Y') ?> + + onclick="onFormalGeprueftChange(this.checked, akte_id ?>, person_id ?>)"/> + formal_geprueft_amum; + ?> +
+
+ +
+
+ ZGV Prüfung - Studiengang studiengang ?> + + + + + + + + + + + + + + studiengangtyp === 'm') :?> + + + + + + + + + + + + + + + + +
+ + prestudentstatus->status_kurzbz?> + + + prestudentstatus->bestaetigtam) ? "ja" : "nein" ?> + + + widgetlib->widget( + 'Studiensemester_widget', + array(DropdownWidget::SELECTED_ELEMENT => $zgvpruefung->prestudentstatus->studiensemester_kurzbz), + array('name' => 'studiensemester', 'id' => 'studiensemester') + ); ?> + + + prestudentstatus->ausbildungssemester ?> +
+ + widgetlib->widget( + 'Zgv_widget', + array(DropdownWidget::SELECTED_ELEMENT => $zgvpruefung->zgv_code), + array('name' => 'zgv', 'id' => 'zgv') + ); ?> + + + + + + zgvdatum), 'd.m.Y') ?>" + name="zgvdatum"> + + + widgetlib->widget( + 'Nation_widget', + array(DropdownWidget::SELECTED_ELEMENT => $zgvpruefung->zgvnation_code), + array('name' => 'zgvnation', 'id' => 'zgvnation') + ); ?> +
+ + widgetlib->widget( + 'Zgvmaster_widget', + array(DropdownWidget::SELECTED_ELEMENT => $zgvpruefung->zgvmas_code), + array('name' => 'zgvmas', 'id' => 'zgvmas') + ); ?> + + + + + + zgvmadatum), 'd.m.Y') ?>" + name="zgvmadatum"> + + + widgetlib->widget( + 'Nation_widget', + array(DropdownWidget::SELECTED_ELEMENT => $zgvpruefung->zgvmanation_code), + array('name' => 'zgvmanation', 'id' => 'zgvmanation') + ); ?> +
+ +
+
+
+ + widgetlib->widget( + 'Statusgrund_widget', + array(), + array('name' => 'absage', 'id' => 'absage') + ); */ + //Prestudenten cannot be abgewiesen or freigegeben if already done + if(!isset($zgvpruefung->prestudentstatus->bestaetigtam) && $zgvpruefung->prestudentstatus->status_kurzbz != 'Abgewiesener') : + ?> +
+ + + +
+ + + + + + + + + + + + + + + + + + + + +
DatumAktivitätUser
zeitpunkt), 'd.m.Y H:i:s') ?>logdata->name ?>insertvon ?>
+ + + + + + + + + + + + + + + + + +
DatumNotizUser
insertamum), 'd.m.Y H:i:s') ?>titel ?>verfasser_uid ?>
+
+ +
+ Titel: +
+ Text: + +
+ + + diff --git a/application/widgets/Nation_widget.php b/application/widgets/Nation_widget.php new file mode 100644 index 000000000..2c20b8691 --- /dev/null +++ b/application/widgets/Nation_widget.php @@ -0,0 +1,22 @@ +load->model('codex/nation_model', 'NationModel'); + $this->NationModel->addOrder('nation_code'); + + $this->addSelectToModel($this->NationModel, 'nation_code', 'kurztext'); + + $this->setElementsArray( + $this->NationModel->load(), + true, + 'Select a nation...', + 'No nation found' + ); + + $this->loadDropDownView($widgetData); + } +} \ No newline at end of file diff --git a/application/widgets/Statusgrund_widget.php b/application/widgets/Statusgrund_widget.php new file mode 100644 index 000000000..d0f9d2f58 --- /dev/null +++ b/application/widgets/Statusgrund_widget.php @@ -0,0 +1,22 @@ +load->model('crm/statusgrund_model', 'StatusgrundModel'); + $this->StatusgrundModel->addOrder('statusgrund_id'); + + $this->addSelectToModel($this->StatusgrundModel, 'statusgrund_id', 'bezeichnung_mehrsprachig[1]'); + + $this->setElementsArray( + $this->StatusgrundModel->load(), + true, + 'Select a Statusgrund...', + 'No Statusgrund found' + ); + + $this->loadDropDownView($widgetData); + } +} \ No newline at end of file diff --git a/application/widgets/Zgv_widget.php b/application/widgets/Zgv_widget.php new file mode 100644 index 000000000..8858d3206 --- /dev/null +++ b/application/widgets/Zgv_widget.php @@ -0,0 +1,22 @@ +load->model('codex/zgv_model', 'ZgvModel'); + $this->ZgvModel->addOrder('zgv_bez'); + + $this->addSelectToModel($this->ZgvModel, 'zgv_code', 'zgv_bez'); + + $this->setElementsArray( + $this->ZgvModel->load(), + true, + 'Select a zgv...', + 'No zgv found' + ); + + $this->loadDropDownView($widgetData); + } +} \ No newline at end of file diff --git a/application/widgets/Zgvmaster_widget.php b/application/widgets/Zgvmaster_widget.php new file mode 100644 index 000000000..8ac331109 --- /dev/null +++ b/application/widgets/Zgvmaster_widget.php @@ -0,0 +1,22 @@ +load->model('codex/zgvmaster_model', 'ZgvmasterModel'); + $this->ZgvmasterModel->addOrder('zgvmas_bez'); + + $this->addSelectToModel($this->ZgvmasterModel, 'zgvmas_code', 'zgvmas_bez'); + + $this->setElementsArray( + $this->ZgvmasterModel->load(), + true, + 'Select a zgv...', + 'No zgv found' + ); + + $this->loadDropDownView($widgetData); + } +} \ No newline at end of file From 6aeb96818fed163ab86070e0ed0b15c626d758d7 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 19 Dec 2017 10:53:02 +0100 Subject: [PATCH 41/45] - Added new includes to FHC-Header.php - Now FilterWidget is not rendering an entire page but only a div - Added view infocenterData to show the filter itself - FilterWidget now is using the new FHC-Header --- .../system/infocenter/InfoCenter.php | 56 ------------------- .../views/system/infocenter/infocenter.php | 20 ++----- .../system/infocenter/infocenterData.php | 50 +++++++++++++++++ .../system/infocenter/infocenterFilters.php | 4 +- application/views/templates/FHC-Header.php | 6 ++ application/views/widgets/filter/filter.php | 23 ++++---- application/widgets/FilterWidget.php | 19 +++++-- 7 files changed, 90 insertions(+), 88 deletions(-) create mode 100644 application/views/system/infocenter/infocenterData.php diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d75ab4d9e..17e7dcc03 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -36,60 +36,4 @@ class InfoCenter extends VileSci_Controller ) ); } - - /** - * - */ - public function filter($filterId = null) - { - $filterWidgetArray = array( - '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 "UpdateDate" - 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 - ', - 'hideHeader' => false, - 'hideSave' => false, - 'checkboxes' => array('PersonId'), - 'additionalColumns' => array('Delete', 'Edit'), - 'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) { - - if ($fieldName == 'PersonId') - { - $datasetRaw->{$fieldName} = ''.$fieldValue.''; - } - elseif ($fieldName == 'Delete') - { - $datasetRaw->{$fieldName} = 'Delete'; - } - elseif ($fieldName == 'Edit') - { - $datasetRaw->{$fieldName} = 'Edit'; - } - - return $datasetRaw; - } - ); - - if ($filterId == null) - { - $filterWidgetArray['app'] = 'core'; - $filterWidgetArray['datasetName'] = 'kontakts'; - $filterWidgetArray['filterKurzbz'] = 'This filter filters'; - } - else - { - $filterWidgetArray['filterId'] = $filterId; - } - - echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); - } } diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php index 984005baa..f5969b7dd 100644 --- a/application/views/system/infocenter/infocenter.php +++ b/application/views/system/infocenter/infocenter.php @@ -1,14 +1,6 @@ -load->view('templates/FHC-Header', array('title' => 'Info Center', 'jquery3' => true)); ?> - - - - +load->view('templates/FHC-Header', array('title' => 'Info Center', 'jquery3' => true, 'tablesorter' => true)); +?> @@ -25,9 +17,9 @@ - + load->view('system/infocenter/infocenterData.php'); + ?> diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php new file mode 100644 index 000000000..0c7b6bdba --- /dev/null +++ b/application/views/system/infocenter/infocenterData.php @@ -0,0 +1,50 @@ + ' + 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 "UpdateDate" + 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 + ', + 'hideHeader' => true, + 'hideSave' => true, + 'additionalColumns' => array('Details'), + 'formatRaw' => function($fieldName, $fieldValue, $datasetRaw) { + + $link = 'Details'; + + if ($fieldName == 'Details') + { + $datasetRaw->{$fieldName} = sprintf( + $link, + base_url('index.ci.php/system/infocenter/infocenterDetails/showDetails/'), + $datasetRaw->PersonId + ); + } + + return $datasetRaw; + } + ); + + $filterId = isset($_GET['filterId']) ? $_GET['filterId'] : null; + + if (isset($filterId) && is_numeric($filterId)) + { + $filterWidgetArray['filterId'] = $filterId; + } + else + { + $filterWidgetArray['app'] = 'core'; + $filterWidgetArray['datasetName'] = 'kontakts'; + $filterWidgetArray['filterKurzbz'] = 'This filter filters'; + } + + echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); +?> diff --git a/application/views/system/infocenter/infocenterFilters.php b/application/views/system/infocenter/infocenterFilters.php index e5d124aad..f15b24fbb 100644 --- a/application/views/system/infocenter/infocenterFilters.php +++ b/application/views/system/infocenter/infocenterFilters.php @@ -3,9 +3,9 @@ { foreach ($listFilters as $name => $filterId) { - $toPrint = ''; + $toPrint = ''; - echo sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter/filter'), $filterId, $name).PHP_EOL; + echo sprintf($toPrint, base_url('index.ci.php/system/infocenter/InfoCenter?filterId'), $filterId, $name).PHP_EOL; } } diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index bde117a48..4b4dcc511 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -9,6 +9,7 @@ $customJSs = isset($customJSs) ? $customJSs : null; // By default set the parameters to false $jquery3 = isset($jquery3) ? $jquery3 : false; +$tablesorter = isset($tablesorter) ? $tablesorter : false; /** * Print the given title of the page @@ -89,11 +90,16 @@ function _generateJSsInclude($JSs) // Eventually required CSS _generateCSSsInclude($customCSSs); // Eventually required CSS + // Table sorter CSS + if ($tablesorter === true) _generateCSSsInclude('skin/tablesort.css'); + // -------------------------------------------------------------------------------------------------------- // Javascripts // JQuery V3 if ($jquery3 === true) _generateJSsInclude('vendor/components/jquery/jquery.min.js'); + // Table sorter JS + if ($tablesorter === true) _generateJSsInclude('vendor/christianbach/tablesorter/jquery.tablesorter.min.js'); // Eventually required JS _generateJSsInclude($customJSs); diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php index 1219e84f3..a5723f4aa 100644 --- a/application/views/widgets/filter/filter.php +++ b/application/views/widgets/filter/filter.php @@ -1,12 +1,16 @@ -load->view( - 'templates/header', - array('title' => 'Filters', 'tablesort' => true, 'tableid' => 'tableDataset', 'widgets' => 'zebra') - ); -?> - +
@@ -71,7 +75,4 @@
- -load->view('templates/footer'); -?> +
diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 3d297bf4f..988032c0a 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -593,7 +593,7 @@ class FilterWidget extends Widget $this->FiltersModel->resetQuery(); // - $this->FiltersModel->addJoin('public.tbl_benutzer', 'person_id'); + $this->FiltersModel->addJoin('public.tbl_benutzer', 'person_id', 'LEFT'); // $this->FiltersModel->addSelect('system.tbl_filters.*'); @@ -619,9 +619,7 @@ class FilterWidget extends Widget else { $whereParameters = array( - 'filter_id' => $this->filter_id, - 'uid' => getAuthUID(), - 'default_filter' => true + 'filter_id' => $this->filterId ); } @@ -635,7 +633,6 @@ class FilterWidget extends Widget if (isset($filter->retval[0]->filter) && trim($filter->retval[0]->filter) != '') { $jsonEncodedFilter = json_decode($filter->retval[0]->filter); - } } @@ -687,6 +684,18 @@ class FilterWidget extends Widget self::ACTIVE_FILTERS_OPTION => $activeFiltersOption ); + $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); + } + else + { + $filterSessionArray = array( + self::SELECTED_FIELDS => array(), + self::SELECTED_FILTERS => array(), + self::ACTIVE_FILTERS => array(), + self::ACTIVE_FILTERS_OPERATION => array(), + self::ACTIVE_FILTERS_OPTION => array() + ); + $this->session->set_userdata(self::SESSION_NAME, $filterSessionArray); } } From 1bb1bdf68b52fd4e19b15784963a40def6275d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 19 Dec 2017 16:09:52 +0100 Subject: [PATCH 42/45] Added Updateinfo Fotoliste --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b28531f8..05c155569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - **[CORE]** Berechtigungsprüfung wurde angepasst damit deaktivierte Benutzer keine Berechtigungen mehr haben - **[FAS]** Mitarbeiterexport exportiert jetzt nur noch die markierten Personen - **[CORE]** Has many as possible javascripts and css present in the repository were removed. Their lack is overcome by the packages in the composer. In the meanwhile also the versions were updated +- **[CIS]** Die Fotoliste wird jetzt mit unoconv erstellt. Die bestehende Vorlage für den Dokumentenexport muss hier angepasst werden ### Updateinfo - **[CORE]** Infoscreen wurde umbenannt (informationsbildschirm.php) From 4c6da4f981ad9b19719e4c3951b14c3bed9bcc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 20 Dec 2017 09:43:32 +0100 Subject: [PATCH 43/45] Doppelte Funktion CutString entfernt --- vilesci/personen/personendetails.php | 38 ++++++++++------------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/vilesci/personen/personendetails.php b/vilesci/personen/personendetails.php index 172bf7051..784b49229 100644 --- a/vilesci/personen/personendetails.php +++ b/vilesci/personen/personendetails.php @@ -20,7 +20,7 @@ * Rudolf Hangl < rudolf.hangl@technikum-wien.at > * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at > */ -require_once('../../config/vilesci.config.inc.php'); +require_once('../../config/vilesci.config.inc.php'); require_once('../../include/functions.inc.php'); require_once('../../include/benutzerberechtigung.class.php'); require_once('../../include/studiengang.class.php'); @@ -38,7 +38,7 @@ $user = get_uid(); if (!$db = new basis_db()) die('Es konnte keine Verbindung zum Server aufgebaut werden.'); - + $rechte = new benutzerberechtigung(); $rechte->getBerechtigungen($user); @@ -58,21 +58,21 @@ echo ' '; -if(!$rechte->isBerechtigt('admin') && +if(!$rechte->isBerechtigt('admin') && !$rechte->isBerechtigt('preinteressent') && !$rechte->isBerechtigt('assistenz')) die('Sie haben keine Berechtigung fuer diese Seite'); if(isset($_GET['id']) && is_numeric($_GET['id'])) $id = $_GET['id']; -else +else die('der Parameter id mit der Person_id muss uebergeben werden'); $person = new person(); if(!$person->load($id)) die('Person wurde nicht gefunden'); - + //PERSON echo '

Person

'; echo ''; @@ -117,7 +117,7 @@ $nation->getAll(); $nation_arr['']=''; foreach($nation->nation as $row) $nation_arr[$row->code]=$row->kurztext; - + $adresstyp_arr = array(''=>'','h'=>'Hauptwohnsitz','n'=>'Nebenwohnsitz','f'=>'Firma'); // *** ADRESSEN *** @@ -144,18 +144,6 @@ foreach ($adresse_obj->result as $row) echo ""; } echo '
".$firma->name."
'; -//PREINTERESSENT -function CutString($strVal, $limit) -{ - if(strlen($strVal) > $limit+3) - { - return substr($strVal, 0, $limit) . "..."; - } - else - { - return $strVal; - } -} $preinteressent = new preinteressent(); $preinteressent->getPreinteressenten($person->person_id); @@ -188,7 +176,7 @@ if(count($preinteressent->result)>0) echo ''; $preinteressent1 = new preinteressent(); $preinteressent1->loadZuordnungen($row->preinteressent_id); - + $stgs=''; foreach ($preinteressent1->result as $row_zuordnung) { @@ -210,12 +198,12 @@ if(count($preinteressent->result)>0) $plz = $adresse->result[0]->plz; $ort = $adresse->result[0]->ort; } - else + else { $plz=''; $ort=''; } - + echo $plz.' '.$ort.' '.$firma->name." ($firma->firmentyp_kurzbz)"; } echo ''; @@ -283,7 +271,7 @@ if(count($prestudent->result)>0) { $uid='ACHTUNG: Es gibt mehrere Studenteneinträge die auf diesen Prestudenten zeigen!'; } - else + else { if($row_std = $db->db_fetch_object($result)) { @@ -295,7 +283,7 @@ if(count($prestudent->result)>0) echo "$uid"; echo "$gruppe"; $prestudent1 = new prestudent(); - $prestudent1->getLastStatus($row->prestudent_id); + $prestudent1->getLastStatus($row->prestudent_id); echo "$prestudent1->status_kurzbz ".($prestudent1->ausbildungssemester!=''?"($prestudent1->ausbildungssemester. Semester)":'').""; echo ''; } @@ -307,7 +295,7 @@ if($result = $db->db_query($qry)) { if($db->db_num_rows($result)>0) { - echo '

Mitarbeiter

'; + echo '

Mitarbeiter

'; echo ' @@ -333,4 +321,4 @@ if($result = $db->db_query($qry)) } echo ''; echo ''; -?> \ No newline at end of file +?> From f9d106113f5b59ee97c93a01ab17e0a17e1020c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 20 Dec 2017 09:43:47 +0100 Subject: [PATCH 44/45] Fehler beim Laden der Dokumente behoben --- include/dokument.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dokument.class.php b/include/dokument.class.php index 7d8b981c2..6cc313583 100644 --- a/include/dokument.class.php +++ b/include/dokument.class.php @@ -670,7 +670,7 @@ class dokument extends basis_db $bezeichnung_mehrsprachig = $sprache->getSprachQuery('bezeichnung_mehrsprachig'); $dokumentbeschreibung_mehrsprachig = $sprache->getSprachQuery('dokumentbeschreibung_mehrsprachig'); $beschreibung_mehrsprachig = $sprache->getSprachQuery('beschreibung_mehrsprachig'); - $qry = "SELECT distinct on (dokument_kurzbz) dokument_kurzbz, bezeichnung, pflicht, nachreichbar, + $qry = "SELECT distinct on (dokument_kurzbz) dokument_kurzbz, bezeichnung, pflicht, nachreichbar, ausstellungsdetails, $bezeichnung_mehrsprachig, $dokumentbeschreibung_mehrsprachig, $beschreibung_mehrsprachig FROM public.tbl_dokumentstudiengang JOIN public.tbl_prestudent using (studiengang_kz) @@ -722,7 +722,7 @@ class dokument extends basis_db $dokumentbeschreibung_mehrsprachig = $sprache->getSprachQuery('dokumentbeschreibung_mehrsprachig'); $beschreibung_mehrsprachig = $sprache->getSprachQuery('beschreibung_mehrsprachig'); - $qry = " SELECT DISTINCT dokument_kurzbz, studiengang_kz, ausstellungsdetails, + $qry = " SELECT DISTINCT dokument_kurzbz, studiengang_kz, ausstellungsdetails, $dokumentbeschreibung_mehrsprachig, $beschreibung_mehrsprachig FROM public.tbl_dokumentstudiengang JOIN public.tbl_dokument using (dokument_kurzbz) From 765ef66bb3a424eb3b4dce9b80a23c1a752eb3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 20 Dec 2017 09:58:34 +0100 Subject: [PATCH 45/45] Fehler beim Anlegen der Noten entschuldigt und unentschuldigt gehoben --- system/dbupdate_3.3.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 22e988540..450c5f7bb 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -399,11 +399,11 @@ if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_pruefungstyp WHERE pruefung } // Note "entschuldigt" hinzufügen -if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'en' AND bezeichnung = 'entschuldigt' OR bezeichnung = 'Entschuldigt';")) +if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'en' AND (bezeichnung = 'entschuldigt' OR bezeichnung = 'Entschuldigt');")) { if($db->db_num_rows($result) == 0) { - $qry = "INSERT INTO lehre.tbl_note(bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES('entschuldigt', 'en', NULL, TRUE, NULL, TRUE, TRUE);"; + $qry = "INSERT INTO lehre.tbl_note(note, bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES((SELECT max(note)+1 FROM lehre.tbl_note),'entschuldigt', 'en', NULL, TRUE, NULL, TRUE, TRUE);"; if(!$db->db_query($qry)) echo 'lehre.tbl_note: '.$db->db_last_error().'
'; @@ -413,11 +413,11 @@ if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'en' } // Note "unentschuldigt" hinzufügen -if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'ue' AND bezeichnung = 'unentschuldigt' OR bezeichnung = 'Unentschuldigt';")) +if($result = @$db->db_query("SELECT 1 FROM lehre.tbl_note WHERE anmerkung = 'ue' AND (bezeichnung = 'unentschuldigt' OR bezeichnung = 'Unentschuldigt');")) { if($db->db_num_rows($result) == 0) { - $qry = "INSERT INTO lehre.tbl_note(bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES('unentschuldigt', 'ue', NULL, FALSE, NULL, TRUE, TRUE);"; + $qry = "INSERT INTO lehre.tbl_note(note, bezeichnung, anmerkung, farbe, positiv, notenwert, aktiv, lehre) VALUES((SELECT max(note)+1 FROM lehre.tbl_note),'unentschuldigt', 'ue', NULL, FALSE, NULL, TRUE, TRUE);"; if(!$db->db_query($qry)) echo 'lehre.tbl_note: '.$db->db_last_error().'
';