Beispiel #1
0
 /**
  * @access protected
  * @return render template edit & update Employee info
  */
 protected function edit()
 {
     $employee_object = new Employees();
     $employee = $employee_object->getEmployee($_GET['employee_id']);
     if (!$employee) {
         return $this->failed();
     }
     if (isset($_GET['name']) && $_GET['email']) {
         $employee = array('name' => $_GET['name'], 'email' => $_GET['email']);
         $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) {
             if ($employee_object->updateEmployee($_GET['employee_id'], $_GET['name'], $_GET['email'])) {
                 return $this->changed($_GET['name']);
             } else {
                 return $this->failed();
             }
         }
     }
     $this->registry['template']->data('title', 'Employee ' . $employee['name']);
     $this->registry['template']->render('header');
     $this->registry['template']->render('header');
     $this->registry['template']->data('employee', $employee);
     $this->registry['template']->data('action', 'Edit');
     $this->registry['template']->render('employee/edit');
 }