Example #1
0
 public function reset()
 {
     if ($this->view->hasResetFormBeenPosted()) {
         try {
             $this->CustomerCatalogue->resetCustomerDatabase();
         } catch (\Exception $e) {
             $this->view->setErrorMessage($e);
         }
         if ($this->CustomerCatalogue->wasCustomerDatabaseSuccessfullyReset()) {
             $this->view->setSuccessResetMessage();
             // Redirect to customer listing
             $controller = new CCustomer($this->db);
             $nav = new \Toeswade\Navigation\NavItem('Customers', 'customers', $controller, 'read');
             \Toeswade\Navigation\VNavigation::redirectTo($nav);
         }
     }
     $this->view->resetForm();
     return $this->view;
 }
Example #2
0
 public function listAllCustomers(array $catalogue)
 {
     $message = $this->getMessage();
     $html = '<table><thead><tr><th>Name</th><th>Surname</th><th>Telephone</th><th>Email</th><th>Edit</th><th>Delete</th></tr></thead><tbody>';
     foreach ($catalogue as $key => $customer) {
         assert($customer instanceof Customer);
         $editLink = \Toeswade\Navigation\VNavigation::createActionLink('update', $customer->getId());
         $deleteLink = \Toeswade\Navigation\VNavigation::createActionLink('delete', $customer->getId());
         $html .= '<tr>';
         $html .= '<td>' . $customer->getName() . '</td>';
         $html .= '<td>' . $customer->getSurname() . '</td>';
         $html .= '<td>' . $customer->getTelephone() . '</td>';
         $html .= '<td>' . $customer->getEmail() . '</td>';
         $html .= '<td><a href="' . $editLink . '" title="Edit this customer">Edit</a></td>';
         $html .= '<td><a href="' . $deleteLink . '" title="Delete this customer">Delete</a></td>';
         $html .= '<tr>';
     }
     $html .= '</tbody></table>';
     // Set page title
     $this->pageTitle = 'List customers';
     // Set HTML
     $this->HTML = $message . $html;
 }