Esempio n. 1
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'store', 'action' => '', 'method' => 'post'));
     $companyData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'company_data', 'label' => _('TXT_COMPANY_DATA'))));
     $companyData->AddChild(new FormEngine\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANY_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_COMPANYNAME'))))));
     $companyData->AddChild(new FormEngine\Elements\TextField(array('name' => 'shortcompanyname', 'label' => _('TXT_SHORT_COMPANY_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SHORT_COMPANY_NAME'))))));
     $companyData->AddChild(new FormEngine\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NIP')), new FormEngine\Rules\Custom(_('ERR_WRONG_NIP'), array(App::getModel('vat'), 'checkVAT'))))));
     $companyData->AddChild(new FormEngine\Elements\TextField(array('name' => 'krs', 'label' => _('TXT_KRS'))));
     $addressData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'address_data', 'label' => _('TXT_ADDRESS_COMPANY_DATA'))));
     $addressData->AddChild(new FormEngine\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACENAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $addressData->AddChild(new FormEngine\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_POSTCODE'))))));
     $addressData->AddChild(new FormEngine\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $addressData->AddChild(new FormEngine\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'))));
     $addressData->AddChild(new FormEngine\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $addressData->AddChild(new FormEngine\Elements\TextField(array('name' => 'province', 'label' => _('TXT_PROVINCE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PROVINCE'))))));
     $addressData->AddChild(new FormEngine\Elements\Select(array('name' => 'countries', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('countrieslist')->getCountryForSelect()), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $bankData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'bank_data', 'label' => _('TXT_BANK_DATA'))));
     $bankData->AddChild(new FormEngine\Elements\TextField(array('name' => 'bankname', 'label' => _('TXT_BANK_NAME'))));
     $bankData->AddChild(new FormEngine\Elements\TextField(array('name' => 'banknr', 'label' => _('TXT_BANK_NUMBER'), 'comment' => _('TXT_BANK_NUMBER_FORMAT'))));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_SINGLE_PHOTO'))));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('INVOICE_SINGLE_PHOTO'), 'repeat_min' => 0, 'repeat_max' => 1, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add')));
     $invoicedata = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'invoice_data', 'label' => _('TXT_INVOICE'))));
     $isinvoiceshopslogan = $invoicedata->AddChild(new FormEngine\Elements\RadioValueGroup(array('name' => 'isinvoiceshopslogan', 'label' => _('TXT_INVOICE_SHOW_SHOP_NAME_AND_TAG'), 'options' => FormEngine\Option::Make(array('1' => _('TXT_INVOICE_SHOW_SHOP_NAME'), '2' => _('TXT_INVOICE_SHOW_SHOP_NAME_AND_TAG'))), 'value' => '1')));
     $invoicedata->AddChild(new FormEngine\Elements\TextField(array('name' => 'invoiceshopslogan', 'label' => _('TXT_NAME_OF_INVOICE_TAG'), 'rules' => array(new FormEngine\Rules\Required(_('TXT_EMPTY_NAME_OF_INVOICE_TAG'))), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $isinvoiceshopslogan, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('2')))))));
     $Data = Event::dispatch($this, 'admin.store.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\NoCode());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Esempio n. 2
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'producer', 'action' => '', 'method' => 'post'));
     $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_MAIN_DATA'))));
     $languageData = $requiredData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'name', 'label' => _('TXT_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME')), new FormEngine\Rules\LanguageUnique(_('ERR_NAME_ALREADY_EXISTS'), 'producertranslation', 'name', null, array('column' => 'producerid', 'values' => (int) $this->registry->core->getParam()))))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'seo', 'label' => _('TXT_SEO_URL'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SEO_URL'))))));
     $languageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'description', 'label' => _('TXT_DESCRIPTION'), 'rows' => 10)));
     $requiredData->AddChild(new FormEngine\Elements\MultiSelect(array('name' => 'deliverer', 'label' => _('TXT_DELIVERER'), 'options' => FormEngine\Option::Make(App::getModel('deliverer')->getDelivererToSelect()))));
     $requiredData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p style="padding-left: 195px;"><a href="' . App::getURLAdressWithAdminPane() . 'deliverer/add' . '" target="_blank"><span>' . _('TXT_ADD_DELIVERER') . '</span></a></p>')));
     $metaData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'meta_data', 'label' => _('TXT_META_INFORMATION'))));
     $metaData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">W przypadku braku informacji META system wygeneruje je automatycznie. W każdej chwili możesz je zmienić edytując dane poniżej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $languageData = $metaData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'keyword_title', 'label' => _('TXT_KEYWORD_TITLE'))));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword_description', 'label' => _('TXT_KEYWORD_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000)));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword', 'label' => _('TXT_KEYWORDS'), 'comment' => _('TXT_KEYWORDS_HELP'))));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_SINGLE_PHOTO'))));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_SINGLE_PHOTO'), 'repeat_min' => 0, 'repeat_max' => 1, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add')));
     $layerData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'view_data', 'label' => _('TXT_STORES'))));
     $layerData->AddChild(new FormEngine\Elements\LayerSelector(array('name' => 'view', 'label' => _('TXT_VIEW'), 'default' => Helper::getViewIdsDefault())));
     $Data = Event::dispatch($this, 'admin.producer.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Esempio n. 3
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'news', 'action' => '', 'method' => 'post'));
     $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_MAIN_DATA'))));
     $languageData = $requiredData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'topic', 'label' => _('TXT_TOPIC'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_TOPIC')), new FormEngine\Rules\LanguageUnique(_('ERR_TOPIC_ALREADY_EXISTS'), 'newstranslation', 'topic', null, array('column' => 'newsid', 'values' => (int) $this->registry->core->getParam()))))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'seo', 'label' => _('TXT_SEO_URL'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SEO_URL'))))));
     $languageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'summary', 'label' => _('TXT_NEWS_SUMMARY'))));
     $languageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'content', 'label' => _('TXT_CONTENT'), 'comment' => _('TXT_MAX_LENGTH') . ' 5000', 'max_length' => 5000)));
     $requiredData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'publish', 'label' => _('TXT_PUBLISH'), 'default' => '1')));
     $requiredData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'featured', 'label' => _('Polecany'), 'default' => '1')));
     $metaData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'meta_data', 'label' => _('TXT_META_INFORMATION'))));
     $metaData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">W przypadku braku informacji META system wygeneruje je automatycznie. W każdej chwili możesz je zmienić edytując dane poniżej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $additionalData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'additional_data', 'label' => _('TXT_ADDITIONAL_INFORMATION'))));
     $additionalData->AddChild(new FormEngine\Elements\Date(array('name' => 'startdate', 'label' => _('TXT_START_DATE'))));
     $additionalData->AddChild(new FormEngine\Elements\Date(array('name' => 'enddate', 'label' => _('TXT_END_DATE'))));
     $languageData = $metaData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'keyword_title', 'label' => _('TXT_KEYWORD_TITLE'))));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword_description', 'label' => _('TXT_KEYWORD_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000)));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword', 'label' => _('TXT_KEYWORDS'), 'comment' => _('TXT_KEYWORDS_HELP'))));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_PHOTOS'))));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_PHOTOS'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add', 'main_id' => isset($this->populateData['photos_pane']['mainphotoid']) ? $this->populateData['photos_pane']['mainphotoid'] : NULL)));
     $layerData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'view_data', 'label' => _('TXT_STORES'))));
     $layerData->AddChild(new FormEngine\Elements\LayerSelector(array('name' => 'view', 'label' => _('TXT_VIEW'), 'default' => Helper::getViewIdsDefault())));
     $Data = Event::dispatch($this, 'admin.news.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Esempio n. 4
0
 public function edit()
 {
     // dodawanie zdjec
     $form = new FormEngine\Elements\Form(array('name' => 'edit_file', 'action' => '', 'method' => 'post'));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_PHOTOS'))));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_PHOTOS'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add')));
     $form->AddFilter(new FormEngine\Filters\Trim());
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         App::redirect(__ADMINPANE__ . '/files');
     }
     $this->renderLayout(array('form' => $form->Render()));
 }
