Merge branch 'features/feature-photos-on-bijou' into staging

This commit is contained in:
Tiavina 2025-01-29 12:46:32 +03:00
commit 78bb8b41c2
32 changed files with 281 additions and 46 deletions

View File

@ -161,5 +161,7 @@ return [
//producttype
['name' => 'page#getProductTypes', 'url' => '/product/getProductTypes', 'verb' => 'PROPFIND'],
//producttype
['name' => 'page#uploadFileToBijoux', 'url' => '/defunt/uploadFileToBijoux', 'verb' => 'POST'],
]
];

View File

@ -257,4 +257,8 @@
background-color: rgb(43, 172, 253);
border-radius: 0 0 5px 5px;
color: white
}
.photoBijouUpload{
all: inherit !important;
}

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

@ -2229,25 +2229,23 @@ class PageController extends Controller {
* @NoCSRFRequired
* @param string $numdefunt
*/
public function saveRapportBijoux($numdefunt){
$current_config = json_decode($this->myDb->getConfiguration($this->idNextcloud));
public function saveRapportBijoux($numdefunt,$withPhotos = false){
if($withPhotos != null && $withPhotos == 1){
$withPhotos = true;
}
else{
$withPhotos = false;
}
$defaultConfig = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
$defunt = json_decode($this->myDb->getOneDefunt($numdefunt, $this->idNextcloud))[0];
$bijoux = json_decode($this->myDb->getListBijoux($numdefunt, $this->idNextcloud));
try {
$nomDefunt = $defunt->nom_defunt;
$date_naissance_temp = date("t-m-Y", strtotime(date($defunt->date_naissance)));
$date_deces_temp = date("t-m-Y", strtotime(date($defunt->date_defunt)));
$date_temp = date("t-m-Y", strtotime(date('Y-m-d')));
$date_habilitation_temp = date("t-m-Y", strtotime(date($defunt->date_habilitation)));
$formatter = new IntlDateFormatter('fr_FR', IntlDateFormatter::LONG, IntlDateFormatter::NONE);
$today = $formatter->format(DateTime::createFromFormat('d-m-Y', $date_temp));
$date_habilitation = $formatter->format(DateTime::createFromFormat('d-m-Y', $date_habilitation_temp));
$date_naissance = $formatter->format(DateTime::createFromFormat('d-m-Y', $date_naissance_temp));
$date_deces = $formatter->format(DateTime::createFromFormat('d-m-Y', $date_deces_temp));
$folderDestination = html_entity_decode($current_config[0]->path).'/CLIENTS/'.strtoupper($defunt->entreprise).'/DEFUNTS/'.strtoupper($nomDefunt).'/RAPPORTS/';
$folderDestination = html_entity_decode($defaultConfig[0]->path).'/CLIENTS/'.strtoupper($defunt->entreprise).'/DEFUNTS/'.strtoupper($nomDefunt).'/RAPPORTS/';
try {
$this->storage->newFolder($folderDestination);
@ -2265,13 +2263,13 @@ class PageController extends Controller {
// logo : 80 de largeur et 55 de hauteur
$logo = $this->getLogo();
if($logo != 'nothing'){
$pdf->Image($this->defaultImagePath."logo.png", 10, 10, 55, 30);
$pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
}
$pdf->SetY(55); $pdf->SetFont('ComicSans', 'B', 15); $pdf->Cell(0, 10, utf8_decode(html_entity_decode("ATTESTATION BIJOU(X)")), 0, 0, 'C');
$pdf->SetY(45); $pdf->SetFont('ComicSans', 'B', 15); $pdf->Cell(0, 10, utf8_decode(html_entity_decode("ATTESTATION BIJOU(X)")), 0, 0, 'C');
$pdf->SetMargins(15,15,15);
$pdf->SetY(80); $pdf->SetFont('ComicSans', '', 10);
$pdf->SetY(65); $pdf->SetFont('ComicSans', '', 10);
$pdf->MultiCell(0, 5, utf8_decode(html_entity_decode("Je soussignée ".$defunt->prenom_thanato." ".strtoupper($defunt->nom_thanato).", Thanatopracteur, agissant pour le compte de la société ".strtoupper($current_config[0]->entreprise)." titulaire de l'habilitation n° ".$defunt->reference_habilitation." atteste par la présente que :
".(strcmp($defunt->sexe, 'm')==0 ? 'Monsieur' : 'Madame').". ".$defunt->nom_defunt."
a été pris(e) en charge par nos services pour des soins mortuaires.")), '','J',0);
@ -2287,6 +2285,38 @@ class PageController extends Controller {
$pdf->SetFont('ComicSans', '', 10); $pdf->MultiCell($col_width, 8, utf8_decode(html_entity_decode($bijou->designation)), 'LTRB', 'L');
$pdf->SetXY($col_width+15, $pdf->GetY()-8); $pdf->SetFont('ComicSans', '', 10); $pdf->MultiCell($col_width, 8, utf8_decode(html_entity_decode($bijou->commentaire)), 'LTRB', 'L');
}
$photosCount = 0;
if($withPhotos){
$photosCountLimitToGoToNewLine = 3;
$currentUserFolder = "/var/www/html/data/$this->idNextcloud/files/";
$clientName = $defunt->nom;
if($clientName != null){
$bijouxPhotosFolder = FileExportHelpers::GetBijouxOfDefuntFolder($clientName,$defunt->nom_defunt,$defaultConfig[0]->path);
$pdf->setXY($pdf->GetX(),$pdf->GetY()+5);
$pdf->Cell(0,5,"Photos :",0,1);
$pdf->setXY($pdf->GetX(),$pdf->GetY()+5);
foreach ($bijoux as $key => $bijou) {
if($bijou->photo == null){
continue;
}
try{
$fullPhotoPath = $currentUserFolder.$bijouxPhotosFolder.$bijou->photo;
$pdf->Image($fullPhotoPath,$pdf->GetX(),$pdf->GetY(),50,30);
$pdf->SetXY($pdf->GetX() + 60,$pdf->GetY());
$photosCount++;
if($photosCount == $photosCountLimitToGoToNewLine){
$pdf->SetY($pdf->GetY() + 35);
}
}
catch(Exception){
}
}
}
if($photosCount > 0){
$pdf->SetY($pdf->GetY()+30);
}
}
$pdf->setY($pdf->GetY()+10);
@ -2297,21 +2327,20 @@ class PageController extends Controller {
// signature
$pdf->SetFont('ComicSans','',11);
$pdf->setY($pdf->GetY()+10);
$pdf->Cell( $pdf->GetPageWidth()-30, 0, utf8_decode(html_entity_decode($current_config[0]->nom).' '.html_entity_decode($current_config[0]->prenom)), 0, 0, 'L');
$pdf->Cell( $pdf->GetPageWidth()-30, 0, utf8_decode(html_entity_decode($defaultConfig[0]->nom).' '.html_entity_decode($defaultConfig[0]->prenom)), 0, 0, 'L');
$pdf->setY($pdf->GetY()+5);
$signatureExist = $this->signatureImageExists('sign.png');
if ($signatureExist) {
$pdf->Image($this->defaultImagePath."sign.png", 15, $pdf->GetY(), 55, 30);
$pdf->Image($this->defaultImagePath."sign.png", 5, $pdf->GetY(), 60, 40);
}
$pdf->setY($pdf->GetY()-5);
$pdf->SetFont('ComicSans','',11); $pdf->Cell( $pdf->GetPageWidth()-80, 0, "Pour :", 0, 0, 'R');
$pdf->SetY(-30); $pdf->SetFont('ComicSans', '', 8); $pdf->MultiCell($pdf->GetPageWidth()-30, 5, utf8_decode(html_entity_decode(iconv("UTF-8", "ISO-8859-1//TRANSLIT", $current_config[0]->legal_one))), '', 'C');
$pdf->SetFont('ComicSans', '', 8); $pdf->MultiCell($pdf->GetPageWidth()-30, 5, utf8_decode(html_entity_decode(iconv("UTF-8", "ISO-8859-1//TRANSLIT", $current_config[0]->legal_two))), '', 'C');
$pdf->SetFont('ComicSans', '', 8); $pdf->MultiCell($pdf->GetPageWidth()-30, 5, utf8_decode(html_entity_decode(iconv("UTF-8", "ISO-8859-1//TRANSLIT", $current_config[0]->telephone))), '', 'C');
$pdf->SetY(-15); $pdf->SetFont('ComicSans', '', 8);
$pdf->MultiCell(0, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 'C');
$pdf->MultiCell(0, 5, utf8_decode(html_entity_decode($defaultConfig[0]->adresse)), 0,'C');
$ff_pdf = $folderDestination.'RAPPORT_BIJOUX_'.strtoupper($nomDefunt).'.pdf';
$this->storage->newFile($ff_pdf);
@ -2719,4 +2748,44 @@ class PageController extends Controller {
}
catch(\OCP\Files\NotFoundException $e) { }
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
*/
public function uploadFileToBijoux($bijouxId){
try{
$configs = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
$currentConfig = $configs[0];
$bijoux = $this->myDb->getBijouxWithDefuntByBijouxId($bijouxId);
if($bijoux == null){
return false;
}
if($bijoux["defunt_id"] == null){
return false;
}
$defuntId = $bijoux["defunt_id"];
$devisOfDefunt = $this->myDb->getDevisOfDefunt($defuntId);
if($devisOfDefunt == null){
return false;
}
$folder = FileExportHelpers::GetBijouxOfDefuntFolder($devisOfDefunt["client_nom"],$bijoux["defunt_nom"],$currentConfig->path);
try {
$this->storage->newFolder($folder);
}
catch(\OCP\Files\NotPermittedException $e) {
}
$photoName = basename($_FILES["photo"]["name"]);
$filename = uniqid() . "_" .$photoName;
$fullPath = $folder.$filename;
$fileContent = file_get_contents($_FILES["photo"]["tmp_name"]);
$this->storage->newFile($fullPath,$fileContent);
$this->myDb->saveBijouxPhoto($bijouxId,$filename,$photoName);
return $fullPath;
}
catch(\OCP\Files\NotFoundException $e) { }
}
}

View File

@ -783,7 +783,7 @@ class Bdd {
}
public function getListBijoux($numdefunt, $idNextcloud) {
$sql = "SELECT ".$this->tableprefix."bijou_defunt.id as bdid, designation, commentaire FROM "
$sql = "SELECT ".$this->tableprefix."bijou_defunt.id as bdid, designation, commentaire,photo,photo_name FROM "
.$this->tableprefix."bijou_defunt, ".$this->tableprefix."defunt
WHERE ".$this->tableprefix."defunt.id = defunt_id AND ".$this->tableprefix."defunt.id = ?";
return $this->execSQL($sql, array($numdefunt));
@ -3707,4 +3707,34 @@ class Bdd {
WHERE devis.id = ?;";
$this->execSQLNoData($sql,[$mention,$devisId]);
}
public function getBijouxWithDefuntByBijouxId($bijouxId){
$sql = "SELECT
bijou.id,
bijou.defunt_id,
bijou.designation,
bijou.commentaire,
bijou.photo,
defunt.nom as defunt_nom
FROM ".$this->tableprefix."bijou_defunt as bijou
LEFT JOIN ".$this->tableprefix."defunt as defunt on bijou.defunt_id = defunt.id
WHERE bijou.id = ? ;";
$bijoux = $this->execSQLNoJsonReturn($sql,[$bijouxId,]);
if(!empty($bijoux)){
return $bijoux[0];
}
return null;
}
public function saveBijouxPhoto($bijouxId,$photo,$photoRealName){
$sql = "UPDATE ".$this->tableprefix."bijou_defunt as bijou_defunt
SET bijou_defunt.photo = ?,bijou_defunt.photo_name = ?
WHERE bijou_defunt.id = ? ;";
$this->execSQLNoData(
$sql,
[$photo,$photoRealName,$bijouxId]);
return true;
}
}

View File

@ -48,4 +48,18 @@ class FileExportHelpers
return strtr( $str, $unwanted_array );
}
public static function GetClientsFolder($clientName,$racinePath){
return $racinePath.'CLIENTS/'.mb_strtoupper($clientName,'UTF-8').'/';
}
public static function GetDefuntsFolder($clientName,$defuntName,$racinePath){
$clientsFolder = self::GetClientsFolder($clientName,$racinePath);
return $clientsFolder.'DEFUNTS/'.mb_strtoupper($defuntName,'UTF-8').'/';
}
public static function GetBijouxOfDefuntFolder($clientName,$defuntName,$racinePath){
$defuntFolder = self::GetDefuntsFolder($clientName,$defuntName,$racinePath);
return $defuntFolder.'BIJOUX/';
}
}

View File

@ -0,0 +1,2 @@
alter table oc_gestion_bijou_defunt add photo VARCHAR(255) DEFAULT NULL;
alter table oc_gestion_bijou_defunt add photo_name VARCHAR(255) DEFAULT NULL;

View File

@ -85,4 +85,17 @@ table.dataTable.display tbody tr.even > [class*="sorting_"] {
.select2-container--default .select2-selection--single .select2-selection__arrow b {
border-color: black rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) !important;
margin-top: -4px !important;
}
.radio-group {
display: flex;
align-items: center;
gap: 15px;
}
.radio-group label {
display: flex;
align-items: center;
gap: 5px;
cursor: pointer;
}

View File

@ -4,7 +4,7 @@ import "../css/mycss.css";
import { globalConfiguration } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import { setDefuntCover,getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
import { setDefuntCover, setBijouxPhoto,getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
let bibliotheques = [];
let sortedBibliotheques = [];
@ -16,6 +16,7 @@ let sortedBibliothequesProduits = [];
window.addEventListener("DOMContentLoaded", function () {
var defuntid = $('#defuntid').data('id');
globalConfiguration();
getBibliotheques(loadBibliotheques);
getObservationsById();
@ -70,9 +71,37 @@ window.addEventListener("DOMContentLoaded", function () {
var pacemakerBtn = document.getElementById("pacemakerBtn");
var rapportSoinBtn = document.getElementById("rapportSoinBtn");
var rapportBijouxBtn = document.getElementById("rapportBijouxBtn");
// var rapportBijouxBtn = document.getElementById("rapportBijouxBtn");
var exportCareCertificateButton = document.getElementById("exportCareCertificate");
var setDefuntCoverButton = this.document.getElementById("coverProductsRadioButton");
var exportBijouxRapport = this.document.getElementById("exportBijouxRapport");
var showRapportBijouxExportModalButton = this.document.getElementById("showRapportBijouxExportModal");
var closeRapportBijouxModalButton = this.document.getElementById("closeRapportBijouxModal");
closeRapportBijouxModalButton.addEventListener("click",function(){
$('#saveRapportBijouxModal').hide();
})
showRapportBijouxExportModalButton.addEventListener("click",function(){
$('#saveRapportBijouxModal').show();
})
exportBijouxRapport.addEventListener("click",function(){
const rapportWithPhotosRadio = document.getElementsByName('withProducts');
let selectedValue = "0";
for (const radio of rapportWithPhotosRadio) {
if (radio.checked) {
selectedValue = radio.value;
break;
}
}
saveRapportBijoux({
numdefunt: defuntid,
withPhotos: selectedValue
});
$('#saveRapportBijouxModal').hide();
});
setDefuntCoverButton.addEventListener("click",function(){
const productCoverRadios = document.getElementsByName('coverProductsRadioButton');
@ -103,6 +132,14 @@ window.addEventListener("DOMContentLoaded", function () {
rapportBijouxBtn.addEventListener("click", function(){
saveRapportBijoux({ numdefunt: defuntid });
});
$(".photoBijouUpload").on("change", function () {
let fileInput = this;
let file = fileInput.files[0];
let bijouxId = $(this).data("id");
setBijouxPhoto(bijouxId,file);
getBijouxById();
})
});
function loadBibliotheques(response) {

View File

@ -512,9 +512,18 @@ export function getBijouxById() {
}).done(function (response, code) {
$('#bijoux tbody').empty();
$.each(JSON.parse(response), function (arrayID, myresp) {
let photo = myresp.photo;
let photoHtml = "";
if(photo != null){
photoHtml = '<td><label style="padding-right:5px;">'+myresp.photo_name+'</label><input type="file" accept="image/png, image/gif, image/jpeg" class="photoBijouUpload" data-id="' + myresp.bdid + '"></td>'
}
else{
photoHtml = '<td><input type="file" accept="image/png, image/gif, image/jpeg" class="photoBijouUpload" data-id="' + myresp.bdid + '"></td>';
}
$('#bijoux tbody').append('<tr>'+
'<td><div class="editable" data-table="bijou_defunt" data-column="designation" data-id="' + myresp.bdid + '">' + ((myresp.designation.length === 0) ? '-' : myresp.designation) + '</div></td>' +
'<td><div class="editable" data-table="bijou_defunt" data-column="commentaire" data-id="' + myresp.bdid + '">' + ((myresp.commentaire.length === 0) ? '-' : myresp.commentaire) + '</div></td>' +
photoHtml +
'<td><div data-html2canvas-ignore data-modifier="getBijouxById" data-id="' + myresp.bdid + '" data-table="bijou_defunt" class="deleteItem icon-delete"></div></td>'+
'</tr>'
);
@ -830,3 +839,34 @@ export function exportClientDevisByMonthAndYearToPdf(clientId,year,month) {
showError(t('gestion', "Erreur dans la génération de devis multiple"));
});
};
/**
* Set bijoux photo
* @param {*} bijouxId
* @param {*} file
*/
export function setBijouxPhoto(bijouxId,file) {
if(file){
let formData = new FormData();
formData.append("bijouxId", bijouxId);
formData.append("photo", file);
$.ajax({
url: baseUrl + '/defunt/uploadFileToBijoux',
type: 'POST',
contentType: false,
processData: false,
data: formData
}).done(function (response) {
if(response != null) {
showSuccess('Sauvegardé dans' + response);
return;
}
showError(t('gestion', "Erreur dans l'assignation de photo sur ce bijou"));
}).fail(function (response, code) {
showError(t('gestion', "Erreur dans la génération de devis multiple"));
});
}
else{
showError(t('gestion', "Veuillez choisir une image"))
}
};

View File

@ -447,6 +447,7 @@
<tr>
<th>Désignation</th>
<th><?php p($l->t('Comment'));?></th>
<th><?php p($l->t('Photo'));?></th>
<th>Actions</th>
</tr>
</thead>
@ -459,6 +460,29 @@
<hr>
<div class="d-flex">
<button id="rapportSoinBtn" class="btn btn-secondary" type="button">Générer le rapport de soins</button>
<button id="rapportBijouxBtn" class="btn btn-secondary" type="button">Générer le rapport des bijoux</button>
<button id="showRapportBijouxExportModal" class="btn btn-secondary" type="button" data-toggle="modal" data-target="#saveRapportBijouxModal">Générer le rapport des bijoux</button>
</div>
<div class="modal" id="saveRapportBijouxModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Générer le rapport de bijoux</h5>
</div>
<div class="modal-body">
<div class="radio-group">
<label>
<input type="radio" name="withProducts" value="1"> Avec photos
</label>
<label>
<input type="radio" name="withProducts" value="0"> Sans photos
</label>
</div>
</div>
<div class="modal-footer">
<button id="closeRapportBijouxModal" type="button" class="btn btn-secondary">Annuler</button>
<button id="exportBijouxRapport" type="button" class="btn btn-primary">Sauvegarder</button>
</div>
</div>
</div>
</div>
</div>