Exemplo n.º 1
0
 /**
  * @access protected
  * @global array $registry
  * @return render Add Employee Template & Add Employee
  */
 protected function add()
 {
     global $registry;
     if (isset($_GET['name']) && isset($_GET['email'])) {
         $employee = array('name' => $_GET['name'], 'email' => $_GET['email']);
         $this->registry['template']->data('employee', $employee);
         $validate = new Form();
         $set_name = $validate->validateText($employee['name']);
         $set_email = $validate->validateEmail($employee['email']);
         if (!$set_name) {
             $this->registry['template']->data('set_name', $set_name);
         }
         if (!$set_email) {
             $this->registry['template']->data('set_email', $set_email);
         }
         if ($set_name && $set_email) {
             $employee_object = new Employees();
             if ($employee_object->insertEmployee($_GET['name'], $_GET['email'])) {
                 return $this->added($_GET['name']);
             } else {
                 return $this->failed();
             }
         }
     }
     $this->registry['template']->data('title', 'Add Employee');
     $this->registry['template']->render('header');
     $this->registry['template']->data('action', 'Add');
     $this->registry['template']->render('employee/edit');
     $this->registry['template']->render('footer');
 }