Esempio n. 5
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     $this->_attributes['session_name'] = session_name();
     $this->_attributes['session_id'] = session_id();
     $this->_attributes['file_types'] = array('jpg', 'png', 'gif', 'swf');
     if (!isset($this->_attributes['file_source'])) {
         $this->_attributes['file_source'] = 'upload/';
     }
     $this->_attributes['file_types_description'] = \Gekosale\Translation::get('TXT_FILE_TYPES_IMAGE');
     $this->_attributes['upload_url'] = App::getURLAdressWithAdminPane() . 'files/add/' . base64_encode($this->_attributes['file_source']);
     $this->_attributes['load_handler'] = 'xajax_LoadFiles_' . $this->_id;
     App::getRegistry()->xajaxInterface->registerFunction(array('LoadFiles_' . $this->_id, $this, 'LoadFiles'));
     $this->_attributes['delete_handler'] = 'xajax_DeleteFile_' . $this->_id;
     App::getRegistry()->xajaxInterface->registerFunction(array('DeleteFile_' . $this->_id, $this, 'DeleteFile'));
     $this->_attributes['type_icons'] = array('cdup' => DESIGNPATH . '_images_panel/icons/filetypes/cdup.png', 'unknown' => DESIGNPATH . '_images_panel/icons/filetypes/unknown.png', 'directory' => DESIGNPATH . '_images_panel/icons/filetypes/directory.png', 'gif' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'png' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'jpg' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'bmp' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'txt' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'doc' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'rtf' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'odt' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'htm' => DESIGNPATH . '_images_panel/icons/filetypes/document.png', 'html' => DESIGNPATH . '_images_panel/icons/filetypes/document.png', 'php' => DESIGNPATH . '_images_panel/icons/filetypes/document.png');
 }
