diff --git a/api/v1/assets/read.php b/api/v1/assets/read.php index 7474ae8f..92b9b3ba 100644 --- a/api/v1/assets/read.php +++ b/api/v1/assets/read.php @@ -9,7 +9,7 @@ if($_SERVER['REQUEST_METHOD'] !== "GET"){ exit(); } -// Specific asset query via ID +// Asset via ID (single) if(isset($_GET['asset_id'])){ $id = intval($_GET['asset_id']); $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_id = '$id' AND company_id = '$company_id'"); @@ -22,8 +22,8 @@ elseif(isset($_GET['asset_type'])){ } // Asset query via name -elseif(isset($_GET['name'])){ - $name = mysqli_real_escape_string($mysqli,$_GET['name']); +elseif(isset($_GET['asset_name'])){ + $name = mysqli_real_escape_string($mysqli,$_GET['asset_name']); $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_name = '$name' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset"); } @@ -39,28 +39,10 @@ elseif(isset($_GET['asset_client_id'])){ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_client_id = '$client' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset"); } -// All asset query +// All assets else{ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset"); } - // Output -if($sql && mysqli_num_rows($sql) > 0){ - $return_arr['success'] = "True"; - $return_arr['count'] = mysqli_num_rows($sql); - - $row = array(); - while($row = mysqli_fetch_array($sql)){ - $return_arr['data'][] = $row; - } - - echo json_encode($return_arr); - exit(); -} -else{ - $return_arr['success'] = "False"; - $return_arr['message'] = "No asset(s) (with that ID) for this company"; - echo json_encode($return_arr); - exit(); -} \ No newline at end of file +include("../read_output.php"); \ No newline at end of file diff --git a/api/v1/certificates/read.php b/api/v1/certificates/read.php new file mode 100644 index 00000000..01f3baa5 --- /dev/null +++ b/api/v1/certificates/read.php @@ -0,0 +1,36 @@ + 0){ + $return_arr['success'] = "True"; + $return_arr['count'] = mysqli_num_rows($sql); + + $row = array(); + while($row = mysqli_fetch_array($sql)){ + $return_arr['data'][] = $row; + } + + echo json_encode($return_arr); + exit(); +} +else{ + $return_arr['success'] = "False"; + $return_arr['message'] = "No resource for this company with the specified parameter(s)."; + echo json_encode($return_arr); + exit(); +} \ No newline at end of file diff --git a/api/v1/software/read.php b/api/v1/software/read.php new file mode 100644 index 00000000..b82514d1 --- /dev/null +++ b/api/v1/software/read.php @@ -0,0 +1,48 @@ +