fix stats devis thanato
This commit is contained in:
parent
411cc2d5a8
commit
03784fd8e6
@ -2615,7 +2615,7 @@ class Bdd
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getThanatoDevisListByDate($thanatoId, $date)
|
||||
private function getThanatoDevisListByDateSave($thanatoId, $date)
|
||||
{
|
||||
$dateFormatted = $date->format('Y-m-d');
|
||||
$sql = "SELECT
|
||||
@ -2656,6 +2656,42 @@ class Bdd
|
||||
return $devisList;
|
||||
}
|
||||
|
||||
private function getThanatoDevisListByDate($thanatoId, $date)
|
||||
{
|
||||
$dateFormatted = $date->format('Y-m-d');
|
||||
$sql = "SELECT
|
||||
devis.id,
|
||||
devis.date,
|
||||
devis.mentions,
|
||||
devis.num as calendar_uuid,
|
||||
devis.id_defunt as id_defunt,
|
||||
devis.id_lieu as id_lieu,
|
||||
devis.id_client as id_client,
|
||||
devis.id_thanato as id_thanato,
|
||||
thanato.nom as nom_thanato,
|
||||
thanato.prenom as prenom_thanato,
|
||||
defunt.nom as nom_defunt,
|
||||
lieu.nom as nom_lieu,
|
||||
lieu.latitude as lieu_latitude,
|
||||
lieu.longitude as lieu_longitude,
|
||||
client.nom as nom_client,
|
||||
client.entreprise as client_entreprise,
|
||||
client.adresse as client_adresse
|
||||
FROM ".$this->tableprefix."devis as devis
|
||||
LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||
LEFT JOIN ".$this->tableprefix."lieu as lieu on devis.id_lieu = lieu.id
|
||||
LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id
|
||||
LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id
|
||||
WHERE devis.date = ? AND
|
||||
devis.id_thanato = ?
|
||||
ORDER BY devis.date ASC;";
|
||||
$devisList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$dateFormatted,$thanatoId]
|
||||
);
|
||||
return $devisList;
|
||||
}
|
||||
|
||||
public function getThanatoById($thanatoId)
|
||||
{
|
||||
$sql = "SELECT id, nom, prenom,fk_user_uuid FROM ".$this->tableprefix."thanato WHERE id = ? LIMIT 1;";
|
||||
|
||||
@ -34,7 +34,8 @@ use OCA\Gestion\Constants\BddConstant;
|
||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||
use OCA\Gestion\Constants\AbsenceTypeConstant;
|
||||
|
||||
class ExportThanatoStatisticService {
|
||||
class ExportThanatoStatisticService
|
||||
{
|
||||
/** @var Bdd */
|
||||
private $gestionBdd;
|
||||
|
||||
@ -50,14 +51,16 @@ class ExportThanatoStatisticService {
|
||||
Bdd $gestionBdd,
|
||||
LoggerInterface $logger,
|
||||
IRootFolder $rootFolder,
|
||||
GeoService $geoService) {
|
||||
GeoService $geoService
|
||||
) {
|
||||
$this->geoService = $geoService;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->logger = $logger;
|
||||
$this->gestionBdd = $gestionBdd;
|
||||
}
|
||||
|
||||
private function getFilename($thanatoName,$thanatoLastName,$month,$year){
|
||||
private function getFilename($thanatoName, $thanatoLastName, $month, $year)
|
||||
{
|
||||
$filename = "$year-$month-";
|
||||
$filename .= $thanatoName . '-' . $thanatoLastName;
|
||||
$filename = str_replace(' ', '-', $filename);
|
||||
@ -65,7 +68,8 @@ class ExportThanatoStatisticService {
|
||||
return $filename;
|
||||
}
|
||||
|
||||
private function exportThanatoStatistic($thanatoId,$month,$year,$idNextcloud){
|
||||
private function exportThanatoStatistic($thanatoId, $month, $year, $idNextcloud)
|
||||
{
|
||||
$thanato = $this->gestionBdd->getThanatoById($thanatoId);
|
||||
if($thanato == null) {
|
||||
return null;
|
||||
@ -82,8 +86,7 @@ class ExportThanatoStatisticService {
|
||||
$storage = $this->rootFolder->getUserFolder($idNextcloud);
|
||||
try {
|
||||
$storage->newFolder($thanatoFolder);
|
||||
}
|
||||
catch(\OCP\Files\NotPermittedException $e) {
|
||||
} catch(\OCP\Files\NotPermittedException $e) {
|
||||
|
||||
}
|
||||
$filename = $this->getFilename($thanato["nom"], $thanato["prenom"], $month, $year);
|
||||
@ -94,7 +97,8 @@ class ExportThanatoStatisticService {
|
||||
return $fileNamePath;
|
||||
}
|
||||
|
||||
public function exportThanatosListStatistic(array $thanatoIds,$month,$year,$idNextcloud){
|
||||
public function exportThanatosListStatistic(array $thanatoIds, $month, $year, $idNextcloud)
|
||||
{
|
||||
$filenames = [];
|
||||
foreach($thanatoIds as $thanatoId) {
|
||||
$filename = $this->exportThanatoStatistic($thanatoId, $month, $year, $idNextcloud);
|
||||
@ -105,9 +109,10 @@ class ExportThanatoStatisticService {
|
||||
return $filenames;
|
||||
}
|
||||
|
||||
public function getExportThanatoFileHeader(): string{
|
||||
public function getExportThanatoFileHeader(): string
|
||||
{
|
||||
$fileHeader =
|
||||
'FACTURE'.';'.
|
||||
'DEVIS'.';'.
|
||||
'THANATOPRACTEUR'.';'.
|
||||
'DATE'.';'.
|
||||
'HEURE DE DEBUT'.';'.
|
||||
@ -133,10 +138,13 @@ class ExportThanatoStatisticService {
|
||||
return $fileHeader;
|
||||
}
|
||||
|
||||
private function populateNoDevisDataInADay(string $fileContent,$leave){
|
||||
private function populateNoDevisDataInADay(string $fileContent, $leave)
|
||||
{
|
||||
$startTimeValue = "";
|
||||
$endTimeValue = "";
|
||||
$leaveValue = "Non";
|
||||
$restValue = "Non"; // AJOUTER CETTE LIGNE
|
||||
$diseaseValue = "Non"; // AJOUTER CETTE LIGNE
|
||||
if($leave["onLeave"]) {
|
||||
$startTimeValue = $leave["startTime"];
|
||||
$endTimeValue = $leave["endTime"];
|
||||
@ -176,7 +184,8 @@ class ExportThanatoStatisticService {
|
||||
return $fileContent;
|
||||
}
|
||||
|
||||
public function populateExportDataIntoFileContent(array $exportData,string $fileContent): string{
|
||||
public function populateExportDataIntoFileContent(array $exportData, string $fileContent): string
|
||||
{
|
||||
|
||||
$g_totalDistance = 0;
|
||||
$g_totalDevisHours = 0;
|
||||
@ -216,8 +225,7 @@ class ExportThanatoStatisticService {
|
||||
}
|
||||
$totalAbsenceHours = $totalLeaveHours + $totalRestHours + $totalDiseaseHours;
|
||||
$totalWorkedHours -= $totalAbsenceHours;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$totalDevisCount += count($devisData["devisId"]);
|
||||
$routeLines = $this->gestionBdd->getRouteLinesByDevisIdList($devisData["devisId"]);
|
||||
$totalDistanceAndTotalTravelingHoursBetweenDevis = $this->geoService->getTotalDistanceAndTotalTravelingHoursBetweenDevisLocationByRouteLines($routeLines);
|
||||
@ -258,7 +266,8 @@ class ExportThanatoStatisticService {
|
||||
$totalLeaveHours,
|
||||
$totalTravelingHoursBetweenDevisLocation,
|
||||
$totalDiseaseHours,
|
||||
$totalRestHours,$totalDevisCount
|
||||
$totalRestHours,
|
||||
$totalDevisCount
|
||||
);
|
||||
|
||||
$g_totalDistance += $totalDistance;
|
||||
@ -279,13 +288,15 @@ class ExportThanatoStatisticService {
|
||||
$g_totalLeaveHours,
|
||||
$g_totalTravelingHoursBetweenDevisLocation,
|
||||
$g_totalDiseaseHours,
|
||||
$g_totalRestHours,$g_totalDevisCount
|
||||
$g_totalRestHours,
|
||||
$g_totalDevisCount
|
||||
);
|
||||
|
||||
return $fileContent;
|
||||
}
|
||||
|
||||
private function populateLastRecapForTheLine(string $fileContent,$distance,$totalDevisHours,$totalWorkedHours,$totalLeaveHours,$totalTravelingHours ,$totalDiseaseHours = 0,$totalRestHours = 0,$totalDevisCount = 0){
|
||||
private function populateLastRecapForTheLine(string $fileContent, $distance, $totalDevisHours, $totalWorkedHours, $totalLeaveHours, $totalTravelingHours, $totalDiseaseHours = 0, $totalRestHours = 0, $totalDevisCount = 0)
|
||||
{
|
||||
$fileContent = $fileContent.
|
||||
''.';'.
|
||||
''.';'.
|
||||
@ -312,7 +323,8 @@ class ExportThanatoStatisticService {
|
||||
return $fileContent;
|
||||
}
|
||||
|
||||
private function getFormatDevisProduitsAsString($devisProduits){
|
||||
private function getFormatDevisProduitsAsString($devisProduits)
|
||||
{
|
||||
$result = '';
|
||||
foreach ($devisProduits as $produit) {
|
||||
$result .= $produit['produit_reference'] . '-' . $produit['produit_description'] . '--';
|
||||
@ -322,7 +334,8 @@ class ExportThanatoStatisticService {
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function populateDevisDataIntoThanatoExportFileContent(string $fileContent,array $devis){
|
||||
private function populateDevisDataIntoThanatoExportFileContentSave(string $fileContent, array $devis)
|
||||
{
|
||||
$produitAsString = $this->getFormatDevisProduitsAsString($devis["produits"]);
|
||||
$factureNum = $devis["facture_num"] ?? $devis["facture_on_group_num"] ?? "";
|
||||
$fileContent = $fileContent.
|
||||
@ -352,4 +365,35 @@ class ExportThanatoStatisticService {
|
||||
return $fileContent;
|
||||
|
||||
}
|
||||
|
||||
private function populateDevisDataIntoThanatoExportFileContent(string $fileContent, array $devis)
|
||||
{
|
||||
$produitAsString = $this->getFormatDevisProduitsAsString($devis["produits"]);
|
||||
$devisNum = (string)$devis["calendar_uuid"];
|
||||
$fileContent = $fileContent.
|
||||
FileExportHelpers::FormatTextForExport($devisNum).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis['nom_thanato'] . ' ' . $devis['prenom_thanato']).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["date"]).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["startTime"]).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["endTime"]).';'.
|
||||
FileExportHelpers::FormatTextForExport($produitAsString).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["dayType"]).';'.
|
||||
FileExportHelpers::FormatTextForExport('Non').';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["nom_defunt"]).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["nom_lieu"] ?? "").';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["nom_client"] ?? "").';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["client_adresse"] ?? "").
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'."\n";
|
||||
|
||||
return $fileContent;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user