set defunt cover on defunt show, WIP error message (defunt doesnt have devis, or the products does not exist)
This commit is contained in:
parent
d499696964
commit
8ea19d7b87
File diff suppressed because one or more lines are too long
@ -271,13 +271,14 @@ class PageController extends Controller {
|
||||
* @param string $numdefunt
|
||||
*/
|
||||
public function defuntshow($numdefunt) {
|
||||
$defunt = $this->myDb->getOneDefunt($numdefunt,$this->idNextcloud);
|
||||
$defunt = $this->myDb->getOneDefunt($numdefunt,$this->idNextcloud,true);
|
||||
$coverProducts = $this->myDb->getCoverProducts();
|
||||
return new TemplateResponse('gestion', 'defuntshow', array( 'groups' => $this->groups, 'user' => $this->user, 'configuration'=> $this->getConfiguration(),
|
||||
'defunt'=>json_decode($defunt),
|
||||
'path' => $this->idNextcloud,
|
||||
'url' => $this->getNavigationLink(),
|
||||
'logo' => $this->getLogo(),
|
||||
'coverProducts' =>$this->myDb->getCoverProducts()
|
||||
'coverProducts' =>json_decode($coverProducts)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@ -525,7 +525,7 @@ class Bdd {
|
||||
return $this->execSQL($sql, array($numdevis));
|
||||
}
|
||||
|
||||
public function getOneDefunt($numdefunt,$idNextcloud){
|
||||
public function getOneDefunt($numdefunt,$idNextcloud,$includeDefuntProductCover = false){
|
||||
$sql = "SELECT ".$this->tableprefix."defunt.id, ".$this->tableprefix."devis.version, ".$this->tableprefix."devis.comment, ".$this->tableprefix."devis.date, num,"
|
||||
.$this->tableprefix."devis.id as id_devis,".$this->tableprefix."devis.id_client, id_lieu, id_thanato,".$this->tableprefix."devis.user_id as user_id, "
|
||||
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt,".$this->tableprefix."defunt.date_naissance,".$this->tableprefix."defunt.sexe,".$this->tableprefix."defunt.ref_pacemaker,"
|
||||
@ -572,7 +572,21 @@ class Bdd {
|
||||
LEFT JOIN ".$this->tableprefix."lieu on ".$this->tableprefix."devis.id_lieu = ".$this->tableprefix."lieu.id
|
||||
LEFT JOIN ".$this->tableprefix."thanato on ".$this->tableprefix."devis.id_thanato = ".$this->tableprefix."thanato.id
|
||||
WHERE ".$this->tableprefix."defunt.id = ?";
|
||||
return $this->execSQL($sql, array($numdefunt));
|
||||
|
||||
$defunts = $this->execSQLNoJsonReturn($sql,[$numdefunt]);
|
||||
if($includeDefuntProductCover){
|
||||
foreach($defunts as &$defunt){
|
||||
$defunt["product_cover_id"] = null;
|
||||
$defuntHasDevis = $defunt["id_devis"] != null;
|
||||
if($defuntHasDevis){
|
||||
$productCover = $this->getProductCoverByDevisId($defunt["id_devis"]);
|
||||
if($productCover != null){
|
||||
$defunt["product_cover_id"] = $productCover["produit_id"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return json_encode($defunts);
|
||||
}
|
||||
|
||||
public function getListProduit($numdevis, $idNextcloud){
|
||||
@ -2829,12 +2843,36 @@ class Bdd {
|
||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count(ProductConstant::PRODUCT_COVER_REFERENCE_LIST), '?'));
|
||||
$sql = "SELECT
|
||||
produit.id,
|
||||
produit.reference
|
||||
produit.reference,
|
||||
produit.description
|
||||
FROM ".$this->tableprefix."produit as produit
|
||||
WHERE produit.reference IN ($sqlConditionsPlaceholder)";
|
||||
|
||||
return $this->execSQL($sql,ProductConstant::PRODUCT_COVER_REFERENCE_LIST);
|
||||
}
|
||||
|
||||
private function getProductCoverByDevisId($devisId){
|
||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count(ProductConstant::PRODUCT_COVER_REFERENCE_LIST), '?'));
|
||||
$sql = "SELECT
|
||||
produit_devis.id,
|
||||
produit.id as produit_id,
|
||||
produit.reference,
|
||||
produit.description
|
||||
FROM ".$this->tableprefix."produit_devis as produit_devis
|
||||
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
|
||||
WHERE produit_devis.devis_id = ? AND
|
||||
produit.reference IN ($sqlConditionsPlaceholder) LIMIT 1";
|
||||
|
||||
$productCover = $this->execSQLNoJsonReturn($sql,
|
||||
array_merge(
|
||||
[$devisId],
|
||||
ProductConstant::PRODUCT_COVER_REFERENCE_LIST
|
||||
));
|
||||
if($productCover){
|
||||
return $productCover[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -4,7 +4,7 @@ import "../css/mycss.css";
|
||||
|
||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||
import "./listener/main_listener";
|
||||
import { getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
|
||||
import { setDefuntCover,getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
|
||||
|
||||
let bibliotheques = [];
|
||||
let sortedBibliotheques = [];
|
||||
@ -72,7 +72,22 @@ window.addEventListener("DOMContentLoaded", function () {
|
||||
var rapportSoinBtn = document.getElementById("rapportSoinBtn");
|
||||
var rapportBijouxBtn = document.getElementById("rapportBijouxBtn");
|
||||
var exportCareCertificateButton = document.getElementById("exportCareCertificate");
|
||||
var setDefuntCoverButton = this.document.getElementById("coverProductsRadioButton");
|
||||
|
||||
setDefuntCoverButton.addEventListener("click",function(){
|
||||
const productCoverRadios = document.getElementsByName('coverProductsRadioButton');
|
||||
let selectedValue = null;
|
||||
for (const radio of productCoverRadios) {
|
||||
if (radio.checked) {
|
||||
selectedValue = radio.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setDefuntCover({
|
||||
defuntId : defuntid,
|
||||
productId : selectedValue
|
||||
});
|
||||
})
|
||||
|
||||
exportCareCertificateButton.addEventListener("click",function(){
|
||||
exportCareCertificate({defuntId : defuntid});
|
||||
|
||||
@ -745,3 +745,29 @@ export function exportCareCertificate(defuntIdPayload) {
|
||||
error(response);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Set defunt cover (Housse)
|
||||
* @param {*} setDefuntCoverPayload
|
||||
*/
|
||||
export function setDefuntCover(setDefuntCoverPayload) {
|
||||
if(setDefuntCoverPayload.productId == null){
|
||||
showError('Veuillez choisir une housse à appliquer');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: baseUrl + '/defunt/setDefuntCover',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(setDefuntCoverPayload)
|
||||
}).done(function (response) {
|
||||
if(response == null) {
|
||||
showMessage('Ce defunt n\'appartient à aucun devis.');
|
||||
} else {
|
||||
showSuccess('Housse appliquée au defunt avec succès');
|
||||
}
|
||||
}).fail(function (response, code) {
|
||||
showMessage(t('gestion', 'Erreur dans l\'application de la housse'));
|
||||
error(response);
|
||||
});
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
if($i>1) $quantiteOptions[] = $i;
|
||||
if($i<15) $quantiteOptions[] = $i + 0.5;
|
||||
}
|
||||
$coverProducts = $_['coverProducts'];
|
||||
?>
|
||||
<div id="contentTable">
|
||||
<div id="defuntid" data-table="defunt" data-id="<?php echo $_['defunt'][0]->id; ?>"></div>
|
||||
@ -28,60 +29,80 @@
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="col-6" style="margin-bottom: 32px">
|
||||
<h6>INFORMATIONS GÉNÉRALES</h6>
|
||||
<hr>
|
||||
<!-- Date -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Date de décès</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input inputDate w-100" type="date" value="<?php echo $_['defunt'][0]->date_defunt ?>" data-table="defunt" data-column="date" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
<div class="row">
|
||||
<div class="col-6" style="margin-bottom: 32px">
|
||||
<h6>INFORMATIONS GÉNÉRALES</h6>
|
||||
<hr>
|
||||
<!-- Date -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Date de décès</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input inputDate w-100" type="date" value="<?php echo $_['defunt'][0]->date_defunt ?>" data-table="defunt" data-column="date" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Heure -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Heure de soin</div>
|
||||
<div class="col-9">
|
||||
<div class="d-flex flex-row col-12 align-items-center">
|
||||
<div class="col-5">
|
||||
<input class="gestion-input w-100" type="time" value="<?php echo $_['defunt'][0]->heure_debut ?>" data-table="defunt" data-column="heure_debut" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
</div>
|
||||
<div class="d-flex col-2 justify-content-center align-items-center">à</div>
|
||||
<div class="col-5">
|
||||
<input class="gestion-input w-100" type="time" value="<?php echo $_['defunt'][0]->heure_fin ?>" data-table="defunt" data-column="heure_fin" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
<!-- Heure -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Heure de soin</div>
|
||||
<div class="col-9">
|
||||
<div class="d-flex flex-row col-12 align-items-center">
|
||||
<div class="col-5">
|
||||
<input class="gestion-input w-100" type="time" value="<?php echo $_['defunt'][0]->heure_debut ?>" data-table="defunt" data-column="heure_debut" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
</div>
|
||||
<div class="d-flex col-2 justify-content-center align-items-center">à</div>
|
||||
<div class="col-5">
|
||||
<input class="gestion-input w-100" type="time" value="<?php echo $_['defunt'][0]->heure_fin ?>" data-table="defunt" data-column="heure_fin" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Nom -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Nom</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input w-100" type="text" value="<?php echo $_['defunt'][0]->nom_defunt ?>" data-table="defunt" data-column="nom" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
<!-- Nom -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Nom</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input w-100" type="text" value="<?php echo $_['defunt'][0]->nom_defunt ?>" data-table="defunt" data-column="nom" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Date de naissance -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Date de naissance</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input w-100" type="date" value="<?php echo $_['defunt'][0]->date_naissance ?>" data-table="defunt" data-column="date_naissance" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Sexe -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Sexe</div>
|
||||
<div class="col-9">
|
||||
<select class="gestion-select w-100" data-table="defunt" data-column="sexe" data-id="<?php echo $_['defunt'][0]->id ?>">
|
||||
<option value="m" <?php if(strcmp($_['defunt'][0]->sexe, 'm')==0) echo 'selected' ?>>Masculin</option>
|
||||
<option value="f" <?php if(strcmp($_['defunt'][0]->sexe, 'f')==0) echo 'selected' ?>>Féminin</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Référence pacemaker -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 16px">
|
||||
<div class="col-3">Référence pacemaker</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input w-100" type="text" value="<?php echo $_['defunt'][0]->ref_pacemaker ?>" data-table="defunt" data-column="ref_pacemaker" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Date de naissance -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Date de naissance</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input w-100" type="date" value="<?php echo $_['defunt'][0]->date_naissance ?>" data-table="defunt" data-column="date_naissance" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
<div class="col-6">
|
||||
<h6>Housse</h6>
|
||||
<hr>
|
||||
<?php foreach ($coverProducts as $currentCoverProduct): ?>
|
||||
<div class="row">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<input type="radio"
|
||||
name="coverProductsRadioButton"
|
||||
value="<?= htmlspecialchars($currentCoverProduct->id); ?>"
|
||||
<?= $currentCoverProduct->id == $_['defunt'][0]->product_cover_id ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label"><?= htmlspecialchars($currentCoverProduct->description); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Sexe -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||
<div class="col-3">Sexe</div>
|
||||
<div class="col-9">
|
||||
<select class="gestion-select w-100" data-table="defunt" data-column="sexe" data-id="<?php echo $_['defunt'][0]->id ?>">
|
||||
<option value="m" <?php if(strcmp($_['defunt'][0]->sexe, 'm')==0) echo 'selected' ?>>Masculin</option>
|
||||
<option value="f" <?php if(strcmp($_['defunt'][0]->sexe, 'f')==0) echo 'selected' ?>>Féminin</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Référence pacemaker -->
|
||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 16px">
|
||||
<div class="col-3">Référence pacemaker</div>
|
||||
<div class="col-9">
|
||||
<input class="gestion-input w-100" type="text" value="<?php echo $_['defunt'][0]->ref_pacemaker ?>" data-table="defunt" data-column="ref_pacemaker" data-id="<?php echo $_['defunt'][0]->id ?>"/>
|
||||
<?php endforeach; ?>
|
||||
<div class="row p-2">
|
||||
<button class="btn btn-secondary" id="coverProductsRadioButton"> Choisir la housse</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user