<?php

  //setting header to json
  header('Content-Type: application/json');
  header("Access-Control-Allow-Origin: *");


  $id = $_POST["id"];  // get internal sensor id from js
  $driverID = $_POST["driver"];  // get value
  require '../php/database.php';

  $query = 'SELECT rulesEquipment.ruleID, rulesEquipment.equipmentPinID, rulesEquipment.equipmentOffOn, rulesEquipment.switchDelay, rulesEquipment.nextDoseDelay, rulesEquipment.doseML, pinsAvailable.pinTypeID, pinsAvailable.iconID, pinsAvailable.name
  FROM rulesEquipment
  LEFT JOIN pinsAvailable
  ON rulesEquipment.equipmentPinID = pinsAvailable.pinID
  ORDER BY rulesEquipment.ruleID, rulesEquipment.equipmentPinID, rulesEquipment.switchDelay ASC';

  //execute query
  $result = $mysqli->query($query);

  //loop through the returned data
  $dataWindow = array();
  foreach ($result as $row) {
    $dataWindow[] = $row;
  }

  //free memory associated with result
  $result->close();

  //close connection
  $mysqli->close();
  print json_encode($dataWindow);