/**
  * deletes a request with a requestID on a users DB.
  *
  * @param $userdb
  * @param $requestId
  * @return bool
  */
 public function deleteRequest($userdb, $requestId)
 {
     $username = RequestHelper::readUsernameFromRequest();
     //control variable
     $all_query_ok = true;
     //disable autocommit so commit/rollback is possible
     $this->core->dbh->autocommit(false);
     // select all intervention IDs with the specified RequestID as an array
     if ($stmt = $this->core->dbh->query("SELECT IntervID FROM intervention WHERE Request_id = '" . $requestId . "'")) {
         $row = $stmt->fetch_row();
         $stmt->close();
     } else {
         $all_query_ok = false;
     }
     if (!$all_query_ok) {
         LogHelper::write("select intervid failed", $username);
     }
     //skip deleting intervention work and material if no interventions are in the DB
     //delete from intervention_material and intervention_work
     if (!empty($row)) {
         $oIntervention = new Intervention($userdb);
         foreach ($row as $intervID) {
             $all_query_ok &= $oIntervention->deleteInterventionMaterial($intervID);
             $all_query_ok &= $oIntervention->deleteInterventionWork($intervID);
         }
     }
     //delete from interventions
     $this->core->dbh->query("DELETE FROM intervention WHERE Request_id = '" . $requestId . "'") ? false : ($all_query_ok = false);
     if (!$all_query_ok) {
         LogHelper::write("delete intervention failed", $username);
     }
     //delete from requests
     $this->core->dbh->query("DELETE FROM request WHERE Request_id = '" . $requestId . "'") ? false : ($all_query_ok = false);
     if (!$all_query_ok) {
         LogHelper::write("delete request failed", $username);
     }
     // commit or rollback
     if ($all_query_ok) {
         $this->core->dbh->commit();
         $this->core->dbh->close();
         return TRUE;
     } else {
         $this->core->dbh->rollback();
         $this->core->dbh->close();
         return FALSE;
     }
 }
  */
 $app->post('/intervention/work', function () use($app) {
     //required parameters not empty or 'null'
     $toVerify = array('IntervID', 'Action', 'Date_action', 'Time');
     R::verifyRequiredParams($toVerify);
     $app->add(new \Slim\Middleware\ContentTypes());
     $body = $app->request()->getBody();
     $request = json_decode($body, true);
     $response = array();
     $intervID = $request['IntervID'];
     $action = $request['Action'];
     $date_action = $request['Date_action'];
     $time = $request['Time'];
     //read user db and name from request
     $userdb = R::readDbFromRequest();
     $by_user = R::readUsernameFromRequest();
     //add work
     $oIntervention = new Intervention($userdb);
     $workId = $oIntervention->addWork($intervID, $action, $date_action, $time, $by_user);
     //read old total work
     $oldTotalWork = $oIntervention->getTotalWork($intervID);
     //update new total work as hours (not as minutes)
     $newTotalWork = $oldTotalWork + $time / 60;
     $InUpdated = $oIntervention->updateInterventionWork($intervID, $newTotalWork, $by_user);
     if ($workId != NULL & $InUpdated) {
         $response["error"] = false;
         $response["message"] = "Intervention work created";
         Log::write("Intervention work with ID " . $workId . " created successfully.", $by_user);
         R::echoResponse(201, $response);
     } else {
         $response["error"] = true;
         Log::write("Asset with ID " . $id . " updated successfully.", $by_user);
         R::echoResponse(200, $response);
     } else {
         $response["error"] = true;
         $response["message"] = "Could not update asset";
         Log::write("Could not update Asset with ID " . $id, $by_user);
         R::echoResponse(500, $response);
     }
 });
 /**
  * DELETE route for deleting asset
  *
  */
 $app->delete('/asset/:assetid', function ($assetid) use($app) {
     $userdb = R::readDbFromRequest();
     $username = R::readUsernameFromRequest();
     $oAsset = new Asset($userdb);
     //check if asset exists, if not, throw 404 error.
     $exists = $oAsset->checkIfAssetExists($assetid);
     if (!$exists) {
         $response["error"] = true;
         $response["message"] = "Asset does not exist";
         R::echoResponse(404, $response);
     } else {
         $result = $oAsset->deleteAsset($userdb, $assetid);
         if ($result) {
             $response["error"] = false;
             $response["message"] = "Asset deleted";
             Log::write("Asset " . $assetid . " deleted.", $username);
             R::echoResponse(200, $response);
         } else {