Esempio n. 1
0
 public function createComponent($name)
 {
     switch ($name) {
         case 'importForm':
             $form = new AppForm($this, $name);
             $form->addFile('file', __('File:'))->addRule(Form::FILLED, __('You have to entry file.'));
             $form->addText('provision', __('Provision (%):'))->addRule(Form::FILLED, __('You have to entry provison.'))->addRule(Form::NUMERIC, __('Provison has to be a number.'))->addRule(Form::RANGE, __('Provision has to be between 0 and 99.'), array(0, 99));
             $form->addCheckbox('update_only', __('only update existing products'));
             // availability_id
             $availabilities = array(0 => __('–––'));
             foreach (mapper::product_availabilities()->findAll() as $_) {
                 $availabilities[$_->getId()] = $_->getName();
             }
             $form->addSelect('availability_id', __('Default availability:'), $availabilities);
             $form->addSubmit('ok', '✔ ' . __('Import'));
             $form->setDefaults(array('provision' => 0, 'update_only' => TRUE));
             $form->onSubmit[] = array($this, 'onImportFormSubmit');
             break;
         case 'importManufacturersForm':
             $form = new AppForm($this, $name);
             $form->addFile('file', __('File:'))->addRule(Form::FILLED, __('You have to entry file.'));
             $form->addSubmit('ok', '✔ ' . __('Import'));
             $form->onSubmit[] = array($this, 'onImportManufacturersFormSubmit');
             break;
         default:
             parent::createComponent($name);
     }
 }
Esempio n. 2
0
 /**
  * Login form component factory.
  * @return mixed
  */
 protected function createComponentLoginForm()
 {
     $form = new AppForm();
     $form->addText('username', 'Username:'******'Please provide an username.');
     $form->addPassword('password', 'Password:'******'Please provide a password.');
     $form->addSubmit('login', 'Login');
     $form->addProtection('Please submit this form again (security token has expired).');
     /**/
     $form->onSubmit[] = array($this, 'loginFormSubmitted');
     /**/
     /* PHP 5.3
     		$that = $this;
     		$form->onSubmit[] = function($form) use ($that) {
     			try {
     				$user = Environment::getUser();
     				$user->authenticate($form['username']->getValue(), $form['password']->getValue());
     				$that->getApplication()->restoreRequest($that->backlink);
     				$that->redirect('Dashboard:');
     
     			} catch (AuthenticationException $e) {
     				$form->addError($e->getMessage());
     			}
     		};*/
     return $form;
 }
 /**
  * Example form factory
  * @return AppForm
  */
 protected function createComponentExampleForm()
 {
     $form = new AppForm();
     $form->addTextarea("text", "Text", 110, 20)->getControlPrototype()->class("texyla");
     $form->addSubmit("s", "Submit");
     return $form;
 }
 protected function createComponentDeleteForm()
 {
     $array = $this->fileModel->getAllFiles();
     $form = new AppForm();
     $form->addCheckBoxList('file', 'files:', $array['ids']);
     $form->addSubmit('delete', 'Smazat soubory')->onClick[] = array($this, 'deleteClicked');
     return $form;
 }
Esempio n. 5
0
 protected function createComponentLoginForm()
 {
     $form = new AppForm();
     $form->addText('userName', 'Uživatelské jméno:')->addRule(Form::FILLED, "Uživatelské jméno musí být zadáno");
     $form->addPassword('password', 'Heslo:')->addRule(Form::FILLED, "Heslo musí být zadáno");
     $form->addSubmit('ok', 'Přihlásit')->onClick[] = array($this, 'okClicked');
     return $form;
 }
Esempio n. 6
0
 protected function createComponentMetaAddForm()
 {
     $form = new AppForm();
     $form->getElementPrototype()->class('ajax');
     $form->addText('key', 'klíč')->getControlPrototype()->style = 'width:90px';
     $form->addText('value', 'hodnota');
     $form->addSubmit('submit1', 'Přidat');
     $form->onSuccess[] = callback($this, 'metaAddFormSubmitted');
     return $form;
 }
 /**
  * Login form component factory.
  * @return mixed
  */
 protected function createComponentLoginForm()
 {
     $form = new AppForm();
     $form->addText('username', 'Username:'******'Please provide a username.');
     $form->addPassword('password', 'Password:'******'Please provide a password.');
     $form->addCheckbox('remember', 'Remember me on this computer');
     $form->addSubmit('login', 'Login');
     $form->onSubmit[] = callback($this, 'loginFormSubmitted');
     return $form;
 }
