Exemplo n.º 1
0
 protected function createComponentAddEdit($name)
 {
     $roles[0] = ' ';
     $mroles = new RolesModel();
     $rows = $mroles->getTreeValues();
     foreach ($rows as $key => $row) {
         // function array_merge does't work correctly with integer indexes
         // manual array merge
         $roles[$key] = $row;
     }
     $form = new NAppForm($this, $name);
     $renderer = $form->getRenderer();
     $renderer->wrappers['label']['suffix'] = ':';
     //$form->addGroup('Add');
     $form->addText('name', 'Name', 30)->addRule(NForm::FILLED, 'You have to fill name.')->getControlPrototype()->onChange("create_key()");
     $form->addText('key_name', 'Key', 30)->addRule(NForm::FILLED, 'You have to fill key.');
     $form->addSelect('parent_id', 'Parent', $roles, 15);
     $form->addTextArea('comment', 'Comment', 40, 4)->addRule(NForm::MAX_LENGTH, 'Comment must be at least %d characters.', 250);
     if ($this->getAction() == 'add') {
         $form->addSubmit('add', 'Add');
     } else {
         $form->addSubmit('edit', 'Edit');
     }
     $form->onSuccess[] = array($this, 'addEditOnFormSubmitted');
 }
Exemplo n.º 2
0
 protected function createComponentAddReference()
 {
     $form = new NAppForm();
     $form->addText('name', 'Jméno reference:');
     $form->addText('client', 'Klient:');
     $form->addText('scale', 'Rozsah:');
     $form->addText('realized', 'Realizováno:');
     $form->addText('url', 'SEO url (v rámci webu):');
     $form->addSelect('typ', 'Typ:', array('web' => "Webová reference", 'adv' => "Reklama"));
     // Reference positions
     $container = $form->addContainer('pos');
     $container->addCheckbox(ReferencesManager::REF_T_UVOD, ' Úvod');
     $container->addCheckbox(ReferencesManager::REF_T_RWEB, ' Reference (webdesign)');
     $container->addCheckbox(ReferencesManager::REF_T_RREK, ' Reference (reklama)');
     $container->addCheckbox(ReferencesManager::REF_T_WEBD, ' Webdesign');
     $container->addCheckbox(ReferencesManager::REF_T_VENK, ' Venkovní reklama');
     $container->addCheckbox(ReferencesManager::REF_T_TISK, ' Tisk');
     $container->addCheckbox(ReferencesManager::REF_T_GRAF, ' Grafika a Design');
     $container->addCheckbox(ReferencesManager::REF_T_PRED, ' Reklamní předměty');
     $container->addCheckbox(ReferencesManager::REF_T_RAZI, ' Razítka');
     $container->addCheckbox(ReferencesManager::REF_T_INZE, ' Inzerce');
     $container->addCheckbox(ReferencesManager::REF_T_FOTO, ' Fotografie');
     $container->addCheckbox(ReferencesManager::REF_T_MARK, ' Marketing');
     // Images
     $size = NEnvironment::getVariable('sizes');
     $form->addFile('pic_1', 'Obr. úvodka (' . $size[0][0] . 'x' . $size[0][1] . '):')->addCondition(NForm::FILLED)->addRule(NForm::MIME_TYPE, 'Obrázek musí být ve formátu JPG, PNG nebo GIF.', 'image/*');
     $form->addFile('pic_2', 'Obr. náhled (' . $size[1][0] . 'x' . $size[1][1] . '):')->addCondition(NForm::FILLED)->addRule(NForm::MIME_TYPE, 'Obrázek musí být ve formátu JPG, PNG nebo GIF.', 'image/*');
     $form->addFile('pic_3', 'Obr. popup: (' . $size[2][0] . 'x' . $size[2][1] . '):')->addCondition(NForm::FILLED)->addRule(NForm::MIME_TYPE, 'Obrázek musí být ve formátu JPG, PNG nebo GIF.', 'image/*');
     $form['pic_1']->getControlPrototype()->class('file');
     $form['pic_2']->getControlPrototype()->class('file');
     $form['pic_3']->getControlPrototype()->class('file');
     $form->addSubmit('addref', 'Uložit');
     $form->onSubmit[] = callback($this, 'addReferenceSubmited');
     return $form;
 }
