diff --git a/gestion/appinfo/routes.php b/gestion/appinfo/routes.php index f76e56a..477acb5 100644 --- a/gestion/appinfo/routes.php +++ b/gestion/appinfo/routes.php @@ -207,7 +207,8 @@ return [ ['name' => 'provider#moveAttachmentFile', 'url' => '/test-move', 'verb' => 'GET'], ['name' => 'provider#sendEmailAttachment', 'url' => '/test-send-mail-attach', 'verb' => 'GET'], - + + ['name' => 'page#updateDevisLigneTrajet', 'url' => '/updateDevisLigneTrajet', 'verb' => 'POST'], ] ]; \ No newline at end of file diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index 88fe45c..ff68591 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -1481,7 +1481,7 @@ class PageController extends Controller { $this->storage->newFolder($_clean_folder); } catch(\OCP\Files\NotPermittedException $e) { } - $trajetdetails = json_decode($this->myDb->getTrajetsdetails_orderByDate($numtrajet, $idNextcloud)); + $trajetdetails = json_decode($this->myDb->getTrajetsdetails_orderByDate($numtrajet, $this->idNextcloud)); $distance_temp = 0; $distances = array(); $last_point = NULL; @@ -2920,4 +2920,39 @@ class PageController extends Controller { } catch(\OCP\Files\NotFoundException $e) { } } + /** + * @NoAdminRequired + * @NoCSRFRequired + * @param int $defuntId + */ + + public function updateDevisLigneTrajet($idNextcloud ,$mois , $annee){ + //get all devis id from month avril + if(!$idNextcloud || !$mois || !$mois){ + return null; + } + + + $all_devis = $this->myDb->getAllDevisByMonthAndYear($idNextcloud,$mois,$annee); + + foreach($all_devis as $devis){ + + $ligne_trajet = json_decode($this->myDb->getOneTrajetdetails_byIdDevis($devis['id'], $idNextcloud))[0]; + + + if($ligne_trajet != NULL) { + $this->myDb->gestion_delete('ligne_trajet', $ligne_trajet->id, $idNextcloud); + $ligne_trajet = NULL; + } + $devisObject = json_decode($this->myDb->getOneDevis($devis['id'], $idNextcloud))[0]; + + $this->myDb->generate_ligneTrajet($devisObject, $idNextcloud); + $ligne_trajet = json_decode( json: $this->myDb->getOneTrajetdetails_byIdDevis($devisObject->devisid, $idNextcloud))[0]; + $this->myDb->range_ligneTrajet($ligne_trajet->id_trajet, $idNextcloud); + $this->myDb->calculer_distance_trajet(numtrajet: $ligne_trajet->id_trajet, idNextcloud: $idNextcloud); + + } + return true; + + } } diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index ba4eeb1..4bca608 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -2372,7 +2372,7 @@ class Bdd { client.nom as client_nom, client.prenom as client_prenom, client.entreprise as client_entreprise, - client.fk_client_group_id + client.fk_client_group_id as fk_client_group_id FROM ".$this->tableprefix."client as client WHERE client.id = ?;"; $clientList = $this->execSQLNoJsonReturn( @@ -3698,4 +3698,15 @@ class Bdd { return $this->execSQLNoJsonReturn($sql, $devisIdList); } + //get all devis id from month avril + public function getAllDevisByMonthAndYear($idNextcloud,$mois, $annee ){ + $thanato = $this->getThanatoByUserUuid($idNextcloud); + if($thanato == null){ + return array(); + } + $sql = "SELECT * FROM {$this->tableprefix}devis WHERE MONTH(date) = ? AND YEAR(date) = ? AND id_thanato = ?;"; + return $this->execSQLNoJsonReturn($sql,array( $mois , $annee, $thanato['id'] )); + } } + + diff --git a/gestion/lib/Service/GestionService.php b/gestion/lib/Service/GestionService.php index 6a2d7a0..130c971 100644 --- a/gestion/lib/Service/GestionService.php +++ b/gestion/lib/Service/GestionService.php @@ -50,6 +50,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCA\Gestion\Constants\DevisMentionConstant; use OCA\Gestion\Service\Devis\Pdf\DevisPdfService; use OCA\Gestion\Constants\VCalendarPropertyConstant; +use function OCP\Log\logger; class GestionService { /** @var Bdd */ @@ -80,18 +81,15 @@ class GestionService { private IMAPClientFactory $clientFactory; - private ?string $currentUserId; - public function __construct( - ?string $UserId, + IUserSession $userSession, Bdd $gestionBdd, OrderBdd $orderBdd, LoggerInterface $logger, OrderPdfService $orderPdfService, DevisPdfService $devisPdfService, TalkService $talkService, - IUserSession $userSession, IRootFolder $rootFolder, IMailer $mailer, IConfig $config, @@ -101,7 +99,6 @@ class GestionService { ) { - $this->currentUserId = $UserId; $this->orderBdd = $orderBdd; $this->logger = $logger; $this->gestionBdd = $gestionBdd; @@ -520,9 +517,9 @@ class GestionService { } $messageId = (int) $emailId; try { - $message = $this->mailManager->getMessage($this->currentUserId, $messageId); - $mailbox = $this->mailManager->getMailbox($this->currentUserId, $message->getMailboxId()); - $account = $this->accountService->find($this->currentUserId, $mailbox->getAccountId()); + $message = $this->mailManager->getMessage($this->userConnectedUuid, $messageId); + $mailbox = $this->mailManager->getMailbox($this->userConnectedUuid, $message->getMailboxId()); + $account = $this->accountService->find($this->userConnectedUuid, $mailbox->getAccountId()); } catch (DoesNotExistException $e) { return [];