<?php
include '../config/database.php';

function _api($Version,$Product){
	$conn = _connectDB();
	$sql = "SELECT * FROM monitor WHERE  Code='CJ5' AND Version='V5';";

	$result = $conn->query($sql);
	$res = [];
	if ($result->num_rows > 0) {
	    while($row = $result->fetch_assoc()) {
			array_push($res,$row);
	    }
	}
	return $res;
}
if(isset($_GET['code']) AND isset($_GET['version']) ){
	$Version = $_GET['version'];
	$Code = $_GET['code'];
	$newOBJ = [];
	foreach (_api($Version,$Code) as $key => $value) {
		$value['groupline_name'] = $value['groupline_name'].''.decode($value['groupline_name2'],APP); 
		array_push($newOBJ,  $value);
	}
	echo json_encode($newOBJ);
}else{
	echo json_encode([]);
}


