function handleChangePrice(NFORM $form)
 {
     $values = $form->getValues();
     $id_category = $this->getParam('id_category');
     $coeficient = $values['coeficient'];
     if (!is_numeric($id_category)) {
         $form->addError('Nie je vybraná kategória');
         return $form;
     }
     if ($coeficient == 0) {
         $form->addError('Koeficient nesmie byť nula.');
         return $form;
     }
     $list = dibi::fetchAll("\n\t\t\t\tSELECT\n\t\t\t\tproduct_param.id_product_param,\n\t\t\t\tproduct_param.price\n\t\t\t\tFROM\n\t\t\t\t\t[category_product]\n\t\t\t\t\tJOIN [product_param] USING(id_product)\n\t\t\t\tWHERE\n\t\t\t\t\tid_category = %i", $id_category);
     foreach ($list as $l) {
         $arr = array('price' => round($l['price'] * $coeficient));
         dibi::query("UPDATE [product_param] SET ", $arr, "WHERE id_product_param = %i", $l['id_product_param']);
     }
 }
Exemple #2
0
 public function onSubmitAuthenticate(NFORM $form)
 {
     $values = $form->getValues();
     $this->invalidateControl();
     $user = $this->getPresenter()->user;
     try {
         //			$user->setExpiration ( '+ 30 days', FALSE );
         $user->login($values['login'], $values['password']);
         $form->setValues(array(), TRUE);
         if ($values['backlink'] != '') {
             $this->getPresenter()->redirectUrl($values['backlink']);
         } else {
             $this->getPresenter()->redirect('this');
         }
     } catch (NAuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
Exemple #3
0
 function onSubmitAuthenticate(NFORM $form)
 {
     $values = $form->getValues();
     $this->invalidateControl('login');
     $this->invalidateControl('minilogin');
     //		$this->invalidateControl('classs');
     $user = NEnvironment::getUser();
     try {
         $user->setExpiration('+ 2 days', FALSE);
         //			$user->setAuthenticationHandler ( new UserModel() );
         $user->login($values['login'], $values['password']);
         $form->setValues(array(), TRUE);
         if ($values['backlink'] != '') {
             $this->getPresenter()->redirectUrl($values['backlink']);
         } else {
             //$this->getPresenter()->redirect('this');
         }
     } catch (NAuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
 function saveRegistration(NFORM $form)
 {
     $values = (array) $form->getValues();
     $user = UserModel::getFluent(false)->where(' login = %s', $values['login'])->fetch();
     try {
         if ($user and $user['login'] == $values['login']) {
             throw new InvalidStateException(_('Uživateľ pod týmto prihlasovacím meno už existuje.'));
         }
         //			if($user AND $user['email'] == $values['email'])
         //				throw new InvalidStateException( _('Emailová adresa sa už nachádza v databáze. ') );
         //
         unset($values['passwordCheck']);
         unset($values['terms_and_conditions']);
         $values['activate'] = 1;
         //registrovany dostane automaticky 2% zlavu
         $values['discount'] = 2;
         UserModel::insert($values);
         $this->flashMessage("Registrácia je dokončená, účet aktivovaný a ste prihlásený na stránke.");
         $template = clone $this->template;
         $template->setFile(APP_DIR . '/FrontModule/templates/Profil/registrationConfirmEmail.phtml');
         $template->values = $values;
         $mail = new MyMail();
         $mail->addTo($values['login']);
         $mail->addBcc(NEnvironment::getVariable('error_email'));
         $mail->setSubject(_('Informácie o účte'));
         $mail->setTemplate($template);
         $mail->send();
         $this->user->login($values['login'], $values['password']);
         if ($this->backlink != '') {
             $this->restoreRequest($this->backlink);
         } else {
             $this->redirect('Homepage:default');
         }
     } catch (InvalidStateException $e) {
         $form->addError($e->getMessage());
         //			throw $e;
     }
 }