public function wijzigAction() { if ($this->request->isPost()) { // get the value form input fields $begintijd = $this->request->getPost("begintijd"); $id = $this->request->getPost("id"); $datum = $this->request->getPost("datum"); $medewerker = $this->request->getPost("gebruiker_id"); $behandeling = $this->request->getPost("behandeling_id"); // check for duplicate appointments $checkafspraak = Afspraak::findFirst(["begintijd = :begintijd: AND datum = :datum: AND gebruiker_id = :gebruiker_id: AND id != :id:", "bind" => ["begintijd" => $begintijd, "datum" => $datum, "gebruiker_id" => $medewerker, "id" => $id]]); if ($checkafspraak) { // display message appointment already taken $this->response->redirect('admin/detail/' . $id); $this->flash->error("deze combiniatie van datum, begintijd en medewerker is al bezet"); } else { $afspraak = Afspraak::findFirstById($id); if (!$afspraak) { echo "afspraak does not exist"; die; } // set input values equal to a row in the table $afspraak->datum = $datum; $afspraak->begintijd = $begintijd; $afspraak->behandeling_id = $behandeling; $afspraak->gebruiker_id = $medewerker; // update selected appointment $result = $afspraak->update(); if (!$result) { $output = []; foreach ($afspraak->getMessages() as $message) { $output[] = $message; } $output = implode("<br><br>", $output); // display invalid input form user $this->flash->error($output); $this->response->redirect('admin/detail/' . $id); return; } $this->response->redirect('admin/overzicht'); } } }
public function overzichtAction() { Tag::setTitle("Mijn afspraken"); // use session variable $user = $this->session->get('auth'); $rol = $user['rol']; $id = $user['id']; // display appointments where id equals session id from logged user $afspraak = Afspraak::find(["klant_id = '" . $id . "'\n "]); if ($rol != "user") { $this->response->redirect("account/index"); } $this->view->setVar('afspraak', $afspraak); }