mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-18 12:39:29 +00:00
stores the status of profilUpdate with their language in the database and adapts the logic to it
This commit is contained in:
@@ -9,6 +9,11 @@ if (!defined('BASEPATH'))
|
||||
class ProfilUpdate extends Auth_Controller
|
||||
{
|
||||
|
||||
public static $STATUS_PENDING =NULL;
|
||||
public static $STATUS_ACCEPTED =NULL;
|
||||
public static $STATUS_REJECTED =NULL;
|
||||
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct([
|
||||
'index' => ['student/stammdaten:r','mitarbeiter/stammdaten:r'],
|
||||
@@ -38,7 +43,8 @@ class ProfilUpdate extends Auth_Controller
|
||||
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
|
||||
$this->load->model('system/Sprache_model', 'SpracheModel');
|
||||
$this->load->model('person/Profil_update_status_model', 'ProfilUpdateStatusModel');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
@@ -57,9 +63,22 @@ class ProfilUpdate extends Auth_Controller
|
||||
//? put the uid and pid inside the controller for reusability
|
||||
$this->uid = getAuthUID();
|
||||
$this->pid = getAuthPersonID();
|
||||
|
||||
// static constants
|
||||
$this->ProfilUpdateStatusModel->addSelect(['status_kurzbz']);
|
||||
$status_kurzbz = $this->ProfilUpdateStatusModel->load();
|
||||
if(hasData($status_kurzbz)){
|
||||
list($status_pending, $status_accepted, $status_rejected) = getData($status_kurzbz);
|
||||
|
||||
self::$STATUS_PENDING = $status_pending->status_kurzbz;
|
||||
self::$STATUS_ACCEPTED = $status_accepted->status_kurzbz;
|
||||
self::$STATUS_REJECTED = $status_rejected->status_kurzbz;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function index(){
|
||||
$this->load->view('Cis/ProfilUpdate');
|
||||
}
|
||||
@@ -324,7 +343,7 @@ class ProfilUpdate extends Auth_Controller
|
||||
$payload = $json->payload;
|
||||
$identifier = property_exists($json->payload,"kontakt_id")? "kontakt_id" : (property_exists($json->payload,"adresse_id")? "adresse_id" : null);
|
||||
|
||||
$data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon"=>$this->uid,"status"=>$this->p->t('profilUpdate', 'pending') ];
|
||||
$data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon"=>$this->uid, "status"=>self::$STATUS_PENDING?:'Pending' ];
|
||||
|
||||
//? insert fileID in the dataset if sent with post request
|
||||
if(isset($json->fileID)){
|
||||
@@ -357,7 +376,7 @@ class ProfilUpdate extends Auth_Controller
|
||||
|
||||
if($res){
|
||||
$pending_changes = array_filter($res, function($element) {
|
||||
return $element->status == 'Pending' || $element->status == 'Ausstehend';
|
||||
return $element->status == isset(self::$STATUS_PENDING)?:"Pending";
|
||||
});
|
||||
|
||||
foreach($pending_changes as $update_request){
|
||||
@@ -419,13 +438,30 @@ class ProfilUpdate extends Auth_Controller
|
||||
|
||||
|
||||
public function getProfilUpdateWithPermission($status=null){
|
||||
|
||||
|
||||
|
||||
// early return if no status has been passed as argument
|
||||
if(!isset($status)){
|
||||
echo json_encode($this->ProfilUpdateModel->getProfilUpdateWithPermission());
|
||||
return;
|
||||
}
|
||||
|
||||
// get the sprache of the user
|
||||
$sprachenIndex = $this->SpracheModel->loadWhere(["sprache"=>getUserLanguage()]);
|
||||
$sprachenIndex = hasData($sprachenIndex)? getData($sprachenIndex)[0]->index : null;
|
||||
|
||||
if(isset($sprachenIndex) && isset($status)){
|
||||
// get the corresponding status kurz_bz primary key out of the translation
|
||||
$status = $this->ProfilUpdateStatusModel->execReadOnlyQuery("select * from public.tbl_profil_update_status where ? = ANY(bezeichnung_mehrsprachig)",[$status]);
|
||||
$status = hasData($status) ? getData($status)[0]->status_kurzbz : null;
|
||||
$res = $this->ProfilUpdateModel->getProfilUpdateWithPermission(isset($status)?['status'=>$status]:null);
|
||||
|
||||
$res = $this->ProfilUpdateModel->getProfilUpdateWithPermission(isset($status)?['status'=>$status]:null);
|
||||
|
||||
echo json_encode($res);
|
||||
echo json_encode($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function getOE_from_student($student_uid){
|
||||
|
||||
|
||||
@@ -88,7 +88,8 @@ class Profil_update_model extends DB_Model
|
||||
$studentBerechtigung = $this->permissionlib->isBerechtigt('student/stammdaten', 's');
|
||||
$mitarbeiterBerechtigung = $this->permissionlib->isBerechtigt('mitarbeiter/stammdaten', 's');
|
||||
$oe_berechtigung = $this->permissionlib->getOE_isEntitledFor('student/stammdaten');
|
||||
|
||||
|
||||
$lang = "select index from public.tbl_sprache where sprache =" . $this->escape(getUserLanguage());
|
||||
$res = [];
|
||||
|
||||
if ($studentBerechtigung) {
|
||||
@@ -98,8 +99,9 @@ class Profil_update_model extends DB_Model
|
||||
$parameters = [];
|
||||
$query = "
|
||||
SELECT
|
||||
profil_update_id, tbl_profil_update.uid, (tbl_person.vorname || ' ' || tbl_person.nachname) AS name , topic, requested_change, tbl_profil_update.updateamum, tbl_profil_update.updatevon, tbl_profil_update.insertamum, tbl_profil_update.insertvon, status, status_timestamp, status_message, attachment_id
|
||||
FROM public.tbl_profil_update
|
||||
profil_update_id, tbl_profil_update.uid, (tbl_person.vorname || ' ' || tbl_person.nachname) AS name , topic, requested_change, tbl_profil_update.updateamum, tbl_profil_update.updatevon, tbl_profil_update.insertamum, tbl_profil_update.insertvon, status, public.tbl_profil_update_status.bezeichnung_mehrsprachig[(".$lang.")] as status_translated, status_timestamp, status_message, attachment_id
|
||||
FROM public.tbl_profil_update
|
||||
JOIN public.tbl_profil_update_status ON public.tbl_profil_update_status.status_kurzbz = public.tbl_profil_update.status
|
||||
JOIN public.tbl_student ON public.tbl_student.student_uid=public.tbl_profil_update.uid
|
||||
JOIN public.tbl_benutzer ON public.tbl_benutzer.uid = public.tbl_student.student_uid
|
||||
JOIN public.tbl_person ON public.tbl_benutzer.person_id=public.tbl_person.person_id
|
||||
@@ -123,7 +125,8 @@ class Profil_update_model extends DB_Model
|
||||
}
|
||||
}
|
||||
if ($mitarbeiterBerechtigung) {
|
||||
$this->addSelect(["profil_update_id", "tbl_profil_update.uid", "(tbl_person.vorname || ' ' || tbl_person.nachname) AS name", "topic", "requested_change", "tbl_profil_update.updateamum", "tbl_profil_update.updatevon", "tbl_profil_update.insertamum", "tbl_profil_update.insertvon", "status", "status_timestamp", "status_message", "attachment_id"]);
|
||||
$this->addSelect(["profil_update_id", "tbl_profil_update.uid", "(tbl_person.vorname || ' ' || tbl_person.nachname) AS name", "topic", "requested_change", "tbl_profil_update.updateamum", "tbl_profil_update.updatevon", "tbl_profil_update.insertamum", "tbl_profil_update.insertvon", "status", "public.tbl_profil_update_status.bezeichnung_mehrsprachig[(".$lang.")] AS status_translated", "status_timestamp", "status_message", "attachment_id"]);
|
||||
$this->addJoin('tbl_profil_update_status', 'tbl_profil_update_status.status_kurzbz=tbl_profil_update.status');
|
||||
$this->addJoin('tbl_mitarbeiter', 'tbl_mitarbeiter.mitarbeiter_uid=tbl_profil_update.uid');
|
||||
$this->addJoin('tbl_benutzer', 'tbl_benutzer.uid=tbl_profil_update.uid');
|
||||
$this->addJoin('tbl_person', 'tbl_benutzer.person_id=tbl_person.person_id');
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class Profil_update_status_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_profil_update_status';
|
||||
$this->pk = ['status_kurzbz'];
|
||||
$this->hasSequence = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Profil_update_topic_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_profil_update_topic';
|
||||
$this->pk = ['topic_kurzbz'];
|
||||
$this->hasSequence = false;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,25 @@ import AcceptDenyUpdate from "./AcceptDenyUpdate.js";
|
||||
import Alert from "../../../components/Bootstrap/Alert.js";
|
||||
import Loading from "../../../components/Loader.js";
|
||||
|
||||
const STATUS = Object.freeze({
|
||||
PENDING: "Pending",
|
||||
ACCEPTED: "Accepted",
|
||||
REJECTED: "Rejected",
|
||||
})
|
||||
|
||||
const sortProfilUpdates = (ele1, ele2) => {
|
||||
const sortProfilUpdates = (ele1, ele2, thisPointer)=> {
|
||||
|
||||
let result = 0;
|
||||
if (ele1.status === this.$p.t('profilUpdate','pending')) {
|
||||
if (ele1.status === STATUS.PENDING) {
|
||||
result = -1;
|
||||
} else if (ele1.status === this.$p.t('profilUpdate','accepted')) {
|
||||
result = ele2.status === this.$p.t('profilUpdate','rejected') ? -1 : 1;
|
||||
} else if (ele1.status === STATUS.ACCEPTED) {
|
||||
result = ele2.status === STATUS.REJECTED ? -1 : 1;
|
||||
} else {
|
||||
result = 1;
|
||||
}
|
||||
//? if they have the same status the insert date is used for ordering
|
||||
|
||||
if (ele1.status === ele2.status) {
|
||||
//? if they have the same status , insert_date gets compared for order
|
||||
result =
|
||||
new Date(ele2.insertamum.split(".").reverse().join("-")) -
|
||||
new Date(ele1.insertamum.split(".").reverse().join("-"));
|
||||
@@ -54,15 +61,15 @@ export default{
|
||||
if (this.showAll) {
|
||||
return url + "getProfilUpdateWithPermission";
|
||||
} else {
|
||||
return url + "getProfilUpdateWithPermission/pending";
|
||||
return url + `getProfilUpdateWithPermission/${STATUS.PENDING}`;
|
||||
}
|
||||
},
|
||||
ajaxResponse: function (url, params, response) {
|
||||
ajaxResponse: (url, params, response)=> {
|
||||
//url - the URL of the request
|
||||
//params - the parameters passed with the request
|
||||
//response - the JSON object returned in the body of the response.
|
||||
//? sorts the response data from the backend
|
||||
if (response) response.sort(sortProfilUpdates);
|
||||
if (response) response.sort((ele1,ele2)=>sortProfilUpdates(ele1,ele2,this));
|
||||
|
||||
return response;
|
||||
},
|
||||
@@ -185,21 +192,17 @@ export default{
|
||||
},
|
||||
{
|
||||
title: "Status",
|
||||
field: "status",
|
||||
field: "status_translated",
|
||||
hozAlign: "center",
|
||||
headerFilter: true,
|
||||
formatter: (cell, para) => {
|
||||
let iconClasses ="fa fa-lg"
|
||||
if(cell.getValue() == this.$p.t('profilUpdate','pending')) {
|
||||
iconClasses += " fa-circle-info text-info "
|
||||
let iconClasses =""
|
||||
let status = cell.getRow().getData().status;
|
||||
switch (status){
|
||||
case "Pending": iconClasses += "fa fa-lg fa-circle-info text-info "; break;
|
||||
case "Accepted": iconClasses += "fa fa-lg fa-circle-check text-success "; break;
|
||||
case "Rejected": iconClasses += "fa fa-lg fa-circle-xmark text-danger "; break;
|
||||
}
|
||||
else if(cell.getValue() == this.$p.t('profilUpdate','accepted')) {
|
||||
iconClasses += " fa-circle-check text-success "
|
||||
}
|
||||
else if(cell.getValue() == this.$p.t('profilUpdate','rejected')) {
|
||||
iconClasses += " fa-circle-xmark text-danger "
|
||||
}
|
||||
|
||||
return `<div class='row justify-content-center'><div class='col-2'><i class='${iconClasses}'></i></div> <div class='col-4'><span>${cell.getValue()}</span></div></div>`;
|
||||
},
|
||||
|
||||
@@ -320,6 +323,8 @@ export default{
|
||||
|
||||
<select class="mb-4 " v-model="showAll" @change="updateData" class="form-select" aria-label="Profil updates display selection">
|
||||
<option :selected="true" :value="false">{{$p.t('profilUpdate','pendingRequests')}}</option>
|
||||
<option :value="false">{{$p.t('profilUpdate','acceptedRequests')}}</option>
|
||||
<option :value="false">{{$p.t('profilUpdate','rejectedRequests')}}</option>
|
||||
<option :value="true">{{$p.t('profilUpdate','allRequests')}}</option>
|
||||
</select>
|
||||
|
||||
@@ -327,7 +332,7 @@ export default{
|
||||
|
||||
<loading ref="loadingModalRef" :timeout="0"></loading>
|
||||
|
||||
<core-filter-cmpt title="Update Requests" ref="UpdatesTable" :tabulatorEvents="events" :tabulator-options="profil_updates_table_options" tableOnly :sideMenu="false" />
|
||||
<core-filter-cmpt :title="$p.t('profilUpdate','profilUpdateRequests')" ref="UpdatesTable" :tabulatorEvents="events" :tabulator-options="profil_updates_table_options" tableOnly :sideMenu="false" />
|
||||
|
||||
</div>`,
|
||||
};
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
$qry = " CREATE TABLE public.tbl_profil_update_status (
|
||||
status_kurzbz VARCHAR(32) NOT NULL,
|
||||
beschreibung VARCHAR(256) NULL,
|
||||
bezeichnung_mehrsprachig VARCHAR(256)[] NULL,
|
||||
CONSTRAINT tbl_profil_update_status_pk PRIMARY KEY(status_kurzbz)
|
||||
);
|
||||
|
||||
INSERT INTO public.tbl_profil_update_status VALUES ('Ausstehend','Profil Änderungen die noch nicht bearbeitet wurden'),
|
||||
('Pending','Profil updates that were not processed yet'),
|
||||
('Akzeptiert','Profil Änderungen die akzeptiert wurden'),
|
||||
('Accepted','Profil updates that were accepted'),
|
||||
('Abgelehnt','Profil Änderungen die abgelehn wurden'),
|
||||
('Rejected','Profil updates that were rejected');";
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_profil_update_status TO vilesci;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_profil_update_status TO web;
|
||||
|
||||
INSERT INTO public.tbl_profil_update_status VALUES ('Pending','Profil Änderungen die noch nicht bearbeiten wurden','{Ausstehend,Pending}'),
|
||||
('Accepted','Profil Änderungen die angenommen wurden','{Angenommen,Accepted}'),
|
||||
('Rejected','Profil Änderungen die abgelehn wurden','{Abgelehnt,Rejected}');";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>public.tbl_profil_update_status: '.$db->db_last_error().'</strong><br>';
|
||||
@@ -28,29 +29,24 @@
|
||||
$qry="CREATE TABLE public.tbl_profil_update_topic (
|
||||
topic_kurzbz VARCHAR(32) NOT NULL,
|
||||
beschreibung VARCHAR(256) NULL,
|
||||
bezeichnung_mehrsprachig VARCHAR(256)[] NULL,
|
||||
CONSTRAINT tbl_profil_update_topic_pk PRIMARY KEY(topic_kurzbz)
|
||||
);
|
||||
|
||||
INSERT INTO public.tbl_profil_update_topic VALUES ('Vorname','Vorname aktualisieren'),
|
||||
('First name','Update first name'),
|
||||
('Nachname','Nachname aktualisieren'),
|
||||
('Last name','Update last name'),
|
||||
('Titel','Titel aktualisieren'),
|
||||
('Title','Update title'),
|
||||
('Postnomen','Postnomen aktualisieren'),
|
||||
('post-nominals','Update post-nominals'),
|
||||
('Private Kontakte','Kontakt aktualisieren'),
|
||||
('Private Contacts','Update contact'),
|
||||
('Kontakt löschen','Kontakt löschen'),
|
||||
('Delete contact','Delete contact'),
|
||||
('Kontakt hinzufügen','Kontakt hinzufügen'),
|
||||
('Add contact','Add contact'),
|
||||
('Private Adressen','Adresse aktualisieren'),
|
||||
('Private Addresses','Update address'),
|
||||
('Adresse löschen','Adresse löschen'),
|
||||
('Delete address','Delete address'),
|
||||
('Adresse hinzufügen','Adresse löschen'),
|
||||
('Add address','Add address');";
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_profil_update_topic TO vilesci;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_profil_update_topic TO web;
|
||||
|
||||
|
||||
INSERT INTO public.tbl_profil_update_topic VALUES ('Vorname','Vorname aktualisieren','{Vorname,\"First name\"}'),
|
||||
('Nachname','Nachname aktualisieren','{Nachname,\"Last name\"}'),
|
||||
('Titel','Titel aktualisieren','{Titel,Title}'),
|
||||
('Postnomen','Postnomen aktualisieren','{Postnomen,Post-nominal}'),
|
||||
('Private Kontakte','Kontakt aktualisieren','{\"Private Kontakte\",\"Private Contacts\"}'),
|
||||
('Kontakt löschen','Kontakt löschen','{\"Kontakt löschen\",\"Delete contact\"}'),
|
||||
('Kontakt hinzufügen','Kontakt hinzufügen','{\"Kontakt hinzufügen\",\"Add contact\"}'),
|
||||
('Private Adressen','Adresse aktualisieren','{\"Private Adressen\",\"Private Addreses\"}'),
|
||||
('Adresse löschen','Adresse löschen','{\"Adresse löschen\",\"Delete address\"}'),
|
||||
('Adresse hinzufügen','Adresse löschen','{\"Adresse hinzufügen\",\"Delete address\"}');";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>public.tbl_profil_update_topic: '.$db->db_last_error().'</strong><br>';
|
||||
|
||||
@@ -24848,14 +24848,34 @@ array(
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Profil Update Anfrage',
|
||||
'description' => '',
|
||||
'text' => 'Profil Änderungs Anfrage',
|
||||
'description' => 'Eine Änderungs Anfrage',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Profil Update Request',
|
||||
'description' => '',
|
||||
'description' => 'One profil update request',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'profilUpdate',
|
||||
'phrase' => 'profilUpdateRequests',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Profil Änderungs Anfragen',
|
||||
'description' => 'Mehrere Änderungs Anfragen',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Profil Update Requests',
|
||||
'description' => 'Multiple update requests',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
@@ -25020,6 +25040,46 @@ array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'profilUpdate',
|
||||
'phrase' => 'acceptedRequests',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Angenommene Anfragen',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Accepted Requests',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'profilUpdate',
|
||||
'phrase' => 'rejectedRequests',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Abgelehnte Anfragen',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Rejected Requests',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'profilUpdate',
|
||||
@@ -25700,6 +25760,27 @@ array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'profilUpdate',
|
||||
'phrase' => 'profilUpdate_status_error',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Ein Fehler ist aufgetreten, der Status "{0}" ist unbekannt',
|
||||
'description' => 'Fehler der auftritt wenn es den Status nicht in der Datenbank gibt',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'An error occurred, the status "{0}" is not known',
|
||||
'description' => 'error that occurrs when the used status is not present in the database',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user