Esempio n. 6
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'deliverer', 'action' => '', 'method' => 'post'));
     $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_MAIN_DATA'))));
     $languageData = $requiredData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'name', 'label' => _('TXT_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME')), new FormEngine\Rules\LanguageUnique(_('ERR_NAME_ALREADY_EXISTS'), 'deliverertranslation', 'name', null, array('column' => 'delivererid', 'values' => (int) $this->registry->core->getParam()))))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'www', 'label' => _('TXT_WWW'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'comment' => _('TXT_EXAMPLE') . ': gekosale@gekosale.pl', 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL')), new FormEngine\Rules\Email(_('ERR_WRONG_EMAIL'))))));
     $relatedProducts = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'related_products', 'label' => _('TXT_SELECT_PRODUCTS'))));
     $relatedProducts->AddChild(new FormEngine\Elements\ProductSelect(array('name' => 'products', 'label' => _('TXT_SELECT_PRODUCTS'), 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE)));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_SINGLE_PHOTO'))));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_SINGLE_PHOTO'), 'repeat_min' => 0, 'repeat_max' => 1, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add')));
     $Data = Event::dispatch($this, 'admin.deliverer.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\NoCode());
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Esempio n. 7
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'category', 'action' => '', 'method' => 'post'));
     $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_BASIC_INFORMATION'))));
     $languageData = $requiredData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'name', 'label' => _('TXT_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME'))))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'seo', 'label' => _('TXT_SEO_URL'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_CATEGORY_SEO')), new FormEngine\Rules\Format(_('ERR_ALPHANUMERIC_INVALID'), '/^[A-Za-z0-9-_\\/\\",\'\\s]+$/'), new FormEngine\Rules\LanguageUnique(_('ERR_CATEGORY_SEO_ALREADY_EXISTS'), 'categorytranslation', 'seo', null, array('column' => 'categoryid', 'values' => (int) $this->registry->core->getParam()))))));
     $requiredData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'enable', 'label' => _('TXT_ENABLE_CATEGORY'), 'default' => '1')));
     $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'distinction', 'label' => _('TXT_CATEGORY_ORDER'))));
     $requiredData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>' . _('TXT_PARENT_CATEGORY') . '</p>')));
     if ($this->populateData['required_data']['categoryid']) {
         $active = $this->populateData['required_data']['categoryid'];
     } else {
         $active = $this->registry->core->getParam();
     }
     $requiredData->AddChild(new FormEngine\Elements\Tree(array('name' => 'categoryid', 'label' => _('TXT_CATEGORY'), 'comment' => _('TXT_PARENT_CATEGORY_EXAMPLE'), 'choosable' => true, 'selectable' => false, 'sortable' => false, 'clickable' => false, 'items' => App::getModel('category')->getChildCategories(0, array($active)), 'restrict' => (int) $this->registry->core->getParam(), 'load_children' => array(App::getModel('category'), 'getChildCategories'), 'rules' => array(new FormEngine\Rules\Custom(_('ERR_BIND_SELF_PARENT_INVALID'), array(App::getModel('category'), 'checkParentValue'), array('categoryid' => (int) $this->registry->core->getParam()))))));
     $metaData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'meta_data', 'label' => _('TXT_META_INFORMATION'))));
     $metaData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">W przypadku braku informacji META system wygeneruje je automatycznie. W każdej chwili możesz je zmienić edytując dane poniżej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $languageData = $metaData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'keywordtitle', 'label' => _('TXT_KEYWORD_TITLE'))));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyworddescription', 'label' => _('TXT_KEYWORD_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000)));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword', 'label' => _('TXT_KEYWORDS'), 'comment' => _('TXT_KEYWORDS_HELP'), 'max_length' => 1000)));
     $descriptionPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'description_pane', 'label' => _('TXT_DESCRIPTION'))));
     $descriptionLanguageData = $descriptionPane->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'shortdescription', 'label' => _('TXT_SHORTDESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 3000, 'rows' => 20)));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'description', 'label' => _('TXT_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 5000', 'max_length' => 3000, 'rows' => 30)));
     $products = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'category_products', 'label' => _('TXT_PRODUCTS'))));
     $products->AddChild(new FormEngine\Elements\ProductSelect(array('name' => 'products', 'label' => _('TXT_PRODUCTS'), 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE)));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_SINGLE_PHOTO'))));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_SINGLE_PHOTO'), 'repeat_min' => 0, 'repeat_max' => 1, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add')));
     $layerData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'view_data', 'label' => _('TXT_STORES'))));
     $layerData->AddChild(new FormEngine\Elements\LayerSelector(array('name' => 'view', 'label' => _('TXT_VIEW'))));
     $Data = Event::dispatch($this, 'admin.category.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Esempio n. 8
0
 public function initForm()
 {
     $set = App::getModel('attributegroup')->getSugestVariant((int) $this->registry->core->getParam());
     $availablity = $this->registry->core->getDefaultValueToSelect() + App::getModel('availablity')->getAvailablityToSelect();
     $form = new FormEngine\Elements\Form(array('name' => 'product', 'action' => '', 'method' => 'post'));
     $basicPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'basic_pane', 'label' => _('TXT_BASIC_INFORMATION'))));
     $basicLanguageData = $basicPane->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $seoname = $basicLanguageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'name', 'label' => _('TXT_PRODUCT_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PRODUCT_NAME')), new FormEngine\Rules\LanguageUnique(_('ERR_NAME_ALREADY_EXISTS'), 'producttranslation', 'name', null, array('column' => 'productid', 'values' => (int) $this->registry->core->getParam()))))));
     $basicLanguageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'seo', 'label' => _('TXT_PRODUCT_SEO'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PRODUCT_SEO')), new FormEngine\Rules\Format(_('ERR_ALPHANUMERIC_INVALID'), '/^[A-Za-z0-9-_\\",\'\\s]+$/'), new FormEngine\Rules\LanguageUnique('Wybierz inny adres URL, podany już istnieje', 'producttranslation', 'seo', null, array('column' => 'productid', 'values' => (int) $this->registry->core->getParam()))))));
     $basicPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'enable', 'label' => _('TXT_ENABLE_PRODUCT'), 'default' => '0')));
     $basicPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'ean', 'label' => _('TXT_EAN'))));
     $basicPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'delivelercode', 'label' => _('TXT_DELIVELERCODE'))));
     $producerid = $basicPane->AddChild(new FormEngine\Elements\Select(array('name' => 'producerid', 'label' => _('TXT_PRODUCER'), 'addable' => true, 'onAdd' => 'xajax_AddProducer', 'add_item_prompt' => 'Podaj nazwę producenta', 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('producer')->getProducerToSelect()))));
     $basicPane->AddChild(new FormEngine\Elements\Select(array('name' => 'delivererid', 'label' => _('TXT_DELIVERER'), 'addable' => true, 'onAdd' => 'xajax_AddDeliverer', 'add_item_prompt' => 'Podaj nazwę dostawcy', 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('deliverer')->getDelivererToSelect()))));
     $metaData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'meta_data', 'label' => _('TXT_META_INFORMATION'))));
     $metaData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">W przypadku braku informacji META system wygeneruje je automatycznie. W każdej chwili możesz je zmienić edytując dane poniżej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $languageData = $metaData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'keywordtitle', 'label' => _('TXT_KEYWORD_TITLE'))));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyworddescription', 'label' => _('TXT_KEYWORD_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000)));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword', 'label' => _('TXT_KEYWORDS'), 'comment' => _('TXT_KEYWORDS_HELP'))));
     $stockPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'stock_pane', 'label' => _('TXT_SHIPPING_STOCK_SETTINGS'))));
     if ((int) $set > 0) {
         $stockPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p><strong style="color: red;">UWAGA:</strong>Ten produkt posiada warianty produktu. Jego stan magazynowy zostanie określony automatycznie na podstawie sumy stanów magazynowych wszystkich wariantów. Przejdź do zakładki Warianty produktu aby edytować stany.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
         $stockPane->AddChild(new FormEngine\Elements\Constant(array('name' => 'stock', 'label' => _('TXT_STOCK'), 'suffix' => _('TXT_QTY'), 'default' => 0)));
         $stockPane->AddChild(new FormEngine\Elements\Hidden(array('name' => 'stock', 'label' => _('TXT_STOCK'), 'default' => 0)));
     } else {
         $stockPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'stock', 'label' => _('TXT_STOCK'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STOCK')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'suffix' => _('TXT_QTY'), 'default' => 0)));
     }
     $stockPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Śledzenie stanu magazynowego spowoduje, że stan magazynowy będzie się zmieniał automatycznie w przypadku zamówień. Produkty z włączonym śledzeniem i ilością 0 nie będą mogły być zamówione przez klientów.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $stockPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'trackstock', 'label' => _('TXT_TRACKSTOCK'))));
     $disableatstockenabled = $stockPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'disableatstockenabled', 'label' => _('TXT_DISABLEATSTOCK_ENABLE'), 'default' => '0')));
     $stockPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'disableatstock', 'label' => _('TXT_DISABLEATSTOCK'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $disableatstockenabled, new FormEngine\Conditions\Equals('1'))), 'default' => '0')));
     $stockPane->AddChild(new FormEngine\Elements\Select(array('name' => 'availablityid', 'label' => _('TXT_AVAILABLITY'), 'options' => FormEngine\Option::Make($availablity))));
     $categoryPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'category_pane', 'label' => _('TXT_CATEGORY'))));
     $categoryPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz kategorie w jakich ma pojawić się produkt. Kategoriami możesz zarządzać na stronie <a href="' . $this->registry->router->generate('admin', true, array('controller' => 'category')) . '" target="_blank">Katalog &raquo; Kategorie</a>.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $category = $categoryPane->AddChild(new FormEngine\Elements\Tree(array('name' => 'category', 'label' => _('TXT_CATEGORY'), 'choosable' => false, 'selectable' => true, 'sortable' => false, 'clickable' => false, 'items' => App::getModel('view')->getChildCategories(), 'load_children' => array(App::getModel('view'), 'getChildCategories'))));
     $pricePane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'price_pane', 'label' => _('TXT_PRICE'))));
     $vat = $pricePane->AddChild(new FormEngine\Elements\Select(array('name' => 'vatid', 'label' => _('TXT_VAT'), 'options' => FormEngine\Option::Make(App::getModel('vat')->getVATAll()), 'addable' => true, 'onAdd' => 'xajax_AddVat', 'add_item_prompt' => 'Podaj wartość stawki VAT')));
     $currencies = App::getModel('currencieslist')->getCurrencyForSelect();
     $sellcurrency = $pricePane->AddChild(new FormEngine\Elements\Select(array('name' => 'sellcurrencyid', 'label' => _('TXT_SELL_CURRENCY'), 'options' => FormEngine\Option::Make($currencies), 'default' => Session::getActiveShopCurrencyId())));
     $buycurrency = $pricePane->AddChild(new FormEngine\Elements\Select(array('name' => 'buycurrencyid', 'label' => _('TXT_BUY_CURRENCY'), 'options' => FormEngine\Option::Make($currencies), 'default' => Session::getActiveShopCurrencyId())));
     $pricePane->AddChild(new FormEngine\Elements\Price(array('name' => 'buyprice', 'label' => _('TXT_BUYPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_BUYPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), 'vat_field' => $vat)));
     $standardPrice = $pricePane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'standard_price', 'label' => _('TXT_STANDARD_SELLPRICE'), 'class' => 'priceGroup')));
     $price = $standardPrice->AddChild(new FormEngine\Elements\Price(array('name' => 'sellprice', 'label' => _('TXT_SELLPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat)));
     $enablePromotion = $standardPrice->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'promotion', 'label' => _('TXT_ENABLE_PROMOTION'), 'default' => '0')));
     $standardPrice->AddChild(new FormEngine\Elements\Price(array('name' => 'discountprice', 'label' => _('TXT_DISCOUNTPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $enablePromotion, new FormEngine\Conditions\Equals(1))))));
     $standardPrice->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionstart', 'label' => _('TXT_START_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $enablePromotion, new FormEngine\Conditions\Equals(1))))));
     $standardPrice->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionend', 'label' => _('TXT_END_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $enablePromotion, new FormEngine\Conditions\Equals(1))))));
     $pricePane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center"><strong>Ceny dla grup klientów</strong><br />Jeżeli chcesz aby dana grupa klientów posiadała inne ceny, uzupełnij wybrane sekcje poniżej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $clientGroups = App::getModel('clientgroup/clientgroup')->getClientGroupAll();
     foreach ($clientGroups as $clientGroup) {
         $group = $pricePane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'field_' . $clientGroup['id'], 'label' => $clientGroup['name'], 'class' => 'priceGroup')));
         $groups[$clientGroup['id']] = $group->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'groupid_' . $clientGroup['id'], 'label' => _('TXT_ENABLE_GROUP_PRICE'), 'default' => '0')));
         $group->AddChild(new FormEngine\Elements\Price(array('name' => 'sellprice_' . $clientGroup['id'], 'label' => _('TXT_SELLPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $groups[$clientGroup['id']], new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals(1)))))));
         $promotion[$clientGroup['id']] = $group->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'promotion_' . $clientGroup['id'], 'label' => _('TXT_ENABLE_CLIENTGROUP_PROMOTION'), 'default' => '0')));
         $group->AddChild(new FormEngine\Elements\Price(array('name' => 'discountprice_' . $clientGroup['id'], 'label' => _('TXT_DISCOUNTPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $promotion[$clientGroup['id']], new FormEngine\Conditions\Equals(1))))));
         $group->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionstart_' . $clientGroup['id'], 'label' => _('TXT_START_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $promotion[$clientGroup['id']], new FormEngine\Conditions\Equals(1))))));
         $group->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionend_' . $clientGroup['id'], 'label' => _('TXT_END_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $promotion[$clientGroup['id']], new FormEngine\Conditions\Equals(1))))));
     }
     $weightPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'weight_pane', 'label' => _('TXT_WEIGHT_DATA'))));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'weight', 'label' => _('TXT_WEIGHT'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_WEIGHT')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'suffix' => 'kg', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), 'default' => 0)));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'width', 'label' => _('TXT_WIDTH'), 'suffix' => 'cm', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()))));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'height', 'label' => _('TXT_HEIGHT'), 'suffix' => 'cm', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()))));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'deepth', 'label' => _('TXT_DEEPTH'), 'suffix' => 'cm', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()))));
     $weightPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz miarę produktu w jakiej sprzedawany jest produkt. Jednostkami możesz zarządzać na stronie <a href="' . $this->registry->router->generate('admin', true, array('controller' => 'unitmeasure')) . '" target="_blank">Katalog &raquo; Jednostka miary</a>. Jeżeli chcesz tylko dodać nową opcję, użyj ikony dodawania obok listy wyboru.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $weightPane->AddChild(new FormEngine\Elements\Select(array('name' => 'unit', 'label' => _('TXT_UNIT_MEASURE'), 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('unitmeasure')->getUnitMeasureToSelect()), 'addable' => true, 'onAdd' => 'xajax_AddUnitMeasure', 'add_item_prompt' => 'Podaj nazwę jednostki miary', 'default' => 0)));
     $weightPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wpisz ilość sztuk w opakowaniu. Podczas dodawania produktu do koszyka ilość zostanie zaokrąglona do pełnych opakowań</p>')));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'packagesize', 'label' => _('TXT_PACKAGE_SIZE'), 'comment' => _('TXT_PACKAGE_SIZE_HELP'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PACKAGE_SIZE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), 'default' => 1)));
     $descriptionPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'description_pane', 'label' => _('TXT_DESCRIPTION'))));
     $descriptionLanguageData = $descriptionPane->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'shortdescription', 'label' => _('TXT_SHORTDESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000, 'rows' => 20)));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'description', 'label' => _('TXT_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 5000', 'max_length' => 5000, 'rows' => 30)));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'longdescription', 'label' => _('TXT_ADDITIONAL_INFO'), 'rows' => 30)));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_PHOTOS'))));
     $photosPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz zdjęcia dla produktu z biblioteki lub wgraj je z dysku komputera. Zdjęcie oznaczone jako główne będzie wyświetlane w listach produktów oraz w karcie produktu jako pierwsze.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_PHOTOS'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add', 'main_id' => isset($this->populateData['photos_pane']['mainphotoid']) ? $this->populateData['photos_pane']['mainphotoid'] : '')));
     $filePane = $form->addChild(new FormEngine\Elements\Fieldset(array('name' => 'files_pane', 'label' => _('TXT_FILES'))));
     $filePane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz pliki z biblioteki, które chcesz przypisać do tego produktu.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $filePane->AddChild(new FormEngine\Elements\Downloader(array('name' => 'file', 'label' => _('TXT_FILES'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'virtualproduct/add')));
     $warrantyPane = $form->addChild(new FormEngine\Elements\Fieldset(array('name' => 'warranty_pane', 'label' => _('TXT_WARRANTY'))));
     $warrantyPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz pliki z biblioteki, które chcesz przypisać do tego produktu.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $warrantyPane->AddChild(new FormEngine\Elements\Downloader(array('name' => 'warranty', 'label' => _('TXT_WARRANTY'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'virtualproduct/add')));
     $upsellProducts = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'upsell_products', 'label' => _('TXT_UPSELL'))));
     $upsellProducts->AddChild(new FormEngine\Elements\ProductSelectRelated(array('name' => 'upsell', 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'exclude' => array((int) $this->registry->core->getParam()))));
     $similarProducts = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'similar_products', 'label' => _('TXT_SIMILAR_PRODUCT_LIST'))));
     $similarProducts->AddChild(new FormEngine\Elements\ProductSelectRelated(array('name' => 'similar', 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'exclude' => array((int) $this->registry->core->getParam()))));
     $crosssellProducts = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'crosssell_products', 'label' => _('TXT_CROSSSELL'))));
     $crosssellProducts->AddChild(new FormEngine\Elements\ProductSelectRelated(array('name' => 'crosssell', 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'exclude' => array((int) $this->registry->core->getParam()))));
     $statusProductPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'statusproduct_pane', 'label' => _('TXT_PRODUCT_STATUS'))));
     $statusProductPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Statusy produktów są używane do wyświetlania specjalnych oznaczeń na listach i kartach produktów.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $statusProductPane->AddChild(new FormEngine\Elements\MultiSelect(array('name' => 'productstatuses', 'label' => _('TXT_PRODUCT_STATUS'), 'addable' => true, 'onAdd' => 'xajax_AddProductStatus', 'add_item_prompt' => 'Podaj nazwę statusu', 'options' => FormEngine\Option::Make(App::getModel('productstatus')->getProductstatusAll(false)))));
     $idnew = $statusProductPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'newactive', 'label' => _('TXT_PRODUCT_IS_NEW'))));
     $newData = $statusProductPane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'new_data', 'label' => _('TXT_NEW_DATA'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $idnew, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1')))))));
     $newData->AddChild(new FormEngine\Elements\Date(array('name' => 'startnew', 'label' => _('TXT_START_DATE'))));
     $newData->AddChild(new FormEngine\Elements\Date(array('name' => 'endnew', 'label' => _('TXT_END_DATE'))));
     $groups = App::getModel('attributegroup/attributegroup')->getGroupsForCategory(0);
     if (!empty($groups)) {
         $variantsPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'variants_pane', 'label' => _('TXT_PRODUCT_VARIANTS'))));
         $variantsPane->AddChild(new FormEngine\Elements\ProductVariantsEditor(array('name' => 'variants', 'label' => _('TXT_PRODUCT_VARIANTS'), 'category' => $category, 'price' => $price, 'set' => $set, 'vat_field' => $vat, 'availablity' => $availablity, 'photos' => App::getModel('product')->productSelectedPhotos((int) $this->registry->core->getParam()), 'allow_generate' => App::getModel('order')->checkProductWithAttributes((int) $this->registry->core->getParam()))));
     }
     $Data = Event::dispatch($this, 'admin.product.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Esempio n. 9
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'client', 'action' => '', 'method' => 'post'));
     $personalData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'personal_data', 'label' => _('TXT_PERSONAL_DATA'))));
     $personalData->AddChild(new FormEngine\Elements\Select(array('name' => 'viewid', 'label' => _('TXT_SHOP'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SHOP'))), 'options' => FormEngine\Option::Make(App::getModel('view')->getViewAllSelect()), 'default' => Helper::getViewId())));
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     if ($this->getParam() > 0) {
         $personalData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Uwaga zmieniając adres Email zmieni sie również login do sklepu</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     } else {
         $personalData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Dla klienta zostanie wygenerowane hasło które umożliwi mu dostęp do panelu sklepu. Hasło zostanie wysłane na podany adres e-mail.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     }
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'comment' => _('TXT_EMAIL_FORM'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL')), new FormEngine\Rules\Email(_('ERR_WRONG_EMAIL')), new FormEngine\Rules\Unique(_('ERR_EMAIL_ALREADY_EXISTS'), 'clientdata', 'email', null, array('column' => 'email', 'values' => (int) $this->registry->core->getParam()))))));
     $personalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'newsletter', 'label' => _('TXT_NEWSLETTER'), 'default' => '1')));
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'phone', 'label' => _('TXT_PHONE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PHONE')), new FormEngine\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/')))));
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'phone2', 'label' => _('TXT_ADDITIONAL_PHONE'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/')))));
     $personalData->AddChild(new FormEngine\Elements\Select(array('name' => 'clientgroupid', 'label' => _('TXT_GROUPS'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_GROUPS'))), 'addable' => true, 'onAdd' => 'xajax_AddClientGroup', 'add_item_prompt' => 'Podaj nazwę grupy', 'options' => FormEngine\Option::Make(App::getModel('clientgroup/clientgroup')->getClientGroupAllToSelect()))));
     $personalData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Klient będzie awansowany/degradowany zgodnie z ustawieniami automatycznego awansu w <a href="' . $this->registry->router->generate('admin', true, array('controller' => 'view')) . '" target="_blank">Konfiguracja &raquo; Sklepy</a></p>')));
     $personalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'autoassign', 'label' => _('TXT_AUTO_ASSIGN'), 'default' => '1')));
     $additionalData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'additional_data', 'label' => _('TXT_ADDITIONAL_DATA'))));
     $additionalData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'description', 'label' => _('TXT_DESCRIPTION'))));
     $additionalData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Blokada konta uniemożliwia zalogowanie klienta w sklepie oraz ponowną rejestrację za pomocą tego samego adresu e-mail.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $additionalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'disable', 'label' => _('TXT_DISABLE_CLIENT'))));
     $billingData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'billing_data', 'label' => _('TXT_EDIT_ORDER_BILLING_DATA'))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_POSTCODE')), new FormEngine\Rules\Format(_('ERR_WRONG_FORMAT'), "/[0-9]{2}\\-[0-9]{3}/")))));
     $billingData->AddChild(new FormEngine\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => FormEngine\Option::Make(App::getModel('countrieslist')->getCountryForSelect()), 'default' => $this->registry->loader->getParam('countryid'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'))));
     $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new FormEngine\Rules\Custom(_('ERR_WRONG_NIP'), array(App::getModel('vat'), 'checkVAT'))))));
     $shippingData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'shipping_data', 'label' => _('TXT_EDIT_ORDER_SHIPPING_DATA'))));
     $copy = $shippingData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<a href="#" id="copy">' . _('TXT_JS_ADDRESS_COPY_FROM') . '</a>')));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_POSTCODE')), new FormEngine\Rules\Format(_('ERR_WRONG_FORMAT'), "/[0-9]{2}\\-[0-9]{3}/")))));
     $shippingData->AddChild(new FormEngine\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => FormEngine\Option::Make(App::getModel('countrieslist')->getCountryForSelect()), 'default' => $this->registry->loader->getParam('countryid'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'))));
     $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new FormEngine\Rules\Custom(_('ERR_WRONG_NIP'), array(App::getModel('vat'), 'checkVAT'))))));
     if ((int) $this->registry->core->getParam() > 0) {
         $clientsData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'orders', 'label' => _('TXT_CLIENT_ORDERS'))));
         $history = App::getModel('order')->getclientOrderHistory((int) $this->registry->core->getParam());
         if (count($history) > 0) {
             $html = '<div class="view-order"><ul class="changes-detailed">';
             foreach ($history as $order) {
                 $url = App::getURLAdressWithAdminPane() . 'order/edit/' . $order['idorder'];
                 $html .= "<li>";
                 $html .= "<h4><span>{$order['adddate']}</span></h4>";
                 $html .= "<p>Nr. zamówienia:  <strong><a href=\"{$url}\" target=\"_blank\">#{$order['idorder']}</a></strong></p>";
                 $html .= "<p class=\"author\">" . _('TXT_ALL_ORDERS_PRICE') . ": <strong>{$order['globalprice']}</strong></p>";
                 $html .= "<p class=\"author\">" . _('TXT_ORDER_STATUS') . ": <strong>{$order['status']}</strong></p>";
                 $html .= "</li>";
             }
             $html .= '</div>';
         } else {
             $html = '<p>' . _('TXT_ORDER_HISTORY_EMPTY') . '</p>';
         }
         $clientsData->AddChild(new FormEngine\Elements\StaticText(array('text' => $html)));
     }
     $Data = Event::dispatch($this, 'admin.client.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\NoCode());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Esempio n. 10
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'view', 'action' => '', 'method' => 'post'));
     $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_MAIN_DATA'))));
     $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'name', 'label' => _('TXT_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME'))))));
     $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz domyślny szablon sklepu. Szablonami możesz zarządzać na stronie <a href="' . App::getURLAdressWithAdminPane() . 'templateeditor' . '" target="_blank">Szablony stylów &raquo; Biblioteka szablonów</a>.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $requiredData->AddChild(new FormEngine\Elements\Select(array('name' => 'pageschemeid', 'label' => _('TXT_PAGESCHEME'), 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('pagescheme')->getPageschemeAllToSelect()), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PAGESCHEME'))))));
     $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz firmę/podmiot obsługujący sklep. Firmami możesz zarządzać na stronie <a href="' . App::getURLAdressWithAdminPane() . 'store' . '" target="_blank">Konfiguracja &raquo; Firmy</a>.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $requiredData->AddChild(new FormEngine\Elements\Select(array('name' => 'store', 'label' => _('TXT_STORE'), 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('store')->getStoreToSelect()), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STORE'))))));
     $requiredData->AddChild(new FormEngine\Elements\Hidden(array('name' => 'currencyid')));
     $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz domyślny kontakt dla sklepu. Kontaktami możesz zarządzać na stronie <a href="' . App::getURLAdressWithAdminPane() . 'contact' . '" target="_blank">Konfiguracja &raquo; Kontakt</a>.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $requiredData->AddChild(new FormEngine\Elements\Select(array('name' => 'contactid', 'label' => _('TXT_DEFAULT_CONTACT'), 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('contact')->getContactToSelect()))));
     $requiredData->AddChild(new FormEngine\Elements\Select(array('name' => 'showtax', 'label' => _('TXT_SHOW_TAX_VALUE'), 'options' => FormEngine\Option::Make(App::getModel('suffix/suffix')->getPrice()), 'default' => 1)));
     $requiredData->AddChild(new FormEngine\Elements\Select(array('name' => 'defaultvatid', 'label' => _('TXT_DEFAULT_VAT'), 'options' => FormEngine\Option::Make(App::getModel('vat')->getVATAll()), 'default' => 2)));
     $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'namespace', 'label' => _('TXT_NAMESPACE'))));
     $offline = $requiredData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'offline', 'label' => _('TXT_SHOP_OFFLINE'), 'comment' => _('TXT_OFFLINE_INSTRUCTION'))));
     $requiredData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'offlinetext', 'label' => _('TXT_OFFLINE_MESSAGE'), 'comment' => _('TXT_MAX_LENGTH') . ' 5000', 'rows' => 50, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $offline, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1')))))));
     $metaData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'meta_data', 'label' => _('TXT_META_INFORMATION'))));
     $languageData = $metaData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'keyword_title', 'label' => _('TXT_KEYWORD_TITLE'))));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword_description', 'label' => _('TXT_KEYWORD_DESCRIPTION'))));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword', 'label' => _('TXT_KEYWORDS'), 'comment' => _('TXT_KEYWORDS_HELP'))));
     $languageData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Możesz dodać dowolne znaczniki do sekcji HEAD szablonu sklepu. Wykorzystaj to pole np. do przeprowadzenia weryfikacji domeny dla Google Apps.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'additionalmeta', 'label' => _('TXT_ADDITIONAL_META'), 'rows' => 10)));
     $url = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'url_pane', 'label' => _('TXT_WWW'))));
     $url->AddChild(new FormEngine\Elements\TextField(array('name' => 'url', 'label' => _('TXT_URL'))));
     $categoryPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'category_pane', 'label' => _('TXT_CATEGORY'))));
     $categories = App::getModel('view')->getChildCategories();
     if (count($categories) > 0) {
         $categoryPane->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>' . _('TXT_VIEW_CATEGORY_INSTRUCTION') . '</p>')));
     } else {
         $categoryPane->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>' . _('TXT_VIEW_CATEGORY_EMPTY_INSTRUCTION') . '</p>')));
     }
     $category = $categoryPane->AddChild(new FormEngine\Elements\Tree(array('name' => 'category', 'label' => _('TXT_CATEGORY'), 'sortable' => false, 'selectable' => true, 'clickable' => false, 'items' => $categories, 'load_children' => array(App::getModel('view'), 'getChildCategories'))));
     $dispatchmethodPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'dispatchmethod_pane', 'label' => _('TXT_DISPATCHMETHOD_PANE'))));
     $dispatchmethodPane->AddChild(new FormEngine\Elements\MultiSelect(array('name' => 'dispatchmethod', 'label' => _('TXT_DISPATCHMETHOD'), 'options' => FormEngine\Option::Make(App::getModel('dispatchmethod')->getDispatchmethodToSelect()))));
     $paymentmethodPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'paymentmethod_pane', 'label' => _('TXT_PAYMENTMETHOD_PANE'))));
     $paymentmethodPane->AddChild(new FormEngine\Elements\MultiSelect(array('name' => 'paymentmethod', 'label' => _('TXT_PAYMENTMETHOD'), 'options' => FormEngine\Option::Make(App::getModel('paymentmethod')->getPaymentmethodToSelect()))));
     $assignToGroupData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'assigntogroup_data', 'label' => _('TXT_AUTOMATICLY_ASSIGN_TO_GROUP'))));
     $assignToGroupData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Automatyczny awans umożliwia przechodzenie klientom Twojego sklepu do wyższych grup rabatowych w zależności od tego ile zakupów zrealizują w określonym czasie.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $assignToGroupData->AddChild(new FormEngine\Elements\Select(array('name' => 'taxes', 'label' => _('TXT_TAKE_THE_VALUE'), 'options' => array(new FormEngine\Option('0', _('TXT_NETTO')), new FormEngine\Option('1', _('TXT_PRICE_GROSS'))), 'suffix' => _('TXT_CLIENT_ORDERS'))));
     $assignToGroupData->AddChild(new FormEngine\Elements\Select(array('name' => 'periodid', 'label' => _('TXT_PERIOD'), 'options' => FormEngine\Option::Make(App::getModel('period/period')->getPeriod()))));
     $assignToGroupData->AddChild(new FormEngine\Elements\RangeEditor(array('name' => 'table', 'label' => _('TXT_DISPATCHMETHOD_TABLE_PRICE'), 'suffix' => _('TXT_CURRENCY'), 'range_suffix' => _('TXT_CURRENCY'), 'options' => FormEngine\Option::Make(App::getModel('clientgroup')->getClientGroupToRangeEditor()))));
     $registrationData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'registration_data', 'label' => _('TXT_REGISTRATION_SETTINGS'))));
     $registrationData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'forcelogin', 'label' => _('TXT_FORCE_CLIENT_LOGIN'), 'comment' => _('TXT_FORCE_CLIENT_LOGIN_HELP'))));
     $registrationData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'enableregistration', 'label' => _('TXT_ENABLE_REGISTRATION'), 'comment' => _('TXT_ENABLE_REGISTRATION_HELP'))));
     $registrationData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'confirmregistration', 'label' => _('TXT_REGISTRATION_CONFIRM'), 'comment' => _('TXT_REGISTRATION_CONFIRM_HELP'))));
     $cartData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'cart_data', 'label' => _('TXT_CART_SETTINGS'))));
     $cartData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'cartredirect', 'label' => _('TXT_CART_REDIRECT'))));
     $cartData->AddChild(new FormEngine\Elements\TextField(array('name' => 'minimumordervalue', 'label' => _('TXT_MINIMUM_ORDER_VALUE'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'default' => 0)));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'logo', 'label' => _('TXT_LOGO'))));
     $photosPane->AddChild(new FormEngine\Elements\LocalFile(array('name' => 'photo', 'label' => _('TXT_LOGO'), 'file_source' => 'design/_images_frontend/core/logos/', 'file_types' => array('png', 'jpg', 'gif'))));
     $photosPane->AddChild(new FormEngine\Elements\LocalFile(array('name' => 'favicon', 'label' => _('TXT_FAVICON'), 'file_source' => 'design/_images_frontend/core/logos/', 'file_types' => array('ico'))));
     $photosPane->AddChild(new FormEngine\Elements\LocalFile(array('name' => 'watermark', 'label' => _('TXT_WATERMARK'), 'file_source' => 'design/_images_frontend/core/logos/', 'file_types' => array('png'))));
     $mailerdata = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'mailer_data', 'label' => _('TXT_MAIL_SETTINGS'))));
     $mailerType = $mailerdata->AddChild(new FormEngine\Elements\Select(array('name' => 'mailer', 'label' => _('TXT_MAIL_TYPE'), 'options' => FormEngine\Option::Make(array('mail' => 'mail', 'sendmail' => 'sendmail', 'smtp' => 'smtp')))));
     $mailerdata->AddChild(new FormEngine\Elements\TextField(array('name' => 'server', 'label' => _('TXT_MAIL_SERVER'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $mailerType, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('smtp')))), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_MAIL_SERVER'))))));
     $mailerdata->AddChild(new FormEngine\Elements\TextField(array('name' => 'port', 'label' => _('TXT_MAIL_SERVER_PORT'), 'default' => 587, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $mailerType, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('smtp')))), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_MAIL_SERVER_PORT'))))));
     $mailerdata->AddChild(new FormEngine\Elements\Select(array('name' => 'smtpsecure', 'label' => _('TXT_MAIL_SMTP_SECURE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $mailerType, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('smtp')))), 'options' => FormEngine\Option::Make(array('' => 'brak', 'ssl' => 'ssl', 'tls' => 'tls')), 'value' => '')));
     $mailerdata->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'smtpauth', 'label' => _('TXT_MAIL_SMTP_AUTH'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $mailerType, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('smtp')))))));
     $mailerdata->AddChild(new FormEngine\Elements\TextField(array('name' => 'smtpusername', 'label' => _('TXT_MAIL_SMTP_USERNAME'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $mailerType, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('smtp')))))));
     $mailerdata->AddChild(new FormEngine\Elements\Password(array('name' => 'smtppassword', 'label' => _('TXT_MAIL_SMTP_PASSWORD'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $mailerType, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('smtp')))))));
     $mailerdata->AddChild(new FormEngine\Elements\TextField(array('name' => 'fromname', 'label' => _('TXT_MAIL_FROMNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_MAIL_FROMNAME'))))));
     $mailerdata->AddChild(new FormEngine\Elements\TextField(array('name' => 'fromemail', 'label' => _('TXT_MAIL_FROMEMAIL'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_MAIL_FROMEMAIL'))))));
     $mailerdata->AddChild(new FormEngine\Elements\LocalFile(array('name' => 'terms', 'label' => 'Plik regulaminu', 'comment' => 'Zostanie załączony do każdego maila z potwierdzeniem zamówienia', 'file_source' => 'upload/', 'file_types' => array('pdf'))));
     $invoicedata = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'invoice_data', 'label' => _('TXT_INVOICE'))));
     $invoicedata->AddChild(new FormEngine\Elements\Select(array('name' => 'invoicenumerationkind', 'label' => _('TXT_INVOICE_NUMERATION'), 'options' => FormEngine\Option::Make(App::getModel('invoice')->getInvoiceNumerationTypes()))));
     $invoicedata->AddChild(new FormEngine\Elements\TextField(array('name' => 'invoicedefaultpaymentdue', 'label' => _('TXT_INVOICE_DEFAULT_PAYMENT_DUE'), 'suffix' => _('TXT_DAYS'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')))));
     $Data = Event::dispatch($this, 'admin.view.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     return $form;
 }
Esempio n. 11
0
 public function edit()
 {
     $rawUserData = App::getModel('users')->getUserById($this->registry->core->getParam());
     if (empty($rawUserData)) {
         App::redirect(__ADMINPANE__ . '/users');
     }
     $layers = App::getModel('users')->getLayersAll();
     $form = new FormEngine\Elements\Form(array('name' => 'user', 'action' => '', 'method' => 'post'));
     $personalData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'personal_data', 'label' => _('TXT_PERSONAL_DATA'))));
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $personalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL')), new FormEngine\Rules\Email(_('ERR_WRONG_EMAIL')), new FormEngine\Rules\Unique(_('ERR_EMAIL_ALREADY_EXISTS'), 'userdata', 'email', null, array('column' => 'userid', 'values' => $this->registry->core->getParam()))))));
     $changePassword = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'change_password', 'label' => _('TXT_CHANGE_USERS_PASSWORD'))));
     $userid = Session::getActiveUserid();
     $edituserid = $this->registry->core->getParam();
     if ($userid == $edituserid) {
         $newPasswordChange = $changePassword->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'changepassword', 'label' => _('TXT_CHANGE_PASS'))));
         $oldPassword = $changePassword->AddChild(new FormEngine\Elements\Password(array('name' => 'oldpasswd', 'label' => _('TXT_PASSWORD_OLD'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $newPasswordChange, new FormEngine\Conditions\Equals('1'))))));
         $newPassword = $changePassword->AddChild(new FormEngine\Elements\Password(array('name' => 'newppasswd', 'label' => _('TXT_PASSWORD_NEW'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PASSWORD')), new FormEngine\Rules\Format(_('ERR_PASSWORD_NEW_INVALID'), '/^.{6,}$/')), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $newPasswordChange, new FormEngine\Conditions\Equals('1'))))));
         $changePassword->AddChild(new FormEngine\Elements\Password(array('name' => 'newpasswdrep', 'label' => _('TXT_PASSWORD_REPEAT'), 'rules' => array(new FormEngine\Rules\Compare(_('ERR_PASSWORDS_NOT_COMPATIBILE'), $newPassword)), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $newPasswordChange, new FormEngine\Conditions\Equals('1'))))));
     } else {
         $changePassword->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>' . _('TXT_PASSWORD_CHANGE_INSTRUCTION') . '</p>')));
         $newPassword = $changePassword->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'newpassword', 'label' => _('TXT_PASSWORD_NEW'))));
     }
     $isglobal = App::getModel('users')->checkActiveUserIsGlobal();
     if ($isglobal == 1) {
         $rightsData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'rights_data', 'label' => _('TXT_RIGHTS'))));
         $rightsData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>' . _('TXT_SET_USER_LAYER_RIGHTS') . '</p>')));
         $global = $rightsData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'global', 'label' => _('TXT_GLOBAL_USER'))));
         $rightsData->AddChild(new FormEngine\Elements\Select(array('name' => 'group', 'label' => _('TXT_GROUPS'), 'options' => FormEngine\Option::Make(App::getModel('groups/groups')->getGroupsAllToSelect()), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_GROUP'))), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $global, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1')))))));
         $layers = App::getModel('users')->getLayersAll();
         foreach ($layers as $key => $store) {
             $storeRightsData[$store['id']] = $rightsData->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'store_' . $store['id'], 'label' => _('TXT_RIGHTS') . ' dla ' . $store['name'], 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $global, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1')))))));
             foreach ($store['views'] as $v => $view) {
                 $storeRightsData[$store['id']]->AddChild(new FormEngine\Elements\Select(array('name' => 'view_' . $view['id'], 'label' => $view['name'], 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('groups/groups')->getGroupsAllToSelect()))));
             }
         }
     }
     $additionalData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'additional_data', 'label' => _('TXT_ADDITIONAL_DATA'))));
     $additionalData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'description', 'label' => _('TXT_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 3000', 'max_length' => 3000)));
     $additionalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'active', 'label' => _('TXT_ENABLE_USER'))));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_PHOTO'))));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_PHOTO'), 'repeat_min' => 0, 'repeat_max' => 1, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add')));
     $form->AddFilter(new FormEngine\Filters\NoCode());
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\Secure());
     $userData = array('personal_data' => array('firstname' => $rawUserData['firstname'], 'surname' => $rawUserData['surname'], 'email' => $rawUserData['email']), 'additional_data' => array('description' => $rawUserData['description'], 'active' => $rawUserData['active']), 'photos_pane' => array('photo' => $rawUserData['photo']), 'rights_data' => array('global' => $rawUserData['globaluser'], 'group' => $rawUserData['idgroup']));
     foreach ($rawUserData['layer'] as $key => $layer) {
         $userData['rights_data']['store_' . $layer['store']][] = array('view_' . $layer['view'] => $layer['group']);
     }
     $form->Populate($userData);
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         try {
             $edituser = $form->getSubmitValues();
             App::getModel('users')->updateUser($edituser, $this->registry->core->getParam());
             if ($userid == $edituserid) {
                 if ($edituser['change_password']['changepassword'] == 1) {
                     $editpassword = $edituser['change_password']['newppasswd'];
                     $changPassword = App::getModel('users')->updateUserPassword($edituser['change_password']['newppasswd']);
                     Session::setActiveUserFirstname($edituser['personal_data']['firstname']);
                     Session::setActiveUserSurname($edituser['personal_data']['surname']);
                     Session::setActiveUserEmail($edituser['personal_data']['email']);
                 }
             } else {
                 if ($edituser['change_password']['newpassword'] == 1) {
                     $editpassword = Core::passwordGenerate();
                     $changPassword = App::getModel('users')->updateUserPassword($editpassword);
                     if ($changPassword == true) {
                         $password = Core::passwordGenerate();
                         $this->registry->template->assign('password', $editpassword);
                         App::getModel('mailer')->sendEmail(array('template' => 'newPasswordForUser', 'email' => array($edituser['personal_data']['email']), 'bcc' => false, 'subject' => _('TXT_EDIT_PASSWORD_USER'), 'viewid' => Helper::getViewId()));
                     }
                 }
             }
         } catch (Exception $e) {
             Session::setVolatileUsereditError(1, false);
         }
         App::redirect(__ADMINPANE__ . '/users');
     }
     $error = Session::getVolatileUsereditError();
     if ($error[0] == 1) {
         $this->registry->template->assign('error', $e->getMessage());
     }
     $this->registry->template->assign('form', $form->Render());
     $this->registry->xajax->processRequest();
     $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript());
     $this->registry->template->display($this->loadTemplate('edit.tpl'));
 }