Esempio n. 8
0
 public function createComponentLoginForm()
 {
     $form = new AppForm();
     $form->addText('username', 'Uživatelské jméno:')->addRule(Form::FILLED, 'Vyplňte prosím uživatelské jméno.');
     $form->addPassword('password', 'Heslo:')->addRule(Form::FILLED, 'Vyplňte, prosím, heslo.');
     $form->addCheckbox('remember', 'Trvale přihlásit na tomto počítači');
     $form->addSubmit('login', 'Přihlásit se');
     $form->onSuccess[] = callback($this, 'loginFormSubmitted');
     return $form;
 }
Esempio n. 9
0
 public function createComponentContactForm()
 {
     $form = new AppForm();
     $form->addText("name", "Jméno");
     $form->addText("email", "E-mail")->setRequired('Vyplňte, prosím, správně svůj email.')->addRule(Form::EMAIL, 'Vyplňte, prosím, správně svůj email.');
     $form->addTextArea("text", "Zpráva")->setRequired('Vyplňte, prosím, svou zprávu.');
     $form->addSubmit("submit1", "Odeslat");
     //$form->addProtection(); //sends cookie ... wtf?
     $form->onSuccess[] = callback($this, 'contactFormSubmitted');
     return $form;
 }
Esempio n. 10
0
 public function createComponentRedirectEditForm()
 {
     $form = new AppForm();
     $form->getElementPrototype()->class('ajax');
     $form->addHidden('id');
     $form->addText('oldurl', 'stará adresa');
     $form->addText('newurl', 'nová adresa');
     $form->addSubmit('submit1', 'OK');
     $form->onSuccess[] = callback($this, 'redirectEditFormSubmitted');
     return $form;
 }
Esempio n. 11
0
 protected function createComponentHomeForm($name)
 {
     $form = new AppForm();
     $form->addTextArea('text', 'Text')->addRule(Form::FILLED, "Bez textu zůstane úvodní strana prázdná")->getControlPrototype()->style = 'width: 685px; height: 370px';
     $form->addHidden('id');
     $dataSource = dibi::query('SELECT id, text FROM [options] WHERE [name]=%s', 'home')->fetch();
     if ($dataSource != null) {
         $form->setDefaults($dataSource);
     }
     $form->addSubmit('ok', 'Uložit')->onClick[] = array($this, 'saveClicked');
     return $form;
 }
Esempio n. 12
0
 protected function createComponentFormGraphsSettings($name)
 {
     $form = new AppForm($this, $name);
     // construct form fields by first patient
     $fields = Storage::getInstance()->getStoredFields();
     foreach ($fields as $field => $props) {
         $form->addCheckbox($field, $field);
     }
     $form->addSubmit('save', 'Uložiť');
     $form->onSubmit[] = array($this, 'SubmittedGraphsSettings');
     return $form;
 }
Esempio n. 13
0
 public function createComponentTranslationsAddForm()
 {
     $form = new AppForm();
     $form->getElementPrototype()->class('ajax');
     $form->addHidden('id');
     $form->addText('key', 'Klíč');
     foreach ($this->context->params["langs"] as $l => $txt) {
         $form->addText($l, $txt);
     }
     $form->addSubmit('submit1', 'OK');
     $form->onSuccess[] = callback($this, 'editFormSubmitted');
     return $form;
 }
