3684 lines
174 KiB
PHP
3684 lines
174 KiB
PHP
<?php
|
|
include "../config/config.php";
|
|
Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session et vérifiant que les accès sont autorisés.
|
|
|
|
Entete_page_html();
|
|
|
|
//SELECT TBV.Nom, TBMB.Valeur, TBMB.No_paquet FROM TB_BATEAUX_Mesures_batteries TBMB INNER JOIN TB_BATEAUX_Variables TBV ON TBMB.ID_Variable = TBV.Cle_primaire WHERE TBV.ID_Bateau = 1 AND TBMB.ID_Bateau = 1;
|
|
|
|
//************************************************************************************************************************************
|
|
// Initialisation des variables globales
|
|
//************************************************************************************************************************************
|
|
$message_erreur = "";
|
|
$message_information = "";
|
|
|
|
Ouverture_bdd(); // Connexion à MySql
|
|
|
|
|
|
//************************************************************************************************************************************
|
|
// Traitement des variables d'entrées
|
|
//************************************************************************************************************************************
|
|
|
|
// Variables de SESSION :
|
|
if (!isset($_SESSION['Bateaux']['page'])) $_SESSION['Bateaux']['page'] = 'Accueil';
|
|
if (!isset($_SESSION['Bateaux']['ancre'])) $_SESSION['Bateaux']['ancre'] = "";
|
|
if (!isset($_SESSION['Bateaux']['origine'])) $_SESSION['Bateaux']['origine'] = "";
|
|
if (!isset($_SESSION['Bateaux']['tri_liste'])) $_SESSION['Bateaux']['tri_liste'] = "Flotte";
|
|
if (!isset($_SESSION['Bateaux']['sens_tri_liste'])) $_SESSION['Bateaux']['sens_tri_liste'] = "ASC";
|
|
if (!isset($_SESSION['Bateaux']['type_details_bateau'])) $_SESSION['Bateaux']['type_details_bateau'] = "TB_BATEAUX_Carte";
|
|
if (!isset($_SESSION['Bateaux']['id_entree_details_bateau'])) $_SESSION['Bateaux']['id_entree_details_bateau'] = 0;
|
|
if (!isset($_SESSION['Bateaux']['type_courbe_details_bateau'])) $_SESSION['Bateaux']['type_courbe_details_bateau'] = "Aucune";
|
|
if (!isset($_SESSION['Bateaux']['bateau']['Cle_primaire'])) $_SESSION['Bateaux']['bateau']['Cle_primaire'] = 0;
|
|
if (!isset($_SESSION['Bateaux']['bateau']['Nom'])) $_SESSION['Bateaux']['bateau']['Nom'] = "";
|
|
if (!isset($_SESSION['Bateaux']['bateau']['ID_Flotte'])) $_SESSION['Bateaux']['bateau']['ID_Flotte'] = 0;
|
|
if (!isset($_SESSION['Bateaux']['bateau']['ID_Carte'])) $_SESSION['Bateaux']['bateau']['ID_Carte'] = 0;
|
|
if (!isset($_SESSION['Bateaux']['bateau']['ID_Famille'])) $_SESSION['Bateaux']['bateau']['ID_Famille'] = 0;
|
|
if (!isset($_SESSION['Bateaux']['bateau']['Date_mes'])) $_SESSION['Bateaux']['bateau']['Date_mes'] = date("Y-m-d");
|
|
if (!isset($_SESSION['Bateaux']['bateau']['Date_carte'])) $_SESSION['Bateaux']['bateau']['Date_carte'] = date("Y-m-d");
|
|
if (!isset($_SESSION['Bateaux']['bateau']['Commentaires'])) $_SESSION['Bateaux']['bateau']['Commentaires'] = "";
|
|
|
|
|
|
// Variables GET :
|
|
if (isset($_GET['ancre'])) $_SESSION['Bateaux']['ancre'] = $_GET['ancre'];
|
|
|
|
if (isset($_GET['action']))
|
|
{
|
|
switch ($_GET['action'])
|
|
{
|
|
//===================================
|
|
case "navigation":
|
|
{
|
|
if (isset($_GET['destination']))
|
|
{
|
|
$_SESSION['Bateaux']['page'] = $_GET['destination'];
|
|
}
|
|
|
|
if (isset($_GET['ancre']))
|
|
{
|
|
$_SESSION['Bateaux']['ancre'] = $_GET['ancre'];
|
|
}
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "changement_langue":
|
|
{
|
|
if (isset($_GET['langue']))
|
|
{
|
|
$_SESSION['langue'] = $_GET['langue'];
|
|
chargement_langue();
|
|
}
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "changement_type":
|
|
{
|
|
if (isset($_GET['type']))
|
|
{
|
|
$_SESSION['type_utilisateur'] = $_GET['type'];
|
|
chargement_langue();
|
|
}
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "tri_liste":
|
|
{
|
|
if (isset($_GET['colonne']))
|
|
{
|
|
if ($_SESSION['Bateaux']['tri_liste'] == $_GET['colonne'])
|
|
{
|
|
if ($_SESSION['Bateaux']['sens_tri_liste'] == "ASC") $_SESSION['Bateaux']['sens_tri_liste'] = "DESC";
|
|
else $_SESSION['Bateaux']['sens_tri_liste'] = "ASC";
|
|
}
|
|
else
|
|
{
|
|
$_SESSION['Bateaux']['tri_liste'] = $_GET['colonne'];
|
|
$_SESSION['Bateaux']['sens_tri_liste'] = "ASC";
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "toggle_edit":
|
|
{
|
|
if ($_SESSION['modifier_texte'] == 0) $_SESSION['modifier_texte'] = 1;
|
|
else if ($_SESSION['modifier_texte'] == 1) $_SESSION['modifier_texte'] = 0;
|
|
|
|
break;
|
|
}
|
|
//===================================
|
|
case "details_bateau":
|
|
{
|
|
if (isset($_GET['id_bateau']))
|
|
{
|
|
$_SESSION['Bateaux']['bateau']['Cle_primaire'] = $_GET['id_bateau'];
|
|
$_SESSION['Bateaux']['type_details_bateau'] = "TB_BATEAUX_Carte";
|
|
$_SESSION['Bateaux']['type_courbe_details_bateau'] = "Aucune";
|
|
$_SESSION['Bateaux']['id_entree_details_bateau'] = 0;
|
|
$_SESSION['Bateaux']['page'] = "Details_bateau";
|
|
$_SESSION['Bateaux']['bateau']['ID_Famille'] = 0;
|
|
|
|
if (isset($_GET['origine'])) $_SESSION['Bateaux']['origine'] = $_GET['origine'];
|
|
else $_SESSION['Bateaux']['origine'] = "";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "type_details_bateau":
|
|
{
|
|
if (isset($_GET['type']))
|
|
{
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] != $_GET['type'])
|
|
{
|
|
$_SESSION['Bateaux']['type_details_bateau'] = $_GET['type'];
|
|
$_SESSION['Bateaux']['id_entree_details_bateau'] = 0;
|
|
$_SESSION['Bateaux']['id_variable_details_bateau'] = 0;
|
|
$_SESSION['Bateaux']['bateau']['ID_Famille'] = 0;
|
|
|
|
$_SESSION['Bateaux']['ancre'] = "";
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "changement_onglet":
|
|
{
|
|
if (isset($_GET['id_onglet']))
|
|
{
|
|
$_SESSION['Bateaux']['bateau']['ID_Famille'] = $_GET['id_onglet'];
|
|
}
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "div_details_bateau":
|
|
{
|
|
if (isset($_GET['id_entree'])){
|
|
if($_SESSION['Bateaux']['id_entree_details_bateau'] != $_GET['id_entree']){
|
|
$_SESSION['Bateaux']['id_entree_details_bateau'] = $_GET['id_entree'];
|
|
$_SESSION['Bateaux']['type_courbe_details_bateau'] = "Tous";
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Capteurs") $_SESSION['Bateaux']['id_variable_details_bateau'] = $_GET['capteur'];
|
|
}
|
|
else {
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune") $_SESSION['Bateaux']['type_courbe_details_bateau'] = "Aucune";
|
|
else $_SESSION['Bateaux']['type_courbe_details_bateau'] = "Tous";
|
|
}
|
|
}
|
|
else if (isset($_GET['id_carte'])){
|
|
if($_SESSION['Bateaux']['id_entree_details_bateau'] == $_GET['id_carte']) $_SESSION['Bateaux']['id_entree_details_bateau'] = "0";
|
|
else $_SESSION['Bateaux']['id_entree_details_bateau'] = $_GET['id_carte'];
|
|
}
|
|
break;
|
|
}
|
|
//===================================
|
|
case "courbe_details_bateau":
|
|
{
|
|
if ((isset($_GET['id_entree'])) AND (isset($_GET['type_courbe'])))
|
|
{
|
|
if ($_SESSION['Bateaux']['id_entree_details_bateau'] == $_GET['id_entree'] && $_GET['variable'] == 0 )
|
|
{
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese") $_SESSION['Bateaux']['type_courbe_details_bateau'] = "Tous";
|
|
else if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous") $_SESSION['Bateaux']['type_courbe_details_bateau'] = "Synthese";
|
|
$_SESSION['Bateaux']['date_debut'] = $_GET['date_debut'];
|
|
$_SESSION['Bateaux']['date_fin'] = $_GET['date_fin'];
|
|
}
|
|
else
|
|
{
|
|
$_SESSION['Bateaux']['id_entree_details_bateau'] = $_GET['id_entree'];
|
|
$_SESSION['Bateaux']['type_courbe_details_bateau'] = $_GET['type_courbe'];
|
|
$_SESSION['Bateaux']['id_variable_details_bateau'] = $_GET['variable'];
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Capteurs") $_SESSION['Bateaux']['id_variable_details_bateau'] = $_GET['capteur'];
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "modification_bateau":
|
|
{
|
|
if (isset($_GET['id_bateau']))
|
|
{
|
|
$_SESSION['Bateaux']['bateau']['Cle_primaire'] = $_GET['id_bateau'];
|
|
$_SESSION['Bateaux']['page'] = "Modification_bateau";
|
|
}
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "creation_bateau":
|
|
{
|
|
$_SESSION['Bateaux']['page'] = "Creation_bateau";
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "demande_suppression_bateau":
|
|
{
|
|
if (isset($_GET['id_bateau']))
|
|
{
|
|
$_SESSION['Bateaux']['bateau']['Cle_primaire'] = $_GET['id_bateau'];
|
|
$_SESSION['Bateaux']['page'] = "Confirmation_suppression_bateau";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//===================================
|
|
case "confirmation_suppression_bateau":
|
|
{
|
|
if (isset($_GET['id_bateau']))
|
|
{
|
|
$_SESSION['Bateaux']['bateau']['Cle_primaire'] = $_GET['id_bateau'];
|
|
|
|
// Suppression du bateau :
|
|
$requete = 'UPDATE TB_Bateaux SET Validite=0 WHERE Cle_primaire=?';
|
|
Requete_preparee_bdd($requete,
|
|
array(
|
|
array('s', $_SESSION['Bateaux']['bateau']['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
|
|
$flag_redirection = true; // Evite que le message d'erreur soit supprimé par la redirection de purge d'URL
|
|
|
|
$message_information = 'Le bateau <span class="gras">'.$_SESSION['Bateaux']['bateau']['Nom'].'</span> a été dévalidé dans la base de données.';
|
|
|
|
$_SESSION['Bateaux']['page'] = "Accueil";
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($_SESSION['Bateaux']['ancre'] == "") header('Location:bateaux.php'); // Permet de "vider" la barre d'URL des champs GET et donc de doubler le traitement en cas de raffraichissement de page...
|
|
else header('Location:bateaux.php#'.$_SESSION['Bateaux']['ancre'].'');
|
|
}
|
|
|
|
|
|
// Variables POST :
|
|
if (isset($_POST['date_version'])){
|
|
$_SESSION['Bateaux']['date_version'] = $_POST['date_version'];
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
// Création/Modification Bateau :
|
|
if (isset($_POST['validation_creation_bateau']) OR isset($_POST['validation_modification_bateau']))
|
|
{
|
|
// Vérification si un changement de carte a été demandé :
|
|
$flag_new_carte = false;
|
|
$new_id_carte = isset($_POST['ID_Carte']) ? addslashes ($_POST['ID_Carte']) : 0;
|
|
if ($_SESSION['Bateaux']['bateau']['ID_Carte'] != $new_id_carte) $flag_new_carte = true;
|
|
|
|
//echo "Flag nouvelle carte = ".($flag_new_carte ? "Oui" : "Non")." <br />";
|
|
|
|
// Mémorisation des valeurs saisies pour éviter de les perdre en cas d'erreur rendant la création impossible :
|
|
$_SESSION['Bateaux']['bateau']['Nom'] = isset($_POST['Nom']) ? addslashes ($_POST['Nom']) : "";
|
|
$_SESSION['Bateaux']['bateau']['ID_Flotte'] = isset($_POST['ID_Flotte']) ? addslashes ($_POST['ID_Flotte']) : 0;
|
|
$_SESSION['Bateaux']['bateau']['ID_Carte'] = isset($_POST['ID_Carte']) ? addslashes ($_POST['ID_Carte']) : 0;
|
|
$_SESSION['Bateaux']['bateau']['Date_mes'] = isset($_POST['Date_mes']) ? addslashes ($_POST['Date_mes']) : date("Y-m-d");
|
|
$_SESSION['Bateaux']['bateau']['Date_carte'] = isset($_POST['Date_carte']) ? addslashes ($_POST['Date_carte']) : date("Y-m-d");
|
|
$_SESSION['Bateaux']['bateau']['Commentaires'] = isset($_POST['Commentaires']) ? addslashes ($_POST['Commentaires']) : "";
|
|
|
|
if (isset($_POST['validation_creation_bateau']))
|
|
{
|
|
// Création du bateau :
|
|
$requete = 'INSERT INTO TB_Bateaux (Nom, ID_Flotte, ID_Carte, Date_mes, Date_carte, Date_derniere_maj, Commentaires) VALUES (?, ?, ?, ?, ?, ?, ?)';
|
|
Requete_preparee_bdd($requete,
|
|
array(
|
|
array('s', $_SESSION['Bateaux']['bateau']['Nom']),
|
|
array('i', $_SESSION['Bateaux']['bateau']['ID_Flotte']),
|
|
array('i', $_SESSION['Bateaux']['bateau']['ID_Carte']),
|
|
array('s', $_SESSION['Bateaux']['bateau']['Date_mes']),
|
|
array('s', $_SESSION['Bateaux']['bateau']['Date_carte']),
|
|
array('s', $_SESSION['Bateaux']['bateau']['Date_derniere_maj']),
|
|
array('s', $_SESSION['Bateaux']['bateau']['Commentaires'])),
|
|
__FILE__, __LINE__);
|
|
|
|
// Récup de la clé primaire de l'enregistrement créé :
|
|
$_SESSION['Bateaux']['bateau']['Cle_primaire'] = Recuperation_id_cree_bdd();
|
|
|
|
// Retour à la liste si la création s'est bien passée :
|
|
$_SESSION['Bateaux']['page'] = "Accueil";
|
|
}
|
|
else if (isset($_POST['validation_modification_bateau']))
|
|
{
|
|
// Mise à jour du bateau :
|
|
$requete = 'UPDATE TB_Bateaux SET Nom=?, ID_Flotte=?, ID_Carte=?, Date_mes=?, Date_carte=?, Commentaires=? WHERE Cle_primaire=?';
|
|
Requete_preparee_bdd($requete,
|
|
array(
|
|
array('s', $_SESSION['Bateaux']['bateau']['Nom']),
|
|
array('i', $_SESSION['Bateaux']['bateau']['ID_Flotte']),
|
|
array('i', $_SESSION['Bateaux']['bateau']['ID_Carte']),
|
|
array('s', $_SESSION['Bateaux']['bateau']['Date_mes']),
|
|
array('s', $_SESSION['Bateaux']['bateau']['Date_carte']),
|
|
array('s', $_SESSION['Bateaux']['bateau']['Commentaires']),
|
|
array('i', $_SESSION['Bateaux']['bateau']['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
|
|
// Message d'information :
|
|
$message_information = 'Le bateau <span class="gras">'.$_SESSION['Bateaux']['bateau']['Nom'].'</span> vient d\'être modifié';
|
|
|
|
// Retour à la liste si la modification s'est bien passée :
|
|
$_SESSION['Bateaux']['page'] = "Accueil";
|
|
}
|
|
|
|
|
|
// Recherche de l'adresse MAC de la carte ShipBase déclarée :
|
|
$requete = 'SELECT Adresse_mac FROM TB_Cartes WHERE Cle_primaire=?';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $_SESSION['Bateaux']['bateau']['ID_Carte'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$_SESSION['Bateaux']['bateau']['Adresse_mac'] = str_replace(":", "_", $donnees['Adresse_mac']);
|
|
}
|
|
|
|
// Si changement de carte (ou nouveau bateau) :
|
|
if ($flag_new_carte)
|
|
{
|
|
// Vérification de l'existence du répertoire correspondant à cette adresse MAC sur le serveur, dans le répertoire "Bateaux" :
|
|
$flag_creation_repertoires = false;
|
|
if (repertoire_contient_repertoire(REPERTOIRE_BATEAUX, $_SESSION['Bateaux']['bateau']['Adresse_mac'])) // Le répertoire existe :
|
|
{
|
|
// Cas particulier du répertoire d'archives qui pouvait ne pas exister sur les premiers bateaux (permet de créer le fichier archive dans ce cas) :
|
|
if (!repertoire_contient_repertoire(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'], 'archives')) mkdir(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'/archives');
|
|
|
|
// Si le contenu des sous-répertoires est vide, on ne sauvegarde pas l'ancien bateau (cas standard) :
|
|
if (repertoire_est_vide(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'/download') AND
|
|
repertoire_est_vide(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'/upload') AND
|
|
repertoire_est_vide(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'/archives'))
|
|
{
|
|
$message_information .= '<br />Le répertoire ['.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'] et ses trois sous-répertoires "download", "upload" et "archives" existaient déjà dans le répertoire "bateaux" et ils sont bien vides.';
|
|
}
|
|
else // ... et son contenu n'est PAS vide :
|
|
{
|
|
$suffixe_repertoire_archive = '__SAUVEGARDE_'.date("Y-m-d_H-i-s");
|
|
if (rename(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'], REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].$suffixe_repertoire_archive))
|
|
{
|
|
$message_erreur .= 'Le répertoire ['.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'] n\'était pas vide ; il a donc été renommé en ['.REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].$suffixe_repertoire_archive.']</br>';
|
|
$flag_creation_repertoires = true;
|
|
}
|
|
else
|
|
{
|
|
$message_erreur .= 'Le répertoire ['.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'] dans "bateaux" existait et n\'était pas vide mais son renommage a échoué ! Il est conservé tel quel...</br>';
|
|
}
|
|
}
|
|
}
|
|
else $flag_creation_repertoires = true;
|
|
|
|
// Création du répertoire de communication pour cette adresse MAC :
|
|
if ($flag_creation_repertoires)
|
|
{
|
|
if (mkdir(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac']))
|
|
{
|
|
mkdir(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'/download');
|
|
mkdir(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'/upload');
|
|
mkdir(REPERTOIRE_BATEAUX.'/'.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'/archives');
|
|
$message_information .= '<br />Le répertoire ['.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'] et ses trois sous-répertoires "download", "upload" et "archives" viennent d\'être créés dans le répertoire "bateaux"';
|
|
|
|
}
|
|
else $message_erreur .= '!!! Le répertoire ['.$_SESSION['Bateaux']['bateau']['Adresse_mac'].'] n\'a pas pu être créé dans le répertoire "bateaux" !!!';
|
|
}
|
|
}
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
// Filtre du graphe :
|
|
if (isset($_POST['filtrer_graphe'])){
|
|
$_SESSION['Bateaux']['graphe_date_debut'] = $_POST['date_debut'];
|
|
$_SESSION['Bateaux']['graphe_date_fin'] = $_POST['date_fin'];
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
// Modifier la validité des droits
|
|
if (isset($_POST['validite_acces'])) {
|
|
// echo 'Validité = ON pour ID='.$_POST['ID'].'<br />';
|
|
$requete = 'UPDATE TB_Lien_bateau_shipmember SET Validite_acces = 1 WHERE ID = '.$_POST['ID'];
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
}
|
|
else if (!isset($_POST['validite_acces']) && isset($_POST['ID']) && !isset($_POST['supprimerAcces']) && !isset($_POST['modifierAcces'])){
|
|
// echo 'Validité = OFF pour ID='.$_POST['ID'].'<br />';
|
|
$requete = 'UPDATE TB_Lien_bateau_shipmember SET Validite_acces = 0 WHERE ID = '.$_POST['ID'];
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
// Supprimer l'accès
|
|
if (isset($_POST['supprimerAcces']) && isset($_POST['ID'])){
|
|
$id = $_POST['ID'];
|
|
$requete = 'UPDATE TB_Lien_bateau_shipmember SET Validite = 0 WHERE ID = ? ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $id)),
|
|
__FILE__, __LINE__);
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
// Modifier l'accès
|
|
if (isset($_POST['modifierAcces']) && isset($_POST['ID'])){
|
|
$id = $_POST['ID'];
|
|
$fin_validite = $_POST['fin_validite']." 23:59:59";
|
|
$type_profil = $_POST['type_profil'];
|
|
$requete = 'UPDATE TB_Lien_bateau_shipmember SET Fin_validite = ? , ID_Type_acces_bateau_shipmember = ? WHERE ID = ? ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('s', $fin_validite),
|
|
array('i', $type_profil),
|
|
array('i', $id)),
|
|
__FILE__, __LINE__);
|
|
}
|
|
|
|
|
|
|
|
//************************************************************************************************************************************
|
|
// Traitement des données
|
|
//************************************************************************************************************************************
|
|
|
|
// Protection contre les accès directs... :
|
|
$flag_sortie = true;
|
|
do // Dummy loop :
|
|
{
|
|
if (!$_SESSION['acces_valide']) break; // Si on n'est pas identifié, on ne peut pas accéder quoi qu'il arrive...
|
|
|
|
if ($_SESSION['shipmember']['Niveau_acces'] >= NIVEAU_MINI_ACCES_ADMINISTATEUR)
|
|
{
|
|
$flag_sortie = false; // Si on est administrateur, on a toujours accès....
|
|
break;
|
|
}
|
|
|
|
// Recherche des droits d'accès à un bateau en particulier :
|
|
if ($_SESSION['Bateaux']['page'] == "Details_bateau")
|
|
{
|
|
$requete = 'SELECT * FROM TB_Lien_bateau_shipmember WHERE Validite=1 AND Validite_acces=1 AND ID_SHIPMEMBER=? AND ID_BATEAU=? ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $_SESSION['shipmember']['Cle_primaire']),
|
|
array('i', $_SESSION['Bateaux']['bateau']['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$flag_sortie = false;
|
|
break;
|
|
}
|
|
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
}
|
|
if($flag_sortie && $_SESSION['Bateaux']['bateau']['Cle_primaire'] == 25){
|
|
$flag_sortie = false;
|
|
}
|
|
} while (0);
|
|
|
|
if ($flag_sortie) header('Location:shipmembers.php?action=navigation&destination=Login');
|
|
|
|
|
|
switch ($_SESSION['Bateaux']['page'])
|
|
{
|
|
//****************************************************************************************************************************
|
|
case "Accueil":
|
|
{
|
|
//--------------------------------------------------
|
|
// Récupération des informations sur les bateaux :
|
|
$nb_bateaux = 0;
|
|
|
|
switch($_SESSION['Bateaux']['tri_liste'])
|
|
{
|
|
case "Nom": { $tri_liste = " ORDER By Nom ".$_SESSION['Bateaux']['sens_tri_liste']; break; }
|
|
case "Flotte" : { $tri_liste = " ORDER By nom_flotte ".$_SESSION['Bateaux']['sens_tri_liste'].", Nom"; break; }
|
|
case "Carte": { $tri_liste = " ORDER By nom_carte ".$_SESSION['Bateaux']['sens_tri_liste']; break; }
|
|
case "Adresse_mac": { $tri_liste = " ORDER By adresse_carte ".$_SESSION['Bateaux']['sens_tri_liste']; break; }
|
|
case "Version": { $tri_liste = " ORDER By version ".$_SESSION['Bateaux']['sens_tri_liste'].", Nom"; break; }
|
|
case "Date_maj": { $tri_liste = " ORDER By Date_derniere_maj ".$_SESSION['Bateaux']['sens_tri_liste'].", Nom"; break; }
|
|
default : { $tri_liste = " ORDER By nom_flotte, Nom ".$_SESSION['Bateaux']['sens_tri_liste']; break; }
|
|
}
|
|
|
|
$requete = 'SELECT TB_Bateaux.Cle_primaire AS Cle_primaire, ';
|
|
$requete .= ' TB_Bateaux.Nom AS Nom, ';
|
|
$requete .= ' (SELECT Nom FROM TB_Flottes WHERE Validite=1 AND Cle_primaire=TB_Bateaux.ID_Flotte) AS nom_flotte, ';
|
|
$requete .= ' (SELECT No_serie FROM TB_Cartes WHERE Validite=1 AND Cle_primaire=TB_Bateaux.ID_Carte) AS nom_carte, ';
|
|
$requete .= ' (SELECT Adresse_mac FROM TB_Cartes WHERE Validite=1 AND Cle_primaire=TB_Bateaux.ID_Carte) AS adresse_carte, ';
|
|
$requete .= ' (SELECT Valeur FROM TB_BATEAUX_Systeme WHERE Validite=1 AND ID_Bateau=TB_Bateaux.Cle_primaire AND Nom="Version_soft_no_package") AS version, ';
|
|
$requete .= ' TB_Bateaux.Date_derniere_maj AS Date_derniere_maj, ';
|
|
$requete .= ' TB_Bateaux.Commentaires AS Commentaires ';
|
|
$requete .= ' FROM `TB_Bateaux` ';
|
|
$requete .= ' WHERE Validite=1 ';
|
|
$requete .= $tri_liste;
|
|
// echo "Requête = [".$requete."]<br />";
|
|
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$bateaux[$nb_bateaux] = $donnees;
|
|
|
|
// Mise en forme de certaines variables :
|
|
if ($bateaux[$nb_bateaux]['version'] == "") $bateaux[$nb_bateaux]['version'] = '<i>inconnue</i>';
|
|
if ($donnees['Date_derniere_maj'] < "2020-01-02") $bateaux[$nb_bateaux]['Date_derniere_maj'] = "<i>Jamais</i>";
|
|
else $bateaux[$nb_bateaux]['Date_derniere_maj'] = Formatage_date($donnees['Date_derniere_maj']);
|
|
$bateaux[$nb_bateaux]['Commentaires'] = htmlspecialchars(stripcslashes($bateaux[$nb_bateaux]['Commentaires']));
|
|
|
|
$nb_bateaux ++;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
break;
|
|
}
|
|
|
|
//****************************************************************************************************************************
|
|
case "Details_bateau":
|
|
{
|
|
//--------------------------------------------------
|
|
// Récupération des informations sur le bateau :
|
|
$nb_bateaux = 0;
|
|
|
|
$requete = 'SELECT * FROM TB_Bateaux WHERE Cle_primaire=? ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $_SESSION['Bateaux']['bateau']['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$bateau = $donnees;
|
|
$sous_req = "SELECT Adresse_mac FROM TB_Cartes WHERE Validite = 1 AND Cle_primaire = ".$bateau['ID_Carte'];
|
|
$sous_rep = Requete_bdd($sous_req, __FILE__, __LINE__);
|
|
$sous_don = Recherche_ligne_bdd($sous_rep);
|
|
|
|
$bateau['Adresse_mac'] = $sous_don['Adresse_mac'];
|
|
Liberation_jeu_de_resultat_bdd($sous_rep);
|
|
|
|
// Mise en forme de textes :
|
|
if ($donnees['Date_derniere_maj'] < "2020-01-02") $bateau['Date_derniere_maj'] = "<i>".Recuperer_texte("bateau","details","derniere_connexion","jamais")."</i>";
|
|
else {
|
|
$bateau['Date_derniere_maj'] = Formatage_date($donnees['Date_derniere_maj']);
|
|
$_SESSION['Bateaux']['derniere_maj'] = $donnees['Date_derniere_maj'];
|
|
}
|
|
$bateau['Commentaires'] = htmlspecialchars(stripcslashes($bateau['Commentaires']));
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
|
|
// Recherche de la version en cours sur le bateau :
|
|
$bateau['version'] = "Version inconnue";
|
|
$requete = 'SELECT Valeur FROM TB_BATEAUX_Systeme WHERE ID_Bateau=? AND Nom="Version_soft_no_package" AND Validite=1 ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $_SESSION['Bateaux']['bateau']['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$bateau['version'] = $donnees['Valeur'];
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
/*
|
|
for ($i = 0; $i < $_SESSION['acces']; $i++){
|
|
if ($_SESSION['bateau_shipmember'][$i]['ID_Bateau'] == $bateau['Cle_primaire']){
|
|
$acces = $_SESSION['bateau_shipmember'][$i]['Niveau_acces'];
|
|
break;
|
|
}
|
|
else $acces = 0;
|
|
}
|
|
if ($_SESSION['acces'] == 0) $acces = 0;
|
|
|
|
$requete = 'SELECT * FROM TB_Lien_bateau_shipmember_acces WHERE Validite=1 AND Niveau_acces='.$acces;
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
$donnees = Recherche_ligne_bdd($reponse);
|
|
$acces_profil = $donnees;
|
|
*/
|
|
|
|
//---------------------------------------------
|
|
// Recherche des droits d'accès au bateau :
|
|
//---------------------------------------------
|
|
if ($_SESSION['shipmember']['Niveau_acces'] >= NIVEAU_MINI_ACCES_ADMINISTATEUR) // Dans le cas des administrateurs, on accorde tous les droits, indépendamment des paramètres du bateau
|
|
{
|
|
$acces_profil['Creation_profils'] = 1;
|
|
$acces_profil['Devalidation_profils'] = 2;
|
|
$acces_profil['Consultation_donnees'] = 2;
|
|
$acces_profil['Modification_acces'] = 1;
|
|
}
|
|
else
|
|
{
|
|
// Valeurs par défaut :
|
|
$id_type_acces = 0;
|
|
$acces_profil['Creation_profils'] = 0;
|
|
$acces_profil['Devalidation_profils'] = 0;
|
|
$acces_profil['Consultation_donnees'] = 0;
|
|
$acces_profil['Modification_acces'] = 0;
|
|
|
|
// Recherche de l'ID de l'accès le plus élevé pour ce bateau et ce shipmember :
|
|
$requete = 'SELECT ID_Type_acces_bateau_shipmember FROM TB_Lien_bateau_shipmember WHERE Validite=1 AND Validite_acces=1 AND ID_Shipmember=? AND ID_Bateau=? AND Fin_validite>=? ORDER BY ID_Type_acces_bateau_shipmember DESC LIMIT 1';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $_SESSION['shipmember']['Cle_primaire']),
|
|
array('i', $_SESSION['Bateaux']['bateau']['Cle_primaire']),
|
|
array('s', date_format(date_create(), 'Y-m-d H:i:s'))),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$id_type_acces = $donnees['ID_Type_acces_bateau_shipmember'];
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
if ($_SESSION['Bateaux']['bateau']['Cle_primaire'] == 25 && $id_type_acces == 0){
|
|
$id_type_acces = 4;
|
|
}
|
|
|
|
// Recherche des caractérirtiques de l'accès le plus élevé trouvé :
|
|
if ($id_type_acces > 0)
|
|
{
|
|
$requete = 'SELECT * FROM TB_Types_acces_bateau_shipmember WHERE Validite=1 AND Cle_primaire=?';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $id_type_acces)),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$acces_profil = $donnees;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
}
|
|
}
|
|
|
|
|
|
// Récupération des types d'accès possibles :
|
|
//$requete = 'SELECT Nom, Niveau_acces FROM TB_Lien_bateau_shipmember_acces WHERE Validite = 1 AND Niveau_acces < 99';
|
|
$requete = 'SELECT * FROM TB_Types_acces_bateau_shipmember WHERE Validite=1 ';
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
$type_acces_nb = 0;
|
|
while($donnees = Recherche_ligne_bdd($reponse)){
|
|
if ($_SESSION['langue'] == "EN") $donnees['Nom'] = $donnees['Nom_en'];
|
|
else $donnees['Nom'] = $donnees['Nom_fr'];
|
|
|
|
$type_acces[$type_acces_nb++] = $donnees;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
|
|
// Génération d'un nouveau code d'acces :
|
|
if (isset($_POST['generer_code_acces'])){
|
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
$charactersLength = strlen($characters);
|
|
$unique = false;
|
|
do { // Vérifier si le code n'est pas déjà utilisé
|
|
$code_acces = '';
|
|
for ($i = 0; $i < 6; $i++) {
|
|
$code_acces .= $characters[random_int(0, $charactersLength - 1)];
|
|
}
|
|
$req = 'SELECT Code FROM TB_Lien_bateau_shipmember WHERE Code="'.$code_acces.'"';
|
|
$rep = Requete_bdd($req, __FILE__, __LINE__);
|
|
$donnees = Recherche_ligne_bdd($rep);
|
|
if ($donnees == NULL) $unique = true;
|
|
} while($unique == false);
|
|
|
|
if (isset($_POST['date_validite']) && (!empty($_POST['date_validite']))){
|
|
$date = $_POST['date_validite']." 00:00:00";
|
|
}
|
|
else $date = '9999-12-31 23:59:59';
|
|
$requete = 'INSERT INTO TB_Lien_bateau_shipmember(ID_Bateau, Code, Fin_validite, Cree_par, ID_Type_acces_bateau_shipmember) VALUES (?,?,?,?,?)';
|
|
$reponse = Requete_preparee_bdd($requete, array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('s', $code_acces),
|
|
array('s', $date),
|
|
array('i', $_SESSION['shipmember']['Cle_primaire']),
|
|
array('i', $_POST['type_acces'])
|
|
),__FILE__, __LINE__);
|
|
$no = Recuperation_id_cree_bdd();
|
|
|
|
if ( code_acces_pdf($code_acces, $no, $bateau['Adresse_mac'],"")== 0 ) Entete_page_html();
|
|
|
|
// Message d'information :
|
|
|
|
// if (isset($_SESSION['pdf']['src']) && $_SESSION['pdf']['src'] != '')
|
|
// $message_information.= "Télécharger le code d'accès d'<a class='download' target='_blank' href= ".$_SESSION['pdf']['src']."> ici </a> ";
|
|
// $_SESSION['pdf']['src'] ='';
|
|
|
|
}
|
|
|
|
|
|
$nb_onglets = 0;
|
|
|
|
//-----------------------------------------------------------
|
|
// Recherche des informations complémentaires sur le bateau :
|
|
switch($_SESSION['Bateaux']['type_details_bateau'])
|
|
{
|
|
//=========================
|
|
case "gerer_les_acces":
|
|
{
|
|
$requete = 'SELECT * FROM TB_Lien_bateau_shipmember WHERE Validite=1 AND ID_Bateau='.$bateau['Cle_primaire'].' AND ID_Shipmember!=0 ';
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
$utilisateur_acces_nb = 0;
|
|
while ($donnees = Recherche_ligne_bdd($reponse)){
|
|
// Récupérer le nom et le prénom du shipmember qui a accès :
|
|
$sous_req = ' SELECT Nom, Prenom, Email FROM TB_Shipmembers WHERE Validite=1 AND ID='.$donnees['ID_Shipmember'].'';
|
|
$sous_rep = Requete_bdd($sous_req, __FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_rep);
|
|
$donnees['sm_Nom'] = $sous_donnees['Nom'];
|
|
$donnees['sm_Prenom'] = $sous_donnees['Prenom'];
|
|
$donnees['sm_Email'] = $sous_donnees['Email'];
|
|
// Récupérer le nom et le prénom du shipmember qui a crée le lien :
|
|
$sous_req = ' SELECT Nom, Prenom FROM TB_Shipmembers WHERE Validite=1 AND ID='.$donnees['Cree_par'].'';
|
|
$sous_rep = Requete_bdd($sous_req, __FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_rep);
|
|
$donnees['cree_par_Nom'] = $sous_donnees['Nom'];
|
|
$donnees['cree_par_Prenom'] = $sous_donnees['Prenom'];
|
|
// Récupérer le niveau accès garantie à l'utilisateur :
|
|
//$sous_req = ' SELECT Nom FROM TB_Lien_bateau_shipmember_acces WHERE Validite=1 AND Niveau_acces='.$donnees['Niveau_acces'].'';
|
|
$sous_req = 'SELECT * FROM TB_Types_acces_bateau_shipmember WHERE Validite=1 AND Cle_primaire='.$donnees['ID_Type_acces_bateau_shipmember'].' ';
|
|
$sous_rep = Requete_bdd($sous_req, __FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_rep);
|
|
if ($_SESSION['langue'] == "EN") $donnees['Niveau_acces_nom'] = $sous_donnees['Nom_en'];
|
|
else $donnees['Niveau_acces_nom'] = $sous_donnees['Nom_fr'];
|
|
$utilisateur_acces[$utilisateur_acces_nb++] = $donnees;
|
|
}
|
|
|
|
|
|
break;
|
|
}
|
|
//=========================
|
|
case "TB_BATEAUX_Carte":
|
|
{
|
|
$timestamp_debut = hrtime(TRUE); // En ns
|
|
// Récupérer les positions du bateaux pour le maps (30 derniers jours)
|
|
$date = date_create();
|
|
date_sub($date, date_interval_create_from_date_string(DATE_SEUIL_1.' days'));
|
|
|
|
$date_debut_carte = date_format($date, 'Y-m-d H:00:00');
|
|
|
|
$data_map = [];
|
|
// $requete = 'SELECT DISTINCT Date FROM (
|
|
// SELECT Date FROM TB_BATEAUX_Mesures_capteurs WHERE ID_Bateau = '.$_SESSION['Bateaux']['bateau']['Cle_primaire'].' AND ID = 7 AND ID_Variable = 64 AND Date > "'.$date_debut_carte.'" UNION ALL
|
|
// SELECT Date FROM TB_BATEAUX_Mesures_capteurs WHERE ID_Bateau = '.$_SESSION['Bateaux']['bateau']['Cle_primaire'].' AND ID = 8 AND ID_Variable = 64 AND Date > "'.$date_debut_carte.'"
|
|
// ) uni ORDER BY Date;';
|
|
// echo "Requête = ".$requete."<br />"; // Temps de traitement = 1 470 ms pour 'Et Si... 2'
|
|
|
|
// Recherche des coordonnées du début de carte :
|
|
// Latitude :
|
|
$requete = 'SELECT Date, Valeur FROM TB_BATEAUX_Mesures_capteurs WHERE ID_Bateau='.$_SESSION['Bateaux']['bateau']['Cle_primaire'].' AND ID=7 AND ID_Variable=64 AND Date<="'.$date_debut_carte.'" ORDER BY Date LIMIT 1';
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
$donnees = Recherche_ligne_bdd($reponse);
|
|
if ($donnees == NULL) // S'il n'y a aucune latitude AVANT le début de la carte, on cherche la première APRES la date de début :
|
|
{
|
|
$requete = 'SELECT Date, Valeur FROM TB_BATEAUX_Mesures_capteurs WHERE ID_Bateau='.$_SESSION['Bateaux']['bateau']['Cle_primaire'].' AND ID=7 AND ID_Variable=64 AND Date>"'.$date_debut_carte.'" ORDER BY Date LIMIT 1';
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
$donnees = Recherche_ligne_bdd($reponse);
|
|
}
|
|
else{
|
|
|
|
}
|
|
$data_map[0]['latitude'] = ($donnees != NULL) ? $donnees['Valeur'] : 45.735237; // NB : s'il n'y aucune valeur ni AVANT ni APRES, c'est qu'il n'y a pas de courbe à tracer...
|
|
|
|
// Longitude :
|
|
$requete = 'SELECT Date, Valeur FROM TB_BATEAUX_Mesures_capteurs WHERE ID_Bateau='.$_SESSION['Bateaux']['bateau']['Cle_primaire'].' AND ID=8 AND ID_Variable=64 AND Date<="'.$date_debut_carte.'" ORDER BY Date LIMIT 1';
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
$donnees = Recherche_ligne_bdd($reponse);
|
|
if ($donnees == NULL) // S'il n'y a aucune longitude AVANT le début de la carte, on cherche la première APRES la date de début :
|
|
{
|
|
$requete = 'SELECT Date, Valeur FROM TB_BATEAUX_Mesures_capteurs WHERE ID_Bateau='.$_SESSION['Bateaux']['bateau']['Cle_primaire'].' AND ID=8 AND ID_Variable=64 AND Date>"'.$date_debut_carte.'" ORDER BY Date LIMIT 1';
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
$donnees = Recherche_ligne_bdd($reponse);
|
|
}
|
|
$data_map[0]['longitude'] = ($donnees != NULL) ? $donnees['Valeur'] : 4.804827;
|
|
$data_map[0]['date'] = $date_debut_carte;
|
|
$nb_data = 1;
|
|
|
|
// Requête de tous les points sur la période :
|
|
$requete = 'SELECT Date, ID, Valeur FROM TB_BATEAUX_Mesures_capteurs WHERE ID_Bateau='.$_SESSION['Bateaux']['bateau']['Cle_primaire'].' AND (ID=7 OR ID=8) AND ID_Variable=64 AND Date>"'.$date_debut_carte.'" ORDER BY Date';
|
|
// echo "Requête = ".$requete."<br />"; // Temps de traitement = 7.9ms pour Et Si... 2
|
|
$reponse = Requete_bdd($requete, __FILE__, __LINE__);
|
|
while($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$date_point = Formatage_date($donnees['Date']).' [UTC]';
|
|
$date_point_sans_formatage = $donnees['Date'];
|
|
$jour = substr($donnees['Date'], 8, 2);
|
|
|
|
if ($date_point == $data_map[$nb_data - 1]['date']) // Si on est sur la même date que la data précédente, on ne créée pas de nouveau point mais on ajoute juste la LAT ou LON sur le point précédent :
|
|
{
|
|
if ($donnees['ID'] == 7)
|
|
{
|
|
$data_map[$nb_data - 1]['latitude'] = $donnees['Valeur'];
|
|
$data_map[$nb_data - 1]['latitude_dms'] = Conversion_DECtoDMS("LAT", $donnees['Valeur']);
|
|
}
|
|
else
|
|
{
|
|
$data_map[$nb_data - 1]['longitude'] = $donnees['Valeur'];
|
|
$data_map[$nb_data - 1]['longitude_dms'] = Conversion_DECtoDMS("LON", $donnees['Valeur']);
|
|
}
|
|
}
|
|
else // Si on est sur une date différente de la dat précédente, on créée un nouveau point :
|
|
{
|
|
$data_map[$nb_data]['date'] = $date_point;
|
|
$data_map[$nb_data]['raw_date'] = $date_point_sans_formatage;
|
|
|
|
// Couleur unie :
|
|
$data_map[$nb_data]['couleur'] = '#004563';
|
|
$data_map[$nb_data]['opacite'] = 0.8;
|
|
|
|
// Couleur de tracé alternée (bleu clair / bleu foncé) les jours pairs et impairs :
|
|
// if (($jour % 2) == 0) $data_map[$nb_data]['couleur'] = '#75B9DA'; //'#00FF00';
|
|
// else $data_map[$nb_data]['couleur'] = '#004563'; //'#FF0000';
|
|
|
|
// Couleur de tracé avec 10 couleurs tournantes :
|
|
/*
|
|
switch($jour % 10)
|
|
{
|
|
default :
|
|
case 0 : { $data_map[$nb_data]['couleur'] = '#00FF99'; $data_map[$nb_data]['opacite'] = 1.0; break; } // Vert d'eau
|
|
case 1 : { $data_map[$nb_data]['couleur'] = '#FFC000'; $data_map[$nb_data]['opacite'] = 0.8; break; } // Orange
|
|
case 2 : { $data_map[$nb_data]['couleur'] = '#004563'; $data_map[$nb_data]['opacite'] = 0.8; break; } // Bleu Koriolan foncé
|
|
case 3 : { $data_map[$nb_data]['couleur'] = '#990099'; $data_map[$nb_data]['opacite'] = 0.8; break; } // Violet
|
|
case 4 : { $data_map[$nb_data]['couleur'] = '#00B050'; $data_map[$nb_data]['opacite'] = 0.6; break; } // Vert
|
|
case 5 : { $data_map[$nb_data]['couleur'] = '#FF0000'; $data_map[$nb_data]['opacite'] = 0.4; break; } // Rouge
|
|
case 6 : { $data_map[$nb_data]['couleur'] = '#FFFF00'; $data_map[$nb_data]['opacite'] = 0.8; break; } // Jaune
|
|
case 7 : { $data_map[$nb_data]['couleur'] = '#FF7DFF'; $data_map[$nb_data]['opacite'] = 0.9; break; } // Fushia
|
|
case 8 : { $data_map[$nb_data]['couleur'] = '#00B0F0'; $data_map[$nb_data]['opacite'] = 0.6; break; } // Bleu roi
|
|
case 9 : { $data_map[$nb_data]['couleur'] = '#996633'; $data_map[$nb_data]['opacite'] = 0.5; break; } // Marron
|
|
}
|
|
*/
|
|
|
|
if ($donnees['ID'] == 7)
|
|
{
|
|
$data_map[$nb_data]['latitude'] = $donnees['Valeur'];
|
|
$data_map[$nb_data]['longitude'] = $data_map[$nb_data-1]['longitude']; // Dans le doute, on met à jour la LON avec la dernière valeur connue
|
|
}
|
|
else
|
|
{
|
|
$data_map[$nb_data]['longitude'] = $donnees['Valeur'];
|
|
$data_map[$nb_data]['latitude'] = $data_map[$nb_data-1]['latitude']; // Dans le doute, on met à jour la LAT avec la dernière valeur connue
|
|
}
|
|
|
|
$data_map[$nb_data]['latitude_dms'] = Conversion_DECtoDMS("LAT", $data_map[$nb_data]['latitude']);
|
|
$data_map[$nb_data]['longitude_dms'] = Conversion_DECtoDMS("LON", $data_map[$nb_data]['longitude']);
|
|
|
|
$nb_data ++;
|
|
}
|
|
}
|
|
|
|
// Batteries du bateau
|
|
$requete = 'SELECT Nom, Tension_nominale, Soc FROM TB_BATEAUX_Batteries WHERE ID_Bateau=? AND Validite=1';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
$nb_batteries = 0;
|
|
while($donnees = Recherche_ligne_bdd($reponse)){
|
|
$batteries[$nb_batteries++] = $donnees;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
// Rservoirs du bateau
|
|
$nb_familles = 0;
|
|
// Recherche des onglets configurés sur le bateau :
|
|
$requete = 'SELECT Cle_primaire, Nom FROM TB_BATEAUX_Familles_reservoirs WHERE ID_Bateau=? AND Validite=1 ORDER BY Priorite_affichage ASC ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
// Recherche du nombre de réservoirs affectés à cette famille :
|
|
$sous_requete = 'SELECT COUNT(*) as Total FROM TB_BATEAUX_Reservoirs WHERE ID_Bateau=? AND Validite=1 AND ID_Famille_reservoirs=? ';
|
|
$sous_reponse = Requete_preparee_bdd($sous_requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $donnees['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_reponse);
|
|
|
|
if ($sous_donnees['Total'] > 0) {
|
|
$bateau['familles'][$nb_familles] = $donnees; // Ajout de la famille au tableau des familles
|
|
|
|
// Recherche des réservoirs appartenant à la famille en cours :
|
|
$reservoirs_requete = 'SELECT * FROM TB_BATEAUX_Reservoirs ';
|
|
$reservoirs_requete .= 'WHERE ID_Bateau=? AND Validite=1 AND ID_Famille_reservoirs=? ORDER BY ABS(Priorite_affichage_accueil) ASC';
|
|
$reservoirs_reponse = Requete_preparee_bdd($reservoirs_requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $donnees['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
|
|
while ($reservoir = Recherche_ligne_bdd($reservoirs_reponse)) {
|
|
$bateau['familles'][$nb_familles]['reservoirs'][] = $reservoir; // Ajout du réservoir au tableau de réservoirs de la famille
|
|
}
|
|
|
|
Liberation_jeu_de_resultat_bdd($reservoirs_reponse);
|
|
|
|
$nb_familles++;
|
|
}
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
|
|
|
|
$nb_onglets = 0;
|
|
$timestamp_fin = hrtime(TRUE); // En ns
|
|
//echo "Temps exécution = ".number_format(($timestamp_fin - $timestamp_debut)/(1000 * 1000), 1, ".", " ")." ms et nb points = ".$nb_data."<br />";
|
|
break;
|
|
}
|
|
//=========================
|
|
case "TB_BATEAUX_Systeme":
|
|
{
|
|
if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != "") $date_ver = str_replace("T"," ",$_SESSION['Bateaux']['date_version']).":00";
|
|
|
|
if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != "" && $_SESSION['Bateaux']['date_version'] != $_SESSION['Bateaux']['derniere_maj']){
|
|
$requete = 'SELECT * FROM '.$_SESSION['Bateaux']['type_details_bateau'].'_archive WHERE ID_Bateau=? AND SUBSTR(date_maj, 1, 13) = (SELECT SUBSTR(date_maj, 1, 13) from '.$_SESSION['Bateaux']['type_details_bateau'].'_archive WHERE SUBSTR(date_maj, 1, 13) < SUBSTR("'.$date_ver.'", 1, 13) ORDER BY date_maj DESC limit 1) ORDER BY Nom ASC';
|
|
}
|
|
|
|
else {
|
|
$requete = 'SELECT * FROM '.$_SESSION['Bateaux']['type_details_bateau'].' WHERE ID_Bateau=? AND Validite=1 ORDER BY Nom ASC';
|
|
}
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$bateau['details_bateau'][''.$donnees['Nom'].'']['Valeur'] = $donnees['Valeur'];
|
|
if (isset($donnees['Description'])) $bateau['details_bateau'][''.$donnees['Nom'].'']['Description'] = $donnees['Description'];
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
|
|
// Mise en forme de certains champs et valeurs par défaut lorsqu'aucune donnée n'est encore disponible :
|
|
if(isset($bateau['details_bateau']['Version_soft_no_package']['Valeur'])) $bateau['version'] = $bateau['details_bateau']['Version_soft_no_package']['Valeur'];
|
|
elseif(isset($bateau['details_bateau']['Version_soft_package']['Valeur'])) $bateau['version'] = $bateau['details_bateau']['Version_soft_package']['Valeur'];
|
|
else $bateau['version'] = '<i>inconnue</i>';
|
|
|
|
if (!isset($bateau['details_bateau']['Version_soft_modem']['Valeur'])) $bateau['details_bateau']['Version_soft_modem']['Valeur'] = '<i>inconnue</i>';
|
|
if (!isset($bateau['details_bateau']['No_iccid']['Valeur'])) $bateau['details_bateau']['No_iccid']['Valeur'] = '<i>inconnu</i>';
|
|
if (!isset($bateau['details_bateau']['No_imei']['Valeur'])) $bateau['details_bateau']['No_imei']['Valeur'] = '<i>inconnu</i>';
|
|
if (!isset($bateau['details_bateau']['No_imsi']['Valeur'])) $bateau['details_bateau']['No_imsi']['Valeur'] = '<i>inconnu</i>';
|
|
|
|
|
|
//-------------------------------------
|
|
// Recherche des cartes existantes à bord :
|
|
$nb_cartes = 0;
|
|
$requete="";
|
|
//$requete = 'SELECT * FROM TB_BATEAUX_Cartes WHERE ID_Bateau=? AND Validite=1 AND Presence=1 ORDER BY Adresse_k_bus';
|
|
if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != ""){
|
|
$requete = 'SELECT * FROM TB_BATEAUX_Cartes_archive WHERE ID_Bateau=? AND SUBSTR(date_maj, 1, 13) = (SELECT SUBSTR(date_maj, 1, 13) from TB_BATEAUX_Cartes_archive WHERE SUBSTR(date_maj, 1, 13) < substr("'.$date_ver.'",1 ,13) ORDER BY date_maj DESC limit 1) ORDER BY Adresse_k_bus';
|
|
}
|
|
|
|
else {
|
|
$requete = 'SELECT * FROM TB_BATEAUX_Cartes WHERE ID_Bateau=? AND Validite=1 ORDER BY Adresse_k_bus';
|
|
}
|
|
//echo "Requête = [".$requete."]<br />";
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
// Mise en forme de certains champs :
|
|
switch($donnees['Type'])
|
|
{
|
|
//-------------------------------
|
|
case TYPE_CARTE_COMPAGNON:
|
|
{
|
|
$donnees['nom_type'] = "ShipBase";
|
|
break;
|
|
}
|
|
|
|
//-------------------------------
|
|
case TYPE_CARTE_SP812:
|
|
case TYPE_CARTE_SP8DC:
|
|
{
|
|
if ($donnees['Type'] == TYPE_CARTE_SP812) $donnees['nom_type'] = "ShipPower812";
|
|
else $donnees['nom_type'] = "ShipPower8DC";
|
|
|
|
// Valeurs par défaut des circuits affectés à ce module :
|
|
for ($i = 0; $i < 8; $i++) $donnees['circuits'][$i]['Nom'] = "<i>--- Non affecté ---</i>";
|
|
|
|
// Recherche des circuits réellement affectés à ce module :
|
|
$sous_requete = 'SELECT * FROM TB_BATEAUX_Circuits WHERE ID_Bateau='.$bateau['Cle_primaire'].' AND No_carte='.$donnees['Adresse_k_bus'].' AND Validite=1 ORDER BY No_circuit_carte';
|
|
//echo "Requête = [".$sous_requete."]<br />";
|
|
$sous_reponse = Requete_bdd($sous_requete, __FILE__, __LINE__);
|
|
while ($sous_donnees = Recherche_ligne_bdd($sous_reponse))
|
|
{
|
|
if ($sous_donnees['ID_Circuit_esclave'] >= 0) $donnees['circuits'][$sous_donnees['No_circuit_carte']]['Nom'] = '<span class="gras">'.$sous_donnees['Nom'].'</span>';
|
|
else $donnees['circuits'][$sous_donnees['No_circuit_carte']]['Nom'] = '<span class="gras">'.$sous_donnees['Nom'].'</span> <i>[circuit renfort]</i>';
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($sous_reponse);
|
|
|
|
break;
|
|
}
|
|
|
|
//-------------------------------
|
|
case TYPE_CARTE_SBS1224:
|
|
{
|
|
$donnees['nom_type'] = "ShipBS";
|
|
break;
|
|
}
|
|
|
|
//-------------------------------
|
|
case TYPE_CARTE_SP4AC:
|
|
{
|
|
$donnees['nom_type'] = "ShipPower4AC";
|
|
|
|
// Valeurs par défaut des circuits affectés à ce module :
|
|
for ($i = 0; $i < 4; $i++) $donnees['circuits'][$i]['Nom'] = "<i>--- Non affecté ---</i>";
|
|
|
|
// Recherche des circuits réellement affectés à ce module :
|
|
$sous_requete = 'SELECT * FROM TB_BATEAUX_Circuits WHERE ID_Bateau='.$bateau['Cle_primaire'].' AND No_carte='.$donnees['Adresse_k_bus'].' AND Validite=1 ORDER BY No_circuit_carte';
|
|
//echo "Requête = [".$sous_requete."]<br />";
|
|
$sous_reponse = Requete_bdd($sous_requete, __FILE__, __LINE__);
|
|
while ($sous_donnees = Recherche_ligne_bdd($sous_reponse))
|
|
{
|
|
$donnees['circuits'][$sous_donnees['No_circuit_carte']]['Nom'] = '<span class="gras">'.$sous_donnees['Nom'].'</span>';
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($sous_reponse);
|
|
break;
|
|
}
|
|
|
|
//-------------------------------
|
|
default : { $donnees['nom_type'] = "<i>Type inconnu...</i>"; break; }
|
|
}
|
|
if ($donnees['Flag_resistance_terminaison'] == 1) $donnees['libelle_resistance_terminaison'] = "Oui";
|
|
else $donnees['libelle_resistance_terminaison'] = "Non";
|
|
|
|
$cartes[$nb_cartes ++] = $donnees;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
break;
|
|
}
|
|
|
|
//=========================
|
|
case "TB_BATEAUX_Capteurs":
|
|
{
|
|
if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != "") $date_ver = str_replace("T"," ",$_SESSION['Bateaux']['date_version']).":00";
|
|
|
|
$nb_entrees = 0;
|
|
if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != ""){
|
|
$requete = 'SELECT * FROM '.$_SESSION['Bateaux']['type_details_bateau'].'_archive WHERE ID_Bateau=? AND SUBSTR(date_maj, 1, 13) = (SELECT SUBSTR(date_maj, 1, 13) from '.$_SESSION['Bateaux']['type_details_bateau'].'_archive WHERE SUBSTR(date_maj, 1, 13) < SUBSTR("'.$date_ver.'", 1, 13) ORDER BY date_maj DESC limit 1) ORDER BY Priorite_affichage_accueil ASC';
|
|
}
|
|
else {
|
|
// Recherche des onglets configurés sur le bateau :
|
|
$requete = 'SELECT Cle_primaire, Nom FROM TB_BATEAUX_Familles_capteurs WHERE ID_Bateau=? AND Validite=1 ORDER BY Priorite_affichage ASC ';
|
|
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
// Recherche du nombre de capteurs affectés à cette famille :
|
|
$sous_requete = 'SELECT COUNT(*) as Total FROM TB_BATEAUX_Capteurs WHERE ID_Bateau=? AND Validite=1 AND ID_Famille_capteurs=? ';
|
|
$sous_reponse = Requete_preparee_bdd($sous_requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $donnees['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_reponse);
|
|
|
|
if ($sous_donnees['Total'] > 0) $bateau['onglets'][$nb_onglets ++] = $donnees; // On ne présente que les familles ayant au moins 1 capteur...
|
|
Liberation_jeu_de_resultat_bdd($sous_reponse);
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
// Affectation du premier onglet si aucun n'est sélectionné :
|
|
if ($nb_onglets > 0)
|
|
{
|
|
if ($_SESSION['Bateaux']['bateau']['ID_Famille'] == 0) $_SESSION['Bateaux']['bateau']['ID_Famille'] = $bateau['onglets'][0]['Cle_primaire'];
|
|
$filtre_famille = " ID_Famille_capteurs=".$_SESSION['Bateaux']['bateau']['ID_Famille']." ";
|
|
}
|
|
else $filtre_famille = " 1 ";
|
|
|
|
// Recherche des éléments appartenant à l'onglet en cours :
|
|
$requete = 'SELECT * FROM TB_BATEAUX_Capteurs ';
|
|
$requete .= 'WHERE ID_Bateau=? AND Validite=1 AND '.$filtre_famille.' ORDER BY ABS(Priorite_affichage_accueil) ASC';
|
|
}
|
|
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
|
|
// echo 'Requête = [ '.$requete.' ]<br />';
|
|
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$bateau['details_bateau'][$nb_entrees] = $donnees;
|
|
|
|
// Recherche de l'unité du capteur :
|
|
$sous_requete = 'SELECT Unite FROM TB_BATEAUX_Variables WHERE ID_Bateau=? AND Validite=1 AND Cle_primaire=? ';
|
|
$sous_reponse = Requete_preparee_bdd($sous_requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $donnees['ID_Variable'])),
|
|
__FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_reponse);
|
|
$bateau['details_bateau'][$nb_entrees]['Unite'] = $sous_donnees['Unite'];
|
|
Liberation_jeu_de_resultat_bdd($sous_reponse);
|
|
|
|
$nb_entrees ++;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune")
|
|
{
|
|
// Préparation des paramètres spécifiques à chaque type (mais communs à tous les éléments de ce type) :
|
|
|
|
$haxis_format = "'dd/MM'";
|
|
$langue = "'".$_SESSION['langue']."'";
|
|
$couleur_1 = "'rgb(117, 185, 218)'"; // Valeur par défaut (bleu Koriolan)
|
|
$couleur_2 = "'rgb(117, 185, 218)'"; // Valeur par défaut (bleu Koriolan)
|
|
$couleur_3 = "'rgb(117, 185, 218)'"; // Valeur par défaut (bleu Koriolan)
|
|
|
|
|
|
$titre_graphique = Recuperer_texte("bateau","details","capteurs","titre_graphe1");
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous") $nom_table = "TB_BATEAUX_Mesures_capteurs";
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese") $nom_table = "TB_BATEAUX_Archive_mesures_capteurs";
|
|
$diviseur_unite = 1;
|
|
$variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type = ? AND ID_Bateau = ? ORDER BY Priorite_affichage";
|
|
// $variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type = ? AND ID_Bateau = ? AND Priorite_affichage != 0 ORDER BY Priorite_affichage";
|
|
$type_var = 3;
|
|
|
|
|
|
switch($_SESSION['Bateaux']['type_courbe_details_bateau'])
|
|
{
|
|
//===============
|
|
case "Aucune": break;
|
|
|
|
//===============
|
|
default: $_SESSION['Bateaux']['type_courbe_details_bateau'] = "Synthese"; // Pas de break;
|
|
case "Synthese" :
|
|
{
|
|
$nb_jours_periode = 360;
|
|
$regroupement_donnees = 1; // * 60; // En secondes ATTENTION : Pas sûr car passé en ms dans la requête ci-desssous !!!! A Vérifier !
|
|
|
|
if ((isset($_SESSION['Bateaux']['graphe_date_debut']) && $_SESSION['Bateaux']['graphe_date_debut'] != '') || isset($_SESSION['Bateaux']['graphe_date_fin']) && $_SESSION['Bateaux']['graphe_date_fin'] != ''){
|
|
if(isset($_SESSION['Bateaux']['graphe_date_debut']) && $_SESSION['Bateaux']['graphe_date_debut'] != '') $titre_graphique .= Recuperer_texte("bateau","details","all","titre_graphe5").str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_debut']).":00";
|
|
if(isset($_SESSION['Bateaux']['graphe_date_fin']) && $_SESSION['Bateaux']['graphe_date_fin'] != '') $titre_graphique .= Recuperer_texte("bateau","details","all","titre_graphe6").str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_fin']).":00";
|
|
$titre_graphique .= Recuperer_texte("bateau","details","all","titre_graphe");
|
|
}
|
|
else $titre_graphique .= Recuperer_texte("bateau","details","capteurs","titre_graphe2").($nb_jours_periode).Recuperer_texte("bateau","details","capteurs","titre_graphe3");
|
|
|
|
$requete = ' SELECT (UNIX_TIMESTAMP(Date) * 1000) AS Date, '; // Le x1000 permet d'avoir directement un timestamp en ms (nécessaire pour la fonction Date de JS)
|
|
$requete .= ' Valeur_maxi AS Max, ';
|
|
$requete .= ' Valeur_mini AS Min, ';
|
|
$requete .= ' Valeur_moyenne AS Avg ';
|
|
$requete .= ' FROM '.$nom_table.' WHERE ID_Bateau=? AND ID=? AND ID_Variable=? AND Date>? AND Date<=? ';
|
|
$requete .= ' GROUP BY (Date DIV 1000000) ORDER BY Date '; // Le 'DIV 1000000' permet de passer de timestamp à des jours (https://dev.mysql.com/doc/refman/8.0/en/date-and-time-type-conversion.html )
|
|
|
|
$table = array();
|
|
$table['cols'] = array(
|
|
array('label' => 'Date', 'type' => 'datetime'),
|
|
array('label' => 'Max', 'type' => 'number'), // Nb : le nom de chaque champs (comme 'Max') est visible à l'écran quand on balade la crosshair.
|
|
array('label' => 'Min', 'type' => 'number'), // ... Il vaut donc mieux leur donner un nom explicite, notamment sur ce graphique avec plusieurs courbes.
|
|
array('label' => 'Avg', 'type' => 'number') // ... A noter que la question de la traduction peut se poser...
|
|
);
|
|
|
|
$nom_val_max = "Max"; // Nom de la variable sur laquelle la valeur max de la courbe sera calculée
|
|
$nom_val_min = "Min"; // Nom de la variable sur laquelle la valeur min de la courbe sera calculée
|
|
|
|
$couleur_1 = "'rgb(0, 69, 99)'";
|
|
$couleur_2 = "'rgb(117,185,218)'";
|
|
$couleur_3 = "'rgb(171, 215, 237)'";
|
|
|
|
break;
|
|
}
|
|
//===============
|
|
case "Tous" :
|
|
{
|
|
$nb_jours_periode = DATE_SEUIL_1;
|
|
$regroupement_donnees = 1; // * 60; // En secondes ATTENTION : Pas sûr car passé en ms dans la requête ci-desssous !!!! A Vérifier !
|
|
|
|
$titre_graphique .= Recuperer_texte("bateau","details","capteurs","titre_graphe2").($nb_jours_periode).Recuperer_texte("bateau","details","capteurs","titre_graphe4");
|
|
|
|
$requete = ' SELECT (UNIX_TIMESTAMP(Date) * 1000) AS Date, '; // Le x1000 permet d'avoir directement un timestamp en ms (nécessaire pour la fonction Date de JS)
|
|
$requete .= ' Valeur AS Val ';
|
|
$requete .= ' FROM '.$nom_table.' WHERE ID_Bateau=? AND ID=? AND ID_Variable=? AND Date>? AND Date<=?';
|
|
$requete .= ' GROUP BY (Date DIV '.$regroupement_donnees.') ORDER BY Date ';
|
|
|
|
$table = array();
|
|
$table['cols'] = array(
|
|
array('label' => 'Date', 'type' => 'datetime'),
|
|
array('label' => 'Val', 'type' => 'number'),
|
|
array('label' => 'Valeur_2', 'type' => 'number'),
|
|
array('label' => 'Valeur_3', 'type' => 'number')
|
|
);
|
|
|
|
$nom_val_max = "Val"; // Nom de la variable sur laquelle la valeur max de la courbe sera calculée
|
|
$nom_val_min = "Val"; // Nom de la variable sur laquelle la valeur min de la courbe sera calculée
|
|
|
|
$couleur_1 = "'rgb(0, 69, 99)'";
|
|
$couleur_2 = "'rgb(117,185,218)'";
|
|
$couleur_3 = "'rgb(171, 215, 237)'";
|
|
break;
|
|
}
|
|
}
|
|
// Préparation du tableau de valeurs :
|
|
$min = 999999;
|
|
$max = -999999;
|
|
$rows = array();
|
|
|
|
|
|
|
|
// Calcul des dates de début de filtrage des données du graphique :
|
|
$date = date_create();
|
|
$date_fin = date_format($date, 'Y-m-d H:i:s');
|
|
date_sub($date, date_interval_create_from_date_string(''.$nb_jours_periode.' days'));
|
|
$date_debut = date_format($date, 'Y-m-d H:i:s');
|
|
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"){
|
|
if(isset($_SESSION['Bateaux']['graphe_date_debut']) && $_SESSION['Bateaux']['graphe_date_debut'] != '') $date_debut = str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_debut']).":00";
|
|
if(isset($_SESSION['Bateaux']['graphe_date_fin']) && $_SESSION['Bateaux']['graphe_date_fin'] != '') $date_fin = str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_fin']).":00";
|
|
}
|
|
|
|
// Récupération des datas :
|
|
|
|
|
|
// if ($_SESSION['Bateaux']['id_variable_details_bateau'] == 0){
|
|
// $_SESSION['Bateaux']['id_variable_details_bateau'] = $variables[0]['Cle_primaire']; // Variable par default pour ne pas avoir un graphe vide
|
|
// }
|
|
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $_SESSION['Bateaux']['id_entree_details_bateau']),
|
|
array('i', $_SESSION['Bateaux']['id_variable_details_bateau']),
|
|
array('s', $date_debut),
|
|
array('s', $date_fin)),
|
|
__FILE__, __LINE__);
|
|
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
// Préparation de la chaine de date selon format "Date(Year, Month, Day, Hours, Minutes, Seconds, Milliseconds)" :
|
|
$chaine_date = 'Date('.$donnees['Date'].')'; // On créée la chaine qui appellera la fonction Date avec le timestamp (soit une chaine du genre 'Date(124524415214225)')
|
|
$temp = array();
|
|
$temp[] = array('v' => $chaine_date);
|
|
switch($_SESSION['Bateaux']['type_courbe_details_bateau'])
|
|
{
|
|
case "Synthese" :
|
|
{
|
|
$temp[] = array('v' => $donnees['Max']);
|
|
$temp[] = array('v' => $donnees['Min']);
|
|
$temp[] = array('v' => $donnees['Avg']);
|
|
break;
|
|
}
|
|
case "Tous" :
|
|
{
|
|
$temp[] = array('v' => $donnees['Val']);
|
|
|
|
break;
|
|
}
|
|
}
|
|
$rows[] = array('c' => $temp);
|
|
|
|
if ($donnees[''.$nom_val_max.''] != '' && $donnees[''.$nom_val_max.''] > $max) $max = $donnees[''.$nom_val_max.''];
|
|
if ($donnees[''.$nom_val_min.''] != '' && $donnees[''.$nom_val_min.''] < $min) $min = $donnees[''.$nom_val_min.''];
|
|
|
|
}
|
|
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
// Préparation des données :
|
|
// Création des faux points 0.1ms avant chaque nouveau enregistrement pour bien affiché les graphes
|
|
switch($_SESSION['Bateaux']['type_courbe_details_bateau'])
|
|
{
|
|
case "Synthese" :
|
|
{
|
|
$size = sizeof($rows);
|
|
for ($i = 1; $i < $size; $i++){
|
|
$date = str_replace(')','',str_replace('Date(','',$rows[$i]['c']['0']['v']))-100;
|
|
$date = 'Date('.$date.')';
|
|
|
|
$temp_faux = array();
|
|
$temp_faux[] = array('v' => $date);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['2']['v']);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['3']['v']);
|
|
$rows[] = array('c' => $temp_faux);
|
|
}
|
|
// if (sizeof($rows) > 0){
|
|
// $temp_faux = array();
|
|
// $temp_faux[] = array('v' => "Date(".time()."000)");
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['2']['v']);
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['3']['v']);
|
|
// $rows[] = array('c' => $temp_faux);
|
|
// }
|
|
|
|
break;
|
|
}
|
|
case "Tous" :
|
|
{
|
|
$size = sizeof($rows);
|
|
for ($i = 1; $i < $size; $i++){
|
|
$date = str_replace(')','',str_replace('Date(','',$rows[$i]['c']['0']['v']))-100;
|
|
$date = 'Date('.$date.')';
|
|
|
|
$temp_faux = array();
|
|
$temp_faux[] = array('v' => $date);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
|
|
$rows[] = array('c' => $temp_faux);
|
|
}
|
|
// if (sizeof($rows) > 0){
|
|
// $temp_faux = array();
|
|
// $temp_faux[] = array('v' => "Date(".time()."000)");
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
|
|
// $rows[] = array('c' => $temp_faux);
|
|
// }
|
|
break;
|
|
}
|
|
}
|
|
// Trier le tableau du data
|
|
function sortByDate_rows($a, $b) {
|
|
return str_replace(')','',str_replace('Date(','',$a['c']['0']['v'])) - str_replace(')','',str_replace('Date(','',$b['c']['0']['v']));
|
|
}
|
|
usort($rows, 'sortByDate_rows');
|
|
$table['rows'] = $rows; // Stockage de toutes les rows créées dans 'table'
|
|
$jsonTable = json_encode($table); // Mise au format JSON pour être lu par la fonction JS
|
|
|
|
$nomgraphique = "'graphique_".$_SESSION['Bateaux']['id_entree_details_bateau']."'"; // Permet de passer à la fonction JS le nom du graphique (différent pour chaque capteur...)
|
|
|
|
//===============================================================================================================================================
|
|
// GRAPHIQUES :
|
|
//===============================================================================================================================================
|
|
// Appels JavaScript pour générer le graphique :
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
google.charts.load('current', {packages: ['corechart'], language: <?=$langue?>}); // Load the Visualization API and the chart package(s).
|
|
google.charts.setOnLoadCallback(drawChart); // Set a callback to run when the Google Visualization API is loaded.
|
|
|
|
function drawChart()
|
|
{
|
|
var data = new google.visualization.DataTable(<?=$jsonTable?>);
|
|
var options =
|
|
{
|
|
width: '100%',
|
|
height: '100%',
|
|
<?php if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"): ?>
|
|
legend: { position: 'bottom', alignment: 'center' },
|
|
<?php endif; ?>
|
|
<?php if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous"): ?>
|
|
legend: 'none',
|
|
<?php endif; ?>
|
|
responsive: true,
|
|
// curveType: 'function', // Utilisable uniquement si le type de graphique est Line (ne fonctionne pas avec Area)
|
|
backgroundColor: 'rgb(250, 250, 250)',
|
|
lineWidth: 3,
|
|
areaOpacity: '0.2',
|
|
pointsVisible: true,
|
|
pointSize: 5,
|
|
pointShape: 'star',
|
|
explorer: {
|
|
actions: ['dragToZoom', 'rightClickToReset'],
|
|
// axis: 'horizontal',
|
|
keepInBounds: true,
|
|
maxZoomIn: 0.001,
|
|
zoomEnabled: true,
|
|
zoomDelta:0.2
|
|
},
|
|
zoomEnabled: true,
|
|
crosshair: {
|
|
trigger: 'focus', // Eviter de mettre 'both' car avec le zoom, le crosshair a tendance à 'coller à la souris'...
|
|
color: 'rgb(0, 69, 99)', // Commenter la ligne pour prendre la couleur de la courbe sur laquelle on est.
|
|
},
|
|
chartArea: {
|
|
left: '10%', // Marge à gauche de la zone de graphique (permet d'afficher les valeurs de vAxis)
|
|
width: '88%',
|
|
top: '2%', // Permet de ne pas toucher le titre du graphique (qui est traité en HTML/CSS car la gestion des titres ici est pourrie... Par exe, pas de centrage possible !)
|
|
height: '85%' // Un espace en-dessous est nécessaire pour les repères de l'axe X.
|
|
},
|
|
hAxis: {
|
|
textStyle: { fontSize:10 },
|
|
format:<?=$haxis_format?>,
|
|
/* gridlines: {
|
|
count: -1,
|
|
units: {
|
|
days: {format: ['MMM dd']},
|
|
hours: {format: ['HH:mm', 'ha']},
|
|
minutes: {format: ['mm']}
|
|
}
|
|
},
|
|
minorGridlines: {
|
|
units: {
|
|
hours: {format: ['hh:mm:ss a', 'ha']},
|
|
minutes: {format: ['HH:mm a Z', ':mm']}
|
|
}
|
|
}*/
|
|
},
|
|
vAxis: {
|
|
maxValue:<?=$max?>,
|
|
minValue:<?=$min?>,
|
|
textStyle: { fontSize:10 },
|
|
},
|
|
series:
|
|
{
|
|
0: {
|
|
areaOpacity: '0.0',
|
|
color: <?=$couleur_1?>
|
|
},
|
|
1: {
|
|
areaOpacity: '0.0',
|
|
color: <?=$couleur_3?>
|
|
},
|
|
2: {
|
|
areaOpacity: '0.0',
|
|
color: <?=$couleur_2?>
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
var chart = new google.visualization.AreaChart(document.getElementById(<?=$nomgraphique?>));
|
|
chart.draw(data, options);
|
|
}
|
|
</script>
|
|
<?php
|
|
}
|
|
break;
|
|
}
|
|
|
|
//=========================
|
|
case "TB_BATEAUX_Batteries":
|
|
case "TB_BATEAUX_Circuits":
|
|
case "TB_BATEAUX_Reservoirs":
|
|
{
|
|
if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != "") $date_ver = str_replace("T"," ",$_SESSION['Bateaux']['date_version']).":00";
|
|
|
|
$nb_entrees = 0;
|
|
if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != "")
|
|
{
|
|
$requete = 'SELECT * FROM '.$_SESSION['Bateaux']['type_details_bateau'].'_archive WHERE ID_Bateau=? AND SUBSTR(date_maj, 1, 13) = (SELECT SUBSTR(date_maj, 1, 13) from '.$_SESSION['Bateaux']['type_details_bateau'].'_archive WHERE SUBSTR(date_maj, 1, 13) < SUBSTR("'.$date_ver.'", 1, 13) ORDER BY date_maj DESC limit 1) ORDER BY Priorite_affichage_accueil ASC';
|
|
}
|
|
else
|
|
{
|
|
switch($_SESSION['Bateaux']['type_details_bateau'])
|
|
{
|
|
//----------------------------------------
|
|
case "TB_BATEAUX_Circuits":
|
|
{
|
|
// Recherche des onglets configurés sur le bateau :
|
|
$requete = 'SELECT Cle_primaire, Nom FROM TB_BATEAUX_Familles_circuits WHERE ID_Bateau=? AND Validite=1 ORDER BY Priorite_affichage ASC ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
// Recherche du nombre de circuits affectés à cette famille :
|
|
$sous_requete = 'SELECT COUNT(*) as Total FROM TB_BATEAUX_Circuits WHERE ID_Bateau=? AND Validite=1 AND ID_Famille_circuits=? ';
|
|
$sous_reponse = Requete_preparee_bdd($sous_requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $donnees['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_reponse);
|
|
|
|
if ($sous_donnees['Total'] > 0) $bateau['onglets'][$nb_onglets ++] = $donnees; // On ne présente que les familles ayant au moins 1 circuit...
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
// Affectation du premier onglet si aucun n'est sélectionné :
|
|
if ($nb_onglets > 0)
|
|
{
|
|
if ($_SESSION['Bateaux']['bateau']['ID_Famille'] == 0) $_SESSION['Bateaux']['bateau']['ID_Famille'] = $bateau['onglets'][0]['Cle_primaire'];
|
|
$filtre_famille = " ID_Famille_circuits=".$_SESSION['Bateaux']['bateau']['ID_Famille']." ";
|
|
}
|
|
else $filtre_famille = " 1 ";
|
|
|
|
// Recherche des éléments appartenant à l'onglet en cours :
|
|
$requete = 'SELECT * FROM TB_BATEAUX_Circuits ';
|
|
$requete .= 'WHERE ID_Bateau=? AND Validite=1 AND '.$filtre_famille.' ORDER BY ABS(Priorite_affichage_accueil) ASC';
|
|
|
|
|
|
break;
|
|
}
|
|
|
|
//----------------------------------------
|
|
case "TB_BATEAUX_Reservoirs":
|
|
{
|
|
// Recherche des onglets configurés sur le bateau :
|
|
$requete = 'SELECT Cle_primaire, Nom FROM TB_BATEAUX_Familles_reservoirs WHERE ID_Bateau=? AND Validite=1 ORDER BY Priorite_affichage ASC ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
// Recherche du nombre de réservoirs affectés à cette famille :
|
|
$sous_requete = 'SELECT COUNT(*) as Total FROM TB_BATEAUX_Reservoirs WHERE ID_Bateau=? AND Validite=1 AND ID_Famille_reservoirs=? ';
|
|
$sous_reponse = Requete_preparee_bdd($sous_requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $donnees['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
$sous_donnees = Recherche_ligne_bdd($sous_reponse);
|
|
|
|
if ($sous_donnees['Total'] > 0) $bateau['onglets'][$nb_onglets ++] = $donnees; // On ne présente que les familles ayant au moins 1 réservoir...
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
// Affectation du premier onglet si aucun n'est sélectionné :
|
|
if ($nb_onglets > 0)
|
|
{
|
|
if ($_SESSION['Bateaux']['bateau']['ID_Famille'] == 0) $_SESSION['Bateaux']['bateau']['ID_Famille'] = $bateau['onglets'][0]['Cle_primaire'];
|
|
$filtre_famille = " ID_Famille_reservoirs=".$_SESSION['Bateaux']['bateau']['ID_Famille']." ";
|
|
}
|
|
else $filtre_famille = " 1 ";
|
|
|
|
// Recherche des éléments appartenant à l'onglet en cours :
|
|
$requete = 'SELECT * FROM TB_BATEAUX_Reservoirs ';
|
|
$requete .= 'WHERE ID_Bateau=? AND Validite=1 AND '.$filtre_famille.' ORDER BY ABS(Priorite_affichage_accueil) ASC';
|
|
|
|
break;
|
|
}
|
|
|
|
//----------------------------------------
|
|
default :
|
|
{
|
|
$requete = 'SELECT * FROM '.$_SESSION['Bateaux']['type_details_bateau'].' WHERE ID_Bateau=? AND Validite=1 ORDER BY Priorite_affichage_accueil ASC';
|
|
break;
|
|
}
|
|
}
|
|
// echo 'Requête = [ '.$requete.' ]<br />';
|
|
|
|
}
|
|
|
|
// Exécution de la requête et récupération des résultats :
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$bateau['details_bateau'][$nb_entrees] = $donnees;
|
|
|
|
switch($_SESSION['Bateaux']['type_details_bateau'])
|
|
{
|
|
//----------------------------------------
|
|
case "TB_BATEAUX_Batteries":
|
|
{
|
|
// Capacité 1 :
|
|
if ($bateau['details_bateau'][$nb_entrees]['Capacite_1'] != "")
|
|
{
|
|
$capa = explode("/", $bateau['details_bateau'][$nb_entrees]['Capacite_1']);
|
|
$bateau['details_bateau'][$nb_entrees]['capacite_1'] = number_format($capa[0], 0, ".", " ")." Ah [C".number_format($capa[1], 0, ".", " ")."]";
|
|
}
|
|
else $bateau['details_bateau'][$nb_entrees]['capacite_1'] = "<i>".Recuperer_texte("bateau","details","batteries","capacite_1_non_renseignee")."</i>"; // Ce cas ne devrait jamais se produire !
|
|
|
|
// Capacité 2 :
|
|
if ($bateau['details_bateau'][$nb_entrees]['Capacite_2'] != "")
|
|
{
|
|
$capa = explode("/", $bateau['details_bateau'][$nb_entrees]['Capacite_2']);
|
|
$bateau['details_bateau'][$nb_entrees]['capacite_2'] = number_format($capa[0], 0, ".", " ")." Ah [C".number_format($capa[1], 0, ".", " ")."]";
|
|
}
|
|
else $bateau['details_bateau'][$nb_entrees]['capacite_2'] = "<i>".Recuperer_texte("bateau","details","batteries","capacite_2_non_renseignee")."</i>";
|
|
|
|
// Type :
|
|
switch($bateau['details_bateau'][$nb_entrees]['Type'])
|
|
{
|
|
case 0 : { $bateau['details_bateau'][$nb_entrees]['type'] = "<i>".Recuperer_texte("bateau","details","batteries","non_defini")."</i>"; break; }
|
|
case 1 : { $bateau['details_bateau'][$nb_entrees]['type'] = Recuperer_texte("bateau","details","batteries","type_pb_acide_liquide"); break; }
|
|
case 2 : { $bateau['details_bateau'][$nb_entrees]['type'] = Recuperer_texte("bateau","details","batteries","type_pb_agm"); break; }
|
|
case 3 : { $bateau['details_bateau'][$nb_entrees]['type'] = Recuperer_texte("bateau","details","batteries","type_pb_gel"); break; }
|
|
case 4 : { $bateau['details_bateau'][$nb_entrees]['type'] = Recuperer_texte("bateau","details","batteries","type_pb_carbone"); break; }
|
|
case 10 : { $bateau['details_bateau'][$nb_entrees]['type'] = Recuperer_texte("bateau","details","batteries","type_lithium"); break; }
|
|
default : { $bateau['details_bateau'][$nb_entrees]['type'] = "<i>".Recuperer_texte("bateau","details","batteries","type_inconnu")."</i>"; break; }
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//----------------------------------------
|
|
case "TB_BATEAUX_Circuits":
|
|
case "TB_BATEAUX_Reservoirs":
|
|
default :
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
$nb_entrees ++;
|
|
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
|
|
// Calculs des éléments de la courbe si une courbe est demandée :
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune")
|
|
{
|
|
// $start_time = microtime(true);
|
|
|
|
// Préparation des paramètres spécifiques à chaque type (mais communs à tous les éléments de ce type) :
|
|
|
|
$haxis_format = "'dd/MM/yy'";
|
|
$langue = "'".$_SESSION['langue']."'";
|
|
$couleur_1 = "'rgb(117, 185, 218)'"; // Valeur par défaut (bleu Koriolan)
|
|
$couleur_2 = "'rgb(117, 185, 218)'"; // Valeur par défaut (bleu Koriolan)
|
|
$couleur_3 = "'rgb(117, 185, 218)'"; // Valeur par défaut (bleu Koriolan)
|
|
|
|
$regroupement_donnees = 1; // Valeur par défaut (en secondes)
|
|
|
|
switch($_SESSION['Bateaux']['type_details_bateau'])
|
|
{
|
|
case "TB_BATEAUX_Batteries":
|
|
{
|
|
$titre_graphique = "";
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous") $nom_table = "TB_BATEAUX_Mesures_batteries";
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese") $nom_table = "TB_BATEAUX_Archive_mesures_batteries";
|
|
$diviseur_unite = 1;
|
|
if ((version_compare($bateau['version'], '2.1.8') < 0) && ($bateau['Cle_primaire'] != 25))
|
|
{
|
|
$variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type = ? AND ID_Bateau = ? ORDER BY Priorite_affichage";
|
|
}
|
|
else $variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type=? AND ID_Bateau=? AND Priorite_affichage!=0 ORDER BY Priorite_affichage";
|
|
|
|
$type_var = 4;
|
|
break;
|
|
}
|
|
case "TB_BATEAUX_Circuits":
|
|
{
|
|
$titre_graphique = "";
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous") $nom_table = "TB_BATEAUX_Mesures_circuits";
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese") $nom_table = "TB_BATEAUX_Archive_mesures_circuits";
|
|
$diviseur_unite = 1;
|
|
$variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type = ? AND ID_Bateau = ? ORDER BY Priorite_affichage";
|
|
// $variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type = ? AND ID_Bateau = ? AND Priorite_affichage != 0 ORDER BY Priorite_affichage";
|
|
$type_var = 1;
|
|
break;
|
|
}
|
|
case "TB_BATEAUX_Reservoirs":
|
|
{
|
|
// limite du nombre de valeurs affichées qui atteignait 82 000 sur 30 jours.... !
|
|
$regroupement_donnees = 120; // En secondes
|
|
$titre_graphique = "";
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous") $nom_table = "TB_BATEAUX_Mesures_reservoirs";
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese") $nom_table = "TB_BATEAUX_Archive_mesures_reservoirs";
|
|
$diviseur_unite = 1;
|
|
$variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type = ? AND ID_Bateau = ? ORDER BY Priorite_affichage";
|
|
// $variables = "SELECT Cle_primaire, Nom, Unite FROM TB_BATEAUX_Variables WHERE Type = ? AND ID_Bateau = ? AND Priorite_affichage != 0 ORDER BY Priorite_affichage";
|
|
$type_var = 3;
|
|
break;
|
|
}
|
|
}
|
|
|
|
switch($_SESSION['Bateaux']['type_courbe_details_bateau'])
|
|
{
|
|
//===============
|
|
case "Aucune": break;
|
|
|
|
//===============
|
|
default: $_SESSION['Bateaux']['type_courbe_details_bateau'] = "Synthese"; // Pas de break;
|
|
case "Synthese" :
|
|
{
|
|
$nb_jours_periode = 360;
|
|
|
|
// $titre_graphique .= Recuperer_texte("bateau","details","rest","titre_graphe2").($nb_jours_periode).Recuperer_texte("bateau","details","rest","titre_graphe3");
|
|
|
|
if ((isset($_SESSION['Bateaux']['graphe_date_debut']) && $_SESSION['Bateaux']['graphe_date_debut'] != '') || isset($_SESSION['Bateaux']['graphe_date_fin']) && $_SESSION['Bateaux']['graphe_date_fin'] != ''){
|
|
if(isset($_SESSION['Bateaux']['graphe_date_debut']) && $_SESSION['Bateaux']['graphe_date_debut'] != '') $titre_graphique .= Recuperer_texte("bateau","details","all","titre_graphe5").str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_debut']).":00";
|
|
if(isset($_SESSION['Bateaux']['graphe_date_fin']) && $_SESSION['Bateaux']['graphe_date_fin'] != '') $titre_graphique .= Recuperer_texte("bateau","details","all","titre_graphe6").str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_fin']).":00";
|
|
$titre_graphique .= Recuperer_texte("bateau","details","all","titre_graphe");
|
|
}
|
|
else $titre_graphique .= Recuperer_texte("bateau","details","rest","titre_graphe2").($nb_jours_periode).Recuperer_texte("bateau","details","rest","titre_graphe3");
|
|
|
|
|
|
$requete = ' SELECT (UNIX_TIMESTAMP(Date) * 1000) AS Date, '; // Le x1000 permet d'avoir directement un timestamp en ms (nécessaire pour la fonction Date de JS)
|
|
$requete .= ' Valeur_maxi AS Max, ';
|
|
$requete .= ' Valeur_mini AS Min, ';
|
|
$requete .= ' Valeur_moyenne AS Avg ';
|
|
$requete .= ' FROM '.$nom_table.' WHERE ID_Bateau=? AND ID=? AND ID_Variable=? AND Date>? AND Date<=? ';
|
|
$requete .= ' GROUP BY (Date DIV 1000000) ORDER BY Date '; // Le 'DIV 1000000' permet de passer de timestamp à des jours (https://dev.mysql.com/doc/refman/8.0/en/date-and-time-type-conversion.html )
|
|
|
|
$table = array();
|
|
$table['cols'] = array(
|
|
array('label' => 'Date', 'type' => 'datetime'),
|
|
array('label' => 'Max', 'type' => 'number'), // Nb : le nom de chaque champs (comme 'Max') est visible à l'écran quand on balade la crosshair.
|
|
array('label' => 'Min', 'type' => 'number'), // ... Il vaut donc mieux leur donner un nom explicite, notamment sur ce graphique avec plusieurs courbes.
|
|
array('label' => 'Avg', 'type' => 'number') // ... A noter que la question de la traduction peut se poser...
|
|
);
|
|
|
|
$nom_val_max = "Max"; // Nom de la variable sur laquelle la valeur max de la courbe sera calculée
|
|
$nom_val_min = "Min"; // Nom de la variable sur laquelle la valeur min de la courbe sera calculée
|
|
|
|
$couleur_1 = "'rgb(0, 69, 99)'";
|
|
$couleur_2 = "'rgb(117,185,218)'";
|
|
$couleur_3 = "'rgb(171, 215, 237)'";
|
|
|
|
break;
|
|
}
|
|
|
|
//===============
|
|
case "Tous" :
|
|
{
|
|
$nb_jours_periode = DATE_SEUIL_1;
|
|
|
|
$titre_graphique .= Recuperer_texte("bateau","details","rest","titre_graphe2").($nb_jours_periode).Recuperer_texte("bateau","details","rest","titre_graphe4");
|
|
|
|
$requete = ' SELECT (UNIX_TIMESTAMP(Date) * 1000) AS Date, ';
|
|
$requete .= ' Valeur AS Val '; // Le x1000 permet d'avoir directement un timestamp en ms (nécessaire pour la fonction Date de JS)
|
|
$requete .= ' FROM '.$nom_table.' WHERE ID_Bateau=? AND ID=? AND ID_Variable=? AND Date>? AND Date<=?';
|
|
$requete .= ' GROUP BY (Date DIV '.$regroupement_donnees.') ORDER BY Date ';
|
|
|
|
$table = array();
|
|
$table['cols'] = array(
|
|
array('label' => 'Date', 'type' => 'datetime'),
|
|
array('label' => 'Val', 'type' => 'number'),
|
|
array('label' => 'Valeur_2', 'type' => 'number'),
|
|
array('label' => 'Valeur_3', 'type' => 'number')
|
|
);
|
|
|
|
$nom_val_max = "Val"; // Nom de la variable sur laquelle la valeur max de la courbe sera calculée
|
|
$nom_val_min = "Val"; // Nom de la variable sur laquelle la valeur min de la courbe sera calculée
|
|
|
|
$couleur_1 = "'rgb(0, 69, 99)'";
|
|
$couleur_2 = "'rgb(117,185,218)'";
|
|
$couleur_3 = "'rgb(171, 215, 237)'";
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
// Préparation du tableau de valeurs :
|
|
$min = 999999;
|
|
$max = -999999;
|
|
$rows = array();
|
|
|
|
|
|
|
|
// Calcul des dates de début de filtrage des données du graphique :
|
|
$date = date_create();
|
|
$date_fin = date_format($date, 'Y-m-d H:i:s');
|
|
date_sub($date, date_interval_create_from_date_string(''.$nb_jours_periode.' days'));
|
|
$date_debut = date_format($date, 'Y-m-d H:i:s');
|
|
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"){
|
|
if(isset($_SESSION['Bateaux']['graphe_date_debut']) && $_SESSION['Bateaux']['graphe_date_debut'] != '') $date_debut = str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_debut']).":00";
|
|
if(isset($_SESSION['Bateaux']['graphe_date_fin']) && $_SESSION['Bateaux']['graphe_date_fin'] != '') $date_fin = str_replace("T"," ",$_SESSION['Bateaux']['graphe_date_fin']).":00";
|
|
}
|
|
|
|
// Récupération des noms de variables
|
|
$var_reponse = Requete_preparee_bdd($variables,
|
|
array(
|
|
array('i', $type_var),
|
|
array('i', $bateau['Cle_primaire'])
|
|
),
|
|
__FILE__, __LINE__);
|
|
|
|
//echo 'Requête : '.$variables.', type_var='.$type_var.' et clé_primaire du bateau = '.$bateau['Cle_primaire'].'<br />';
|
|
$nb_var = 0;
|
|
$variables = NULL;
|
|
while ($donnees = Recherche_ligne_bdd($var_reponse))
|
|
{
|
|
// echo $nb_var.' : '.$donnees['Nom'].'<br />';
|
|
$variables[$nb_var ++] = $donnees;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($var_reponse);
|
|
|
|
|
|
// Récupération des datas :
|
|
if ($_SESSION['Bateaux']['id_variable_details_bateau'] == 0){
|
|
$_SESSION['Bateaux']['id_variable_details_bateau'] = $variables[0]['Cle_primaire']; // Variable par default pour ne pas avoir un graphe vide
|
|
}
|
|
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $_SESSION['Bateaux']['id_entree_details_bateau']),
|
|
array('i', $_SESSION['Bateaux']['id_variable_details_bateau']),
|
|
array('s', $date_debut),
|
|
array('s', $date_fin)),
|
|
__FILE__, __LINE__);
|
|
$nb_val = 0;
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
// Préparation de la chaine de date selon format "Date(Year, Month, Day, Hours, Minutes, Seconds, Milliseconds)" :
|
|
$chaine_date = 'Date('.$donnees['Date'].')'; // On créée la chaine qui appellera la fonction Date avec le timestamp (soit une chaine du genre 'Date(124524415214225)')
|
|
$temp = array();
|
|
$temp[] = array('v' => $chaine_date);
|
|
switch($_SESSION['Bateaux']['type_courbe_details_bateau'])
|
|
{
|
|
case "Synthese" :
|
|
{
|
|
$temp[] = array('v' => $donnees['Max']);
|
|
$temp[] = array('v' => $donnees['Min']);
|
|
$temp[] = array('v' => $donnees['Avg']);
|
|
break;
|
|
}
|
|
case "Tous" :
|
|
{
|
|
$temp[] = array('v' => $donnees['Val']);
|
|
break;
|
|
}
|
|
}
|
|
$rows[] = array('c' => $temp);
|
|
|
|
if ($donnees[''.$nom_val_max.''] != '' && $donnees[''.$nom_val_max.''] > $max) $max = $donnees[''.$nom_val_max.''];
|
|
if ($donnees[''.$nom_val_min.''] != '' && $donnees[''.$nom_val_min.''] < $min) $min = $donnees[''.$nom_val_min.''];
|
|
$nb_val ++;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
//$titre_graphique .= "<br />Nb de valeurs = ".$nb_val."<br />";
|
|
// Préparation des données :
|
|
// Création des faux points 0.1ms avant chaque nouveau enregistrement pour bien affiché les graphes
|
|
switch($_SESSION['Bateaux']['type_courbe_details_bateau'])
|
|
{
|
|
case "Synthese" :
|
|
{
|
|
$size = sizeof($rows);
|
|
for ($i = 1; $i < $size; $i++){
|
|
$date = str_replace(')','',str_replace('Date(','',$rows[$i]['c']['0']['v']))-100;
|
|
$date = 'Date('.$date.')';
|
|
|
|
$temp_faux = array();
|
|
$temp_faux[] = array('v' => $date);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['2']['v']);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['3']['v']);
|
|
$rows[] = array('c' => $temp_faux);
|
|
}
|
|
// if (sizeof($rows) > 0){
|
|
// $temp_faux = array();
|
|
// $temp_faux[] = array('v' => "Date(".time()."000)");
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['2']['v']);
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['3']['v']);
|
|
// $rows[] = array('c' => $temp_faux);
|
|
// }
|
|
|
|
break;
|
|
}
|
|
case "Tous" :
|
|
{
|
|
$size = sizeof($rows);
|
|
for ($i = 1; $i < $size; $i++){
|
|
$date = str_replace(')','',str_replace('Date(','',$rows[$i]['c']['0']['v']))-100;
|
|
$date = 'Date('.$date.')';
|
|
|
|
$temp_faux = array();
|
|
$temp_faux[] = array('v' => $date);
|
|
$temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
|
|
$rows[] = array('c' => $temp_faux);
|
|
}
|
|
// if (sizeof($rows) > 0){
|
|
// $temp_faux = array();
|
|
// $temp_faux[] = array('v' => "Date(".time()."000)");
|
|
// $temp_faux[] = array('v' => $rows[$i-1]['c']['1']['v']);
|
|
|
|
// $rows[] = array('c' => $temp_faux);
|
|
// }
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Trier le tableau du data
|
|
function sortByDate_rows($a, $b) {
|
|
return str_replace(')','',str_replace('Date(','',$a['c']['0']['v'])) - str_replace(')','',str_replace('Date(','',$b['c']['0']['v']));
|
|
}
|
|
usort($rows, 'sortByDate_rows');
|
|
|
|
$table['rows'] = $rows; // Stockage de toutes les rows créées dans 'table'
|
|
$jsonTable = json_encode($table); // Mise au format JSON pour être lu par la fonction JS
|
|
|
|
$nomgraphique = "'graphique_".$_SESSION['Bateaux']['id_entree_details_bateau']."'"; // Permet de passer à la fonction JS le nom du graphique (différent pour chaque capteur...)
|
|
|
|
/*$nb_intervalles = 5;
|
|
$maille = 100;
|
|
$max = ceil($max / $maille) * $maille;
|
|
$intervalle = floor(($max - $min) / $nb_intervalles);
|
|
echo 'Min = '.$min.', Max = '.$max.' et intervalle = '.$intervalle.'<br />';
|
|
*/
|
|
|
|
//===============================================================================================================================================
|
|
// GRAPHIQUES :
|
|
//===============================================================================================================================================
|
|
// Appels JavaScript pour générer le graphique :
|
|
?>
|
|
<script type="text/javascript">
|
|
google.charts.load('current', {packages: ['corechart'], language: <?=$langue?>}); // Load the Visualization API and the chart package(s).
|
|
google.charts.setOnLoadCallback(drawChart); // Set a callback to run when the Google Visualization API is loaded.
|
|
|
|
function drawChart()
|
|
{
|
|
var data = new google.visualization.DataTable(<?=$jsonTable?>);
|
|
var options =
|
|
{
|
|
width: '100%',
|
|
height: '100%',
|
|
<?php if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"): ?>
|
|
legend: { position: 'bottom', alignment: 'center' },
|
|
<?php endif; ?>
|
|
<?php if ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous"): ?>
|
|
legend: 'none',
|
|
<?php endif; ?>
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
// curveType: 'function', // Utilisable uniquement si le type de graphique est Line (ne fonctionne pas avec Area)
|
|
backgroundColor: 'rgb(250, 250, 250)',
|
|
lineWidth: 3,
|
|
areaOpacity: '0.2',
|
|
pointsVisible: true,
|
|
pointSize: 5,
|
|
pointShape: 'star',
|
|
explorer: {
|
|
actions: ['dragToZoom', 'rightClickToReset'],
|
|
// axis: 'horizontal',
|
|
keepInBounds: true,
|
|
maxZoomIn: 0.001,
|
|
zoomDelta:0.2
|
|
},
|
|
crosshair: {
|
|
trigger: 'focus', // Eviter de mettre 'both' car avec le zoom, le crosshair a tendance à 'coller à la souris'...
|
|
color: 'rgb(0, 69, 99)', // Commenter la ligne pour prendre la couleur de la courbe sur laquelle on est.
|
|
},
|
|
chartArea: {
|
|
left: '10%', // Marge à gauche de la zone de graphique (permet d'afficher les valeurs de vAxis)
|
|
width: '88%',
|
|
top: '2%', // Permet de ne pas toucher le titre du graphique (qui est traité en HTML/CSS car la gestion des titres ici est pourrie... Par exe, pas de centrage possible !)
|
|
height: '85%' // Un espace en-dessous est nécessaire pour les repères de l'axe X.
|
|
},
|
|
hAxis: {
|
|
textStyle: { fontSize:10 },
|
|
format:<?=$haxis_format?>,
|
|
/* gridlines: {
|
|
count: -1,
|
|
units: {
|
|
days: {format: ['MMM dd']},
|
|
hours: {format: ['HH:mm', 'ha']},
|
|
minutes: {format: ['mm']}
|
|
}
|
|
},
|
|
minorGridlines: {
|
|
units: {
|
|
hours: {format: ['hh:mm:ss a', 'ha']},
|
|
minutes: {format: ['HH:mm a Z', ':mm']}
|
|
}
|
|
}*/
|
|
},
|
|
vAxis: {
|
|
maxValue:<?=$max?>,
|
|
minValue:<?=$min?>,
|
|
textStyle: { fontSize:10 },
|
|
},
|
|
series:
|
|
{
|
|
0: {
|
|
areaOpacity: '0.0',
|
|
color: <?=$couleur_1?>,
|
|
areaColor: 'green'
|
|
},
|
|
1: {
|
|
areaOpacity: '0.3',
|
|
color: <?=$couleur_3?>,
|
|
areaColor: 'red'
|
|
},
|
|
2: {
|
|
areaOpacity: '0.0',
|
|
color: <?=$couleur_2?>
|
|
}
|
|
}
|
|
};
|
|
|
|
// data.setProperties(1, 1, {'style': 'background-color: #111111;'});
|
|
var chart = new google.visualization.AreaChart(document.getElementById(<?=$nomgraphique?>));
|
|
|
|
chart.draw(data, options);
|
|
}
|
|
</script>
|
|
<?php
|
|
|
|
// Calculate script execution time
|
|
// $execution_time = number_format((microtime(true) - $start_time), 3, ".", " ");
|
|
// echo 'Temps d\'exécution = '.$execution_time.'<br />';
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//=========================
|
|
default: break;
|
|
|
|
} // Fin du switch 'type_details_bateau'
|
|
|
|
$requete_date_maj = "SELECT substr(date_maj,1,10) as date from TB_BATEAUX_Systeme_archive WHERE ID_Bateau = ? GROUP BY substr(date_maj,1,10) UNION
|
|
SELECT substr(date_maj,1,10) as date from TB_BATEAUX_Batteries_archive WHERE ID_Bateau = ? GROUP BY substr(date_maj,1,10) UNION
|
|
SELECT substr(date_maj,1,10) as date from TB_BATEAUX_Cartes_archive WHERE ID_Bateau = ? GROUP BY substr(date_maj,1,10) UNION
|
|
SELECT substr(date_maj,1,10) as date from TB_BATEAUX_Circuits_archive WHERE ID_Bateau = ? GROUP BY substr(date_maj,1,10) UNION
|
|
SELECT substr(date_maj,1,10) as date from TB_BATEAUX_Systeme_archive WHERE ID_Bateau = ? GROUP BY substr(date_maj,1,10) ";
|
|
$reponse_date_maj = Requete_preparee_bdd($requete_date_maj,
|
|
array(
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $bateau['Cle_primaire']),
|
|
array('i', $bateau['Cle_primaire'])
|
|
),
|
|
__FILE__, __LINE__);
|
|
$nb_dates_maj = 0;
|
|
while ($donnees = Recherche_ligne_bdd($reponse_date_maj))
|
|
{
|
|
$dates_maj[$nb_dates_maj ++] = $donnees;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse_date_maj);
|
|
|
|
function sortByDate($a, $b) {
|
|
return str_replace('-','',preg_replace('/[T_-_ _:]/', '', $b['date'])) - str_replace('-','',preg_replace('/[T_-_ _:]/', '', $a['date']));
|
|
}
|
|
if ($nb_dates_maj != 0) usort($dates_maj, 'sortByDate');
|
|
|
|
|
|
|
|
break;
|
|
}
|
|
|
|
//****************************************************************************************************************************
|
|
case "Creation_bateau":
|
|
case "Modification_bateau":
|
|
{
|
|
//--------------------------------------------------
|
|
// Préparation des variables du bateau :
|
|
if ($_SESSION['Bateaux']['page'] == "Creation_bateau")
|
|
{
|
|
$_SESSION['Bateaux']['bateau']['Cle_primaire'] = 0;
|
|
$_SESSION['Bateaux']['bateau']['Nom'] = "";
|
|
$_SESSION['Bateaux']['bateau']['ID_Flotte'] = 0;
|
|
$_SESSION['Bateaux']['bateau']['ID_Carte'] = 0;
|
|
$_SESSION['Bateaux']['bateau']['Date_mes'] = date("Y-m-d");
|
|
$_SESSION['Bateaux']['bateau']['Date_carte'] = date("Y-m-d");
|
|
$_SESSION['Bateaux']['bateau']['Date_derniere_maj'] = "2020-01-01 00:00:00";
|
|
$_SESSION['Bateaux']['bateau']['Commentaires'] = "";
|
|
}
|
|
else // Modification :
|
|
{
|
|
$requete = 'SELECT * FROM TB_Bateaux WHERE Cle_primaire=? ';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(
|
|
array('i', $_SESSION['Bateaux']['bateau']['Cle_primaire'])),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$_SESSION['Bateaux']['bateau'] = $donnees;
|
|
|
|
// Mise en forme de textes :
|
|
$_SESSION['Bateaux']['bateau']['Commentaires'] = htmlspecialchars(stripcslashes($_SESSION['Bateaux']['bateau']['Commentaires']));
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
}
|
|
|
|
//--------------------------------------------------
|
|
// Recherche des flottes existantes :
|
|
$nb_flottes = 0;
|
|
|
|
$flottes[$nb_flottes]['Cle_primaire'] = 0;
|
|
$flottes[$nb_flottes]['Nom'] = '--- Affecté à aucune flotte ---';
|
|
$nb_flottes ++;
|
|
|
|
$requete = 'SELECT * FROM TB_Flottes WHERE Validite=1 ORDER BY Nom ASC';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$flottes[$nb_flottes ++] = $donnees;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
// Recherche des cartes existantes et disponibles (+ la carte actuellement installée) :
|
|
$nb_cartes = 0;
|
|
|
|
$cartes[$nb_cartes]['Cle_primaire'] = 0;
|
|
$cartes[$nb_cartes]['No_serie'] = '--- Aucune carte ShipBase installée ---';
|
|
$cartes[$nb_cartes]['Adresse_mac'] = "";
|
|
$cartes[$nb_cartes]['Affectee'] = false;
|
|
$nb_cartes ++;
|
|
|
|
// $requete = 'SELECT * FROM TB_Cartes WHERE Validite=1 AND Type=1 AND (NOT EXISTS (SELECT ID_Carte FROM TB_Bateaux WHERE TB_Cartes.Cle_primaire=TB_Bateaux.ID_Carte) OR '.$ajout_requete.') ORDER BY No_serie ASC';
|
|
$requete = 'SELECT *, EXISTS(SELECT ID_Carte FROM TB_Bateaux WHERE TB_Bateaux.Validite=1 AND TB_Cartes.Cle_primaire=TB_Bateaux.ID_Carte) AS Affectee FROM TB_Cartes WHERE Validite=1 AND Type=0 AND Etat!='.ETAT_CARTE_REBUT.' ORDER BY No_serie ASC';
|
|
$reponse = Requete_preparee_bdd($requete,
|
|
array(),
|
|
__FILE__, __LINE__);
|
|
while ($donnees = Recherche_ligne_bdd($reponse))
|
|
{
|
|
$cartes[$nb_cartes] = $donnees;
|
|
if ($_SESSION['Bateaux']['bateau']['ID_Carte'] == $donnees['Cle_primaire']) $cartes[$nb_cartes]['Affectee'] = false; // Permet de resélectionner la carte existante carte...
|
|
$nb_cartes ++;
|
|
}
|
|
Liberation_jeu_de_resultat_bdd($reponse);
|
|
|
|
|
|
break;
|
|
}
|
|
|
|
//****************************************************************************************************************************
|
|
case "Confirmation_suppression_bateau":
|
|
{
|
|
break;
|
|
}
|
|
|
|
//****************************************************************************************************************************
|
|
default:
|
|
{
|
|
$_SESSION['Bateaux']['page'] = "Accueil";
|
|
break;
|
|
}
|
|
}
|
|
|
|
Fermeture_bdd(); // Déconnexion de MySQL
|
|
|
|
|
|
//************************************************************************************************************************************
|
|
// Affichage
|
|
//************************************************************************************************************************************
|
|
|
|
|
|
//********************************************************************************************************************************
|
|
// Affichage principal :
|
|
echo '<div id="Bateaux">';
|
|
|
|
//=========================================================================================
|
|
// Entête :
|
|
Entete_page($message_erreur, $message_information);
|
|
|
|
switch ($_SESSION['Bateaux']['page'])
|
|
{
|
|
//************************************************************************************************************************
|
|
case "Accueil":
|
|
{
|
|
echo '<div id="accueil" class="page_principale">';
|
|
echo '<h1>Bateaux</h1>';
|
|
echo '<div class="table_wrapper">';
|
|
echo '<table class="bateau">
|
|
<thead>
|
|
<tr>';
|
|
echo '<th><a href="bateaux.php?action=tri_liste&colonne=Nom">Nom</a></th>';
|
|
echo '<th><a href="bateaux.php?action=tri_liste&colonne=Flotte">Flotte</a></th>';
|
|
echo '<th><a href="bateaux.php?action=tri_liste&colonne=Carte">ShipBase</a></th>';
|
|
echo '<th><a href="bateaux.php?action=tri_liste&colonne=Adresse_mac">Adresse MAC</a></th>';
|
|
echo '<th><a href="bateaux.php?action=tri_liste&colonne=Version">Version</a></th>';
|
|
echo '<th><a href="bateaux.php?action=tri_liste&colonne=Date_maj">Dernière mise à jour [UTC]</a></th>';
|
|
// echo '<th>Commentaires</th>';
|
|
echo '</tr>
|
|
</thead>
|
|
<tbody>';
|
|
for ($i = 0; $i < $nb_bateaux; $i ++)
|
|
{
|
|
echo '<tr>
|
|
<td>
|
|
<a href="bateaux.php?action=details_bateau&id_bateau='.$bateaux[$i]['Cle_primaire'].'">
|
|
'.$bateaux[$i]['Nom'].'
|
|
</a>
|
|
</td>';
|
|
echo '<td>'.$bateaux[$i]['nom_flotte'].'</td>';
|
|
echo '<td>'.$bateaux[$i]['nom_carte'].'</td>';
|
|
echo '<td>'.$bateaux[$i]['adresse_carte'].'</td>';
|
|
echo '<td>'.$bateaux[$i]['version'].'</td>';
|
|
echo '<td>'.$bateaux[$i]['Date_derniere_maj'].'</td>';
|
|
// echo '<td>'.$bateaux[$i]['Commentaires'].'</td>';
|
|
echo '</tr>';
|
|
}
|
|
echo '</tbody>
|
|
</table>';
|
|
echo '</div>';
|
|
|
|
echo '<div class="boutons_bas_de_page">';
|
|
echo '<a title="" href="administration.php?action=navigation&destination=Accueil">Retour au menu Administration</a>';
|
|
echo '<a title="" href="bateaux.php?action=creation_bateau">Créer un nouveau bateau</a>';
|
|
echo '</div>';
|
|
|
|
echo '</div>';
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
//****************************************************************************************************************************
|
|
case "Details_bateau":
|
|
{
|
|
echo '<div id="details_bateau" class="page_principale">';
|
|
|
|
echo '<h1>Bateau <span class="gras">'.$bateau['Nom'].'</span></h1>';
|
|
|
|
echo '<div class="entete_bateau">';
|
|
if ($_SESSION['shipmember']['Niveau_acces'] >= NIVEAU_MINI_ACCES_ADMINISTATEUR || $acces_profil['Consultation_donnees'] == 2)
|
|
{
|
|
echo '<div class="bouton_gestion_acces">';
|
|
echo Ajouter_lien_modif_buttons("bateau","details","boutons","acces");
|
|
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=gerer_les_acces"';
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "gerer_les_acces") echo ' class="actif" '; echo '>
|
|
'.$_SESSION['textes']['bateau']['details']['boutons']['acces'] .'
|
|
</a>';
|
|
echo '</div>';
|
|
}
|
|
|
|
echo '<div class="derniere_maj">'.Recuperer_texte("bateau","details","derniere_connexion","libelle").' : <span class="gras">'.$bateau['Date_derniere_maj'].' [UTC]</span></div>';
|
|
echo '</div>';
|
|
|
|
// if ($nb_dates_maj != 0){
|
|
// echo '<div class="date_maj_version" id="date_maj_version">Consulter une configuration précédente :';
|
|
// echo '<form action="bateaux.php" method="POST">
|
|
|
|
// <select name="date_version" id="date_version_select">';
|
|
// echo '<option value="'.$_SESSION['Bateaux']['derniere_maj'].'" selected > '.$_SESSION['Bateaux']['derniere_maj'].' </option>';
|
|
// for ($i = 0; $i < $nb_dates_maj; $i++){
|
|
|
|
// echo '<option value="'.$dates_maj[$i]['date'].'T00:00" ';
|
|
// if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != "")
|
|
// if ($_SESSION['Bateaux']['date_version'] == $dates_maj[$i]['date'].'T00:00') echo "selected";
|
|
// echo '> '.$dates_maj[$i]['date'].' </option>';
|
|
// }
|
|
// echo ' </select>
|
|
// <button type="submit">'.$_SESSION['textes']['bateau']['details']['graph']['filtrer'].Ajouter_lien_modif_buttons("bateau","details","graph","filtrer").'</button>
|
|
// </form>';
|
|
|
|
// echo '</div>';
|
|
// }
|
|
// echo '<div class="date_maj_version" id="date_maj_version">Version date précise:';
|
|
// echo '<form action="bateaux.php" method="POST">
|
|
// <input type="datetime-local" name="date_version" id="date_version" max="'.$_SESSION['Bateaux']['derniere_maj'].'" ';
|
|
// if (isset($_SESSION['Bateaux']['date_version']) && $_SESSION['Bateaux']['date_version'] != "") echo 'value="'.$_SESSION['Bateaux']['date_version'].'"';
|
|
// echo '>
|
|
|
|
// <button type="submit"> Chercher </button>
|
|
// </form>';
|
|
|
|
// echo '</div>';
|
|
|
|
|
|
// if ($nb_data > 0){
|
|
// echo '<div id="maCarte">
|
|
|
|
// </div>';
|
|
// }
|
|
//--------------------------------
|
|
// Boutons de haut de page :
|
|
echo '<div class="boutons_haut_de_page">';
|
|
if ( ($_SESSION['shipmember']['Niveau_acces'] >= NIVEAU_MINI_ACCES_ADMINISTATEUR) ||
|
|
(($acces_profil['Consultation_donnees'] == 1) ||
|
|
($acces_profil['Consultation_donnees'] == 2)) )
|
|
{
|
|
|
|
echo '<div>';
|
|
echo Ajouter_lien_modif_buttons("bateau","details","boutons","carte");
|
|
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=TB_BATEAUX_Carte"';
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Carte") echo ' class="actif" '; echo '>
|
|
'.$_SESSION['textes']['bateau']['details']['boutons']['carte'] .'
|
|
</a>';
|
|
echo '</div>';
|
|
echo '<div>';
|
|
echo Ajouter_lien_modif_buttons("bateau","details","boutons","batteries");
|
|
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=TB_BATEAUX_Batteries"';
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Batteries") echo ' class="actif" '; echo '>
|
|
'.$_SESSION['textes']['bateau']['details']['boutons']['batteries'] .'
|
|
</a>';
|
|
echo '</div>';
|
|
echo '<div>';
|
|
echo Ajouter_lien_modif_buttons("bateau","details","boutons","circuits");
|
|
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=TB_BATEAUX_Circuits"';
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Circuits") echo ' class="actif" '; echo '>
|
|
'.$_SESSION['textes']['bateau']['details']['boutons']['circuits'] .'
|
|
</a>';
|
|
echo '</div>';
|
|
echo '<div>';
|
|
echo Ajouter_lien_modif_buttons("bateau","details","boutons","reservoirs");
|
|
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=TB_BATEAUX_Reservoirs"';
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Reservoirs") echo ' class="actif" '; echo '>
|
|
'.$_SESSION['textes']['bateau']['details']['boutons']['reservoirs'] .'
|
|
</a>';
|
|
echo '</div>';
|
|
echo '<div>';
|
|
echo Ajouter_lien_modif_buttons("bateau","details","boutons","capteurs");
|
|
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=TB_BATEAUX_Capteurs"';
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Capteurs") echo ' class="actif" '; echo '>
|
|
'.$_SESSION['textes']['bateau']['details']['boutons']['capteurs'] .'
|
|
</a>';
|
|
echo '</div>';
|
|
echo '<div>';
|
|
echo Ajouter_lien_modif_buttons("bateau","details","boutons","par_sys");
|
|
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=TB_BATEAUX_Systeme"';
|
|
if ($_SESSION['Bateaux']['type_details_bateau'] == "TB_BATEAUX_Systeme") echo ' class="actif" '; echo '>'
|
|
.$_SESSION['textes']['bateau']['details']['boutons']['par_sys'].
|
|
'</a>';
|
|
echo '</div>';
|
|
}
|
|
|
|
|
|
echo '</div>';
|
|
|
|
// Affichage des onglets lorsqu'il y en a :
|
|
if ($nb_onglets > 0)
|
|
{
|
|
echo '<div class="onglets">';
|
|
for ($i = 0; $i < $nb_onglets; $i ++)
|
|
{
|
|
echo '<a title="" href="bateaux.php?action=changement_onglet&id_onglet='.$bateau['onglets'][$i]['Cle_primaire'].' "';
|
|
if ($_SESSION['Bateaux']['bateau']['ID_Famille'] == $bateau['onglets'][$i]['Cle_primaire']) echo ' class="actif" '; echo '>'
|
|
.$bateau['onglets'][$i]['Nom'].
|
|
'</a>';
|
|
}
|
|
echo '</div>';
|
|
}
|
|
|
|
echo '<div class="corps_details_bateau">';
|
|
switch($_SESSION['Bateaux']['type_details_bateau'])
|
|
{
|
|
case "TB_BATEAUX_Carte":
|
|
{
|
|
if ($nb_data > 0){
|
|
echo '<div id="dateSlider"></div>';
|
|
|
|
echo '<div id="maCarte"></div>';
|
|
|
|
// echo '<div id="table_a_carte">
|
|
// <br>
|
|
// <table>
|
|
// <tr>
|
|
// <th colspan="4"> Etat de charge :</th>
|
|
// <th colspan="3"> Consommation électrique : </th>
|
|
// </tr>';
|
|
// for ($i = 0; $i < $nb_batteries; $i ++)
|
|
// {
|
|
// echo '<tr>
|
|
// <td> '.$batteries[$i]['Nom'].' : </td>
|
|
// <td> '.$batteries[$i]['Tension_nominale'].' V </td>
|
|
// <td> '.$batteries[$i]['Soc'].' %</td>
|
|
// <td> </td>
|
|
// <td>';
|
|
// if ($i==0) {
|
|
// echo
|
|
// '[en dur]Moyenne: </td>
|
|
// <td> [en dur]3.2A </td>
|
|
// <td> [en dur]Sur 24h</td>';
|
|
// }
|
|
// elseif ($i==1) {
|
|
// echo
|
|
// '[en dur]Maximale : </td>
|
|
// <td> [en dur]8.2A </td>
|
|
// <td> [en dur]2h30 au total</td>';
|
|
// }
|
|
// if ($i==2) {
|
|
// echo
|
|
// '[en dur]Minimale: </td>
|
|
// <td> [en dur]0.13 </td>
|
|
// <td> [en dur]13h21</td>';
|
|
// }
|
|
// echo
|
|
// '</tr>';
|
|
// }
|
|
// echo'
|
|
// </table>
|
|
// <br><br><br>
|
|
// <table>
|
|
// <tr>
|
|
// <th colspan="2"> Date début de la croisière : </th>
|
|
// <th colspan="2"> Date fin de la croisière : </th>
|
|
// <th colspan="2"> Nom de la croisière : </th>
|
|
// </tr>
|
|
// <tr>
|
|
// <td colspan="2" id="date_debut_croisire"> </td>
|
|
// <td colspan="2" id="date_fin_croisire"> </td>
|
|
// <td colspan="2"> Nom </td>
|
|
// </tr>
|
|
// <tr> <td colspan="6"> </td> </tr>
|
|
// <tr> <td colspan="6"> </td> </tr>
|
|
// ';
|
|
|
|
|
|
// for ($i = 0; $i < $nb_familles; $i ++){
|
|
// echo
|
|
// '
|
|
// <tr>
|
|
// <th colspan="3"> '.$bateau['familles'][$i]['Nom'].' : </th>
|
|
// <th > Consommation moyenne : </th>
|
|
// <th > Consommation depuis le début de la croisière : </th>
|
|
// <th > Nbre de pleins : </th>
|
|
// </tr>'
|
|
// ;
|
|
// for($j = 0; $j < sizeof($bateau['familles'][$i]['reservoirs']); $j++){
|
|
// echo
|
|
// '
|
|
// <tr>
|
|
// <td> '.$bateau['familles'][$i]['reservoirs'][$j]['Nom'].' : </td>
|
|
// <td> '.$bateau['familles'][$i]['reservoirs'][$j]['Capacite'].' l </td>
|
|
// <td> '.$bateau['familles'][$i]['reservoirs'][$j]['Niveau'].' % </td>
|
|
// <td> [en dur] x/24h </td>
|
|
// <td> [en dur] x l</td>
|
|
// <td> [en dur] x</td>
|
|
// </tr>
|
|
// '
|
|
// ;
|
|
// }
|
|
// }
|
|
|
|
// echo
|
|
|
|
// ' <tr> <td colspan="6"> </td> </tr>
|
|
// <tr> <td colspan="6"> </td> </tr>
|
|
// <tr>
|
|
// <th colspan="2"> Distance parcourue : </th>
|
|
// <th colspan="2"> Vitesse moyenne : </th>
|
|
// <th colspan="2"> Vitesse max : </th>
|
|
// </tr>
|
|
// <tr>
|
|
// <td> Dernières 24h : </td>
|
|
// <td> Depuis le début de la croisière : </td>
|
|
// <td> Dernières 24h : </td>
|
|
// <td> Depuis le début de la croisière : </td>
|
|
// <td colspan="2"> Depuis le début de la croisière : </td>
|
|
// </tr>
|
|
// <tr>
|
|
// <td id="distance24h"> </td>
|
|
// <td id="distance"> </td>
|
|
// <td> </td>
|
|
// <td> </td>
|
|
// <td colspan="2"> </td>
|
|
// </tr>
|
|
// </table>
|
|
|
|
echo '<div>';
|
|
}
|
|
break;
|
|
}
|
|
//===========================================================
|
|
case "TB_BATEAUX_Batteries":
|
|
{
|
|
for ($i = 0; $i < $nb_entrees; $i ++)
|
|
{
|
|
echo '<div class="ancre" id="ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'"> </div>'; // L'utilisation d'une div dédiée permet de donner une "hauteur" à l'ancre et ainsi dégager de dessous le bandeau de menu...
|
|
|
|
echo '<div class="titre_composant">
|
|
<p class="titre_text">
|
|
<a class="titre_icon" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'">
|
|
'.$bateau['details_bateau'][$i]['Nom'].'
|
|
</a>
|
|
</p>
|
|
|
|
<div class="titre_desc">
|
|
<p>'.Recuperer_texte("bateau","details","batterie","tension").' : '.number_format($bateau['details_bateau'][$i]['Tension'], 2, ".", " ").' V</p>
|
|
<p>'.Recuperer_texte("bateau","details","batterie","soc").' :
|
|
<span class="';
|
|
if($bateau['details_bateau'][$i]['Soc'] < $bateau['details_bateau'][$i]['Soc_seuil_bas']) echo " red";
|
|
else if($bateau['details_bateau'][$i]['Soc'] > $bateau['details_bateau'][$i]['Soc_seuil_haut']) echo " green";
|
|
else echo " orange";
|
|
echo '">'.number_format($bateau['details_bateau'][$i]['Soc'], 2, ".", " ").' %</span>
|
|
</p>
|
|
</div>
|
|
|
|
<a class="titre_icon ';
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune" AND ($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau'])) echo "less";
|
|
else echo "more";
|
|
echo '" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'"> </a>
|
|
</div>';
|
|
|
|
// Graphique :
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune"))
|
|
{
|
|
echo '<div class="graphique">';
|
|
echo '<div class="titre">';
|
|
for($j = 0; $j < $nb_var; $j++){
|
|
if ($_SESSION['Bateaux']['id_variable_details_bateau'] == $variables[$j]['Cle_primaire']){
|
|
$titre_graphique = $variables[$j]['Nom'].' (en '.$variables[$j]['Unite'].')'.$titre_graphique;
|
|
}
|
|
}
|
|
echo $titre_graphique;
|
|
echo '</div>';
|
|
if($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese" ){
|
|
echo '
|
|
<form class="variables" action="bateaux.php#ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'" method="post" name="formGraph">
|
|
<label for="date_debut">
|
|
<span> '.Recuperer_texte("bateau","details","graph","date_debut").'</span>
|
|
<input type="datetime-local" name="date_debut" id="date_debut">
|
|
</label>
|
|
<label for="date_fin">
|
|
<span> '.Recuperer_texte("bateau","details","graph","date_fin").' </span>
|
|
<input type="datetime-local" name="date_fin" id="date_fin">
|
|
</label>
|
|
<button type="submit" name="filtrer_graphe"> '.$_SESSION['textes']['bateau']['details']['graph']['filtrer'].Ajouter_lien_modif_buttons("bateau","details","graph","filtrer").' </button>
|
|
</form>';
|
|
}
|
|
echo '<div class="top_part_graph">';
|
|
if($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous" || $_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"){
|
|
echo '<div class="vars" style="min-width: 250px;">';
|
|
|
|
for($j = 0; $j < $nb_var; $j++){
|
|
echo '<div class="var ';
|
|
if ($_SESSION['Bateaux']['id_variable_details_bateau'] == $variables[$j]['Cle_primaire']) echo 'actif';
|
|
echo '">';
|
|
echo '<a href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&variable='.$variables[$j]['Cle_primaire'].'&type_courbe='.$_SESSION['Bateaux']['type_courbe_details_bateau'].'"> ';
|
|
echo $variables[$j]['Nom'];
|
|
echo '</a>' ;
|
|
echo '</div>';
|
|
}
|
|
echo'
|
|
</div>';
|
|
}
|
|
echo' <div class="graph" id="graphique_'.$bateau['details_bateau'][$i]['Cle_primaire'].'">
|
|
</div>';
|
|
echo '</div>
|
|
|
|
</div>';
|
|
$_SESSION['Bateaux']['graphe_date_debut'] = '';
|
|
$_SESSION['Bateaux']['graphe_date_fin'] = '';
|
|
echo '<div class="boutons_graphique">';
|
|
echo '<a title="" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&type_courbe=Synthese"';
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese")) echo '>'.$_SESSION['textes']['bateau']['details']['graph']['display_all'].Ajouter_lien_modif_buttons("bateau","details","graph","display_all").'</a>';
|
|
else echo ' >'.$_SESSION['textes']['bateau']['details']['graph']['display_daily'] .Ajouter_lien_modif_buttons("bateau","details","graph","display_daily").'</a>';
|
|
echo '</div>';
|
|
// Capacité 1 :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","batterie","cap").' 1</div>
|
|
<div class="champs_valeur">'.$bateau['details_bateau'][$i]['capacite_1'].'</div>
|
|
</div>';
|
|
|
|
// Capacité 2 :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","batterie","cap").' 2</div>
|
|
<div class="champs_valeur">'.$bateau['details_bateau'][$i]['capacite_2'].'</div>
|
|
</div>';
|
|
|
|
// Type :
|
|
echo '<div class="champs">';
|
|
//echo '<div class="champs_titre">'.Recuperer_texte("bateau","details","batterie","cap").' 2</div>
|
|
echo '<div class="champs_titre">Type de batterie</div>
|
|
<div class="champs_valeur">'.$bateau['details_bateau'][$i]['type'].'</div>
|
|
</div>';
|
|
|
|
// Seuil soc haut :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","batterie","seuil_haut").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Soc_seuil_haut'], 0, ".", " ").' %</div>
|
|
</div>';
|
|
|
|
// Seuil soc bas :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","batterie","seuil_bas").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Soc_seuil_bas'], 0, ".", " ").' %</div>
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//===========================================================
|
|
case "TB_BATEAUX_Circuits":
|
|
{
|
|
for ($i = 0; $i < $nb_entrees; $i ++)
|
|
{
|
|
echo '<div class="ancre" id="ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'"> </div>'; // L'utilisation d'une div dédiée permet de donner une "hauteur" à l'ancre et ainsi dégager de dessous le bandeau de menu...
|
|
|
|
echo '<div class="titre_composant">
|
|
<p class="titre_text">
|
|
<a class="titre_icon" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'">
|
|
'.$bateau['details_bateau'][$i]['Nom'].'
|
|
</a>
|
|
</p>
|
|
|
|
<div class="titre_desc titre_capt">
|
|
<p class="capteur_state ';
|
|
if ($bateau['details_bateau'][$i]['Etat_commande_carte'] == 1) echo 'capteur_off "> Off';
|
|
elseif ($bateau['details_bateau'][$i]['Etat_commande_carte'] == 2) echo 'A DEFINIR en fonction de la valeur de Mode_test de la carte de commande';
|
|
elseif ($bateau['details_bateau'][$i]['Consigne'] == 0) echo 'capteur_off "> Off';
|
|
else
|
|
{
|
|
echo 'capteur_on "> On';
|
|
echo '<p style="line-height: 60px; margin-left: 10px"><span class="consommation_instantanee"></span>'.number_format($bateau['details_bateau'][$i]['Intensite'], 2, ".", " ").' A</p>';
|
|
if (($bateau['details_bateau'][$i]['Consigne'] > 0) AND
|
|
($bateau['details_bateau'][$i]['Consigne'] < 100)) echo '['.$bateau['details_bateau'][$i]['Consigne'].' %]';
|
|
}
|
|
echo '<p>
|
|
|
|
|
|
</div>
|
|
|
|
<a class="titre_icon ';
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune" AND ($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau'])) echo "less";
|
|
else echo "more";
|
|
echo '" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'"> </a>
|
|
</div>';
|
|
|
|
|
|
// Graphique :
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune"))
|
|
{
|
|
echo '<div class="graphique">';
|
|
echo '<div class="titre">';
|
|
for($j = 0; $j < $nb_var; $j++){
|
|
if ($_SESSION['Bateaux']['id_variable_details_bateau'] == $variables[$j]['Cle_primaire']){
|
|
$titre_graphique = $variables[$j]['Nom'].' (en '.$variables[$j]['Unite'].')'.$titre_graphique;
|
|
}
|
|
}
|
|
echo $titre_graphique;
|
|
echo '</div>';
|
|
if($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese" ){
|
|
echo '
|
|
<form class="variables" action="bateaux.php#ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'" method="post" name="formGraph">
|
|
<label for="date_debut">
|
|
<span>'.Recuperer_texte("bateau","details","graph","date_debut").'</span>
|
|
<input type="datetime-local" name="date_debut" id="date_debut">
|
|
</label>
|
|
<label for="date_fin">
|
|
<span> '.Recuperer_texte("bateau","details","graph","date_fin").' </span>
|
|
<input type="datetime-local" name="date_fin" id="date_fin">
|
|
</label>
|
|
<button type="submit" name="filtrer_graphe">'.$_SESSION['textes']['bateau']['details']['graph']['filtrer'].Ajouter_lien_modif_buttons("bateau","details","graph","filtrer").'</button>
|
|
</form>';
|
|
}
|
|
echo '<div class="top_part_graph">';
|
|
if($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous" || $_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"){
|
|
echo '<div class="vars" style="min-width: 250px;">';
|
|
|
|
for($j = 0; $j < $nb_var; $j++){
|
|
echo '<div class="var ';
|
|
if ($_SESSION['Bateaux']['id_variable_details_bateau'] == $variables[$j]['Cle_primaire']) echo 'actif';
|
|
echo '">';
|
|
echo '<a href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&variable='.$variables[$j]['Cle_primaire'].'&type_courbe='.$_SESSION['Bateaux']['type_courbe_details_bateau'].'"> ';
|
|
echo $variables[$j]['Nom'];
|
|
echo '</a>' ;
|
|
echo '</div>';
|
|
}
|
|
echo'
|
|
</div>';
|
|
}
|
|
echo' <div class="graph" id="graphique_'.$bateau['details_bateau'][$i]['Cle_primaire'].'">
|
|
</div>';
|
|
echo '</div>
|
|
|
|
</div>';
|
|
$_SESSION['Bateaux']['graphe_date_debut'] = '';
|
|
$_SESSION['Bateaux']['graphe_date_fin'] = '';
|
|
echo '<div class="boutons_graphique">';
|
|
echo '<a title="" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&type_courbe=Synthese"';
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese")) echo '>'.$_SESSION['textes']['bateau']['details']['graph']['display_all'].Ajouter_lien_modif_buttons("bateau","details","graph","display_all").'</a>';
|
|
else echo ' >'.$_SESSION['textes']['bateau']['details']['graph']['display_daily'] .Ajouter_lien_modif_buttons("bateau","details","graph","display_daily").'</a>';
|
|
echo '</div>';
|
|
|
|
// Etat :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","circuits","etat").'</div>
|
|
<div class="champs_valeur">';
|
|
if ($bateau['details_bateau'][$i]['Etat_commande_carte'] == 1) { echo Recuperer_texte("bateau","details","circuits","tension_faible"); }
|
|
elseif ($bateau['details_bateau'][$i]['Etat_commande_carte'] == 2) { echo Recuperer_texte("bateau","details","circuits","cmd_man"); }
|
|
else
|
|
{
|
|
switch($bateau['details_bateau'][$i]['Etat'])
|
|
{
|
|
case 1 : { echo Recuperer_texte("bateau","details","circuits","limitation"); break; }
|
|
case 2 : { echo Recuperer_texte("bateau","details","circuits","protection"); break; }
|
|
case 3 : { echo Recuperer_texte("bateau","details","circuits","disjonction"); break; }
|
|
case 4 : { echo Recuperer_texte("bateau","details","circuits","court_circuit_batterie"); break; }
|
|
case 5 : { echo Recuperer_texte("bateau","details","circuits","delestage"); break; }
|
|
default: { echo Recuperer_texte("bateau","details","circuits","ok"); break; }
|
|
}
|
|
}
|
|
echo '</div>
|
|
</div>';
|
|
|
|
// Consigne :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","circuits","etat").'</div>
|
|
<div class="champs_valeur">';
|
|
if ($bateau['details_bateau'][$i]['Etat_commande_carte'] == 1) echo 'Off';
|
|
elseif ($bateau['details_bateau'][$i]['Etat_commande_carte'] == 2) echo 'A DEFINIR en fonction de la valeur de Mode_test de la carte de commande';
|
|
elseif ($bateau['details_bateau'][$i]['Consigne'] == 0) echo 'Off';
|
|
else
|
|
{
|
|
echo 'On';
|
|
if (($bateau['details_bateau'][$i]['Consigne'] > 0) AND
|
|
($bateau['details_bateau'][$i]['Consigne'] < 100)) echo '['.$bateau['details_bateau'][$i]['Consigne'].' %]';
|
|
}
|
|
echo '</div>
|
|
</div>';
|
|
|
|
// Seuil de disjonction :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","circuits","seuil_disjonction").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Intensite_seuil_haut'], 0, ".", " ").' A</div>
|
|
</div>';
|
|
|
|
// Temporisation de disjonction :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","circuits","temp_disjonction").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Intensite_seuil_haut_tempo']/1000, 1, ".", " ").' '.Recuperer_texte("bateau","details","circuits","sec").'</div>
|
|
</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//===========================================================
|
|
case "TB_BATEAUX_Reservoirs":
|
|
{
|
|
for ($i = 0; $i < $nb_entrees; $i ++)
|
|
{
|
|
echo '<div class="ancre" id="ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'"> </div>'; // L'utilisation d'une div dédiée permet de donner une "hauteur" à l'ancre et ainsi dégager de dessous le bandeau de menu...
|
|
|
|
echo '<div class="titre_composant">
|
|
<p class="titre_text">
|
|
<a class="titre_icon" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'">
|
|
'.$bateau['details_bateau'][$i]['Nom'].'
|
|
</a>
|
|
</p>
|
|
|
|
<div class="titre_desc">
|
|
<p>'.Recuperer_texte("bateau","details","reservoirs","niveau").' :
|
|
<span class="';
|
|
if($bateau['details_bateau'][$i]['Niveau'] < $bateau['details_bateau'][$i]['Niveau_seuil_bas']) echo " red";
|
|
else if($bateau['details_bateau'][$i]['Niveau'] > $bateau['details_bateau'][$i]['Niveau_seuil_haut']) echo " green";
|
|
else echo " orange";
|
|
echo '">'.number_format(($bateau['details_bateau'][$i]['Capacite'] * $bateau['details_bateau'][$i]['Niveau'])/100, 0, ".", " ").' '.Recuperer_texte("bateau","details","reservoirs","litres").'
|
|
soit '.number_format($bateau['details_bateau'][$i]['Niveau'], 1, ".", " ").' %
|
|
|
|
</p>
|
|
<p>'.Recuperer_texte("bateau","details","reservoirs","capacite_totale").' : '.$bateau['details_bateau'][$i]['Capacite'].' litres
|
|
</p>
|
|
</div>
|
|
|
|
<a class="titre_icon ';
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune" AND ($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau'])) echo "less";
|
|
else echo "more";
|
|
echo '" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'"> </a>
|
|
</div>';
|
|
|
|
// Graphique :
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune"))
|
|
{
|
|
echo '<div class="graphique">';
|
|
echo '<div class="titre">';
|
|
for($j = 0; $j < $nb_var; $j++){
|
|
if ($_SESSION['Bateaux']['id_variable_details_bateau'] == $variables[$j]['Cle_primaire']){
|
|
$titre_graphique = $variables[$j]['Nom'].' (en '.$variables[$j]['Unite'].')'.$titre_graphique;
|
|
}
|
|
}
|
|
echo $titre_graphique;
|
|
echo '</div>';
|
|
if($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese" ){
|
|
echo '
|
|
<form class="variables" action="bateaux.php#ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'" method="post" name="formGraph">
|
|
<label for="date_debut">
|
|
<span>'.Recuperer_texte("bateau","details","graph","date_debut").'</span>
|
|
<input type="datetime-local" name="date_debut" id="date_debut">
|
|
</label>
|
|
<label for="date_fin">
|
|
<span> '.Recuperer_texte("bateau","details","graph","date_fin").' </span>
|
|
<input type="datetime-local" name="date_fin" id="date_fin">
|
|
</label>
|
|
<button type="submit" name="filtrer_graphe">'.$_SESSION['textes']['bateau']['details']['graph']['filtrer'].Ajouter_lien_modif_buttons("bateau","details","graph","filtrer").'</button>
|
|
</form>';
|
|
}
|
|
echo '<div class="top_part_graph">';
|
|
if($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous" || $_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"){
|
|
echo '<div class="vars" style="min-width: 250px; display: none;">';
|
|
|
|
for($j = 0; $j < $nb_var; $j++){
|
|
echo '<div class="var ';
|
|
if ($_SESSION['Bateaux']['id_variable_details_bateau'] == $variables[$j]['Cle_primaire']) echo 'actif';
|
|
echo '">';
|
|
echo '<a href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&variable='.$variables[$j]['Cle_primaire'].'&type_courbe='.$_SESSION['Bateaux']['type_courbe_details_bateau'].'"> ';
|
|
echo $variables[$j]['Nom'];
|
|
echo '</a>' ;
|
|
echo '</div>';
|
|
}
|
|
echo'
|
|
</div>';
|
|
}
|
|
echo' <div class="graph" id="graphique_'.$bateau['details_bateau'][$i]['Cle_primaire'].'">
|
|
</div>';
|
|
echo '</div>
|
|
|
|
</div>';
|
|
$_SESSION['Bateaux']['graphe_date_debut'] = '';
|
|
$_SESSION['Bateaux']['graphe_date_fin'] = '';
|
|
echo '<div class="boutons_graphique">';
|
|
echo '<a title="" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&type_courbe=Synthese"';
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese")) echo '>'.$_SESSION['textes']['bateau']['details']['graph']['display_all'].Ajouter_lien_modif_buttons("bateau","details","graph","display_all").'</a>';
|
|
else echo ' >'.$_SESSION['textes']['bateau']['details']['graph']['display_daily'] .Ajouter_lien_modif_buttons("bateau","details","graph","display_daily").'</a>';
|
|
echo '</div>';
|
|
|
|
// // Seuil niveau haut :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","reservoirs","seuil_haut").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Niveau_seuil_haut'], 0, ".", " ").' %</div>
|
|
</div>';
|
|
|
|
// Seuil niveau bas :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","reservoirs","seuil_bas").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Niveau_seuil_bas'], 0, ".", " ").' %</div>
|
|
</div>';
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//===========================================================
|
|
case "TB_BATEAUX_Capteurs":
|
|
{
|
|
for ($i = 0; $i < $nb_entrees; $i ++)
|
|
{
|
|
echo '<div class="ancre" id="ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'"> </div>'; // L'utilisation d'une div dédiée permet de donner une "hauteur" à l'ancre et ainsi dégager de dessous le bandeau de menu...
|
|
|
|
echo '<div class="titre_composant">
|
|
<p class="titre_text">
|
|
<a class="titre_icon" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&capteur='.$bateau['details_bateau'][$i]['ID_Variable'].'">
|
|
'.$bateau['details_bateau'][$i]['Nom'].'
|
|
</a>
|
|
</p>
|
|
|
|
<div class="titre_desc">
|
|
<p>'.Recuperer_texte("bateau","details","capteurs","valeur").' :
|
|
<span class="';
|
|
if($bateau['details_bateau'][$i]['Valeur'] > $bateau['details_bateau'][$i]['Valeur_seuil_haut']) echo " green";
|
|
else if($bateau['details_bateau'][$i]['Valeur'] < $bateau['details_bateau'][$i]['Valeur_seuil_bas']) echo " red";
|
|
else echo " orange";
|
|
echo '">'.number_format($bateau['details_bateau'][$i]['Valeur'], $bateau['details_bateau'][$i]['Precision_affichage_accueil'], ".", " ").' '.$bateau['details_bateau'][$i]['Unite'].'</span>
|
|
</p>
|
|
</div>
|
|
|
|
<a class="titre_icon ';
|
|
if ($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune" AND ($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau'])) echo "less";
|
|
else echo "more";
|
|
echo '" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=div_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&capteur='.$bateau['details_bateau'][$i]['ID_Variable'].'"> </a>
|
|
</div>';
|
|
|
|
|
|
|
|
// Graphique :
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] != "Aucune"))
|
|
{
|
|
echo '<div class="graphique">';
|
|
echo '<div class="titre">';
|
|
echo $titre_graphique;
|
|
echo '</div>';
|
|
|
|
if($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese"){
|
|
echo '<form class="variables" action="bateaux.php#ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'" method="post" name="formGraph">
|
|
<label for="date_debut">
|
|
<span>'.Recuperer_texte("bateau","details","graph","date_debut").'</span>
|
|
<input type="datetime-local" name="date_debut" id="date_debut">
|
|
</label>
|
|
<label for="date_fin">
|
|
<span> '.Recuperer_texte("bateau","details","graph","date_fin").' </span>
|
|
<input type="datetime-local" name="date_fin" id="date_fin">
|
|
</label>
|
|
<button type="submit" name="filtrer_graphe">'.$_SESSION['textes']['bateau']['details']['graph']['filtrer'].Ajouter_lien_modif_buttons("bateau","details","graph","filtrer").'</button>
|
|
|
|
</form>';
|
|
}
|
|
echo '<div class="top_part_graph">';
|
|
echo'<div class="graph" id="graphique_'.$bateau['details_bateau'][$i]['Cle_primaire'].'">
|
|
</div>';
|
|
echo '</div>
|
|
|
|
</div>';
|
|
$_SESSION['Bateaux']['graphe_date_debut'] = '';
|
|
$_SESSION['Bateaux']['graphe_date_fin'] = '';
|
|
echo '<div class="boutons_graphique">';
|
|
echo '<a title="" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&type_courbe=Synthese"';
|
|
if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese")) echo '>'.$_SESSION['textes']['bateau']['details']['graph']['display_all'].Ajouter_lien_modif_buttons("bateau","details","graph","display_all").'</a>';
|
|
else echo ' >'.$_SESSION['textes']['bateau']['details']['graph']['display_daily'] .Ajouter_lien_modif_buttons("bateau","details","graph","display_daily").'</a>';
|
|
echo '</div>';
|
|
|
|
// Valeur seuil haut :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","capteurs","valeur_seuil_haut").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Valeur_seuil_haut'], $bateau['details_bateau'][$i]['Precision_affichage_accueil'], ".", " ").' '.$bateau['details_bateau'][$i]['Unite'].'</div>
|
|
</div>';
|
|
|
|
// Valeur seuil bas :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bienvenue","details","capteurs","valeur_seuil_bas").'</div>
|
|
<div class="champs_valeur">'.number_format($bateau['details_bateau'][$i]['Valeur_seuil_bas'], $bateau['details_bateau'][$i]['Precision_affichage_accueil'], ".", " ").' '.$bateau['details_bateau'][$i]['Unite'].'</div>
|
|
</div>';
|
|
|
|
// Etat :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","capteurs","etat").'</div>
|
|
<div class="champs_valeur">';
|
|
if ($bateau['details_bateau'][$i]['Etat'] == 0) { echo Recuperer_texte("bateau","details","capteurs","ok"); }
|
|
elseif ($bateau['details_bateau'][$i]['Etat'] == 1) { echo Recuperer_texte("bateau","details","capteurs","alerte"); }
|
|
elseif ($bateau['details_bateau'][$i]['Etat'] == 2) { echo Recuperer_texte("bateau","details","capteurs","alarme"); }
|
|
|
|
echo '</div>
|
|
</div>';
|
|
}
|
|
|
|
|
|
|
|
// // Boutons graphique :
|
|
// echo '<div class="boutons_graphique">';
|
|
// echo '<a title="" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&variable=0&capteur='.$bateau['details_bateau'][$i]['ID_Variable'].'&type_courbe=Synthese"';
|
|
// if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
// ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Synthese")) echo ' class="actif">'.$_SESSION['textes']['bateau']['details']['graph']['hide'].'</a>';
|
|
// else echo ' >'.$_SESSION['textes']['bateau']['details']['graph']['display_daily'] .Ajouter_lien_modif_buttons("bateau","details","graph","display_daily").'</a>';
|
|
// echo '<a title="" href="bateaux.php?ancre=ancre_'.$bateau['details_bateau'][$i]['Cle_primaire'].'&action=courbe_details_bateau&id_entree='.$bateau['details_bateau'][$i]['Cle_primaire'].'&variable=0&capteur='.$bateau['details_bateau'][$i]['ID_Variable'].'&type_courbe=Tous"';
|
|
// if (($bateau['details_bateau'][$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) AND
|
|
// ($_SESSION['Bateaux']['type_courbe_details_bateau'] == "Tous")) echo ' class="actif">'.$_SESSION['textes']['bateau']['details']['graph']['hide'].'</a>';
|
|
// else echo ' >'.$_SESSION['textes']['bateau']['details']['graph']['display_all'] .'</a>';
|
|
// echo '</div>';
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//===========================================================
|
|
case "TB_BATEAUX_Systeme":
|
|
{
|
|
// Informations provenant de TB_Systeme :
|
|
// Version :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","parsys","ver").'</div>
|
|
<div class="champs_valeur">'.$bateau['version'].'</div>
|
|
</div>';
|
|
|
|
// Version modem :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","parsys","verm").'</div>
|
|
<div class="champs_valeur">'.$bateau['details_bateau']['Version_soft_modem']['Valeur'].'</div>
|
|
</div>';
|
|
|
|
// N° d'ICCID :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","parsys","iccid").'</div>
|
|
<div class="champs_valeur">'.$bateau['details_bateau']['No_iccid']['Valeur'].'</div>
|
|
</div>';
|
|
|
|
// N° d'IMEI :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","parsys","imei").'</div>
|
|
<div class="champs_valeur">'.$bateau['details_bateau']['No_imei']['Valeur'].'</div>
|
|
</div>';
|
|
|
|
// N° d'IMSI :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","parsys","imsi").'</div>
|
|
<div class="champs_valeur">'.$bateau['details_bateau']['No_imsi']['Valeur'].'</div>
|
|
</div>';
|
|
|
|
// Informations sur les cartes présentes à bord (TB_Cartes) :
|
|
for ($i = 0; $i < $nb_cartes; $i ++)
|
|
{
|
|
|
|
echo '<div class="ancre" id="ancre_'.$cartes[$i]['Cle_primaire'].'"> </div>'; // L'utilisation d'une div dédiée permet de donner une "hauteur" à l'ancre et ainsi dégager de dessous le bandeau de menu...
|
|
|
|
echo '<div class="titre_composant">
|
|
<p class="titre_text">';
|
|
echo '<a class="titre_icon" href="bateaux.php?ancre=ancre_'.$cartes[$i]['Cle_primaire'].'&action=div_details_bateau&id_carte='.$cartes[$i]['Cle_primaire'].'">';
|
|
if (($cartes[$i]['Adresse_k_bus']) != 0 ) echo $cartes[$i]['Adresse_k_bus']." - ";
|
|
echo $cartes[$i]['nom_type'];
|
|
echo '</a>';
|
|
echo '</p>
|
|
|
|
<div class="titre_desc">
|
|
<p>'.Recuperer_texte("bateau","details","parsys","mac").' : '.$cartes[$i]['Adresse_mac'].'</p>
|
|
<p>'.Recuperer_texte("bateau","details","parsys","ver_logicielle").' : '.$cartes[$i]['Software_version'].'</p>';
|
|
echo '</div>
|
|
|
|
<a class="titre_icon ';
|
|
if ($cartes[$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']) echo "less";
|
|
else echo "more";
|
|
echo '" href="bateaux.php?ancre=ancre_'.$cartes[$i]['Cle_primaire'].'&action=div_details_bateau&id_carte='.$cartes[$i]['Cle_primaire'].'"> </a>
|
|
</div>';
|
|
|
|
if ($cartes[$i]['Cle_primaire'] == $_SESSION['Bateaux']['id_entree_details_bateau']){
|
|
echo '<div class="carte">';
|
|
// Résistance de terminaison :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","parsys","resistance").'</div>
|
|
<div class="champs_valeur">'.$cartes[$i]['libelle_resistance_terminaison'].'</div>
|
|
</div>';
|
|
|
|
// Version matérielle :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">'.Recuperer_texte("bateau","details","parsys","ver_materielle").'</div>
|
|
<div class="champs_valeur">'.$cartes[$i]['Hardware_version'].'</div>
|
|
</div>';
|
|
|
|
// Données spécifiques en fonction du type de carte :
|
|
echo '<br />';
|
|
switch($cartes[$i]['Type'])
|
|
{
|
|
//---------------------------
|
|
case TYPE_CARTE_SP812:
|
|
case TYPE_CARTE_SP8DC:
|
|
{
|
|
// Circuits affectés à ce module :
|
|
for ($j = 0; $j < 8; $j++)
|
|
{
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">Circuit n° '.($j + 1).'</div>
|
|
<div class="champs_valeur">'.$cartes[$i]['circuits'][$j]['Nom'].'</div>
|
|
</div>';
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
//---------------------------
|
|
case TYPE_CARTE_SP4AC:
|
|
{
|
|
// Circuits affectés à ce module :
|
|
for ($j = 0; $j < 4; $j++)
|
|
{
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">Circuit n° '.($j + 1).'</div>
|
|
<div class="champs_valeur">'.$cartes[$i]['circuits'][$j]['Nom'].'</div>
|
|
</div>';
|
|
}
|
|
break;
|
|
}
|
|
|
|
//---------------------------
|
|
case TYPE_CARTE_COMPAGNON:
|
|
case TYPE_CARTE_SBS1224:
|
|
default : break;
|
|
}
|
|
echo '</div>';
|
|
}
|
|
}
|
|
|
|
/* // Version complète de tous les champs de TB_Systeme :
|
|
foreach($bateau['details_bateau'] as $key => $value)
|
|
{
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">
|
|
'.$key.'
|
|
</div>
|
|
<div class="champs_valeur">
|
|
'.$value['Valeur'].'
|
|
</div>';
|
|
if (isset($value['Description']))
|
|
{
|
|
echo '<div class="champs_description">
|
|
'.$value['Description'].'
|
|
</div>';
|
|
}
|
|
echo '</div>';
|
|
}
|
|
*/
|
|
break;
|
|
}
|
|
|
|
|
|
//===========================================================
|
|
case "gerer_les_acces":
|
|
{
|
|
echo '<div class="gestion_acces">';
|
|
echo ' <div class="generer_code">
|
|
<form action="bateaux.php" method="POST">';
|
|
echo ' <select name="type_acces" id="type_acces" required>
|
|
<option value="" disabled selected> -- '.$_SESSION['textes']['bateau']['details']['acces']['select'] .' -- </option>' ;
|
|
for ($i = 0; $i < $type_acces_nb; $i++){
|
|
echo '<option value="'.$type_acces[$i]['Cle_primaire'].'"> '.$type_acces[$i]['Nom'].' </option>';
|
|
}
|
|
echo ' </select>';
|
|
echo ' <input type="date" name="date_validite" id="date_validite"> ';
|
|
echo ' <button type="submit" name="generer_code_acces"> '.$_SESSION['textes']['bateau']['details']['acces']['generer'] .' </button>';
|
|
echo ' </form>
|
|
</div>';
|
|
echo ' <div class="users"> ';
|
|
echo ' <table>';
|
|
echo ' <tr>';
|
|
echo ' <th> '.Recuperer_texte("bateau","details","acces","validite").' </th>';
|
|
echo ' <th> '.Recuperer_texte("bateau","details","acces","shipmember").'</th>';
|
|
echo ' <th> '.Recuperer_texte("bateau","details","acces","cree_par").'</th>';
|
|
echo ' <th> '.Recuperer_texte("bateau","details","acces","type_profil").'</th>';
|
|
echo ' <th> '.Recuperer_texte("bateau","details","acces","fin_validite").' </th>';
|
|
echo ' <th> </th>';
|
|
echo ' </tr>';
|
|
if ($utilisateur_acces_nb == 0) echo '<tr> <td colspan="5"> 0 shipmember / acces </td> </tr>';
|
|
else {
|
|
for($i = 0; $i < $utilisateur_acces_nb; $i++){
|
|
|
|
echo ' <form action="bateaux.php" method="POST">';
|
|
echo ' <tr>';
|
|
echo ' <td > <input name="validite_acces" onChange="this.form.submit()" type="checkbox" ';
|
|
if (isset($acces_profil['Devalidation_profils']) && $acces_profil['Devalidation_profils'] == 0) echo ' disabled ';
|
|
if (isset($acces_profil['Devalidation_profils']) && $acces_profil['Devalidation_profils'] == 1 && $utilisateur_acces[$i]['ID_Type_acces_bateau_shipmember'] == 2) echo ' disabled ';
|
|
if ($utilisateur_acces[$i]['Validite_acces'] == 1) echo 'checked';
|
|
echo '> </td>';
|
|
echo ' <td> '.$utilisateur_acces[$i]['sm_Prenom'].' '.$utilisateur_acces[$i]['sm_Nom'].' ['.$utilisateur_acces[$i]['sm_Email'].']</td>';
|
|
echo ' <td> '.$utilisateur_acces[$i]['cree_par_Prenom'].' '.$utilisateur_acces[$i]['cree_par_Nom'].'</td>';
|
|
echo ' <td name="niveau_acces" value="'.$utilisateur_acces[$i]['ID_Type_acces_bateau_shipmember'].'">'.$utilisateur_acces[$i]['Niveau_acces_nom'].'</td>';
|
|
echo ' <td name="fin_validite" value="'.$utilisateur_acces[$i]['Fin_validite'].'"> ';
|
|
echo (substr($utilisateur_acces[$i]['Fin_validite'],0,-9) == "9999-12-31") ? Recuperer_texte("bateau","details","acces","aucune_fin") : substr($utilisateur_acces[$i]['Fin_validite'],0,-9) ;
|
|
echo ' </td>';
|
|
echo ' <input hidden name="ID" value="'.$utilisateur_acces[$i]['ID'].'">';
|
|
if ($acces_profil['Modification_acces'] == 1){
|
|
echo ' <td id="modifier_acces" onclick="popUpEditAccess(' . htmlspecialchars(json_encode($utilisateur_acces[$i]), ENT_QUOTES, 'UTF-8') . ')"></td>';
|
|
}
|
|
echo ' </tr>';
|
|
echo ' </form>';
|
|
}
|
|
|
|
|
|
}
|
|
echo ' </table>';
|
|
echo ' </div>';
|
|
|
|
echo '</div>';
|
|
|
|
echo '<div id="popUpAcces" style="display: none;">';
|
|
echo ' <div id="popUpAccesModal">';
|
|
echo ' <div id="top_part">';
|
|
echo ' <p> '.Recuperer_texte("bateau","edit_acces","popup","title").' </p>';
|
|
echo ' <p id="close" onclick="closeEditAccess();"> </p>';
|
|
echo ' </div>';
|
|
echo ' <form action="bateaux.php" method="POST">';
|
|
echo ' <label for="shipmemberForm" id="ShipMember"> ';
|
|
echo ' <input id="shipmemberForm" type="text" value="" name="shipmember" readonly>';
|
|
echo ' <span>'.Recuperer_texte("bateau","details","acces","shipmember").'</span>';
|
|
echo ' </label>';
|
|
echo ' <label for="cree_parForm" id="Cree_par"> ';
|
|
echo ' <input id="cree_parForm" type="text" value="" name="cree_par" readonly>';
|
|
echo ' <span>'.Recuperer_texte("bateau","details","acces","cree_par").'</span>';
|
|
echo ' </label>';
|
|
echo ' <label for="type_profilForm" id="Type_profil"> ';
|
|
echo ' <select name="type_profil" id="type_profilForm" required>
|
|
<option value="" disabled selected> -- '.$_SESSION['textes']['bateau']['details']['acces']['select'] .' -- </option>' ;
|
|
for ($i = 0; $i < $type_acces_nb; $i++){
|
|
echo '<option value="'.$type_acces[$i]['Cle_primaire'].'"> '.$type_acces[$i]['Nom'].' </option>';
|
|
}
|
|
echo ' </select>';
|
|
echo ' <span>'.Recuperer_texte("bateau","details","acces","type_profil").'</span>';
|
|
echo ' </label>';
|
|
echo ' <label for="fin_validiteForm" id="Fin_validite"> ';
|
|
echo ' <input id="fin_validiteForm" type="date" value="" name="fin_validite" required>';
|
|
echo ' <span>'.Recuperer_texte("bateau","details","acces","fin_validite").'</span>';
|
|
echo ' </label>';
|
|
echo ' <input hidden id="idForm" name="ID" value="">';
|
|
echo ' <button type="submit" name="supprimerAcces" onclick="return window.confirm(\''.$_SESSION["textes"]["bateau"]["edit_acces"]["popup"]["delete_confirm"].'\');"> '.Recuperer_texte("bateau","edit_acces","popup","delete").' </button>';
|
|
echo ' <button type="submit" name="modifierAcces"> '.Recuperer_texte("bateau","edit_acces","popup","update").' </button>';
|
|
echo ' </form>';
|
|
echo ' </div>';
|
|
echo '</div>';
|
|
|
|
break;
|
|
}
|
|
|
|
//===========================================================
|
|
default:
|
|
{
|
|
echo '<p>'.Recuperer_texte("bateau","details","autres","autre").'</p>';
|
|
break;
|
|
}
|
|
}
|
|
echo '</div>'; // Fin de class="corps_details_bateau"
|
|
|
|
|
|
|
|
//--------------------------------
|
|
echo '<div class="boutons_bas_de_page">';
|
|
if ($_SESSION['Bateaux']['origine'] == "shipmember") echo '<a title="" href="shipmembers.php?action=navigation&destination=Accueil">Retour au menu ShipMember</a>';
|
|
else
|
|
{
|
|
echo '<a title="" href="administration.php?action=navigation&destination=Accueil">Retour au menu Administration</a>';
|
|
echo '<a title="" href="bateaux.php?action=navigation&destination=Accueil">Revenir à la liste des bateaux</a>';
|
|
echo '<a href="bateaux.php?action=modification_bateau&id_bateau='.$bateau['Cle_primaire'].'">Modifier</a>';
|
|
}
|
|
echo '</div>';
|
|
|
|
|
|
//-------------------------------
|
|
// Help
|
|
echo '<div class="help_note" id="help_note" style="display:none;">';
|
|
echo '<p>';
|
|
switch($_SESSION['Bateaux']['type_details_bateau'])
|
|
{
|
|
case 'TB_BATEAUX_Carte':
|
|
{
|
|
echo Recuperer_texte("bateau","details","help_note","carte").Ajouter_lien_modif("bateau","details","help_note","carte");
|
|
break;
|
|
}
|
|
case 'TB_BATEAUX_Batteries':
|
|
{
|
|
echo Recuperer_texte("bateau","details","help_note","batteries").Ajouter_lien_modif("bateau","details","help_note","batteries");
|
|
break;
|
|
}
|
|
case 'TB_BATEAUX_Circuits':
|
|
{
|
|
echo Recuperer_texte("bateau","details","help_note","circuits").Ajouter_lien_modif("bateau","details","help_note","circuits");
|
|
break;
|
|
}
|
|
case 'TB_BATEAUX_Reservoirs':
|
|
{
|
|
echo Recuperer_texte("bateau","details","help_note","reservoirs").Ajouter_lien_modif("bateau","details","help_note","reservoirs");
|
|
break;
|
|
}
|
|
case 'TB_BATEAUX_Capteurs':
|
|
{
|
|
echo Recuperer_texte("bateau","details","help_note","capteurs").Ajouter_lien_modif("bateau","details","help_note","capteurs");
|
|
break;
|
|
}
|
|
case 'TB_BATEAUX_Systeme':
|
|
{
|
|
echo Recuperer_texte("bateau","details","help_note","systeme").Ajouter_lien_modif("bateau","details","help_note","systeme");
|
|
break;
|
|
}
|
|
case 'gerer_les_acces':
|
|
{
|
|
echo Recuperer_texte("bateau","details","help_note","acces").Ajouter_lien_modif("bateau","details","help_note","acces");
|
|
break;
|
|
}
|
|
|
|
}
|
|
echo '</p>';
|
|
echo '</div>';
|
|
echo '<div class="help help_open" id="help" onclick="toggle_help();">';
|
|
echo '</div>';
|
|
|
|
|
|
echo '</div>';
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
//************************************************************************************************************************
|
|
case "Creation_bateau":
|
|
case "Modification_bateau":
|
|
{
|
|
echo '<div id="creation_bateau" class="page_principale">';
|
|
|
|
echo '<h1>Bateaux</h1>';
|
|
|
|
echo '<form action="bateaux.php" method="post">';
|
|
|
|
|
|
|
|
if ($_SESSION['Bateaux']['page'] == "Creation_bateau") echo '<h2>Nouveau bateau</h2>';
|
|
else echo '<h2>Modification du bateau <span class="gras">'.$_SESSION['Bateaux']['bateau']['Nom'].'</span></h2>';
|
|
|
|
//----------------------------------------
|
|
// Nom :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">
|
|
Nom
|
|
</div>
|
|
<div class="champs_valeur">
|
|
<input name="Nom" placeholder="Par exemple : Et Si... 2" value="'.$_SESSION['Bateaux']['bateau']['Nom'].'" >
|
|
</div>
|
|
</div>';
|
|
|
|
//----------------------------------------
|
|
// Date de mise en service :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">
|
|
Date de mise en service
|
|
</div>
|
|
<div class="champs_valeur">
|
|
<input name="Date_mes" placeholder="Format Y-m-d" value="'.$_SESSION['Bateaux']['bateau']['Date_mes'].'" >
|
|
</div>
|
|
</div>';
|
|
|
|
//----------------------------------------
|
|
// Flotte :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">
|
|
Flotte à laquelle le bateau appartient
|
|
</div>
|
|
<div class="champs_valeur">
|
|
<select name="ID_Flotte">';
|
|
for ($i=0; $i<$nb_flottes; $i++)
|
|
{
|
|
echo ' <option value="'.$flottes[$i]['Cle_primaire'].'" '; if ($flottes[$i]['Cle_primaire'] == $_SESSION['Bateaux']['bateau']['ID_Flotte']) echo 'selected'; echo '>
|
|
'.$flottes[$i]['Nom'].'
|
|
</option>';
|
|
}
|
|
|
|
echo '</select>
|
|
</div>
|
|
</div>';
|
|
|
|
//----------------------------------------
|
|
// Carte :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">
|
|
Carte ShipBase installée à bord
|
|
</div>
|
|
<div class="champs_valeur">
|
|
<select name="ID_Carte">';
|
|
for ($i=0; $i<$nb_cartes; $i++)
|
|
{
|
|
echo ' <option value="'.$cartes[$i]['Cle_primaire'].'" ';
|
|
if ($cartes[$i]['Cle_primaire'] == $_SESSION['Bateaux']['bateau']['ID_Carte']) echo 'selected class="selection_actuelle" ';
|
|
if ($cartes[$i]['Affectee']) echo ' disabled ';
|
|
echo '>
|
|
'.$cartes[$i]['No_serie'].'';
|
|
if (strlen($cartes[$i]['Adresse_mac']) == 17) echo '['.$cartes[$i]['Adresse_mac'].']';
|
|
echo '</option>';
|
|
}
|
|
echo '</select>
|
|
</div>
|
|
</div>';
|
|
|
|
//----------------------------------------
|
|
// Date d'installation de la carte ShipBase à bord :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">
|
|
Date d\'installation de la carte ShipBase à bord
|
|
</div>
|
|
<div class="champs_valeur">
|
|
<input name="Date_carte" placeholder="Format Y-m-d" value="'.$_SESSION['Bateaux']['bateau']['Date_carte'].'" >
|
|
</div>
|
|
</div>';
|
|
|
|
//----------------------------------------
|
|
// Commentaires :
|
|
echo '<div class="champs">
|
|
<div class="champs_titre">
|
|
Commentaires
|
|
</div>
|
|
<div class="champs_valeur">
|
|
<textarea cols="" rows="" name="Commentaires" placeholder="Vos commentaires sur la bateau" autocomplete="off">'.$_SESSION['Bateaux']['bateau']['Commentaires'].'</textarea>
|
|
</div>
|
|
</div>';
|
|
|
|
//----------------------------------------
|
|
// Boutons de bas de page :
|
|
echo '<div class="boutons_bas_de_page">';
|
|
if ($_SESSION['Bateaux']['page'] == "Creation_bateau") // Création :
|
|
{
|
|
echo '<a title="" href="bateaux.php?action=navigation&destination=Accueil">Annuler</a>';
|
|
echo '<button type="submit" name="validation_creation_bateau" title="Valider la création de la bateau">Créer la bateau</button>';
|
|
}
|
|
else // Modification :
|
|
{
|
|
echo '<a title="" href="bateaux.php?action=navigation&destination=Accueil">Annuler</a>';
|
|
echo '<button type="submit" name="validation_modification_bateau" title="Valider les modification de la bateau">Enregistrer les modifications</button>';
|
|
echo '<a title="" href="bateaux.php?action=demande_suppression_bateau&id_bateau='.$_SESSION['Bateaux']['bateau']['Cle_primaire'].'">Supprimer la bateau</a>';
|
|
}
|
|
echo '</div>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</div>';
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
//****************************************************************************************************************************
|
|
case "Confirmation_suppression_bateau":
|
|
{
|
|
echo '<div id="confirmation_suppression_bateau" class="page_principale">';
|
|
|
|
echo '<h1>Bateaux</h1>';
|
|
|
|
echo '<div class="message_confirmation">';
|
|
|
|
echo '<p>
|
|
Confirmez-vous la suppression du bateau
|
|
<span class="gras">';
|
|
echo $_SESSION['Bateaux']['bateau']['Nom'];
|
|
echo '</span> ?
|
|
</p>';
|
|
echo '<p>Si oui, son entrée dans la base de données sera dévalidée de la base de données.</p>';
|
|
|
|
echo '</div>';
|
|
|
|
echo '<div class="boutons_bas_de_page">';
|
|
echo '<a title="" href="bateaux.php?action=navigation&destination=Accueil">Annuler</a>';
|
|
echo '<a title="" href="bateaux.php?action=confirmation_suppression_bateau&id_bateau='.$_SESSION['Bateaux']['bateau']['Cle_primaire'].'">Confirmer la suppression</a>';
|
|
echo '</div>';
|
|
|
|
echo '</div>';
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
echo '</div>';
|
|
|
|
Pied_de_page();
|
|
?>
|
|
|
|
|
|
<script>
|
|
|
|
function toggle_help(){
|
|
var help = document.getElementById("help");
|
|
var help_note = document.getElementById("help_note");
|
|
|
|
if (help_note.style.display == "none"){
|
|
help_note.style.display = "block";
|
|
help.classList.remove("help_open");
|
|
help.classList.add("help_close");
|
|
}
|
|
else {
|
|
help_note.style.display = "none";
|
|
help.classList.remove("help_close");
|
|
help.classList.add("help_open");
|
|
}
|
|
}
|
|
|
|
$(window).resize(function(){
|
|
drawChart();
|
|
});
|
|
|
|
function closeEditAccess(){
|
|
document.getElementById('popUpAcces').style.display = "none";
|
|
}
|
|
|
|
function popUpEditAccess(data){
|
|
acces = data;
|
|
|
|
document.getElementById('popUpAcces').style.display = "block";
|
|
document.getElementById('shipmemberForm').value = acces['sm_Nom']+" "+acces['sm_Prenom']+" ["+acces['sm_Email']+"] ";
|
|
document.getElementById('cree_parForm').value = acces['cree_par_Nom']+" "+acces['cree_par_Prenom'];
|
|
document.getElementById('idForm').value = acces['ID'];
|
|
|
|
const selectElement = document.getElementById('type_profilForm');
|
|
|
|
for (let i = 0; i < selectElement.options.length; i++) {
|
|
if (selectElement.options[i].value === acces['ID_Type_acces_bateau_shipmember']) {
|
|
selectElement.options[i].selected = true;
|
|
break;
|
|
}
|
|
}
|
|
document.getElementById('fin_validiteForm').value = acces['Fin_validite'].substring(0,10);
|
|
}
|
|
|
|
function calculateDistance(lat1, lon1, lat2, lon2) {
|
|
const earthRadius = 6371;
|
|
|
|
const deltaLat = (lat2 - lat1) * (Math.PI / 180);
|
|
const deltaLon = (lon2 - lon1) * (Math.PI / 180);
|
|
|
|
const a = Math.sin(deltaLat / 2) ** 2 + Math.cos(lat1 * (Math.PI / 180)) * Math.cos(lat2 * (Math.PI / 180)) * Math.sin(deltaLon / 2) ** 2;
|
|
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
|
|
const distance = earthRadius * c;
|
|
|
|
// 2eme méthode, même résultat
|
|
// a1 = Math.sin(lat1 * (Math.PI / 180)) * Math.sin(lat2 * (Math.PI / 180));
|
|
// a2 = Math.cos(lat1 * (Math.PI / 180)) * Math.cos(lat2 * (Math.PI / 180));
|
|
// a3 = Math.cos(lon2 * (Math.PI / 180) - lon1 * (Math.PI / 180));
|
|
// a4 = a1 + a2 * a3;
|
|
// a5 = Math.acos(a4);
|
|
// distance = a5 * earthRadius;
|
|
|
|
return distance;
|
|
}
|
|
// MAP
|
|
var nb_data = <?php echo isset($nb_data) ? $nb_data : 0; ?>;
|
|
|
|
if (nb_data > 0) {
|
|
var data_map = <?php echo (isset($data_map) && is_array($data_map) && sizeof($data_map) > 0) ? json_encode($data_map) : '[]'; ?>;
|
|
// Additional JavaScript code using data_map can follow here
|
|
|
|
// Custom scale control for displaying nautical miles
|
|
var nauticalScaleControl = L.control.scale({
|
|
position: 'bottomleft',
|
|
imperial: false
|
|
});
|
|
|
|
nauticalScaleControl.options.update = function (options) {
|
|
var maxMeters = this._map.options.crs.getSize(this._map.getPixelBounds()).x,
|
|
maxNMiles = maxMeters / 1852;
|
|
|
|
this._updateScale(maxNMiles, 'NM', this._getRoundNum(maxNMiles, options));
|
|
};
|
|
|
|
var carte = L.map('maCarte').setView([data_map[nb_data-1]['latitude'],data_map[nb_data-1]['longitude']],10);
|
|
|
|
//----------------------------------
|
|
// Fond de carte :
|
|
// Très épurée :
|
|
L.tileLayer('https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png', {
|
|
maxZoom: 20,
|
|
attribution: '<a href="https://stadiamaps.com/">© Stadia Maps</a> | <a href="https://openmaptiles.org/">© OpenMapTiles</a> | <a href="http://openstreetmap.org">© OpenStreetMap</a> '
|
|
}).addTo(carte);
|
|
|
|
//----------------------------------
|
|
// Couches additionnelles :
|
|
// Open Sea Map :
|
|
L.tileLayer('https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', {
|
|
attribution: '| <a href="http://www.openseamap.org">© OpenSeaMap</a>'
|
|
}).addTo(carte);
|
|
|
|
nauticalScaleControl.addTo(carte);
|
|
|
|
var circles = {};
|
|
var lines = [];
|
|
|
|
var distance_total = 0;
|
|
var distance24h = 0;
|
|
var now = new Date();
|
|
|
|
for (var i = 0; i < nb_data; i++)
|
|
{
|
|
if (data_map[i]['latitude'] != null && data_map[i]['longitude'] != null)
|
|
{
|
|
var circle = L.circle([data_map[i]['latitude'], data_map[i]['longitude']],
|
|
{
|
|
//color: '#004563',
|
|
color: data_map[i]['couleur'],
|
|
opacity: data_map[i]['opacite'],
|
|
fillColor: '#75B9DA',
|
|
fillOpacity: 0.7,
|
|
radius: 50
|
|
}).addTo(carte);
|
|
circle.bindPopup(data_map[i]['date'] + '<br />' + data_map[i]['latitude_dms'] + '<br />' + data_map[i]['longitude_dms']);
|
|
|
|
if (i == (nb_data-1))
|
|
{
|
|
var myIcon = L.icon({
|
|
iconUrl: "images/location-pointer.png",
|
|
iconSize: [30, 30],
|
|
popupAnchor: [0, -30],
|
|
});
|
|
if (!(nb_data == 1 && data_map[i]['latitude'] == 45.735237 && data_map[i]['longitude'] == 4.804827)){
|
|
var marker = L.marker([data_map[i]['latitude'], data_map[i]['longitude']]).addTo(carte);
|
|
marker.bindPopup(data_map[i]['date'] + '<br />' + data_map[i]['latitude_dms'] + '<br />' + data_map[i]['longitude_dms']);
|
|
}
|
|
}
|
|
circles['circle' + i] = circle;
|
|
|
|
if (i > 0)
|
|
{
|
|
var previousCircle = circles['circle' + (i - 1)];
|
|
if (previousCircle!= null)
|
|
{
|
|
var line = L.polyline([previousCircle.getLatLng(), circle.getLatLng()], {
|
|
//(((data_map[i]['jour'] % 2) == 0) ? color: '#004563' : color: '#554563')
|
|
//color: '#004563'
|
|
color: data_map[i]['couleur'],
|
|
opacity: data_map[i]['opacite'],
|
|
}).addTo(carte);
|
|
lines.push(line);
|
|
|
|
// Calculate distance
|
|
var lat1 = data_map[i - 1]['latitude'];
|
|
var lon1 = data_map[i - 1]['longitude'];
|
|
var lat2 = data_map[i]['latitude'];
|
|
var lon2 = data_map[i]['longitude'];
|
|
|
|
var distance = calculateDistance(lat1, lon1, lat2, lon2); // Implement the distance calculation function
|
|
data_map[i]['distance'] = distance;
|
|
|
|
distance_total += distance;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Initialiser l'affichage avec la distance totale sur 90jrs
|
|
|
|
// A DECOMMENTER !!!!
|
|
// document.getElementById("distance").innerText = (distance_total*1.852).toFixed(2)+" NM";
|
|
// document.getElementById("date_debut_croisire").innerText = data_map[1]['date'];
|
|
// document.getElementById("date_fin_croisire").innerText = data_map[nb_data-1]['date'];
|
|
|
|
if(nb_data > 1){
|
|
// Convert date strings to timestamps
|
|
data_map.forEach(function(item) {
|
|
item.timestamp = Date.parse(item.raw_date) / 1000;
|
|
});
|
|
// Initialize the slider
|
|
var dateSlider = document.getElementById('dateSlider');
|
|
noUiSlider.create(dateSlider, {
|
|
range: {
|
|
min: data_map[1]['timestamp'], // Use the timestamp directly
|
|
max: data_map[nb_data-1]['timestamp'] // Use the timestamp directly
|
|
},
|
|
step: 1,
|
|
start: [data_map[1]['timestamp'], data_map[nb_data-1]['timestamp']], // Use the timestamp directly
|
|
connect: true,
|
|
tooltips: [true, true],
|
|
format: {
|
|
to: function (value) {
|
|
return new Date(value * 1000).toISOString().replace("T"," ").slice(0,19)+"Z"; // The Z is needed so the algo knows that the dates are in UTC, if we remove it it won't work correctly, we will lose data for the first and last 2 hours
|
|
},
|
|
from: function (value) {
|
|
return value;
|
|
}
|
|
}
|
|
});
|
|
|
|
// Put right date on the bottom
|
|
const lastElement = $('.noUi-tooltip:last');
|
|
lastElement[0].style.bottom="-40px";
|
|
|
|
// Handle slider change event
|
|
dateSlider.noUiSlider.on('slide', function (values) {
|
|
var startDate = new Date(values[0]);
|
|
var endDate = new Date(values[1]);
|
|
|
|
var totalDistance = 0; // Initialize the total distance for the selected date range
|
|
var debut_croisiere = 0;
|
|
for (var i = 0; i < nb_data; i++) {
|
|
var currentDate = new Date(data_map[i]['timestamp'] * 1000);
|
|
if (currentDate >= startDate && currentDate <= endDate) {
|
|
if(debut_croisiere == 0) debut_croisiere = data_map[i]['date']; // Date début croisière, premier point dans l'intervalle
|
|
fin_croisiere = data_map[i]['date']; // Date fin croisière, dernier point dans l'intervalle
|
|
if (i > 0) {
|
|
(typeof data_map[i]['distance'] !== 'undefined' && data_map[i]['distance'] !== null) ? totalDistance += data_map[i]['distance'] : totalDistance = totalDistance; // Add the distance to the total
|
|
}
|
|
if (circles['circle' + i]) {
|
|
circles['circle' + i].addTo(carte);
|
|
}
|
|
if (i > 0 && lines[i - 1]) {
|
|
lines[i - 1].addTo(carte);
|
|
}
|
|
} else {
|
|
if (circles['circle' + i]) {
|
|
circles['circle' + i].removeFrom(carte);
|
|
}
|
|
if (i > 0 && lines[i - 1]) {
|
|
lines[i - 1].removeFrom(carte);
|
|
}
|
|
}
|
|
}
|
|
// Update the table
|
|
|
|
// A DECOMMENTER !!!!
|
|
// document.getElementById("distance").innerText = (totalDistance * 1.852).toFixed(2) + " NM";
|
|
// document.getElementById("date_debut_croisire").innerText = debut_croisiere;
|
|
// document.getElementById("date_fin_croisire").innerText = fin_croisiere;
|
|
});
|
|
|
|
|
|
}
|
|
|
|
//Calculer la distance pour les derniers 24hrs
|
|
var totalDistance24h = 0; // Initialize total distance for the past 24 hours
|
|
var twentyFourHoursAgo = new Date() - 24 * 60 * 60 * 1000; // Calculate the timestamp for 24 hours ago
|
|
|
|
for (var i = 2; i < nb_data; i++) {
|
|
var currentDate = new Date(data_map[i]['timestamp'] * 1000);
|
|
if (currentDate >= twentyFourHoursAgo) { // Check if the data point is within the past 24 hours
|
|
if (i > 0) {
|
|
if (typeof data_map[i]['distance'] !== 'undefined' && data_map[i]['distance'] !== null) {
|
|
totalDistance24h += data_map[i]['distance']; // Add the distance to the total
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// A DECOMMENTER !!!!
|
|
// document.getElementById("distance24h").innerText = (totalDistance24h*1.852).toFixed(2)+" NM";
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|