fix change get id_lieu
This commit is contained in:
parent
8e0d004137
commit
771113c66d
@ -1744,44 +1744,55 @@ class PageController extends Controller
|
||||
$trajet = json_decode($this->myDb->getOneTrajet($numtrajet, $this->idNextcloud))[0];
|
||||
|
||||
$formatter_ds = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
|
||||
// Set the pattern for the formatter to "d-MMMM" to display the day and month name in French
|
||||
$formatter_ds->setPattern('dd-MMM');
|
||||
|
||||
$monthName = $this->month_toString(intval($trajet->mois));
|
||||
$fullnameThanato = (($trajet->nom_thanato != null) ? $trajet->nom_thanato : '').' '.(($trajet->prenom_thanato != null) ? $trajet->prenom_thanato : '');
|
||||
|
||||
$_clean_folder = $clean_folder.'INDEMNITES KILOMETRIQUES/'.$trajet->annee.'/'.strtoupper($fullnameThanato).'/';
|
||||
try {
|
||||
$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;
|
||||
|
||||
$ik_temp = 'CLIENTS'.';'.'JOUR'.';'.'LIEU'.';'.'TOTAL'."\n";
|
||||
for ($i = 0; $i < sizeof($trajetdetails); $i++) {
|
||||
|
||||
$total_rows = sizeof($trajetdetails);
|
||||
|
||||
for ($i = 0; $i < $total_rows; $i++) {
|
||||
$date_temp = new DateTime($trajetdetails[$i]->date);
|
||||
if(strcmp(explode('-', $trajetdetails[$i]->date)[2], explode('-', $trajetdetails[$i + 1]->date)[2]) != 0) {
|
||||
|
||||
// Vérifier si c'est la dernière ligne OU si le jour change
|
||||
$is_last_row = ($i == $total_rows - 1);
|
||||
$day_changes = !$is_last_row && (strcmp(explode('-', $trajetdetails[$i]->date)[2], explode('-', $trajetdetails[$i + 1]->date)[2]) != 0);
|
||||
|
||||
if($is_last_row || $day_changes) {
|
||||
// Calculer la distance du retour pour la dernière ligne du jour
|
||||
if($last_point != null && $last_point->lid != null && $trajetdetails[$i]->lid != null) {
|
||||
$currentDistance = $this->myDb->calcul_distance(floatval($last_point->latitude), floatval($last_point->longitude), floatval($trajetdetails[$i]->latitude), floatval($trajetdetails[$i]->longitude));
|
||||
$distance_temp += $currentDistance;
|
||||
}
|
||||
|
||||
// Dernière ligne du jour : afficher le total cumulé
|
||||
array_push($distances, $distance_temp);
|
||||
$ik_temp = $ik_temp.utf8_decode(html_entity_decode($trajetdetails[$i]->cprenoms.' '.$trajetdetails[$i]->cnom)).';'.utf8_decode($formatter_ds->format($date_temp)).';'.utf8_decode(html_entity_decode($trajetdetails[$i]->lieu)).';'.$distance_temp."\n";
|
||||
$ik_temp .= utf8_decode(html_entity_decode($trajetdetails[$i]->cprenoms.' '.$trajetdetails[$i]->cnom)).';'.utf8_decode($formatter_ds->format($date_temp)).';'.utf8_decode(html_entity_decode($trajetdetails[$i]->lieu)).';'.$distance_temp."\n";
|
||||
$distance_temp = 0;
|
||||
$last_point = null;
|
||||
} else {
|
||||
// Calculer la distance depuis last_point vers le point COURANT
|
||||
$currentDistance = 0;
|
||||
if($last_point != null && $last_point->lid != null && $trajetdetails[$i]->lid != null) {
|
||||
$currentDistance = $this->myDb->calcul_distance(floatval($last_point->latitude), floatval($last_point->longitude), floatval($trajetdetails[$i]->latitude), floatval($trajetdetails[$i]->longitude));
|
||||
$distance_temp += $currentDistance;
|
||||
}
|
||||
|
||||
// Mettre à jour last_point avec le point actuel
|
||||
if($trajetdetails[$i]->lid != null) {
|
||||
$last_point = $trajetdetails[$i];
|
||||
}
|
||||
if($last_point->lid != null && $trajetdetails[$i + 1]->lid != null) {
|
||||
|
||||
|
||||
$currentDistance = $this->myDb->calcul_distance(floatval($last_point->latitude), floatval($last_point->longitude), floatval($trajetdetails[$i + 1]->latitude), floatval($trajetdetails[$i + 1]->longitude));
|
||||
$distance_temp += $currentDistance;
|
||||
}
|
||||
$ik_temp = $ik_temp.utf8_decode(html_entity_decode($trajetdetails[$i]->cprenoms.' '.$trajetdetails[$i]->cnom)).';'.utf8_decode($formatter_ds->format($date_temp)).';'.utf8_decode(html_entity_decode($trajetdetails[$i]->lieu)).';'.$currentDistance."\n";
|
||||
$ik_temp .= utf8_decode(html_entity_decode($trajetdetails[$i]->cprenoms.' '.$trajetdetails[$i]->cnom)).';'.utf8_decode($formatter_ds->format($date_temp)).';'.utf8_decode(html_entity_decode($trajetdetails[$i]->lieu)).';'.$currentDistance."\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1790,23 +1801,17 @@ class PageController extends Controller
|
||||
foreach ($distances as $key => $valdistance) {
|
||||
$distance_final += $valdistance;
|
||||
}
|
||||
|
||||
$ik_temp = $ik_temp."\n\n\n\n".''.';'.''.';'.'sous total'.';'.$distance_final;
|
||||
|
||||
$ik_temp .= "\n\n\n\n".''.';'.''.';'.'sous total'.';'.$distance_final;
|
||||
$total_ik = $distance_final * floatval($current_config[0]->coefficient_ik);
|
||||
$ik_temp = $ik_temp."\n\n".''.';'.'TOTAL'.';'.$current_config[0]->coefficient_ik.';'.$total_ik;
|
||||
$ik_temp = $ik_temp."\n".''.';'.'ELECTRIQUE'.';'.''.';'.round($total_ik, 2);
|
||||
|
||||
$ik_temp .= "\n\n".''.';'.'TOTAL'.';'.$current_config[0]->coefficient_ik.';'.$total_ik;
|
||||
$ik_temp .= "\n".''.';'.'ELECTRIQUE'.';'.''.';'.round($total_ik, 2);
|
||||
$nom_thanato = html_entity_decode($trajet->nom_thanato).' '.html_entity_decode($trajet->prenom_thanato);
|
||||
$ff = $_clean_folder.'IK_'.$trajet->annee.'_'.$monthName.'_'.strtoupper($fullnameThanato).'_'.strtoupper($nom_thanato).'.csv';
|
||||
$this->storage->newFile($ff);
|
||||
$file = $this->storage->get($ff);
|
||||
$file->putContent($ik_temp);
|
||||
|
||||
} catch(\OCP\Files\NotFoundException $e) {
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1197,8 +1197,9 @@ class Bdd
|
||||
|
||||
$trajetdetails = json_decode($this->getTrajetsdetails_orderByDate($numtrajet, $idNextcloud));
|
||||
|
||||
$sql_h2f = "SELECT * FROM ".$this->tableprefix."lieu WHERE LOWER(".$this->tableprefix."lieu.nom) = ?";
|
||||
$response_h2f = $this->execSQL($sql_h2f, array($lieuSiege));
|
||||
$sql_h2f = "SELECT * FROM ".$this->tableprefix."lieu WHERE LOWER(nom) LIKE ? LIMIT 1";
|
||||
$response_h2f = $this->execSQL($sql_h2f, array('%' . strtolower($lieuSiege) . '%'));
|
||||
|
||||
$h2f = json_decode($response_h2f)[0];
|
||||
|
||||
$id_h2f = ($h2f != null) ? $h2f->id : 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user