Ejemplo n.º 1
0
 public function actionCompany()
 {
     if (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY && !Yii::app()->user->checkAccess('admin')) {
         throw new CHttpException(403);
     }
     $CompanyForm = new CompanyForm();
     $Company = Yii::app()->getUser()->getProfile()->company;
     if (($data = Yii::app()->getRequest()->getPost('CompanyForm')) !== null) {
         $CompanyForm->setAttributes($_POST['CompanyForm'], false);
         if ($CompanyForm->validate()) {
             $Company->setAttributes($_POST['Company'], false);
             if (($uploadedFile = CUploadedFile::getInstance($CompanyForm, 'logo')) !== null) {
                 $Company->changeLogo($uploadedFile);
             }
             if ($Company->save()) {
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('CabinetModule.default', 'Изменения успешно сохранены!'));
             }
         }
     }
     $this->render('company', ['Company' => $Company, 'CompanyForm' => $CompanyForm]);
 }
Ejemplo n.º 2
0
 protected function processForm(sfWebRequest $request, CompanyForm $form)
 {
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         try {
             $isNew = $form->isNew();
             $company = $form->save();
         } catch (Doctrine_Validator_Exception $e) {
             $this->getUser()->setFlash('error', $e->getMessage());
             return sfView::SUCCESS;
         }
         $this->getUser()->setFlash('success', $isNew ? 'The item has been created successfully' : 'The item has been updated successfully', true);
         if ($request->hasParameter('save_and_add')) {
             $this->redirect('@company_new');
         } else {
             $this->redirect(array('sf_route' => 'company_edit', 'sf_subject' => $company));
         }
     } else {
         $this->getUser()->setFlash('error', 'Please check the values entered in the form', false);
     }
 }
Ejemplo n.º 3
0
 /**
  *
  * @return Application\Form\CompanyForm
  */
 protected function getForm()
 {
     $form = new CompanyForm();
     $submit = new Zend_Form_Element_Submit("send");
     $submit->setLabel($this->i18n->_("Guardar"));
     $form->addElement($submit)->setMethod('post');
     $form->twitterDecorators();
     return $form;
 }
Ejemplo n.º 4
0
 /**
  * @author : ELGUENNUNI Sohaib, s.elguennuni@gmail.com  
  */
 public function addcompanyAction()
 {
     $this->title = 'update Company';
     $form = new CompanyForm();
     $id = $this->_companyMemberModel->getCompany(App_Utilities::getIdMember());
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $data = $form->getValues();
             $fullFilePath = $form->logo->receive();
             $pathparts = pathinfo($form->logo->getFileName());
             $data['logo'] = $pathparts['basename'];
             $this->_companyModel->updateCompany($data, $id);
             $this->_redirect($this->view->url(array('module' => 'frontend', 'controller' => 'profile', 'action' => 'index', 'id' => App_Utilities::getIdMember()), 'default', true));
         } else {
             $form->populate($formData);
         }
     } else {
         $form->populate($this->_companyModel->getCompany($id));
     }
     $this->view->form = $form;
 }