function createComponentForm($name)
 {
     $f = new MyForm();
     $f->addHidden('id_product_template_group');
     $f->addGroup('Nastavenie skupiny');
     $f->addText('group_name', 'Názov skupiny')->addRule(NForm::FILLED, 'Názov skupiny musí byť vyplnený');
     $f->addCheckbox('default', 'Predvolená skupina?');
     $f->addCheckbox('allow_change_price', 'Možnosť meniť cenu pre jednotlivé parametre?');
     $f->addGroup('Parametre');
     $rows = $this->model->getProductParamRows();
     foreach ($rows as $k => $r) {
         $f->addCheckbox($r, $r);
     }
     $f->addGroup('');
     $f->addSubmit('btn', 'Uložiť');
     $f->onSuccess[] = array($this, 'handleSave');
     return $f;
 }
 protected function createComponentSettingForm($name)
 {
     $article = $this->getService('Article');
     $f = new MyForm();
     $f->addGroup('Nastavenie eshopu');
     $f->addSelect('SHOP_ENABLE', 'Zapnúť obchod', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     $f->addSelect('SHOW_PRICE_WITH_TAX', 'Cena sa bude zadávať i zobrazovať s DPH?', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     $f->addSelect('SHOW_TAX_FOR_PRODUCT', 'Zobraziť priradenie dane pri produkte', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     //		$f->addSelect('SHOW_PRICE_WITH_DPH', 'Cena sa zobraz s DPH', array(0=>'nie', 1=>'áno'))
     //			->addRule( NForm::FILLED, 'Musí byť vyplené');
     $f->addSelect('CONDITIONS_CMS_ID', 'Obchodné podmienky, použitie CMS stránky', $article->getFluent()->fetchPairs('id_node', 'title'));
     $f->addTextArea('footer_for_emails', 'Pätička pre emaili')->getControlPrototype()->style = "width:700px;";
     $f->addGroup('Heureka');
     $f->addSelect('HEUREKA__ENABLE', 'Spustiť heureku', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     $f->addText('HEUREKA__API_KEY', 'API KEY');
     $f->addGroup('Facebook');
     $f->addSelect('FACEBOOK__AUTH_ENABLE', 'Povoliť Facebook prihlasovanie', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     //twitter.consumer_key = JD4NBeGvlkEomwmaYYlIQ
     //twitter.consumer_secret = WgRwndqR3oA6hShLk43mnQVTpcJvvY9Lmsfe45WNXw
     //
     //google.client_id = 924141147825.apps.googleusercontent.com
     //google.client_secret = G1SSmJ0efgD69eKP43D04FEd
     //google.redirect_url = "http://www.propagacnepredmety.sk/google-account/log-in/"
     $f->addText('FACEBOOK__appId', 'appId');
     $f->addText('FACEBOOK__secret', 'secret');
     $f->addGroup('Google Account');
     $f->addSelect('GOOGLE__AUTH_ENABLE', 'Povoliť Google prihlasovanie', array(0 => 'nie', 1 => 'áno'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     $f->addText('GOOGLE__client_id', 'client_id');
     $f->addText('GOOGLE__client_secret', 'client_secret');
     $f->addText('GOOGLE__application_name', 'application_name');
     $f->addText('GOOGLE__redirect_url', 'redirect_url');
     $f->addGroup('Google Analytics');
     $f->addText('GOOGLE_ANALYTICS__ID', 'ID');
     $f->addGroup('Doprava');
     //		$f->addSelect('DELIVERY_IS_WITH_TAX', 'Doprava je už s danou?', array(0=>'nie', 1=>'áno'))
     //			->addRule( NForm::FILLED, 'Musí byť vyplené');
     $vat = VatModel::init();
     $f->addSelect('DELIVERY_TAX', 'Dan na dopravu?', $vat->getFluent()->fetchPairs('value', 'name'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     $f->addGroup('Platby');
     $vat = VatModel::init();
     $f->addSelect('PAYMENT_TAX', 'Dan na platbu?', $vat->getFluent()->fetchPairs('value', 'name'))->addRule(NForm::FILLED, 'Musí byť vyplené');
     $f->addGroup();
     $f->addSubmit('btn', 'Uložiť');
     $f->onSuccess[] = array($this, 'handleSaveSetting');
     $f->setDefaults($this->getService('Setting')->fetchPairs());
     return $f;
 }
Exemple #3
0
 /**
  * Form to add a topic
  *
  * @access protected
  * @return Nette\Application\UI\Form
  * @since 1.0.0
  */
 protected function createComponentForumForm()
 {
     $form = new MyForm();
     $form->addGroup(!$this->forumTopicId ? 'Topic' : 'Reply to topic');
     $form->addText('name', 'Name:', 50, 40)->addRule($form::FILLED, 'Name must be filled.');
     if (!$this->forumTopicId) {
         $form->addText('title', 'Title:', 50, 100)->addRule($form::FILLED, 'Title must be filled.');
     }
     $form->addTextArea('topic', 'Comment:', 87, 5)->addRule($form::FILLED, 'Comment must be filled.');
     $form->addProtection('Security token did not match. Possible CSRF attack.');
     $form->addSubmit('insert', 'Insert');
     $form->onSuccess[] = callback($this, 'forumFormSubmitted');
     return $form;
 }
 function createComponent($name)
 {
     switch ($name) {
         //	    case 'addForm':
         //			$form = $this->baseForm();
         //			$form->addSubmit('btn', 'Pridať');
         ////			$values['product_alternative'] = ProductModel::getFluent($this->id_lang)->where('id_category = 5')->fetchPairs("id_product",'id_product');
         //			//poziadavka klienta - zobrat vsetky produkty z doplnkov
         //
         //
         //			$form->setDefaults( array('id_product_template_group'=>$this->getService('ProductTemplateGroupModel')->getIdDefaultTemplate()) );
         //
         //
         //			$form->onSuccess[] = callback($this, 'add');
         //			return $form;
         //		break;
         case 'editForm':
             $id_product = $this->getPresenter()->getParam('id');
             $form = $this->baseForm();
             $form['id_product']->setValue($id_product);
             $values = array();
             //Titulok 	- doplnit categoria+ nazov produktu
             //Kľúčové slová -
             //Meta popis - doplnit categoria+ nazov produktu  + Výkon + Dĺžka Horenia
             foreach ($this->template->langs as $l) {
                 $val = ProductModel::get($id_product, $l['id_lang']);
                 // ziste ktore komponenty maju jazykovu mutaciu
                 $controls_for_lang = array();
                 foreach ($form->getComponents() as $control) {
                     if (strpos($control->getName(), CategoryFormControl::$_separator)) {
                         if (strpos($control->getName(), CategoryFormControl::$_separator . $l['iso'])) {
                             list($val_key) = explode(CategoryFormControl::$_separator . $l['iso'], $control->getName());
                             $values += array($control->getName() => $val[$val_key]);
                         }
                     } else {
                         if (isset($val[$control->getName()])) {
                             $values += array($control->getName() => $val[$control->getName()]);
                         }
                     }
                 }
             }
             //print_r(ProductModel::getProductAlternative($id_product));exit;
             $values['product_alternative'] = ProductModel::getProductAlternative($id_product);
             // vyriesenie categorii
             //nacitanie prveho parametru - iba pre jednoparametrove produkty
             $param = (array) dibi::fetch("SELECT * FROM [product_param] WHERE id_product = %i", $id_product);
             $form->setDefaults(array_merge($param, $values));
             $form->addSubmit('btn_save_and_stay', 'Upraviť a zostať tu');
             $form->addSubmit('btn_save', 'Upraviť');
             $form->onSuccess[] = callback($this, 'save');
             return $form;
             break;
             /*
              * generator
              */
         /*
          * generator
          */
         case 'generatorForm':
             //ProductModel::repairMinPrice();
             NFormContainer::extensionMethod('NFormContainer::addCheckboxList', array('CheckboxList', 'addCheckboxList'));
             $sizes = dibi::query("SELECT size FROM [product_param] WHERE size !='' GROUP BY size")->fetchPairs('size', 'size');
             $colors = dibi::query("SELECT color FROM [product_param] WHERE color !='' GROUP BY color")->fetchPairs('color', 'color');
             $materials = dibi::query("SELECT material FROM [product_param] WHERE material !='' GROUP BY material")->fetchPairs('material', 'material');
             $f = new MyForm();
             //			$f->getElementPrototype()->addClass('ajax');
             $renderer = $f->getRenderer();
             $renderer->wrappers['controls']['container'] = NHtml::el('div')->addClass('container');
             $renderer->wrappers['pair']['container'] = NHtml::el('div')->addClass('pair-container');
             $renderer->wrappers['label']['container'] = NHtml::el('h3');
             $renderer->wrappers['control']['container'] = NHtml::el('div')->addClass('input-container');
             //			usort($sizes, 'EshopProductControl::cmp');
             $f->addCheckboxList('size', 'Veľkosť', $sizes);
             $f->addCheckboxList('color', 'Farba', $colors);
             $f->addCheckboxList('material', 'Material', $materials);
             //ak je pridavanie a neexistuje id
             $f->addHidden('id_product', $this->getParam('id'));
             //
             //
             //			$renderer = $f->getRenderer();
             //			$renderer->wrappers['label']['container'] = NULL;
             //
             //			//ziskaj vsetky mozne velkosti
             //			$sizes = dibi::fetchAll("SELECT size FROM [product_param] GROUP BY size");
             //			$f->addGroup('Veľkosť');
             //			foreach($sizes as $k=>$size){
             //				$f->addCheckbox('size_'.$k, $size['size']);
             //			}
             //
             //			//ziskaj vsetky mozne farby
             //			$colors = dibi::fetchAll("SELECT color FROM [product_param] GROUP BY color");
             //			$f->addGroup('Farba');
             //			foreach($colors as $k=>$color){
             //				$f->addCheckbox('color_'.$k, $color['color']);
             //			}
             //
             //			//ziskaj vsetky mozne material
             //			$materials = dibi::fetchAll("SELECT material FROM [product_param] GROUP BY material");
             //			$f->addGroup('Material');
             //			foreach($materials as $k=>$material){
             //				$f->addCheckbox('material_'.$k, $material['material']);
             //			}
             $f->addGroup()->setOption('container', 'fieldset class=clear');
             $f->addSubmit('btn_generate', 'Generovať');
             $f->onSuccess[] = array($this, 'handleAddGeneratedParam');
             return $f;
             break;
         case 'productParams':
             //			$d = ProductModel::getProductParamDatasource( $this->getParam('id'))->fetchAll();
             $id_product = $this->getParam('id');
             $grid = new Tabella(ProductModel::getProductParamDatasource($id_product), array('sorting' => 'asc', 'order' => 'sequence', 'id_table' => 'id_product_param', 'limit' => 50, "onSubmit" => function ($post) {
                 //						print_r($post);exit;
                 ProductModel::setProductParamValue($post, $post['id_product_param']);
             }, "onDelete" => function ($id) {
                 ProductModel::deleteProductParamValue($id);
             }));
             $el = NHtml::el("div");
             $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyParam!', array('id_product' => $id_product)))->addClass('addIcon ajax'));
             $grid->addColumn($el, 'sequence', array('width' => 20, 'filter' => NULL, "editable" => true));
             //vytiahnutie template_group pre produkt - ake bude mat parametre
             if ($id_product) {
                 $id_product_template_group = ProductModel::getFluent(1, false, false)->removeClause('select')->select('id_product_template_group')->where('id_product = %i', $id_product)->fetchSingle();
             } else {
                 //ak je id_product NULL jedna sa pridavanie produktu
                 if ($id_product == NULL and $this->getParam('id_product_template_group') != NULL) {
                     $id_product_template_group = $this->getParam('id_product_template_group');
                 } else {
                     $id_product_template_group = $this->getService('ProductTemplateGroupModel')->getIdDefaultTemplate();
                 }
             }
             $params = $this->getService('ProductTemplateGroupModel')->fetchAssocAllParam($id_product_template_group);
             foreach ($params as $p) {
                 if ($p['checked']) {
                     $grid->addColumn($this->getService('translator')->translate($p['row_name']), $p['row_name'], array("width" => 50, "editable" => true));
                 }
             }
             $grid->addColumn("Cena", "price", array("width" => 100, "editable" => true));
             //			_repairPriceForView
             //
             //
             //			$grid->addColumn( "Na sklade", "stock", array( "width" => 50, "editable" => true ) );
             ////			$grid->addColumn( "Farba", "color", array( "width" => 100, "editable" => true ) );
             ////			$grid->addColumn( "Veľkosť", "size", array( "width" => 100, "editable" => true ) );
             ////			$grid->addColumn( "Material", "material", array( "width" => 100, "editable" => true ) );
             //			$grid->addColumn( "Napojenie", "connection", array( "width" => 100, "editable" => true ) );
             //			$grid->addColumn( "Cena", "price", array( "width" => 100, "editable" => true ) );
             $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) {
                 $el = NHtml::el("td");
                 $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteProductParam!', array('id_product_param' => $row->id_product_param)))->addClass('deleteIcon ajax'));
                 return $el;
             }));
             $this->addComponent($grid, $name);
             break;
         case 'pictogram':
             $p = new PictogramControl($this, $name);
             return $p;
             break;
         case 'keyword':
             return new KeywordControl();
             break;
         case 'ajaxtest':
             return new AjaxTextControl();
             break;
         default:
             return parent::createComponent($name);
             break;
     }
 }
Exemple #5
0
 static function baseForm($check_email = true)
 {
     $form = new MyForm();
     $renderer = $form->getRenderer();
     $renderer->wrappers['group']['label'] = 'h3';
     $form->addGroup(_('Informácie o zákazníkovi'))->setOption('container', 'fieldset id=user-info');
     $form->addText('login', _('Používateľské meno / Email'));
     if ($check_email) {
         $form['login']->addRule(NForm::FILLED, _('Používateľské meno musí byť vyplnené'))->addRule(NForm::EMAIL, _('Používateľské meno musí byť email.'));
     }
     //				$form->addText('email', _('Email'))
     //					->addRule(NForm::FILLED, _('Email musí byť vyplnený'))
     //					->addRule(NForm::EMAIL, _('Email nie je v správnom tvare'));
     $form->addPassword('password', _('Heslo'));
     $form->addPassword('passwordCheck', _('Znova heslo'))->addConditionOn($form['password'], NForm::FILLED)->addRule(NForm::FILLED, _('Zadejte heslo pro kontrolu'))->addRule(NForm::EQUAL, _('Hesla sa musia zhodovať'), $form['password']);
     /*
      * Info o uzivatelovi
      */
     $form->addGroup('Účtovné informácie');
     $form->addRadioList('type', '', array(0 => _('Súkromná osoba'), 1 => _('Podnikateľ - firma')))->addRule(NForm::FILLED, _('Uveďte či ste súkromná osoba alebo firma'))->setDefaultValue(0);
     //$form->addSelect('title', _('Oslovenie'), array( 0=>_('Žiadne'), 1=>_('Pán'),2=>_('Pani'),3=>_('Slečna') ));
     $form->addText('name', _('Meno'))->addRule(NForm::FILLED, _('Meno musí byť vyplnené'));
     $form->addText('surname', _('Priezvisko'))->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené'));
     $form->addText('address', _('Adresa'))->addRule(NForm::FILLED, _('Adresa musí byť vyplnená'));
     $form->addText('city', _('Mesto'))->addRule(NForm::FILLED, _('Mesto musí byť vyplnené'));
     $form->addText('zip', _('PSČ'))->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené'));
     $form->addSelect('iso', _('Štát'), UserModel::getAllCountry())->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené'));
     $form->addText('phone', _('Telefón'))->addRule(NForm::FILLED, _('Telefón musí byť vyplnený'));
     //$form->addText('fax', _('Fax'));
     $form->addGroup(_('Firemné informácie'))->setOption('container', 'fieldset id=company-form-container');
     $form->addText('company_name', _('Názov spoločnosti '))->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Názov spoločnosti musí byť vyplnený'));
     $form->addText('ico', _('IČO'))->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('IČO spoločnosti musí byť vyplnené'))->addRule(NForm::MAX_LENGTH, 'Maximálna dĺžka je 12', 12);
     $form->addRadioList('paying_vat', _('Platca DPH'), array(0 => 'platca', 1 => 'neplatca'))->setDefaultValue(0)->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('IČO spoločnosti musí byť vyplnené'));
     $form->addText('dic', _('DIČ'))->addConditionOn($form['type'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('DIČ spoločnosti musí byť vyplnené'));
     $form->addGroup('');
     $form->addRadioList('use_delivery_address', _('Dodacia adresa'), array(0 => _('Prednastavená (rovnaká ako fakturačná adresa)'), 1 => _('Iná')))->setDefaultValue(0);
     $form->addGroup(_('Dodacia adresa'))->setOption('container', 'fieldset id=delivery-address-container');
     //$form->addSelect('title', _('Oslovenie'), array( 0=>_('Žiadne'), 1=>_('Pán'),2=>_('Pani'),3=>_('Slečna') ));
     $form->addText('delivery_name', _('Meno'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Meno musí byť vyplnené'));
     $form->addText('delivery_surname', _('Priezvisko'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené'));
     $form->addText('delivery_address', _('Adresa'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Adresa musí byť vyplnená'));
     $form->addText('delivery_city', _('Mesto'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Mesto musí byť vyplnené'));
     $form->addText('delivery_zip', _('PSČ'))->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené'));
     $form->addSelect('delivery_iso', _('Štát'), UserModel::getAllCountry())->addConditionOn($form['use_delivery_address'], NFORM::EQUAL, 1)->addRule(NForm::FILLED, _('Priezvisko musí byť vyplnené'));
     $form->addText('delivery_phone', _('Telefón'));
     return $form;
 }