get_tool_events.php 979 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. include 'con.php';
  3. //error handling
  4. ini_set('display_errors', 1);
  5. error_reporting(E_ALL);
  6. //variables from centurio
  7. $toolID = $_POST["toolID"];
  8. //db
  9. $sql = "SELECT * FROM (SELECT * FROM DTC_TOOL_LC_EVENT WHERE TOOL_ID = '{$toolID}' ORDER BY DATE_TIME DESC) WHERE ROWNUM <= 5";
  10. $res = sqlStm($sql);
  11. $article = $res["ARTICLE_ID"];
  12. if (!array_filter($article)) {
  13. $newsql = "SELECT * FROM (SELECT * FROM DTC_TOOL_LC_EVENT WHERE TOOL_ID = '{$toolID}' AND ARTICLE_ID IS NOT NULL ORDER BY DATE_TIME DESC ) WHERE ROWNUM <= 1";
  14. $res2 = sqlStm($newsql);
  15. $lastArticle = $res2["ARTICLE_ID"][0];
  16. } else {
  17. $last = array_filter($article);
  18. $lastArticle = end($last);
  19. }
  20. $eventList = json_encode($res);
  21. $sqlAc = "SELECT NAME_DE FROM DTC_TOOLPART";
  22. $toolPart = json_encode(sqlStm($sqlAc)["NAME_DE"]);
  23. //to centurio
  24. header('Content-Type:application/json');
  25. echo json_encode( array("eventList" => $eventList, "lastArticle" => $lastArticle, "toolPart" => $toolPart));
  26. ?>