<?php
header('Content-type: application/json');
include '../config/database.php';
function _users_find_stock($gid,$v,$product){
	$conn = _connectDB();
	$sql = "SELECT s.* FROM groupline g LEFT  JOIN stock_list  s ON s.g_id = g.groupline_id WHERE groupline_key = '".$gid."' AND groupline_products = '".$product."' AND groupline_version = '".$v."'";
	$result = $conn->query($sql);
	$res = [];
	if ($result->num_rows > 0) {
	    while($row = $result->fetch_assoc()) {
			array_push($res,$row);
	    }
	}
	return $res;
}

$gid = $_GET['gid'];
$v = $_GET['v'];
$product = $_GET['p'];

if(isset($_GET['gid'])){
	echo json_encode(_users_find_stock($gid,$v,$product));
}
