diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index f1cd674b7..92932b8ea 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -64,6 +64,7 @@ class InfoCenter extends VileSci_Controller $this->load->model('person/person_model', 'PersonModel'); $this->load->model('system/message_model', 'MessageModel'); $this->load->model('system/filters_model', 'FiltersModel'); + $this->load->model('system/personLock_model', 'PersonLockModel'); // Loads libraries $this->load->library('DmsLib'); @@ -110,10 +111,20 @@ class InfoCenter extends VileSci_Controller if (!is_numeric($person_id)) show_error('person id is not numeric!'); - $persondata = $this->_loadPersonData($person_id); - if (!isset($persondata)) + $personexists = $this->PersonModel->load($person_id); + if(isError($personexists)) + show_error($personexists->retval); + + if (empty($personexists->retval[0])) show_error('person does not exist!'); + //mark person as locked for editing + $result = $this->PersonLockModel->lockPerson($person_id, $this->uid, self::APP); + + if(isError($result)) + show_error($result->retval); + + $persondata = $this->_loadPersonData($person_id); $prestudentdata = $this->_loadPrestudentData($person_id); $this->load->view( @@ -129,6 +140,20 @@ class InfoCenter extends VileSci_Controller ); } + /** + * unlocks page from edit by a person, redirects to overview filter page + * @param $person_id + */ + public function unlockPerson($person_id) + { + $result = $this->PersonLockModel->unlockPerson($person_id, self::APP); + + if(isError($result)) + show_error($result->retval); + + redirect(self::URL_PREFIX); + } + /** * Saves if a document has been formal geprueft. saves current timestamp if checked as geprueft, or null if not. */ @@ -235,7 +260,7 @@ class InfoCenter extends VileSci_Controller } //check if still Interessent and not freigegeben yet - if($lastStatus->retval[0]->status_kurzbz === 'Interessent' && !isset($lastStatus->retval[0]->bestaetigtam)) + if ($lastStatus->retval[0]->status_kurzbz === 'Interessent' && !isset($lastStatus->retval[0]->bestaetigtam)) { $result = $this->PrestudentstatusModel->insert( array( @@ -517,6 +542,13 @@ class InfoCenter extends VileSci_Controller */ private function _loadPersonData($person_id) { + $lockedby = $this->PersonLockModel->checkIfLocked($person_id); + + if (isError($lockedby)) + { + show_error($lockedby->retval); + } + $stammdaten = $this->PersonModel->getPersonStammdaten($person_id, true); if (isError($stammdaten)) @@ -567,6 +599,7 @@ class InfoCenter extends VileSci_Controller $messagelink = base_url('/index.ci.php/system/Messages/write/'.$user_person->retval[0]->person_id); $data = array ( + 'lockedby' => isset($lockedby->retval[0]->uid) ? $lockedby->retval[0]->uid : null, 'stammdaten' => $stammdaten->retval, 'dokumente' => $dokumente->retval, 'dokumente_nachgereicht' => $dokumente_nachgereicht->retval, @@ -606,7 +639,7 @@ class InfoCenter extends VileSci_Controller $zgvpruefung = $prestudent->retval[0]; - if(isset($zgvpruefung->prestudentstatus)) + if (isset($zgvpruefung->prestudentstatus)) { $position = strpos($zgvpruefung->prestudentstatus->anmerkung, 'Alt:'); diff --git a/application/models/system/PersonLock_model.php b/application/models/system/PersonLock_model.php new file mode 100644 index 000000000..1a3edd917 --- /dev/null +++ b/application/models/system/PersonLock_model.php @@ -0,0 +1,90 @@ +dbTable = 'system.tbl_person_lock'; + $this->pk = 'lock_id'; + } + + /** + * checks if a specific person is locked. By default, looks for any entries in locktable for the person. + * Alternatively, looks only for locks in a certain app + * @param $person_id + * @param null $app + * @return array all locks for a person if locked, null otherwise + */ + public function checkIfLocked($person_id, $app = null) + { + $lockdata = $app === null ? array('person_id' => $person_id) : array('person_id' => $person_id, 'app' => $app); + + $result = $this->loadWhere($lockdata); + + if($result->error) + return error($result->retval); + else + { + if(count($result->retval) > 0) + return success($result->retval); + else + return success(null); + } + } + + /** + * locks a person. returns null if person was not locked (e.g. when already locked) + * @param $person_id + * @param $uid user who locks the person + * @param $app optional, application in which person is locked + * @return array inserted lock id if person was locked, null otherwise + */ + public function lockPerson($person_id, $uid, $app = null) + { + $locked = $this->checkIfLocked($person_id, $app); + + if($locked->error) + return error($locked->retval); + + //insert only if not already locked + if($locked->retval === null) + return $this->insert(array('person_id' => $person_id, 'uid' => $uid, 'app' => $app)); + else + return success(null); + } + + /** + * remove a lock for a person. By default, removes any entries in locktable for the person + * Alternatively, removes only locks in a certain app + * @param $person_id + * @param null $app + * @return array deleted lock ids if person was locked, null otherwise + */ + public function unlockPerson($person_id, $app = null) + { + $deleted = array(); + $locks = $this->checkIfLocked($person_id, $app); + + if ($locks->retval === null) + return success(null); + + foreach ($locks->retval as $lock) + { + $result = $this->delete($lock->lock_id); + if($result->error) + return error($result->retval); + + $deleted[] = $lock; + } + + return success($deleted); + } +} diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php index 8244e8c67..a61e8b392 100644 --- a/application/views/system/infocenter/infocenter.php +++ b/application/views/system/infocenter/infocenter.php @@ -9,7 +9,7 @@ 'sbadmintemplate' => true, 'tablesorter' => true, 'customCSSs' => 'skin/tablesort_bootstrap.css', - 'customJSs' => array('include/js/infocenterPersonDataset.js', 'include/js/bootstrapper.js') + 'customJSs' => array('include/js/bootstrapper.js', 'include/js/infocenter/infocenterPersonDataset.js') ) ); ?> @@ -40,9 +40,6 @@ - load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 16effcfdd..0db3a7cdb 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -1,19 +1,27 @@ load->view( - 'templates/FHC-Header', - array( - 'title' => 'InfocenterDetails', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'jqueryui' => true, - 'tablesorter' => true, - 'tinymce' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('skin/admintemplate.css', 'skin/tablesort_bootstrap.css'), - 'customJSs' => 'include/js/bootstrapper.js' - ) -); + $this->load->view( + 'templates/FHC-Header', + array( + 'title' => 'InfocenterDetails', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'jqueryui' => true, + 'tablesorter' => true, + 'tinymce' => true, + 'sbadmintemplate' => true, + 'customCSSs' => + array( + 'skin/admintemplate.css', + 'skin/tablesort_bootstrap.css' + ), + 'customJSs' => + array( + 'include/js/bootstrapper.js', + 'include/js/tablesort/tablesort.js', + 'include/js/infocenter/infocenterDetails.js') + ) + ); ?>
@@ -29,12 +37,25 @@ $this->load->view(
-
- +
+ +
+
+
+ wird bearbeitet von: + +    +  Freigeben + +
+
@@ -124,27 +145,9 @@ $this->load->view(
diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index 3e2ec1fb7..6aae1c9f6 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -80,7 +80,9 @@ strasse.', '.$adresse->plz.' '.$adresse->ort : '' ?> - heimatadresse === true ? 'Heimatadresse' : '').($adresse->heimatadresse === true && $adresse->rechnungsadresse === true ? ', ' : '').($adresse->rechnungsadresse === true ? 'Rechnungsadresse' : ''); ?> + heimatadresse === true ? 'Heimatadresse' : ''). + ($adresse->heimatadresse === true && $adresse->rechnungsadresse === true ? ', ' : ''). + ($adresse->rechnungsadresse === true ? 'Rechnungsadresse' : ''); ?> @@ -103,13 +105,4 @@
-
- \ No newline at end of file +
\ No newline at end of file diff --git a/include/js/infocenter/infocenterDetails.js b/include/js/infocenter/infocenterDetails.js new file mode 100644 index 000000000..a03a5320e --- /dev/null +++ b/include/js/infocenter/infocenterDetails.js @@ -0,0 +1,74 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/** + * javascript file for infocenterDetails page + */ + +$(document).ready( + function () + { + //initialise table sorter + addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]); + addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]); + addTablesorter("msgtable", [[0, 1], [2, 0]], ["zebra", "filter"], 2); + addTablesorter("logtable", [[0, 1]], ["filter"], 2); + addTablesorter("notiztable", [[0, 1]], ["filter"], 2); + + //add pager + tablesortAddPager("logtable", "logpager", 23); + tablesortAddPager("notiztable", "notizpager", 10); + + //initialise datepicker + $.datepicker.setDefaults($.datepicker.regional['de']); + $(".dateinput").datepicker({ + "dateFormat": "dd.mm.yy" + }); + + //add click events to "formal geprüft" checkboxes +/* $(".prchbox input[type=checkbox]").click( + function() + { + var akteid = this.; + var personid = ; + window.location = "../saveFormalGeprueft?akte_id="+akteid+"&formal_geprueft=" + this.checked + "&person_id="+personid; + } + );*/ + + //add submit event to message send link + $("#sendmsglink").click( + function () + { + $("#sendmsgform").submit(); + } + ); + + //prevent opening modal when Statusgrund not chosen + $("#absageModal").on('show.bs.modal', function (e) + { + if ($("[name=statusgrund]").val() === "null") + { + $("#statusgrselect").addClass("has-error"); + return e.preventDefault(); + } + } + ); + + $("[name=statusgrund]").change(function () + { + $("#statusgrselect").removeClass("has-error"); + } + ); + } +); diff --git a/include/js/infocenterPersonDataset.js b/include/js/infocenter/infocenterPersonDataset.js similarity index 70% rename from include/js/infocenterPersonDataset.js rename to include/js/infocenter/infocenterPersonDataset.js index 90957e03a..f4d80a370 100644 --- a/include/js/infocenterPersonDataset.js +++ b/include/js/infocenter/infocenterPersonDataset.js @@ -1,8 +1,26 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ /** + * javascript file for infocenter overview page */ $(document).ready( function() { + //bootstrap table + $("#tableDataset").addClass('table table-bordered table-responsive'); + // Checks if the table contains data (rows) if ($('#tableDataset').find('tbody:empty').length == 0 && $('#tableDataset').find('tr:empty').length == 0) @@ -17,6 +35,9 @@ $(document).ready( } ); +/** + * adds person table additional actions html (above and beneath it) + */ function appendTableActionsHtml() { var currurl = window.location.href; @@ -47,7 +68,9 @@ function appendTableActionsHtml() $("#datasetActionsBottom").append("

"); } - +/** + * sets functionality for the actions above and beneath the person table + */ function setTableActions() { $(".sendMsgsLink").click(function() { @@ -67,7 +90,7 @@ function setTableActions() $(".selectAll").click(function() { - //trs only if not filtered by tablesorter + //select only trs if not filtered by tablesorter var trs = $("#tableDataset tbody tr").not(".filtered"); trs.find("input[name=PersonId\\[\\]]").prop("checked", true); } diff --git a/include/js/tablesort/tablesort.js b/include/js/tablesort/tablesort.js new file mode 100644 index 000000000..c1c171959 --- /dev/null +++ b/include/js/tablesort/tablesort.js @@ -0,0 +1,86 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/** + * provides helper functions for adding mottie tablesorter + * enables easier configuration of the tablesorter by providing a common default configuration + */ + +/** + * adds tablesorter to specified tableid, german date format, default theme + * @param tableid + * @param sortList columns to sort by, as array of arrays (each array contains column number and 1/0 for asc/desc order) + * @param widgets optional widgets like zebra or filter + * @param minrows optional minimal amount of rows for filter row to be shown (only relevant for filter widget) + */ +function addTablesorter(tableid, sortList, widgets, minrows) +{ + $("#" + tableid).tablesorter( + { + theme: "default", + dateFormat: "ddmmyyyy", + sortList: sortList, + widgets: widgets + } + ); + + if($("#" + tableid + " tr.tablesorter-filter-row").length) + { + //hide filters if less than n datarows (+ 2 for headings and filter row itself), default 0 + var minrows = minrows || 0; + if ($("#" + tableid + " tr").length < minrows + 2) + { + $("#" + tableid + " tr.tablesorter-filter-row").hide(); + } + } +} + +/** + * adds pager for specified tableid. Assumes bootstap icons are available! + * @param tableid + * @param pagerid + * @param size number of rows for each page + */ +function tablesortAddPager(tableid, pagerid, size) +{ + var html = + '
' + + '
' + + ' ' + + '' + + '' + + ' ' + + '' + + '
' + + '
'; + + var rowcount = $("#" + tableid + " tr").length; + + //not show pager if only one table page + if (rowcount > size) + { + var table = $("#" + tableid); + table.after(html); + + table.tablesorterPager( + { + container: $("#" + pagerid), + size: size, + cssDisabled: 'disabled', + savePages: false, + output: '{startRow} – {endRow} / {totalRows} Zeilen' + } + ); + } +} \ No newline at end of file diff --git a/skin/admintemplate.css b/skin/admintemplate.css index 5df078833..88fcff3b3 100644 --- a/skin/admintemplate.css +++ b/skin/admintemplate.css @@ -1,3 +1,13 @@ +/*custom styles for sb admin 2 template: https://startbootstrap.com/template-overviews/sb-admin-2/*/ + +/*optional header at right side of the main header*/ +.headerright{ + margin: 40px 0 20px -30px; + padding: 6.4px 0 9px; + border-bottom: 1px solid #eee; +} + +/*change of panel colors (grey) */ .panel-primary > .panel-heading{ color: black; background-color: #dfdfdf; @@ -6,4 +16,4 @@ .panel-primary{ border-color: #dfdfdf; -} +} \ No newline at end of file diff --git a/skin/admintemplate_contentonly.css b/skin/admintemplate_contentonly.css index a8e76cc08..d5a69d07d 100644 --- a/skin/admintemplate_contentonly.css +++ b/skin/admintemplate_contentonly.css @@ -1,3 +1,6 @@ +/*stylesheet for sb admin 2 pages that do not have menu and toolbar*/ +@import "admintemplate.css"; + @media (min-width:768px) { #page-wrapper { margin-right: 250px;