insert trajet start for thanato (lieu name is the name of the thanato) when creating an agenda
This commit is contained in:
parent
3d573145ec
commit
8c58746ed7
@ -605,7 +605,8 @@ class Bdd {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function insertTrajetdetails_h2f($numtrajet, $date, $idNextcloud){
|
||||
public function insertTrajetdetails_h2f($numtrajet, $date, $idNextcloud,$lieuSiege = "siege",$devisId = 0){
|
||||
$lieuSiege = strtolower($lieuSiege);
|
||||
$last=0;
|
||||
$last = $this->lastinsertid("ligne_trajet", $idNextcloud) + 1;
|
||||
|
||||
@ -615,8 +616,8 @@ class Bdd {
|
||||
|
||||
$trajetdetails = json_decode($this->getTrajetsdetails_orderByDate($numtrajet, $idNextcloud));
|
||||
|
||||
$sql_h2f = "SELECT * FROM ".$this->tableprefix."lieu WHERE LOWER(".$this->tableprefix."lieu.nom) LIKE 'siege';";
|
||||
$response_h2f = $this->execSQL($sql_h2f, array());
|
||||
$sql_h2f = "SELECT * FROM ".$this->tableprefix."lieu WHERE LOWER(".$this->tableprefix."lieu.nom) = ?";
|
||||
$response_h2f = $this->execSQL($sql_h2f, array($lieuSiege));
|
||||
$h2f = json_decode($response_h2f)[0];
|
||||
|
||||
$id_h2f = ($h2f!=NULL)?$h2f->id:0;
|
||||
@ -631,8 +632,8 @@ class Bdd {
|
||||
`source`,
|
||||
`user_id`
|
||||
)
|
||||
VALUES (?,?,0,?,?,?,'','siege',?);";
|
||||
$this->execSQLNoData($sql, array($idNextcloud,$date,$id_h2f,$numtrajet,$rang+1,$last));
|
||||
VALUES (?,?,?,?,?,?,'','siege',?);";
|
||||
$this->execSQLNoData($sql, array($idNextcloud,$date,$devisId,$id_h2f,$numtrajet,$rang+1,$last));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1142,12 +1143,11 @@ class Bdd {
|
||||
}
|
||||
}
|
||||
|
||||
public function createDevisTrajetFromVCalendar($devisId){
|
||||
$idNextcloud = 'admin';
|
||||
public function createDevisTrajetFromVCalendar($devisId,$idNextcloud = "admin"){
|
||||
$devis = json_decode($this->getOneDevis($devisId, $idNextcloud))[0];
|
||||
$this->generate_ligneTrajet($devis, $idNextcloud);
|
||||
$ligne_trajet = json_decode($this->getOneTrajetdetails_byIdDevis($devis->devisid, $idNextcloud))[0];
|
||||
$this->range_ligneTrajet($ligne_trajet->id_trajet, $idNextcloud);
|
||||
$ligne_trajet = json_decode(json: $this->getOneTrajetdetails_byIdDevis($devis->devisid, $idNextcloud))[0];
|
||||
$this->range_ligneTrajet($ligne_trajet->id_trajet, $idNextcloud,$devis->devisid);
|
||||
$this->calculer_distance_trajet($ligne_trajet->id_trajet, $idNextcloud);
|
||||
}
|
||||
|
||||
@ -1300,7 +1300,7 @@ class Bdd {
|
||||
* 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
|
||||
*/
|
||||
public function range_ligneTrajet($id_trajet, $idNextcloud) {
|
||||
public function range_ligneTrajet($id_trajet, $idNextcloud,$devisId = 0) {
|
||||
$lignes = json_decode($this->getTrajetsdetails_orderByDate($id_trajet, $idNextcloud));
|
||||
$nb_jour = 0;
|
||||
if(sizeof($lignes)>0) {
|
||||
@ -1308,7 +1308,7 @@ class Bdd {
|
||||
$dates = array(0=>$lignes[0]->date);
|
||||
$date_temp = $lignes[0]->date;
|
||||
foreach ($lignes as $key => $ligne) {
|
||||
if(strcmp($date_temp, $ligne->date)!=0) {
|
||||
if(strcmp($date_temp, string2: $ligne->date)!=0) {
|
||||
$date_temp = $ligne->date;
|
||||
array_push($dates, $date_temp);
|
||||
$nb_jour++;
|
||||
@ -1318,7 +1318,7 @@ class Bdd {
|
||||
// on verifie si le nombre de ligne ets correspond à 2*nb_jour (debut et fin de journee)
|
||||
$reste = (2*$nb_jour) - (sizeof(array_filter($lignes, function($ligne) {return strcmp($ligne->source,'siege')==0;})));
|
||||
while ($reste>0) {
|
||||
$this->insertTrajetdetails_h2f($id_trajet, $lignes[0]->date, $idNextcloud);
|
||||
$this->insertTrajetdetails_h2f($id_trajet, $lignes[0]->date, $idNextcloud,$idNextcloud,$devisId);
|
||||
$reste--;
|
||||
}
|
||||
|
||||
@ -1899,8 +1899,8 @@ class Bdd {
|
||||
if(empty($thanatoIds)){
|
||||
return [];
|
||||
}
|
||||
$currentYear = date('Y');
|
||||
$currentMonth = date('m');
|
||||
$currentYear = '2025';
|
||||
$currentMonth = '1';
|
||||
|
||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count($thanatoIds), '?'));
|
||||
$sql = "SELECT
|
||||
|
||||
@ -67,8 +67,7 @@ class GestionService {
|
||||
}
|
||||
else{
|
||||
//get from calendar object
|
||||
$calendarUuid = VCalendarHelpers::GetValueFromKeyInVCalendarString("UID", $vCalendarString);
|
||||
$organizerName = $this->gestionBdd->getCalendarOrganizerNameByCalendarObjectUuid($calendarUuid);
|
||||
$organizerName = $this->getOrganizerNameFromVCalendarString($vCalendarString);
|
||||
if($organizerName != null){
|
||||
$thanatoIdFromDb = $this->gestionBdd->getFirstThanatoIdByName($organizerName);
|
||||
if($thanatoIdFromDb != null){
|
||||
@ -78,6 +77,12 @@ class GestionService {
|
||||
}
|
||||
return $thanatoId;
|
||||
}
|
||||
|
||||
private function getOrganizerNameFromVCalendarString(string $vCalendarString){
|
||||
$calendarUuid = VCalendarHelpers::GetValueFromKeyInVCalendarString("UID", $vCalendarString);
|
||||
$organizerName = $this->gestionBdd->getCalendarOrganizerNameByCalendarObjectUuid($calendarUuid);
|
||||
return $organizerName;
|
||||
}
|
||||
private function GetAttendeesNameFromVCalendarString(string $vCalendarString): array
|
||||
{
|
||||
$names = [];
|
||||
@ -127,7 +132,8 @@ class GestionService {
|
||||
$articlesId = $this->gestionBdd->getArticlesIdFromArticlesNameArray($articlesValue);
|
||||
$this->gestionBdd->insertDevisArticleFromDevisIdAndArticlesIdArray($devisId, $articlesId);
|
||||
}
|
||||
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId);
|
||||
$organizerName = $this->getOrganizerNameFromVCalendarString($vCalendarString);
|
||||
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId,$organizerName);
|
||||
}
|
||||
|
||||
private function GetClientIdFromVCalendarString(string $vCalendarString){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user