Example #1
0
 protected function createComponentCreateSunglassesForm()
 {
     $form = new Nette\Application\UI\Form();
     $unglasses = array("Červená" => "Červená", "Černá" => "Černá", "Bílá" => "Bílá", "Zelená" => "Zelená", "Žlutá" => "Žlutá", "Modrá" => "Modrá");
     $form->addSelect('color', "Barva brýlí", $unglasses)->setAttribute('onchange', 'changeSungalssesHomepageModal(this)')->setAttribute("class", "form-control");
     $form->addButton('create', "Navrhni si vlastní brýle")->setAttribute('onclick', 'showHomepageModalMore()')->setAttribute("id", "modalHomepageMoreButton");
     $form->addText('text', "Nápis")->setAttribute("placeholder", "Co by si měl rád na svých brýlích?")->setAttribute("class", "form-control")->setRequired('Přece by si nechtěl brýle nez nápisu. Něco si vymysli...')->addRule(Nette\Forms\Form::MAX_LENGTH, "Nápis může obsahovat maximálně %d znaků", 15);
     $form->addButton('next', "Pokračovat")->setAttribute('onclick', 'checkHeadlineHomePageModal()')->setAttribute("id", "modalHomepageNextButton");
     $form->addText('email', "Email")->setAttribute("placeholder", "Ještě nám prosím vyplň email a máš hotovo...")->setAttribute("class", "form-control")->addRule(Nette\Forms\Form::EMAIL, "Máš tam chybu, zkus to líp...");
     $form->addSubmit('save', "Dokončit");
     $form->onSuccess[] = $this->createSunglassesSucceeded;
     return $form;
 }
 public function create()
 {
     $form = new Form();
     $form->addText('workStart', 'Začátek', 3, 5)->setRequired('Vyplňte pole "Začátek prac. doby".')->setDefaultValue($this->defaultItemTime['workStart'])->setHtmlId('workStart')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Začátek prac. doby" lze zadat pouze
                  čas v 24 hodinovém formátu po půlhodinách.', '([01]?[0-9]|2[0-3]):(0|3)0');
     $form->addText('workEnd', 'Konec', 3, 5)->setRequired('Vyplňte pole "Konec prac. doby".')->setDefaultValue($this->defaultItemTime['workEnd'])->setHtmlId('workEnd')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Konec prac. doby" lze zadat pouze
                  čas v 24 hodinovém formátu po půlhodinách.', '([01]?[0-9]|2[0-3]):(0|3)0');
     $form->addText('lunch', 'Oběd', 3, 5)->setRequired('Vyplňte pole "Oběd".')->setDefaultValue($this->defaultItemTime['lunch'])->setHtmlId('lunch')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Oběd" lze zadat pouze
                  čas v ve formátu s čárkou. (např. 1 nebo 1,5)', '^(0|[1-9]|1[0-9]|2[0-3])(,(0|5))?$');
     $form->addText('otherHours', 'Ostatní hod.')->setDefaultValue($this->defaultItemTime['otherHours'])->setHtmlId('otherHours')->setAttribute('class', 'input-time')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Do pole "Ostaní hodiny" lze zadat pouze
                  čas ve formátu s čárkou.(např. 6 nebo 6,5)', '^(0|[1-9]|1[0-9]|2[0-3])(,(0|5))?$');
     $form->addText('locality', 'Místo pracoviště', 28, 40)->setRequired('Vyplňte pole "Místo pracoviště".')->setHtmlId('locality')->getControlPrototype()->class = 'item-text-input';
     $form->addText('description', 'Popis práce', 28, 30)->getControlPrototype()->class = 'item-text-input';
     $form->addText('descOtherHours', 'Komentář k ostat. hod. (např. svátek)', 28, 30)->addConditionOn($form['otherHours'], Form::FILLED)->addCondition(Form::FILLED)->addRule(function ($item, $arg) {
         return \InvoiceTime::processTime($arg) == '00:00:00' ? false : true;
     }, self::OTHER_HOURS_ZERO_TIME_ERROR_MSG, $form['otherHours']);
     $form['descOtherHours']->getControlPrototype()->class = 'item-text-input';
     // time control buttons
     $form->addButton('workStartAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workStart']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 0, 'val' => -30]));
     $form->addButton('workStartSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workStart']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 0, 'val' => 30]));
     $form->addButton('workEndAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workEnd']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 1, 'val' => 30]));
     $form->addButton('workEndSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workEnd']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 1, 'val' => -30]));
     $form->addButton('lunchAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['lunch']->control->attrs['id'], 'slider' => 'slider_lunch', 'val' => -30]));
     $form->addButton('lunchSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['lunch']->control->attrs['id'], 'slider' => 'slider_lunch', 'val' => 30]));
     $form->addButton('otherHoursAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['otherHours']->control->attrs['id'], 'slider' => 'slider_time_other', 'val' => 0]));
     $form->addButton('otherHoursSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['otherHours']->control->attrs['id'], 'slider' => 'slider_time_other', 'val' => 0]));
     $form->addSubmit('save', 'Uložit řádek');
     $form->getElementPrototype()->id = 'update-form';
     return $form;
 }
Example #3
0
 public function create()
 {
     $form = new Form();
     $form->getElementPrototype()->class("ajax");
     $form->addText("description")->addRule(Form::MAX_LENGTH, "Maximální délka popisu může být %d znaků.", Photo::MAX_DESCRIPTION_LENGTH)->setAttribute("size", 40)->setRequired("Zadej prosím popis fotografie.");
     $form->addText("source")->addRule(Form::MAX_LENGTH, "Maximální délka popisu může být %d znaků.", Photo::MAX_SOURCE_LENGTH)->setRequired("Zadej prosím zdroj fotografie.");
     $form->addText("photoTags")->setAttribute("size", 30);
     $form->addButton("addPhotoTag");
     $form->addSubmit("submit");
     $form->onSuccess[] = array($this, "addPhotoFormSucceeded");
     return $form;
 }
Example #4
0
 public function create()
 {
     $form = new Form();
     $form->addText("title")->addRule(Form::MAX_LENGTH, "Maximální délka nadpisu může být %d znaků.", Article::MAX_TITLE_LENGTH)->setRequired("Zadej prosím nadpis článku.");
     $form->addTextArea("content")->setAttribute("rows", 15)->setAttribute("cols", 7)->setRequired("Zadej prosím text článku.");
     $form->addCheckboxList("categories", null, $this->categories)->setRequired("Vyber prosím alespoň jednu kategorii.");
     $form->addText("tags")->setAttribute("size", 30);
     $form->addButton("addTag");
     $form->addRadioList("publishedAt", null, array("now" => "Publikovat ihned", "noChange" => "Ponechat stávající", "later" => "Naplánovat na"))->setRequired("Zadej prosím datum vydání.");
     $form->addText("day")->setAttribute("size", 2)->setRequired("Zadej prosím den vydání.")->addRule(Form::RANGE, "Den musí být číselná hodnota v intervalu %d až %d.", array(1, 31))->setDefaultValue(date("j"));
     $form->addSelect("month")->setItems(DateTimeUtils::getMonths(), true)->setDefaultValue(date("n"));
     $form->addSelect("year")->setItems(DateTimeUtils::getYears(), false)->setDefaultValue(date("Y"));
     $form->addText("hour")->setAttribute("size", 2)->setRequired("Zadej prosím hodinu vydání.")->addRule(Form::RANGE, "Hodina musí být číselná hodnota v intervalu %d až %d.", array(0, 23))->setDefaultValue(date("H"));
     $form->addText("minute")->setAttribute("size", 2)->setRequired("Zadej prosím minutu vydání.")->addRule(Form::RANGE, "Minuta musí být číselná hodnota v intervalu %d až %d.", array(0, 59))->setDefaultValue(date("i"));
     $form->addSubmit("submit");
     $form->onValidate[] = array($this, "validateAddArticleForm");
     $form->onSuccess[] = array($this, "addArticleFormSucceeded");
     return $form;
 }
Example #5
0
 protected function createComponentOsobaEditForm()
 {
     $form = new Form();
     $form->addText('jmeno', 'Jméno a příjmení')->addRule(Form::FILLED, 'Jméno a příjmení musí být vyplněno.');
     $form->addText('email', 'Email')->addRule(Form::EMAIL, 'Email musí být validní.');
     $form->addText('cisloJednotky', 'Číslo jednotky');
     $form->addCheckbox('chceMaily', 'Dostávat emaily?');
     if ($this->user->isInRole('spravce')) {
         $form->addMultiSelect('role', 'Role/oprávnění:', Model\UserManager::$roleDiakritika)->setAttribute('class', 'form-control');
     }
     $form->addHidden('id');
     $form->addSubmit('send', 'Uložit');
     if ($this->presenter->action == 'edit') {
         $form->addButton('delete', 'Smazat')->setAttribute('data-toggle', 'modal')->setAttribute('data-target', '#modal-delete')->setAttribute('class', 'btn btn-danger');
     }
     $form->onSuccess[] = array($this, 'osobaEditFormSucceeded');
     //$form->onValidate[] = array($this, 'validateLicenceForm');
     $form->setRenderer(new BootstrapRenderer());
     return $form;
 }
Example #6
0
 /**
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->getElementPrototype()->id = "actionForm";
     $form->addText("name", "Jméno akce:")->setHtmlId("name")->setRequired("Prosím zadejte jméno akce.");
     $form->addText("humanName", "Lidský formát akce:")->setHtmlId("humanName")->setRequired("Prosím zadejte jméno akce v lidském formátu.");
     $form->addHidden("aclActionID");
     $form->addButton("cancel", "Storno")->setHtmlId("cancel");
     $form->addSubmit("sender", "Uložit změny")->setHtmlId("sender");
     if ($this->aclActionID) {
         $actionEntity = $this->actionRepository->get($this->aclActionID);
         if ($actionEntity) {
             $form['aclActionID']->setValue($actionEntity->aclActionID);
             $form['name']->setValue($actionEntity->name);
             $form['humanName']->setValue($actionEntity->humanName);
         }
     }
     $form->onSuccess[] = callback($this, "Submit");
     $form->onError[] = callback($this, "Error");
     return $form;
 }
Example #7
0
 /** Vytvoření komponenty
  *
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->addText("login", "Přihlašovací jméno:")->setAttribute("autocomplete", "off")->setRequired("Prosím zadejte přihlašovací jméno.");
     $form->addPassword("password1", "Heslo:")->setAttribute("class", "form-control")->setAttribute("autocomplete", "off");
     $form->addPassword("password2", "Heslo pro kontrolu:")->setAttribute("class", "form-control")->setAttribute("autocomplete", "off");
     $roles = $this->roleRepository->read()->where("name != ?", "root");
     if (!$this->user->isInRole("root")) {
         $roles->where("name NOT(?)", $this->user->getRoles());
     }
     $roles = $roles->fetchPairs("aclRoleID", "name");
     $form->addSelect("role", "Oprávnění:", $roles)->setAttribute("class", "form-control");
     $form->addCheckbox("active", "Aktivní");
     $form->addButton("cancel", "Storno")->setHtmlId("cancel");
     $form->addSubmit("sender", "Uložit změny")->setHtmlId("sender");
     $form->addHidden("userID");
     $form['password2']->addRule(Form::EQUAL, 'Hesla se neshodují', $form['password1']);
     if ($this->rsuserID) {
         $userEntity = $this->userRepository->get($this->rsuserID);
         if ($userEntity) {
             $form['login']->setValue($userEntity->login);
             $form['login']->setAttribute("readonly");
             $form['userID']->setValue($this->rsuserID);
             $form['active']->setValue($userEntity->getActive());
             if ($userEntity->getUserID() == $this->user->getId()) {
                 $form['role']->setDisabled();
             }
             if ($userEntity->getLogin() != "root" && $userEntity->getUserID() !== $this->user->getId()) {
                 $form['role']->setValue($userEntity->aclRoleID);
             }
         }
     } else {
         $form['password1']->setRequired("Prosím zadejte heslo.");
     }
     $form->onSuccess[] = callback($this, "Submit");
     $form->onError[] = callback($this, "FormError");
     return $form;
 }
Example #8
0
 public function createComponentUploadFile()
 {
     $form = new \Nette\Application\UI\Form();
     $form->setTranslator($this->translator);
     $form->addUpload('file', 'File:')->setRequired()->addRule(\Nette\Application\UI\Form::MAX_FILE_SIZE, 'File is too big! Please, choose smaller one. It could be 3 megs large.', 3 * 1024 * 1024);
     $form->addButton('send', 'Upload');
     $form->onSuccess[] = array($this, 'saveFile');
     return $form;
 }
Example #9
0
 protected function createComponentDokumentEditForm()
 {
     $form = new Form();
     $kategorie = $this->kategorie->getSelect();
     $form->addText('jmeno', 'Jméno souboru')->addRule(Form::FILLED, 'Jméno souboru musí být vyplněno.');
     $form->addText('popis', 'Popis')->addRule(Form::FILLED, 'Popis souboru musí být vyplněn.');
     $form->addSelect('kategorie_id', 'Kategorie', $kategorie);
     $form->addCheckbox('verejne', 'Veřejný soubor');
     $form->addSubmit('send', 'Uložit');
     $form->addButton('delete', 'Smazat')->setAttribute('data-toggle', 'modal')->setAttribute('data-target', '#modal-delete')->setAttribute('class', 'btn btn-danger');
     $form->addHidden('id');
     $form->onSuccess[] = array($this, 'dokumentEditFormSucceeded');
     //$form->onValidate[] = array($this, 'validateLicenceForm');
     $form->setRenderer(new BootstrapRenderer());
     return $form;
 }
Example #10
0
 public function createComponentAddFileForm()
 {
     $form = new AppForm();
     $form->addSelect('file_id', 'Add file:', $this->files->getFilesToSelect('image'));
     $form->addButton('add', 'Add');
     $form->onSuccess[] = array($this, 'saveFile');
     return $form;
 }
 protected function createComponentPasswdForm()
 {
     $form = new Form();
     $form->getElementPrototype()->class('ajax');
     $form->addButton('passwd_but', 'Změnit heslo')->setAttribute('class', 'button')->setAttribute('id', 'change_passwd_but');
     $form->addPassword('current_passwd')->setAttribute('placeholder', 'Aktuální heslo')->setAttribute('id', 'current_passwd_input')->setAttribute('class', 'user_settings_input');
     $form->addPassword('new_passwd')->setAttribute('placeholder', 'Nové heslo')->setAttribute('id', 'new_passwd_input')->setAttribute('class', 'user_settings_input');
     $form->addPassword('new_passwd_again')->setAttribute('placeholder', 'Potvrzení nového hesla')->setAttribute('id', 'new_passwd_again_input')->setAttribute('class', 'user_settings_input');
     $form->addSubmit('change_passwd_but_save', 'Uložit')->setAttribute('class', 'button last_passwd');
     $form->addButton('passwd_storno', 'Storno')->setAttribute('class', 'button last_passwd')->setAttribute('id', 'storno_passwd_but');
     $form->onSuccess[] = array($this, 'passwdFormSucceeded');
     return $form;
 }
Example #12
0
 /** Vytvoření formuláře
  * 
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->getElementPrototype()->id = "resourceForm";
     $form->addText("name", "Jméno modulu:")->setHtmlId("name")->setRequired("Prosím zadejte jméno modulu.");
     $form->addHidden("aclResourceID");
     $form->addButton("cancel", "Storno")->setHtmlId("cancel");
     $form->addSubmit("sender", "Uložit změny")->setHtmlId("sender");
     $actions = $this->actionRepository->read();
     $container = $form->addContainer("actions");
     foreach ($actions as $key => $action) {
         $container->addCheckbox($key, $action->humanName);
     }
     if ($this->aclResourceID) {
         $modelEntities = $this->modelRepository->read()->where("aclResourceID", $this->aclResourceID);
         $modelEntity = $modelEntities->fetch();
         if ($modelEntity) {
             $form['aclResourceID']->setValue($modelEntity->getAclResource()->getAclResourceID());
             $form['name']->setValue($modelEntity->getAclResource()->name);
             foreach ($modelEntities as $entity) {
                 $form["actions"][$entity->aclActionID]->setValue(TRUE);
             }
         } else {
             $resourceEntity = $this->resourceRepository->get($this->aclResourceID);
             if ($resourceEntity) {
                 $form['aclResourceID']->setValue($this->aclResourceID);
                 $form['name']->setValue($resourceEntity->getName());
             }
         }
     }
     $form->onSuccess[] = callback($this, "Submit");
     $form->onError[] = callback($this, "Error");
     return $form;
 }
Example #13
0
 /** Vytvoření formuláře
  * 
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->getElementPrototype()->id = "roleForm";
     $form->addText("name", "Jméno skupiny:")->setHtmlId("name")->setRequired("Prosím zadejte jméno skupiny oprávnění.");
     $form->addHidden("aclRoleID");
     $form->addButton("cancel", "Storno")->setHtmlId("cancel");
     $form->addSubmit("sender", "Uložit změny")->setHtmlId("sender");
     $resources = $this->resourceRepository->read();
     foreach ($resources as $resource) {
         $container = $form->addContainer($resource->aclResourceID);
         $actions = $this->modelRepository->read()->where("aclResourceID", $resource->aclResourceID);
         foreach ($actions as $key => $action) {
             $checkbox = $container->addCheckbox($key, $action->getAclAction()->humanName);
             if ($this->aclRoleID) {
                 $permissions = $this->permissionRepository->read()->where("aclRoleID", $this->aclRoleID)->where("aclModel.aclResourceID", $resource->aclResourceID)->where("aclModel.aclActionID", $action->aclActionID)->where("allowed", TRUE);
                 if ($permissions->count() > 0) {
                     $checkbox->setValue(TRUE);
                 }
             }
         }
     }
     if ($this->aclRoleID) {
         $roleEntity = $this->roleRepository->get($this->aclRoleID);
         if ($roleEntity) {
             $form['aclRoleID']->setValue($roleEntity->aclRoleID);
             $form['name']->setValue($roleEntity->name);
         }
     }
     $form->onSuccess[] = callback($this, "Submit");
     $form->onError[] = callback($this, "Error");
     return $form;
 }