}); // EDIT Customer POST $app->post('/customer/edit', function ($request, $response) { $data = $request->getParsedBody(); $customer_data = []; $customer_data['CustomerNumber'] = filter_var($data['id'], FILTER_SANITIZE_STRING); $customer_data['Name'] = filter_var($data['name'], FILTER_SANITIZE_STRING); $customer_data['Address'] = filter_var($data['address'], FILTER_SANITIZE_STRING); $customer_data['Telephone'] = filter_var($data['phone'], FILTER_SANITIZE_STRING); $customer_mapper = new CustomerMapper($this->db); $customer = $customer_mapper->getCustomerById($customer_data['CustomerNumber']); $this->logger->info("Updating customer " . $customer->getName()); $customer->setName($customer_data['Name']); $customer->setAddress($customer_data['Address']); $customer->setPhoneNumber($customer_data['Telephone']); $customer_mapper->update($customer); $response = $response->withRedirect("/index.php/customers"); return $response; }); // Delete Customer $app->get('/customer/{id}/delete', function ($request, $response, $args) { $customer_id = (int) $args['id']; $customer_mapper = new CustomerMapper($this->db); $customer = $customer_mapper->getCustomerById($customer_id); $this->logger->info("Customer retrieved " . $customer->getName()); $customer_mapper->delete($customer); $response = $response->withRedirect("/index.php/customers"); return $response; }); /**********************DEPARTMENTS**********************/ // Departments