Esempio n. 14
0
 public function createComponent($name)
 {
     switch ($name) {
         case 'loginForm':
             $form = new AppForm($this, $name);
             $form->addText('username', __('Username:'******'password', __('Password:'******'ok', __('Login'));
             $form->onSubmit[] = array($this, 'onLoginFormSubmit');
             break;
         default:
             return parent::createComponent($name);
     }
 }
Esempio n. 15
0
 public function createComponent($name)
 {
     switch ($name) {
         case 'settingsForm':
             $form = new AppForm($this, $name);
             // basic
             $form->addGroup(__('Basic'));
             $form->addText('shopName', __('Shop name:'))->addRule(Form::FILLED, __('You have to entry shop name.'));
             $form->addText('shopSlogan', __('Shop slogan:'))->addRule(Form::FILLED, __('You have to entry shop slogan.'));
             $form->addText('shopEmail', __('Contact e-mail:'))->addRule(Form::FILLED, __('You have to entry contact e-mail.'));
             // address
             $form->addGroup(__('Shop address'));
             $form->addText('shopAddressCompany', __('Company:'));
             $form->addText('shopAddressName', __('Name:'))->addRule(Form::FILLED, __('You have to entry name.'));
             $form->addText('shopAddressStreet', __('Street:'))->addRule(Form::FILLED, __('You have to entry street.'));
             $form->addText('shopAddressCity', __('City:'))->addRule(Form::FILLED, __('You have to entry city.'));
             $form->addText('shopAddressPostcode', __('Post code:'))->addRule(Form::FILLED, __('You have to entry post code.'));
             // miscellaneous
             $form->addGroup(__('Miscellaneous'));
             $form->addText('metaKeywords', __('META keywords:'))->addRule(Form::FILLED, __('You have to entry META keywords.'));
             $form->addText('metaDescription', __('META description:'))->addRule(Form::FILLED, __('You have to entry META description.'));
             $form->addText('currency', __('Currency:'))->addRule(Form::FILLED, __('You have to entry currency.'));
             $form->addText('itemsPerPage', __('Items per page:'))->addRule(Form::FILLED, __('You have to entry items per page.'))->addRule(Form::FILLED, __('Items per page has to be a number.'));
             $themes = array(0 => __('–––'));
             foreach (new DirectoryIterator(Environment::expand('%themeDir%')) as $_) {
                 if (!$_->isDot() && $_->isDir()) {
                     $themes[$_->getFilename()] = $_->getFilename();
                 }
             }
             $form->addSelect('theme', __('Theme:'), $themes)->skipFirst();
             $form['theme']->addRule(Form::FILLED, __('You have to select theme.'));
             // submit
             $form->setCurrentGroup(NULL);
             $form->addSubmit('ok', '✔ ' . __('Save'));
             $form->onSubmit[] = array($this, 'onSettingsFormSubmit');
             break;
         case 'changeLoginForm':
             $form = new AppForm($this, $name);
             $form->addText('username', __('Username:'******'You have to entry username.'));
             $form->addPassword('old_password', __('Old password:'******'You have to entry old password.'));
             $form->addPassword('new_password', __('New password:'******'You have to entry new password.'));
             $form->addPassword('new_password_again', __('New password (again):'))->addRule(Form::FILLED, __('You have to entry new password again.'))->addRule(Form::EQUAL, __('New passwords have to match.'), $form['new_password']);
             $form->addSubmit('ok', '✔ ' . __('Change'));
             $form->onSubmit[] = array($this, 'onChangeLoginFormSubmit');
             break;
         default:
             parent::createComponent($name);
     }
 }
Esempio n. 16
0
 protected function createComponentForm()
 {
     $form = new AppForm();
     $form->addHidden('id');
     $form->addText('jmeno', 'Jméno:')->setOption('description', 'Prázdné jméno smaže záznam.');
     $form->addText('prezdivka', 'Přezdívka:');
     $form->addText('adresa', 'Adresa:');
     $form->addText('pevny_telefon', 'Pevná linka:');
     $form->addText('mobilni_telefon', 'Mobil:')->setOption('description', 'STS přidejte nakonec do závorky');
     $form->addText('email', 'E-mail:');
     $form->addSelect('oddil', 'Oddíl:', self::$oddily);
     $form->addText('poznamka', 'Poznámka:');
     $form->addSubmit('save', 'Uložit');
     $form->onSuccess[] = callback($this, 'editFormSubmitted');
     return $form;
 }
Esempio n. 17
0
 public function createComponent($name)
 {
     switch ($name) {
         case 'pageAddForm':
         case 'pageEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('page');
             }
         case 'actualityAddFrom':
         case 'actualityEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('actuality');
             }
         case 'manufacturerAddForm':
         case 'manufacturerEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('manufacturer');
             }
         case 'categoryAddForm':
         case 'categoryEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('category');
             }
         case 'productAddForm':
         case 'productEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('product');
             }
             // form itself
             $action = substr($name, $prefix_len);
             $action = substr($action, 0, strlen($action) - 4);
             // instantiate
             $form = new AppForm($this, $name);
             // name
             $form->addText('name', __('Name:'))->addRule(Form::FILLED, __('You have to entry name.'));
             // edit or add?
             if (substr($name, strlen($name) - 8) !== 'EditForm') {
                 // add
                 $form->addText('nice_name', __('Name in URL:'))->addRule(Form::FILLED, __('You have to entry URL name.'));
             } else {
                 // edit
                 $form->addHidden('nice_name');
                 if (strncmp($name, 'manufacturer', 12) === 0 || strncmp($name, 'product', 7) === 0) {
                     $form->addHidden('id');
                 }
             }
             // is category?
             if (strncmp($name, 'category', 8) === 0) {
                 $form->addHidden('id');
             }
             // metas
             $form->addText('meta_keywords', __('META keywords:'));
             $form->addText('meta_description', __('META description:'));
             // description or content?
             if (strncmp($name, 'manufacturer', 12) === 0 || strncmp($name, 'category', 8) === 0) {
                 $form->addTextarea('content', __('Description:'));
             } else {
                 $form->addTextarea('content', __('Content:'));
             }
             // is product?
             if (strncmp($name, 'product', 7) === 0) {
                 // category
                 $categories = array(0 => __('–––'));
                 foreach (mapper::categories()->findAll() as $_) {
                     list($depth, $category) = $_;
                     $categories[$category->getId()] = str_repeat('–', $depth) . ' ' . $category->getName();
                 }
                 $form->addSelect('category_id', __('Category:'), $categories)->skipFirst();
                 // manufacturer
                 $manufacturers = array(0 => __('–––'));
                 foreach (mapper::manufacturers()->findAll() as $manufacturer) {
                     $manufacturers[$manufacturer->getId()] = $manufacturer->getName();
                 }
                 $form->addSelect('manufacturer_id', __('Manufacturer:'), $manufacturers)->skipFirst();
                 // availability
                 $availabilities = array(0 => __('–––'));
                 foreach (mapper::product_availabilities()->findAll() as $_) {
                     $availabilities[$_->getId()] = $_->getName();
                 }
                 $form->addSelect('availability_id', __('Availability:'), $availabilities)->skipFirst();
                 // code
                 $form->addText('code', __('Code:'));
                 // price
                 $form->addText('price', __('Price:'))->addRule(Form::NUMERIC, __('Price has to be a number.'));
             }
             // picture
             $pictures = array(0 => __('–––'));
             foreach (mapper::pictures()->findAll() as $_) {
                 $pictures[$_->getId()] = self::remove_ext($_->getFile());
             }
             $form->addSelect('picture_id', __('Picture:'), $pictures);
             // submit
             $form->addSubmit('ok', '✔ ' . __($action));
             $form->onSubmit[] = array($this, 'on' . ucfirst(substr($name, 0, strlen($name) - 4)) . 'Submit');
             break;
         case 'categoriesForm':
             $form = new AppForm($this, $name);
             $items = array(0 => __('–––'));
             foreach (mapper::categories()->findAll() as $_) {
                 list($depth, $category) = $_;
                 $items[$category->getId()] = str_repeat('–', $depth) . ' ' . $category->getName();
             }
             $form->addSelect('id', __('Category:'), $items)->skipFirst();
             $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onCategoriesFormEdit');
             $form->addSubmit('add', '⊕ ' . __('Add subcategory'))->onClick[] = array($this, 'onCategoriesFormAdd');
             $form->addSubmit('delete', '⊗ ' . __('Delete'))->onClick[] = array($this, 'onCategoriesFormDelete');
             break;
         case 'newPictureForm':
             $form = new AppForm($this, $name);
             $form->addFile('file', __('File:'));
             $form->addText('rename', __('Rename to:'));
             $form->addText('description', __('Description:'));
             $form->addSubmit('ok', '➦ ' . __('Upload'));
             $form->onSubmit[] = array($this, 'onNewPictureSubmit');
             break;
         case 'availabilitiesForm':
             $form = new AppForm($this, $name);
             $availabilities = array(0 => __('–––'));
             foreach (mapper::product_availabilities()->findAll() as $_) {
                 $availabilities[$_->getId()] = $_->getName();
             }
             $form->addSelect('id', __('Availability:'), $availabilities)->skipFirst();
             $form['id']->addRule(Form::FILLED, __('You have to choose availability.'));
             $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onAvailabilitiesFormEdit');
             $form->addSubmit('delete', '⊗ ' . __('Delete'))->onClick[] = array($this, 'onAvailabilitiesFormDelete');
             break;
         case 'availabilityAddForm':
         case 'availabilityEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('availability');
             }
             $action = substr($name, $prefix_len);
             $action = substr($action, 0, strlen($action) - 4);
             $form = new AppForm($this, $name);
             if (substr($name, strlen($name) - 8) === 'EditForm') {
                 $form->addHidden('id');
             }
             $form->addText('name', __('Name:'));
             $form->addSubmit('ok', '✔ ' . __($action));
             $form->onSubmit[] = array($this, 'on' . ucfirst(substr($name, 0, strlen($name) - 4)) . 'Submit');
             break;
         case 'titlePageForm':
             $form = new AppForm($this, $name);
             $form->addTextarea('content', __('Content:'))->addRule(Form::FILLED, __('You have to entry content.'));
             $form->addSubmit('save', '✔ ' . __('Save'));
             $form->onSubmit[] = array($this, 'onTitlePageFormSubmit');
             $form->setDefaults(array('content' => require_once Environment::expand('%titlePageFile%')));
             break;
         default:
             parent::createComponent($name);
     }
 }
