- added issue resolution job and libraries for defining how to resolve issues

- added issue inserts (fehlerupdate.php), included them in checksystem
- added getAufenthaltsdauer method to Bisio_model.php
- Add column parameterFuerBehebung to system.tbl_issue
This commit is contained in:
KarpAlex
2022-01-17 10:07:37 +01:00
parent 09ec853f2d
commit 765b26a439
24 changed files with 1315 additions and 57 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* Job for resolving core issues
*/
class IssueResolver extends IssueResolver_Controller
{
public function __construct()
{
parent::__construct();
// set fehler codes which can be resolved by the job
$this->_codeLibMappings = array(
'CORE_ZGV_0001' => 'CORE_ZGV_0001',
'CORE_ZGV_0002' => 'CORE_ZGV_0002',
'CORE_ZGV_0003' => 'CORE_ZGV_0003',
'CORE_ZGV_0004' => 'CORE_ZGV_0004',
'CORE_ZGV_0005' => 'CORE_ZGV_0005',
'CORE_INOUT_0001' => 'CORE_INOUT_0001',
'CORE_INOUT_0002' => 'CORE_INOUT_0002',
'CORE_INOUT_0003' => 'CORE_INOUT_0003',
'CORE_INOUT_0004' => 'CORE_INOUT_0004',
'CORE_INOUT_0005' => 'CORE_INOUT_0005',
'CORE_INOUT_0006' => 'CORE_INOUT_0006'
);
}
}
@@ -58,21 +58,44 @@ class Issues extends Auth_Controller
{
$issue_ids = $this->input->post('issue_ids');
$status_kurzbz = $this->input->post('status_kurzbz');
$verarbeitetvon = $this->_uid;
$user = $this->_uid;
$errors = array();
foreach ($issue_ids as $issue_id)
{
$issueRes = $this->issueslib->changeIssueStatus($issue_id, $status_kurzbz, $verarbeitetvon);
switch ($status_kurzbz)
{
case IssuesLib::STATUS_NEU:
$changeIssueMethod = 'setNeu';
break;
case IssuesLib::STATUS_IN_BEARBEITUNG:
$changeIssueMethod = 'setInBearbeitung';
break;
case IssuesLib::STATUS_BEHOBEN:
$changeIssueMethod = 'setBehoben';
break;
default:
$changeIssueMethod = null;
break;
}
if (isError($issueRes))
$errors[] = getError($issueRes);
if (isEmptyString($changeIssueMethod))
$errors[] = error("Invalid issue status given");
else
{
/* var_dump($changeIssueMethod);
var_dump($issue_id);*/
$issueRes = $this->issueslib->{$changeIssueMethod}($issue_id, $user);
if (isError($issueRes))
$errors[] = getError($issueRes);
}
}
if (!isEmptyArray($errors))
$this->outputJsonError(implode(", ", $errors));
else
$this->outputJsonSuccess("Status erfolgreich aktualisiert");
$this->outputJsonSuccess("Status successfully refreshed");
}
/**
@@ -133,7 +156,7 @@ class Issues extends Auth_Controller
// add oes for which there is the "manage issues" Berechtigung
if (!$oe_kurzbz_berechtigt = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_KURZBZ))
show_error('Keine Berechtigung oder Fehler bei Berechtigungsprüfung');
show_error('No permission or error when checking permissions');
$all_oe_kurzbz_berechtigt = array_unique(array_merge($oe_kurzbz_for_funktion, $oe_kurzbz_berechtigt));
@@ -0,0 +1,15 @@
<?php
/**
* Interface defining method to implement for issue resolution checker (from core and extensions)
*/
interface IIssueResolvedChecker
{
/**
* Checks if a issue of a certain type is resolved.
* Classes for resolving a certain issue type implement this method.
* @param array $params parameters needed for issue resolution
* @return object with success(true) if issue resolved, success(false) otherwise
*/
function checkIfIssueIsResolved($params);
}
+91
View File
@@ -0,0 +1,91 @@
<?php
/**
* Controller for retrieving open issues and, if the issue condition is not met anymore, automatically set it to resolved
*/
abstract class IssueResolver_Controller extends JOB_Controller
{
const ISSUES_FOLDER = 'issues';
protected $_codeLibMappings;
public function __construct()
{
parent::__construct();
$this->load->model('system/Issue_model', 'IssueModel');
$this->load->library('IssuesLib');
}
/**
* Initializes issue resolution.
*/
public function run()
{
// load open issues with given errorcodes
$openIssuesRes = $this->IssueModel->getOpenIssues(array_keys($this->_codeLibMappings));
// log error if occured
if (isError($openIssuesRes))
{
$this->logError(getError($openIssuesRes));
return;
}
// log info if no data found
if (!hasData($openIssuesRes))
{
$this->logInfo("No open issues found");
return;
}
$openIssues = getData($openIssuesRes);
foreach ($openIssues as $issue)
{
if (isset($this->_codeLibMappings[$issue->fehlercode]))
{
$libName = $this->_codeLibMappings[$issue->fehlercode];
// add person id and oe kurzbz automatically as params, merge it with additional params
// decode bewerbung_parameter into assoc array
$params = array_merge(
array('issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz),
isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array()
);
// if called from extension (extension name set), path includes extension names, otherwiese it is the core library folder
$libPath = isset($this->_extensionName) ? 'extensions/'.$this->_extensionName.'/'.self::ISSUES_FOLDER.'/' : self::ISSUES_FOLDER.'/';
// load library connected to fehlercode
$this->load->library(
$libPath.$libName
);
$lowercaseLibName = mb_strtolower($libName);
// call the function for checking if issue is resolved
$issueResolvedRes = $this->{$lowercaseLibName}->checkIfIssueIsResolved($params);
if (isError($issueResolvedRes))
{
$this->logError(getError($issueResolvedRes));
return;
}
$issueResolvedData = getData($issueResolvedRes);
if ($issueResolvedData === true)
{
// set issue to resolved if needed
$behobenRes = $this->issueslib->setBehoben($issue->issue_id, null);
if (isError($behobenRes))
$this->logError(getError($behobenRes));
else
$this->logInfo("Issue ".$issue->issue_id." successfully resolved");
}
}
}
}
}
+308
View File
@@ -0,0 +1,308 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class AkteLibOld extends FHC_Controller
{
const AKTE_KATEGORIE_KURZBZ = 'Akte';
const AKTE_CONTENT_PROPERTY = 'file_content';
const AKTE_TITEL_PROPERTY = 'titel';
private $_ci; // Code igniter instance
private $_uid;
/**
* Object initialization
*/
public function __construct()
{
$this->_ci =& get_instance();
$this->_uid = getAuthUID();
$this->_ci->load->model('crm/Akte_model', 'AkteModel');
$this->_ci->load->model('content/Dms_model', 'DmsModel');
$this->_ci->load->model('content/DmsVersion_model', 'DmsVersionModel');
$this->_ci->load->model('content/DmsFS_model', 'DmsFSModel');
}
public function insertAkteDms($akte)
{
$dmsRes = $this->_insertDmsFromAkteData($akte);
if (isError($dmsRes))
return $dmsRes;
if (hasData($dmsRes))
{
$dms_id = getData($dmsRes)['dms_id'];
$akte['dms_id'] = $dms_id;
unset($akte[self::AKTE_CONTENT_PROPERTY]);
// insert Akte
$akteRes = $this->_ci->AkteModel->insert($akte);
if (isError($akteRes))
return $akteRes;
if (hasData($akteRes))
{
$akte_id = getData($akteRes);
return success(
array(
'akte_id' => $akte_id,
'dms_id' => $dms_id
)
);
}
else
return error("Error when inserting Akte");
}
else
return error("Error when inserting Dms");
}
public function updateAkteDms($akte_id, $akte, $overwriteVersion = false)
{
$dms_id = null;
$maxVersion = 0;
// get latest version number
$db = new DB_Model();
$akteDmsRes = $db->execReadOnlyQuery(
'SELECT dms_id, max(version) AS max_version
FROM public.tbl_akte ak
LEFT JOIN campus.tbl_dms USING(dms_id)
LEFT JOIN campus.tbl_dms_version USING(dms_id)
WHERE akte_id = ?
GROUP BY dms_id',
array($akte_id)
);
if (isError($akteDmsRes))
return $akteDmsRes;
if (hasData($akteDmsRes))
{
$akteDms = getData($akteDmsRes)[0];
// if no dms, insert new
if (is_null($akteDms->dms_id))
{
$dmsRes = $this->_insertDmsFromAkteData($akte);
if (isError($dmsRes))
return $dmsRes;
if (hasData($dmsRes))
{
$dms_id = getData($dmsRes)['dms_id'];
}
else
return error('Error when inserting dms');
}
else
{
$dms_id = $akteDms->dms_id;
// otherwise update dms version
$maxVersion = $akteDms->max_version;
if (is_numeric($maxVersion))
{
// overwrite latest
$currVersion = $overwriteVersion === true ? $maxVersion : $maxVersion + 1;
$writeFileRes = $this->_writeFile($akte[self::AKTE_TITEL_PROPERTY], $akte[self::AKTE_CONTENT_PROPERTY], $dms_id, $currVersion);
if (isError($writeFileRes))
return $writeFileRes;
if (hasData($writeFileRes))
{
// update or insert dms version
$filename = getData($writeFileRes);
$dmsVersionRes = $this->_upsertDmsVersion($dms_id, $currVersion, $filename, $akte);
if (isError($dmsVersionRes))
return $dmsVersionRes;
}
else
return error("Error when writing file");
}
else
return error("invalid dms version");
}
/* var_dump("DMS ID");
var_dump($dms_id);*/
if (!is_numeric($dms_id))
return error("invalid dms id");
// update Akte and link akte to inserted dms
$akte['dms_id'] = $dms_id;
unset($akte[self::AKTE_CONTENT_PROPERTY]);
$akteUpdateRes = $this->_ci->AkteModel->update(
$akte_id,
$akte
);
if (isError($akteUpdateRes))
return $akteUpdateRes;
return success(
array(
'akte_id' => $akte_id,
'dms_id' => $dms_id,
'version' => $maxVersion
)
);
}
else
return error("Akte not found");
}
private function _insertDmsFromAkteData($akte)
{
if (!isset($akte[self::AKTE_TITEL_PROPERTY]))
return error("Akte has no title");
if (!isset($akte[self::AKTE_CONTENT_PROPERTY]))
return error("Akte has no inhalt");
// write akte to filesystem
$fileWriteRes = $this->_writeFile($akte[self::AKTE_TITEL_PROPERTY], $akte[self::AKTE_CONTENT_PROPERTY]);
if (isError($fileWriteRes))
return $fileWriteRes;
if (hasData($fileWriteRes))
{
$filename = getData($fileWriteRes);
// insert dms
$dmsRes = $this->_ci->DmsModel->insert(
array(
'kategorie_kurzbz' => self::AKTE_KATEGORIE_KURZBZ
)
);
if (isError($dmsRes))
return $dmsRes;
if (hasData($dmsRes))
{
$dms_id = getData($dmsRes);
// insert dms version
$dmsVersionRes = $this->_upsertDmsVersion($dms_id, 0, $filename, $akte);
if (isError($dmsVersionRes))
return $dmsVersionRes;
return success(
array(
'dms_id' => $dms_id
)
);
}
else
return error("Error when inserting DMS");
}
else
return error("Error when writing file");
}
private function _writeFile($akteFilename, $akteInhalt, $dms_id = null, $version = null)
{
$filename = null;
if (isset($dms_id) && isset($version))
{
$this->_ci->DmsVersionModel->addSelect('filename');
$dmsVersionRes = $this->_ci->DmsVersionModel->loadWhere(
array(
'dms_id' => $dms_id,
'version' => $version
)
);
if (isError($dmsVersionRes))
return $dmsVersionRes;
if (hasData($dmsVersionRes))
{
$filename = getData($dmsVersionRes)[0]->filename;
}
}
else
{
$filename = $this->_getUniqueFilename($akteFilename);
}
if (isEmptyString($filename))
return error('No filename provided.');
// write akte to filesystem
$writeRes = $this->_ci->DmsFSModel->write($filename, $akteInhalt);
if (isError($writeRes))
return $writeRes;
return success($filename);
}
private function _upsertDmsVersion($dms_id, $version, $filename, $akte)
{
$dmsVersionToSave = array(
'dms_id' => $dms_id,
'version' => $version,
'filename' => $filename,
'mimetype' => isset($akte['mimetype']) ? $akte['mimetype'] : null, // TODO check if exists
'name' => isset($akte['titel']) ? $akte['titel'] : null, // TODO check if exists,
);
$dmsVersionRes = $this->_ci->DmsVersionModel->loadWhere(
array(
'dms_id' => $dms_id,
'version' => $version
)
);
if (isError($dmsVersionRes))
return $dmsVersionRes;
if (hasData($dmsVersionRes))
{
$dmsVersionToSave['updatevon'] = $this->_uid;
$dmsVersionToSave['updateamum'] = date('Y-m-d H:i:s');
return $this->_ci->DmsVersionModel->update(
array(
'dms_id' => $dms_id,
'version' => $version
),
$dmsVersionToSave
);
}
else
{
$dmsVersionToSave['insertvon'] = $this->_uid;
$dmsVersionToSave['insertamum'] = date('Y-m-d H:i:s');
return $this->_ci->DmsVersionModel->insert($dmsVersionToSave);
}
}
private function _getUniqueFilename($filename)
{
$uniqueFilename = uniqid();
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
if (!isEmptyString($fileExtension))
$uniqueFilename .= '.'.$fileExtension;
return $uniqueFilename;
}
}
+74 -50
View File
@@ -62,17 +62,17 @@ class IssuesLib
* @param array $fehlertext_params params for sprint replace of error text in system.tbl_fehler
* @return object success or error
*/
public function addFhcIssue($fehler_kurzbz, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null)
public function addFhcIssue($fehler_kurzbz, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $resolution_params = null)
{
$fehlerRes = $this->_ci->FehlerModel->loadWhere(array('fehler_kurzbz' => $fehler_kurzbz));
if (hasData($fehlerRes))
{
$fehlercode = getData($fehlerRes)[0]->fehlercode;
return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params);
return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params);
}
else
return error("Fehler $fehler_kurzbz nicht gefunden");
return error("Error $fehler_kurzbz not found");
}
/**
@@ -82,13 +82,13 @@ class IssuesLib
* @param int $person_id
* @param int $oe_kurzbz
* @param array $fehlertext_params params for replacement of parts of error text
* @param bool $force_predefined if true, only predefined external issues are added
* @param bool $force_predefined if true, only predefined (with entry in fehler table) external issues are added
* @return object success or error
*/
public function addExternalIssue($fehlercode_extern, $inhalt_extern, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $force_predefined = false)
public function addExternalIssue($fehlercode_extern, $inhalt_extern, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null/* $resolve_params = null*//*, $force_predefined = false*/)
{
if (isEmptyString($fehlercode_extern))
return error("fehlercode_extern fehlt");
return error("fehlercode_extern missing");
// get external fehlercode (unique for each app)
$this->_ci->FehlerModel->addSelect('fehlercode');
@@ -102,19 +102,18 @@ class IssuesLib
if (isError($fehlerRes))
return $fehlerRes;
$fehlerData = getData($fehlerRes)[0];
// check if there is a predefined custom error for the external issue
if (hasData($fehlerRes))
{
$fehlerData = getData($fehlerRes)[0];
// if found, use the code
$fehlercode = $fehlerData->fehlercode;
}
elseif ($force_predefined === true)
/*elseif ($force_predefined === true)
{
// only added if predefined
return success("No definition found - not added");
}
return success("Keine Definition gefunden - Issue nicht hinzugefügt");
}*/
else
{
// if predefined error is not found, insert with fallback code
@@ -122,20 +121,52 @@ class IssuesLib
}
// add external issue
return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params, $fehlercode_extern, $inhalt_extern);
return $this->_addIssue($fehlercode, $person_id, $oe_kurzbz, $fehlertext_params, null, $fehlercode_extern, $inhalt_extern);
}
public function setBehoben($issue_id, $user)
{
$data = array(
'status_kurzbz' => self::STATUS_BEHOBEN,
'verarbeitetvon' => $user,
'verarbeitetamum' => date('Y-m-d H:i:s')
);
return $this->_changeIssueStatus($issue_id, $data, $user);
}
public function setInBearbeitung($issue_id, $user)
{
$data = array(
'status_kurzbz' => self::STATUS_IN_BEARBEITUNG,
'verarbeitetvon' => $user
);
return $this->_changeIssueStatus($issue_id, $data, $user);
}
public function setNeu($issue_id, $user)
{
$data = array(
'status_kurzbz' => self::STATUS_NEU,
'verarbeitetvon' => null,
'verarbeitetamum' => null
);
return $this->_changeIssueStatus($issue_id, $data, $user);
}
/**
* Changes status of an issue.
* @param int $issue_id
* @param string $status_kurzbz the new status
* @param string $verarbeitetvon uid of person changing the status (needed for in Bearbeitung and behoben)
* @param array $sdata the data to save, including status
* @param string $user uid of person changing the status (needed for in Bearbeitung and behoben)
* @return success or error
*/
public function changeIssueStatus($issue_id, $status_kurzbz, $verarbeitetvon = null)
private function _changeIssueStatus($issue_id, $data, $user)
{
if (!isset($issue_id) || !is_numeric($issue_id))
return error("Issue Id muss korrekt gesetzt sein.");
return error("Issue Id must be set correctly.");
// check if given status is same as existing
$this->_ci->IssueModel->addSelect('status_kurzbz');
@@ -143,39 +174,14 @@ class IssuesLib
if (hasData($currStatus))
{
if (getData($currStatus)[0]->status_kurzbz == $status_kurzbz)
return success("Gleicher Status bereits gesetzt");
if (getData($currStatus)[0]->status_kurzbz == $data['status_kurzbz'])
return success("Same status already set");
}
else
return error("Fehler beim Holen des Status");
return error("Error when getting status");
$data = array(
'status_kurzbz' => $status_kurzbz,
'updatevon' => $verarbeitetvon,
'updateamum' => date('Y-m-d H:i:s')
);
if ($status_kurzbz == self::STATUS_NEU)
{
$data['verarbeitetvon'] = null;
}
if ($status_kurzbz == self::STATUS_NEU || $status_kurzbz == self::STATUS_IN_BEARBEITUNG)
{
$data['verarbeitetamum'] = null;
}
if ($status_kurzbz == self::STATUS_IN_BEARBEITUNG || $status_kurzbz == self::STATUS_BEHOBEN)
{
if (isset($verarbeitetvon))
$data['verarbeitetvon'] = $verarbeitetvon;
else
return error("Verarbeitetvon nicht gesetzt");
}
if ($status_kurzbz == self::STATUS_BEHOBEN)
$data['verarbeitetamum'] = date('Y-m-d H:i:s');
$data['updatevon'] = $user;
$data['updateamum'] = date('Y-m-d H:i:s');
return $this->_ci->IssueModel->update(
array(
@@ -191,14 +197,15 @@ class IssuesLib
* @param int $person_id
* @param string $oe_kurzbz
* @param array $fehlertext_params
* @param string $resolution_params
* @param string $fehlercode_extern
* @param string $inhalt_extern
* @return object success or error
*/
private function _addIssue($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $fehlercode_extern = null, $inhalt_extern = null)
private function _addIssue($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlertext_params = null, $resolution_params = null, $fehlercode_extern = null, $inhalt_extern = null)
{
if (isEmptyString($person_id) && isEmptyString($oe_kurzbz))
return error("Person_id oder oe_kurzbz muss gesetzt sein.");
return error("Person_id or oe_kurzbz must be set.");
// get fehlertextVorlage and replace it with params
$fehlerRes = $this->_ci->FehlerModel->load($fehlercode);
@@ -218,6 +225,22 @@ class IssuesLib
if ($openIssueCount == 0)
{
var_dump($resolution_params);
if (isset($resolution_params))
{
if (is_array($resolution_params))
{
foreach ($resolution_params as $resolution_key => $resolution_param)
{
if (!is_string($resolution_key))
return error("Invalid parameter for resolution, must be an associative array");
}
}
else
return error("Invalid parameters for resolution");
}
return $this->_ci->IssueModel->insert(
array(
'fehlercode' => $fehlercode,
@@ -228,6 +251,7 @@ class IssuesLib
'oe_kurzbz' => $oe_kurzbz,
'datum' => date('Y-m-d H:i:s'),
'status_kurzbz' => self::STATUS_NEU,
'behebung_parameter' => isset($resolution_params) ? json_encode($resolution_params) : null,
'insertvon' => $this->_insertvon
)
);
@@ -236,9 +260,9 @@ class IssuesLib
return success($openIssueCount);
}
else
return error("Anzahl offener Issues konnte nicht ermittelt werden.");
return error("Number of open issues could not be determined");
}
else
return error("Fehler $fehlercode nicht gefunden");
return error("Error $fehlercode could not be found");
}
}
@@ -0,0 +1,31 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Bisio Zweck does not exist
*/
class CORE_INOUT_0001 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
return error('Bisio Id missing');
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('codex/Bisiozweck_model', 'BisiozweckModel');
// get all bisio Zwecke
$this->_ci->BisiozweckModel->addSelect('1');
$bisiozweckRes = $this->_ci->BisiozweckModel->loadWhere(array('bisio_id' => $params['bisio_id']));
if (isError($bisiozweckRes))
return $bisiozweckRes;
if (hasData($bisiozweckRes))
return success(true); // resolved if bisio Zweck exists
else
return success(false); // not resolved if no bisio zweck
}
}
@@ -0,0 +1,34 @@
<?php
/**
* More than one Zweck for incoming
*/
class CORE_INOUT_0002 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
return error('Bisio Id missing');
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('codex/Bisiozweck_model', 'BisiozweckModel');
// get all bisio Zwecke
$this->_ci->BisiozweckModel->addSelect('1');
$bisiozweckRes = $this->_ci->BisiozweckModel->loadWhere(array('bisio_id' => $params['bisio_id']));
if (isError($bisiozweckRes))
return $bisiozweckRes;
if (hasData($bisiozweckRes))
{
if (count(getData($bisiozweckRes)) <= 1) // resolved if one bisio Zweck
return success(true);
else
return success(false); // otherwise not resolved
}
else
return success(true); // resolved if no bisio zweck
}
}
@@ -0,0 +1,39 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Invalid Zweck for incoming
*/
class CORE_INOUT_0003 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
return error('Bisio Id missing');
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('codex/Bisiozweck_model', 'BisiozweckModel');
// get all Zwecke
$this->_ci->BisiozweckModel->addSelect('zweck_code');
$bisiozweckRes = $this->_ci->BisiozweckModel->loadWhere(array('bisio_id' => $params['bisio_id']));
if (isError($bisiozweckRes))
return $bisiozweckRes;
if (hasData($bisiozweckRes))
{
$bisiozweckData = getData($bisiozweckRes);
// resolved if Zweck is 1, 2 or 3
if (count($bisiozweckData) == 1 && !in_array($bisiozweckData[0]->zweck_code, array(1, 2, 3)))
return success(false);
else
return success(true);
}
else
return success(true);
}
}
@@ -0,0 +1,57 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Aufenthaltsförderung must exist if certain length of outgoing stay is exceeded
*/
class CORE_INOUT_0004 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
return error('Bisio Id missing');
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('codex/Aufenthaltfoerderung_model', 'AufenthaltfoerderungModel');
// get all Zwecke
$this->_ci->AufenthaltfoerderungModel->addSelect('tbl_aufenthaltfoerderung.aufenthaltfoerderung_code');
$this->_ci->AufenthaltfoerderungModel->addJoin('bis.tbl_bisio_aufenthaltfoerderung', 'aufenthaltfoerderung_code');
$this->_ci->AufenthaltfoerderungModel->addOrder('tbl_aufenthaltfoerderung.aufenthaltfoerderung_code');
$bisioFoerderungRes = $this->_ci->AufenthaltfoerderungModel->loadWhere(array('bisio_id' => $params['bisio_id']));
if (isError($bisioFoerderungRes))
return $bisioFoerderungRes;
if (hasData($bisioFoerderungRes))
{
// resolved if Aufenthaltsfoerderung exists
return success(true);
}
else
{
$this->_ci->load->model('codex/Bisio_model', 'BisioModel');
// get Bisio Aufenthaltsdauer
$aufenthaltsdauerRes = $this->_ci->BisioModel->getAufenthaltsdauer($params['bisio_id']);
if (isError($aufenthaltsdauerRes))
return $aufenthaltsdauerRes;
if (hasData($aufenthaltsdauerRes))
{
$aufenthaltsdauer = getData($aufenthaltsdauerRes);
// check if stay >= 29 days. If yes and no Aufenthaltsfoerderung - not resolved
if ($aufenthaltsdauer >= 29)
return success(false);
else
return success(true);
}
else // no Aufenthaltsdauer - not resolved
return success(false);
}
}
}
@@ -0,0 +1,54 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ECTS angerechnet must exist for outgoing if longer stay
*/
class CORE_INOUT_0005 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
return error('Bisio Id missing');
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('codex/Bisio_model', 'BisioModel');
//$this->_ci->load->model('codex/Aufenthaltfoerderung_model', 'AufenthaltfoerderungModel');
// get all Zwecke
$this->_ci->BisioModel->addSelect('ects_angerechnet');
$bisioRes = $this->_ci->BisioModel->loadWhere(array('bisio_id' => $params['bisio_id']));
if (isError($bisioRes))
return $bisioRes;
if (hasData($bisioRes) && !isEmptyString(getData($bisioRes)[0]->ects_angerechnet))
{
// resolved if ects exists
return success(true);
}
else
{
// get Bisio Aufenthaltsdauer
$aufenthaltsdauerRes = $this->_ci->BisioModel->getAufenthaltsdauer($params['bisio_id']);
if (isError($aufenthaltsdauerRes))
return $aufenthaltsdauerRes;
if (hasData($aufenthaltsdauerRes))
{
$aufenthaltsdauer = getData($aufenthaltsdauerRes);
// check if stay >= 29 days. If yes and no ects - not resolved
if ($aufenthaltsdauer >= 29)
return success(false);
else
return success(true);
}
else // no Aufenthaltsdauer - not resolved
return success(false);
}
}
}
@@ -0,0 +1,54 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ECTS erworben must exist for outgoing if longer stay
*/
class CORE_INOUT_0006 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['bisio_id']) || !is_numeric($params['bisio_id']))
return error('Bisio Id missing');
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('codex/Bisio_model', 'BisioModel');
//$this->_ci->load->model('codex/Aufenthaltfoerderung_model', 'AufenthaltfoerderungModel');
// get all Zwecke
$this->_ci->BisioModel->addSelect('ects_erworben');
$bisioRes = $this->_ci->BisioModel->loadWhere(array('bisio_id' => $params['bisio_id']));
if (isError($bisioRes))
return $bisioRes;
if (hasData($bisioRes) && !isEmptyString(getData($bisioRes)[0]->ects_erworben))
{
// resolved if ects exists
return success(true);
}
else
{
// get Bisio Aufenthaltsdauer
$aufenthaltsdauerRes = $this->_ci->BisioModel->getAufenthaltsdauer($params['bisio_id']);
if (isError($aufenthaltsdauerRes))
return $aufenthaltsdauerRes;
if (hasData($aufenthaltsdauerRes))
{
$aufenthaltsdauer = getData($aufenthaltsdauerRes);
// check if stay >= 29 days. If yes and no ects - not resolved
if ($aufenthaltsdauer >= 29)
return success(false);
else
return success(true);
}
else // no Aufenthaltsdauer - not resolved
return success(false);
}
}
}
@@ -0,0 +1,42 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ZGV Datum in future
*/
class CORE_ZGV_0001 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
return error('Prestudent Id missing');
$this->_ci =& get_instance(); // get code igniter instance
// get zgvdatum of prestudent
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->_ci->PrestudentModel->addSelect('zgvdatum');
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
if (isError($prestudentRes))
return $prestudentRes;
if (hasData($prestudentRes))
{
$zgvdatum = getData($prestudentRes)[0]->zgvdatum;
if (isEmptyString($zgvdatum))
return success(false);
// check if zgvdatum comes after today
if ($zgvdatum > date('Y-m-d'))
return success(false);
else
return success(true);
}
else
return success(false);
}
}
@@ -0,0 +1,50 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ZGV Datum must be after Geburtsdatum
*/
class CORE_ZGV_0002 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
return error('Prestudent Id missing');
$this->_ci =& get_instance(); // get code igniter instance
// get zgvdatum of prestudent
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->_ci->PrestudentModel->addSelect('zgvdatum, gebdatum');
$this->_ci->PrestudentModel->addJoin('public.tbl_person', 'person_id');
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
if (isError($prestudentRes))
return $prestudentRes;
if (hasData($prestudentRes))
{
$prestudentData = getData($prestudentRes)[0];
$zgvdatum = $prestudentData->zgvdatum;
if (isEmptyString($zgvdatum))
return success(false);
$gebdatum = $prestudentData->gebdatum;
if (isEmptyString($gebdatum))
return success(false);
// check if zgvdatum comes before geburtsdatum
if ($zgvdatum < $gebdatum)
return success(false);
else
return success(true);
}
else
return success(false);
}
}
@@ -0,0 +1,42 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ZGV master Datum in future
*/
class CORE_ZGV_0003 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
return error('Prestudent Id missing');
$this->_ci =& get_instance(); // get code igniter instance
// get zgvdatum of prestudent
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->_ci->PrestudentModel->addSelect('zgvmadatum');
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
if (isError($prestudentRes))
return $prestudentRes;
if (hasData($prestudentRes))
{
$zgvdatum = getData($prestudentRes)[0]->zgvmadatum;
if (isEmptyString($zgvdatum))
return success(false);
// check if zgvdatum comes after today
if ($zgvdatum > date('Y-m-d'))
return success(false);
else
return success(true);
}
else
return success(false);
}
}
@@ -0,0 +1,50 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ZGV Datum should not be after ZGV master Datum
*/
class CORE_ZGV_0004 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
return error('Prestudent Id missing');
$this->_ci =& get_instance(); // get code igniter instance
// get zgvdatum of prestudent
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->_ci->PrestudentModel->addSelect('zgvdatum, zgvmadatum');
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
if (isError($prestudentRes))
return $prestudentRes;
if (hasData($prestudentRes))
{
$prestudentData = getData($prestudentRes)[0];
// get and compare zgvdatum and zgvmadatum
$zgvdatum = $prestudentData->zgvdatum;
if (isEmptyString($zgvdatum))
return success(false);
$zgvmadatum = $prestudentData->zgvmadatum;
if (isEmptyString($zgvmadatum))
return success(false);
// check if zgvmadatum comes after zgvdatum
if ($zgvmadatum < $zgvdatum)
return success(false);
else
return success(true);
}
else
return success(false);
}
}
@@ -0,0 +1,50 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ZGV master Datum before Geburtsdatum
*/
class CORE_ZGV_0005 implements IIssueResolvedChecker
{
public function checkIfIssueIsResolved($params)
{
if (!isset($params['prestudent_id']) || !is_numeric($params['prestudent_id']))
return error('Prestudent Id missing');
$this->_ci =& get_instance(); // get code igniter instance
// get zgvdatum and geburtsdatum of prestudent
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->_ci->PrestudentModel->addSelect('zgvmadatum, gebdatum');
$this->_ci->PrestudentModel->addJoin('public.tbl_person', 'person_id');
$prestudentRes = $this->_ci->PrestudentModel->load($params['prestudent_id']);
if (isError($prestudentRes))
return $prestudentRes;
if (hasData($prestudentRes))
{
$prestudentData = getData($prestudentRes)[0];
$zgvdatum = $prestudentData->zgvmadatum;
if (isEmptyString($zgvdatum))
return success(false);
$gebdatum = $prestudentData->gebdatum;
if (isEmptyString($gebdatum))
return success(false);
// check if zgvdatum comes before geburtsdatum
if ($zgvdatum < $gebdatum)
return success(false);
else
return success(true);
}
else
return success(false);
}
}
+33
View File
@@ -11,4 +11,37 @@ class Bisio_model extends DB_Model
$this->dbTable = 'bis.tbl_bisio';
$this->pk = 'bisio_id';
}
/**
* Gets duration of stay in days by bisio_id.
* @param int $bisio_id
* @return object success with number of days or error
*/
public function getAufenthaltsdauer($bisio_id)
{
// get from and to date
$this->addSelect('von, bis');
$bisioRes = $this->load($bisio_id);
if (isError($bisioRes))
return $bisioRes;
if (hasData($bisioRes))
{
$bisioData = getData($bisioRes)[0];
$avon = $bisioData->von;
$abis = $bisioData->bis;
if (is_null($avon) || is_null($abis))
return success("Von or bis date not set");
$vonDate = new DateTime($avon);
$bisDate = new DateTime($abis);
$interval = $vonDate->diff($bisDate);
return success($interval->days);
}
else
return success("Bisio not found");
}
}
+1 -1
View File
@@ -165,7 +165,7 @@ class Person_model extends DB_Model
if (!hasData($person))
return success(null);
$this->KontaktModel->addSelect('kontakttyp, anmerkung, kontakt, zustellung');
$this->KontaktModel->addSelect('kontakt_id, kontakttyp, anmerkung, kontakt, zustellung');
$this->KontaktModel->addOrder('kontakttyp');
$this->KontaktModel->addOrder('insertamum', 'DESC');
$where = $zustellung_only === true ? array('person_id' => $person_id, 'zustellung' => true) : array('person_id' => $person_id);
+39
View File
@@ -12,6 +12,45 @@ class Issue_model extends DB_Model
$this->pk = 'issue_id';
}
/**
* Gets issues which are open, i.e. not resolved.
* @param array $fehlercodes only issues for given fehler are retrieved
* @param int $person_id
* @param string $oe_kurzbz
* @param string $fehlercode_extern
* @return object success with issues or error
*/
public function getOpenIssues($fehlercodes, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null)
{
$params = array($fehlercodes);
// issue exists for a fehlercode (or fehlercode_extern), person_id, oe_kurzbz, if not verarbeitet yet
$qry = 'SELECT issue_id, fehlercode, inhalt, fehlercode_extern, inhalt_extern, person_id, oe_kurzbz,
behebung_parameter, datum, verarbeitetvon, verarbeitetamum
FROM system.tbl_issue
WHERE fehlercode IN ?
AND verarbeitetamum IS NULL';
if (!isEmptyString($fehlercode_extern))
{
$qry .= ' AND fehlercode_extern = ?';
$params[] = $fehlercode_extern;
}
if (isset($person_id))
{
$qry .= ' AND person_id = ?';
$params[] = $person_id;
}
if (isset($oe_kurzbz))
{
$qry .= ' AND oe_kurzbz = ?';
$params[] = $oe_kurzbz;
}
return $this->execQuery($qry, $params);
}
/**
* Gets number of open (non-resolved) issues.
* @param string $fehlercode unique error code
+2
View File
@@ -107,10 +107,12 @@ var IssuesDataset = {
{
successCallback: function(data, textStatus, jqXHR) {
if (FHC_AjaxClient.isError(data))
{
FHC_DialogLib.alertError(
FHC_PhrasesLib.t("fehlermonitoring", "statusAendernFehler") + ": "
+ FHC_AjaxClient.getError(data)
);
}
else if (FHC_AjaxClient.hasData(data))
{
FHC_FilterWidget.reloadDataset();
+10
View File
@@ -83,6 +83,16 @@ echo '<div>';
require_once('filtersupdate.php');
echo '</div>';
// ******** fehlerupdate ************/
echo '<H2>Issues time!</H2>';
echo '<div>';
echo 'fehlerupdate.php wird aufgerufen...';
echo '</div>';
echo '<div>';
require_once('fehlerupdate.php');
echo '</div>';
// ******** Berechtigungen Prüfen ************/
echo '<h2>Berechtigungen pruefen</h2>';
+10
View File
@@ -5713,6 +5713,16 @@ if ($result = $db->db_query("SELECT * FROM pg_class WHERE relname='idx_tbl_zeita
}
}
// Add column parameterFuerBehebung to system.tbl_issue
if(!$result = @$db->db_query("SELECT behebung_parameter FROM system.tbl_issue LIMIT 1"))
{
$qry = 'ALTER TABLE system.tbl_issue ADD COLUMN behebung_parameter JSONB;';
if(!$db->db_query($qry))
echo '<strong>system.tbl_issue: '.$db->db_last_error().'</strong><br>';
else
echo '<br>Added column behebung_parameter to table system.tbl_issue';
}
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
+173
View File
@@ -0,0 +1,173 @@
<?php
/**
* Copyright (C) 2013 FH Technikum-Wien
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
// Array of fehler to be added in the database
$fehlerArr = array(
array(
'fehlercode' => 'CORE_ZGV_0001',
'fehler_kurzbz' => 'zgvDatumInZukunft',
'fehlercode_extern' => null,
'fehlertext' => 'ZGV Datum in Zukunft',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_ZGV_0002',
'fehler_kurzbz' => 'zgvDatumVorGeburtsdatum',
'fehlercode_extern' => null,
'fehlertext' => 'ZGV Datum vor Geburtsdatum',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_ZGV_0003',
'fehler_kurzbz' => 'zgvMasterDatumInZukunft',
'fehlercode_extern' => null,
'fehlertext' => 'ZGV Masterdatum in Zukunft',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_ZGV_0004',
'fehler_kurzbz' => 'zgvMasterDatumVorZgvdatum',
'fehlercode_extern' => null,
'fehlertext' => 'ZGV Masterdatum vor Zgvdatum',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_ZGV_0005',
'fehler_kurzbz' => 'zgvMasterDatumVorGeburtsdatum',
'fehlercode_extern' => null,
'fehlertext' => 'ZGV Masterdatum vor Geburtsdatum',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_INOUT_0001',
'fehler_kurzbz' => 'keinAufenthaltszweckPlausi',
'fehlercode_extern' => null,
'fehlertext' => 'Kein Aufenthaltszweck gefunden',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_INOUT_0002',
'fehler_kurzbz' => 'zuVieleZweckeIncomingPlausi',
'fehlercode_extern' => null,
'fehlertext' => 'Es sind %s Aufenthaltszwecke eingetragen (max. 1 Zweck für Incomings)',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_INOUT_0003',
'fehler_kurzbz' => 'falscherIncomingZweckPlausi',
'fehlercode_extern' => null,
'fehlertext' => 'Aufenthaltszweckcode ist %s (für Incomings ist nur Zweck 1, 2, 3 erlaubt)',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_INOUT_0004',
'fehler_kurzbz' => 'outgoingAufenthaltfoerderungfehltPlausi',
'fehlercode_extern' => null,
'fehlertext' => 'Keine Aufenthaltsfoerderung angegeben (bei Outgoings >= 29 Tage Monat im Ausland muss mind. 1 gemeldet werden)',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_INOUT_0005',
'fehler_kurzbz' => 'outgoingAngerechneteEctsFehlenPlausi',
'fehlercode_extern' => null,
'fehlertext' => 'Angerechnete ECTS fehlen (Meldepflicht bei Outgoings >= 29 Tage Monat im Ausland)',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
),
array(
'fehlercode' => 'CORE_INOUT_0006',
'fehler_kurzbz' => 'outgoingErworbeneEctsFehlenPlausi',
'fehlercode_extern' => null,
'fehlertext' => 'Erworbene ECTS fehlen (Meldepflicht bei Outgoings >= 29 Tage Monat im Ausland)',
'fehlertyp_kurzbz' => 'error',
'app' => 'core'
)
);
// Loop through the filters array
for ($fehlerCounter = 0; $fehlerCounter < count($fehlerArr); $fehlerCounter++)
{
$fehler = $fehlerArr[$fehlerCounter]; // single fehler definition
// add optional fields
$optional_fields = array('fehlercode_extern');
foreach ($optional_fields as $optional_field)
{
if (!array_key_exists($optional_field, $fehler))
$fehler[$optional_field] = null;
}
// If it's an array and contains the required fields
if (is_array($fehler)
&& isset($fehler['fehlercode']) && isset($fehler['fehler_kurzbz'])
&& isset($fehler['fehlertext']) && isset($fehler['fehlertyp_kurzbz'])
&& isset($fehler['app']))
{
$selectFehlerQuery = 'SELECT 1
FROM system.tbl_fehler
WHERE fehlercode = '.$db->db_add_param($fehler['fehlercode']);
// If no error occurred while loading a fehler from the DB
if ($dbFehlerDefinition = @$db->db_query($selectFehlerQuery))
{
// If NO filters were loaded: insert
if ($db->db_num_rows($dbFehlerDefinition) == 0)
{
$insertFehlerQuery = 'INSERT INTO system.tbl_fehler (
fehlercode,
fehler_kurzbz,
fehlercode_extern,
fehlertext,
fehlertyp_kurzbz,
app
) VALUES (
'.$db->db_add_param($fehler['fehlercode']).',
'.$db->db_add_param($fehler['fehler_kurzbz']).',
'.$db->db_add_param($fehler['fehlercode_extern']).',
'.$db->db_add_param($fehler['fehlertext']).',
'.$db->db_add_param($fehler['fehlertyp_kurzbz']).',
'.$db->db_add_param($fehler['app']).'
)';
if (!@$db->db_query($insertFehlerQuery)) // checks query execution
{
echo '<strong>An error occurred while inserting fehler: '.$db->db_last_error().'</strong><br>';
}
else
{
echo 'Fehler added: '.$fehler['fehlercode'].' - '.$fehler['fehler_kurzbz'].'<br>';
}
}
}
else // otherwise if errors occurred
{
echo '<strong>An error occurred while inserting fehler: '.$db->db_last_error().'</strong><br>';
}
}
}