equipment_revitVersion.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. include("connectSQL_Component.php");
  3. if (isset($_GET["parent"])) {
  4. $type = $_GET["type"];
  5. $parent = $_GET["parent"];
  6. $jsonFileContents = file_get_contents("../../assets/equipmentTable2.json");
  7. $json = json_decode($jsonFileContents);
  8. for ($i = 0; $i < count($json); $i++) {
  9. if ($parent == $json[$i]->category_code) {
  10. $parent = $json[$i]->category_name;
  11. }
  12. for ($j = 0; $j < count($json[$i]->children); $j++) {
  13. if ($type == $json[$i]->children[$j]->component_code) {
  14. $type = $json[$i]->children[$j]->component_name;
  15. }
  16. }
  17. }
  18. if ($type != "")
  19. $sql = "SELECT DISTINCT [revitVersion] FROM [BIMComponents].[dbo].[Component_Info] WHERE [componentGroup] LIKE '%" . $parent . "%' AND [category] = '" . $type . "';";
  20. else if ($type == "")
  21. $sql = "SELECT DISTINCT [revitVersion] FROM [BIMComponents].[dbo].[Component_Info] WHERE [componentGroup] LIKE '%" . $parent . "%';";
  22. $fetchResult = sqlsrv_query($conn, $sql);
  23. $revitVersion = [];
  24. while ($row = sqlsrv_fetch_array($fetchResult)) {
  25. if ($row["revitVersion"] != null) {
  26. array_push($revitVersion, $row["revitVersion"]);
  27. }
  28. }
  29. echo json_encode($revitVersion);
  30. }