Esempio n. 18
0
 public function createComponent($name)
 {
     switch ($name) {
         case 'manageStatusesForm':
             $form = new AppForm($this, $name);
             $statuses = array(0 => __('–––'));
             foreach (mapper::order_statuses()->findAll() as $_) {
                 $statuses[$_->getId()] = $_->getName() . ($_->getInitial() ? ' ✱' : '');
             }
             $form->addSelect('id', __('Status:'), $statuses)->skipFirst();
             $form['id']->addRule(Form::FILLED);
             $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onManageStatusesFormEdit');
             break;
         case 'statusAddForm':
         case 'statusEditForm':
             $prefix_len = strlen('status');
             $action = substr($name, $prefix_len);
             $action = substr($action, 0, strlen($action) - 4);
             $form = new AppForm($this, $name);
             if (substr($name, strlen($name) - 8) === 'EditForm') {
                 $form->addHidden('id');
             }
             $form->addText('name', __('Name:'))->addRule(Form::FILLED, __('You have to entry status name.'));
             $form->addCheckbox('initial', __('initial for orders'));
             $form->addSubmit('ok', '✔ ' . __($action));
             $form->onSubmit[] = array($this, 'on' . substr($name, 0, strlen($name) - 4) . 'Submit');
             break;
         case 'managePaymentTypesForm':
             $form = new AppForm($this, $name);
             $types = array(0 => __('–––'));
             foreach (mapper::order_payment_types()->findAll() as $_) {
                 $types[$_->getId()] = $_->getName();
             }
             $form->addSelect('id', __('Payment type:'), $types)->skipFirst();
             $form['id']->addRule(Form::FILLED);
             $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onManagePaymentTypesFormEdit');
             break;
         case 'manageDeliveryTypesForm':
             $form = new AppForm($this, $name);
             $types = array(0 => __('–––'));
             foreach (mapper::order_delivery_types()->findAll() as $_) {
                 $types[$_->getId()] = $_->getName();
             }
             $form->addSelect('id', __('Delivery type:'), $types)->skipFirst();
             $form['id']->addRule(Form::FILLED);
             $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onManageDeliveryTypesFormEdit');
             break;
         case 'paymentTypeAddForm':
         case 'paymentTypeEditForm':
             $prefix_len = strlen('paymentType');
         case 'deliveryTypeAddForm':
         case 'deliveryTypeEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('deliveryType');
             }
             $action = substr($name, $prefix_len);
             $action = substr($action, 0, strlen($action) - 4);
             $form = new AppForm($this, $name);
             if (substr($name, strlen($name) - 8) === 'EditForm') {
                 $form->addHidden('id');
             }
             $form->addText('name', __('Name:'))->addRule(Form::FILLED, __('You have to entry name.'));
             $form->addText('price', __('Price:'))->addRule(Form::FILLED, __('You have to entry price.'))->addRule(Form::NUMERIC, __('Price has to be a number.'));
             $form->addSubmit('ok', '✔ ' . __($action));
             $form->onSubmit[] = array($this, 'on' . substr($name, 0, strlen($name) - 4) . 'Submit');
             break;
         case 'changeOrderStatusForm':
             $form = new AppForm($this, $name);
             $statuses = array(0 => __('–––'));
             foreach (mapper::order_statuses()->findAll() as $_) {
                 $statuses[$_->getId()] = $_->getName();
             }
             $form->addSelect('status_id', __('Status:'), $statuses)->skipFirst()->addRule(Form::FILLED, __('You have to entry status.'));
             $form->addHidden('id');
             $form->addSubmit('ok', '✔ ' . __('Change'));
             $form->onSubmit[] = array($this, 'onChangeOrderStatusFormSubmit');
             break;
         case 'sendMailForm':
             $form = new AppForm($this, $name);
             $form->addText('to', __('To:'))->addRule(Form::EMAIL, __('E-mail has to be an e-mail.'));
             $form->addText('subject', __('Subject:'))->addRule(Form::FILLED, __('You have to entry subject.'));
             $form->addTextArea('body', __('Body:'))->addRule(Form::FILLED, __('You have to entry text.'));
             $form->addSubmit('ok', '✔ ' . __('Send'));
             $form->onSubmit[] = array($this, 'onSendMailFormSubmit');
             $form->addHidden('order_id');
             break;
         default:
             parent::createComponent($name);
     }
 }
