added lock mechanism for persons, outsourced infocenter code to javascript

This commit is contained in:
alex
2018-02-20 18:05:36 +01:00
parent d9f6bfb76b
commit 695e7f60af
10 changed files with 371 additions and 126 deletions
@@ -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:');
@@ -0,0 +1,90 @@
<?php
/**
* Enables content locking.
* An entry in the locktable means certain content is marked locked and a user is its editor.
*/
class PersonLock_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->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);
}
}
@@ -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 @@
</div>
</div>
</div>
<script>
$("#tableDataset").addClass('table table-bordered table-responsive');
</script>
</body>
<?php $this->load->view('templates/FHC-Footer'); ?>
@@ -1,19 +1,27 @@
<?php
$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' => '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')
)
);
?>
<body>
<div id="wrapper">
@@ -29,12 +37,25 @@ $this->load->view(
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h3 class="page-header">Infocenter
Details: <?php echo $stammdaten->vorname.' '.$stammdaten->nachname ?>
</h3>
<div class="col-lg-8">
<h3 class="page-header">
Infocenter Details: <?php echo $stammdaten->vorname.' '.$stammdaten->nachname ?>
</h3>
</div>
<div class="col-lg-4">
<div class="headerright text-right">
wird bearbeitet von:
<?php
if(isset($lockedby)):
echo $lockedby;
?>
&nbsp;&nbsp;
<a href="../unlockPerson/<?php echo $stammdaten->person_id; ?>"><i class="fa fa-sign-out"></i>&nbsp;Freigeben</a>
<?php endif; ?>
</div>
</div>
</div>
<br />
<section>
<div class="row">
<div class="col-lg-12">
@@ -124,27 +145,9 @@ $this->load->view(
</div> <!-- ./wrapper -->
<script>
$(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"]);
addTablesorter("logtable", [[0, 1]], ["filter"]);
addTablesorter("notiztable", [[0, 1]], ["filter"]);
//add pager
togglePager(23, "logtable", "logpager");
togglePager(10, "notiztable", "notizpager");
//initialise datepicker
$.datepicker.setDefaults($.datepicker.regional['de']);
$(".dateinput").datepicker({
"dateFormat": "dd.mm.yy"
});
//add click events to "formal geprüft" checkboxes
<?php foreach($dokumente as $dokument): ?>
@@ -157,75 +160,8 @@ $this->load->view(
}
<?php endforeach ?>
//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");
}
);
}
);
function addTablesorter(tableid, sortList, widgets)
{
$("#" + tableid).tablesorter(
{
theme: "default",
dateFormat: "ddmmyyyy",
sortList: sortList,
widgets: widgets
}
);
//hide filters if less than 2 datarows (+ 2 for headings and filter row itself)
if ($("#" + tableid + " tr").length < 4)
{
$("#" + tableid + " tr.tablesorter-filter-row").hide();
}
}
function togglePager(size, tableid, pagerid)
{
var html =
'<div id="' + pagerid + '" class="pager"> ' +
'<form class="form-inline">' +
'<i class="fa fa-step-backward first"></i>&nbsp;' +
'<i class="fa fa-backward prev"></i>' +
'<span class="pagedisplay"></span>' +
'<i class="fa fa-forward next"></i>&nbsp;' +
'<i class="fa fa-step-forward last"></i>' +
'</form>' +
'</div>';
var rowcount = $("#" + tableid + " tr").length;
//not show pager if on first 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'
}
);
}
}
</script>
</body>
@@ -80,7 +80,9 @@
<?php echo isset($adresse) ? $adresse->strasse.', '.$adresse->plz.' '.$adresse->ort : '' ?>
</td>
<td>
<?php echo ($adresse->heimatadresse === true ? 'Heimatadresse' : '').($adresse->heimatadresse === true && $adresse->rechnungsadresse === true ? ', ' : '').($adresse->rechnungsadresse === true ? 'Rechnungsadresse' : ''); ?>
<?php echo ($adresse->heimatadresse === true ? 'Heimatadresse' : '').
($adresse->heimatadresse === true && $adresse->rechnungsadresse === true ? ', ' : '').
($adresse->rechnungsadresse === true ? 'Rechnungsadresse' : ''); ?>
</td>
</tr>
<?php endforeach; ?>
@@ -103,13 +105,4 @@
</div>
<?php endif; ?>
</div>
</div>
<script>
//add submit event to message send link
$("#sendmsglink").click(
function ()
{
$("#sendmsgform").submit();
}
);
</script>
</div>
@@ -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 <http://www.gnu.org/licenses/>.
*/
/**
* 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");
}
);
}
);
@@ -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 <http://www.gnu.org/licenses/>.
*/
/**
* 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("<br><br>");
}
/**
* 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);
}
+86
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
/**
* 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 =
'<div id="' + pagerid + '" class="pager"> ' +
'<form class="form-inline">' +
'<i class="fa fa-step-backward first"></i>&nbsp;' +
'<i class="fa fa-backward prev"></i>' +
'<span class="pagedisplay"></span>' +
'<i class="fa fa-forward next"></i>&nbsp;' +
'<i class="fa fa-step-forward last"></i>' +
'</form>' +
'</div>';
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'
}
);
}
}
+11 -1
View File
@@ -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;
}
}
+3
View File
@@ -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;