public function display()
 {
     $connection = new Connection();
     $statement = new Statement($connection);
     //get mechanic view
     $SQL = "SELECT * FROM MechanicView WHERE idMINIEmployee = :id";
     $statement->setInt('id', Session::get('id'));
     $mechanic = $statement->select($SQL)->first();
     // get vehicles with issues that have not yet been added to maintenance.
     $SQL = 'SELECT * FROM VehicleReportedIssues';
     $statement = new Statement($connection);
     $issues = $statement->select($SQL)->all();
     // get vehicles in under maintenance.
     $SQL = 'SELECT * FROM Maintenance m
         INNER JOIN VehicleView v ON m._idVehicle = v.idVehicle
         WHERE _ReturnedBy IS NULL';
     $statement = new Statement($connection);
     $maintenance = $statement->select($SQL)->all();
     // display completed maintenance.
     $SQL = 'SELECT * FROM Maintenance m
         INNER JOIN VehicleView v ON m._idVehicle = v.idVehicle
         WHERE _ReturnedBy IS NOT NULL
         ORDER BY DateReturned DESC';
     $statement = new Statement($connection);
     $completed = $statement->select($SQL)->all();
     $data = ['mechanic' => $mechanic, 'issues' => $issues, 'maintenance' => $maintenance, 'completed' => $completed];
     $html = $this->view->render('MechanicHome', $data);
     $this->response->setContent($html);
 }
 public function complete($params)
 {
     $log = $params['log'];
     $mechanic = Session::get('id');
     $SQL = 'UPDATE Maintenance
         SET _ReturnedBy = :mechanic, DateReturned = CURRENT_TIMESTAMP
         WHERE MaintenanceLogNumber = :log';
     $statement = new Statement(new Connection());
     $statement->setInt('log', $log);
     $statement->setInt('mechanic', $mechanic);
     $complete = $statement->update($SQL);
     if (!is_a($complete, "PDOException")) {
         header('Location:/mechanic');
     } else {
         $data = ['error' => $complete->errorInfo[2], 'return' => "/maintenance/log/{$log}"];
         $html = $this->view->render('Error', $data);
         $this->response->setContent($html);
     }
 }
 public function update($params)
 {
     $log = $params['log'];
     $item = $params['item'];
     $mechanic = Session::get('id');
     $description = $this->request->getParameter('description');
     $SQL = 'UPDATE MaintenanceItem
         SET ItemDescription = :description
         WHERE idMaintenanceItem = :item';
     $statement = new Statement(new Connection());
     // $statement->setInt('mechanic', $mechanic);
     $statement->setInt('item', $item);
     $statement->setInt('description', $description);
     $statement->update($SQL);
     header("Location: /maintenance/log/{$log}");
 }
$env = 'dev';
// https://github.com/PatrickLouys/no-framework-tutorial
$whoops = new \Whoops\Run();
if ($env === 'dev') {
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
} else {
    $whoops->pushHandler(function ($e) {
        echo 'error!';
    });
}
$whoops->register();
// https://github.com/PatrickLouys/no-framework-tutorial
$injector = (include 'Dependencies.php');
$request = $injector->make('Http\\HttpRequest');
$response = $injector->make('Http\\HttpResponse');
Session::set('id', 10);
// https://github.com/PatrickLouys/no-framework-tutorial
foreach ($response->getHeaders() as $header) {
    header($header, false);
}
// https://github.com/PatrickLouys/no-framework-tutorial
$routeDefinitionCallback = function (\FastRoute\RouteCollector $r) {
    $routes = (include 'Routes.php');
    foreach ($routes as $route) {
        $r->addRoute($route[0], $route[1], $route[2]);
    }
};
// https://github.com/PatrickLouys/no-framework-tutorial
$dispatcher = \FastRoute\simpleDispatcher($routeDefinitionCallback);
$routeInfo = $dispatcher->dispatch($request->getMethod(), $request->getPath());
// https://github.com/PatrickLouys/no-framework-tutorial