PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/common/pages/data.php

https://github.com/carlosefonseca/ER-client-webapp
PHP | 139 lines | 110 code | 18 blank | 11 comment | 11 complexity | c35e83c73d3d8b9d9780803caef96a44 MD5 | raw file
  1. <?
  2. global $client;
  3. global $title;
  4. $title = "Dados Locais";
  5. $data = parseDataFiles("serverfiles");
  6. function echoValOrND($v, $unid = "", $hasSpan = true) {
  7. $ND = "<span title='Dados não disponiveis'>N/D</span>";
  8. if ($v != "") {
  9. if($hasSpan) {
  10. echo "<span>$v</span> $unid";
  11. } else {
  12. echo "$v $unid";
  13. }
  14. } else {
  15. echo $ND;
  16. }
  17. }
  18. //GET GARDENS
  19. require_once("../common/DBconnect.php");
  20. $q = "SELECT id, name, status FROM jardins WHERE client = '$client' ".getUserGardens(true)." ORDER BY id";
  21. $res = mysql_query($q);
  22. ?>
  23. <link rel="stylesheet" type="text/css" href="../common/css/tablesorter/tablesorter.css" />
  24. <link rel="stylesheet" type="text/css" href="../common/css/tooltip.css" />
  25. <script src="../common/js/jquery.tooltip.js"></script>
  26. <div class="content" style="">
  27. <table id="data" class="tablesorter">
  28. <thead>
  29. <tr>
  30. <th>#</th>
  31. <th>Jardim</th>
  32. <th>Último Relatório</th>
  33. <th title="Estado de cada slave - Verde:OK | Vermelho:Problema">Estado Slaves</th>
  34. <? # <th title="Número de Slaves em erro">Anómalias</th>?>
  35. <th title="Sectores activos e inactivos - Verde:Activo | Vermelho:Inactivo">Sectores </th>
  36. <th title="Número de programas activos em cada jardim">Programas</th>
  37. <th title="Caudal de água gasta nas regas do tipo 1">Caudal Tipo 1</th>
  38. <th title="Caudal total nas últimas 24h">Total 24h</th>
  39. <th title="Variação do caudal total em relação ao dia anterior">Dia anterior</th>
  40. <th title="Volume total gasto por jardim">Volume total</th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. <? while($r = mysql_fetch_array($res)):
  45. $id=$r["id"]; $jId="j".$id;
  46. if (!array_key_exists("j".$id, $data["status"])) {
  47. continue;
  48. }
  49. $st = $data["status"]["j".$id];
  50. $name = utf8_encode($r["name"]);
  51. $report = ($st["data"]!=""&&$st["hora"]!="")?$st["data"]." - ".$st["hora"]:'';
  52. // $status = $st["estado"];
  53. $slaves = "";
  54. for($i=0;$i< strlen($st["estado"]);$i++) {
  55. $slaves .= "<span class='s".$st["estado"][$i]."'>".($i+1)."</span> ";
  56. }
  57. $anomalias = $st["erros"];
  58. $sectores = "";
  59. if ($data["secAct"][$jId] != null) {
  60. foreach($data["secAct"][$jId] as $n => $s) {
  61. $sectores .= "<span class='s$s'>$n</span> ";
  62. }
  63. }
  64. $programas = $data["progAct"][$jId];
  65. $mmT1 = $data["mmT1"][$jId];
  66. $c24h = $data["c24h"][$jId]["caudal"];
  67. $variacao = $data["c24h"][$jId]["variacao"];
  68. $cTotal = $data["cTotal"][$jId];
  69. ?>
  70. <tr>
  71. <td class="id" ><? echoValOrND($id); ?></td>
  72. <td class="name"><? echoValOrND($name); ?></td>
  73. <td class="time"><? echoValOrND($report); ?></td>
  74. <td class="stat"><? echoValOrND($slaves,'',0); ?></td>
  75. <? /* <td class="anom"><? echoValOrND($anomalias); ?></td>*/ ?>
  76. <td class="sact"><? echoValOrND($sectores,'',0);?></td>
  77. <td class="prog"><? echoValOrND($programas); ?></td>
  78. <td class="mmt1"><? echoValOrND($mmT1, "mm"); ?></td>
  79. <td class="c24h"><? echoValOrND($c24h, "m<sup>3</sup>"); ?></td>
  80. <td class="cvar"><? echoValOrND($variacao,"m<sup>3</sup>"); ?></td>
  81. <td class="ctot"><? echoValOrND($cTotal, "m<sup>3</sup>"); ?></td>
  82. <? /*<td class=""><span><? $t=sec2time($data["tempoultimarega"][$jId]); printf("%d:%02d",$t["hours"]*60+$t["minutes"],$t["seconds"]);?></span></td>*/?>
  83. </tr>
  84. <? endwhile; ?>
  85. </tbody>
  86. <tfoot>
  87. <? /* <tr>
  88. <th colspan="5" class="space"></th>
  89. <th>Média:</th>
  90. <th><? echo $data["caudalmm"]["media"];?> m<sup>3</sup>/mm</th>
  91. <th><? echo $data["caudal"]["media"];?> m<sup>3</sup></th>
  92. <th><? $t=sec2time($data["tempoultimarega"]["media"]);
  93. printf("%d:%02d",$t["hours"]*60+$t["minutes"],$t["seconds"]);?></th>
  94. <th><? echo $data["ultimarega"]["media"];?> mm</th>
  95. </tr> */
  96. if (array_key_exists("total",$data["mmT1"])) { $mmT1Total = $data["mmT1"]["total"]; } else { $mmT1Total = ""; }
  97. ?>
  98. <tr class="last">
  99. <th colspan="5" class="space"></th>
  100. <th>Total:</th>
  101. <th><? echoValOrND($mmT1Total, "m<sup>3</sup>/mm");?></th>
  102. <th colspan="2"><? echo $data["c24h"]["total"];?> m<sup>3</sup></th>
  103. <th><? echo $data["cTotal"]["total"];?> m<sup>3</sup></th>
  104. <? /* <th><? $t=sec2time($data["tempoultimarega"]["total"]);
  105. printf("%d:%02d",$t["hours"]*60+$t["minutes"],$t["seconds"]);?></th>*/?>
  106. </tr>
  107. </tfoot>
  108. </table>
  109. </div>
  110. <script type="text/javascript" src="../common/js/jquery.tablesorter.min.js"></script>
  111. <script>
  112. $("#data").tablesorter({
  113. textExtraction: function(node) {
  114. // extract data from markup and return it
  115. return $(node).find("span").html();
  116. },
  117. widgets: ['zebra'],
  118. sortList: [[0,0]]
  119. });
  120. $("#data th").tooltip({showBody:" - ",track: true,delay: 0, fade: 250,positionLeft: true});
  121. </script>