From e1816f8590ebb65a914088af3ba24de004f647dc Mon Sep 17 00:00:00 2001 From: narindraezway Date: Mon, 30 Jun 2025 15:36:53 +0300 Subject: [PATCH 1/4] Migration : ADD DOCUMENT_GENERATED_DATE AND DOCUMENT_SENT_DATE COLUMNS TO OC_GESTION_FACTURE AND CREATE OC_GESTION_RECAP_FACTURE_STATE TABLE --- .../Sql/20250630-ADD-document_generated_date.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 gestion/lib/Sql/20250630-ADD-document_generated_date.sql diff --git a/gestion/lib/Sql/20250630-ADD-document_generated_date.sql b/gestion/lib/Sql/20250630-ADD-document_generated_date.sql new file mode 100644 index 0000000..594ece1 --- /dev/null +++ b/gestion/lib/Sql/20250630-ADD-document_generated_date.sql @@ -0,0 +1,13 @@ +alter table oc_gestion_facture +add column document_generated_date DATE DEFAULT NULL, +add column document_sent_date DATE DEFAULT NULL; + +create table if not exists oc_gestion_recap_facture_state ( + id INT PRIMARY KEY AUTO_INCREMENT NOT NULL, + fk_client_id INT, + fk_client_group_facturation_id INT, + month INT, + year INT, + document_generated_date DATE DEFAULT NULL, + document_sent_date DATE DEFAULT NULL +); \ No newline at end of file From 5f9a3a9c244211da5e115274443160da3de44fa5 Mon Sep 17 00:00:00 2001 From: narindraezway Date: Thu, 3 Jul 2025 15:50:47 +0300 Subject: [PATCH 2/4] Sort clients by name in dropdown list --- gestion/lib/Controller/PageController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index 53e1986..6afa9d2 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -365,7 +365,10 @@ class PageController extends Controller { $produits = json_decode($this->myDb->getListProduit($d->id, $this->idNextcloud)); $d->dproduits = $produits; } - $clients = json_decode($this->myDb->getClientsAndClientGroupFacturations(includeClientInsideGroup:false)); + $clients = json_decode($this->myDb->getClientsAndClientGroupFacturations(includeClientInsideGroup:false )); + usort($clients, function($a, $b) { + return strcmp($a->nom, $b->nom); + }); return new TemplateResponse('gestion', 'apercustousdevis', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'configuration'=> $this->getConfiguration(), 'devis'=> $devis, @@ -398,6 +401,9 @@ class PageController extends Controller { $facture->dproduits = $produits; } $clients = json_decode($this->myDb->getClientsAndClientGroupFacturations()); + usort($clients, function($a, $b) { + return strcmp($a->nom, $b->nom); + }); return new TemplateResponse('gestion', 'apercustoutesfactures', array( 'groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'configuration'=> $this->getConfiguration(), 'factures'=> $factures, From f46dcf75da2775f7676cede50e8d0feaa5376282 Mon Sep 17 00:00:00 2001 From: narindraezway Date: Wed, 9 Jul 2025 13:28:58 +0300 Subject: [PATCH 3/4] add plus espcae for description in pdf --- .../Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php index c71618c..ea91098 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php @@ -334,7 +334,8 @@ class InvoiceGroupPdfHandler extends FPDF $totalTtc = 0; $totalTva = 0; $yValue = $this->startingYOfArticlesTable + 13; - $maxDescriptionWidth = 102; + // $maxDescriptionWidth = 102; + $maxDescriptionWidth = 104.3; $currentIndexPosition = $this->currentIndexPosition; for ($currentIndexPosition; $currentIndexPosition < ($this->initialIndexPosition + $this->devisCountToGet); $currentIndexPosition++) { $currentDevis = $devisData[$currentIndexPosition]; From c144fbed379870342430a386a6e51f8b3a2414ae Mon Sep 17 00:00:00 2001 From: narindraezway Date: Wed, 9 Jul 2025 13:48:45 +0300 Subject: [PATCH 4/4] Generates the necessary folder for defunt and the client --- .../lib/Service/Devis/Pdf/DevisPdfService.php | 25 +++++++++++++++++++ gestion/lib/Service/GestionService.php | 12 ++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gestion/lib/Service/Devis/Pdf/DevisPdfService.php b/gestion/lib/Service/Devis/Pdf/DevisPdfService.php index 5c48951..adca6b4 100644 --- a/gestion/lib/Service/Devis/Pdf/DevisPdfService.php +++ b/gestion/lib/Service/Devis/Pdf/DevisPdfService.php @@ -150,6 +150,31 @@ class DevisPdfService { $devisByYearFolder ]; } + /** + * Genere simplement le dossier de defunt et client pour le devis pour le user connecter + */ + public function generateClientAndDefuntFolder($devisId,$idNextCloud){ + $storage = $this->rootFolder->getUserFolder($idNextCloud); + $configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); + $currentConfig = $configs[0]; + $devisPdfData = $this->gestionBdd->getDevisPdfDataByDevisId($devisId); + if($devisPdfData == null){ + return null; + } + + $clean_folder = html_entity_decode(string: $currentConfig->path).'/'; + $devisPdfDataFormatted = $this->formatDevisDataToPdfDataFormat($devisPdfData,$currentConfig); + $devisPdfFolders = $this->getDevisPdfFolder($devisPdfDataFormatted,$clean_folder); + + foreach($devisPdfFolders as $folder){ + try { + $storage->newFolder($folder); + } + catch(\OCP\Files\NotPermittedException $e) { + + } + } + } private function GetMultipleDevisFilename($multipleDevisData,$month,$year,$type = DevisExportTypeConstant::TYPE_SINGLE){ $filename = ""; diff --git a/gestion/lib/Service/GestionService.php b/gestion/lib/Service/GestionService.php index c6112f3..53aa809 100644 --- a/gestion/lib/Service/GestionService.php +++ b/gestion/lib/Service/GestionService.php @@ -34,6 +34,7 @@ use OCA\Gestion\Db\Bdd; use OCP\IUserSession; use Psr\Log\LoggerInterface; use OCA\Gestion\Helpers\VCalendarHelpers; +use OCA\Gestion\Service\Devis\Pdf\DevisPdfService; class GestionService { @@ -48,15 +49,22 @@ class GestionService private $userConnectedUuid; + /** @var DevisPdfService */ + private $devisPdfService; + public function __construct( Bdd $gestionBdd, LoggerInterface $logger, TalkService $talkService, - IUserSession $userSession + IUserSession $userSession, + DevisPdfService $devisPdfService + ) { $this->logger = $logger; $this->gestionBdd = $gestionBdd; $this->talkService = $talkService; + $this->devisPdfService = $devisPdfService; + try { $this->userConnectedUuid = $userSession->getUser()->getUID(); } catch (Exception) { @@ -325,12 +333,14 @@ class GestionService $devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devisId, $userName); $this->talkService->sendDevisTalkNotifications($devisTalkMessage, $userName, $this->userConnectedUuid); $this->gestionBdd->createDevisTrajetFromVCalendar($devisId, $userName); + $this->devisPdfService->generateClientAndDefuntFolder($devisId , $this->userConnectedUuid); } catch (\OC\OCS\Exception $e) { $this->logger->debug("Error while handling created calendar object: " . $e->getMessage()); } catch (\Throwable $e) { $this->logger->debug("Error while handling created calendar object: " . $e->getMessage()); } } + private function GetThanatoNameFromVCalendarString($vCalendarString) {