Esempio n. 19
0
 /**
  * A little componen factory
  * @param string
  */
 public function createComponent($name)
 {
     switch ($name) {
         case 'dataForm':
             $data = isset(Environment::getSession(SESSION_ORDER_NS)->data) ? Environment::getSession(SESSION_ORDER_NS)->data : array();
             $form = new AppForm($this, $name);
             // contacts
             $form->addGroup(__('Contacts'));
             $form->addText('email', __('E-mail:'))->setEmptyValue('@')->addRule(Form::FILLED, __('You have to enter your e-mail.'))->addRule(Form::EMAIL, __('This is not an e-mail address.'));
             $form->addText('phone', __('Phone number:'))->addRule(Form::FILLED, __('You have to enter your phone number.'))->addRule(Form::NUMERIC, __('Phone number has to be number.'));
             // payer
             $form->addGroup(__('Payer'));
             $form->addText('payer_name', __('Name:'))->addRule(Form::FILLED, __('You have to enter your name.'));
             $form->addText('payer_lastname', __('Last name:'))->addRule(Form::FILLED, __('You have to enter your last name.'));
             $form->addText('payer_company', __('Company:'));
             $form->addText('payer_street', __('Street:'))->addRule(Form::FILLED, __('You have to enter your street.'));
             $form->addText('payer_city', __('City:'))->addRule(Form::FILLED, __('You have to enter your city.'));
             $form->addText('payer_postcode', __('Post code:'))->addRule(Form::FILLED, __('You have to enter your post code.'))->addRule(Form::NUMERIC, __('Post code has to be number.'));
             $form->addCheckbox('same_delivery', __('deliver at same address (you do not need to fill Delivery address below)'))->setValue(TRUE);
             // delivery address
             $form->addGroup(__('Delivery address'));
             $form->addText('delivery_name', __('Name:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your name.'));
             $form->addText('delivery_lastname', __('Last name:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your last name.'));
             $form->addText('delivery_street', __('Street:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your street.'));
             $form->addText('delivery_city', __('City:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your city.'));
             $form->addText('delivery_postcode', __('Post code:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your post code.'))->addRule(Form::NUMERIC, __('Post code has to be number.'));
             // delivery type
             $form->addGroup(__('Delivery type'));
             $delivery_types = array();
             foreach (mapper::order_delivery_types()->findAll() as $delivery_type) {
                 $delivery_types[$delivery_type->getId()] = $delivery_type->getName() . Environment::expand(' (' . $delivery_type->getPrice() . ' %currency%)');
             }
             $form->addSelect('delivery_type', __('Type:'), $delivery_types);
             // payment type
             $form->addGroup(__('Payment type'));
             $payment_types = array();
             foreach (mapper::order_payment_types()->findAll() as $payment_type) {
                 $payment_types[$payment_type->getId()] = $payment_type->getName() . Environment::expand(' (' . $payment_type->getPrice() . ' %currency%)');
             }
             $form->addSelect('payment_type', __('Type:'), $payment_types);
             // comment
             $form->addGroup(__('Comment'));
             $form->addTextarea('comment', __('Comment:'));
             // submit
             $form->setCurrentGroup(NULL);
             $form->addSubmit('ok', '(3/3) ' . __('Complete order »'));
             $form['ok']->setRendered(TRUE);
             $form->onSubmit[] = array($this, 'onDataFormSubmit');
             // defaults
             if (isset(Environment::getSession(SESSION_ORDER_NS)->data)) {
                 $form->setDefaults(Environment::getSession(SESSION_ORDER_NS)->data);
             }
             break;
         default:
             parent::createComponent($name);
     }
 }
