mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
added Parking feauture to infocenter
This commit is contained in:
@@ -6,7 +6,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
* Also shows infocenter-related data for a person and its prestudents, enables document and zgv checks,
|
||||
* displays and saves Notizen for a person, logs infocenter-related actions for a person
|
||||
*/
|
||||
class InfoCenter extends VileSci_Controller
|
||||
class InfoCenter extends FHC_Controller
|
||||
{
|
||||
// App and Verarbeitungstaetigkeit name for logging
|
||||
const APP = 'infocenter';
|
||||
@@ -21,12 +21,14 @@ class InfoCenter extends VileSci_Controller
|
||||
'saveformalgep' => array(
|
||||
'logtype' => 'Action',
|
||||
'name' => 'Document formally checked',
|
||||
'message' => 'Document %s formally checked, set to %s'
|
||||
'message' => 'Document %s formally checked, set to %s',
|
||||
'success' => null
|
||||
),
|
||||
'savezgv' => array(
|
||||
'logtype' => 'Action',
|
||||
'name' => 'ZGV saved',
|
||||
'message' => 'ZGV saved for degree program %s, prestudentid %s'
|
||||
'message' => 'ZGV saved for degree program %s, prestudentid %s',
|
||||
'success' => null
|
||||
),
|
||||
'abgewiesen' => array(
|
||||
'logtype' => 'Processstate',
|
||||
@@ -41,12 +43,14 @@ class InfoCenter extends VileSci_Controller
|
||||
'savenotiz' => array(
|
||||
'logtype' => 'Action',
|
||||
'name' => 'Note added',
|
||||
'message' => 'Note with title %s was added'
|
||||
'message' => 'Note with title %s was added',
|
||||
'success' => null
|
||||
),
|
||||
'updatenotiz' => array(
|
||||
'logtype' => 'Action',
|
||||
'name' => 'Note updated',
|
||||
'message' => 'Note with title %s was updated'
|
||||
'message' => 'Note with title %s was updated',
|
||||
'success' => null
|
||||
)
|
||||
);
|
||||
private $uid; // contains the UID of the logged user
|
||||
@@ -473,12 +477,11 @@ class InfoCenter extends VileSci_Controller
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$json = FALSE;
|
||||
$json = false;
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
$json = TRUE;
|
||||
$json = true;
|
||||
|
||||
//set log "Notiz updated"
|
||||
$this->_log($person_id, 'updatenotiz', array($titel));
|
||||
@@ -543,6 +546,61 @@ class InfoCenter extends VileSci_Controller
|
||||
->_display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date until which a person is parked
|
||||
* @param $person_id
|
||||
*/
|
||||
public function getParkedDate($person_id)
|
||||
{
|
||||
$result = $this->personloglib->getParkedDate($person_id);
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes parking of a person, i.e. a person is not expected to do any actions while it is parked
|
||||
*/
|
||||
public function park()
|
||||
{
|
||||
$person_id = $this->input->post('person_id');
|
||||
$date = $this->input->post('parkdate');
|
||||
|
||||
$this->personloglib->park($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes parking of a person
|
||||
*/
|
||||
public function unPark()
|
||||
{
|
||||
$person_id = $this->input->post('person_id');
|
||||
|
||||
$this->personloglib->unPark($person_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the End date of the current Studienjahr
|
||||
*/
|
||||
public function getStudienjahrEnd()
|
||||
{
|
||||
$this->load->model('organisation/studienjahr_model', 'StudienjahrModel');
|
||||
|
||||
$result = $this->StudienjahrModel->getCurrStudienjahr();
|
||||
|
||||
$json = false;
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$json = $result->retval[0]->ende;
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($json));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
@@ -762,7 +820,7 @@ class InfoCenter extends VileSci_Controller
|
||||
show_error($user_person->retval);
|
||||
}
|
||||
|
||||
$messagelink = base_url('/index.ci.php/system/Messages/write/'.$user_person->retval[0]->person_id);
|
||||
$messagelink = site_url('/system/Messages/write/'.$user_person->retval[0]->person_id);
|
||||
|
||||
$data = array (
|
||||
'lockedby' => $lockedby,
|
||||
@@ -898,15 +956,20 @@ class InfoCenter extends VileSci_Controller
|
||||
{
|
||||
$logdata = $this->logparams[$logname];
|
||||
|
||||
$datatolog = array(
|
||||
'name' => $logdata['name']
|
||||
);
|
||||
|
||||
if (isset($logdata['message']))
|
||||
$datatolog['message'] = vsprintf($logdata['message'], $messageparams);
|
||||
|
||||
if (array_key_exists('success', $logdata))
|
||||
$datatolog['success'] = true;
|
||||
|
||||
$this->personloglib->log(
|
||||
$person_id,
|
||||
$logdata['logtype'],
|
||||
array(
|
||||
'name' => $logdata['name'],
|
||||
'message' => vsprintf($logdata['message'],
|
||||
$messageparams),
|
||||
'success' => 'true'
|
||||
),
|
||||
$datatolog,
|
||||
self::TAETIGKEIT,
|
||||
self::APP,
|
||||
null,
|
||||
|
||||
@@ -7,6 +7,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
*/
|
||||
class PersonLogLib
|
||||
{
|
||||
const PARKED_LOGNAME = 'Parked';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -79,4 +81,101 @@ class PersonLogLib
|
||||
else
|
||||
show_error($result->retval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parks a person, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent)
|
||||
* Done by adding a logentry in the future
|
||||
* @param $person_id
|
||||
* @param $date
|
||||
* @param $taetigkeit_kurzbz
|
||||
* @param string $app
|
||||
* @param null $oe_kurzbz
|
||||
* @param null $user
|
||||
* @return bool wether parking was successfull
|
||||
*/
|
||||
public function park($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null)
|
||||
{
|
||||
$logdata = array(
|
||||
'name' => self::PARKED_LOGNAME
|
||||
);
|
||||
|
||||
$data = array(
|
||||
'person_id' => $person_id,
|
||||
'zeitpunkt' => $date,
|
||||
'taetigkeit_kurzbz' => $taetigkeit_kurzbz,
|
||||
'app' => $app,
|
||||
'oe_kurzbz' => $oe_kurzbz,
|
||||
'logtype_kurzbz' => 'Processstate',
|
||||
'logdata' => json_encode($logdata),
|
||||
'insertvon' => $user
|
||||
);
|
||||
|
||||
$result = $this->ci->PersonLogModel->insert($data);
|
||||
if (isSuccess($result))
|
||||
return true;
|
||||
else
|
||||
show_error($result->retval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unparks a person, i.e. removes all log entries in the future
|
||||
* @param $person_id
|
||||
*/
|
||||
public function unPark($person_id)
|
||||
{
|
||||
$result = $this->ci->PersonLogModel->getLogsInFuture($person_id);
|
||||
|
||||
$deleted = array();
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
if (count($result->retval) > 0)
|
||||
{
|
||||
foreach ($result->retval as $log)
|
||||
{
|
||||
$logdata = json_decode($log->logdata);
|
||||
if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME)
|
||||
{
|
||||
$delresult = $this->ci->PersonLogModel->deleteLog($log->log_id);
|
||||
if (isSuccess($delresult))
|
||||
$deleted[] = $log->log_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
show_error($result->retval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets date until which a person is parked
|
||||
* @param $person_id
|
||||
* @return the date if person is parked, null otherwise
|
||||
*/
|
||||
public function getParkedDate($person_id)
|
||||
{
|
||||
$result = $this->ci->PersonLogModel->getLogsInFuture($person_id);
|
||||
|
||||
$parkeddate = null;
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
if (count($result->retval) > 0)
|
||||
{
|
||||
foreach ($result->retval as $log)
|
||||
{
|
||||
$logdata = json_decode($log->logdata);
|
||||
if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME)
|
||||
{
|
||||
$parkeddate = $log->zeitpunkt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
show_error($result->retval);
|
||||
|
||||
return $parkeddate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,21 @@ class Studienjahr_model extends DB_Model
|
||||
$this->pk = 'studienjahr_kurzbz';
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets current Studienjahr, as determined by its start and enddate
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCurrStudienjahr()
|
||||
{
|
||||
$query = 'SELECT *
|
||||
FROM public.tbl_studienjahr
|
||||
JOIN public.tbl_studiensemester using(studienjahr_kurzbz)
|
||||
WHERE start <= now()
|
||||
AND ende >= now()
|
||||
ORDER by start DESC
|
||||
LIMIT 1';
|
||||
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,4 +90,36 @@ class PersonLog_model extends CI_Model
|
||||
|
||||
return success($result->result());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all logs with zeitpunkt > today
|
||||
* @param $person_id
|
||||
* @return array
|
||||
*/
|
||||
public function getLogsInFuture($person_id)
|
||||
{
|
||||
$this->db->order_by('zeitpunkt', 'DESC');
|
||||
$this->db->order_by('log_id', 'DESC');
|
||||
|
||||
$result = $this->db->get_where($this->dbTable, "person_id=".$this->db->escape($person_id)." AND zeitpunkt > now()");
|
||||
|
||||
return success($result->result());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a log
|
||||
* @param $log_id
|
||||
* @return array
|
||||
*/
|
||||
public function deleteLog($log_id)
|
||||
{
|
||||
$this->load->library('PermissionLib');
|
||||
if(!$this->permissionlib->isEntitled('system.tbl_log', PermissionLib::DELETE_RIGHT))
|
||||
show_error('Permission denied - You need Access to system.tbl_log');
|
||||
|
||||
$this->db->where('log_id', $log_id);
|
||||
$result = $this->db->delete($this->dbTable);
|
||||
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,9 +151,16 @@
|
||||
),\', \'
|
||||
) AS "StgAktiv",
|
||||
pl.zeitpunkt AS "LockDate",
|
||||
pl.lockuser as "LockUser"
|
||||
pl.lockuser as "LockUser",
|
||||
pd.parkdate AS "ParkDate"
|
||||
FROM public.tbl_person p
|
||||
LEFT JOIN (SELECT person_id, zeitpunkt, uid as lockuser FROM system.tbl_person_lock WHERE app = \''.$APP.'\') pl USING(person_id)
|
||||
LEFT JOIN (
|
||||
SELECT person_id, zeitpunkt as parkdate
|
||||
FROM system.tbl_log
|
||||
WHERE logdata->>\'name\' = \'Parked\'
|
||||
AND zeitpunkt > now()
|
||||
) pd USING(person_id)
|
||||
WHERE
|
||||
EXISTS(
|
||||
SELECT 1
|
||||
@@ -204,7 +211,9 @@
|
||||
ucfirst($this->p->t('lehre','studiengang')) . ' (' . $this->p->t('global','nichtGesendet') . ')',
|
||||
ucfirst($this->p->t('lehre','studiengang')) . ' (' . $this->p->t('global','aktiv') . ')',
|
||||
ucfirst($this->p->t('global','sperrdatum')),
|
||||
ucfirst($this->p->t('global','gesperrtVon'))),
|
||||
ucfirst($this->p->t('global','gesperrtVon')),
|
||||
"ParkedDate"
|
||||
),
|
||||
'formatRaw' => function($datasetRaw) {
|
||||
|
||||
$datasetRaw->{'Details'} = sprintf(
|
||||
@@ -267,10 +276,20 @@
|
||||
},
|
||||
'markRow' => function($datasetRaw) {
|
||||
|
||||
$mark = '';
|
||||
|
||||
if ($datasetRaw->LockDate != null)
|
||||
{
|
||||
return FilterWidget::DEFAULT_MARK_ROW_CLASS;
|
||||
$mark = FilterWidget::DEFAULT_MARK_ROW_CLASS;
|
||||
}
|
||||
|
||||
if ($datasetRaw->ParkDate != null)
|
||||
{
|
||||
//parking has prio over locking
|
||||
$mark = "text-info";
|
||||
}
|
||||
|
||||
return $mark;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -131,8 +131,11 @@
|
||||
<?php $this->load->view('system/infocenter/notizen.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6" id="logs">
|
||||
<div class="col-lg-6">
|
||||
<div id="parking"></div>
|
||||
<div id="logs">
|
||||
<?php $this->load->view('system/infocenter/logs.php'); ?>
|
||||
</div>
|
||||
</div> <!-- ./column -->
|
||||
</div> <!-- ./row -->
|
||||
</div> <!-- ./panel-body -->
|
||||
|
||||
Reference in New Issue
Block a user