public function applyAction()
 {
     $this->view->pageTitle = 'Careers';
     if ($this->getRequest()->isPost()) {
         // Handle the cv file and form data
         $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim');
         $validators = array('name' => array('NotEmpty', 'messages' => 'Please enter your name'), 'tel' => array('NotEmpty', 'messages' => 'Please enter your telephone number'), 'email' => array('NotEmpty', 'messages' => 'Please enter your email address'), 'enquiry' => array('NotEmpty', 'messages' => 'Please tell us why this position interests you'));
         $input = new Zend_Filter_Input($filters, $validators, $_POST);
         if ($input->isValid()) {
             $upload = new Zend_File_Transfer();
             // Make sure the file is actually a document
             $upload->clearValidators();
             $upload->setOptions(array('ignoreNoFile' => true));
             //$upload->addValidator('MimeType', false, array('application/msword', 'application/pdf', 'application/rtf', 'text/plain'));
             if ($upload->isValid()) {
                 $params = Zend_Registry::get('params');
                 $uploadPath = $params->cms->fileUploadPath;
                 $upload->setDestination($uploadPath);
                 $upload->receive();
                 $fileInfo = $upload->getFileInfo();
                 $emailer = new Application_Core_Mail();
                 $emailer->setTo($params->email->careers, 'HomeLet');
                 $emailer->setFrom($input->email, $input->name);
                 $emailer->setSubject('HomeLet - Job Application (' . $input->position . ')');
                 $bodyHtml = 'Position : ' . $input->position . '<br />';
                 $bodyHtml .= 'Name : ' . $input->name . '<br />';
                 $bodyHtml .= 'Email : ' . $input->email . '<br />';
                 $bodyHtml .= 'Tel : ' . $input->tel . '<br />';
                 $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />';
                 if ($fileInfo['cv_file']['type'] !== null) {
                     $emailer->addAttachment($fileInfo['cv_file']['destination'] . '/' . $fileInfo['cv_file']['name'], $fileInfo['cv_file']['name']);
                 }
                 $emailer->setBodyHtml($bodyHtml);
                 if ($emailer->send()) {
                     $this->_helper->redirector('thanks', 'careers');
                 } else {
                 }
             } else {
                 // Invalid file type
                 $this->view->errors = array('cv_file' => 'Invalid file type');
                 $this->view->name = $input->name;
                 $this->view->tel = $input->tel;
                 $this->view->email = $input->email;
                 $this->view->enquiry = $input->enquiry;
             }
         } else {
             // Invalid form data
             $this->view->errors = $input->getMessages();
             $this->view->name = $input->name;
             $this->view->tel = $input->tel;
             $this->view->email = $input->email;
             $this->view->enquiry = $input->enquiry;
         }
     }
     $careerUrl = $this->getRequest()->getParam('careerID');
     $careerID = substr($careerUrl, 0, strpos($careerUrl, '-'));
     $careers = new Datasource_Cms_Careers();
     $career = $careers->getById($careerID);
     $this->view->title = $career['title'];
     $this->view->id = $career['id'];
 }