Merge branch 'fixes/fix-add-articles-in-export-devis' into staging
This commit is contained in:
commit
7816f73d78
@ -2559,7 +2559,7 @@ class PageController extends Controller {
|
|||||||
try{
|
try{
|
||||||
$current_config = json_decode($this->myDb->getConfiguration($this->idNextcloud));
|
$current_config = json_decode($this->myDb->getConfiguration($this->idNextcloud));
|
||||||
$clean_folder = html_entity_decode($current_config[0]->path).'/';
|
$clean_folder = html_entity_decode($current_config[0]->path).'/';
|
||||||
$_clean_folder = $clean_folder.'STATISTIQUES/';
|
$_clean_folder = $clean_folder.'STATISTIQUES/THANATOS/';
|
||||||
try {
|
try {
|
||||||
$this->storage->newFolder($_clean_folder);
|
$this->storage->newFolder($_clean_folder);
|
||||||
}
|
}
|
||||||
@ -2568,9 +2568,8 @@ class PageController extends Controller {
|
|||||||
}
|
}
|
||||||
$fileHeader = $this->exportThanatoStatisticService->getExportThanatoFileHeader();
|
$fileHeader = $this->exportThanatoStatisticService->getExportThanatoFileHeader();
|
||||||
$fileContent = $this->exportThanatoStatisticService->populateExportDataIntoFileContent($exportData,$fileHeader);
|
$fileContent = $this->exportThanatoStatisticService->populateExportDataIntoFileContent($exportData,$fileHeader);
|
||||||
$thanatoIdsString = implode('-', $thanatoIdsToExport);
|
$filename = $this->exportThanatoStatisticService->getFilename($thanatoIdsToExport);
|
||||||
$uuid = Uuid::uuid4()->toString();
|
$fileNamePath = $_clean_folder."STAT-THANATOS-" . $filename . '.csv';
|
||||||
$fileNamePath = $_clean_folder."STAT-ThanatoIds-" . $thanatoIdsString . '-' . $uuid . '.csv';
|
|
||||||
$this->storage->newFile($fileNamePath);
|
$this->storage->newFile($fileNamePath);
|
||||||
$file = $this->storage->get($fileNamePath);
|
$file = $this->storage->get($fileNamePath);
|
||||||
$file->putContent($fileContent);
|
$file->putContent($fileContent);
|
||||||
|
|||||||
@ -86,6 +86,26 @@ class Bdd {
|
|||||||
return $this->execSQL($sql, array());
|
return $this->execSQL($sql, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getThanatoByIds(array $thanatoIds){
|
||||||
|
if(empty($thanatoIds)){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sqlConditionsPlaceholder = implode(',', array_fill(0, count($thanatoIds), '?'));
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
thanato.id,
|
||||||
|
thanato.nom as thanato_nom,
|
||||||
|
thanato.prenom as thanato_prenom
|
||||||
|
FROM ".$this->tableprefix."thanato as thanato
|
||||||
|
WHERE thanato.id IN ($sqlConditionsPlaceholder)";
|
||||||
|
$thanatoList = $this->execSQLNoJsonReturn(
|
||||||
|
$sql,
|
||||||
|
$thanatoIds);
|
||||||
|
|
||||||
|
return $thanatoList;
|
||||||
|
}
|
||||||
|
|
||||||
public function getBibliotheques($idNextcloud) {
|
public function getBibliotheques($idNextcloud) {
|
||||||
$sql = "SELECT * FROM ".$this->tableprefix."bibliotheque;";
|
$sql = "SELECT * FROM ".$this->tableprefix."bibliotheque;";
|
||||||
return $this->execSQL($sql, array());
|
return $this->execSQL($sql, array());
|
||||||
@ -359,9 +379,8 @@ class Bdd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getProduits($idNextcloud){
|
public function getProduits($idNextcloud){
|
||||||
// $sql = "SELECT * FROM ".$this->tableprefix."produit WHERE id_nextcloud = ?";
|
$sql = "SELECT * FROM ".$this->tableprefix."produit
|
||||||
$sql = "SELECT * FROM ".$this->tableprefix."produit";
|
WHERE $this->tableprefix.produit.id";
|
||||||
// return $this->execSQL($sql, array($idNextcloud));
|
|
||||||
return $this->execSQL($sql, array());
|
return $this->execSQL($sql, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1754,11 +1773,30 @@ class Bdd {
|
|||||||
return $devisListGroupedByDateAndThenByThanato;
|
return $devisListGroupedByDateAndThenByThanato;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getProduitsDevisByDevisId($devisId){
|
||||||
|
$sql = "SELECT
|
||||||
|
produit_devis.id as produit_devis_id,
|
||||||
|
produit.id as produit_id,
|
||||||
|
produit.reference as produit_reference,
|
||||||
|
produit.description as 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 = ?;";
|
||||||
|
$produitsList = $this->execSQLNoJsonReturn(
|
||||||
|
$sql,
|
||||||
|
[$devisId]);
|
||||||
|
return $produitsList;
|
||||||
|
}
|
||||||
|
|
||||||
private function getDevisListGroupedByDateAndThenByThanato(array $devisList){
|
private function getDevisListGroupedByDateAndThenByThanato(array $devisList){
|
||||||
$devisListGroupedByDateAndThenByThanato = [];
|
$devisListGroupedByDateAndThenByThanato = [];
|
||||||
foreach($devisList as $devis){
|
foreach($devisList as $devis){
|
||||||
$devisDate = $devis["date"];
|
$devisDate = $devis["date"];
|
||||||
$devisThanatoId = $devis["id_thanato"];
|
$devisThanatoId = $devis["id_thanato"];
|
||||||
|
$devis = $this->setDevisStartAndEndTime($devis);
|
||||||
|
$devis = $this->setDevisIsWeekendOrNotText($devis);
|
||||||
|
$devis = $this->setDevisProduitsList($devis);
|
||||||
|
//set devis articles list into devis data
|
||||||
if (!isset($devisListGroupedByDateAndThenByThanato[$devisThanatoId])) {
|
if (!isset($devisListGroupedByDateAndThenByThanato[$devisThanatoId])) {
|
||||||
$devisListGroupedByDateAndThenByThanato[$devisThanatoId] = [];
|
$devisListGroupedByDateAndThenByThanato[$devisThanatoId] = [];
|
||||||
}
|
}
|
||||||
@ -1769,14 +1807,23 @@ class Bdd {
|
|||||||
"devisId" => []
|
"devisId" => []
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$devis = $this->setDevisStartAndEndTime($devis);
|
|
||||||
$devis = $this->setDevisIsWeekendOrNotText($devis);
|
|
||||||
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devis"][] = $devis;
|
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devis"][] = $devis;
|
||||||
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devisId"][] = $devis['id'];
|
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devisId"][] = $devis['id'];
|
||||||
}
|
}
|
||||||
return $devisListGroupedByDateAndThenByThanato;
|
return $devisListGroupedByDateAndThenByThanato;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setDevisProduitsList($devis){
|
||||||
|
$produitsList = $this->getProduitsDevisByDevisId($devis['id']);
|
||||||
|
foreach($produitsList as $produit){
|
||||||
|
if (!isset($devis['produits'])) {
|
||||||
|
$devis['produits'] = [];
|
||||||
|
}
|
||||||
|
$devis['produits'][] = $produit;
|
||||||
|
}
|
||||||
|
return $devis;
|
||||||
|
}
|
||||||
|
|
||||||
private function setDevisIsWeekendOrNotText($devis){
|
private function setDevisIsWeekendOrNotText($devis){
|
||||||
$isWeekend = DateHelpers::isWeekend($devis['date']);
|
$isWeekend = DateHelpers::isWeekend($devis['date']);
|
||||||
$value = $isWeekend ? "Ferie" : "J";
|
$value = $isWeekend ? "Ferie" : "J";
|
||||||
|
|||||||
@ -43,12 +43,25 @@ class ExportThanatoStatisticService {
|
|||||||
$this->gestionBdd = $gestionBdd;
|
$this->gestionBdd = $gestionBdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFilename(array $thanatoIds){
|
||||||
|
$thanatoList = $this->gestionBdd->getThanatoByIds($thanatoIds);
|
||||||
|
$currentYear = date('Y');
|
||||||
|
$currentMonth = date('m');
|
||||||
|
$filename = "$currentYear-$currentMonth-";
|
||||||
|
foreach($thanatoList as $thanato){
|
||||||
|
$filename .= $thanato['thanato_nom'] . '-' . $thanato['thanato_prenom'] . '--';
|
||||||
|
}
|
||||||
|
$filename = rtrim($filename, '-');
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
|
|
||||||
public function getExportThanatoFileHeader(): string{
|
public function getExportThanatoFileHeader(): string{
|
||||||
$fileHeader =
|
$fileHeader =
|
||||||
'Thanatopracteur'.';'.
|
'Thanatopracteur'.';'.
|
||||||
'Date'.';'.
|
'Date'.';'.
|
||||||
'Heure Debut'.';'.
|
'Heure Debut'.';'.
|
||||||
'Heure Fin'.';'.
|
'Heure Fin'.';'.
|
||||||
|
'Soins'.';'.
|
||||||
utf8_decode(html_entity_decode('Jour/Ferie')).';'.
|
utf8_decode(html_entity_decode('Jour/Ferie')).';'.
|
||||||
utf8_decode(html_entity_decode('Nom et Prénom')).';'.
|
utf8_decode(html_entity_decode('Nom et Prénom')).';'.
|
||||||
'Lieu'.';'.
|
'Lieu'.';'.
|
||||||
@ -86,16 +99,29 @@ class ExportThanatoStatisticService {
|
|||||||
''.';'.
|
''.';'.
|
||||||
''.';'.
|
''.';'.
|
||||||
''.';'.
|
''.';'.
|
||||||
|
''.';'.
|
||||||
utf8_decode(html_entity_decode("$distance"))."\n";
|
utf8_decode(html_entity_decode("$distance"))."\n";
|
||||||
return $fileContent;
|
return $fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getFormatDevisProduitsAsString($devisProduits){
|
||||||
|
$result = '';
|
||||||
|
foreach ($devisProduits as $produit) {
|
||||||
|
$result .= $produit['produit_reference'] . '-' . $produit['produit_description'] . '--';
|
||||||
|
}
|
||||||
|
// Remove the trailing "--" at the end
|
||||||
|
$result = rtrim($result, '-');
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
private function populateDevisDataIntoThanatoExportFileContent(string $fileContent,array $devis){
|
private function populateDevisDataIntoThanatoExportFileContent(string $fileContent,array $devis){
|
||||||
|
$produitAsString = $this->getFormatDevisProduitsAsString($devis["produits"]);
|
||||||
$fileContent = $fileContent.
|
$fileContent = $fileContent.
|
||||||
utf8_decode(html_entity_decode($devis['nom_thanato'] . ' ' . $devis['prenom_thanatho'])).';'.
|
utf8_decode(html_entity_decode($devis['nom_thanato'] . ' ' . $devis['prenom_thanatho'])).';'.
|
||||||
utf8_decode(html_entity_decode($devis["date"])).';'.
|
utf8_decode(html_entity_decode($devis["date"])).';'.
|
||||||
utf8_decode(html_entity_decode($devis["startTime"])).';'.
|
utf8_decode(html_entity_decode($devis["startTime"])).';'.
|
||||||
utf8_decode(html_entity_decode($devis["endTime"])).';'.
|
utf8_decode(html_entity_decode($devis["endTime"])).';'.
|
||||||
|
utf8_decode(html_entity_decode($produitAsString)).';'.
|
||||||
utf8_decode(html_entity_decode($devis["dayType"])).';'.
|
utf8_decode(html_entity_decode($devis["dayType"])).';'.
|
||||||
utf8_decode(html_entity_decode($devis["nom_defunt"])).';'.
|
utf8_decode(html_entity_decode($devis["nom_defunt"])).';'.
|
||||||
utf8_decode(html_entity_decode($devis["nom_lieu"] ?? "")).';'.
|
utf8_decode(html_entity_decode($devis["nom_lieu"] ?? "")).';'.
|
||||||
|
|||||||
35
gestion/package-lock.json
generated
35
gestion/package-lock.json
generated
@ -654,6 +654,17 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@popperjs/core": {
|
||||||
|
"version": "2.11.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
|
||||||
|
"integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/popperjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@skjnldsv/sanitize-svg": {
|
"node_modules/@skjnldsv/sanitize-svg": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@skjnldsv/sanitize-svg/-/sanitize-svg-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@skjnldsv/sanitize-svg/-/sanitize-svg-1.0.2.tgz",
|
||||||
@ -2520,6 +2531,13 @@
|
|||||||
"node": ">=8.0.0"
|
"node": ">=8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ical.js": {
|
||||||
|
"version": "1.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ical.js/-/ical.js-1.5.0.tgz",
|
||||||
|
"integrity": "sha512-7ZxMkogUkkaCx810yp0ZGKvq1ZpRgJeornPttpoxe6nYZ3NLesZe1wWMXDdwTkj/b5NtXT+Y16Aakph/ao98ZQ==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
"node_modules/iconv-lite": {
|
"node_modules/iconv-lite": {
|
||||||
"version": "0.6.3",
|
"version": "0.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||||
@ -3011,6 +3029,13 @@
|
|||||||
"linkifyjs": "^4.0.0"
|
"linkifyjs": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/linkifyjs": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
"node_modules/loader-runner": {
|
"node_modules/loader-runner": {
|
||||||
"version": "4.3.0",
|
"version": "4.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
|
||||||
@ -4540,6 +4565,16 @@
|
|||||||
"base64-arraybuffer": "^1.0.2"
|
"base64-arraybuffer": "^1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/v-click-outside": {
|
"node_modules/v-click-outside": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/v-click-outside/-/v-click-outside-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/v-click-outside/-/v-click-outside-3.2.0.tgz",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user