<?php //$_POST["date_jour"]=date("Y-m-d",time()-86400); $_POST["date_jour"] = date("d-mY", time() - 86400); $_POST["date_jour"] = "27-08-2014"; //on recherche la liste de véhicule auquel a droit l'utilisateur $sql = getsqllistvehicule(); $link_list_vehicule = query($sql); while ($tbl_list_vehicule = fetch($link_list_vehicule)) { $_POST["vehicule"] = $tbl_list_vehicule["phantom_device_id"]; $tabresult = exportexcel("mensuel", implodeargskey($_POST), array("Date", "Début", "Fin", "Ampl.", "Conduite", "Arrêt", "Distance", "Vit.max."), array("date", "debut", "fin", "datediff", "conduite", "arret", "km", "vitessemax")); $html = "Ci joint le rapport conducteur du mois " . date2month($_POST["date_jour"]) . " pour le véhicule " . $tbl_list_vehicule["nomvehicule"]; sendmailmister('', '', 'Rapport conducteur du mois ' . date2month($_POST["date_jour"]), $html, $_SESSION["email"], '', $tabresult); } //mise a jour de la date dans rapport /* $sql="update ".__racinebd__."rapport set date_envoi='".$_POST["date_debut"]."' where rapport_id=10"; query($sql); */
} $sql = "select * from " . __racinebd__ . "type_compte where compte_id=" . $_SESSION["compte_id"] . " and supprimer=0 order by libelle"; $link = query($sql); while ($tbl = fetch($link)) { $tbl_list_type[] = $tbl; $key_list_type[$tbl["type_compte_id"]] = $tbl["libelle"]; } if ($_POST["agence"] != "") { $where2 = " and agence_compte_id=" . $_POST["agence"]; } if ($_POST["date_debut"] != "" || $_POST["date_fin"] != "") { $totalalldistance = 0; $totalallconso = 0; $totalallarret = 0; $totalallconduite = 0; $sql = getsqllistvehicule() . $where2; //$sql=getsqllistvehiculerapport($where).$where2; //print $sql; $link_km = query($sql); while ($tbl_km = fetch($link_km)) { if ($tbl_km["phantom_device_id"] != "") { //print_r($tbl); $sql = "select * from " . __racinebd__ . "categorie_compte_device ccd\r\n inner join " . __racinebd__ . "categorie_compte cc on ccd.categorie_compte_id=cc.categorie_compte_id where device_id=" . $tbl_km["phantom_device_id"]; //print $sql; $link2 = query($sql); $tbl_list_cat = array(); while ($tbl2 = fetch($link2)) { $tbl_list_cat[] = $tbl2["libelle"]; } $tbl_km["listcat"] = implode(", ", $tbl_list_cat); //calcul du temps
$link2 = query($sql); $tabagence = array(); while ($tbl2 = fetch($link2)) { $tabagence[] = $tbl2["agence_compte_id"]; } if (count($tabvehicule)) { $_SESSION["filtreagence"] = " and agence_compte_id in(" . implode(",", $tabagence) . ")"; } //alarme de vitesse //on regarde si la personne doit recevoir ces alertes $sql = "select * from " . __racinebd__ . "rapport_usersgps where rapport_id=11 and usergps_id=" . $tbl_user["usergps_id"]; //print $sql; $linkalerte = query($sql); if ($linkalerte) { //recherche des vehicules du compte géré par cet utilisateur qui ont des alarmes de vitesse $sql = getsqllistvehicule() . " and vitessemax!='0.00'"; //print $sql."<br>"; $link_vehicule = query($sql); while ($tbl_list_vehicule = fetch($link_vehicule)) { //on liste des enregistrement de la table position pendant l'interval d'alerte $sql = "select * from positions where device_id=" . $tbl_list_vehicule["traccar_device_id"] . " and time>='" . $dernierdatedebut . "' and time<'" . $nouveldatedebut . "' and speed>'" . inversevitessekmh($tbl_list_vehicule["vitessemax"]) . "'"; //print $sql."<br>"; $linkvitesse = query($sql); if (num_rows($linkvitesse) > 0) { $html = "Bonjour,<br> le véhicule " . $tbl_list_vehicule["nomvehicule"] . " \r\n (" . $tbl_list_vehicule["immatriculation"] . ") à été controlé à une vitesse de :"; while ($tbl_vitesse = fetch($linkvitesse)) { $adresse = str_replace(", France", "", getAddess($tbl_vitesse["latitude"], $tbl_vitesse["longitude"])); $datelieu = "<br>" . affichedatetime($tbl_vitesse["time"]) . "<br>" . $adresse; $html .= "<br>" . vitessekmh($tbl_vitesse["speed"]) . " km/h à " . $datelieu . "<br>"; } $html .= "Sa vitesse maximale autorisée est de " . $tbl_list_vehicule["vitessemax"] . " km/h";
query($sql); $msgsave = "Sauvegarde éffectuée"; } if ($_POST["agence"] != "") { //listing des véhicules $sql = getsqllistvehicule() . " and agence_compte_id=" . $_POST["agence"]; $link = query($sql); while ($tbl = fetch($link)) { //mettre a jour les km $sql = "select * from " . __racinebd__ . "type_compte tc where type_compte_id=" . $tbl["type_compte_id"]; //print $sql; $link2 = query($sql); $tbl_type = fetch($link2); $tbl["type"] = $tbl_type; //recherche catégorie $sql = "select * from " . __racinebd__ . "categorie_compte_device ccd\r\n inner join " . __racinebd__ . "categorie_compte cc on ccd.categorie_compte_id=cc.categorie_compte_id where device_id=" . $tbl["phantom_device_id"]; //print $sql; $link2 = query($sql); $tbl_list_cat = array(); while ($tbl2 = fetch($link2)) { $tbl_list_cat[] = $tbl2["libelle"]; } $tbl["listcat"] = implode(", ", $tbl_list_cat); $tbl_list_vehicule[] = $tbl; } } if ($_POST["agence"] != "" && $_POST["id"] != "" && $_POST["mode"] != "modif") { $sql = getsqllistvehicule() . " and pd.device_id=" . $_POST["id"]; $link = query($sql); $tbl_modif_vitesse = fetch($link); }
<?php require "../../admin/require/function.php"; require "../../conf_front.php"; //print_r($_GET); /* $sql = "select *,pd.device_id as phantom_device_id from users t inner join ".__racinebd__."compte c on c.application_id=t.original_application_id inner join device d on d.owner_id=t.user_id inner join ".__racinebd__."device pd on pd.owner_id=t.user_id inner join user_template ut on ut.user_template_id=t.user_template_id and ut.application_id=c.application_id and template_name='Device' left join ".__racinebd__."categorie_compte_device ccd on pd.device_id=ccd.device_id where t.active=1 and c.application_id=".$_SESSION["application_id"]." and t.user_id in('".((is_array($_GET["vehicule"]))?implode(",",$_GET["vehicule"]):"0")."')"; */ $sql = getsqllistvehicule() . " and pd.device_id in(" . (is_array($_GET["vehicule"]) ? implode(",", $_GET["vehicule"]) : "0") . ")"; //print $sql; $link = query($sql); $content = array(); while ($tbl = fetch($link)) { //$content[]="{\"nomvehicule\": \"".$tbl["nomvehicule"]."\", \"date\": \"".$tbl["time_stamp"]."\",\"couleur\":\"".etatvoiturecouleur($tbl["user_id"])."\",\"bordure\":\"".etatvoiturecouleur($tbl["user_id"])."\",\"latitude\":".$tbl["latitude"].",\"longitude\":".$tbl["longitude"].",\"img\":\"".urliconvoiture($tbl["user_id"])."\"}"; $tabcouleur = etatvoiturecouleur($tbl["phantom_device_id"]); $content[] = "{\"nomvehicule\": \"" . $tbl["nomvehicule"] . "\", \"date\": \"" . $tbl["time"] . "\",\"couleur\":\"" . $tabcouleur[1] . "\",\"bordure\":\"" . $tabcouleur[1] . "\",\"latitude\":" . $tbl["latitude"] . ",\"longitude\":" . $tbl["longitude"] . ",\"img\":\"" . urliconvoiture($tbl["phantom_device_id"]) . "\"}"; } ?> {"listvehicule": [ <?php echo implode(",", $content); ?> ] }
$sql = "select lc.*,tlc.libelle as lib from " . __racinebd__ . "lieu_compte lc inner join " . __racinebd__ . "type_lieu_compte tlc on lc.type_lieu_compte_id=tlc.type_lieu_compte_id where compte_id=" . $_SESSION["compte_id"] . " and lc.supprimer=0 and alarme=1 " . $where . " order by lc.libelle"; $link = query($sql); while ($tbl = fetch($link)) { $tbl_list_lieu[] = $tbl; } $sql = "select * from " . __racinebd__ . "typealarme_agence where type=2 order by libelle"; $link = query($sql); while ($tbl = fetch($link)) { $tbl_list_type_alarme_agence[] = $tbl; } $sql = "select * from " . __racinebd__ . "jour order by jour_id"; $link = query($sql); while ($tbl = fetch($link)) { $tbl_list_jour[] = $tbl; } $sql = getsqllistvehicule() . " and agence_compte_id=" . $_POST["agence"]; $link = query($sql); while ($tbl = fetch($link)) { $tbl_list_vehicule[] = $tbl; } $sql = "select *,u.usergps_id from " . __racinebd__ . "compte c \r\n inner join " . __racinebd__ . "usergps u on u.compte_id=c.compte_id \r\n where c.supprimer=0 and u.supprimer=0 and c.compte_id=" . $_SESSION["compte_id"]; $link = query($sql); while ($tbl = fetch($link)) { $tbl_list_user[] = $tbl; } } if ($_POST["agence"] != "" && $_POST["id"] != "") { $sql = "select * from " . __racinebd__ . "alarme_compte where alarme_compte_id=" . $_POST["id"]; $link = query($sql); $tbl_modif_alarme = fetch($link); //on recherche les jours
if ($_POST["agence"] != "") { $where .= " and agence_compte_id=" . $_POST["agence"]; } if ($_POST["categorie"] != "") { $where .= " and categorie_compte_id=" . $_POST["categorie"]; } if ($_POST["nom"] != "") { $where .= " and nomvehicule like '%" . $_POST["nom"] . "%'"; } /* if($_POST["etat"]!=""){ $where.=" and gmr.data_bool=".$_POST["etat"]; } */ //listing des véhicules $sql = getsqllistvehicule() . " " . $where; //print $sql."<br>"; $link = query($sql); $nbgo = 0; $nbstay = 0; while ($tbl = fetch($link)) { //recherche catégorie $sql = "select * from " . __racinebd__ . "categorie_compte_device ccd\r\n inner join " . __racinebd__ . "categorie_compte cc on ccd.categorie_compte_id=cc.categorie_compte_id where device_id=" . $tbl["phantom_device_id"]; //print $sql; $link2 = query($sql); $tbl_list_cat = array(); while ($tbl2 = fetch($link2)) { $tbl_list_cat[] = $tbl2["libelle"]; } $tbl["listcat"] = implode(", ", $tbl_list_cat); $debut = "";