Esempio n. 20
0
 /**
  * Component factory.
  * @see Nette/ComponentContainer#createComponent()
  */
 protected function createComponentForm($name)
 {
     $form = new AppForm();
     $form->addGroup('general');
     //$form->getElementPrototype()->id('editform');
     $form->addText('name', 'Křestí a příp. prostřední jméno')->addRule(Form::FILLED, "Jméno je potřeba vyplnit");
     $form->addText('surname', 'Příjmení')->addRule(Form::FILLED, "Příjmení je potřeba vyplnit");
     $form->addCheckbox('r', 'Osmileté gymnázium (R)');
     $form->addSelect('mark', 'Písmeno třídy', array("A" => "A", "B" => "B", "C" => "C", "D" => "D"));
     $form->addGroup('left');
     $form->addText('class', 'Maturitní ročník', 4);
     $form->addGroup('right');
     $form->addSelect('number', 'Číslo třídy', array("?", "1", "2", "3", "4", "5", "6", "7", "8"));
     $form['class']->addConditionOn($form['number'], Form::EQUAL, 0)->addRule(Form::FILLED, 'Pokud nevyberete číslo třídy, musíte zadat maturitní ročník')->addRule(Form::NUMERIC, 'Ročník musí být číslo')->addRule(Form::RANGE, 'Rok maturity musí být od %d do %d', array(1960, 2999));
     $form->addGroup('submit');
     $form->addSubmit('ok', 'Přidat autora')->onClick[] = array($this, 'addClicked');
     if ($this->setId != '') {
         $dataSource = dibi::query('SELECT * FROM [authors] WHERE authorId=%i', $this->setId)->fetch();
         $form->setDefaults($dataSource);
         $form['ok']->onClick = array(array($this, 'SaveClicked'));
         $form['ok']->caption = "Uložit autora";
         $form->addHidden("authorId")->setValue($this->setId);
     }
     $this->addComponent($form, $name);
     return;
 }
Esempio n. 21
0
 protected function createComponentFormPatientProperties($name)
 {
     $form = new AppForm($this, $name);
     // construct form fields by first patient
     $fields = Storage::getInstance()->getStoredFields();
     foreach ($fields as $field => $props) {
         $form->addText($field, $field)->addRule(Form::FILLED, 'Nesmie byt prazdne!');
     }
     $form->addSubmit('save', 'Uložiť');
     return $form;
 }
