1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
| <?php
//error_reporting(0);
session_start();
$id_of = $_GET['ID'];
//$id_of = $_GET['ID'];
//$id_of = '0344243';
?>
<!DOCTYPE html>
<html>
<head>
<title>C&D FOODS FRANCE - DOSEUSES MTBO</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>C&D FOODS FRANCE DOSEUSES MTBO STATS</title>
<link rel="shortcut icon" href="favicon.ico">
<script src="jquery.mobile/demos/js/jquery.js"></script>
<script src="jquery.mobile/demos/_assets/js/index.js"></script>
<script src="jquery.mobile/demos/js/jquery.mobile-1.4.5.min.js"></script>
<script src="jquery.mobile/kiwi.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/data.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<script src="https://code.highcharts.com/stock/modules/export-data.js"></script>
<link rel="stylesheet" href="stat.css">
</head>
<?php
$mysqli = new mysqli("localhost", "anniv", "anniversaire", "AUTOMATES");
if ($mysqli->connect_errno) {
printf("echec de la connexion : %s\n", $mysqli->connect_error);
exit();
}
$sql = $mysqli->query("SELECT max(compteur) FROM AUTOMATES.TIMERSIMA WHERE OF='$id_of' AND compteur <=1500000");
$req=mysqli_fetch_array($sql);
$compteurmax = $req['max(compteur)'];
$sql2 = $mysqli->query("SELECT * FROM AUTOMATES.TIMERSIMA WHERE OF='$id_of' AND compteur = '$compteurmax'");
//$sql2 = $mysqli->query("SELECT max(ID) FROM AUTOMATES.TIMERSIMA WHERE OF='$id_of'");
$req2=mysqli_fetch_array($sql2);
//$idmax = $req2['max(ID)'];
$idmax = $req2['ID'];
$sql22 = $mysqli->query("SELECT * FROM AUTOMATES.TIMERSIMA WHERE OF='$id_of' AND ID = '$idmax'");
$req22=mysqli_fetch_array($sql22);
$timermax = $req22['TIMER'];
$description = $req22['DESCRIPTION'];
$theorique = $req22['THEORIQUE'];
$maxid = $req22['ID'];
$sql33 = $mysqli->query("SELECT * FROM AUTOMATES.TIMERSIMA WHERE OF='$id_of' LIMIT 1");
$req33=mysqli_fetch_array($sql33);
$STARTTIMER = $req33['TIMER'];
$description2 = $req33['DESCRIPTION'];
$STARTID = $req33['ID'];
$compteurmin = $req33['compteur'];
$id_code = $req33['CODE'];
$result = $mysqli->query("select TIMER, SPEED from AUTOMATES.TIMERSIMA WHERE (SPEED >=0 AND SPEED <= 1200) AND (ID BETWEEN $STARTID AND $idmax)");
$dbdata = array();
while ( $row = $result->fetch_assoc()) {
$dbdata[]=$row;
}
//Print array in JSON format
$maligne = json_encode($dbdata);
$manouvelleligne0 = str_replace('"',"",$maligne);
$manouvelleligne = str_replace("{","[",$manouvelleligne0);
$manouvelleligne2 = str_replace("}","]",$manouvelleligne);
$manouvelleligne3 = str_replace("TIMER","",$manouvelleligne2);
$manouvelleligne4 = str_replace("SPEED","",$manouvelleligne3);
$manouvelleligne5 = str_replace(":","",$manouvelleligne4);
$manouvelleligne6 = str_replace('"',"",$manouvelleligne5);
$manouvelleligne7 = str_replace(',',"000,",$manouvelleligne6);
$manouvelleligne8 = str_replace(']000,[',"],[",$manouvelleligne7);
$manouvelleligne9 = str_replace('"[',"[",$manouvelleligne8);
$manouvelleligne10 = str_replace('"',"",$manouvelleligne9);
$content = json_encode($manouvelleligne10);
$content2 = str_replace('"',"",$content);
//echo $content2;
$fp = fopen('SIMASPEED.json', 'w');
fwrite($fp, $content2);
fclose($fp);
//boites produites
$result2 = $mysqli->query("select TIMER, compteur from AUTOMATES.TIMERSIMA WHERE (compteur <= 2000000 AND compteur >=0) AND (ID BETWEEN $STARTID AND $idmax)");
$dbdata2 = array();
while ( $row2 = $result2->fetch_assoc()) {
$dbdata2[]=$row2;
}
$maligne1 = json_encode($dbdata2);
//echo $maligne1;
$manouvelleligne01 = str_replace('"',"",$maligne1);
$manouvelleligne11 = str_replace("{","[",$manouvelleligne01);
$manouvelleligne21 = str_replace("}","]",$manouvelleligne11);
$manouvelleligne31 = str_replace("TIMER","",$manouvelleligne21);
$manouvelleligne41 = str_replace("compteur","",$manouvelleligne31);
$manouvelleligne51 = str_replace(":","",$manouvelleligne41);
$manouvelleligne61 = str_replace('"',"",$manouvelleligne51);
$manouvelleligne71 = str_replace(',',"000,",$manouvelleligne61);
$manouvelleligne81 = str_replace(']000,[',"],[",$manouvelleligne71);
$manouvelleligne91 = str_replace('"[',"[",$manouvelleligne81);
$content3 = json_encode($manouvelleligne91);
$content4 = str_replace('"',"",$content3);
//echo $content4;
$fp2 = fopen('SIMACOUNT.json', 'w');
fwrite($fp2, $content4);
fclose($fp2);
?>
<body>
<div id="bloc1"><?php echo $description; ?></div>
<div id="bloc2">OF: <?php echo $id_of; ?> -- -- Code Produit: <?php echo $id_code; ?> </div>
<div id="bloc3">du <?php echo date('d/m/Y', $STARTTIMER).' --'.date('H:i:s', $STARTTIMER); ?> au <?php echo date('d/m/Y', $timermax).' --'.date('H:i:s', $timermax); ?></div>
<div id="bloc4">Prévu: <?php echo $theorique; ?> boites -+-+- Produit: <?php echo $compteurmax; ?> boites</div>
<BR>
<div id="container" style="height: 400px; min-width: 310px"></div>
<script>
Highcharts.setOptions({
time: {
timezoneOffset: -1 * 60
}
});
Highcharts.getJSON('SIMASPEED.json', function (data) {
var startDate = new Date(data[data.length - 1][0]), // Get year of last data point
minRate = 1,
maxRate = 0,
startPeriod,
date,
rate,
index;
startDate.setMonth(startDate.getMonth() - 1); // a quarter of a year before last data point
startPeriod = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
for (index = data.length - 1; index >= 0; index = index - 1) {
date = data[index][0]; // data[i][0] is date
rate = data[index][1]; // data[i][1] is exchange rate
if (date < startPeriod) {
break; // stop measuring highs and lows
}
if (rate > maxRate) {
maxRate = rate;
}
if (rate < minRate) {
minRate = rate;
}
}
// Create the chart
Highcharts.stockChart('container', {
rangeSelector: {
selected: 1
},
title: {
text: 'Vitesse de la SIMA2 pendant OF'
},
yAxis: {
title: {
text: 'VITESSE'
},
plotLines: [{
value: minRate,
color: 'grey',
dashStyle: 'shortdash',
width: 2,
label: {
text: 'minimum'
}
}, {
value: maxRate,
color: 'green',
dashStyle: 'shortdash',
width: 2,
label: {
text: 'maximum'
}
}]
},
series: [{
name: 'boites par minute',
data: data,
tooltip: {
valueDecimals: 0
}
}]
});
});
</script>
</div>
<BR>
<div id="container2" style="height: 400px; min-width: 310px"></div>
<script>
Highcharts.getJSON('SIMACOUNT.json', function (data) {
var startDate = new Date(data[data.length - 1][0]), // Get year of last data point
minRate = 1,
maxRate = 0,
startPeriod,
date,
rate,
index;
startDate.setMonth(startDate.getMonth() - 3); // a quarter of a year before last data point
startPeriod = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
for (index = data.length - 1; index >= 0; index = index - 1) {
date = data[index][0]; // data[i][0] is date
rate = data[index][1]; // data[i][1] is exchange rate
if (date < startPeriod) {
break; // stop measuring highs and lows
}
if (rate > maxRate) {
maxRate = rate;
}
if (rate < minRate) {
minRate = rate;
}
}
// Create the chart
Highcharts.stockChart('container2', {
rangeSelector: {
selected: 1
},
title: {
text: 'boites produites de la SIMA2 pendant OF'
},
yAxis: {
title: {
text: 'boites produites'
},
plotLines: [{
value: minRate,
color: 'grey',
dashStyle: 'shortdash',
width: 2,
label: {
text: 'minimum'
}
}, {
value: maxRate,
color: 'blue',
dashStyle: 'shortdash',
width: 2,
label: {
text: 'maximum'
}
}]
},
series: [{
name: 'boites',
data: data,
tooltip: {
valueDecimals: 0
}
}]
});
});
</script>
</div>
<?php
$sql4 = $mysqli->query("SELECT * FROM AUTOMATES.TIMERSIMA WHERE OF='$id_of' AND compteur='$compteurmin'");
$req4=mysqli_fetch_array($sql4);
$timermin = $req4['TIMER'];
$description2 = $req4['DESCRIPTION'];
// ---------------------
function build_html_table_tr_ARRETS( $rowAll )
{
$table_datas = array();
$compteur = array();
$row_PREV = array(); // row précédent
$compteur['minutes'] = 0; // compteur de ligne en ARRET
$compteur['Timedebut'] = ''; // début ARRET
$compteur['Timefin'] = ''; // fin ARRET
$compteur['IDs'] = array(); // liste des ID correspondant à un ARRET
// ---------
foreach( $rowAll as $row )
{
if( $row['STATUS']=='ARRET' )
{
$compteur['minutes']++;
$compteur['IDs'][] = $row['ID'];
if( empty($compteur['Timedebut']) ){ $compteur['Timedebut'] = $row['TIMER']; }
$compteur['Timefin'] = $row['TIMER'];
}
if( !empty($row_PREV) && $row_PREV['STATUS']=='ARRET' && $row['STATUS']!='ARRET' )
{
if( empty($compteur['Timedebut']) ){ $compteur['Timedebut'] = $row_PREV['TIMER']; }
$compteur['Timefin'] = $row['TIMER'];
$table_datas[$row_PREV['ID']] = $row_PREV;
$table_datas[$row_PREV['ID']]['minutes'] = $compteur['minutes'];
$table_datas[$row_PREV['ID']]['Timedebut'] = $compteur['Timedebut'];
$table_datas[$row_PREV['ID']]['Timefin'] = $compteur['Timefin'];
$table_datas[$row_PREV['ID']]['IDs'] = $compteur['IDs'];
}
if( $row['STATUS']!='ARRET' )
{
$compteur['minutes'] = 0;
$compteur['Timedebut'] = '';
$compteur['Timefin'] = '';
$compteur['IDs'] = array();
}
$row_PREV = $row;
}
// ---------
// derniere ligne (en dehors du foreach)
if( $row['STATUS']=='ARRET' )
{
$compteur['Timefin'] = $row['TIMER'];
$table_datas[$row['ID']] = $row;
$table_datas[$row['ID']]['minutes'] = $compteur['minutes'];
$table_datas[$row['ID']]['Timedebut'] = $compteur['Timedebut'];
$table_datas[$row['ID']]['Timefin'] = $compteur['Timefin'];
$table_datas[$row['ID']]['IDs'] = $compteur['IDs'];
}
// ---------
return $table_datas;
}
// ---------------------
?>
<?php
// ---------------------
$id_of = '349540';
$table_datas = array();
if ($result = $mysqli->query("SELECT * FROM TIMERSIMA WHERE OF='$id_of' ORDER BY TIMER ASC"))
{
$rowAll = $result->fetch_all(MYSQLI_ASSOC);
$table_datas = build_html_table_tr_ARRETS( $rowAll );
}
// ---------------------
?>
<table id="tableau2" summary="E">
<caption><h1> ERREURS</h1> </caption>
<thead>
<th scope="col">IDs</th>
<th scope="col">OF</th>
<th scope="col">Time Début</th>
<th scope="col">Time Fin</th>
<th scope="col">Time Diff.</th>
<th scope="col">Minutes</th>
<th scope="col">STATUT</th>
<th scope="col">Voir les erreurs</th>
</thead>
<tbody>
<?php
// Affichage
foreach( $table_datas as $row )
{
$dateDebut = new DateTime();
$dateDebut->setTimestamp($row['Timedebut']);
$dateFin = new DateTime();
$dateFin->setTimestamp($row['Timefin']);
$dateDiff = $dateDebut->diff($dateFin);
echo
" <tr>
<td>" . implode(', ',$row['IDs']) . "</td>
<td>" . $row['OF'] . "</td>
<td>" . $dateDebut->format('d/m/Y H:i:s') . "</td>
<td>" . $dateFin->format('d/m/Y H:i:s') . "</td>
<td>" . $dateDiff->format('%I:%S') . "</td>
<td>" . $row['minutes'] . "</td>
<td>" . $row['STATUS'] . "</td>
<td><a href='codeerror.php?ID=".$row['ID']."' rel='external' data-role='button' data-mini='true' data-inline='true'>cliquez ici</a></td>
</tr>
";
}
?>
<div id="bloc4">
<?php echo 'Temps Total des arrêts DOSEUSE: '.$row_cnt.' minute(s) ';?><br />
<?php echo 'Le plus gros arrêt DOSEUSE: Cause :';?>
</div>
</body>
</html> |
Partager