public function add() { $form = new FormEngine\Elements\Form(array('name' => 'recipientlist', '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')), new FormEngine\Rules\Unique(_('ERR_NAME_ALREADY_EXISTS'), 'recipientlist', 'name'))))); $clientgroupData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'clientgroup_data', 'label' => _('TXT_CLIENT_GROUPS_LIST')))); $clientgroupData->AddChild(new FormEngine\Elements\DatagridSelect(array('name' => 'clientgroup', 'label' => _('TXT_CLIENTGROUPS'), 'key' => 'idclientgroup', 'datagrid_init_function' => array(App::getModel('clientgroup'), 'initDatagrid'), 'repeat_max' => FormEngine\FE::INFINITE, 'columns' => $this->getClientGroupDatagridColumns()))); $clientData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'client_data', 'label' => _('TXT_CLIENTS_LIST')))); $clientData->AddChild(new FormEngine\Elements\DatagridSelect(array('name' => 'clients', 'label' => _('TXT_CLIENT'), 'key' => 'idclient', 'datagrid_init_function' => array(App::getModel('client'), 'initDatagrid'), 'repeat_max' => FormEngine\FE::INFINITE, 'columns' => $this->getClientDatagridColumns()))); $clientnewsletterData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'clientnewsletter_data', 'label' => _('TXT_CLIENT_NEWSLETTER_LIST')))); $clientnewsletterData->AddChild(new FormEngine\Elements\DatagridSelect(array('name' => 'clientnewsletter', 'label' => _('TXT_CLIENT_NEWSLETTER'), 'key' => 'idclientnewsletter', 'datagrid_init_function' => array(App::getModel('clientnewsletter'), 'initDatagrid'), 'repeat_max' => FormEngine\FE::INFINITE, 'columns' => $this->getClientNewsletterDatagridColumns()))); $form->AddFilter(new FormEngine\Filters\NoCode()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $this->model->addNewRecipient($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT)); if (FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/recipientlist/add'); } else { App::redirect(__ADMINPANE__ . '/recipientlist'); } } $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('add.tpl')); }
public function add() { $populateData = array('required_data' => array('controller' => 0), 'view_data' => array('view' => Helper::getViewIdsDefault())); $form = $this->formModel->initForm(1); $form->Populate($populateData); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\NoCode()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $id = $this->model->addNewPaymentmethod($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT)); if (FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/paymentmethod/add'); } else { if (Helper::getViewId() > 0) { Session::setVolatileMessage("Moduł płatności został dodany. Skonfiguruj go teraz w zakładce Konfiguracja."); App::redirect(__ADMINPANE__ . '/paymentmethod/edit/' . $id); } else { App::redirect(__ADMINPANE__ . '/paymentmethod'); } } } $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('add.tpl')); }
public function add() { $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { $this->model->addSitemaps($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT)); if (FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/sitemaps/add'); } else { App::redirect(__ADMINPANE__ . '/sitemaps'); } } $this->renderLayout(array('form' => $form->Render())); }
public function add() { $form = $this->formModel->initForm(); if ($form->Validate(\FormEngine\FE::SubmittedData())) { $this->model->addView($form->getSubmitValues(\FormEngine\Elements\Form::FORMAT_FLAT)); Session::setActiveViewIds(NULL); if (\FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/view/add'); } else { App::redirect(__ADMINPANE__ . '/view'); } } $this->renderLayout(array('form' => $form->Render())); }
public function add() { $form = $this->formModel->initForm(); if ($form->Validate(\FormEngine\FE::SubmittedData())) { $this->model->addNewNews($form->getSubmitValues(\FormEngine\Elements\Form::FORMAT_FLAT)); if (\FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/news/add'); } else { App::redirect(__ADMINPANE__ . '/news'); } } $this->registry->xajaxInterface->registerFunction(array('doAJAXCreateSeo', App::getModel('seo'), 'doAJAXCreateSeo')); $this->renderLayout(array('form' => $form->Render())); }
public function add() { $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->save($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT)); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } if (FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/producer/add'); } else { App::redirect(__ADMINPANE__ . '/producer'); } } $this->registry->xajaxInterface->registerFunction(array('doAJAXCreateSeo', App::getModel('seo'), 'doAJAXCreateSeo')); $this->renderLayout(array('form' => $form->Render())); }
public function add() { $this->registry->xajaxInterface->registerFunction(array('AddClientGroup', App::getModel('clientgroup'), 'addEmptyClientGroup')); $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { $generatedPassword = Core::passwordGenerate(); $clientId = $this->model->addNewClient($form->getSubmitValues(), $generatedPassword); $Data = $form->getSubmitValues(); $Data['personal_data']['password'] = $generatedPassword; $this->registry->template->assign('personal_data', $Data['personal_data']); $this->registry->template->assign('address', $Data['billing_data']); App::getModel('mailer')->sendEmail(array('template' => 'addClientFromAdmin', 'email' => array($Data['personal_data']['email']), 'bcc' => false, 'subject' => Translation::get('TXT_REGISTRATION_NEW'), 'viewid' => $Data['personal_data']['viewid'])); if (FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/client/add'); } else { App::redirect(__ADMINPANE__ . '/client'); } } $this->renderLayout(array('form' => $form->Render())); }
public function edit() { $rawNewsletterData = $this->model->getNewsletterData($this->id); $populateData = array('required_data' => array('name' => $rawNewsletterData['name'], 'email' => $rawNewsletterData['email'], 'subject' => $rawNewsletterData['subject'], 'textform' => $rawNewsletterData['textform'], 'htmlform' => $rawNewsletterData['htmlform']), 'recipient_data' => array('recipient' => $rawNewsletterData['recipient'])); $this->formModel->setPopulateData($populateData); $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->updateNewsletter($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->id); if (FormEngine\FE::IsAction('send')) { $newsletter = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); if (is_array($newsletter['recipient'])) { $clients = $newsletter['recipient']; $clientModel = App::getModel('client'); $clientid = $clientModel->selectClient($clients); $clientsData = $clientModel->selectClientsFromNewsletter($clientid); $clientnewsletterid = $clientModel->selectClientNewsletter($clients); $clientsNewsletterData = $clientModel->selectClientsNewsletterFromNewsletter($clientnewsletterid); $clientgroupid = $clientModel->selectClientGroup($clients); $clientsGroupData = $clientModel->selectClientsGroupFromNewsletter($clientgroupid); $sum = array_values(array_unique(array_merge($clientsData, $clientsNewsletterData, $clientsGroupData))); $qty = count($sum); if (strlen($newsletter['htmlform']) == 0) { $newsletter['htmlform'] = ' '; } $this->registry->template->assign('newsletter', $newsletter); foreach ($sum as $email) { App::getModel('mailer')->sendEmail(array('template' => 'newsletter', 'email' => array($email), 'bcc' => false, 'disableLayout' => true, 'subject' => $newsletter['subject'], 'viewid' => Helper::getViewId())); } Session::setVolatileMessage("Newsletter został wysłany do {$qty} klientów."); } else { Session::setVolatileMessage("Newsletter nie został wysłany - brak odbiorców newslettera."); } } } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/newsletter'); } $this->renderLayout(array('form' => $form->Render())); }
public function add() { $form = new FormEngine\Elements\Form(array('name' => 'rangetype', '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'), 'rangetypetranslation', 'name'))))); $categoryData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'category_data', 'label' => _('TXT_CATEGORY_DATA')))); $categoryData->AddChild(new FormEngine\Elements\Tree(array('name' => 'category', 'label' => _('TXT_CATEGORY'), 'choosable' => false, 'selectable' => true, 'sortable' => false, 'clickable' => false, 'items' => App::getModel('category')->getChildCategories(), 'load_children' => array(App::getModel('category'), 'getChildCategories')))); $form->AddFilter(new FormEngine\Filters\NoCode()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { App::getModel('rangetype')->addNewRangeType($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT)); if (FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/rangetype/add'); } else { App::redirect(__ADMINPANE__ . '/rangetype'); } } $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('add.tpl')); }
public function edit() { $PopulateData = $this->model->getProductAndAttributesById((int) $this->id); $groupPrice = App::getModel('product')->getProductGroupPrice($this->id, false); $CurrentViewData = array('basic_pane' => array('language_data' => $PopulateData['language'], 'ean' => $PopulateData['ean'], 'enable' => $PopulateData['enable'], 'delivelercode' => $PopulateData['delivelercode'], 'producerid' => $PopulateData['producerid'], 'delivererid' => $PopulateData['delivererid']), 'meta_data' => array('language_data' => $PopulateData['language']), 'category_pane' => array('category' => $PopulateData['category']), 'price_pane' => array('vatid' => $PopulateData['vatid'], 'buyprice' => $PopulateData['buyprice'], 'buycurrencyid' => $PopulateData['buycurrencyid'], 'sellcurrencyid' => $PopulateData['sellcurrencyid'], 'standard_price' => array('sellprice' => $PopulateData['sellprice'], 'promotion' => $PopulateData['promotion'], 'discountprice' => $PopulateData['discountprice'], 'promotionstart' => $PopulateData['promotionstart'], 'promotionend' => $PopulateData['promotionend'])), 'weight_pane' => array('weight' => $PopulateData['weight'], 'width' => $PopulateData['width'], 'height' => $PopulateData['height'], 'deepth' => $PopulateData['deepth'], 'unit' => $PopulateData['unit'], 'packagesize' => $PopulateData['packagesize']), 'stock_pane' => array('stock' => $PopulateData['standardstock'], 'trackstock' => $PopulateData['trackstock'], 'availablityid' => isset($PopulateData['availablityid']) ? $PopulateData['availablityid'] : 0, 'disableatstockenabled' => $PopulateData['disableatstockenabled'], 'disableatstock' => $PopulateData['disableatstock']), 'description_pane' => array('language_data' => $PopulateData['language']), 'crosssell_products' => array('crosssell' => App::getModel('crosssell')->getProductsDataGrid((int) $this->id)), 'upsell_products' => array('upsell' => App::getModel('upsell')->getProductsDataGrid((int) $this->id)), 'similar_products' => array('similar' => App::getModel('similarproduct')->getProductsDataGrid((int) $this->id)), 'photos_pane' => array('photo' => $PopulateData['photo'], 'mainphotoid' => $PopulateData['mainphotoid']), 'files_pane' => array('file' => $PopulateData['file']), 'warranty_pane' => array('warranty' => $PopulateData['warranty']), 'statusproduct_pane' => array('productstatuses' => $PopulateData['productstatuses'], 'newactive' => $PopulateData['productnew']['newactive'], 'new_data' => array('startnew' => $PopulateData['productnew']['startnew'], 'endnew' => $PopulateData['productnew']['endnew'])), 'variants_pane' => array('variants' => $PopulateData['variants'])); foreach ($groupPrice as $key => $val) { $CurrentViewData['price_pane'][$key] = $val; } $this->formModel->setPopulateData($CurrentViewData); $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->productUpdateAll($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->id); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } if (FormEngine\FE::IsAction('continue')) { App::redirect(__ADMINPANE__ . '/product/edit/' . $this->id); } else { App::redirect(__ADMINPANE__ . '/product'); } } $this->renderLayout(array('form' => $form->Render(), 'productName' => isset($PopulateData['language'][Helper::getLanguageId()]['name']) ? $PopulateData['language'][Helper::getLanguageId()]['name'] : $PopulateData['language'][1]['name'], 'productLink' => App::getURLAdress() . Seo::getSeo('productcart') . '/' . (isset($PopulateData['language'][Helper::getLanguageId()]['seo']) ? $PopulateData['language'][Helper::getLanguageId()]['seo'] : $PopulateData['language'][1]['seo']))); }
public function edit() { $this->registry->xajax->registerFunction(array('DeleteLayoutBox', $this->model, 'deleteLayoutbox')); $layoutboxes = $this->model->getLayoutBoxTree(); $pagescheme_id = $this->id; // selected by user if (Helper::getViewId() > 0 && $pagescheme_id != $this->registry->core->getParam(0)) { // if it is not current view pagescheme change it App::redirect(__ADMINPANE__ . '/layoutbox/edit/' . $pagescheme_id . ',' . $this->model->getFirstLayoutBox($pagescheme_id)); } $layoutbox_id = $this->registry->core->getParam(1); // id from URL if ((int) $layoutbox_id == 0 || empty($layoutboxes[$pagescheme_id . ',' . $layoutbox_id])) { // change pagescheme if subpage is not inside active $pagescheme_id = App::getModel('view')->getViewPagescheme(Helper::getViewId()); App::redirect(__ADMINPANE__ . '/layoutbox/edit/' . $pagescheme_id . ',' . $this->model->getFirstLayoutBox($pagescheme_id)); } $layoutBox = $this->model->getLayoutBoxToEdit($layoutbox_id); $behaviourBoxArray = $this->model->getLayoutBoxJSValuesToEdit($layoutbox_id); $ctValues = $this->model->getLayoutBoxContentTypeSpecificValues($layoutbox_id); if (isset($ctValues['categoryId']) && $ctValues['categoryId'] > 0) { $this->categoryActive = $ctValues['categoryId']; $this->categories = App::getModel('category')->getChildCategories(0, array($this->categoryActive)); } $tree = new FormEngine\Elements\Form(array('name' => 'scheme_tree', 'action' => '', 'method' => 'post')); $tree->AddChild(new FormEngine\Elements\Tree(array('name' => 'pagescheme', 'sortable' => false, 'retractable' => false, 'selectable' => false, 'clickable' => true, 'deletable' => true, 'addable' => false, 'items' => $layoutboxes, 'onClick' => 'openLayoutBoxEditor', 'active' => $pagescheme_id . ',' . $layoutbox_id))); $form = new FormEngine\Elements\Form(array('name' => 'layoutbox', 'action' => '', 'method' => 'post')); $contentTypes = $this->model->getLayoutBoxContentTypeOptions(); $boxEdit = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'box', 'label' => _('TXT_BOX_SETTINGS')))); $boxEdit->AddChild(new FormEngine\Elements\TextField(array('name' => 'name', 'label' => _('TXT_NAME'), 'comment' => 'Wewnętrzna nazwa boksu, niewidoczna dla Klientów', 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_NAME')))))); $title = $boxEdit->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data'))); $title->AddChild(new FormEngine\Elements\TextField(array('name' => 'title', 'label' => _('TXT_BOX_TITLE'), 'comment' => 'Tytuł boksu, który zobaczą Klienci', 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_BOX_TITLE')))))); $boxContent = $boxEdit->AddChild(new FormEngine\Elements\Select(array('name' => 'box_content', 'label' => _('TXT_BOX_CONTENT'), 'options' => FormEngine\Option::Make($this->model->getLayoutBoxContentTypeOptionsAllToSelect()), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_BOX_CONTENT')))))); $this->_addContentTypeSpecificFields($form, $boxContent, $contentTypes); $boxBehaviourEdit = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'behaviour', 'label' => _('TXT_BOX_BEHAVOIUR')))); $boxBehaviourEdit->AddChild(new FormEngine\Elements\Select(array('name' => 'bNoHeader', 'label' => 'Wyświetlaj nagłówek', 'options' => array(new FormEngine\Option('0', 'Tak'), new FormEngine\Option('1', 'Nie'))))); $boxBehaviourEdit->AddChild(new FormEngine\Elements\TextField(array('name' => 'iDefaultSpan', 'label' => 'Domyślne rozciągnięcie', 'comment' => 'Wpisz liczbę kolumn', 'rules' => array(new FormEngine\Rules\Format(_('ERR_VALUE_INVALID'), '/^(([0-9]{1,2})|(\\0)?)$/'))))); $boxBehaviourEdit->AddChild(new FormEngine\Elements\Select(array('name' => 'iEnableBox', 'label' => 'Wyświetlanie boksu', 'options' => array(new FormEngine\Option('0', 'Dla wszystkich'), new FormEngine\Option('1', 'Dla zalogowanych'), new FormEngine\Option('2', 'Dla niezalogowanych'), new FormEngine\Option('3', 'Nie wyświetlaj'))))); $populate = array('box' => array('name' => $layoutBox['name'], 'language_data' => array('title' => $layoutBox['title']), 'box_content' => $layoutBox['controller']), 'behaviour' => array('bNoHeader' => 0, 'iDefaultSpan' => '1', 'iEnableBox' => 0)); if (isset($behaviourBoxArray) && count($behaviourBoxArray) > 0) { foreach ($behaviourBoxArray as $js => $value) { $populate['behaviour'][$js] = $value; } } $populate = $this->_populateContentTypeFields($contentTypes, $populate, $ctValues, $layoutBox['controller']); $form->Populate($populate); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $this->model->editLayoutBox($this->_performArtificialMechanics($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT)), $layoutbox_id); if (FormEngine\FE::IsAction('continue')) { App::redirect(__ADMINPANE__ . '/layoutbox/edit/' . $pagescheme_id . ',' . $layoutbox_id); } else { App::redirect(__ADMINPANE__ . '/layoutbox'); } } $this->renderLayout(array('tree' => $tree->Render(), 'id' => $layoutbox_id, 'form' => $form->Render())); }
public function add() { $this->registry->template->assign('groups', App::getModel('groups')->getGroupsAll()); $groups = App::getModel('groups/groups')->getGroupsAllToSelect(); $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')))); $firstname = $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\Tip(array('tip' => '<p>' . _('TXT_USER_PASSWORD_INFO') . '</p>'))); $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'))))); $rightsData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'rights_data', 'label' => _('TXT_RIGHTS')))); $isglobal = App::getModel('users')->checkActiveUserIsGlobal(); if ($isglobal == 1) { $global = $rightsData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'global', 'label' => _('TXT_GLOBAL_USER'), 'default' => '1'))); $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())))); } } } else { $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']))); 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($view['id']))))); } } } $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))); $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()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $password = Core::passwordGenerate(); $users = $form->getSubmitValues(); $totalGroups = 0; if ((int) $users['rights_data']['global'] == 0) { foreach ($users['rights_data'] as $k => $v) { if (substr($k, 0, 5) == 'store') { foreach ($v as $viewid => $group) { if ($group > 0) { $totalGroups++; } } } } if ($totalGroups == 0) { Session::setVolatileMessage("Nie powiodło się dodanie użytkownika. Każdy użytkownik musi posiadać wybraną przynajmniej jedną grupę."); App::redirect(__ADMINPANE__ . '/users/add'); } } App::getModel('users')->addNewUser($users, $password); $this->registry->template->assign('password', $password); $this->registry->template->assign('users', $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT)); App::getModel('mailer')->sendEmail(array('template' => 'newPasswordForUser', 'email' => array($users['personal_data']['email']), 'bcc' => false, 'subject' => _('TXT_NEW_USER'), 'viewid' => Helper::getViewId())); if (FormEngine\FE::IsAction('next')) { App::redirect(__ADMINPANE__ . '/users/add'); } else { App::redirect(__ADMINPANE__ . '/users'); } } $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('add.tpl')); }