Esempio n. 22
0
 /**
  * Album delete form component factory.
  * @return mixed
  */
 protected function createComponentDeleteForm()
 {
     $form = new AppForm();
     /* PHP 5.3
     		$that = $this;
     		$form->addSubmit('cancel', 'Cancel')->onClick[] = function() use ($that) {
     			$that->redirect('default');
     		};
     		$form->addSubmit('delete', 'Delete')->onClick[] = function() use ($that) {
     			$album = new Albums;
     			$album->delete($that->getParam('id'));
     			$that->flashMessage('Album has been deleted.');
     			$that->redirect('default');
     		};
     		$form['delete']->getControlPrototype()->class('default');
     		*/
     /**/
     $form->addSubmit('cancel', 'Cancel');
     $form->addSubmit('delete', 'Delete')->getControlPrototype()->class('default');
     $form->onSubmit[] = array($this, 'deleteFormSubmitted');
     /**/
     $form->addProtection('Please submit this form again (security token has expired).');
     return $form;
 }
Esempio n. 23
0
 private function formNewEditFields(AppForm $form)
 {
     $form->addGroup('Content')->setOption('container', Html::el('fieldset')->id('contents'));
     $form->addText('title', 'Title')->addRule(Form::FILLED, 'Fill title');
     $form->addTextarea('content', 'Text');
     $templates = $this->model('contentTemplates')->get('page');
     $form->addGroup('Properties')->setOption('container', Html::el('fieldset')->id('properties'));
     $categories = $this->model('categories')->getPairs();
     $categories = array('0' => 'none') + $categories;
     $form->addSelect('category', 'Category', $categories);
     $form->addCheckBox('homepage', 'Set as homepage?');
     $form->addSelect('template', 'Template', $templates);
     $form->addCheckBox('has_widgets', 'Has widgets');
     $form->addText('publish_time', 'Publish time');
     //$form->addText('time', '');
     $form->addText('keywords', 'keywords');
     $form->addTextarea('description', 'description');
     $form->addHidden('content_type')->setValue('page');
     if ($form->name == 'formNewPage') {
         //$form->addGroup('Link')->setOption('container', Html::el('fieldset')->id('link'));
         $menus = $this->model('menu')->getPairs();
         $menus = array(0 => 'none') + $menus;
         $form->addSelect('link', 'Link in menu', $menus);
     }
     $form->addTextArea('css_files', 'Css files')->getControlPrototype()->{'data-ext'} = 'css';
     $form->addTextArea('js_files', 'Js files')->getControlPrototype()->{'data-ext'} = 'js';
     $form->addGroup('')->setOption('container', Html::el('fieldset')->id('buttons'));
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('btnPreview', 'Preview')->onClick[] = array($this, 'formNewPagePreview');
     $form['btnPreview']->getControlPrototype()->class('ajax');
     return $form;
 }
Esempio n. 24
0
 public function createComponentEditForm($table, $id = null)
 {
     $form = new AppForm($this, $table . 'EditForm');
     $form->addProtection();
     if ($id != null) {
         $form->addHidden('id')->setValue($id);
     }
     switch ($table) {
         case 'students':
             $years = $this->model('courses')->getYears();
             $form->addText('name', 'Name');
             $form->addText('surname', 'Surname');
             $form->addSelect('year', 'year' . ':', $years);
             if ($id != null) {
                 $values = $this->model('students')->getStudent($id);
             }
             break;
         case 'teachers':
             $departments = $this->model('school')->getDepartments();
             $form->addText('name', 'Name');
             $form->addText('surname', 'Surname');
             $form->addSelect('department', 'department' . ':')->setItems($departments, false);
             if ($id != null) {
                 $values = $this->model('teachers')->getTeacher($id);
             }
             break;
         case 'rooms':
             $form->addText('name', 'Name');
             if ($id != null) {
                 $values = $this->model('school')->getRoom($id);
             }
             break;
         case 'departments':
             $form->addText('name', 'Name');
             if ($id != null) {
                 $values = $this->model('school')->getDepartment($id);
             }
             break;
         case 'learning_times':
             $form->addText('time', 'time');
             if ($id != null) {
                 $values = $this->model('school')->getLearningTime($id);
             }
             break;
         case 'courses':
             $years = $this->model('courses')->getYears();
             $departments = $this->model('school')->getDepartments();
             $form->addText('name', 'name');
             $form->addSelect('year', 'year:', $years);
             $form->addSelect('semester', 'semester:', array('L' => 'L', 'Z' => 'Z'));
             $form->addSelect('department', 'department:', $departments);
             if ($id != null) {
                 $values = $this->model('courses')->getCourse($id);
             }
             break;
     }
     $form->addSubmit('btnSubmit', 'Save');
     $form->onSubmit[] = array($this, 'editFormSubmitted');
     if (isset($values)) {
         $form->setDefaults($values);
     }
     return $form;
 }
