HEX
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System: Windows NT ALTAIR 10.0 build 20348 (Windows Server 2022) AMD64
User: Administrator (0)
PHP: 8.1.10
Disabled: NONE
Upload Files
File: C:/laragon/www/beplocal/TableProdottiData.php
<?php
include_once 'DBClassConcentratore.php';
include_once 'Utilities.php';

$DatabaseConcentratore = new DatabaseConcentratore();
$conn = new PDO("sqlsrv:server=".$DatabaseConcentratore->db_host." ; Database=".$DatabaseConcentratore->db_name, $DatabaseConcentratore->db_user, $DatabaseConcentratore->db_password);
// get data and store in a json array

$filterSql = $_POST['filter']; 
$jwt = $_POST['jwt'];
$authLevel = $_POST['AUTH_LEVEL'];

if(verificaToken($jwt, $authLevel)) {
	$barcodeFilter = "";
	if(isset($_POST['barcode']) && strlen($_POST['barcode']) > 0){
		
		$barcodeFilter = "where bc_code = '".$_POST['barcode']."' ";
		
	}




	
		$query = "select ".
				"art.ar_codart as 'IDAmus', ".
				"art.ar_desint as 'IDInterno',".
				"art.ar_descr as 'Descrizione', ".
				"bc.bc_code as 'Barcode', ".
				"list.lc_prezzo as 'Prezzo', ".
				"cat.tb_deshhl1 as 'Categoria',".
				"ana.an_descr1 as 'Fornitore' ".
				"from aes.dbo.artico as art ".
				"left join ".
				"( ".
				" SELECT ".
				" bc_codart, ".
				" MAX(bc_code) as 'bc_code' ".
				" FROM aes.dbo.barcode ".
				$barcodeFilter.
				" GROUP BY bc_codart ".
				" ) as bc on art.ar_codart = bc.bc_codart ".
				"inner join ( ".
				"SELECT ".
				"lc_codart, ".
				" MAX(lc_prezzo) as 'lc_prezzo' ".
				" FROM ".
				" aes.dbo.listini where lc_listino = 1 and lc_tipo = '' GROUP BY lc_codart) as list on list.lc_codart = art.ar_codart ".
				"left join aes.dbo.tabhhl1 cat on cat.tb_codhhl1 = art.ar_hhl1 ".
				"left join aes.dbo.anagra ana on ana.an_conto = art.ar_forn ".
				" where ".
				"1 = 1  ".$filterSql;
			


		
		$stmt = $conn->prepare($query);
		$stmt->execute();
		// $result->bind_param('ii', $from, $to);

		
		$items = array();
		while ($row = $stmt->fetch())
		{
			$items[] = array(
			'IDAmus' => $row['IDAmus'],
			'IDInterno' => $row['IDInterno'],
			'Descrizione' => $row['Descrizione'],
			'Barcode' => $row['Barcode'],
			'Prezzo' => $row['Prezzo'],
			'Categoria' => $row['Categoria'],
			'Fornitore' => $row['Fornitore']
			
			);
		}
		
		

		
		echo json_encode($items);
} else {
	echo json_encode(array('message' => "Errore nella procedura della tabela prodotti. Contattare il supporto tecnico"));
}
?>