name); Core::addBreadcrumb("/account/customers/$id/edit", $page_title); $submit = http::value("submit"); if($submit) { try { Core::validateCSRFToken($submit); $form_exception = new FormException; $customer->name = http::value("name", "trim"); $customer->address_1 = http::value("address_1", "trim"); $customer->address_2 = http::value("address_2", "trim"); $customer->city = http::value("city", "trim"); $customer->county = http::value("county", "trim"); $customer->postal_code = http::value("postal_code", "trim"); $customer->country = http::value("country", "trim"); $customer->email = http::value("email", "email"); $customer->phone = http::value("phone", "trim"); $customer->invoice_contact_name = http::value("invoice_contact_name", "trim"); $customer->email_after_test = http::value("email_after_test", "int"); $customer->email_locations_after_test = http::value("email_locations_after_test", "int"); $customer->year_cycle_month = http::value("year_cycle_month", "int"); $customer->show_in_map_overview = (int) http::value("show_in_map_overview", "int"); if(empty($customer->name)) $form_exception->addError("Name is required."); if($form_exception->hasErrors()) throw $form_exception; $success = $customer->commit(); Core::addAlert("success", "Customer updated successfully."); HTTP::redirect("/account/customers/$id/edit"); } catch(FormException $e) { $e->generateAlerts(); } catch(Exception $e) { Core::addAlert("danger", $e->getMessage()); } } View::includeOnce("header", compact("page_title")); View::include("customer_form", compact("page_title", "customer")); View::includeOnce("footer");