|
|
@@ -0,0 +1,41 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+$page_title = "Add Customer";
|
|
|
+
|
|
|
+Core::addBreadcrumb("/account", "Account");
|
|
|
+Core::addBreadcrumb("/account/customers", "Customers");
|
|
|
+Core::addBreadcrumb("/account/customers/add", $page_title);
|
|
|
+
|
|
|
+$customer = new Customer;
|
|
|
+
|
|
|
+$submit = http::value("submit");
|
|
|
+if($submit) {
|
|
|
+ try {
|
|
|
+ Core::validateCSRFToken($submit);
|
|
|
+
|
|
|
+ $form_exception = new FormException;
|
|
|
+
|
|
|
+ $customer->name = http::value("name", "trim");
|
|
|
+
|
|
|
+ if(empty($customer->name)) $form_exception->addError("Name is required.");
|
|
|
+
|
|
|
+ if($form_exception->hasErrors()) throw $form_exception;
|
|
|
+
|
|
|
+ $success = $customer->commit();
|
|
|
+
|
|
|
+ Core::addAlert("success", "Customer added successfully.");
|
|
|
+ HTTP::redirect("/account/customers");
|
|
|
+ }
|
|
|
+ catch(FormException $e) {
|
|
|
+ $e->generateAlerts();
|
|
|
+ }
|
|
|
+ catch(Exception $e) {
|
|
|
+ Core::addAlert("danger", $e->getMessage());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+View::includeOnce("header", compact("page_title"));
|
|
|
+View::include("customer_add_form", compact("customer"));
|
|
|
+View::includeOnce("footer");
|
|
|
+
|
|
|
+?>
|