<?php
require_once("../include/dbcommon.php"); // DataBase PHPRunner


$rs = DB::Query("SELECT * FROM jsgrid_person");

$person=[];
while( $data = $rs->fetchAssoc() )
{
   $fileArray = my_json_decode($data["picture"]);
   $file = file_get_contents(__DIR__."/../".$fileArray[0]["name"]);
   $data["picture"] = "data:image/png;base64, ".base64_encode($file);  // Image to Base64
   $person[]=$data;
}
$person = "const persons = ".json_encode($person, JSON_UNESCAPED_UNICODE).";"; // convert Array to Json

$rs = DB::Query("SELECT * FROM jsgrid_position");

$position=[];
while( $data = $rs->fetchAssoc() )
{
   $position[]=$data;
}
$position = "const positions = ".json_encode($position, JSON_UNESCAPED_UNICODE).";"; // convert Array to Json

echo $person;
echo $position;
?>