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
|
* @param string $numdefunt
|
||||||
*/
|
*/
|
||||||
public function defuntshow($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(),
|
return new TemplateResponse('gestion', 'defuntshow', array( 'groups' => $this->groups, 'user' => $this->user, 'configuration'=> $this->getConfiguration(),
|
||||||
'defunt'=>json_decode($defunt),
|
'defunt'=>json_decode($defunt),
|
||||||
'path' => $this->idNextcloud,
|
'path' => $this->idNextcloud,
|
||||||
'url' => $this->getNavigationLink(),
|
'url' => $this->getNavigationLink(),
|
||||||
'logo' => $this->getLogo(),
|
'logo' => $this->getLogo(),
|
||||||
'coverProducts' =>$this->myDb->getCoverProducts()
|
'coverProducts' =>json_decode($coverProducts)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -525,7 +525,7 @@ class Bdd {
|
|||||||
return $this->execSQL($sql, array($numdevis));
|
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,"
|
$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."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,"
|
.$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."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
|
LEFT JOIN ".$this->tableprefix."thanato on ".$this->tableprefix."devis.id_thanato = ".$this->tableprefix."thanato.id
|
||||||
WHERE ".$this->tableprefix."defunt.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){
|
public function getListProduit($numdevis, $idNextcloud){
|
||||||
@ -2829,12 +2843,36 @@ class Bdd {
|
|||||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count(ProductConstant::PRODUCT_COVER_REFERENCE_LIST), '?'));
|
$sqlConditionsPlaceholder = implode(',', array_fill(0, count(ProductConstant::PRODUCT_COVER_REFERENCE_LIST), '?'));
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
produit.id,
|
produit.id,
|
||||||
produit.reference
|
produit.reference,
|
||||||
|
produit.description
|
||||||
FROM ".$this->tableprefix."produit as produit
|
FROM ".$this->tableprefix."produit as produit
|
||||||
WHERE produit.reference IN ($sqlConditionsPlaceholder)";
|
WHERE produit.reference IN ($sqlConditionsPlaceholder)";
|
||||||
|
|
||||||
return $this->execSQL($sql,ProductConstant::PRODUCT_COVER_REFERENCE_LIST);
|
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 { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||||
import "./listener/main_listener";
|
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 bibliotheques = [];
|
||||||
let sortedBibliotheques = [];
|
let sortedBibliotheques = [];
|
||||||
@ -72,7 +72,22 @@ window.addEventListener("DOMContentLoaded", function () {
|
|||||||
var rapportSoinBtn = document.getElementById("rapportSoinBtn");
|
var rapportSoinBtn = document.getElementById("rapportSoinBtn");
|
||||||
var rapportBijouxBtn = document.getElementById("rapportBijouxBtn");
|
var rapportBijouxBtn = document.getElementById("rapportBijouxBtn");
|
||||||
var exportCareCertificateButton = document.getElementById("exportCareCertificate");
|
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(){
|
exportCareCertificateButton.addEventListener("click",function(){
|
||||||
exportCareCertificate({defuntId : defuntid});
|
exportCareCertificate({defuntId : defuntid});
|
||||||
|
|||||||
@ -745,3 +745,29 @@ export function exportCareCertificate(defuntIdPayload) {
|
|||||||
error(response);
|
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>1) $quantiteOptions[] = $i;
|
||||||
if($i<15) $quantiteOptions[] = $i + 0.5;
|
if($i<15) $quantiteOptions[] = $i + 0.5;
|
||||||
}
|
}
|
||||||
|
$coverProducts = $_['coverProducts'];
|
||||||
?>
|
?>
|
||||||
<div id="contentTable">
|
<div id="contentTable">
|
||||||
<div id="defuntid" data-table="defunt" data-id="<?php echo $_['defunt'][0]->id; ?>"></div>
|
<div id="defuntid" data-table="defunt" data-id="<?php echo $_['defunt'][0]->id; ?>"></div>
|
||||||
@ -28,60 +29,80 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="col-6" style="margin-bottom: 32px">
|
<div class="row">
|
||||||
<h6>INFORMATIONS GÉNÉRALES</h6>
|
<div class="col-6" style="margin-bottom: 32px">
|
||||||
<hr>
|
<h6>INFORMATIONS GÉNÉRALES</h6>
|
||||||
<!-- Date -->
|
<hr>
|
||||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
<!-- Date -->
|
||||||
<div class="col-3">Date de décès</div>
|
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||||
<div class="col-9">
|
<div class="col-3">Date de décès</div>
|
||||||
<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="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>
|
||||||
</div>
|
<!-- Heure -->
|
||||||
<!-- Heure -->
|
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||||
<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-3">Heure de soin</div>
|
<div class="col-9">
|
||||||
<div class="col-9">
|
<div class="d-flex flex-row col-12 align-items-center">
|
||||||
<div class="d-flex flex-row col-12 align-items-center">
|
<div class="col-5">
|
||||||
<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 ?>"/>
|
||||||
<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>
|
<div class="d-flex col-2 justify-content-center align-items-center">à</div>
|
||||||
<div class="d-flex col-2 justify-content-center align-items-center">à</div>
|
<div class="col-5">
|
||||||
<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 ?>"/>
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- Nom -->
|
||||||
<!-- Nom -->
|
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
||||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
<div class="col-3">Nom</div>
|
||||||
<div class="col-3">Nom</div>
|
<div class="col-9">
|
||||||
<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 ?>"/>
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<!-- Date de naissance -->
|
<div class="col-6">
|
||||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
<h6>Housse</h6>
|
||||||
<div class="col-3">Date de naissance</div>
|
<hr>
|
||||||
<div class="col-9">
|
<?php foreach ($coverProducts as $currentCoverProduct): ?>
|
||||||
<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="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>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
<!-- Sexe -->
|
<div class="row p-2">
|
||||||
<div class="d-flex flex-row align-items-center col-12" style="margin-bottom: 8px">
|
<button class="btn btn-secondary" id="coverProductsRadioButton"> Choisir la housse</button>
|
||||||
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user