tool_config.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. $toolList = $_POST['toolList'];
  8. $toolList = json_decode($toolList);
  9. $dtc = [];
  10. $articles = [];
  11. //db
  12. foreach ($toolList as $toolID){
  13. $sql = "SELECT * FROM (SELECT * FROM DTC_TOOL_LC_EVENT WHERE TOOL_ID = '{$toolID}' ORDER BY DATE_TIME DESC) WHERE ROWNUM <= 5";
  14. $res = sqlStm($sql);
  15. $article = $res["ARTICLE_ID"];
  16. if (!array_filter($article)) {
  17. $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";
  18. $res2 = sqlStm($newsql);
  19. $lastArticle = $res2["ARTICLE_ID"][0];
  20. } else {
  21. $last = array_filter($article);
  22. $lastArticle = end($last);
  23. }
  24. //print_r($res);
  25. $dtc[$toolID] = $res;
  26. $articles[$toolID] = $lastArticle;
  27. }
  28. //print_r($dtc);
  29. //echo "---------------------------------------------------";
  30. //print_r($articles);
  31. //to centurio
  32. header('Content-Type:application/json');
  33. echo json_encode( array("lastArticles" => $articles, "dtc" => $dtc));
  34. ?>