pacemaker photo

This commit is contained in:
Tiavina 2025-01-30 09:41:27 +03:00
parent 0b5838963f
commit 8c0aa7a54d
10 changed files with 116 additions and 8 deletions

View File

@ -161,7 +161,9 @@ return [
//producttype
['name' => 'page#getProductTypes','url' => '/product/getProductTypes', 'verb' => 'PROPFIND'],
//producttype
//uploadFileTobijoux
['name' => 'page#uploadFileToBijoux','url' => '/defunt/uploadFileToBijoux', 'verb' => 'POST'],
//upload pacemaker photo to defunt
['name' => 'page#uploadPacemakerPhotoToDefunts','url' => '/defunt/uploadPacemakerPhotoToDefunts', 'verb' => 'POST'],
]
];

View File

@ -259,6 +259,6 @@
color: white
}
.photoBijouUpload{
.photoBijouUpload, .uploadDefuntPacemakerPhoto{
all: inherit !important;
}

File diff suppressed because one or more lines are too long

View File

@ -2754,7 +2754,6 @@ class PageController extends Controller {
* @NoCSRFRequired
*
*/
public function uploadFileToBijoux($bijouxId){
try{
$configs = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
@ -2786,6 +2785,37 @@ class PageController extends Controller {
return $fullPath;
}
catch(\OCP\Files\NotFoundException $e) { }
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
*/
public function uploadPacemakerPhotoToDefunts($defuntId){
try{
$configs = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
$currentConfig = $configs[0];
$devisOfDefunt = $this->myDb->getDevisOfDefunt($defuntId);
if($devisOfDefunt == null){
return null;
}
$folder = FileExportHelpers::GetPacemakerPhotoFolderOfDefunt($devisOfDefunt["client_nom"],$devisOfDefunt["defunt_nom"],$currentConfig->path);
try {
$this->storage->newFolder($folder);
}
catch(\OCP\Files\NotPermittedException $e) {
}
$photoName = basename($_FILES["photo"]["name"]);
$filename = uniqid() . "_" .$photoName;
$fullPath = $folder.$photoName;
$fileContent = file_get_contents($_FILES["photo"]["tmp_name"]);
$this->storage->newFile($fullPath,$fileContent);
$this->myDb->saveDefuntPacemakerPhoto($defuntId,$filename,$photoName);
return $fullPath;
}
catch(\OCP\Files\NotFoundException $e) {
return null;
}
}
}

View File

@ -709,6 +709,8 @@ class Bdd {
.$this->tableprefix."defunt.presentation_cosmetique,"
.$this->tableprefix."defunt.presentation_sur,"
.$this->tableprefix."defunt.observations_generales,"
.$this->tableprefix."defunt.product_photo,"
.$this->tableprefix."defunt.product_photo_name,"
.$this->tableprefix."client.id as clientid, ".$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, legal_one, entreprise, telephone, mail, ".$this->tableprefix."client.adresse,"
.$this->tableprefix."lieu.nom as lieu, ".$this->tableprefix."lieu.adresse as adresse_soin ,"
.$this->tableprefix."thanato.nom as nom_thanato, ".$this->tableprefix."thanato.prenom as prenom_thanato, "
@ -3714,4 +3716,15 @@ class Bdd {
return true;
}
public function saveDefuntPacemakerPhoto($defuntId,$photo,$photoRealName){
$sql = "UPDATE ".$this->tableprefix."defunt as defunt
SET defunt.product_photo = ?,defunt.product_photo_name = ?
WHERE defunt.id = ? ;";
$this->execSQLNoData(
$sql,
[$photo,$photoRealName,$defuntId]);
return true;
}
}

View File

@ -62,4 +62,9 @@ class FileExportHelpers
return $defuntFolder.'BIJOUX/';
}
public static function GetPacemakerPhotoFolderOfDefunt($clientName,$defuntName,$racinePath){
$defuntFolder = self::GetDefuntsFolder($clientName,$defuntName,$racinePath);
return $defuntFolder.'PACEMAKER/';
}
}

View File

@ -0,0 +1,2 @@
alter table oc_gestion_defunt add product_photo VARCHAR(255) DEFAULT NULL;
alter table oc_gestion_defunt add product_photo_name VARCHAR(255) DEFAULT NULL;

View File

@ -4,7 +4,7 @@ import "../css/mycss.css";
import { globalConfiguration } from "./modules/mainFunction.mjs";
import "./listener/main_listener";
import { setDefuntCover, setBijouxPhoto,getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
import { setDefuntCover, setDefuntPacemakerPhoto,setBijouxPhoto,getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
let bibliotheques = [];
let sortedBibliotheques = [];
@ -100,6 +100,8 @@ window.addEventListener("DOMContentLoaded", function () {
$('#saveRapportBijouxModal').hide();
});
setDefuntCoverButton.addEventListener("click",function(){
const productCoverRadios = document.getElementsByName('coverProductsRadioButton');
let selectedValue = null;
@ -132,6 +134,13 @@ window.addEventListener("DOMContentLoaded", function () {
let bijouxId = $(this).data("id");
setBijouxPhoto(bijouxId,file);
});
$(document).on("change", ".uploadDefuntPacemakerPhoto", function () {
let fileInput = this;
let file = fileInput.files[0];
let defuntId = $(this).data("id");
setDefuntPacemakerPhoto(defuntId,file);
});
});
function loadBibliotheques(response) {

View File

@ -871,3 +871,36 @@ export function setBijouxPhoto(bijouxId,file) {
showError(t('gestion', "Veuillez choisir une image"))
}
};
/**
* Set defunt photo pacemaker
* @param {*} defuntId
* @param {*} file
*/
export function setDefuntPacemakerPhoto(defuntId,file) {
if(file){
let formData = new FormData();
formData.append("defuntId", defuntId);
formData.append("photo", file);
$.ajax({
url: baseUrl + '/defunt/uploadPacemakerPhotoToDefunts',
type: 'POST',
contentType: false,
processData: false,
data: formData
}).done(function (response) {
if(response != null) {
showSuccess('Sauvegardé dans' + response);
let pacemakerPhotoLabel = document.getElementById("pacemakerPhotoLabel");
pacemakerPhotoLabel.innerHTML = file.name;
return;
}
showError(t('gestion', "Le défunt n'appartient à aucun devis"));
}).fail(function (response, code) {
showError(t('gestion', "Le défunt n'appartient à aucun devis"));
});
}
else{
showError(t('gestion', "Veuillez choisir une photo"))
}
};

View File

@ -100,6 +100,20 @@
<input class="gestion-input w-100" type="text" value="<?php echo ($_['defunt'][0]->product_brand ?? "") ?>" data-table="defunt" data-column="product_brand" data-id="<?php echo $_['defunt'][0]->id ?>"/>
</div>
</div>
<!-- Product photo -->
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 16px">
<div class="col-3">Photo du produit</div>
<div class="col-9">
<input class="w-100 uploadDefuntPacemakerPhoto" type="file" data-id="<?php echo $_['defunt'][0]->id ?>"/>
<?php
if($_['defunt'][0]->product_photo != null){
?>
<label id="pacemakerPhotoLabel" for=""><?php echo ($_['defunt'][0]->product_photo_name ?? "") ?></label>
<?php
}
?>
</div>
</div>
</div>
<div class="col-6">
<h6>Housse</h6>