added Parking feauture to infocenter

This commit is contained in:
alex
2018-05-16 20:00:19 +02:00
parent 24d4c316e4
commit 6a67183738
8 changed files with 400 additions and 33 deletions
+99
View File
@@ -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;
}
}