Merge branch 'feature-16190/Issues_automatisches_Beheben'

This commit is contained in:
Andreas Österreicher
2022-02-28 13:23:09 +01:00
24 changed files with 1075 additions and 65 deletions
+28
View File
@@ -0,0 +1,28 @@
<?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
// structure: fehlercode => class (library) name for resolving
$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,42 @@ 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
{
$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 +154,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
*/
public function checkIfIssueIsResolved($params);
}
+119
View File
@@ -0,0 +1,119 @@
<?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';
const CHECK_ISSUE_RESOLVED_METHOD_NAME = 'checkIfIssueIsResolved';
protected $_codeLibMappings;
public function __construct()
{
parent::__construct();
$this->load->model('system/Issue_model', 'IssueModel');
$this->load->library('IssuesLib');
}
/**
* Initializes issue resolution.
*/
public function run()
{
$this->logInfo("Issue resolve job started");
// 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));
}
else
{
// log info if no data found
if (!hasData($openIssuesRes))
{
$this->logInfo("No open issues found");
}
else
{
$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_id' => $issue->issue_id, '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, otherwise it is the core library folder
$libRootPath = isset($this->_extensionName) ? 'extensions/' . $this->_extensionName . '/' : '';
$issuesLibPath = $libRootPath . self::ISSUES_FOLDER . '/';
$issuesLibFilePath = DOC_ROOT . 'application/' . $libRootPath . 'libraries/' . self::ISSUES_FOLDER . '/' . $libName . '.php';
// check if library file exists
if (!file_exists($issuesLibFilePath))
{
// log error and continue with next issue if not
$this->logError("Issue library file " . $issuesLibFilePath . " does not exist");
continue;
}
// load library connected to fehlercode
$this->load->library(
$issuesLibPath . $libName
);
$lowercaseLibName = mb_strtolower($libName);
// check if method is defined in libary class
if (!is_callable(array($this->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
{
// log error and continue with next issue if not
$this->logError("Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName");
continue;
}
// call the function for checking for issue resolution
$issueResolvedRes = $this->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
if (isError($issueResolvedRes))
{
$this->logError(getError($issueResolvedRes));
}
else
{
$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");
}
}
}
}
}
}
$this->logInfo("Issue resolve job ended");
}
}
+87 -52
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)
{
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,13 @@ 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)
{
// only added if predefined
return success("No definition found - not added");
}
else
{
// if predefined error is not found, insert with fallback code
@@ -122,20 +116,70 @@ 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);
}
/**
* Set issue to resolved.
* @param int $issue_id
* @param string $user uid of issue resolver
* @return object success or error
*/
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);
}
/**
* Set issue to in progress.
* @param int $issue_id
* @param string $user uid of issue resovler
* @return object success or error
*/
public function setInBearbeitung($issue_id, $user)
{
$data = array(
'status_kurzbz' => self::STATUS_IN_BEARBEITUNG,
'verarbeitetvon' => $user
);
return $this->_changeIssueStatus($issue_id, $data, $user);
}
/**
* Set issue to new.
* @param int $issue_id
* @param string $user uid of issue resolver
* @return object success or error
*/
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 +187,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 +210,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 +238,20 @@ class IssuesLib
if ($openIssueCount == 0)
{
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 +262,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 +271,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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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,53 @@
<?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, issue_id: '.$params['issue_id']);
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('codex/Bisio_model', 'BisioModel');
// 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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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, issue_id: '.$params['issue_id']);
$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>';
+11 -1
View File
@@ -5955,6 +5955,16 @@ if ($result = $db->db_query("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABL
}
}
// 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>';
@@ -6223,7 +6233,7 @@ $tabellen=array(
"system.tbl_fehler" => array("fehlercode","fehler_kurzbz","fehlercode_extern","fehlertext","fehlertyp_kurzbz","app"),
"system.tbl_fehlertyp" => array("fehlertyp_kurzbz","bezeichnung_mehrsprachig"),
"system.tbl_fehler_zustaendigkeiten" => array("fehlerzustaendigkeiten_id","fehlercode","person_id","oe_kurzbz","funktion_kurzbz"),
"system.tbl_issue" => array("issue_id","fehlercode","fehlercode_extern","inhalt","inhalt_extern","person_id","oe_kurzbz","datum","verarbeitetvon","verarbeitetamum","status_kurzbz","insertvon","insertamum","updatevon","updateamum"),
"system.tbl_issue" => array("issue_id","fehlercode","fehlercode_extern","inhalt","inhalt_extern","person_id","oe_kurzbz","datum","verarbeitetvon","verarbeitetamum","status_kurzbz","behebung_parameter","insertvon","insertamum","updatevon","updateamum"),
"system.tbl_issue_status" => array("status_kurzbz","bezeichnung_mehrsprachig"),
"system.tbl_log" => array("log_id","person_id","zeitpunkt","app","oe_kurzbz","logtype_kurzbz","logdata","insertvon","taetigkeit_kurzbz"),
"system.tbl_logtype" => array("logtype_kurzbz", "data_schema"),
+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>';
}
}
}
+28 -5
View File
@@ -903,9 +903,9 @@ $filters = array(
],
"filters": [
{
"name": "Fehlerstatus",
"name": "Statuscode",
"operation": "ncontains",
"condition": "behoben"
"condition": "resolved"
},
{
"name": "Hauptzuständig",
@@ -964,7 +964,8 @@ $filters = array(
{"name": "Nachname"},
{"name": "PersonId"},
{"name": "Fehlerstatus"},
{"name": "Verarbeitet von"}
{"name": "Verarbeitet von"},
{"name": "Verarbeitet am"}
],
"filters": [
{
@@ -974,14 +975,36 @@ $filters = array(
"option": "days"
},
{
"name": "Fehlerstatus",
"name": "Statuscode",
"operation": "contains",
"condition": "behoben"
"condition": "resolved"
}
]
}
',
'oe_kurzbz' => null,
),
array(
'app' => 'core',
'dataset_name' => 'overview',
'filter_kurzbz' => 'DVUHStorno',
'description' => '{DVUH Storno Übersicht}',
'sort' => 1,
'default_filter' => true,
'filter' => '
{
"name": "DVUHStorno",
"columns": [
{"name": "vorname"},
{"name": "nachname"},
{"name": "matrikelnummer"},
{"name": "studiengang"},
{"name": "studiensemester"}
],
"filters": []
}
',
'oe_kurzbz' => null,
)
);