mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-26 09:04:28 +00:00
added lock mechanism for persons, outsourced infocenter code to javascript
This commit is contained in:
@@ -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;
|
||||
?>
|
||||
|
||||
<a href="../unlockPerson/<?php echo $stammdaten->person_id; ?>"><i class="fa fa-sign-out"></i> 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> ' +
|
||||
'<i class="fa fa-backward prev"></i>' +
|
||||
'<span class="pagedisplay"></span>' +
|
||||
'<i class="fa fa-forward next"></i> ' +
|
||||
'<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>
|
||||
Reference in New Issue
Block a user