diff --git a/application/controllers/Vertragsverwaltung.php b/application/controllers/Vertragsverwaltung.php index f1219335e..243f57118 100644 --- a/application/controllers/Vertragsverwaltung.php +++ b/application/controllers/Vertragsverwaltung.php @@ -4,6 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Vertragsverwaltung extends Auth_Controller { + //TODO(Manu) Permissions public function __construct() { $permissions = []; diff --git a/application/controllers/api/frontend/v1/LvMenu.php b/application/controllers/api/frontend/v1/LvMenu.php new file mode 100644 index 000000000..e69de29bb diff --git a/application/controllers/api/frontend/v1/vertraege/Config.php b/application/controllers/api/frontend/v1/vertraege/Config.php new file mode 100644 index 000000000..1da49cd78 --- /dev/null +++ b/application/controllers/api/frontend/v1/vertraege/Config.php @@ -0,0 +1,60 @@ +. + */ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +use CI3_Events as Events; + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about the VV Config + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Config extends FHCAPI_Controller +{ + public function __construct() + { + // TODO(Manu): permissions + parent::__construct([ + 'printDocument' => ['admin:r', 'assistenz:r'], + ]); + + + // Load Phrases + $this->loadPhrases([ + 'global', + 'person', + ]); + } + + public function printDocument() { + + $params = []; + + Events::trigger('multiActionPrintHonorarvertrag', + // passing $menu per reference + function & () use (&$menu) { + return $menu; + }, + $params + ); + + $this->terminateWithSuccess($menu[0]); + } + +} diff --git a/application/controllers/api/frontend/v1/vertraege/Vertraege.php b/application/controllers/api/frontend/v1/vertraege/Vertraege.php index 72f49f945..b17d8b4e6 100644 --- a/application/controllers/api/frontend/v1/vertraege/Vertraege.php +++ b/application/controllers/api/frontend/v1/vertraege/Vertraege.php @@ -1,6 +1,7 @@ self::PERM_LOGGED, 'deleteLehrauftrag' => self::PERM_LOGGED, 'deleteBetreuung' => self::PERM_LOGGED, - //TODO(Manu) Berechtigung + //TODO(Manu) Berechtigungen 'getMitarbeiter' => self::PERM_LOGGED, 'getHeader' => self::PERM_LOGGED, 'getPersonAbteilung' => self::PERM_LOGGED, 'getLeitungOrg' => self::PERM_LOGGED, + 'getMitarbeiter_uid' => self::PERM_LOGGED, ]); //Load Models and Libraries @@ -678,7 +680,6 @@ class Vertraege extends FHCAPI_Controller //TODO(Manu) rewrite better return $this->terminateWithSuccess("no benutzerdata", self::ERROR_TYPE_GENERAL); - // return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'personID']), self::ERROR_TYPE_GENERAL); } return $this->terminateWithSuccess(getData($result)); } @@ -718,11 +719,29 @@ class Vertraege extends FHCAPI_Controller return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'personID']), self::ERROR_TYPE_GENERAL); } -/* $result = current(getData($result)); - $header = $result->name;*/ - - //return $this->terminateWithSuccess($header); return $this->terminateWithSuccess(getData($result)); } + + public function getMitarbeiter_uid($person_id) + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getMitarbeiter_uid($person_id); + + if (isError($result)) + { + //TODO(Manu) check ErrorLogic + return $this->terminateWithSuccess($result); + //return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'personID']), self::ERROR_TYPE_GENERAL); + } + + return $this->terminateWithSuccess($result); + } + + } diff --git a/application/core/CI3_Events.php b/application/core/CI3_Events.php index 33a96b89e..07dd6a2db 100644 --- a/application/core/CI3_Events.php +++ b/application/core/CI3_Events.php @@ -35,7 +35,7 @@ class CI3_Events }); self::$eventsSorted[$event] = true; } - + foreach (self::$events[$event] as $conf) { $conf[1](...$args); } @@ -46,6 +46,19 @@ class CI3_Events * NOTE(chris): Autoload Events config */ require_once(APPPATH.'config/Events.php'); + foreach (scandir(APPPATH.'config/extensions') as $dir) if ($dir[0] != '.' && file_exists(APPPATH.'config/extensions/'.$dir.'/Events.php')) require_once APPPATH.'config/extensions/'.$dir.'/Events.php'; + +$active_addons_array = explode(";", ACTIVE_ADDONS); +foreach (scandir(FHCPATH.'addons') as $dir) + if ($dir[0] != '.' && file_exists(FHCPATH.'addons/'.$dir.'/Events.php')) + { + // only includes the Events of the addon if the addon is one of the active addons in the cis config + if(in_array($dir,$active_addons_array)) + { + require_once FHCPATH . 'addons/' . $dir . '/Events.php'; + } + } + diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index b616f3fbb..1b3c8834a 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -105,63 +105,12 @@ class Mitarbeiter_model extends DB_Model */ public function getPersonenWithContractDetails($person_id=null) { - /* $qry = "SELECT DISTINCT ON(mitarbeiter_uid) mitarbeiter_uid, person_id, titelpost, titelpre, - nachname, vorname, vornamen, - TO_CHAR(gebdatum::timestamp, 'DD.MM.YYYY') AS format_gebdatum - FROM ((public.tbl_mitarbeiter JOIN public.tbl_benutzer ON(mitarbeiter_uid=uid)) - JOIN public.tbl_person USING(person_id)) - LEFT JOIN public.tbl_benutzerfunktion USING(uid) - LEFT JOIN public.tbl_benutzerfunktion akt_funk ON tbl_mitarbeiter.mitarbeiter_uid = akt_funk.uid AND akt_funk.funktion_kurzbz = 'fachzuordnung' - AND (akt_funk.datum_von IS NULL OR akt_funk.datum_von <= now()) AND (akt_funk.datum_bis IS NULL OR akt_funk.datum_bis >= now()) - WHERE true"; - - if ($fix === true) - $qry .= " AND fixangestellt=true"; - elseif ($fix === false) - $qry .= " AND fixangestellt=false"; - - if ($aktiv === true) - $qry .= " AND tbl_benutzer.aktiv=true"; - elseif ($aktiv === false) - $qry .= " AND tbl_benutzer.aktiv=false"; - - if ($verwendung === true) - { - $qry.=" AND EXISTS(SELECT * FROM bis.tbl_bisverwendung WHERE (ende>now() or ende is null) AND tbl_bisverwendung.mitarbeiter_uid=tbl_mitarbeiter.mitarbeiter_uid)"; - } - elseif ($verwendung === false) - { - $qry.=" AND NOT EXISTS(SELECT * FROM bis.tbl_bisverwendung WHERE (ende>now() or ende is null) AND tbl_bisverwendung.mitarbeiter_uid=tbl_mitarbeiter.mitarbeiter_uid)"; - } - - if ($personaccount === true) - $qry .= " AND tbl_mitarbeiter.personalnummer >= 0"; - elseif ($personaccount === false) - $qry .= " AND tbl_mitarbeiter.personalnummer < 0"; - - $params = array(); - if (!isEmptyArray($uids)) - { - $qry .= " AND tbl_mitarbeiter.mitarbeiter_uid IN ?"; - $params[] = $uids; - } - - return $this->execQuery($qry, $params); - */ - - //TODO(Manu) filter nach DV-Art? was, wenn mehrere? oder einfach wenn extern ODER fix? - //TODO(Manu) email: plus dieses @domainzeugs: mohamed.aburaia@c3p0.ma0068.technikum-wien.at - //Standardkostenstelle... - //was wenn 2 echte DV? schmarrn - $qry = " SELECT b.uid , p.person_id, p.vorname, p.nachname, TO_CHAR(gebdatum::timestamp, 'DD.MM.YYYY') AS format_gebdatum, COALESCE(b.alias, b.uid) AS email, - --COALESCE(b.alias, b.uid) AS EMail, - --u.bezeichnung AS Unternehmen, STRING_AGG(DISTINCT va.bezeichnung, ', ') AS Vertragsarten, STRING_AGG(DISTINCT u.bezeichnung, ', ') AS Unternehmen, STRING_AGG(d.dienstverhaeltnis_id::TEXT, ', ') AS ids, @@ -180,33 +129,11 @@ class Mitarbeiter_model extends DB_Model JOIN hr.tbl_vertragsart va ON d.vertragsart_kurzbz = va.vertragsart_kurzbz "; -/* if ($aktiv === true) - $qry .= " WHERE b.aktiv = true"; - elseif ($aktiv === false) - $qry .= " WHERE b.aktiv = false"; - - if($fix) - { - $filterVertragsart = "echterdv"; - - $filterVertragsart = addslashes($filterVertragsart); // Escaping von Sonderzeichen - $qry .= " AND d.vertragsart_kurzbz = '" . $filterVertragsart . "'"; - } - - if($extern) - { - $filterVertragsart2 = "externerlehrender"; - - $filterVertragsart2 = addslashes($filterVertragsart2); // Escaping von Sonderzeichen - $qry .= " AND d.vertragsart_kurzbz = '" . $filterVertragsart2 . "'"; - }*/ - if($person_id) { $qry .= " WHERE p.person_id = ?"; } - $qry.= " GROUP BY b.uid, p.person_id, p.vorname, p.nachname, b.alias @@ -229,37 +156,7 @@ class Mitarbeiter_model extends DB_Model */ function getPersonAbteilung($person_id) { -/* - $qry = " - SELECT tbl_benutzer.uid - FROM tbl_mitarbeiter - JOIN tbl_benutzer ON tbl_mitarbeiter.mitarbeiter_uid::text = tbl_benutzer.uid::text - JOIN tbl_person USING (person_id) - WHERE tbl_person.person_id=? - "; - - - $result = $this->execQuery($qry, array($person_id)); - - $uid = current(getData($result)); - $uid = $uid->uid; - - - $qry2 =" - SELECT - bf.benutzerfunktion_id,bf.fachbereich_kurzbz,bf.uid,bf.funktion_kurzbz,bf.updateamum,bf.updatevon,bf.insertamum,bf.insertvon,bf.ext_id,bf.semester,bf.oe_kurzbz,bf.datum_von,bf.datum_bis,bf.bezeichnung,bf.wochenstunden, - oe.oe_kurzbz,oe.oe_parent_kurzbz,oe.bezeichnung,oe.organisationseinheittyp_kurzbz,oe.aktiv,oe.mailverteiler,oe.freigabegrenze,oe.kurzzeichen,oe.lehre,oe.standort,oe.warn_semesterstunden_frei,oe.warn_semesterstunden_fix,oe.standort_id - FROM tbl_benutzerfunktion bf JOIN public.tbl_organisationseinheit oe USING(oe_kurzbz) - WHERE uid = ? AND funktion_kurzbz='oezuordnung' - AND datum_von<=now() AND (datum_bis is null OR datum_bis>=now()) - "; - - $result2 = $this->execQuery($qry2, array($uid)); - - - return $result2;*/ - - // First Query + //TODO(Manu) use function getMitarbeiter_uid $qry = " SELECT tbl_benutzer.uid FROM tbl_mitarbeiter @@ -269,14 +166,12 @@ class Mitarbeiter_model extends DB_Model "; $result = $this->execQuery($qry, [$person_id]); - // Validate and extract UID $data = getData($result); if (empty($data)) { return null; // No UID found } $uid = isset($data[0]->uid) ? $data[0]->uid : null; - // $uid = isset($data[0]['uid']) ? $data[0]['uid'] : null; if (!$uid) { return null; // UID extraction failed @@ -475,4 +370,30 @@ class Mitarbeiter_model extends DB_Model return $this->execQuery($qry); } + + public function getMitarbeiter_uid($person_id){ + //TODO(Manu) refactor function + //and use in function getPersonAbteilung + //check function in Vertraege.php + $qry = " + SELECT tbl_benutzer.uid + FROM tbl_mitarbeiter + JOIN tbl_benutzer ON CAST(tbl_mitarbeiter.mitarbeiter_uid AS TEXT) = CAST(tbl_benutzer.uid AS TEXT) + JOIN tbl_person USING (person_id) + WHERE tbl_person.person_id = ? + "; + $result = $this->execQuery($qry, [$person_id]); + + $data = getData($result); + if (empty($data)) { + return null; // No UID found + } + //else + // $data = current($data); + + // $uid = $data->uid; + + $uid = isset($data[0]->uid) ? $data[0]->uid : null; + return $uid; + } } diff --git a/application/views/Vertragsverwaltung.php b/application/views/Vertragsverwaltung.php index c56da0362..0a663761f 100644 --- a/application/views/Vertragsverwaltung.php +++ b/application/views/Vertragsverwaltung.php @@ -30,10 +30,20 @@ $includesArray = array( $this->load->view('templates/FHC-Header', $includesArray); ?> + !defined('GENERATE_ALIAS_STUDENT') ? 'notDefined' : GENERATE_ALIAS_STUDENT, + 'domain' => !defined('DOMAIN') ? 'notDefined' : DOMAIN, + 'chooseLayout' => !defined('CHOOSE_LAYOUT') ? 'notDefined' : CHOOSE_LAYOUT, +]; +?> +
diff --git a/public/js/components/Vertraege/Vertraege.js b/public/js/components/Vertraege/Vertraege.js index 468e73bf8..60705d20a 100644 --- a/public/js/components/Vertraege/Vertraege.js +++ b/public/js/components/Vertraege/Vertraege.js @@ -59,7 +59,6 @@ export default { if (value == null) { return "0.00"; } - return parseFloat(value).toFixed(2); } }, @@ -162,7 +161,21 @@ export default { title: this.$p.t('global', 'aktionen') }); } - } + }, + { + //is just enabled for ADDON Injection KU: MultiprintHonorarvertrag + //(maybe enable also for ADDON FH Burgenland: MultiAccept later) + event: 'rowClick', + handler: (e, row) => { + if (this.dataPrintHonorar.multiselect) { + const selectedContract = row.getData().vertrag_id; + const status = row.getData().status; + const bezeichnung = row.getData().bezeichnung; + + this.toggleRowClick(selectedContract, status, bezeichnung); + } + } + }, ], statusNew: true, formData: { }, @@ -174,13 +187,19 @@ export default { vertragsstatus_kurzbz: 'test', datum: new Date(), }, + dataPrintHonorar: [], + triggeredData: [], childData: {}, isFilterSet: false, + ma_uid: null, + clickedRows: [], + arraySelectedContracts: [], } }, watch: { person_id() { this.$refs.table.reloadTable(); + this.arraySelectedContracts = []; //this.$refs.table.tabulator.setData('api/frontend/v1/vertraege/vertraege/getAllVertraege/' + this.person_id); }, }, @@ -218,7 +237,7 @@ export default { const dataToSend = { person_id: this.person_id, formData: this.formData, - clickedRows: this.childData, //do I need all Data, maybe smaller array? + clickedRows: this.childData, //all data needed, maybe smaller array? }; return this.endpoint @@ -240,7 +259,7 @@ export default { vertrag_id: vertrag_id, person_id: this.person_id, formData: this.formData, - clickedRows: this.childData, //do I need all Data, maybe smaller array? + clickedRows: this.childData, }; return this.endpoint @@ -421,44 +440,111 @@ export default { this.$refs.table.tabulator.clearFilter("status"); } }, + //methods for functionality ADDON KU + printContract(){ + this.getMitarbeiter_uid().then(()=> { + + //check if at least 2 contracts chosen + if(this.arraySelectedContracts.length < 2) { + this.$fhcAlert.alertError('Bitte mindestens 2 Verträge auswählen'); + return; + } + + //check if status=="Genehmigt" + const statusNotGenehmigtExists = this.arraySelectedContracts.some(([_, status]) => status !== 'Genehmigt'); + if(statusNotGenehmigtExists) { + this.$fhcAlert.alertError('Alle Verträge müssen genehmigt sein'); + return; + } + + //build String to Print PDF + let vertragString = ''; + + this.arraySelectedContracts.forEach(element => { + vertragString += '&vertrag_id[]=' + element[0].toString(); + }); + + let linkToPdf = this.dataPrintHonorar.link + + 'content/pdfExport.php?xml=' + this.dataPrintHonorar.xml + '&xsl=' + this.dataPrintHonorar.xsl + '&mitarbeiter_uid=' + this.ma_uid + vertragString + '&output=pdf&uid=' + this.ma_uid; + window.open(linkToPdf, '_blank'); + }); + }, + getMitarbeiter_uid(){ + return this.endpoint + .getMitarbeiter_uid(this.person_id) + .then(response => { + this.ma_uid = response.data; + }) + .catch(this.$fhcAlert.handleSystemError); + }, + toggleRowClick(contractId, status, bezeichnung) { + const index = this.arraySelectedContracts.findIndex( + ([id]) => id === contractId + ); + if (index !== -1) { + this.arraySelectedContracts.splice(index, 1); + } else { + this.arraySelectedContracts.push([contractId, status, bezeichnung]); + } + }, + clearSelection(){ + this.arraySelectedContracts = []; + } }, created() { Promise.all([ this.endpoint.getAllContractTypes(), this.endpoint.getAllContractsNotAssigned2(this.person_id), this.endpoint.getAllContractStati(), + this.$fhcApi.factory.vertraege.configPrintDocument() ]) - .then(([result1, result2, result3]) => { + .then(([result1, result2, result3, result4]) => { this.listContractTypes = result1.data; this.listContractsUnassigned = result2.data; this.listContractStati = result3.data; + this.dataPrintHonorar = result4.data; }) .catch(this.$fhcAlert.handleSystemError); }, mounted() { - this.$nextTick(() => { + //TODO(Manu) check if necessary +/* this.$nextTick(() => { this.$refs.table.tabulator.on("rowClick", (e, row) => { this.contractSelected = row.getData(); console.log("selected Row ", this.contractSelected); }); - }); + });*/ this.getFormattedDate(); }, template: `