Merge branch 'fixes/fix-user-and-thanato-relation' into staging

This commit is contained in:
Tiavina 2025-02-03 08:43:39 +03:00
commit 299dce6b53
32 changed files with 166 additions and 28 deletions

View File

@ -167,5 +167,7 @@ return [
['name' => 'page#uploadPacemakerPhotoToDefunts','url' => '/defunt/uploadPacemakerPhotoToDefunts', 'verb' => 'POST'],
//pay invoices
['name' => 'page#payInvoices','url' => '/facture/payInvoices', 'verb' => 'POST'],
//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

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

View File

@ -11,4 +11,6 @@ abstract class BddConstant
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Johann";
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";
const DEFAULT_THANATOS_GROUP_NAME = "Thanatos";
}

View File

@ -2845,4 +2845,19 @@ class PageController extends Controller {
return false;
}
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
*/
public function getUsersNotLinkedToThanato(){
try{
$result = $this->myDb->getUsersNotLinkedToThanato();
return $result;
}
catch(Exception $e) {
return json_encode([]);
}
}
}

View File

@ -45,7 +45,8 @@ class Bdd {
"fk_client_group_facturation_id","group_facturation_name",
"fk_product_type_id",
"portal_code","alarm_code","funeral_code",
"product_brand","product_reference");
"product_brand","product_reference",
"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",
"client_group_discount","client_group",
@ -128,7 +129,13 @@ class Bdd {
}
public function getThanatopracteurs($idNextcloud){
$sql = "SELECT * FROM ".$this->tableprefix."thanato;";
$sql = "SELECT
thanato.*,
users.uid as user_uuid,
users.displayname as user_display_name
FROM ".$this->tableprefix."thanato as thanato
LEFT JOIN ".self::DEFAULT_TABLE_PREFIX."users as users on thanato.fk_user_uuid = users.uid
;";
return $this->execSQL($sql, array());
}
@ -1075,6 +1082,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;
}
/**
* Insert lieu
*/
@ -2195,7 +2213,7 @@ class Bdd {
}
public function getThanatoById($thanatoId){
$sql = "SELECT id, nom, prenom FROM ".$this->tableprefix."thanato WHERE id = ? LIMIT 1;";
$sql = "SELECT id, nom, prenom,fk_user_uuid FROM ".$this->tableprefix."thanato WHERE id = ? LIMIT 1;";
$thanato = $this->execSQLNoJsonReturn($sql,[$thanatoId]);
if(!empty($thanato)){
return $thanato[0];
@ -2230,7 +2248,10 @@ class Bdd {
$devisListPerThanatoPerDate = [];
$thanato = $this->getThanatoById($thanatoId);
$thanatoName = $thanato["nom"];
$thanatoCalendar = $this->getCalendarByThanatoIdNextcloud($thanato["nom"]);
$thanatoCalendar = $this->getCalendarByThanatoIdNextcloud($thanato["fk_user_uuid"] ?? $thanato["nom"]);
if($thanatoCalendar == null){
return [];
}
$thanatoCalendarId = $thanatoCalendar["id"];
foreach($dateOfMonths as $currentDate){
$currentDateFormatted = $currentDate->format('Y-m-d');
@ -3772,4 +3793,19 @@ class Bdd {
]);
return true;
}
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]);
}
}

View File

@ -70,6 +70,9 @@ class ExportThanatoStatisticService {
return null;
}
$exportData = $this->gestionBdd->getExportThanatoStatisticData($thanatoId,$month,$year);
if($exportData){
return null;
}
$defaultConfig = json_decode($this->gestionBdd->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD));
$racineFolder = html_entity_decode($defaultConfig[0]->path).'/';
$thanatoFolder = $racineFolder.'STATISTIQUES/THANATOS/';

View File

@ -75,7 +75,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;
}
@ -84,7 +84,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;
}

View File

@ -0,0 +1,2 @@
alter table oc_gestion_thanato
add column fk_user_uuid VARCHAR(255) DEFAULT NULL;

View File

@ -72,6 +72,9 @@ document.body.addEventListener('click', e => {
else if(e.target.className.includes("selectProductTypeList")){
Produit.loadProductTypeListIntoSelect(e);
}
else if(e.target.className.includes("selectUserAsThanatoList")){
Thanatopracteur.loadUserNotLinkedToThanatoToSelect(e);
}
else if(e.target.className.includes("loadSelect_listdevis")){
Devis.loadDevisList_dnum(e);
}else if(e.target.className.includes("loadSelect_listalldevis")){

View File

@ -13,6 +13,16 @@ export class Thanatopracteur {
this.nom = ((myresp.nom.length === 0) ? '-' : myresp.nom);
this.reference = ((myresp.reference.length === 0) ? '-' : myresp.reference);
this.date = ((myresp.date_habilitation.length === 0) ? '-' : myresp.date_habilitation);
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
@ -25,6 +35,7 @@ export class Thanatopracteur {
'<div class="editable" data-table="thanato" data-column="nom" data-id="' + this.id + '">' + this.nom + '</div>',
'<div class="editable" data-table="thanato" data-column="reference" data-id="' + this.id + '">' + this.reference + '</div>',
'<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="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;
@ -78,6 +89,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
*/
@ -126,4 +151,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);
});
}
}

View File

@ -27,6 +27,7 @@
<th><?php p($l->t('Last name'));?></th>
<th>Référence</th>
<th>Date d'habilitation</th>
<th>User</th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>