relation of user and thanato
This commit is contained in:
parent
2566848c2f
commit
d7fa518066
@ -146,5 +146,8 @@ return [
|
||||
//thanato
|
||||
['name' => 'page#getThanatoTypeList', 'url' => '/thanato/type', 'verb' => 'PROPFIND'],
|
||||
|
||||
//relation of user and thanato
|
||||
['name' => 'page#getUsersNotLinkedToThanato','url' => '/user/getUsersNotLinkedToThanato', 'verb' => 'PROPFIND'],
|
||||
|
||||
]
|
||||
];
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
16
gestion/lib/Constants/BddConstant.php
Normal file
16
gestion/lib/Constants/BddConstant.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Gestion\Constants;
|
||||
abstract class BddConstant
|
||||
{
|
||||
const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related";
|
||||
const DEFAULT_TABLE_PREFIX = "*PREFIX*";
|
||||
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
|
||||
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
|
||||
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Emmanuelle";
|
||||
|
||||
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";
|
||||
|
||||
const DEFAULT_THANATOS_GROUP_NAME = "Thanatos";
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace OCA\Gestion\Controller;
|
||||
|
||||
use Exception;
|
||||
defined("TAB1") or define("TAB1", "\t");
|
||||
|
||||
use OCP\IGroupManager;
|
||||
@ -2786,4 +2788,19 @@ class PageController extends Controller {
|
||||
public function getThanatoTypeList() {
|
||||
return $this->myDb->geThanatoTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
*/
|
||||
public function getUsersNotLinkedToThanato(){
|
||||
try{
|
||||
$result = $this->myDb->getUsersNotLinkedToThanato();
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e) {
|
||||
return json_encode([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace OCA\Gestion\Db;
|
||||
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
use OCA\Gestion\Helpers\DateHelpers;
|
||||
use OCA\Gestion\Helpers\VCalendarHelpers;
|
||||
use OCP\IDBConnection;
|
||||
@ -12,6 +13,7 @@ class Bdd {
|
||||
private String $charset = 'utf8mb4';
|
||||
|
||||
public const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related";
|
||||
public const DEFAULT_TABLE_PREFIX = "*PREFIX*";
|
||||
|
||||
private IDbConnection $pdo;
|
||||
|
||||
@ -32,7 +34,7 @@ class Bdd {
|
||||
"drainage", "drainage_qte", "drainage_etat", "ponction", "ponction_qte", "cavite", "cavite_qte", "desinfection", "lavage",
|
||||
"rasage", "presentation_cosmetique", "presentation_sur", "hypodermiques", "hypodermiques_sur", "local", "local_sur", "contenu",
|
||||
"commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit",
|
||||
"fk_thanato_type_key","thanato_email");
|
||||
"fk_thanato_type_key","thanato_email","fk_user_uuid");
|
||||
$this->whiteTable = array("client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit", "configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis", "bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt");
|
||||
$this->tableprefix = '*PREFIX*' ."gestion_";
|
||||
$this->pdo = $db;
|
||||
@ -109,9 +111,13 @@ class Bdd {
|
||||
thanato.id_nextcloud,
|
||||
thanato.fk_thanato_type_key,
|
||||
thanato.thanato_email,
|
||||
thanato_type.thanato_type_label
|
||||
thanato_type.thanato_type_label,
|
||||
thanato.fk_user_uuid,
|
||||
users.uid as user_uuid,
|
||||
users.displayname as user_display_name
|
||||
FROM ".$this->tableprefix."thanato as thanato
|
||||
LEFT JOIN ".$this->tableprefix."thanato_type as thanato_type on thanato.fk_thanato_type_key = thanato_type.thanato_type_key
|
||||
LEFT JOIN ".self::DEFAULT_TABLE_PREFIX."users as users on thanato.fk_user_uuid = users.uid
|
||||
;";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
@ -1730,6 +1736,17 @@ class Bdd {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getThanatoIdByUserUuid($userUuid){
|
||||
$sql = "SELECT min(id) as FIRST_INSERT_ID
|
||||
FROM ".$this->tableprefix."thanato
|
||||
WHERE fk_user_uuid = ?";
|
||||
$res = $this->execSQLNoJsonReturn($sql,array($userUuid));
|
||||
if($res){
|
||||
return $res[0]['FIRST_INSERT_ID'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getCalendarOrganizerNameByCalendarObjectUuid(string $calendarObjectUuid){
|
||||
$calendarObject = $this->getCalendarObjectByUuid($calendarObjectUuid);
|
||||
if($calendarObject != null){
|
||||
@ -2633,4 +2650,19 @@ class Bdd {
|
||||
return $this->execSQL($sql,[]);
|
||||
}
|
||||
|
||||
public function getUsersNotLinkedToThanato(){
|
||||
$sql = "SELECT
|
||||
users.uid,
|
||||
users.uid_lower,
|
||||
users.displayname
|
||||
FROM ".self::DEFAULT_TABLE_PREFIX."users as users
|
||||
JOIN .".self::DEFAULT_TABLE_PREFIX."group_user group_user ON users.uid = group_user.uid
|
||||
LEFT JOIN ".$this->tableprefix."thanato as thanato on users.uid = thanato.fk_user_uuid
|
||||
WHERE group_user.gid = ? AND
|
||||
thanato.fk_user_uuid IS NULL;
|
||||
";
|
||||
|
||||
return $this->execSQL($sql,[BddConstant::DEFAULT_THANATOS_GROUP_NAME]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class GestionService {
|
||||
$thanatoNames = $this->GetAttendeesNameFromVCalendarString($vCalendarString);
|
||||
if(count($thanatoNames) > 0){
|
||||
$thanatoName = $thanatoNames[0];
|
||||
$thanatoIdFromDb = $this->gestionBdd->getFirstThanatoIdByName($thanatoName);
|
||||
$thanatoIdFromDb = $this->gestionBdd->getThanatoIdByUserUuid($thanatoName);
|
||||
if($thanatoIdFromDb != null){
|
||||
$thanatoId = $thanatoIdFromDb;
|
||||
}
|
||||
@ -69,7 +69,7 @@ class GestionService {
|
||||
//get from calendar object
|
||||
$organizerName = $this->getPrincipalUsernameFromVCalendarString($vCalendarString);
|
||||
if($organizerName != null){
|
||||
$thanatoIdFromDb = $this->gestionBdd->getFirstThanatoIdByName($organizerName);
|
||||
$thanatoIdFromDb = $this->gestionBdd->getThanatoIdByUserUuid($organizerName);
|
||||
if($thanatoIdFromDb != null){
|
||||
$thanatoId = $thanatoIdFromDb;
|
||||
}
|
||||
|
||||
2
gestion/lib/Sql/20250203-ADD_USER_UID_ON_THANATO.sql
Normal file
2
gestion/lib/Sql/20250203-ADD_USER_UID_ON_THANATO.sql
Normal file
@ -0,0 +1,2 @@
|
||||
alter table oc_gestion_thanato
|
||||
add column fk_user_uuid VARCHAR(255) DEFAULT NULL;
|
||||
@ -66,6 +66,9 @@ document.body.addEventListener('click', e => {
|
||||
}else if(e.target.className.includes("loadSelect_listalldevis")){
|
||||
Devis.loadAllDevisList_dnum(e);
|
||||
}
|
||||
else if(e.target.className.includes("selectUserAsThanatoList")){
|
||||
Thanatopracteur.loadUserNotLinkedToThanatoToSelect(e);
|
||||
}
|
||||
else if(e.target.className.includes("selectThanatoType")){
|
||||
Thanatopracteur.loadThanatoTypeIntoSelect(e);
|
||||
}
|
||||
|
||||
@ -16,6 +16,16 @@ export class Thanatopracteur {
|
||||
this.thanatoTypeLabel = ((myresp.thanato_type_label != null && myresp.thanato_type_label.length > 0)) ? myresp.thanato_type_label : '-';
|
||||
this.thanatoTypeKey = ((myresp.fk_thanato_type_key != null && myresp.fk_thanato_type_key.length > 0)) ? myresp.fk_thanato_type_key : '-';
|
||||
this.thanatoEmail = ((myresp.thanato_email != null && myresp.thanato_email.length > 0)) ? myresp.thanato_email : '';
|
||||
let userDisplayName = "-";
|
||||
let currentUserUuid = (myresp.fk_user_uuid != null && myresp.fk_user_uuid.length > 0) ? myresp.fk_user_uuid : null;
|
||||
if(myresp.displayname != null && myresp.displayname.length > 0){
|
||||
userDisplayName = myresp.displayname
|
||||
}
|
||||
else if(myresp.fk_user_uuid != null && myresp.fk_user_uuid.length > 0){
|
||||
userDisplayName = myresp.fk_user_uuid
|
||||
}
|
||||
this.userDisplayName = userDisplayName;
|
||||
this.currentUserUuid + currentUserUuid;
|
||||
}
|
||||
|
||||
/**undefined
|
||||
@ -30,6 +40,7 @@ export class Thanatopracteur {
|
||||
'<input style="margin:0;padding:0;" class="inputDate" type="date" value=' + this.date + ' data-table="thanato" data-column="date_habilitation" data-id="' + this.id + '"/>',
|
||||
'<div class="editable" data-table="thanato" data-column="thanato_email" data-id="' + this.id + '">' + this.thanatoEmail + '</div>',
|
||||
'<div class="selectThanatoType" data-table="thanato" data-column="fk_thanato_type_key" data-id="' + this.id + '" data-current="' + this.thanatoTypeKey + '">' + this.thanatoTypeLabel + '</div>',
|
||||
'<div class="selectUserAsThanatoList" data-table="thanato" data-column="fk_user_uuid" data-id="' + this.id + '" data-current="' + this.currentUserUuid + '">' + this.userDisplayName + '</div>',
|
||||
'<center><div data-modifier="thanato" data-id=' + this.id + ' data-table="thanato" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div></center>'
|
||||
];
|
||||
return myrow;
|
||||
@ -97,6 +108,20 @@ export class Thanatopracteur {
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
static getUsersNotLinkedToThanato(callback){
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/user/getUsersNotLinkedToThanato', true);
|
||||
oReq.setRequestHeader("Content-Type", "application/json");
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
callback(JSON.parse(this.response));
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc populate thanato select list in devis
|
||||
*/
|
||||
@ -191,4 +216,53 @@ export class Thanatopracteur {
|
||||
e.target.appendChild(selectElement);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* POPULATE LIST OF USER NOT LINKED TO THANATO YET IN A SELECT
|
||||
*/
|
||||
static loadUserNotLinkedToThanatoToSelect(e){
|
||||
Thanatopracteur.getUsersNotLinkedToThanato(response => {
|
||||
|
||||
var selectElement = document.createElement("select");
|
||||
selectElement.dataset.current = e.target.dataset.current;
|
||||
selectElement.dataset.id = e.target.dataset.id;
|
||||
selectElement.dataset.old = e.target.innerHTML;
|
||||
|
||||
selectElement.addEventListener("change", el=>{
|
||||
if(el.target.value != 0){
|
||||
updateDB(el.target.parentElement.dataset.table,
|
||||
el.target.parentElement.dataset.column,
|
||||
el.target.value,
|
||||
el.target.parentElement.dataset.id
|
||||
);
|
||||
|
||||
var parentElement = el.target.parentElement
|
||||
parentElement.innerHTML = el.target.options[el.target.selectedIndex].text;
|
||||
parentElement.dataset.current = el.target.value;
|
||||
}else{
|
||||
var parentElement = el.target.parentElement
|
||||
parentElement.innerHTML = el.target.dataset.old
|
||||
}
|
||||
});
|
||||
|
||||
var option = document.createElement("option");
|
||||
option.value = 0;
|
||||
option.text = t('gestion', 'Cancel');
|
||||
selectElement.appendChild(option);
|
||||
|
||||
JSON.parse(response).forEach(myresp => {
|
||||
var txt = document.createElement("textarea");
|
||||
txt.innerHTML = (myresp.displayname != null && myresp.displayname.length > 0) ? myresp.displayname : myresp.uid
|
||||
var option = document.createElement("option");
|
||||
option.value = myresp.uid
|
||||
option.text = txt.value;
|
||||
selectElement.appendChild(option);
|
||||
});
|
||||
|
||||
checkSelectPurJs(selectElement);
|
||||
|
||||
e.target.innerHTML = ''
|
||||
e.target.appendChild(selectElement);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -26,6 +26,7 @@
|
||||
<th>Date d'habilitation</th>
|
||||
<th><?php p($l->t('Email'));?></th>
|
||||
<th><?php p($l->t('Type'));?></th>
|
||||
<th>User</th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user