public function edit() { $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', null, array('column' => 'rangetypeid', 'values' => (int) $this->registry->core->getParam())))))); $categoryData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'category_data', 'label' => _('TXT_CATEGORY_DATA')))); $rawRangetypeData = App::getModel('rangetype')->getRangeTypeView($this->registry->core->getParam()); $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(0, $rawRangetypeData['rangetypecategorys']), '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()); $rangetypeData = array('required_data' => array('language_data' => $rawRangetypeData['language']), 'category_data' => array('category' => $rawRangetypeData['rangetypecategorys'])); $form->Populate($rangetypeData); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { App::getModel('rangetype')->editRangeType($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->registry->core->getParam()); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } 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('edit.tpl')); }
public function index() { if (Session::getActiveUserid() != null) { App::redirect(__ADMINPANE__ . '/mainside'); } $form = new FormEngine\Elements\Form(array('name' => 'forgotlogin', 'action' => '', 'method' => 'post', 'class' => 'login-form')); $form->AddChild(new FormEngine\Elements\TextField(array('name' => 'login', 'label' => _('TXT_EMAIL_FORM_LOGIN'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_LOGIN_FORM_LOGIN')))))); $form->AddChild(new FormEngine\Elements\Submit(array('name' => 'log_in', 'label' => _('TXT_FORGOT_PASSWORD')))); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\NoCode()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $loginValues = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $result = App::getModel('login')->checkUsers($loginValues['login']); if ($result == 0) { Session::setVolatileLoginError(1, false); } else { $password = Core::passwordGenerate(); App::getModel('login')->changeUsersPassword($result, $password); $this->registry->template->assign('password', $password); App::getModel('mailer')->sendEmail(array('template' => 'forgotUsers', 'email' => array($_POST['login']), 'bcc' => false, 'subject' => _('TXT_FORGOT_PASSWORD'), 'viewid' => Helper::getViewId())); Session::setVolatileMessage("Nowe hasło zostało wysłane na podany adres e-mail."); App::redirect('login'); } } $error = Session::getVolatileLoginError(); if ($error[0] == 1) { $this->registry->template->assign('error', _('ERR_BAD_EMAIL')); } $languages = App::getModel('language')->getLanguages(); $this->registry->xajax->processRequest(); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->assign('form', $form->Render()); $this->registry->template->assign('languages', json_encode($languages)); $this->registry->template->display($this->loadTemplate('index.tpl')); }
public function add() { $form = new FormEngine\Elements\Form(array('name' => 'pagescheme', 'action' => '', 'method' => 'post')); $filesPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'files_pane', 'label' => 'Dodaj nowy szablon'))); $filesPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz z dysku lub wgraj plik zip z szablonem sklepu. Po imporcie będziesz mógł zmienić jego ustawienia oraz ustawić jako domyślny dla sklepu.</p>', 'direction' => FormEngine\Elements\Tip::DOWN))); $files = $filesPane->AddChild(new FormEngine\Elements\LocalFile(array('name' => 'files', 'label' => 'Plik', 'file_source' => 'themes/', 'traversable' => false, 'file_types' => array('zip')))); if ($form->Validate(FormEngine\FE::SubmittedData())) { $Data = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $check = App::getModel('pagescheme/import')->check($Data['files']['file']); $bValid = false; if (is_array($check)) { foreach ($check as $file) { if ($file['filename'] == 'settings/export.json') { $bValid = true; break; } } } if ($bValid) { App::getModel('pagescheme/import')->importPagescheme($Data['files']['file']); App::redirect(__ADMINPANE__ . '/templateeditor'); } else { Session::setVolatileMessage("Musisz wybrać prawidłowe archiwum ZIP."); App::redirect(__ADMINPANE__ . '/templateeditor/add'); } } $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 = new FormEngine\Elements\Form(array('name' => 'promotion', 'action' => '', 'method' => 'post')); $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_SELECT_PRODUCTS')))); $productid = $requiredData->AddChild(new FormEngine\Elements\ProductSelect(array('name' => 'productid', 'label' => _('TXT_SELECT_PRODUCTS'), 'rules' => array(new FormEngine\Rules\Required(_('TXT_SELECT_PRODUCTS'))), 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE))); $pricePane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'discount_pane', 'label' => _('TXT_DISCOUNT')))); $standardPrice = $pricePane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'standard_price', 'label' => _('TXT_STANDARD_SELLPRICE')))); $enablePromotion = $standardPrice->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'promotion', 'label' => _('TXT_ENABLE_PROMOTION'), 'default' => '0'))); $standardPrice->AddChild(new FormEngine\Elements\TextField(array('name' => 'discount', 'label' => _('TXT_DISCOUNT'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_VALUE_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/')), 'default' => '0.00', 'suffix' => '%', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), '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)))))); $clientGroups = App::getModel('clientgroup/clientgroup')->getClientGroupAll(); foreach ($clientGroups as $clientGroup) { $pricePane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'field_' . $clientGroup['id'], 'label' => $clientGroup['name']))); $promotion[$clientGroup['id']] = $pricePane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'promotion_' . $clientGroup['id'], 'label' => _('TXT_ENABLE_CLIENTGROUP_PROMOTION'), 'default' => '0'))); $pricePane->AddChild(new FormEngine\Elements\TextField(array('name' => 'discount_' . $clientGroup['id'], 'label' => _('TXT_DISCOUNT'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_VALUE_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/')), 'default' => '0.00', 'suffix' => '%', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $promotion[$clientGroup['id']], new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals(1))))))); $pricePane->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)))))); $pricePane->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)))))); } $form->AddFilter(new FormEngine\Filters\NoCode()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $Data = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $this->model->addPromotion($Data); App::getModel('product')->updateProductAttributesetPricesAll(); App::redirect(__ADMINPANE__ . '/productpromotion'); } $this->registry->template->assign('form', $form->Render()); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->xajax->processRequest(); $this->registry->template->display($this->loadTemplate('add.tpl')); }
public function index() { if (strlen($this->registry->core->getParam()) > 0) { $result = App::getModel('login')->authProccessSha($this->registry->core->getParam()); if ($result == 1) { Session::setActiveLoginError(null); Session::setActiveUserid($result); App::getModel('login')->checkInstanceIsValid(); App::getModel('login')->setLoginTime(); App::getModel('login')->getUserData(); App::getModel('login')->setDefaultView($result); App::redirect(__ADMINPANE__ . '/mainside'); } } if (Session::getActiveUserid() != null) { App::redirect(__ADMINPANE__ . '/mainside'); } $form = new FormEngine\Elements\Form(array('name' => 'login', 'action' => '', 'method' => 'post', 'class' => 'login-form', 'csrf' => false)); $form->AddChild(new FormEngine\Elements\TextField(array('name' => 'login', 'label' => _('TXT_EMAIL_FORM_LOGIN'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL_FORM_LOGIN')))))); $form->AddChild(new FormEngine\Elements\Password(array('name' => 'password', 'label' => _('TXT_LOGIN_FORM_PASSWORD'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_LOGIN_FORM_PASSWORD')))))); $form->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'autologin', 'label' => _('TXT_AUTOLOGIN')))); $form->AddChild(new FormEngine\Elements\Submit(array('name' => 'log_in', 'label' => _('TXT_LOG_IN')))); $form->AddChild(new FormEngine\Elements\StaticText(array('text' => '<a href="' . App::getURLAdress() . 'forgotlogin">' . _('TXT_LOGIN_FORM_RESET_PASSWORD') . '</a>'))); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\NoCode()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $loginValues = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $result = App::getModel('login')->authProccess($loginValues['login'], $loginValues['password']); if ($result == 0) { Session::setVolatileLoginError(1, false); } else { if (isset($loginValues['autologin']) && $loginValues['autologin'] == 1) { App::getModel('login')->setAdminAutologinKey($result); } else { App::getModel('login')->destroyAdminAutologinKey(); } Session::setActiveLoginError(null); Session::setActiveUserid($result); App::getModel('login')->checkInstanceIsValid(); App::getModel('login')->setLoginTime(); App::getModel('login')->getUserData(); App::getModel('login')->setDefaultView($result); App::redirect(__ADMINPANE__ . '/mainside'); } } $error = Session::getVolatileLoginError(); if ($error[0] == 1) { $this->registry->template->assign('error', _('ERR_BAD_LOGIN_OR_PASSWORD')); } $languages = App::getModel('language')->getLanguages(); $this->registry->xajax->processRequest(); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->assign('form', $form->Render()); $this->registry->template->assign('languages', json_encode($languages)); $this->registry->template->display($this->loadTemplate('index.tpl')); }
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())); }
public function index() { if (App::getConfig('devmode') == 0) { App::redirect(__ADMINPANE__ . '/mainside'); } if ((int) $this->getParam() == 0) { $form = new FormEngine\Elements\Form(array('name' => 'exchange', 'action' => '', 'method' => 'post')); $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'type_pane', 'label' => _('TXT_EXCHANGE_TYPE_MIGRATION_SETTINGS')))); $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Podaj adres URL wtyczki integracyjnej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN))); $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'apiurl', 'label' => _('TXT_MIGRATION_API_URL')))); $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Podaj klucz jaki został ustawiony w pliku integracyjnym ($key)</p>', 'direction' => FormEngine\Elements\Tip::DOWN))); $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'apikey', 'label' => _('TXT_MIGRATION_API_KEY')))); $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Wybierz rodzaj importowanych danych.Sugerujemy import w następującej kolejności: <ul> <li>Zdjęcia</li> <li>Producenci</li> <li>Kategorie</li> <li>Wartości cech</li> <li>Produkty</li> </ul></p>', 'direction' => FormEngine\Elements\Tip::DOWN))); $requiredData->AddChild(new FormEngine\Elements\Select(array('name' => 'entity', 'label' => _('TXT_EXCHANGE_ENTITY'), 'options' => array(new FormEngine\Option(1, _('TXT_PRODUCTS')), new FormEngine\Option(2, _('TXT_CATEGORIES')), new FormEngine\Option(3, _('TXT_PRODUCERS')), new FormEngine\Option(4, _('TXT_PHOTOS')), new FormEngine\Option(5, _('TXT_ATTRIBUTES')), new FormEngine\Option(6, _('TXT_ORDERS')), new FormEngine\Option(7, _('TXT_SIMILARPRODUCT'))), 'default' => 1))); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $Data = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); Session::setActiveMigrationData(json_encode($Data)); App::redirect(__ADMINPANE__ . '/migration/index/' . $Data['entity']); } $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('index.tpl')); } else { if (Session::getActiveMigrationData() == NULL) { App::redirect(__ADMINPANE__ . '/migration/'); } $form = new FormEngine\Elements\Form(array('name' => 'add_migration', 'action' => '', 'method' => 'post')); $progress = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'progres_data', 'label' => 'Aktualizacja'))); $progress->AddChild(new FormEngine\Elements\ProgressIndicator(array('name' => 'progress', 'label' => 'Postęp migracji', 'chunks' => 1, 'load' => array(App::getModel('migration'), 'doLoadQueque'), 'process' => array(App::getModel('migration'), 'doProcessQueque'), 'success' => array(App::getModel('migration'), 'doSuccessQueque'), 'preventSubmit' => true))); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); $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('index.tpl')); } }
public function edit() { $data = $this->model->getOpinion($this->id); $form = new FormEngine\Elements\Form(array('name' => 'productrange', 'action' => '', 'method' => 'post')); $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'data', 'label' => _('TXT_OPINION')))); $requiredData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>' . $data['nick'] . '</p>'))); $requiredData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'review', 'label' => _('TXT_CONTENT'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_FILL_AN_OPINION')))))); $requiredData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'enable', 'label' => _('TXT_PUBLISH')))); $form->Populate(array('data' => array('review' => $data['review'], 'enable' => (int) $data['enable']))); $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->editOpinion($form->getSubmitValues(), $this->registry->core->getParam()); App::redirect(__ADMINPANE__ . '/productrange'); } $this->renderLayout(array('form' => $form->Render())); }
public function edit() { $integrationModel = $this->model->getIntegrationModelById($this->id); if (empty($integrationModel)) { App::redirect(__ADMINPANE__ . '/integration'); } $form = new FormEngine\Elements\Form(array('name' => 'edit_integration', 'action' => '', 'method' => 'post')); if (method_exists(App::getModel('integration/' . $integrationModel), 'updateCategories')) { App::getModel('integration/' . $integrationModel)->updateCategories(); } $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_MAIN_INFORMATION')))); $requiredData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>' . App::getModel('integration/' . $integrationModel)->getDescription() . '</p>'))); $url = $this->registry->router->generate('frontend.integration', true, array('param' => $integrationModel)); $requiredData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p><a href="' . $url . '" target="_blank"><b>Link do pliku integracyjnego</b></a></p>'))); $configurationFields = App::getModel('integration/' . $integrationModel)->getConfigurationFields(); if (is_array($configurationFields) && !empty($configurationFields)) { $configurationData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'configuration_data', 'label' => _('TXT_CONFIGURATION_DATA')))); } $whitelist = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'whitelist_data', 'label' => _('TXT_INTEGRATION_WHITELIST')))); $whitelist->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>' . _('TXT_INTEGRATION_WHITELIST_HELP') . '</p>'))); $whitelist->AddChild(new FormEngine\Elements\StaticText(array('text' => '<strong>Twój adres IP: ' . Core::getRealIpAddress() . '</strong>'))); $fieldset = $whitelist->AddChild(new FormEngine\Elements\FieldsetRepeatable(array('name' => 'whitelist', 'label' => _('TXT_INTEGRATION_WHITELIST'), 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE))); $fieldset->AddChild(new FormEngine\Elements\TextField(array('name' => 'ip', 'label' => 'IP'))); $rawData = $this->model->getIntegrationView($this->id); $pollData = array('whitelist_data' => array('whitelist' => $rawData['whitelist'])); $form->Populate($pollData); $form->AddFilter(new FormEngine\Filters\NoCode()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->editIntegration($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->id); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/integration'); } $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')); }
public function edit() { $tree = new FormEngine\Elements\Form(array('name' => 'category_tree', 'class' => 'category-select', 'action' => '', 'method' => 'post')); $categories = $this->model->getContentCategoryALL(); $rawContentcategoryData = $this->model->getContentCategoryView($this->id); $tree->AddChild(new FormEngine\Elements\Tree(array('name' => 'categories', 'add_item_prompt' => _('TXT_NAME'), 'sortable' => true, 'selectable' => false, 'clickable' => true, 'deletable' => true, 'addable' => true, 'prevent_duplicates' => false, 'items' => $categories, 'onClick' => 'openCategoryEditor', 'onAdd' => 'xajax_AddCategory', 'addLabel' => _('TXT_ADD'), 'onAfterAdd' => 'openCategoryEditor', 'onDelete' => 'xajax_DeleteCategory', 'onAfterDelete' => 'openCategoryEditor', 'onSaveOrder' => 'xajax_ChangeCategoryOrder', 'active' => $this->registry->core->getParam(), 'onAfterDeleteId' => $rawContentcategoryData['next']))); $populateData = array('required_data' => array('footer' => $rawContentcategoryData['footer'], 'header' => $rawContentcategoryData['header'], 'contentcategoryid' => $rawContentcategoryData['contentcategory'], 'language_data' => $rawContentcategoryData['language']), 'meta_data' => array('language_data' => $rawContentcategoryData['language']), 'redirect_data' => array('redirect' => $rawContentcategoryData['redirect'], 'redirect_route' => $rawContentcategoryData['redirect_route'], 'redirect_url' => $rawContentcategoryData['redirect_url']), 'view_data' => array('view' => $rawContentcategoryData['view'])); $this->formModel->setPopulateData($populateData); $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->editContentCategory($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->id); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } Session::setVolatileMessage("Zapisano zmiany w stronie statycznej."); App::redirect(__ADMINPANE__ . '/contentcategory/edit/' . $this->id); } $this->renderLayout(array('form' => $form->Render(), 'tree' => $tree->Render())); }
public function add() { $orderData = App::getModel('order')->getOrderById((int) $this->registry->core->getParam()); $viewData = App::getModel('view')->getView($orderData['viewid']); $invoiceType = (int) $this->registry->core->getParam(1); $invoiceNumber = $this->model->generateInvoiceNumber($viewData['invoicenumerationkind'], $invoiceType, $orderData['order_date'], $orderData['viewid']); $form = new FormEngine\Elements\Form(array('name' => 'invoice', 'action' => '', 'method' => 'post')); $invoiceData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'invoice_data', 'label' => _('TXT_INVOICE')))); $invoiceData->AddChild(new FormEngine\Elements\TextField(array('name' => 'salesperson', 'label' => _('TXT_SALES_PERSON'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SALES_PERSON'))), 'default' => App::getModel('users')->getUserFullName()))); $invoiceDate = $invoiceData->AddChild(new FormEngine\Elements\Date(array('name' => 'invoicedate', 'label' => _('TXT_INVOICE_DATE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_INVOICE_DATE'))), 'default' => date('Y-m-d')))); $wFirmaSettings = $this->registry->core->loadModuleSettings('wfirma', $orderData['viewid']); $inFaktSettings = $this->registry->core->loadModuleSettings('infakt', $orderData['viewid']); if (!empty($wFirmaSettings) && $wFirmaSettings['wfirmalogin'] != '' && $wFirmaSettings['wfirmapassword'] != '') { $invoiceData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>Numer faktury zostanie wygenerowany poprzez API wFirma automatycznie.'))); } elseif (!empty($inFaktSettings) && $inFaktSettings['infaktlogin'] != '' && $inFaktSettings['infaktpassword'] != '') { $invoiceData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p>Numer faktury zostanie wygenerowany poprzez API inFakt automatycznie.'))); } else { $invoiceData->AddChild(new FormEngine\Elements\TextField(array('name' => 'invoicenumber', 'label' => _('TXT_INVOICE_NUMBER'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_INVOICE_NUMBER'))), 'default' => $invoiceNumber, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SUGGEST, $invoiceDate, array($this->model, 'getInvoiceNumberFormat')))))); } $invoiceData->AddChild(new FormEngine\Elements\Date(array('name' => 'duedate', 'label' => _('TXT_MATURITY'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_MATURITY'))), 'default' => date('Y-m-d', strtotime('+' . $viewData['invoicedefaultpaymentdue'] . ' days'))))); $invoiceData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'comment', 'label' => _('TXT_COMMENT'), 'default' => _('TXT_ORDER') . ': ' . $orderData['order_id']))); $invoiceData->AddChild(new FormEngine\Elements\TextField(array('name' => 'totalpayed', 'label' => _('TXT_TOTAL_PAYED'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_TOTAL_PAYED'))), 'default' => '0.00', 'suffix' => $orderData['currencysymbol']))); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $formData = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); if (!empty($wFirmaSettings) && $wFirmaSettings['wfirmalogin'] != '' && $wFirmaSettings['wfirmapassword'] != '') { App::getModel('wfirma')->addInvoice($formData, (int) $this->registry->core->getParam(0), (int) $this->registry->core->getParam(1), $orderData); } elseif (!empty($inFaktSettings) && $inFaktSettings['infaktlogin'] != '' && $inFaktSettings['infaktpassword'] != '') { App::getModel('infakt')->addInvoice($formData, (int) $this->registry->core->getParam(0), (int) $this->registry->core->getParam(1), $orderData); } else { $invoiceNo = $this->model->addInvoice($formData, (int) $this->registry->core->getParam(0), (int) $this->registry->core->getParam(1), $orderData); } Session::setVolatileMessage("Dodano fakturę {$invoiceNo} do zamówienia {$this->registry->core->getParam()}"); App::redirect(__ADMINPANE__ . '/order/edit/' . (int) $this->registry->core->getParam()); } $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->xajax->processRequest(); $this->registry->template->assign('form', $form->Render()); $this->registry->template->display($this->loadTemplate('add.tpl')); }
public function add() { $form = new FormEngine\Elements\Form(array('name' => 'productnews', 'action' => '', 'method' => 'post')); $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => _('TXT_SELECT_PRODUCTS')))); $productid = $requiredData->AddChild(new FormEngine\Elements\ProductSelect(array('name' => 'productid', 'label' => _('TXT_SELECT_PRODUCTS'), 'rules' => array(new FormEngine\Rules\Required(_('TXT_SELECT_PRODUCTS'))), 'exclude' => $this->model->getExcludeProducts(), 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE))); $newData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'new_data', 'label' => _('TXT_NEW_DATA')))); $newData->AddChild(new FormEngine\Elements\Date(array('name' => 'adddate', 'label' => _('TXT_ADDDATE')))); $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')))); $form->AddFilter(new FormEngine\Filters\NoCode()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $Data = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $this->model->addProductNews($Data); App::redirect(__ADMINPANE__ . '/productnews'); } $this->registry->template->assign('form', $form->Render()); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->xajax->processRequest(); $this->registry->template->display($this->loadTemplate('add.tpl')); }
public function edit() { Event::dispatch($this, 'admin.order.checkPaymentStatus', array('id' => (int) $this->registry->core->getParam())); $rawOrderData = $this->model->getOrderById($this->registry->core->getParam()); if (isset($rawOrderData['currencyid']) && !empty($rawOrderData['currencyid'])) { $currencyid = $rawOrderData['currencyid']; } else { $currencyid = Session::getActiveShopCurrencyId(); } try { $order = $this->model->getOrderById((int) $this->registry->core->getParam()); $order['id'] = (int) $this->registry->core->getParam(); $orderNotes = $this->model->getOrderNotes($order['id']); $clientOrderHistory = $this->model->getclientOrderHistory($order['clientid']); } catch (Exception $e) { throw new CoreException($e->getMessage()); } $addNotes = new FormEngine\Elements\Form(array('name' => 'add_notes', 'class' => 'statusChange', 'action' => '', 'method' => 'post')); $addNotes->AddChild(new FormEngine\Elements\Textarea(array('name' => 'contents', 'label' => _('TXT_CONTENT'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_CONTENT')))))); $addNotes->AddChild(new FormEngine\Elements\Submit(array('name' => 'add', 'label' => _('TXT_ADD'), 'icon' => '_images_panel/icons/buttons/add.png'))); $form = new FormEngine\Elements\Form(array('name' => 'order', 'action' => '', 'class' => 'editOrder', 'method' => 'post')); $productsData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'products_data', 'label' => _('TXT_EDIT_ORDER_ORDERED_PRODUCTS')))); $products = $productsData->AddChild(new FormEngine\Elements\OrderEditor(array('name' => 'products', 'label' => _('TXT_EDIT_ORDER_ORDERED_PRODUCTS'), 'advanced_editor' => true, 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'clientgroupid' => (int) $rawOrderData['clientgroupid'], 'currencyid' => (int) $rawOrderData['currencyid'], 'viewid' => $rawOrderData['viewid'], 'on_change' => 'OnProductListChanged'))); $addressData = $form->AddChild(new FormEngine\Elements\Columns(array('name' => 'address_data'))); $billingData = $addressData->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' => 'place', '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')))))); $billingData->AddChild(new FormEngine\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => FormEngine\Option::Make(App::getModel('countrieslist')->getCountryForSelect()), 'default' => 0, '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')))); $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'phone', 'label' => _('TXT_PHONE'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/'))))); $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'phone2', 'label' => _('TXT_ADDITIONAL_PHONE'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/'))))); $billingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL')))))); $shippingData = $addressData->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'shipping_data', 'label' => _('TXT_EDIT_ORDER_SHIPPING_DATA')))); $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' => 'place', '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')))))); $shippingData->AddChild(new FormEngine\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => FormEngine\Option::Make(App::getModel('countrieslist')->getCountryForSelect()), 'default' => 0, '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')))); $shippingData->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 -+]+$/'))))); $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'phone2', 'label' => _('TXT_ADDITIONAL_PHONE'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/'))))); $shippingData->AddChild(new FormEngine\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL')))))); $additionalData = $form->AddChild(new FormEngine\Elements\Columns(array('name' => 'additional_data'))); $paymentData = $additionalData->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'payment_data', 'label' => _('TXT_EDIT_ORDER_PAYMENT_METHOD')))); $paymentData->AddChild(new FormEngine\Elements\Select(array('name' => 'payment_method', 'label' => _('TXT_EDIT_ORDER_PAYMENT_METHOD'), 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + $this->model->getPaymentmethodAllToSelect($this->registry->core->getParam()))))); $weight = 0; foreach ($order['products'] as $product) { $weight += $product['weight']; } $paymentData->AddChild(new FormEngine\Elements\Select(array('name' => 'delivery_method', 'label' => _('TXT_EDIT_ORDER_DELIVERY_METHOD'), 'options' => FormEngine\Option::Make($this->model->getDispatchmethodAllToSelect($order['total'], $this->registry->core->getParam(), $weight))))); $paymentData->AddChild(new FormEngine\Elements\Select(array('name' => 'rules_cart', 'label' => _('TXT_RULES_CART'), 'options' => FormEngine\Option::Make($this->model->getAllRulesForOrder($this->registry->core->getParam()))))); $paymentData->AddChild(new FormEngine\Elements\Constant(array('name' => 'currency', 'label' => _('TXT_KIND_OF_CURRENCY')))); $summaryData = $additionalData->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'summary_data', 'label' => _('TXT_VIEW_ORDER_SUMMARY')))); $summaryData->AddChild(new FormEngine\Elements\Constant(array('name' => 'total_net_total', 'label' => _('TXT_NETTO_AMOUNT')))); $summaryData->AddChild(new FormEngine\Elements\Constant(array('name' => 'total_vat_value', 'label' => _('TXT_VIEW_ORDER_TAX')))); $summaryData->AddChild(new FormEngine\Elements\Constant(array('name' => 'total_delivery', 'label' => _('TXT_DELIVERERPRICE')))); $summaryData->AddChild(new FormEngine\Elements\Constant(array('name' => 'total_total', 'label' => _('TXT_VIEW_ORDER_TOTAL')))); $form->AddFilter(new FormEngine\Filters\NoCode()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); $orderData = array('address_data' => array('billing_data' => array('firstname' => $rawOrderData['billing_address']['firstname'], 'surname' => $rawOrderData['billing_address']['surname'], 'street' => $rawOrderData['billing_address']['street'], 'streetno' => $rawOrderData['billing_address']['streetno'], 'placeno' => $rawOrderData['billing_address']['placeno'], 'place' => $rawOrderData['billing_address']['city'], 'postcode' => $rawOrderData['billing_address']['postcode'], 'countryid' => $rawOrderData['billing_address']['countryid'], 'companyname' => $rawOrderData['billing_address']['companyname'], 'nip' => $rawOrderData['billing_address']['nip'], 'phone' => $rawOrderData['billing_address']['phone'], 'phone2' => $rawOrderData['billing_address']['phone2'], 'email' => $rawOrderData['billing_address']['email']), 'shipping_data' => array('firstname' => $rawOrderData['delivery_address']['firstname'], 'surname' => $rawOrderData['delivery_address']['surname'], 'street' => $rawOrderData['delivery_address']['street'], 'streetno' => $rawOrderData['delivery_address']['streetno'], 'placeno' => $rawOrderData['delivery_address']['placeno'], 'place' => $rawOrderData['delivery_address']['city'], 'postcode' => $rawOrderData['delivery_address']['postcode'], 'countryid' => $rawOrderData['delivery_address']['countryid'], 'companyname' => $rawOrderData['delivery_address']['companyname'], 'nip' => $rawOrderData['delivery_address']['nip'], 'phone' => $rawOrderData['delivery_address']['phone'], 'phone2' => $rawOrderData['billing_address']['phone2'], 'email' => $rawOrderData['delivery_address']['email'])), 'additional_data' => array('payment_data' => array('delivery_method' => $rawOrderData['delivery_method']['dispatchmethodid'], 'payment_method' => $rawOrderData['payment_method']['paymentmethodid'], 'rules_cart' => $rawOrderData['rulescartid'], 'currency' => $rawOrderData['currencysymbol']), 'summary_data' => array('total_net_total' => 132)), 'products_data' => array('products' => $this->model->getProductsDataGrid((int) $this->registry->core->getParam()))); $form->Populate($orderData); $statusChange = new FormEngine\Elements\Form(array('name' => 'add_status_change', 'class' => 'statusChange', 'action' => '', 'method' => 'post')); $idstatus = $statusChange->AddChild(new FormEngine\Elements\Select(array('name' => 'status', 'label' => _('TXT_VIEW_ORDER_CHANGE_STATUS'), 'options' => FormEngine\Option::Make(App::getModel('orderstatus')->getOrderStatusToSelect())))); $statusChange->AddChild(new FormEngine\Elements\Textarea(array('name' => 'comment', 'label' => _('TXT_VIEW_ORDER_CHANGE_COMMENT'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SUGGEST, $idstatus, array(App::getModel('orderstatus'), 'getDefaultComment')))))); $statusChange->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'inform', 'label' => _('TXT_VIEW_ORDER_CHANGE_INFORM_CLIENT')))); $statusChange->AddChild(new FormEngine\Elements\Submit(array('name' => 'update', 'label' => _('TXT_VIEW_ORDER_CHANGE_UPDATE'), 'icon' => '_images_panel/icons/buttons/flag-green.png'))); $statusChange->Populate(array('status' => $order['current_status_id'])); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); if ($addNotes->Validate(FormEngine\FE::SubmittedData())) { try { $notes = $addNotes->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $this->model->addOrderNotes($addNotes->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $order['id']); Session::setVolatileMessage("Dodano notatkę do zamówienia {$this->id}"); App::redirect(__ADMINPANE__ . '/order/edit/' . (int) $this->registry->core->getParam()); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } } if ($statusChange->Validate(FormEngine\FE::SubmittedData())) { $this->model->addOrderHistory($statusChange->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->registry->core->getParam()); try { $email = $statusChange->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); if ($email['inform'] == 1) { $this->model->notifyUser($order, $email['status']); } Session::setVolatileMessage("Zaktualizowano status zamówienia {$this->id}"); $this->model->updateOrderStatus($_POST, $this->registry->core->getParam()); App::redirect(__ADMINPANE__ . '/order/edit/' . (int) $this->registry->core->getParam()); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } } if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->updateOrderById($_POST, $this->registry->core->getParam()); App::redirect(__ADMINPANE__ . '/order/'); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } } $this->registry->template->assign('viewid', Helper::getViewId()); $this->registry->xajaxInterface->registerFunction(array('CalculateDeliveryCost', $this->model, 'calculateDeliveryCostEdit')); $this->registry->xajaxInterface->registerFunction(array('GetDispatchMethodForPrice', $this->model, 'getDispatchMethodForPriceForAjaxEdit')); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->xajax->processRequest(); $this->registry->template->assign('statusChange', $statusChange->Render()); $this->registry->template->assign('addNotes', $addNotes->Render()); $this->registry->template->assign('orderNotes', $orderNotes); $this->registry->template->assign('clientOrderHistory', $clientOrderHistory); $this->registry->template->assign('order', $order); $this->registry->template->assign('currencyid', Session::getActiveCurrencyId()); $this->registry->template->assign('currencysymbol', Session::getActiveCurrencySymbol()); $this->registry->template->assign('form', $form->Render()); $this->registry->template->display($this->loadTemplate('edit.tpl')); }
public function Render() { $form = new FormEngine\Elements\Form(array('name' => 'install', 'action' => '', 'method' => 'post', 'csrf' => false)); $checkDirLogs = $this->check_dir('logs'); $checkDirCache = $this->check_dir('cache'); $checkDirSerialization = $this->check_dir('serialization'); $minPHP = '5.3'; $checkPHPVersion = $this->checkPhpVersion($minPHP); $checkExtensionZlib = $this->checkExtension('zlib'); $checkExtensionGd = $this->checkExtension('gd'); $checkExtensionMysqli = $this->checkExtension('mysqli'); $checkExtensionCurl = $this->checkExtension('curl'); //if(ini_get('output_buffering')){ $checkOB = true; //}else{ //$checkOB = false; //} if ($checkOB == TRUE && $checkPHPVersion == TRUE && $checkExtensionZlib == TRUE && $checkExtensionMysqli == TRUE && $checkExtensionCurl == TRUE && ($checkExtensionGd = TRUE)) { $license = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'license', 'label' => 'Licencja'))); $licenceFile = file_get_contents(ROOTPATH . 'LICENCE'); $gpl = '<div style="height:20em; border:1px solid #ccc; margin-bottom:8px; padding:5px; background:#fff; overflow: auto; overflow-x:hidden; overflow-y:scroll;"> ' . $licenceFile . ' </div>'; $license->AddChild(new FormEngine\Elements\StaticText(array('text' => $gpl))); $license->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'accept_license', 'label' => 'Akceptuję licencję', 'rules' => array(new FormEngine\Rules\Required('Musisz zaakceptować licencję.')), 'default' => 0))); $store = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'store', 'label' => 'Dane administratora sklepu'))); $store->AddChild(new FormEngine\Elements\TextField(array('name' => 'user_email', 'comment' => 'Używany jako login', 'label' => 'E-mail', 'rules' => array(new FormEngine\Rules\Required('Podaj login.'))))); $store->AddChild(new FormEngine\Elements\Password(array('name' => 'user_password', 'label' => 'Hasło', 'rules' => array(new FormEngine\Rules\Required('Podaj hasło.'))))); $database = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'database_settings', 'label' => 'Ustawienia bazy SQL'))); $database->AddChild(new FormEngine\Elements\TextField(array('name' => 'hostspec', 'label' => 'Host', 'default' => 'localhost', 'rules' => array(new FormEngine\Rules\Required('Podaj host bazy SQL.'))))); $database->AddChild(new FormEngine\Elements\TextField(array('name' => 'mysqlport', 'label' => 'Port', 'default' => 3306, 'rules' => array(new FormEngine\Rules\Required('Podaj port bazy SQL.'))))); $database->AddChild(new FormEngine\Elements\TextField(array('name' => 'username', 'label' => 'Użytkownik', 'rules' => array(new FormEngine\Rules\Required('Podaj użytkownika bazy SQL.'))))); $database->AddChild(new FormEngine\Elements\Password(array('name' => 'password', 'label' => 'Hasło'))); $database->AddChild(new FormEngine\Elements\TextField(array('name' => 'database', 'label' => 'Nazwa bazy', 'rules' => array(new FormEngine\Rules\Required('Podaj nazwę bazy SQL.'))))); $database->AddChild(new FormEngine\Elements\TextField(array('name' => 'client_data_encription_string', 'label' => 'Klucz szyfrujący dane', 'default' => substr(md5(uniqid(rand(), true)), 0, 32), 'rules' => array(new FormEngine\Rules\Required('Musisz podać klucz szyfrujący.'))))); $installation = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'installation', 'label' => 'Instalacja'))); $installation->AddChild(new FormEngine\Elements\StaticText(array('text' => '<a href="#" class="installButton">Zainstaluj Gekosale</a>'))); $form->AddFilter(new FormEngine\Filters\Trim()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $Data = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $conn = $this->testDBConnection($Data); if ($conn === TRUE) { $this->importDatabase($Data); $this->configWriter($Data); header('Location: ' . $this->panelURL('admin')); } else { $this->error = addslashes($conn); } } } else { $requirements = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'requirements', 'label' => 'Requirements'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkPHPVersion == TRUE ? '<p style="color: green;"><strong>PHP version</strong> - OK</p>' : '<p style="color: red"><strong>PHP version</strong> - ' . $minPHP . ' required, ' . phpversion() . ' available</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkExtensionZlib == TRUE ? '<p style="color: green;"><strong>Zlib extension</strong> - OK</p>' : '<p style="color: red"><strong>Zlib extension</strong> - No</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkExtensionMysqli == TRUE ? '<p style="color: green;"><strong>Mysqli extension</strong> - OK</p>' : '<p style="color: red"><strong>Mysqli extension</strong> - No</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkExtensionCurl == TRUE ? '<p style="color: green;"><strong>cURL extension</strong> - OK</p>' : '<p style="color: red"><strong>cURL extension</strong> - No</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkExtensionGd == TRUE ? '<p style="color: green;"><strong>GD extension</strong> - OK</p>' : '<p style="color: red"><strong>GD extension</strong> - No</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkDirLogs == TRUE ? '<p style="color: green;"><strong>"logs" dir writeable</strong> - OK</p>' : '<p style="color: red"><strong>"logs" dir writeable</strong> - No</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkDirCache == TRUE ? '<p style="color: green;"><strong>"cache" dir writeable</strong> - OK</p>' : '<p style="color: red"><strong>"cache" dir writeable</strong> - No</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkDirSerialization == TRUE ? '<p style="color: green;"><strong>"serialization" dir writeable</strong> - OK</p>' : '<p style="color: red"><strong>"serialization" dir writeable</strong> - No</p>'))); $requirements->AddChild(new FormEngine\Elements\StaticText(array('text' => $checkOB == TRUE ? '<p style="color: green;"><strong>"output_buffering" is ON</strong> - OK</p>' : '<p style="color: red"><strong>"output_buffering" is OFF</strong> - No</p>'))); } $this->template->display($this->tplFile, array('DESIGNPATH' => App::getURLAdress() . 'design/', 'form' => $form->Render('JS', '', false), 'error' => $this->error)); }
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')); }
public function edit() { $rulescartArray = array(); $rulescartRaw = App::getModel('rulescart')->getRulesCartAll(); foreach ($rulescartRaw as $rulescartruleRaw) { $rulescartArray[$rulescartruleRaw['id']]['name'] = $rulescartruleRaw['name']; $rulescartArray[$rulescartruleRaw['id']]['parent'] = $rulescartruleRaw['parent']; $rulescartArray[$rulescartruleRaw['id']]['weight'] = $rulescartruleRaw['distinction']; } $tree = new FormEngine\Elements\Form(array('name' => 'rulescart_tree', 'class' => 'rulescart-select', 'action' => '', 'method' => 'post')); $tree->AddChild(new FormEngine\Elements\SortableList(array('name' => 'rulescart', 'label' => _('TXT_RULES_CART'), 'add_item_prompt' => _('TXT_ENTER_NEW_CART_RULE_NAME'), 'delete_item_prompt' => _('TXT_DELETE_CART_RULE'), 'sortable' => false, 'selectable' => false, 'clickable' => true, 'deletable' => true, 'addable' => true, 'total' => count($rulescartArray), 'items' => $rulescartArray, 'onClick' => 'openRulesCartEditor', 'onSaveOrder' => 'xajax_ChangeRulesCartOrder', 'onAdd' => 'xajax_AddRulesCart', 'onAfterAdd' => 'openRulesCartEditor', 'onDelete' => 'xajax_DeleteRulesCart', 'onAfterDelete' => 'openRulesCartEditor', 'active' => $this->registry->core->getParam()))); $this->registry->template->assign('tree', $tree->Render()); // //////////////////////////////////// EDIT RULE CART // /////////////////////////////////////////////// $form = new FormEngine\Elements\Form(array('name' => 'rulescart', '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'), 'rulescarttranslation', 'name', null, array('column' => 'rulescartid', 'values' => (int) $this->registry->core->getParam())))))); $languageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'description', 'label' => _('TXT_DESCRIPTION')))); $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Jeśli chcesz, by reguła obowiązywała zawsze, zostaw puste pola z datą</strong></p>', 'direction' => FormEngine\Elements\Tip::DOWN))); $datefrom = $requiredData->AddChild(new FormEngine\Elements\Date(array('name' => 'datefrom', 'label' => _('TXT_START_DATE')))); $requiredData->AddChild(new FormEngine\Elements\Date(array('name' => 'dateto', 'label' => _('TXT_END_DATE')))); // //////////////////////////////// CLIENT GROUPS // ////////////////////////////////////////// $additionalData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'additional_data', 'label' => _('TXT_PROMOTIONRULE_DISCOUNT_DATA')))); $additionalData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Możesz podać wysokość zniżki kwotowo (modyfikator "-") lub procentową wartość zamówienia. Wprowadzając wartość 10:</p> <ul> <li><strong>dla modyfikatora "-"</strong> obniżysz kwotę zamówienia o 10 w danej walucie</li> <li><strong>dla modyfikatora "%"</strong> kwota zamówienia wyniesie 10% pierwotnej wartości</li> </ul> <p><strong>Przykład:</strong> Chcąc udzielić 10% rabatu na zamówienie, wprowadź wartość 90 i wybierz modyfikator "%".</p> '))); $discountForAll = $additionalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'discountforall', 'label' => _('TXT_DISCOUNT_FOR_ALL_GROUP')))); $suffixtypeid = $additionalData->AddChild(new FormEngine\Elements\Select(array('name' => 'suffixtypeid', 'label' => _('TXT_SUFFIXTYPE'), 'options' => FormEngine\Option::Make(App::getModel('suffix/suffix')->getRulesSuffixTypesForSelect()), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1'))))))); $additionalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'discount', 'label' => _('TXT_VALUE'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_VALUE_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/')), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1'))))))); $additionalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'freeshipping', 'label' => _('TXT_FREE_DELIVERY'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1'))))))); $clientGroups = App::getModel('clientgroup/clientgroup')->getClientGroupAll(); foreach ($clientGroups as $clientGroup) { $additionalData->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'field_' . $clientGroup['id'], 'label' => 'Rabat dla ' . $clientGroup['name'], 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1'))))))); $groups[$clientGroup['id']] = $additionalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'groupid_' . $clientGroup['id'], 'label' => $clientGroup['name'], 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1'))))))); $suffix = $additionalData->AddChild(new FormEngine\Elements\Select(array('name' => 'suffixtypeid_' . $clientGroup['id'], 'label' => _('TXT_SUFFIXTYPE'), 'options' => FormEngine\Option::Make(App::getModel('suffix/suffix')->getRulesSuffixTypesForSelect()), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $groups[$clientGroup['id']], new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals(1))), new FormEngine\Dependency(FormEngine\Dependency::SHOW, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1'))))))); $additionalData->AddChild(new FormEngine\Elements\TextField(array('name' => 'discount_' . $clientGroup['id'], 'label' => _('TXT_VALUE'), 'default' => '0.00', 'rules' => array(new FormEngine\Rules\Format(_('ERR_VALUE_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/'), new FormEngine\Rules\Custom(_('ERR_VALUE_INVALID'), array($this, 'checkDiscountValue'), array('suffixType' => $suffix))), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $groups[$clientGroup['id']], new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals(1))), new FormEngine\Dependency(FormEngine\Dependency::SHOW, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1')))), 'filters' => array(new FormEngine\Filters\CommaToDotChanger())))); $additionalData->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'freeshipping_' . $clientGroup['id'], 'label' => _('TXT_FREE_DELIVERY'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $discountForAll, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1'))))))); } $deliverers = App::getModel('dispatchmethod')->getDispatchmethodToSelect(); $deliverersData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'deliverers_data', 'label' => _('TXT_DELIVER')))); if (count($deliverers)) { $deliverersData->AddChild(new FormEngine\Elements\MultiSelect(array('name' => 'deliverers', 'label' => _('TXT_DISPATCHMETHOD'), 'options' => FormEngine\Option::Make($deliverers)))); } else { $deliverersData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p><strong>' . _('TXT_EMPTY_DISPATCHMETHODS') . '</strong><br/> <a href="/admin/dispatchmethod/add" target="_blank">' . _('TXT_ADD_DISPATCHMETHOD') . '</a></p>'))); } // ///////////////////////////////// PAYMENT METHODS // ///////////////////////////////////////////// $payments = App::getModel('paymentmethod')->getPaymentmethodToSelect(); $paymentsData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'payments_data', 'label' => _('TXT_PAYMENTMETHODS')))); if (count($payments)) { $paymentsData->AddChild(new FormEngine\Elements\MultiSelect(array('name' => 'payments', 'label' => _('TXT_PAYMENTMETHODS'), 'options' => FormEngine\Option::Make($payments)))); } else { $paymentsData->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p><strong>' . _('TXT_EMPTY_PAYMENTMETHODS') . '</strong><br/> <a href="/admin/paymentmethod/add" target="_blank">' . _('TXT_ADD_PAYMENTMETHOD') . '</a></p>'))); } $pricePane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'price_pane', 'label' => _('TXT_SUM_PRICE')))); $pricePane->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p><strong>' . _('TXT_FINAL_CART_PRICE') . '</strong></p>'))); $pricePane->AddChild(new FormEngine\Elements\TextField(array('name' => 'cart_price_from', 'label' => _('TXT_PRICE_FROM'), 'suffix' => 'brutto', 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/'))))); $pricePane->AddChild(new FormEngine\Elements\TextField(array('name' => 'cart_price_to', 'label' => _('TXT_PRICE_TO'), 'suffix' => 'brutto', 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/'))))); $pricePane->AddChild(new FormEngine\Elements\StaticText(array('text' => '<p><strong>' . _('TXT_TOTAL_COST') . '</strong></p>'))); $pricePane->AddChild(new FormEngine\Elements\TextField(array('name' => 'dispatch_price_from', 'label' => _('TXT_PRICE_FROM'), 'suffix' => 'brutto', 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/'))))); $pricePane->AddChild(new FormEngine\Elements\TextField(array('name' => 'dispatch_price_to', 'label' => _('TXT_PRICE_TO'), 'suffix' => 'brutto', 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/^([0-9]*\\.*([0-9]{1,2})|(\\0)?)$/'))))); // /////////////////////////////////// VIEW DATA // ///////////////////////////////////////////// $layerData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'view_data', 'label' => _('TXT_STORES')))); $layers = $layerData->AddChild(new FormEngine\Elements\LayerSelector(array('name' => 'view', 'label' => _('TXT_VIEW')))); $form->AddFilter(new FormEngine\Filters\NoCode()); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); // //////////////////////////////////// POPULATE // ////////////////////////////////////////////////// // ////////////////////////////////// REQUIRED_DATA // //////////////////////////////////////////////// $rawRulesCartData = App::getModel('rulescart')->getRulesCartView($this->registry->core->getParam()); $rulesCartRuleData['required_data'] = array('language_data' => $rawRulesCartData['language'], 'suffixtypeid' => $rawRulesCartData['suffixtypeid'], 'discount' => round($rawRulesCartData['discount'], 0), 'datefrom' => $rawRulesCartData['datefrom'], 'dateto' => $rawRulesCartData['dateto'], 'freeshipping' => $rawRulesCartData['freeshipping']); // ////////////////////////////////// ADDITIONAL_DATA // //////////////////////////////////////////////// $rawRulesCartClientGroupData = App::getModel('rulescart')->getRulesCartClientGroupView($this->registry->core->getParam()); if (isset($rawRulesCartData['discountforall']) && $rawRulesCartData['discountforall'] == 1) { $rulesCartRuleData['additional_data']['discountforall'] = $rawRulesCartData['discountforall']; $rulesCartRuleData['additional_data']['suffixtypeid'] = $rawRulesCartData['suffixtypeid']; $rulesCartRuleData['additional_data']['discount'] = round($rawRulesCartData['discount'], 0); $rulesCartRuleData['additional_data']['freeshipping'] = $rawRulesCartData['freeshipping']; } else { $rawRulesCartClientGroupData = App::getModel('rulescart')->getRulesCartClientGroupView($this->registry->core->getParam()); if (count($rawRulesCartClientGroupData) > 0) { foreach ($rawRulesCartClientGroupData as $clientGroupKey => $clientGroupValue) { $rulesCartRuleData['additional_data']['groupid_' . $clientGroupValue['clientgroupid']] = 1; $rulesCartRuleData['additional_data']['discount_' . $clientGroupValue['clientgroupid']] = $clientGroupValue['discount']; $rulesCartRuleData['additional_data']['suffixtypeid_' . $clientGroupValue['clientgroupid']] = $clientGroupValue['suffixtypeid']; $rulesCartRuleData['additional_data']['freeshipping_' . $clientGroupValue['clientgroupid']] = $clientGroupValue['freeshipping']; } } } // ////////////////////////////////// DELIVERER_DATA // //////////////////////////////////////////////// $rawRulesCartDeliverersData = App::getModel('rulescart')->getRulesCartDeliverersView($this->registry->core->getParam()); if (count($rawRulesCartDeliverersData) > 0) { foreach ($rawRulesCartDeliverersData as $delivererId) { $rulesCartRuleData['deliverers_data']['deliverers'][] = $delivererId; } } // ///////////////////////////////// PAYMENT METHODS // ///////////////////////////////////////////// $rawRulesCartPaymentData = App::getModel('rulescart')->getRulesCartPaymentsView($this->registry->core->getParam()); if (count($rawRulesCartPaymentData) > 0) { foreach ($rawRulesCartPaymentData as $paymentId) { $rulesCartRuleData['payments_data']['payments'][] = $paymentId; } } // /////////////////////////////////// CART PRICE // //////////////////////////////////////////////// $rawRulesCartDynamicData = App::getModel('rulescart')->getRulesCartOtherDinamicDataConditionsView($this->registry->core->getParam()); if (count($rawRulesCartDynamicData) > 0) { foreach ($rawRulesCartDynamicData as $dynamicData) { if ($dynamicData['ruleid'] == 11 && $dynamicData['field'] == 'globalpricefrom') { $rulesCartRuleData['price_pane']['cart_price_from'] = $dynamicData['pricefrom']; } if ($dynamicData['ruleid'] == 12 && $dynamicData['field'] == 'globalpriceto') { $rulesCartRuleData['price_pane']['cart_price_to'] = $dynamicData['priceto']; } if ($dynamicData['ruleid'] == 13 && $dynamicData['field'] == 'globalpricewithdispatchmethodfrom') { $rulesCartRuleData['price_pane']['dispatch_price_from'] = $dynamicData['pricefrom']; } if ($dynamicData['ruleid'] == 14 && $dynamicData['field'] == 'globalpricewithdispatchmethodto') { $rulesCartRuleData['price_pane']['dispatch_price_to'] = $dynamicData['priceto']; } } } // /////////////////////////////////// VIEW DATA // ///////////////////////////////////////////// $rawRulesCartViewData = App::getModel('rulescart')->getRulesCartViews($this->registry->core->getParam()); if (count($rawRulesCartViewData) > 0) { foreach ($rawRulesCartViewData as $viewKey => $viewValue) { $rulesCartRuleData['view_data']['view'][] = $viewValue; } } $form->Populate($rulesCartRuleData); // ///////////////////////////////////// SUBMIT // ///////////////////////////////////////////////////// if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $formData = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); App::getModel('rulescart')->editRulesCart($formData, $this->registry->core->getParam()); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/rulescart/edit/' . $this->id); } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// $this->registry->template->assign('form', $form->Render()); $this->registry->xajaxInterface->registerFunction(array('DeleteRulesCart', App::getModel('rulescart'), 'deleteRulesCart')); $this->registry->xajaxInterface->registerFunction(array('AddRulesCart', App::getModel('rulescart'), 'addEmptyRulesCart')); $this->registry->xajaxInterface->registerFunction(array('ChangeRulesCartOrder', App::getModel('rulescart'), 'changeRulesCartOrder')); $this->registry->xajax->processRequest(); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->display($this->loadTemplate('edit.tpl')); }
public function edit() { $subpages = $this->model->getSubpageTree(); $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__ . '/subpagelayout/edit/' . $pagescheme_id . ',' . $this->model->getFirstPageScheme($pagescheme_id)); } $subpage_id = $this->registry->core->getParam(1); // id from URL if ((int) $subpage_id == 0 || empty($subpages[$pagescheme_id . ',' . $subpage_id])) { // change pagescheme if subpage is not inside active $pagescheme_id = App::getModel('view')->getViewPagescheme(Helper::getViewId()); App::redirect(__ADMINPANE__ . '/subpagelayout/edit/' . $pagescheme_id . ',' . $this->model->getFirstPageScheme($pagescheme_id)); } $subpageLayout = App::getModel('subpagelayout')->getSubPageLayoutAll($subpage_id); if (!isset($subpageLayout[0]['name'])) { App::redirect(__ADMINPANE__ . '/subpagelayout'); } $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' => false, 'addable' => false, 'items' => $subpages, 'onClick' => 'openSubpageEditor', 'active' => $pagescheme_id . ',' . $subpage_id))); $form = new FormEngine\Elements\Form(array('name' => 'subpagelayout', 'action' => '', 'method' => 'post')); $columnsEdit = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'columns', 'label' => _('TXT_SUBPAGE_COLUMNS')))); $subpages = App::getModel('subpagelayout')->getSubPageLayoutAllToSelect($subpage_id); $subpagelayoutid = $columnsEdit->AddChild(new FormEngine\Elements\Constant(array('name' => 'subpagelayout_subpage', 'label' => _('Podstrona')))); $subpagelayoutid = $columnsEdit->AddChild(new FormEngine\Elements\Hidden(array('name' => 'subpagelayoutid'))); $columnsDataEdit = $columnsEdit->AddChild(new FormEngine\Elements\FieldsetRepeatable(array('name' => 'columns_data', 'label' => _('TXT_COLUMNS_DATA'), 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE))); $columnsDataEdit->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Aby kolumna rozciągnęła się na całą, pozostałą część strony, jako jej szerokość podaj wartość <strong>0</strong>.</p><p>Jeśli kilka kolumn będzie miało szerokość 0, wówczas zostaną im automatycznie przyznane równe części pozostałego miejsca.</p>', 'retractable' => false))); $columnsDataEdit->AddChild(new FormEngine\Elements\TextField(array('name' => 'columns_width', 'label' => _('TXT_WIDTH'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_WIDTH')))))); $boxDataEdit = $columnsDataEdit->AddChild(new FormEngine\Elements\LayoutBoxesList(array('name' => 'layout_boxes', 'label' => 'Wybierz boksy', 'boxes' => FormEngine\Option::Make(App::getModel('subpagelayout')->getBoxesAllToSelect($subpageLayout[0]['name'], $pagescheme_id))))); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\Secure()); $subpagelayoutcolumn = App::getModel('subpagelayout')->getSubPageLayoutColumn($subpage_id); $populate = array(); if (is_array($subpagelayoutcolumn) && count($subpagelayoutcolumn) > 0) { if (isset($subpagelayoutcolumn['subpagelayoutid']) && $subpagelayoutcolumn['subpagelayoutid'] > 0) { $populate['columns']['subpagelayout_subpage'] = $subpages[$subpagelayoutcolumn['subpagelayoutid']]; $populate['columns']['subpagelayoutid'] = $subpagelayoutcolumn['subpagelayoutid']; } if (isset($subpagelayoutcolumn['columns']) && count($subpagelayoutcolumn['columns']) > 0) { foreach ($subpagelayoutcolumn['columns'] as $column) { $populate['columns']['columns_data'][$column['idsubpagelayoutcolumn']] = array('columns_width' => $column['width']); if (count($column['subpagelayoutcolumnbox']) > 0) { foreach ($column['subpagelayoutcolumnbox'] as $boxes) { $populate['columns']['columns_data'][$column['idsubpagelayoutcolumn']]['layout_boxes'][$boxes['order']] = array('box' => $boxes['layoutboxid'], 'span' => $boxes['colspan'], 'collapsed' => (int) $boxes['collapsed']); } } } } $form->Populate($populate); } if ($form->Validate(FormEngine\FE::SubmittedData())) { try { App::getModel('subpagelayout')->editSubpageLayout($form->getSubmitValues(), $subpage_id); App::getModel('subpagelayout')->flushCache($subpages[$subpagelayoutcolumn['subpagelayoutid']]); App::redirect(__ADMINPANE__ . '/subpagelayout/edit/' . $pagescheme_id . ',' . $subpage_id); } catch (Exception $e) { Session::setVolatileSubpageLayoutAdd(1, false); } } $error = Session::getVolatileSubpageLayoutAdd(); if ($error[0] == 1) { $this->registry->template->assign('error', $e->getMessage()); } $this->registry->xajaxInterface->registerFunction(array('DeleteSubpageLayout', $this, 'DeleteSubpageLayoutForAjax')); $this->renderLayout(array('subpageLayout' => $subpageLayout[0], 'form' => $form->Render(), 'tree' => $tree->Render())); }
public function duplicate() { $tree = new FormEngine\Elements\Form(array('name' => 'category_tree', 'class' => 'category-select', 'action' => '', 'method' => 'post')); $categories = $this->model->getChildCategories(0, array($this->id)); $tree->AddChild(new FormEngine\Elements\Tree(array('name' => 'categories', 'label' => _('TXT_CATEGORIES'), 'add_item_prompt' => _('TXT_ENTER_NEW_CATEGORY_NAME'), 'sortable' => true, 'selectable' => false, 'clickable' => true, 'deletable' => true, 'addable' => true, 'prevent_duplicates' => true, 'items' => $categories, 'load_children' => array($this->model, 'getChildCategories'), 'onClick' => 'openCategoryEditor', 'onDuplicate' => 'openCategoryEditorDuplicate', 'onSaveOrder' => 'xajax_ChangeCategoryOrder', 'onAdd' => 'xajax_AddCategory', 'onAfterAdd' => 'openCategoryEditor', 'onDelete' => 'xajax_DeleteCategory', 'onAfterDelete' => 'openCategoryEditor', 'active' => $this->id))); $rawCategoryData = $this->model->getCategoryView($this->id); $populateData = array('required_data' => array('language_data' => $rawCategoryData['language'], 'categoryid' => $rawCategoryData['catid'], 'distinction' => $rawCategoryData['distinction'], 'enable' => $rawCategoryData['enable']), 'meta_data' => array('language_data' => $rawCategoryData['language']), 'description_pane' => array('language_data' => $rawCategoryData['language']), 'photos_pane' => array('photo' => $rawCategoryData['photoid']), 'category_products' => array('products' => App::getModel('category')->getProductsDataGrid((int) $this->id)), 'view_data' => array('view' => $rawCategoryData['view'])); $this->formModel->setPopulateData($populateData); $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $formData = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $this->model->duplicateCategory($formData); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/category'); } $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->xajax->processRequest(); $this->registry->template->assign('id', $this->id); $this->registry->template->assign('tree', $tree->Render()); $this->registry->template->assign('form', $form->Render()); $this->registry->template->assign('total', count($categories)); $this->registry->template->assign('categoryName', $rawCategoryData['language'][Helper::getLanguageId()]['name']); $this->registry->template->display($this->loadTemplate('duplicate.tpl')); }
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 edit() { $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', null, array('column' => 'idrecipientlist', 'values' => (int) $this->registry->core->getParam())))))); $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()); $rawRecipientListData = $this->model->getRecipientListView($this->registry->core->getParam()); $groups = array(); foreach ($rawRecipientListData['clientgrouplist'] as $groupKey => $groupValue) { array_push($groups, $groupValue['clientgroupid']); } $clients = array(); foreach ($rawRecipientListData['clientlist'] as $clientKey => $clientValue) { array_push($clients, $clientValue['clientid']); } $clientnewsletter = array(); foreach ($rawRecipientListData['clientnewsletterlist'] as $clientnewsletterKey => $clientnewsletterValue) { array_push($clientnewsletter, $clientnewsletterValue['clientnewsletterid']); } $RecipientListData = array('required_data' => array('name' => $rawRecipientListData['name']), 'clientgroup_data' => array('clientgroup' => $groups), 'client_data' => array('clients' => $clients), 'clientnewsletter_data' => array('clientnewsletter' => $clientnewsletter)); $form->Populate($RecipientListData); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->editRecipientList($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->registry->core->getParam()); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/recipientlist'); } $this->registry->xajax->processRequest(); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->assign('form', $form->Render()); $this->registry->template->display($this->loadTemplate('edit.tpl')); }