add depart from home in trajet thantho
This commit is contained in:
parent
20b4f678e0
commit
c22ee124a5
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||||||
namespace OCA\Gestion\Constants;
|
namespace OCA\Gestion\Constants;
|
||||||
abstract class VCalendarPropertyConstant
|
abstract class VCalendarPropertyConstant
|
||||||
{
|
{
|
||||||
const PROPERTY_IS_LEAVE = "ISPRIVATE";
|
const PROPERTY_IS_PRIVATE = "ISPRIVATE";
|
||||||
const ABSENCE_TYPE = "ABSENCETYPE";
|
const ABSENCE_TYPE = "ABSENCETYPE";
|
||||||
const RETURN_TO_SIEGE = "RETURNTOSIEGE";
|
const RETURN_TO_SIEGE = "RETURNTOSIEGE";
|
||||||
|
|
||||||
|
|||||||
@ -1296,9 +1296,9 @@ class Bdd {
|
|||||||
|
|
||||||
$this->insertTrajetdetails_byDevis($trajet->id, $devis, $idNextcloud);
|
$this->insertTrajetdetails_byDevis($trajet->id, $devis, $idNextcloud);
|
||||||
if($devis->return_to_siege){
|
if($devis->return_to_siege){
|
||||||
$hasDepartH2f = $this->check_has_depart_h2f($devis->date,$trajet->id);
|
$hasDepartFromHome = $this->check_has_depart_from_home($devis->date,$trajet->id ,$idNextcloud);
|
||||||
if(!$hasDepartH2f) {
|
if(!$hasDepartFromHome) {
|
||||||
$this->insertTrajetDetails_h2f($trajet->id, $devis->date, $idNextcloud);
|
$this->insertTrajetHome($devis->date,$trajet->id ,$idNextcloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hasAlreadyReturnToSiege = $this->check_if_return_to_siege_already_exist( $devis->date , $trajet->id , $devis->devisid);
|
$hasAlreadyReturnToSiege = $this->check_if_return_to_siege_already_exist( $devis->date , $trajet->id , $devis->devisid);
|
||||||
@ -1319,9 +1319,9 @@ class Bdd {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function check_has_depart_h2f($date,$trajetId) {
|
public function check_has_depart_from_home($date,$trajetId ,$idNextcloud) {
|
||||||
$sql = "SELECT COUNT(*) AS LIGNE_COUNT FROM `".$this->tableprefix."ligne_trajet` WHERE id_trajet = ? AND date = ? AND source = ?;";
|
$sql = "SELECT COUNT(*) AS LIGNE_COUNT FROM `".$this->tableprefix."ligne_trajet` WHERE id_trajet = ? AND date = ? AND source = ?;";
|
||||||
$response = $this->execSQL($sql, array($trajetId,$date,'h2f'));
|
$response = $this->execSQL($sql, array($trajetId,$date,$idNextcloud));
|
||||||
$response = json_decode($response)[0];
|
$response = json_decode($response)[0];
|
||||||
if($response->LIGNE_COUNT > 0 ) {
|
if($response->LIGNE_COUNT > 0 ) {
|
||||||
return true;
|
return true;
|
||||||
@ -1329,10 +1329,11 @@ class Bdd {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function insertTrajetGoHome($date,$trajetId , $idNextcloud) {
|
// Inserer une ligne de trajet from home or to home
|
||||||
|
public function insertTrajetHome($date,$trajetId , $idNextcloud) {
|
||||||
|
/** Ceci est un nouveau concept. Après tout ce temps, nous devons préciser la date de la nouvelle demande pour faire
|
||||||
/** Ceci est un nouveau concept. Après tout ce temps, nous devons préciser la date d'application de la nouvelle demande. pour la go to thanatho */
|
* l'ajout d'un thanato depuis son domicile ver le siege .
|
||||||
|
*/
|
||||||
$dateTime = new DateTime($date);
|
$dateTime = new DateTime($date);
|
||||||
$dateTimeForFunctionalityGoToHome = new DateTime('2025-04-07');
|
$dateTimeForFunctionalityGoToHome = new DateTime('2025-04-07');
|
||||||
|
|
||||||
@ -1351,7 +1352,8 @@ class Bdd {
|
|||||||
|
|
||||||
$lieuId = $responseLocation != null ? $responseLocation->id : 0;
|
$lieuId = $responseLocation != null ? $responseLocation->id : 0;
|
||||||
|
|
||||||
$sql = "INSERT INTO `".$this->tableprefix."ligne_trajet` ( `id_nextcloud`,
|
$sql = "INSERT INTO `".$this->tableprefix."ligne_trajet` (
|
||||||
|
`id_nextcloud`,
|
||||||
`date`,
|
`date`,
|
||||||
`id_devis`,
|
`id_devis`,
|
||||||
`id_client`,
|
`id_client`,
|
||||||
@ -1366,10 +1368,6 @@ class Bdd {
|
|||||||
$this->execSQLNoData($sql, array($idNextcloud,$date,0 ,0,$lieuId,$trajetId,$rang+1,$idNextcloud,$last));
|
$this->execSQLNoData($sql, array($idNextcloud,$date,0 ,0,$lieuId,$trajetId,$rang+1,$idNextcloud,$last));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function range_ligneTrajetV2($id_trajet, $idNextcloud) {
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* ranger les lignes de trajet dans un trajet par date et par rang
|
* ranger les lignes de trajet dans un trajet par date et par rang
|
||||||
* inserer ligne siege au debut et fin de chaque journee s'il n'existe pas
|
* inserer ligne siege au debut et fin de chaque journee s'il n'existe pas
|
||||||
@ -1379,14 +1377,14 @@ class Bdd {
|
|||||||
$datesLignes = [];
|
$datesLignes = [];
|
||||||
$lastRangOfTrajetPossible = 200;
|
$lastRangOfTrajetPossible = 200;
|
||||||
if(sizeof($lignes)>0) {
|
if(sizeof($lignes)>0) {
|
||||||
|
//Groupe By date all lignes de trajet
|
||||||
foreach ($lignes as $key => $ligne) {
|
foreach ($lignes as $key => $ligne) {
|
||||||
$datesLignes[$ligne->date][] = $ligne;
|
$datesLignes[$ligne->date][] = $ligne;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($datesLignes as $date => $currentDateLignes){
|
foreach($datesLignes as $date => $currentDateLignes){
|
||||||
$dateTime = new DateTime($date);
|
$dateTime = new DateTime($date);
|
||||||
$dateTimeForFunctionalityGoToHome = new DateTime('2025-04-07');
|
$dateTimeForFunctionalityGoToHome = new DateTime('2025-04-07');//Don't edit this date, it's a date for the new functionality
|
||||||
|
|
||||||
|
|
||||||
if ( $dateTime <= $dateTimeForFunctionalityGoToHome) {
|
if ( $dateTime <= $dateTimeForFunctionalityGoToHome) {
|
||||||
|
|
||||||
@ -1407,25 +1405,20 @@ class Bdd {
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
//Nouvelle fonctionnalité
|
//Nouvelle fonctionnalité
|
||||||
|
$maxCountLigneHome = 2;
|
||||||
$resteH2f = 1 - (sizeof(array_filter($currentDateLignes, function($ligne) {return strcmp($ligne->source,'h2f')==0;})));
|
|
||||||
if ($resteH2f > 0 ) {
|
$resteHome = $maxCountLigneHome - (sizeof(array_filter($currentDateLignes, function($ligne ) use ($idNextcloud) {return strcmp($ligne->source, $idNextcloud)==0;})));
|
||||||
$this->insertTrajetDetails_h2f($id_trajet, $date, $idNextcloud);
|
while ($resteHome > 0 ) {
|
||||||
|
$this->insertTrajetHome($date ,$id_trajet,$idNextcloud);
|
||||||
|
$resteHome--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ligneHome = json_decode($this->getTrajetsDetailsByDateAndSource($id_trajet, $date, $idNextcloud));
|
||||||
$resteGoHome = 1 - (sizeof(array_filter($currentDateLignes, function($ligne ) use ($idNextcloud) {return strcmp($ligne->source, $idNextcloud)==0;})));
|
|
||||||
if ($resteGoHome > 0 ) {
|
|
||||||
$this->insertTrajetGoHome($date ,$id_trajet,$idNextcloud);
|
|
||||||
}
|
|
||||||
|
|
||||||
$h2fLinge = json_decode($this->getTrajetsDetailsByDateAndSource($id_trajet, $date, 'h2f'));
|
|
||||||
$ligneGoHome = json_decode($this->getTrajetsDetailsByDateAndSource($id_trajet, $date, $idNextcloud));
|
|
||||||
$ordered_lines = json_decode($this->getTrajetsDetailsByDateAndSource($id_trajet, $date));
|
$ordered_lines = json_decode($this->getTrajetsDetailsByDateAndSource($id_trajet, $date));
|
||||||
|
if (count($ligneHome) == $maxCountLigneHome) {
|
||||||
$this->update_ligneTrajet('ligne_trajet', 'rang', 0, $h2fLinge[0]->id, $idNextcloud);
|
$this->update_ligneTrajet('ligne_trajet', 'rang', 0, $ligneHome[0]->id, $idNextcloud);
|
||||||
|
$this->update_ligneTrajet('ligne_trajet', 'rang', $lastRangOfTrajetPossible, $ligneHome[1]->id, $idNextcloud);
|
||||||
$this->update_ligneTrajet('ligne_trajet', 'rang', $lastRangOfTrajetPossible, $ligneGoHome[0]->id, $idNextcloud);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ordered_lines = json_decode($this->getTrajetsDetailsByDateAndSource($id_trajet, $date));
|
$ordered_lines = json_decode($this->getTrajetsDetailsByDateAndSource($id_trajet, $date));
|
||||||
@ -1435,45 +1428,6 @@ class Bdd {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// on verifie si le nombre de ligne h2f correspond à 2*nb_jour (debut et fin de journee)
|
|
||||||
// $reste = (2*$nb_jour) - (sizeof(array_filter($lignes, function($ligne) {return strcmp($ligne->source,'h2f')==0;})));
|
|
||||||
// while ($reste>0) {
|
|
||||||
// $this->insertTrajetDetails_h2f($id_trajet, $lignes[0]->date, $idNextcloud);
|
|
||||||
// $reste--;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $current_lines = json_decode($this->getTrajetsdetails_orderByDate($id_trajet, $idNextcloud));
|
|
||||||
|
|
||||||
// // ici le nombre de ligne h2f est egale au nb_jour*2
|
|
||||||
// $array_siege = array();
|
|
||||||
// $array_home = array();
|
|
||||||
// foreach ($current_lines as $key => $ligne) {
|
|
||||||
// if(strcmp($ligne->source,'h2f') == 0) {
|
|
||||||
// array_push($array_siege, $ligne);
|
|
||||||
// }else{
|
|
||||||
// if(strcmp($ligne->source, $idNextcloud ) == 0 ) {
|
|
||||||
// array_push($array_home, $ligne);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $j=0;
|
|
||||||
// for ($i=0; $i < sizeof($dates); $i++) {
|
|
||||||
|
|
||||||
// $this->update_ligneTrajet('ligne_trajet', 'rang', 0, $array_siege[$j]->id, $idNextcloud);
|
|
||||||
// $this->update_ligneTrajet('ligne_trajet', 'date', $dates[$i], $array_siege[$j]->id, $idNextcloud);
|
|
||||||
|
|
||||||
// $this->update_ligneTrajet('ligne_trajet', 'rang', sizeof($current_lines)+1, $array_siege[$j+1]->id, $idNextcloud);
|
|
||||||
// $this->update_ligneTrajet('ligne_trajet', 'date', $dates[$i], $array_siege[$j+1]->id, $idNextcloud);
|
|
||||||
// $j+=2;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $ordered_lines = json_decode($this->getTrajetsdetails_orderByDate($id_trajet, $idNextcloud));
|
|
||||||
// foreach ($ordered_lines as $key => $line) {
|
|
||||||
// $this->update_ligneTrajet('ligne_trajet', 'rang', $key+1, $line->id, $idNextcloud);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -212,7 +212,7 @@ class GestionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function GetIsPivateFromVCalendarString(string $vCalendarString): bool{
|
private function GetIsPivateFromVCalendarString(string $vCalendarString): bool{
|
||||||
$isPrivateValue = VCalendarHelpers::GetValueFromKeyInVCalendarString(VCalendarPropertyConstant::PROPERTY_IS_LEAVE, $vCalendarString);
|
$isPrivateValue = VCalendarHelpers::GetValueFromKeyInVCalendarString(VCalendarPropertyConstant::PROPERTY_IS_PRIVATE, $vCalendarString);
|
||||||
return $isPrivateValue === "1" ? true : false;
|
return $isPrivateValue === "1" ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user