Exemplo n.º 3
0
 function createComponentBaseForm()
 {
     //	NForm::extensionMethod('NForm::addCBTree', array('CBTree', 'addCBTree'));
     //
     //	$tree = new TreeView;
     //
     //	$tree->primaryKey = 'id_category';
     //	$tree->parentColumn = 'id_parent';
     //	$tree->useAjax = false;
     //	$tree->addLink(null, 'name', 'id', true, $this->presenter);
     //	$tree->dataSource = CategoryModel::getDatasource()->where("id_lang = %i",$this->getPresenter()->id_lang);
     //$form->addCBTree('ctree', _('Kategórie'), $tree);
     $form = new NAppForm();
     $renderer = $form->getRenderer();
     // budeme generovat formulář jako definiční seznam
     $renderer->wrappers['controls']['container'] = NHtml::el('table')->addClass('standard');
     $langs = Setting::getLangs();
     foreach ($langs as $k => $lang) {
         $form->addGroup($lang['name'])->setOption('container', 'fieldset class=lang_fieldset id=lang_' . $lang['iso']);
         $form->addText('name' . self::$_separator . $lang['iso'], _('Názov'))->addRule(NFORM::FILLED, 'Názov ' . $lang['iso'] . ' musí byť vyplnený.');
         $form->addTextArea('description' . self::$_separator . $lang['iso'], 'Popis');
         $form->addText('link_rewrite' . self::$_separator . $lang['iso'], 'URL link')->setDisabled();
         $form->addText('meta_title' . self::$_separator . $lang['iso'], 'Titulok');
         //	    $form->addText('meta_keywords'.self::$_separator.$lang['iso'], 'Kľúčové slová');
         $form->addText('meta_description' . self::$_separator . $lang['iso'], 'Meta popis');
     }
     //$form->addText('icon','Názov ikony');
     $form->addCheckbox('show_on_bottom', 'Zobraziť v spodnej časti');
     $form->addGroup('');
     $form->addHidden('id_category');
     $c = new CategoryModel($this->getPresenter()->id_lang);
     $select = array('' => 'root');
     /*
      * todo dorobit, aby sa nedala vybrat samu seba categoria
      */
     $c->generateTreeToSelect($select, NULL, NULL);
     $form->addSelect('id_parent', 'Rodič', $select);
     //		->addRule(NForm::FILLED, _('Rodič musí byť vyplnený.') );
     $form->addSelect('active', 'Aktívny', array(1 => 'Povolený', 0 => 'Zakázaný'));
     $form->onSuccess[] = array($this, 'categoryAction');
     return $form;
 }
Exemplo n.º 4
0
 protected function createComponentGroupForm($id = 0)
 {
     $this->events = $this->getService('model')->getEvents();
     $form = new NAppForm();
     $form->addText('name', 'Name of the group:')->setRequired('Please provide a name.');
     $events = $this->events->fetchPairs('id', 'name');
     $form->addSelect('eventID', 'Group in event', $events)->setDefaultValue((int) $this->getParam('id'));
     $form->addSubmit('send', 'Create');
     $form->onSuccess[] = callback($this, 'groupFormSubmitted');
     return $form;
 }
Exemplo n.º 5
0
 protected function createComponentTeamForm()
 {
     $events = $this->getService('model')->getEvents();
     $groups = array();
     foreach ($events as $event) {
         $g = $this->getService('model')->getGroups()->where('eventID', $event->id);
         $o = array();
         foreach ($g as $group) {
             $o[$group->id] = $group->name;
         }
         $groups[$event->name] = $o;
     }
     $form = new NAppForm();
     $form->addText('name', 'Name of the team:')->setRequired('Please provide a name.');
     $select = $form->addSelect('groupID', 'Group:', $groups)->setDefaultValue((int) $this->getParam('id'));
     $form->addSubmit('send', 'Create');
     $form->onSuccess[] = callback($this, 'teamFormSubmitted');
     return $form;
 }
Exemplo n.º 6
0
 protected function createComponentAddEdit($login)
 {
     $mroles = new RolesModel();
     $roles = $mroles->getTreeValues();
     $form = new NAppForm($this, $login);
     $renderer = $form->getRenderer();
     $renderer->wrappers['label']['suffix'] = ':';
     //$form->addGroup('Add');
     $form->addText('login', 'login', 30)->addRule(NForm::FILLED, 'You have to fill login.');
     $form->addSelect('activate', 'Aktivovany', array('1' => 'ano', 0 => 'nie'));
     //        if ($this->getAction()=='add') {
     $form->addPassword('password', 'Password', 30)->addRule(NForm::FILLED, 'You have to fill password.');
     $form->addPassword('password2', 'Reenter password', 30)->addRule(NForm::FILLED, 'Reenter your password.')->addRule(NForm::EQUAL, 'Passwords do not match.', $form['password']);
     //        }
     $form->addMultiSelect('roles', 'Roles', $roles, 15);
     if ($this->getAction() == 'add') {
         $form->addSubmit('add', 'Add');
     } else {
         $form->addSubmit('edit', 'Edit');
     }
     $form->onSuccess[] = array($this, 'addEditOnFormSubmitted');
 }
Exemplo n.º 7
0
 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;
     }
 }