diff --git a/application/controllers/jobs/TagJob.php b/application/controllers/jobs/TagJob.php index 9db55c929..68bc35fe8 100644 --- a/application/controllers/jobs/TagJob.php +++ b/application/controllers/jobs/TagJob.php @@ -56,7 +56,7 @@ class TagJob extends JOB_Controller require_once($filePath); } else { echo "File not found: " . $filePath . PHP_EOL; - continue; + continue; } $kurz_bz = $autoTag->typ_kurzbz; @@ -68,6 +68,8 @@ class TagJob extends JOB_Controller $outputArray = $obj->getZuordnungIds(['studiensemester_kurzbz' => $studiensemester_kurzbz]); $data = $outputArray->data; + print_r($kurz_bz . " " . $autoTag->taglib); + $result = $this->taglib->updateAutomatedTags($kurz_bz, $data); $data = $result->retval; @@ -80,7 +82,6 @@ class TagJob extends JOB_Controller print_r(PHP_EOL . "Count Added: ". $result->retval['summary']['added']); print_r(PHP_EOL . "Count Deleted: ". $result->retval['summary']['deleted']); print_r(PHP_EOL); - } print_r( PHP_EOL . "End Job rebuild" . PHP_EOL); diff --git a/application/core/Tag_Controller.php b/application/core/Tag_Controller.php index 44fd06891..a631639e5 100644 --- a/application/core/Tag_Controller.php +++ b/application/core/Tag_Controller.php @@ -20,7 +20,7 @@ class Tag_Controller extends FHCAPI_Controller 'doneTag' => self::BERECHTIGUNG_KURZBZ, 'deleteTag' => self::BERECHTIGUNG_KURZBZ, 'getAllTags' => self::BERECHTIGUNG_KURZBZ, - 'rebuildTagsPrestudent' => self::BERECHTIGUNG_KURZBZ, + 'rebuildTagsForTypeId' => self::BERECHTIGUNG_KURZBZ, ]; $merged_permissions = array_merge($default_permissions, $permissions); @@ -337,11 +337,12 @@ class Tag_Controller extends FHCAPI_Controller $this->terminateWithSuccess(hasData($notiz) ? getData($notiz) : array()); } - public function rebuildTagsPrestudent() + public function rebuildTagsForTypeId() { - $prestudent_id = $this->input->get('prestudent_id'); + $id = $this->input->get('id'); + $typeId = $this->input->get('typeId'); - $result = $this->taglib->rebuildTagsForPrestudent($prestudent_id); + $result = $this->taglib->rebuildTagsForTypeId($typeId, $id); if (isError($result)) return error ('Error occurred during updateAutomatedTags'); diff --git a/application/libraries/TagLib.php b/application/libraries/TagLib.php index 721215965..d49843ad9 100644 --- a/application/libraries/TagLib.php +++ b/application/libraries/TagLib.php @@ -17,7 +17,6 @@ use \stdClass as stdClass; class TagLib { const BATCHUSER = 'sftest'; - const TYP_ZUORDNUNG = 'prestudent_id'; /** * Object initialization @@ -47,7 +46,8 @@ class TagLib $params array expected pattern [ [ - 'prestudent_id' => 123456, + 'id' => 123456, + 'typeId' => 123456, 'von' => '2026-04-01', 'bis' => '2026-06-30' ], @@ -64,7 +64,8 @@ class TagLib //TODO(Manu) check minimal input: foreach ($inputData as $row) { - $pid = $row['prestudent_id']; + $pid = $row['id']; + $typeId = $row['typeId']; $prestudentIds[] = $pid; @@ -81,7 +82,7 @@ class TagLib $allTags = []; $this->_ci->NotizModel->addSelect('nz.notiz_id'); - $this->_ci->NotizModel->addSelect('prestudent_id'); + $this->_ci->NotizModel->addSelect($typeId); $this->_ci->NotizModel->addJoin('public.tbl_notizzuordnung nz', 'notiz_id'); $resultAllTags = $this->_ci->NotizModel->loadWhere([ @@ -92,7 +93,7 @@ class TagLib if (!empty($allTagsData)) { foreach ($allTagsData as $row) { - $allTags[$row->prestudent_id] = $row->notiz_id; + $allTags[$row->$typeId] = $row->notiz_id; } } @@ -171,7 +172,7 @@ class TagLib $resultZuordnung = $this->_ci->NotizzuordnungModel->insert([ 'notiz_id' => $notizId, - self::TYP_ZUORDNUNG => $pid + $typeId => $pid ]); if (isError($resultZuordnung)) { @@ -237,79 +238,7 @@ class TagLib ]); } - public function updateAutomatedTagsForPrestudent_DEPR($tag, $prestudent_id) - { - $_ci = get_instance(); - $_ci->addMeta( - 'IN OLD FUNCTION updateTags', $tag - ); - $return = null; - $notiz_id = null; - - //von und bis auslesen - - - $this->_ci->NotizModel->addSelect('nz.notiz_id'); - $this->_ci->NotizModel->addSelect('prestudent_id'); - $this->_ci->NotizModel->addJoin('public.tbl_notizzuordnung nz', 'notiz_id'); - $resultAllTags = $this->_ci->NotizModel->loadWhere([ - 'typ' => $tag, - 'prestudent_id' => $prestudent_id - ]); - if(hasData($resultAllTags)) - { - $notiz_id = $resultAllTags->retval[0]->notiz_id; - } - - //RECYCLE - if ($notiz_id !== null) - { - //TODO(Manu) refactor for recycle, add - $resultUpdateNotiz = $this->_ci->NotizModel->update( - [ - 'notiz_id' => $notiz_id - ], - array( - 'updateamum' => date('Y-m-d H:i:s'), - 'updatevon' => getAuthUID(), - )); - - if (isError($resultUpdateNotiz)) - return error ('Error occurred update Result ' . $notiz_id); - - $return = ['recycled' => $notiz_id]; - } - else - - { - //TODO(Manu) refactor for recycle, add - $resultInsertNotiz = $this->_ci->NotizModel->insert(array( - 'titel' => 'TAG', - 'text' => 'AUTOMATED TAG', - 'verfasser_uid' => getAuthUID(), - 'erledigt' => false, - 'insertamum' => date('Y-m-d H:i:s'), - 'insertvon' => getAuthUID(), - 'typ' => $tag - )); - - if (isError($resultInsertNotiz)) - return error ('Error occurred insert Result ' . $prestudent_id); - - $resultInsertZuordnung = $this->_ci->NotizzuordnungModel->insert(array( - 'notiz_id' => $resultInsertNotiz->retval, - self::TYP_ZUORDNUNG => $prestudent_id - )); - - if (isError($resultInsertZuordnung)) - return error ('Error occurred insert Zuordnung' . $prestudent_id); - - $return = ['added' => $resultInsertNotiz->retval]; - } - return success($return); - } - - public function updateAutomatedTagsForPrestudent(array $params) + public function updateAutomatedTagsForTypeId(array $params) { $return = null; $notiz_id = null; @@ -317,14 +246,15 @@ class TagLib $von = $params['von']; $bis = $params['bis']; $tag = $params['kurzbz']; - $prestudent_id = $params['prestudent_id']; + $id = $params['id']; + $typeId = $params['typeId']; $this->_ci->NotizModel->addSelect('nz.notiz_id'); - $this->_ci->NotizModel->addSelect('prestudent_id'); + $this->_ci->NotizModel->addSelect($typeId); $this->_ci->NotizModel->addJoin('public.tbl_notizzuordnung nz', 'notiz_id'); $resultAllTags = $this->_ci->NotizModel->loadWhere([ 'typ' => $tag, - 'prestudent_id' => $prestudent_id + $typeId => $id ]); if(hasData($resultAllTags)) { @@ -334,7 +264,6 @@ class TagLib //RECYCLE if ($notiz_id !== null) { - //TODO(Manu) refactor for recycle, add $resultUpdateNotiz = $this->_ci->NotizModel->update( [ 'notiz_id' => $notiz_id @@ -369,25 +298,26 @@ class TagLib $resultInsertZuordnung = $this->_ci->NotizzuordnungModel->insert(array( 'notiz_id' => $resultInsertNotiz->retval, - self::TYP_ZUORDNUNG => $prestudent_id + $typeId => $id )); if (isError($resultInsertZuordnung)) - return error ('Error occurred insert Zuordnung' . $prestudent_id); - + return error ('Error occurred insert Zuordnung ' . $id); $return = ['added' => $resultInsertNotiz->retval]; } return success($return); } /* - * main function for rebuild Tags for single prestudent + * main function for rebuild Tags for typeId * */ - public function rebuildTagsForPrestudent($prestudent_id) + public function rebuildTagsForTypeId($typeId, $id) { $automatedTagsRes = $this->_ci->NotiztypModel->loadWhere(array('automatisiert' => true, 'taglib IS NOT NULL' => null)); $automatedTags = hasData($automatedTagsRes) ? getData($automatedTagsRes) : []; + $_ci = get_instance(); + $result = $this->_ci->StudiensemesterModel->getLastOrAktSemester(); if (isError($result)) return error('Error occurred during retrieving studiensemester'); @@ -395,7 +325,6 @@ class TagLib return error('No studiensemester found'); } $studiensemester_kurzbz = $result->retval[0]->studiensemester_kurzbz ?? null; - $return = []; foreach ($automatedTags as $autoTag) @@ -415,8 +344,10 @@ class TagLib $kurz_bz = $autoTag->typ_kurzbz; $obj = new $className(); + $criteriaIsSet = $obj->isCriteriaSetFor([ - 'prestudent_id' => $prestudent_id, + 'typeId' => $typeId, + 'id' => $id, 'studiensemester_kurzbz' => $studiensemester_kurzbz ]); @@ -429,10 +360,11 @@ class TagLib 'von' => $von, 'bis' => $bis, 'kurzbz' => $autoTag->typ_kurzbz, - 'prestudent_id' => $prestudent_id + 'typeId' => $typeId, + 'id' => $id, ]; - $result = $this->updateAutomatedTagsForPrestudent($params); + $result = $this->updateAutomatedTagsForTypeId($params); if (isError($result)) return error('Error occurred during updateAutomatedTags' . $kurz_bz); @@ -440,7 +372,8 @@ class TagLib } else { - $result = $this->checkForDelete($kurz_bz, $prestudent_id); + $result = $this->checkForDelete($kurz_bz, $typeId, $id); + if ($result != null) $return[$kurz_bz] = $result; } @@ -448,25 +381,27 @@ class TagLib return success($return); } - public function checkForDelete($tag, $prestudent_id) + public function checkForDelete($tag, $typeId, $id) { $return = null; $notiz_id = null; - if (!is_numeric($prestudent_id)) - return error ("prestudent_id " . $prestudent_id . "not numeric"); + if (!is_numeric($id)) + return error ("id " . $id . "not numeric"); $this->_ci->NotizModel->addSelect('nz.notiz_id'); - $this->_ci->NotizModel->addSelect('prestudent_id'); + $this->_ci->NotizModel->addSelect($typeId); $this->_ci->NotizModel->addJoin('public.tbl_notizzuordnung nz', 'notiz_id'); $resultAllTags = $this->_ci->NotizModel->loadWhere([ 'typ' => $tag, - 'prestudent_id' => $prestudent_id + $typeId => $id ]); if(hasData($resultAllTags)) { $notiz_id = $resultAllTags->retval[0]->notiz_id; } + else + return null; if($notiz_id) { diff --git a/application/libraries/tags/CoreDoubleDegreeTagLib.php b/application/libraries/tags/CoreDoubleDegreeTagLib.php index 6de5b053d..264891c3d 100644 --- a/application/libraries/tags/CoreDoubleDegreeTagLib.php +++ b/application/libraries/tags/CoreDoubleDegreeTagLib.php @@ -19,7 +19,7 @@ class CoreDoubleDegreeTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -36,7 +36,8 @@ class CoreDoubleDegreeTagLib $doubledegree_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => $item->start, 'bis' => $item->ende ]; diff --git a/application/libraries/tags/CoreFiftyFiveTagLib.php b/application/libraries/tags/CoreFiftyFiveTagLib.php new file mode 100644 index 000000000..5d4990e5d --- /dev/null +++ b/application/libraries/tags/CoreFiftyFiveTagLib.php @@ -0,0 +1,92 @@ +ci = get_instance(); + $this->ci->load->model('person/Person_model', 'PersonModel'); + $this->ci-> load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + } + + public function getZuordnungIds(array $params) + { + if(!isset($params['studiensemester_kurzbz'])) + { + return (object) array( + 'person_id' => [] + ); + } + + $semester = $params['studiensemester_kurzbz']; + + $result = $this->ci->StudiensemesterModel->loadWhere(array( + 'studiensemester_kurzbz' => $semester + )); + $data = $result->retval[0]; + + $semVon = $data->start; + $semBis = $data->ende; + $result = $this->ci->PersonModel->getFiftyFivers($semVon, $semBis); + + $data = $result->retval; + $fiftyFiveData = array_map(function($item) { + return [ + 'id' => $item->person_id, + 'typeId' => 'person_id', + ]; + }, $data); + + return (object) array( + 'data' => $fiftyFiveData + ); + } + + public function isCriteriaSetFor(array $params) + { + if(!isset($params['person_id']) || !isset($params['studiensemester_kurzbz'])) + { + return false; + } + $semester = $params['studiensemester_kurzbz']; + $person_id = $params['id']; + $typeId = $params['typeId']; + + if($typeId != 'person_id') + return null; + + $result = $this->ci->StudiensemesterModel->loadWhere(array( + 'studiensemester_kurzbz' => $semester + )); + $data = $result->retval[0]; + + $semVon = $data->start; + $semBis = $data->ende; + $result = $this->ci->PersonModel->isFiftyFive($semVon, $semBis, $person_id); + + $data = $result->retval; + $fiftyFiveData = array_map(function($item) { + return [ + 'id' => $item->person_id, + 'typeId' => 'person_id', + ]; + }, $data); + + if(hasData($result)) + { + //array mit prestudent_id, von und bis + return $result; + } + else + return null; + } + +} + diff --git a/application/libraries/tags/CoreJgvTagLib.php b/application/libraries/tags/CoreJgvTagLib.php index 7342a38ff..479da7da0 100644 --- a/application/libraries/tags/CoreJgvTagLib.php +++ b/application/libraries/tags/CoreJgvTagLib.php @@ -19,7 +19,7 @@ class CoreJgvTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -31,7 +31,8 @@ class CoreJgvTagLib $jgv_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => $item->datum_von, 'bis' => $item->datum_bis ]; @@ -44,13 +45,11 @@ class CoreJgvTagLib public function isCriteriaSetFor(array $params) { - if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz'])) - { + if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id') return false; - } $semester = $params['studiensemester_kurzbz']; - $prestudent_id = $params['prestudent_id']; + $prestudent_id = $params['id']; $result = $this->ci->BenutzerfunktionModel->isJgv($semester, $prestudent_id); diff --git a/application/libraries/tags/CoreMissingZgvTagLib.php b/application/libraries/tags/CoreMissingZgvTagLib.php index 1ad87ab7a..73fa9021f 100644 --- a/application/libraries/tags/CoreMissingZgvTagLib.php +++ b/application/libraries/tags/CoreMissingZgvTagLib.php @@ -19,7 +19,7 @@ class CoreMissingZgvTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -39,7 +39,8 @@ class CoreMissingZgvTagLib $zgvmissing_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => null, 'bis' => null ]; @@ -53,13 +54,11 @@ class CoreMissingZgvTagLib public function isCriteriaSetFor(array $params) { - if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz'])) - { + if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id') return false; - } $semester = $params['studiensemester_kurzbz']; - $prestudent_id = $params['prestudent_id']; + $prestudent_id = $params['id']; $this->ci->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id'); $this->ci->PrestudentModel->addJoin('public.tbl_benutzer bn', 'person_id'); diff --git a/application/libraries/tags/CoreOutgoingTagLib.php b/application/libraries/tags/CoreOutgoingTagLib.php index 146513c6d..e076d0adf 100644 --- a/application/libraries/tags/CoreOutgoingTagLib.php +++ b/application/libraries/tags/CoreOutgoingTagLib.php @@ -19,7 +19,7 @@ class CoreOutgoingTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -31,7 +31,8 @@ class CoreOutgoingTagLib $outgoing_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => $item->von, 'bis' => $item->bis ]; @@ -40,25 +41,22 @@ class CoreOutgoingTagLib return (object) array( 'data' => $outgoing_data ); - - } public function isCriteriaSetFor(array $params) { - if (!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz'])) { + if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id') return false; - } $semester = $params['studiensemester_kurzbz']; - $prestudent_id = $params['prestudent_id']; + $prestudent_id = $params['id']; $result = $this->ci->BisioModel->isPrestudentOutgoing($semester, $prestudent_id); - if (hasData($result)) { return $result; - } else + } + else return null; } diff --git a/application/libraries/tags/CorePrewiederholerTagLib.php b/application/libraries/tags/CorePrewiederholerTagLib.php index f0dee27b3..cb2f0a77a 100644 --- a/application/libraries/tags/CorePrewiederholerTagLib.php +++ b/application/libraries/tags/CorePrewiederholerTagLib.php @@ -19,7 +19,7 @@ class CorePrewiederholerTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -34,7 +34,8 @@ class CorePrewiederholerTagLib $prewiederholer_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => $item->start, 'bis' => $item->ende ]; @@ -47,13 +48,11 @@ class CorePrewiederholerTagLib public function isCriteriaSetFor(array $params) { - if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz'])) - { + if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id') return false; - } $semester = $params['studiensemester_kurzbz']; - $prestudent_id = $params['prestudent_id']; + $prestudent_id = $params['id']; $this->ci->PrestudentstatusModel->addSelect('prestudent_id'); $this->ci->PrestudentstatusModel->addSelect('start as von'); diff --git a/application/libraries/tags/CoreStbErhoehtTagLib.php b/application/libraries/tags/CoreStbErhoehtTagLib.php index 76269e998..5795f8348 100644 --- a/application/libraries/tags/CoreStbErhoehtTagLib.php +++ b/application/libraries/tags/CoreStbErhoehtTagLib.php @@ -19,7 +19,7 @@ class CoreStbErhoehtTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -36,7 +36,8 @@ class CoreStbErhoehtTagLib $konto_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => $item->start, 'bis' => $item->ende ]; @@ -49,13 +50,11 @@ class CoreStbErhoehtTagLib public function isCriteriaSetFor(array $params) { - if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz'])) - { + if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id') return false; - } $semester = $params['studiensemester_kurzbz']; - $prestudent_id = $params['prestudent_id']; + $prestudent_id = $params['id']; $this->ci->KontoModel->addSelect('prestudent_id'); $this->ci->KontoModel->addSelect('start as von'); diff --git a/application/libraries/tags/CoreUnterbrecherTagLib.php b/application/libraries/tags/CoreUnterbrecherTagLib.php index aa05030e7..c205c746c 100644 --- a/application/libraries/tags/CoreUnterbrecherTagLib.php +++ b/application/libraries/tags/CoreUnterbrecherTagLib.php @@ -19,7 +19,7 @@ class CoreUnterbrecherTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -34,7 +34,8 @@ class CoreUnterbrecherTagLib $unterbrecher_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => $item->start, 'bis' => $item->ende ]; @@ -47,13 +48,11 @@ class CoreUnterbrecherTagLib public function isCriteriaSetFor(array $params) { - if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz'])) - { + if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id') return false; - } $semester = $params['studiensemester_kurzbz']; - $prestudent_id = $params['prestudent_id']; + $prestudent_id = $params['id']; $this->ci->PrestudentstatusModel->addSelect('prestudent_id'); $this->ci->PrestudentstatusModel->addSelect('start as von'); diff --git a/application/libraries/tags/CoreWiederholerTagLib.php b/application/libraries/tags/CoreWiederholerTagLib.php index 6cd78bb36..3d75e562e 100644 --- a/application/libraries/tags/CoreWiederholerTagLib.php +++ b/application/libraries/tags/CoreWiederholerTagLib.php @@ -19,7 +19,7 @@ class CoreWiederholerTagLib if(!isset($params['studiensemester_kurzbz'])) { return (object) array( - 'prestudent_id' => [] + 'idArray' => [] ); } @@ -34,7 +34,8 @@ class CoreWiederholerTagLib $wiederholer_data = array_map(function($item) { return [ - 'prestudent_id' => $item->prestudent_id, + 'typeId' => 'prestudent_id', + 'id' => $item->prestudent_id, 'von' => $item->start, 'bis' => $item->ende ]; @@ -47,14 +48,11 @@ class CoreWiederholerTagLib public function isCriteriaSetFor(array $params) { - - if(!isset($params['prestudent_id']) || !isset($params['studiensemester_kurzbz'])) - { + if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id') return false; - } $semester = $params['studiensemester_kurzbz']; - $prestudent_id = $params['prestudent_id']; + $prestudent_id = $params['id']; $this->ci->PrestudentstatusModel->addSelect('prestudent_id'); $this->ci->PrestudentstatusModel->addSelect('start as von'); diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index e72b24de4..13196b38f 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -433,4 +433,33 @@ class Person_model extends DB_Model return $this->execReadOnlyQuery($qry, [$person_id]); } + + //just a test function for a person_id tag + //alle personen die innerhalb dieses Zeitraumens 55 werden + public function getFiftyFivers($von, $bis) + { + $qry = " + SELECT + p.person_id + FROM public.tbl_person p + WHERE p.gebdatum >= DATE ? - INTERVAL '55 years' + AND p.gebdatum <= DATE ? - INTERVAL '55 years'; + "; + return $this->execReadOnlyQuery($qry, [$von, $bis]); + } + + //just a test function for a person_id tag + //check if Person gets 55 in this time + public function isFiftyFive($von, $bis, $person_id) + { + $qry = " + SELECT + p.person_id + FROM public.tbl_person p + WHERE p.gebdatum >= DATE ? - INTERVAL '55 years' + AND p.gebdatum <= DATE ? - INTERVAL '55 years' + AND p.persond_id = ?; + "; + return $this->execReadOnlyQuery($qry, [$von, $bis, $person_id]); + } } diff --git a/public/js/api/factory/stv/tag.js b/public/js/api/factory/stv/tag.js index d78e7f685..b0c416e2d 100644 --- a/public/js/api/factory/stv/tag.js +++ b/public/js/api/factory/stv/tag.js @@ -61,11 +61,11 @@ export default { }; }, - rebuildTagsPrestudent(prestudent_id){ + rebuildTagsforTypeId(data){ return { method: 'get', - url: 'api/frontend/v1/stv/Tags/rebuildTagsPrestudent', - params: prestudent_id + url: 'api/frontend/v1/stv/Tags/rebuildTagsForTypeId/', + params: data }; } }; \ No newline at end of file diff --git a/public/js/components/DetailHeader/DetailHeader.js b/public/js/components/DetailHeader/DetailHeader.js index 7cbc52c37..516ecdd87 100644 --- a/public/js/components/DetailHeader/DetailHeader.js +++ b/public/js/components/DetailHeader/DetailHeader.js @@ -246,9 +246,13 @@ export default { this.reload(); }, rebuildPrestudentTags(){ - const prestudent_id = this.headerData[0].prestudent_id; + const params = { + id : this.headerData[0].prestudent_id, + typeId: 'prestudent_id' + }; + return this.$api - .call(ApiTag.rebuildTagsPrestudent({prestudent_id})) + .call(ApiTag.rebuildTagsforTypeId(params)) .then(result => { this.rebuildData = result.data; console.log("Rebuild manually triggered");