Example #1
0
 public function newAction()
 {
     $this->_form = new Mybase_Form_People();
     $this->view->form = $this->_form;
     $formData = $this->getRequest()->getPost();
     if ($this->_request->isPost()) {
         if ($this->_form->isValid($formData)) {
             $company = new Model_Company();
             empty($formData['idcompany']) ? $formData['idcompany'] = $company->save($formData) : $formData['idcompany'];
             $unodorId = new Model_Login();
             $idlogin = $unodorId->save($formData);
             $formData['idlogin'] = $idlogin;
             $this->_modelUser->save($formData);
             $mail = new Model_Mail();
             $mail->prepare($formData)->generate(Model_Mail::INVITE)->send($formData['email']);
             $salt = 'ofsdmší&;516#@ešěýp-§)údjs861fds';
             $hash = md5($this->{$formData}['idcompany'] . $this->{$formData}['name'] . $this->{$formData}['surname'] . $this->{$formData}['email'] . $salt);
             $this->_flash('New User has been successfully created and E-mailed ***TODO*** - ' . $hash, 'done', true);
             return $this->_redirect('/people');
         } else {
             //$this->_flash('There is an errors in the form', 'error', false);
             $this->_form->populate($formData);
         }
     }
 }