<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

include './assets/functions.php';
include './settings/settings.php';
include './settings/config.php';

$pdo = dbConnect($dbname);
$sql = 'SELECT rowID, productcode, productname, product_category,sn from products where status = "1" and build = "1"';
$stmt = $pdo->prepare($sql);
//Excute Query
$stmt->execute();
//Get results
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);

$bearertoken = createCommunicationToken($_SESSION['userkey']);

$view ='
<p id="servicetoken" value="'.$token.'" hidden>'.$token.'</p>
<div style="width:70%">
 <select id="productlist" name="productlist" >
    <option selected value="0">Assign Product</option>
';

foreach ($messages as $message){   
    $view .='<option value="'.$message["rowID"].'|'.$message["product_category"].'|'.$message["sn"].'">'.$message["productcode"].' - '.$message["productname"].'</option>';
}

$view .='</select>
    <input type="hidden" id="lineToSend" >
</div>
<div style="position: relative;left:30%;top: -20px;">
    <button class="button" onclick="startMaintenance()">Assembly</button>
    <button class="button"  id="connectButton" onClick="window.location.reload()">&#8634;</button>
</div>
<div>
<div id="readStatus" style="width: 75%;background-color: #f1f1f1;">
    <div id="readBar"></div>
</div>
</div>
<div id="Device_output">
    <div id="serialResults">
</div>
</div>
<script src = "https://legacy.veliti.nl/assets/readdevice.js?'.script_version.'"></script>
<script src = "https://legacy.veliti.nl/assets/charts.js?'.script_version.'"></script>
<script src = "https://legacy.veliti.nl/assets/jquery-2.1.4.min.js"></script>
<script src = "https://legacy.veliti.nl/assets/DYMO.Label.Framework.latest.js?'.script_version.'" type="text/javascript" charset="UTF-8"> </script>
';
//LABEL PRINTER niet vergeten
//add window.location.relead() after script

echo $view;

?>