private function _add()
 {
     use_helper('Validate');
     $data = $_POST['facilities'];
     Flash::set('facilities_postdata', $data);
     // Add pre-save checks here
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'facilities/add')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('facilities/add'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('facilities/add'));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a facilities name!'));
         redirect(get_url('facilities/add'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('facilities/add'));
     }
     $new_facilities = new Facilities($data);
     $new_facilities->created_by_id = AuthUser::getId();
     $new_facilities->created_on = date('Y-m-d H:i:s');
     if ($new_facilities->save()) {
         if (isset($_FILES)) {
             if (strlen($_FILES['upload_file']['name']) > 0) {
                 $facilities_id = $new_facilities->lastInsertId();
                 $overwrite = false;
                 $file = $this->upload_pdf_file($facilities_id, $_FILES['upload_file']['name'], FILES_DIR . '/facilities/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
                 if ($file === false) {
                     Flash::set('error', __('File has not been uploaded!'));
                 }
                 redirect(get_url('facilities/edit/' . $new_facilities->id));
             }
         }
         Flash::set('success', __('Facilities has been added!'));
         Observer::notify('facilities_after_add', $new_facilities->name);
         // save and quit or save and continue editing?
         if (isset($_POST['commit'])) {
             redirect(get_url('facilities'));
         } else {
             redirect(get_url('facilities/edit/' . $new_facilities->id));
         }
     } else {
         Flash::set('error', __('Facilities has not been added!'));
         redirect(get_url('facilities/add'));
     }
 }