<?php



$pdata = [];

$list = scandir(__DIR__);



foreach ($list as $fn) {

	if (!in_array($fn, [".", "..", __FILE__])) {

		$data = json_decode(file_get_contents(__DIR__ . "/{$fn}"), 1);

		if (isset($data["Products"])) {

			foreach ($data["Products"] as $p) {

				$pdata[$p["PID"]] = $p;

			}

		}

	}

}



?>

<table>

<tr>

	<td>PID</td>

	<td>MPN</td>

	<td>EAN</td>

	<td>Producer</td>

	<td>Price</td>

	<td>Name</td>

	<td>Branches</td>

	<td>Stocks</td>

</tr>

<?php foreach ($plist as $p) { ?>

<tr>

	<td><?= $p["PID"] ?></td>

	<td><?= $p["MPN"] ?></td>

	<td><?= $p["EAN"] ?></td>

	<td><?= $p["Producer"]["Name"] ?></td>

	<td><?= $p["Price"]["Value"] ?></td>

	<td><?= $p["Name"] ?></td>

	<td>

		<?php foreach ($p["Branches"] as $b) { ?>

			<div><?= $b["OId"] ?> <?= $b["Name"] ?></div>

		<?php } ?>

	</td>

	<td>

		<?php foreach ($p["Stocks"] as $b) { ?>

			<div><?= $b["WhId"] ?> x <?= $b["Amount"] ?></div>

		<?php } ?>

	</td>

</tr>

<?php } ?>

</table>	