Esempio n. 25
0
 public function createComponentPreviewUploadForm()
 {
     $form = new AppForm();
     $form->getElementPrototype()->class('ajax_upload');
     $form->addHidden("id");
     $form->addUpload("file", "soubor");
     $form->addSubmit("submit1", "Nahrát");
     $form->onSuccess[] = callback($this, 'previewUploadFormSubmitted');
     return $form;
 }
Esempio n. 26
0
 protected function createComponentFileLoader($name)
 {
     if ($this->setId != '') {
         $form = new AppForm();
         $form->addFile('file', "Přidat soubor:");
         $form->addHidden("workId")->setValue($this->setId);
         $form->addSubmit('fileSubmit', 'Přidat soubor')->onClick[] = array($this, 'fileSent');
         $this->addComponent($form, $name);
     }
     return;
 }
Esempio n. 27
0
 /**
  * Component factory.
  * @see Nette/ComponentContainer#createComponent()
  */
 protected function createComponentForm($name)
 {
     // NOTE: signal-submit on form disregard component's state
     //		because form is created directly by Presenter in signal handling phase
     //		and this principle is used to detect submit signal
     if (!$this->wasRendered) {
         $this->receivedSignal = 'submit';
     }
     $form = new AppForm($this, $name);
     $form->setTranslator($this->getTranslator());
     FormControl::$idMask = 'frm-datagrid-' . $this->getUniqueId() . '-%s-%s';
     $form->onSubmit[] = array($this, 'formSubmitHandler');
     $form->addSubmit('resetSubmit', 'Reset state');
     $form->addSubmit('filterSubmit', 'Apply filters');
     $form->addSelect('operations', 'Selected:', $this->operations);
     $form->addSubmit('operationSubmit', 'Send')->onClick = $this->onOperationSubmit;
     // page input
     $form->addText('page', 'Page', 1);
     $form['page']->setDefaultValue($this->page);
     $form->addSubmit('pageSubmit', 'Change page');
     // items per page selector
     $form->addSelect('items', 'Items per page', array_combine($this->displayedItems, $this->displayedItems));
     $form['items']->setDefaultValue($this->itemsPerPage);
     $form->addSubmit('itemsSubmit', 'Change');
     // generate filters FormControls
     if ($this->hasFilters()) {
         $defaults = array();
         $sub = $form->addContainer('filters');
         foreach ($this->getFilters() as $filter) {
             $sub->addComponent($filter->getFormControl(), $filter->getName());
             // NOTE: must be setted after is FormControl conntected to the form
             $defaults[$filter->getName()] = $filter->value;
         }
         $sub->setDefaults($defaults);
     }
     // checker
     if ($this->hasOperations()) {
         $sub = $form->addContainer('checker');
         if ($this->isSignalReceiver('submit')) {
             // NOTE: important!
             $ds = clone $this->dataSource;
             $this->filterItems();
         }
         foreach ($this->getRows() as $row) {
             $sub->addCheckbox($row[$this->keyName], $row[$this->keyName]);
         }
         if (isset($ds)) {
             $this->dataSource = $ds;
         }
     }
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $form->setRenderer($renderer);
     return;
 }
Esempio n. 28
0
 public function createComponentPageEditForm()
 {
     $form = new AppForm();
     $form->getElementPrototype()->class('ajax');
     $form->addHidden("id_page");
     $form->addText("heading", "nadpis");
     $form->addText("name", "v menu");
     $form->addText("seoname", "adresa")->setAttribute('placeholder', '(automatická)');
     $form->addCheckbox("published", "publikováno");
     $form->addTextArea("text", "obsah stránky");
     $form['text']->getControlPrototype()->class('textarea');
     $form->addSubmit("submit1", "Uložit");
     $form->onSuccess[] = callback($this, 'pageEditFormSubmitted');
     //add additional inputs
     $this->triggerEvent_filter('filterPageEditForm_create', $form);
     return $form;
 }
 protected function createComponentDelete($name)
 {
     $form = new AppForm($this, $name);
     $form->addSubmit('delete', 'Delete');
     $form->addSubmit('cancel', 'Cancel');
     $form->onSubmit[] = array($this, 'deleteOnFormSubmitted');
 }
Esempio n. 30
0
 /**
  * Sign in form component factory.
  * @return Nette\Application\AppForm
  */
 public function createComponentLogin($name)
 {
     $form = new AppForm($this, $name);
     $form->addRadioList('user', NULL, $this->getCredentialsRadioData())->setAttribute('class', 'onClickSubmit');
     $form->addSubmit('send', 'Log in');
     $form->onSubmit[] = callback($this, 'onLoginSubmitted');
     return $form;
 }