public function addEditOnFormSubmitted(NAppForm $form) { // add if ($this->getAction() == 'add') { try { $values = $form->getValues(); dibi::query('INSERT INTO [' . TABLE_PRIVILEGES . '] %v;', $values); $this->flashMessage('The privileg has been added.', 'ok'); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Privileges:'); } catch (Exception $e) { $form->addError('The privileg has not been added.'); throw $e; } } else { // edit try { $id = $this->getParam('id'); $values = $form->getValues(); dibi::query('UPDATE [' . TABLE_PRIVILEGES . '] SET %a WHERE id=%i;', $values, $id); $this->flashMessage('The privileg has been edited.', 'ok'); if (ACL_CACHING and ACL_PROG_MODE) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Privileges:'); } catch (Exception $e) { $form->addError('The privileg has not been edited.'); throw $e; } } }
public function newsFormSubmited(NAppForm $form) { if ($form['addnews']->isSubmittedBy()) { $values = $form->getValues(); $id = (int) $this->getParam('id'); $ref = new News(array('id' => $id)); if ($id > 0) { $ref->update($id, $values); } else { $ref->insert($values); } $this->flashMessage('Novinka uložena.'); } $this->redirect('News:default'); }
/** * Send contact form * @return void */ public function popFormSubmited(NAppForm $form) { if ($form['popsend']->isSubmittedBy()) { $values = $form->getValues(); $this->invalidateControl('popup'); $this->template->poptavka = $this->thankYou(); $body = $values['body'] . "\n\nKontakt: " . $values['contact']; $addTo = $this->getPerson($values['id']); $addTo = $addTo['email']; $mail = new NMail(); $mail->setFrom('Firemni web <*****@*****.**>'); $mail->addTo($addTo); //$mail->addTo('*****@*****.**'); $mail->setSubject('Zprava z firemniho webu'); $mail->setBody($body); $mail->send(); } }
public function addEditOnFormSubmitted(NAppForm $form) { // add action if ($this->getAction() == 'add') { try { $values = $form->getValues(); if ($values['parent_id'] == 0) { $values['parent_id'] = NULL; } dibi::query('INSERT INTO [' . TABLE_ROLES . '] %v;', $values); $this->flashMessage('The role has been added.', 'ok'); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Roles:'); } catch (Exception $e) { $form->addError('The role has not been added.'); throw $e; } } else { // edit action try { $id = $this->getParam('id'); $values = $form->getValues(); if ($values['parent_id'] == 0) { $values['parent_id'] = NULL; } dibi::query('UPDATE [' . TABLE_ROLES . '] SET %a WHERE id=%i;', $values, $id); $this->flashMessage('The role has been edited.', 'ok'); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Roles:'); } catch (Exception $e) { $form->addError('The role has not been edited.'); throw $e; } } }
public function addEditOnFormSubmitted(NAppForm $form) { // Permission form submitted $id = $this->getParam('id'); $values = $form->getValues(); // add if (!$id) { $error = FALSE; dibi::begin(); try { foreach ($values['privilege_id'] as $privi) { foreach ($values['resource_id'] as $resou) { foreach ($values['role_id'] as $role) { if ($resou == '0') { $resou = NULL; } if ($privi == '0') { $privi = NULL; } dibi::query('INSERT INTO [' . TABLE_ACL . '] (role_id, privilege_id, resource_id, access) VALUES (%i, %i, %i, %s);', $role, $privi, $resou, (bool) $values['access']); } } } dibi::commit(); $this->flashMessage('Permission was successfully assigned.', 'ok'); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Permission:'); } catch (Exception $e) { $error = FALSE; $form->addError('Permission was not successfully assigned.'); throw $e; } if ($error) { dibi::rollback(); } } else { // edit try { $values['access'] = (bool) $values['access']; dibi::query('UPDATE [' . TABLE_ACL . '] SET %a WHERE id=%i;', $values, $id); $this->flashMessage('Permission was successfully edited.', 'ok'); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Permission:'); } catch (Exception $e) { $form->addError('Permission was not successfully edited.'); throw $e; } } }
public function vyhledatFormSubmitted(NAppForm $form) { $values = $form->getValues(); $this->presenter->redirect('Vyhledat:default', array('text' => $values['vyhledat'])); }
function handleSendReference(NAppForm $form) { $values = $form->getValues(); $product = ProductModel::get($values['id_product'], 1); if (!$product) { $this->getPresenter()->flashMessage('Pre daný produkt nemôžete odoslať referenciu.'); $this->getPresenter()->redirect('this'); } $template = $this->template; $template->setFile(dirname(__FILE__) . '/ReferenceEmail.phtml'); $template->product_name = $product['name']; $template->v = $values; $mail = new MyMail(); $mail->addTo(NEnvironment::getVariable('client_email')); $mail->setSubject(_('Pridanie referencie ')); $mail->setTemplate($template); $mail->send(); $this->getPresenter()->flashMessage('Referencia bola úspešne odoslaná.'); $this->getPresenter()->redirect('this'); }
public function addEditOnFormSubmitted(NAppForm $form) { $error = false; dibi::begin(); // add action if ($this->getAction() == 'add') { try { $values = $form->getValues(); $roles = $values['roles']; unset($values['password2'], $values['roles']); // $values['password'] = md5($values['password']); // dibi::query('INSERT INTO ['.TABLE_USERS.'] %v;', $values); $user_id = UserModel::insert($values); if (count($roles)) { foreach ($roles as $role) { dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $user_id, $role); } } $this->flashMessage('The user has been added.', 'ok'); dibi::commit(); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Users:'); } catch (Exception $e) { $error = true; $form->addError('The user has not been added.'); throw $e; } } else { // edit action $id = $this->getParam('id'); try { $values = $form->getValues(); $roles = $values['roles']; unset($values['roles']); unset($values['password2']); // dibi::query('UPDATE ['.TABLE_USERS.'] SET %a WHERE id=%i;', $values, $id); UserModel::update($id, $values); dibi::query('DELETE FROM [' . TABLE_USERS_ROLES . '] WHERE user_id=%i;', $id); if (count($roles)) { foreach ($roles as $role) { dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $id, $role); } } $this->flashMessage('The user has been edited.', 'ok'); dibi::commit(); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Users:'); } catch (Exception $e) { $error = true; $form->addError('The user has not been edited.'); throw $e; } } if ($error) { dibi::rollback(); } }
function createComponent($name) { switch ($name) { case 'statusForm': $f = new NAppForm($this, $name); $renderer = $f->getRenderer(); $renderer->wrappers['pair']['container'] = ''; $renderer->wrappers['controls']['container'] = ''; $renderer->wrappers['control']['container'] = ''; $renderer->wrappers['label']['container'] = ''; $f->addSelect('order_status', 'Stav: ', OrderModel::getStatus()); $f->addSubmit('btn_submit', 'Uložiť'); $o = OrderModel::get($this->getParam('id')); $f->setDefaults($o); if ($f->isSubmitted() and $f->isValid()) { $values = $f->getValues(); OrderModel::updateStatus($this->getParam('id'), $values['order_status']); $o = OrderModel::get($this->getParam('id')); $template = $this->template; $template->setFile(APP_DIR . '/FrontModule/templates/Order/OrderChangeStatusEmail.phtml'); //print_r($o); $template->o = $o; $template->status = OrderModel::getStatus($o['order_status']); // echo $template->status;exit; $mail = new MyMail(); $mail->addTo($o['email']); $mail->addBcc(NEnvironment::getVariable('client_email')); $mail->setSubject(_('Objednávka č. ') . $o['id_order'] . ' zmena stavu.'); $mail->setTemplate($template); //echo $template;exit; $mail->send(); $this->flashMessage('Bol odoslaný email o zmene statusu.'); $this->redirect('this'); } return $f; break; case 'orderTabella': $grid = new Tabella(OrderModel::getDatasource(), array('sorting' => 'desc', 'order' => 'id_order')); $grid->addColumn("Číslo obj.", "id_order", array("width" => 50)); $grid->addColumn("Meno", "name", array("width" => 100)); $grid->addColumn("Priezvisko", "surname", array("width" => 100)); $grid->addColumn("Mesto", "city", array("width" => 100)); $grid->addColumn("Dátum vytvorenia", "add_date", array("width" => 100)); $grid->addColumn("Celková cena", "total_price", array("width" => 100)); $grid->addColumn("Stav", "order_status", array("width" => 50, 'type' => Tabella::SELECT, "editable" => true, "filter" => OrderModel::getStatus(), 'renderer' => function ($row) { $el = NHtml::el("td")->setHtml(OrderModel::getStatus($row['order_status'])); return $el; })); $grid->addColumn("Spôsob platby", "payment_method", array("width" => 90, 'type' => Tabella::SELECT, "editable" => false, "filter" => OrderModel::getPaymentMethod(), 'renderer' => function ($row) { $el = NHtml::el("td")->setHtml(OrderModel::getPaymentMethod($row['payment_method'])); return $el; })); $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) { $el = NHtml::el("td"); /* * link na zmazanie produktu */ $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteOrder!', array('id' => $row->id_order)))->addClass('deleteIcon')); /* * link na editaciu produktu */ $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('view', array('id' => $row->id_order)))->addClass('editIcon')); /* * ikona aktivan polozka, neaktivan polozka */ $span = NHtml::el('span'); $el->add($span); return $el; })); $this->addComponent($grid, $name); break; default: return parent::createComponent($name); break; } }
/** TODO - upload a mazani souboru je fungujici, ale napsano naprosto zmatecne */ public function addReferenceSubmited(NAppForm $form) { if ($form['addref']->isSubmittedBy()) { $values = $form->getValues(); $size = NEnvironment::getVariable('sizes'); $id = (int) $this->getParam('id'); $ref = new Reference(array('id' => $id)); // (Re)upload files if ($this->newImage($values['pic_1'], $size[0])) { $ref->unlinkFile($ref->getFilename('pic_1')); } else { unset($values['pic_1']); } if ($this->newImage($values['pic_2'], $size[1])) { $ref->unlinkFile($ref->getFilename('pic_2')); } else { unset($values['pic_2']); } if ($this->newImage($values['pic_3'], $size[2])) { $ref->unlinkFile($ref->getFilename('pic_3')); } else { unset($values['pic_3']); } // Read checkboxes and create position mask $position_mask = 0; foreach ($values['pos'] as $key => $value) { if ($value) { $position_mask += $key; } } $values['pos'] = $position_mask; // Update or add new? if ($id > 0) { $ref->update($id, $values); } else { // Change sort of old items $ref->typ = $values['typ']; $this->model->resortAfterAdd($ref); $ref->insert($values); } $this->flashMessage('Refernce vložena.'); } $this->redirect('References:default'); }
public function kontrolaMailu(NAppForm $form) { $values = $form->getValues(); if ($values->email && !$this->osobyRepository->zkontrolovatDostupnostMailu($values->email)) { $form->addError('Shodnou e-mailovou adresu může mít maximálně 5 osob. Zadejte jinou adresu.'); } }