<?php
if (!isset($_SERVER["HTTP_HOST"])) {
  //parse_str($argv[1], $_GET);
  parse_str($argv[1], $_POST);
}
require "acesso.php";
	$res = array();
	
	$id_firma  = $_POST['id_firma'];
	$id_device = $_POST['id_device'];
	//$con = new PDO("mysql:dbname=$database; charset=utf8", $usuario , $senha);
	$ret = $con->prepare("SELECT COALESCE(a.arcodmar, ' ') AS arcodmar, COALESCE(b.arnommar, ' ') AS arnommar FROM estoque a LEFT JOIN marcas b ON a.arcodmar = b.arcodmar 
			WHERE CAST( MID( arvratad, (artabatu-1)*16+1, 16 ) * 1 AS DECIMAL( 16,2 ) ) > 0 AND a.arcodmar IS NOT NULL AND b.arnommar 
			IS NOT NULL GROUP BY a.arcodmar");
	$ret->execute();
	$mensagem = $ret->errorInfo();
	if ($ret->rowCount() > 0) {
	    $res["marcas"] = array();
	    while ($row = $ret->fetch(PDO::FETCH_ASSOC)) {
	    	array_push($res["marcas"], $row);
	    }
	    $res["sucesso"] = 1;
	} else {
	    $res["sucesso"] = 0;
	    $res["mensagem"] = $mensagem[2];
	}
echo json_encode($res);
?>