diff --git a/gestion/appinfo/routes.php b/gestion/appinfo/routes.php index f76e56a..2ccbfeb 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' => 'GET'], ] ]; \ No newline at end of file diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index 88fe45c..436619a 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,51 @@ 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; + } + + + $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); + + } + //foreach + //$ligne_trajet = json_decode($this->getOneTrajetdetails_byIdDevis($devis->devisid, $idNextcloud))[0]; + /* + if($ligne_trajet != NULL) { + $this->gestion_delete('ligne_trajet', $ligne_trajet->id, $idNextcloud); + $ligne_trajet = NULL; + } + $devis = $this->getOneDevis($devis->devisid, $idNextcloud))[0]; + $this->generate_ligneTrajet($updated_devis, $idNextcloud); + $ligne_trajet = json_decode($this->getOneTrajetdetails_byIdDevis($devis->devisid, $idNextcloud))[0]; + $this->range_ligneTrajet($ligne_trajet->id_trajet, $idNextcloud); + $this->calculer_distance_trajet($ligne_trajet->id_trajet, $idNextcloud); + */ + + } } diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index 14d153c..afab43e 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -3685,4 +3685,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'] )); + } } + +