예제 #1
0
 public function newAction()
 {
     //$user = $this->_helper->Session->getUserSession();
     $this->checkLogin();
     $form = new PAP_Form_PromotionForm();
     $this->view->form = $form;
     $this->loadPriceRules($this->user);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $data['userId'] = $this->user->getId();
             $data['branches'] = $_POST['branches'];
             $newPromotion = new PAP_Model_Promotion();
             $newPromotion->insert($data);
             $this->saveImages($data, $newPromotion);
             $this->_redirect('promotion/index');
         } else {
             $this->loadUserBranches($this->user);
         }
     } else {
         $this->loadUserBranches($this->user);
     }
     $form->imagePromo->setOptions(array('src' => '/images' . $this->user->getBranch()->getLogo()));
     $form->promoCode->setValue($this->getAutoPromoCode());
     //TODO En la descripcion larga cambiar el estilo
     //TODO Descripcion larga no permite puntos.
 }