Example #1
0
 public function index()
 {
     $Config = App::getConfig();
     $configData = array('config_data' => array('admin_panel_link' => __ADMINPANE__, 'ssl' => (string) (isset($Config['ssl']) && $Config['ssl'] == 1) ? 1 : 0), 'gallerysettings_data' => App::getModel('globalsettings')->getGallerySettings());
     $settingsData = App::getModel('globalsettings')->getSettings();
     $colour = $settingsData['gallerysettings_data']['colour'];
     unset($settingsData['gallerysettings_data']);
     $settingsData['gallerysettings_data']['colour'] = array('type' => 1, 'start' => $colour);
     $this->formModel->setPopulateData(array_merge_recursive($configData, $settingsData));
     $form = $this->formModel->initForm();
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         try {
             $Data = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT);
             $Settings = $form->getSubmitValues();
             Event::notify($this, 'admin.globalsettings.model.save', array('id' => 1, 'data' => $Data));
             App::getModel('globalsettings')->updateGallerySettings($Data);
             App::getModel('globalsettings')->updateGlobalSettings($Settings['interface'], 'interface');
             App::getModel('globalsettings')->updateGlobalSettings(array('colour' => $Settings['gallerysettings_data']['colour']['start']), 'gallerysettings_data');
             Session::setActiveGlobalSettings(NULL);
             App::getModel('globalsettings')->configWriter($Data);
             if (__ADMINPANE__ != $Data['admin_panel_link']) {
                 Session::flush();
                 App::redirect('');
             } else {
                 App::redirect(__ADMINPANE__ . '/globalsettings');
             }
         } catch (Exception $e) {
             $this->registry->template->assign('error', $e->getMessage());
         }
     }
     $this->renderLayout(array('form' => $form->Render()));
 }
Example #2
0
 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'));
 }
Example #3
0
 public function edit()
 {
     $rawAttributeGroupData = $this->model->getGroup($this->id);
     if (empty($rawAttributeGroupData)) {
         App::redirect(__ADMINPANE__ . '/attributegroup/');
     }
     $this->registry->xajaxInterface->registerFunction(array('AddGroup', $this->model, 'addEmptyGroup'));
     $this->registry->xajaxInterface->registerFunction(array('DeleteGroup', $this->model, 'deleteGroup'));
     $populateData = array('group_data' => array('attributegroupname' => $rawAttributeGroupData['name'], 'category' => $rawAttributeGroupData['category']), 'attribute_data' => array('attributes' => $rawAttributeGroupData['attributes']));
     $error = Session::getVolatileErrorMessage();
     if ($error) {
         $this->registry->template->assign('errormessage', print_r($error, 1));
     }
     $this->formModel->setPopulateData($populateData);
     $form = $this->formModel->initForm();
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         try {
             $this->model->editAttributeGroup($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->id);
         } catch (Exception $e) {
             $this->registry->template->assign('error', $e->getMessage());
         }
         App::redirect(__ADMINPANE__ . '/attributegroup/edit/' . $this->id);
     }
     $this->renderLayout(array('form' => $form->Render(), 'existingGroups' => $this->model->getAllAttributeGroupName(), 'currentGroup' => $rawAttributeGroupData));
 }
Example #4
0
 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'));
 }
Example #5
0
 public function index()
 {
     if (Session::getActiveClientid() == NULL) {
         $form = new SimpleForm\Form(array('name' => 'order', 'action' => '', 'method' => 'post'));
         $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_EMAIL')), new SimpleForm\Rules\Email(_('ERR_WRONG_EMAIL'))))));
         $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'orderid', 'label' => _('TXT_ORDER_NUMER'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_ORDER_ID'))))));
         if ($form->Validate()) {
             $formData = $form->getSubmitValues();
             $order = App::getModel('order')->getOrderStatusByEmailAndId($formData['email'], $formData['orderid']);
             if ($order != NULL) {
                 $this->registry->template->assign('status', array('orderid' => $formData['orderid'], 'name' => $order));
             } else {
                 $this->registry->template->assign('status', NULL);
             }
         }
         $this->registry->template->assign('form', $form->getForm());
         return $this->registry->template->fetch($this->loadTemplate('check.tpl'));
     } else {
         if ((int) $this->registry->core->getParam() > 0) {
             $order = App::getModel('order')->getOrderByClient((int) $this->registry->core->getParam());
             if (empty($order)) {
                 App::redirectUrl($this->registry->router->generate('frontend.clientorder', true));
             }
             $this->registry->template->assign('order', $order);
             $this->registry->template->assign('orderproductlist', App::getModel('order')->getOrderProductListByClient((int) $this->registry->core->getParam()));
             return $this->registry->template->fetch($this->loadTemplate('view.tpl'));
         } else {
             $this->registry->template->assign('orderlist', App::getModel('order')->getOrderListByClient());
             return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
         }
     }
 }
Example #6
0
 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'));
 }
Example #7
0
 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'));
 }
Example #8
0
 public function initForm()
 {
     $form = new SimpleForm\Form(array('name' => 'registration', 'action' => '', 'method' => 'post'));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone', 'label' => _('TXT_PHONE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PHONE'))))));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_EMAIL')), new SimpleForm\Rules\Email(_('ERR_WRONG_EMAIL'))))));
     $newPassword = $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'password', 'label' => _('TXT_PASSWORD'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PASSWORD')), new SimpleForm\Rules\MinLength(_('ERR_PASSWORD_NEW_INVALID'), 6)))));
     $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'confirmpassword', 'label' => _('TXT_PASSWORD_REPEAT'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_CONFIRM_PASSWORD')), new SimpleForm\Rules\Compare(_('ERR_PASSWORDS_NOT_COMPATIBILE'), $newPassword)))));
     $form->AddChild(new SimpleForm\Elements\Checkbox(array('name' => 'confirmterms', 'label' => sprintf(_('TXT_ACCEPT_TERMS_AND_POLICY_OF_PRIVATE'), App::getModel('staticcontent')->getConditionsLink(), Session::getActiveShopName()), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_TERMS_NOT_AGREED'))), 'default' => 0)));
     $form->AddChild(new SimpleForm\Elements\Checkbox(array('name' => 'newsletter', 'label' => _('TXT_NEWSLETTER_SIGNUP'), 'default' => 0)));
     return $form;
 }
Example #9
0
 public function index()
 {
     $contacts = App::getModel('Contact')->getContactToSelect();
     $contactList = App::getModel('Contact')->getContactList();
     $form = new SimpleForm\Form(array('name' => 'contactform', 'action' => '', 'method' => 'post'));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_EMAIL')), new SimpleForm\Rules\Email(_('ERR_WRONG_EMAIL'))))));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone', 'label' => _('TXT_PHONE'))));
     if ((int) $this->registry->core->getParam() == 0) {
         $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'topic', 'label' => _('TXT_TOPIC'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_TOPIC'))))));
     }
     $form->AddChild(new SimpleForm\Elements\TextArea(array('name' => 'content', 'label' => _('TXT_CONTENT'), 'rows' => 10, 'cols' => 100, 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_CONTACT_CONTENT'))))));
     $client = App::getModel('client')->getClient();
     if (!empty($client)) {
         $form->Populate(array('firstname' => $client['firstname'], 'surname' => $client['surname'], 'phone' => $client['phone'], 'email' => $client['email']));
     }
     if ($form->Validate()) {
         $formData = $form->getSubmitValues();
         $emails = array($formData['email']);
         if (isset($formData['contactsubject'])) {
             $emails[] = App::getModel('Contact')->getDepartmentMail($formData['contactsubject']);
         }
         $content = $formData['content'];
         if ((int) $this->registry->core->getParam() > 0) {
             $subject = _('TXT_PRODUCT_QUOTE') . ' ' . $this->product['productname'];
             $this->registry->template->assign('productLink', $this->registry->router->generate('frontend.productcart', true, array('param' => $this->product['seo'])));
         } else {
             $subject = $formData['topic'];
         }
         $this->registry->template->assign('CONTACT_CONTENT', $formData['content']);
         $this->registry->template->assign('firstname', $formData['firstname']);
         $this->registry->template->assign('surname', $formData['surname']);
         $this->registry->template->assign('email', $formData['email']);
         $this->registry->template->assign('phone', $formData['phone']);
         App::getModel('mailer')->sendEmail(array('template' => 'contact', 'email' => $emails, 'bcc' => true, 'subject' => $subject, 'viewid' => Helper::getViewId()));
         Session::setVolatileSendContact(1, false);
         App::redirectUrl($this->registry->router->generate('frontend.contact', true));
     }
     $sendContact = Session::getVolatileSendContact();
     if ($sendContact[0] == 1) {
         $this->registry->template->assign('sendContact', _('TXT_CONTACT_SENT'));
     }
     $this->registry->template->assign('form', $form->getForm());
     if ((int) $this->registry->core->getParam() > 0) {
         $this->registry->template->assign('productid', $this->getParam());
     }
     $this->registry->template->assign('content', App::getModel('staticcontent')->getContentByRoute('frontend.contact'));
     $this->registry->template->assign('contactList', $contactList);
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Example #10
0
 public function index()
 {
     $clientBillingAddress = $this->model->getClientAddress(1);
     $clientShippingAddress = $this->model->getClientAddress(0);
     $formBilling = new SimpleForm\Form(array('name' => 'billingForm', 'action' => '', 'method' => 'post'));
     $clientType = $formBilling->AddChild(new SimpleForm\Elements\Radio(array('name' => 'clienttype', 'label' => _('TXT_CLIENT_TYPE'), 'options' => array('1' => _('TXT_INDIVIDUAL_CLIENT'), '2' => _('TXT_COMPANY_CLIENT')))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_NIP'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formBilling->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $formBilling->Populate(array('clienttype' => $clientBillingAddress['clienttype'], 'firstname' => $clientBillingAddress['firstname'], 'surname' => $clientBillingAddress['surname'], 'companyname' => $clientBillingAddress['companyname'], 'nip' => $clientBillingAddress['nip'], 'street' => $clientBillingAddress['street'], 'streetno' => $clientBillingAddress['streetno'], 'postcode' => $clientBillingAddress['postcode'], 'placename' => $clientBillingAddress['placename'], 'placeno' => $clientBillingAddress['placeno'], 'countryid' => $clientBillingAddress['countryid']));
     if ($formBilling->Validate()) {
         $formData = $formBilling->getSubmitValues();
         $this->model->updateClientAddress($formData, 1);
         if ($clientShippingAddress['idclientaddress'] == 0) {
             $this->model->updateClientAddress($formData, 0);
         }
         App::redirectUrl($this->registry->router->generate('frontend.clientaddress', true));
     }
     $formShipping = new SimpleForm\Form(array('name' => 'shippingForm', 'action' => '', 'method' => 'post'));
     $clientType = $formShipping->AddChild(new SimpleForm\Elements\Radio(array('name' => 'clienttype', 'label' => _('TXT_CLIENT_TYPE'), 'options' => array('1' => _('TXT_INDIVIDUAL_CLIENT'), '2' => _('TXT_COMPANY_CLIENT')))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formShipping->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $clientShippingAddress = $this->model->getClientAddress(0);
     $formShipping->Populate(array('clienttype' => $clientShippingAddress['clienttype'], 'firstname' => $clientShippingAddress['firstname'], 'surname' => $clientShippingAddress['surname'], 'companyname' => $clientShippingAddress['companyname'], 'nip' => $clientShippingAddress['nip'], 'street' => $clientShippingAddress['street'], 'streetno' => $clientShippingAddress['streetno'], 'postcode' => $clientShippingAddress['postcode'], 'placename' => $clientShippingAddress['placename'], 'placeno' => $clientShippingAddress['placeno'], 'countryid' => $clientShippingAddress['countryid']));
     if ($formShipping->Validate()) {
         $formData = $formShipping->getSubmitValues();
         $this->model->updateClientAddress($formData, 0);
         Session::setVolatileMessage("Zapisano zmiany w adresie dostawy.");
         App::redirectUrl($this->registry->router->generate('frontend.clientaddress', true));
     }
     $this->registry->template->assign('clientBillingAddress', $clientBillingAddress);
     $this->registry->template->assign('clientShippingAddress', $clientShippingAddress);
     $this->registry->template->assign('formBilling', $formBilling->getForm());
     $this->registry->template->assign('formShipping', $formShipping->getForm());
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Example #11
0
 public function add()
 {
     $CurrentViewData = array('basic_pane' => array('enable' => 1, 'producerid' => 0), 'price_pane' => array('buycurrencyid' => Session::getActiveShopCurrencyId(), 'sellcurrencyid' => Session::getActiveShopCurrencyId(), 'vatid' => App::getModel('view')->getDefaultVatId()), 'weight_pane' => array('weight' => 0, 'width' => 0, 'height' => 0, 'deepth' => 0, 'unit' => 0, 'packagesize' => 1), 'stock_pane' => array('stock' => 0, 'trackstock' => 0, 'availablityid' => 0, 'disableatstockenabled' => 0, 'disableatstock' => 0));
     $this->formModel->setPopulateData($CurrentViewData);
     $form = $this->formModel->initForm();
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         $this->model->addNewProduct($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT));
         if (FormEngine\FE::IsAction('next')) {
             App::redirect(__ADMINPANE__ . '/product/add');
         } else {
             App::redirect(__ADMINPANE__ . '/product');
         }
     }
     $this->renderLayout(array('form' => $form->Render()));
 }
Example #12
0
 public function __construct($registry)
 {
     parent::__construct($registry);
     $this->queryColumns = array();
     $this->queryColumnsOptions = array();
     $this->queryTable = '';
     $this->queryFrom = '';
     $this->queryWhere = '';
     $this->queryAdditionalWhere = '';
     $this->queryGroupBy = '';
     $this->encryptionKey = Session::getActiveEncryptionKeyValue();
     $this->languageId = Helper::getLanguageId();
     $this->sqlParams = array();
     $this->viewId = !is_null(Helper::getViewId()) ? Helper::getViewId() : 0;
     $this->viewIds = Helper::getViewIds();
 }
Example #13
0
 public function index()
 {
     $form = App::getFormModel('clientlogin')->initForm();
     if ($form->Validate()) {
         $formData = $form->getSubmitValues();
         $clean = App::getModel('formprotection')->cropDangerousCodeSubmitedValues($formData);
         if ($clean == true) {
             $result = App::getModel('clientlogin')->authProccess($formData['login'], $formData['password']);
             if ($result > 0) {
                 Session::setActiveClientid($result);
                 App::getModel('clientlogin')->checkClientGroup();
                 App::getModel('clientlogin')->setLoginTime();
                 $this->model->saveClientData();
                 $misingCart = App::getModel('missingcart')->checkMissingCartForClient($result);
                 if (isset($formData['autologin']) && $formData['autologin'] == 1) {
                     App::getModel('clientlogin')->setAutologinKey($result);
                 } else {
                     App::getModel('clientlogin')->destroyAutologinKey();
                 }
                 if (is_array($misingCart) && !empty($misingCart)) {
                     App::getModel('cart')->addProductsToCartFromMissingCart($misingCart);
                     App::getModel('missingcart')->cleanMissingCart(Session::getActiveClientid());
                 }
                 if (($this->Cart = Session::getActiveCart()) != NULL) {
                     App::redirectUrl($this->registry->router->generate('frontend.cart', true));
                 } else {
                     App::redirectUrl($this->registry->router->generate('frontend.home', true));
                 }
             } elseif ($result < 0) {
                 Session::setVolatileUserLoginError(2, false);
             } else {
                 Session::setVolatileUserLoginError(1, false);
             }
         }
     }
     if ($this->getParam() == 'changed') {
         $this->registry->template->assign('clientChangedMail', _('TXT_LOGGOUT_CHANGED_EMAIL'));
     }
     $error = Session::getVolatileUserLoginError();
     if ($error[0] == 1) {
         $this->registry->template->assign('loginerror', _('ERR_BAD_LOGIN_OR_PASSWORD'));
     } elseif ($error[0] == 2) {
         $this->registry->template->assign('loginerror', _('TXT_BLOKED_USER'));
     }
     $this->registry->template->assign('form', $form->getForm());
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Example #14
0
    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'));
        }
    }
Example #15
0
 public function getMissingCart($clientid)
 {
     $sql = "SELECT \n\t\t\t\t\tMC.idmissingcart, \n\t\t\t\t\tMC.dispatchmethodid, \n\t\t\t\t\tMC.paymentmethodid \n\t\t\t\tFROM missingcart MC\n\t\t\t\tWHERE MC.clientid = :clientid";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('clientid', Session::getActiveClientid());
     $Data = array();
     try {
         $stmt->execute();
         $rs = $stmt->fetch();
         if ($rs) {
             $Data = array('clientid' => $clientid, 'idmissingcart' => $rs['idmissingcart'], 'dispatchmethodid' => $rs['dispatchmethodid'], 'paymentmethodid' => $rs['paymentmethodid'], 'products' => $this->getProductFromMissingCart($idmissingcart), 'sessionid' => $this['sessionid']);
         } else {
             $Data = 0;
         }
     } catch (Exception $e) {
         new Exception($e->message('Error while selecting session content from sessionhandler.'));
     }
     return $Data;
 }
Example #16
0
 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()));
 }
Example #17
0
 public function getProductsTemplate($model, $controller, $currentParams, $boxAttributes)
 {
     // this has to be defined BEFORE
     // $this->dataset = App::getModel($model)->getDataset();
     // in other case layerednavigationbox will be required
     if ($this->registry->router->getCurrentController() == $controller) {
         $producer = strlen($currentParams['producers']) > 0 ? array_filter(array_values(explode('_', $currentParams['producers']))) : array();
         $attributes = array_filter(strlen($currentParams['attributes']) > 0 ? array_filter(array_values(explode('_', $currentParams['attributes']))) : array());
         $Products = App::getModel('layerednavigationbox')->getProductsForAttributes(0, $attributes);
     }
     $this->dataset = App::getModel($model)->getDataset();
     if ($boxAttributes['productsCount'] > 0) {
         $this->dataset->setPagination($boxAttributes['productsCount']);
     }
     if ($this->registry->router->getCurrentController() == $controller) {
         // only for product news page use datagrid custom parameters
         $sqlParams = array('clientid' => Session::getActiveClientid(), 'producer' => $producer, 'pricefrom' => (double) $currentParams['priceFrom'], 'priceto' => (double) $currentParams['priceTo'], 'filterbyproducer' => !empty($producer) ? 1 : 0, 'enablelayer' => !empty($Products) && count($attributes) > 0 ? 1 : 0, 'products' => $Products);
         if (isset($currentParams['categoryid'])) {
             $sqlParams['categoryid'] = $currentParams['categoryid'];
         }
         if (!empty($currentParams['name'])) {
             $sqlParams['name'] = $currentParams['name'];
         }
         $this->dataset->setSQLParams($sqlParams);
         $this->dataset->setCurrentPage($currentParams['currentPage']);
         if ($currentParams['orderBy'] == 'default') {
             // get order from box settings
             $this->dataset->setOrderBy('name', $boxAttributes['orderBy']);
             $this->dataset->setOrderDir('asc', $boxAttributes['orderDir']);
         } else {
             // get order from params
             $this->dataset->setOrderBy('name', $currentParams['orderBy']);
             $this->dataset->setOrderDir('asc', $currentParams['orderDir']);
         }
     } else {
         $this->dataset->setCurrentPage(1);
         $this->dataset->setOrderBy('name', $boxAttributes['orderBy']);
         $this->dataset->setOrderDir('asc', $boxAttributes['orderDir']);
     }
     return App::getModel($model)->getProductDataset();
 }
Example #18
0
 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'));
 }
Example #19
0
 public function confirm()
 {
     $result = App::getModel('forgotpassword')->validateLink($this->getParam());
     if ($result > 0) {
         $form = new SimpleForm\Form(array('name' => 'forgotpassword', 'action' => '', 'method' => 'post'));
         $newPassword = $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'newpassword', 'label' => _('TXT_PASSWORD_NEW'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PASSWORD')), new SimpleForm\Rules\MinLength(_('ERR_PASSWORD_NEW_INVALID'), 6)))));
         $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'confirmpassword', 'label' => _('TXT_PASSWORD_REPEAT'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_CONFIRM_PASSWORD')), new SimpleForm\Rules\Compare(_('ERR_PASSWORDS_NOT_COMPATIBILE'), $newPassword)))));
         if ($form->Validate()) {
             $formData = $form->getSubmitValues();
             App::getModel('forgotpassword')->forgotPassword($result, $formData['newpassword']);
             Session::setActiveClientid($result);
             App::getModel('clientlogin')->checkClientGroup();
             App::getModel('client')->saveClientData();
             Session::setVolatilePasswordChanged(1, false);
             App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
         }
         $this->registry->template->assign('form', $form->getForm());
         return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
     } else {
         return $this->registry->template->fetch($this->loadTemplate('error.tpl'));
     }
 }
Example #20
0
 public function edit()
 {
     $rawCategoryData = $this->model->getCategoryView($this->id);
     if (empty($rawCategoryData)) {
         App::redirect(__ADMINPANE__ . '/category');
     }
     $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' => 'xajax_DuplicateCategory', 'onSaveOrder' => 'xajax_ChangeCategoryOrder', 'onAdd' => 'xajax_AddCategory', 'onAfterAdd' => 'openCategoryEditor', 'onDelete' => 'xajax_DeleteCategory', 'onAfterDelete' => 'openCategoryEditor', 'onAfterDeleteId' => $rawCategoryData['next'], 'active' => $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->editCategory($formData, $this->id);
             if (isset($integrationModels)) {
                 foreach ($integrationModels as $key => $model) {
                     if (method_exists(App::getModel('integration/' . $model['model']), 'integrationUpdate')) {
                         App::getModel('integration/' . $model['model'])->integrationUpdate($formData, $this->id);
                     }
                 }
             }
             Session::setVolatileMessage("Zapisano zmiany w kategorii.");
         } catch (Exception $e) {
             $this->registry->template->assign('error', $e->getMessage());
         }
         App::redirect(__ADMINPANE__ . '/category/edit/' . $this->id);
     }
     $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('edit.tpl'));
 }
Example #21
0
 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'));
 }
Example #22
0
 public function isNewsletterButton()
 {
     if (isset($_COOKIE['newsletter'])) {
         return FALSE;
     }
     if (Session::getActiveClientid() !== 0 && $this->checkEmailIfExists(Session::getActiveClientEmail()) !== 0) {
         if (!isset($_COOKIE['newsletter'])) {
             setcookie('newsletter', 1, time() + 24 * 60 * 60 * 30, '/', null, false, true);
         }
         return FALSE;
     }
     return TRUE;
 }
Example #23
0
 public function index()
 {
     $clientorder = App::getModel('finalization')->setClientOrder();
     if (App::getModel('cart')->getMinimumOrderValue() > 0 || empty($clientorder['cart'])) {
         App::redirectUrl($this->registry->router->generate('frontend.cart', true));
     }
     $this->registry->xajax->registerFunction(array('saveOrder', App::getModel('finalization'), 'saveOrder'));
     $formContact = new SimpleForm\Form(array('name' => 'contactForm', 'action' => '', 'method' => 'post'));
     $formContact->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone', 'label' => _('TXT_PHONE'))));
     $formContact->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone2', 'label' => _('TXT_ADDITIONAL_PHONE'))));
     $formContact->AddChild(new SimpleForm\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_EMAIL')), new SimpleForm\Rules\Email(_('ERR_WRONG_EMAIL'))))));
     $clientContact = Session::getActiveOrderContactData();
     $formContact->Populate(array('phone' => $clientContact['phone'], 'phone2' => $clientContact['phone2'], 'email' => $clientContact['email']));
     if ($formContact->Validate()) {
         $formData = $formContact->getSubmitValues();
         Session::setActiveOrderContactData($formData);
         App::redirectUrl($this->registry->router->generate('frontend.finalization', true));
     }
     $formBilling = new SimpleForm\Form(array('name' => 'billingForm', 'action' => '', 'method' => 'post'));
     $clientType = $formBilling->AddChild(new SimpleForm\Elements\Radio(array('name' => 'clienttype', 'label' => _('TXT_CLIENT_TYPE'), 'options' => array('1' => _('TXT_INDIVIDUAL_CLIENT'), '2' => _('TXT_COMPANY_CLIENT')))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_NIP'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formBilling->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $clientBillingAddress = Session::getActiveOrderClientAddress();
     $formBilling->Populate(array('clienttype' => $clientBillingAddress['clienttype'], 'firstname' => $clientBillingAddress['firstname'], 'surname' => $clientBillingAddress['surname'], 'companyname' => $clientBillingAddress['companyname'], 'nip' => $clientBillingAddress['nip'], 'street' => $clientBillingAddress['street'], 'streetno' => $clientBillingAddress['streetno'], 'postcode' => $clientBillingAddress['postcode'], 'placename' => $clientBillingAddress['placename'], 'placeno' => $clientBillingAddress['placeno'], 'countryid' => $clientBillingAddress['countryid']));
     if ($formBilling->Validate()) {
         $formData = $formBilling->getSubmitValues();
         if ($formData['clienttype'] == 1) {
             $formData['companyname'] = '';
             $formData['nip'] = '';
         }
         Session::setActiveOrderClientAddress($formData);
         App::redirectUrl($this->registry->router->generate('frontend.finalization', true));
     }
     $formShipping = new SimpleForm\Form(array('name' => 'shippingForm', 'action' => '', 'method' => 'post'));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formShipping->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $clientShippingAddress = Session::getActiveOrderDeliveryAddress();
     $formShipping->Populate(array('firstname' => $clientShippingAddress['firstname'], 'surname' => $clientShippingAddress['surname'], 'companyname' => $clientShippingAddress['companyname'], 'street' => $clientShippingAddress['street'], 'streetno' => $clientShippingAddress['streetno'], 'postcode' => $clientShippingAddress['postcode'], 'placename' => $clientShippingAddress['placename'], 'placeno' => $clientShippingAddress['placeno'], 'countryid' => $clientShippingAddress['countryid']));
     if ($formShipping->Validate()) {
         $formData = $formShipping->getSubmitValues();
         Session::setActiveOrderDeliveryAddress($formData);
         App::redirectUrl($this->registry->router->generate('frontend.finalization', true));
     }
     $this->registry->template->assign('formContact', $formContact->getForm());
     $this->registry->template->assign('formBilling', $formBilling->getForm());
     $this->registry->template->assign('formShipping', $formShipping->getForm());
     $this->registry->template->assign('clientOrder', Session::getActiveClientOrder());
     $this->registry->template->assign('summary', App::getModel('finalization')->getOrderSummary());
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Example #24
0
 public function checkEraty($idpaymentmethod)
 {
     $price = Session::getActiveglobalPriceWithDispatchmethod();
     if ($price > 0) {
         if ($price < 100) {
             return 0;
         }
     } else {
         $order = Session::getActiveClientOrder();
         if (!isset($order['priceWithDispatchMethod']) || $order['priceWithDispatchMethod'] < 100) {
             return 0;
         }
     }
     $sql = "SELECT ES.wariantsklepu, ES.numersklepu, ES.`char`\n\t\t\t\t\tFROM eratysettings ES\n\t\t\t\t\t\tLEFT JOIN paymentmethodview PV ON  ES.paymentmethodid  = PV.paymentmethodid\n\t\t\t\t\tWHERE PV.viewid = :viewid\n\t\t\t\t\tAND ES.paymentmethodid = :idpaymentmethod";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->bindValue('idpaymentmethod', $idpaymentmethod);
     $stmt->execute();
     $rs = $stmt->fetch();
     if ($rs) {
         $Data = array('wariantsklepu' => $rs['wariantsklepu'], 'numersklepu' => $rs['numersklepu'], 'char' => $rs['char']);
         return $Data;
     }
     return 0;
 }
Example #25
0
 public function initForm()
 {
     $set = App::getModel('attributegroup')->getSugestVariant((int) $this->registry->core->getParam());
     $availablity = $this->registry->core->getDefaultValueToSelect() + App::getModel('availablity')->getAvailablityToSelect();
     $form = new FormEngine\Elements\Form(array('name' => 'product', 'action' => '', 'method' => 'post'));
     $basicPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'basic_pane', 'label' => _('TXT_BASIC_INFORMATION'))));
     $basicLanguageData = $basicPane->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $seoname = $basicLanguageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'name', 'label' => _('TXT_PRODUCT_NAME'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PRODUCT_NAME')), new FormEngine\Rules\LanguageUnique(_('ERR_NAME_ALREADY_EXISTS'), 'producttranslation', 'name', null, array('column' => 'productid', 'values' => (int) $this->registry->core->getParam()))))));
     $basicLanguageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'seo', 'label' => _('TXT_PRODUCT_SEO'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PRODUCT_SEO')), new FormEngine\Rules\Format(_('ERR_ALPHANUMERIC_INVALID'), '/^[A-Za-z0-9-_\\",\'\\s]+$/'), new FormEngine\Rules\LanguageUnique('Wybierz inny adres URL, podany już istnieje', 'producttranslation', 'seo', null, array('column' => 'productid', 'values' => (int) $this->registry->core->getParam()))))));
     $basicPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'enable', 'label' => _('TXT_ENABLE_PRODUCT'), 'default' => '0')));
     $basicPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'ean', 'label' => _('TXT_EAN'))));
     $basicPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'delivelercode', 'label' => _('TXT_DELIVELERCODE'))));
     $producerid = $basicPane->AddChild(new FormEngine\Elements\Select(array('name' => 'producerid', 'label' => _('TXT_PRODUCER'), 'addable' => true, 'onAdd' => 'xajax_AddProducer', 'add_item_prompt' => 'Podaj nazwę producenta', 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('producer')->getProducerToSelect()))));
     $basicPane->AddChild(new FormEngine\Elements\Select(array('name' => 'delivererid', 'label' => _('TXT_DELIVERER'), 'addable' => true, 'onAdd' => 'xajax_AddDeliverer', 'add_item_prompt' => 'Podaj nazwę dostawcy', 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('deliverer')->getDelivererToSelect()))));
     $metaData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'meta_data', 'label' => _('TXT_META_INFORMATION'))));
     $metaData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">W przypadku braku informacji META system wygeneruje je automatycznie. W każdej chwili możesz je zmienić edytując dane poniżej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $languageData = $metaData->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $languageData->AddChild(new FormEngine\Elements\TextField(array('name' => 'keywordtitle', 'label' => _('TXT_KEYWORD_TITLE'))));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyworddescription', 'label' => _('TXT_KEYWORD_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000)));
     $languageData->AddChild(new FormEngine\Elements\Textarea(array('name' => 'keyword', 'label' => _('TXT_KEYWORDS'), 'comment' => _('TXT_KEYWORDS_HELP'))));
     $stockPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'stock_pane', 'label' => _('TXT_SHIPPING_STOCK_SETTINGS'))));
     if ((int) $set > 0) {
         $stockPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p><strong style="color: red;">UWAGA:</strong>Ten produkt posiada warianty produktu. Jego stan magazynowy zostanie określony automatycznie na podstawie sumy stanów magazynowych wszystkich wariantów. Przejdź do zakładki Warianty produktu aby edytować stany.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
         $stockPane->AddChild(new FormEngine\Elements\Constant(array('name' => 'stock', 'label' => _('TXT_STOCK'), 'suffix' => _('TXT_QTY'), 'default' => 0)));
         $stockPane->AddChild(new FormEngine\Elements\Hidden(array('name' => 'stock', 'label' => _('TXT_STOCK'), 'default' => 0)));
     } else {
         $stockPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'stock', 'label' => _('TXT_STOCK'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_STOCK')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'suffix' => _('TXT_QTY'), 'default' => 0)));
     }
     $stockPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Śledzenie stanu magazynowego spowoduje, że stan magazynowy będzie się zmieniał automatycznie w przypadku zamówień. Produkty z włączonym śledzeniem i ilością 0 nie będą mogły być zamówione przez klientów.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $stockPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'trackstock', 'label' => _('TXT_TRACKSTOCK'))));
     $disableatstockenabled = $stockPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'disableatstockenabled', 'label' => _('TXT_DISABLEATSTOCK_ENABLE'), 'default' => '0')));
     $stockPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'disableatstock', 'label' => _('TXT_DISABLEATSTOCK'), 'rules' => array(new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $disableatstockenabled, new FormEngine\Conditions\Equals('1'))), 'default' => '0')));
     $stockPane->AddChild(new FormEngine\Elements\Select(array('name' => 'availablityid', 'label' => _('TXT_AVAILABLITY'), 'options' => FormEngine\Option::Make($availablity))));
     $categoryPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'category_pane', 'label' => _('TXT_CATEGORY'))));
     $categoryPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz kategorie w jakich ma pojawić się produkt. Kategoriami możesz zarządzać na stronie <a href="' . $this->registry->router->generate('admin', true, array('controller' => 'category')) . '" target="_blank">Katalog &raquo; Kategorie</a>.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $category = $categoryPane->AddChild(new FormEngine\Elements\Tree(array('name' => 'category', 'label' => _('TXT_CATEGORY'), 'choosable' => false, 'selectable' => true, 'sortable' => false, 'clickable' => false, 'items' => App::getModel('view')->getChildCategories(), 'load_children' => array(App::getModel('view'), 'getChildCategories'))));
     $pricePane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'price_pane', 'label' => _('TXT_PRICE'))));
     $vat = $pricePane->AddChild(new FormEngine\Elements\Select(array('name' => 'vatid', 'label' => _('TXT_VAT'), 'options' => FormEngine\Option::Make(App::getModel('vat')->getVATAll()), 'addable' => true, 'onAdd' => 'xajax_AddVat', 'add_item_prompt' => 'Podaj wartość stawki VAT')));
     $currencies = App::getModel('currencieslist')->getCurrencyForSelect();
     $sellcurrency = $pricePane->AddChild(new FormEngine\Elements\Select(array('name' => 'sellcurrencyid', 'label' => _('TXT_SELL_CURRENCY'), 'options' => FormEngine\Option::Make($currencies), 'default' => Session::getActiveShopCurrencyId())));
     $buycurrency = $pricePane->AddChild(new FormEngine\Elements\Select(array('name' => 'buycurrencyid', 'label' => _('TXT_BUY_CURRENCY'), 'options' => FormEngine\Option::Make($currencies), 'default' => Session::getActiveShopCurrencyId())));
     $pricePane->AddChild(new FormEngine\Elements\Price(array('name' => 'buyprice', 'label' => _('TXT_BUYPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_BUYPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), 'vat_field' => $vat)));
     $standardPrice = $pricePane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'standard_price', 'label' => _('TXT_STANDARD_SELLPRICE'), 'class' => 'priceGroup')));
     $price = $standardPrice->AddChild(new FormEngine\Elements\Price(array('name' => 'sellprice', 'label' => _('TXT_SELLPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat)));
     $enablePromotion = $standardPrice->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'promotion', 'label' => _('TXT_ENABLE_PROMOTION'), 'default' => '0')));
     $standardPrice->AddChild(new FormEngine\Elements\Price(array('name' => 'discountprice', 'label' => _('TXT_DISCOUNTPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $enablePromotion, new FormEngine\Conditions\Equals(1))))));
     $standardPrice->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionstart', 'label' => _('TXT_START_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $enablePromotion, new FormEngine\Conditions\Equals(1))))));
     $standardPrice->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionend', 'label' => _('TXT_END_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $enablePromotion, new FormEngine\Conditions\Equals(1))))));
     $pricePane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center"><strong>Ceny dla grup klientów</strong><br />Jeżeli chcesz aby dana grupa klientów posiadała inne ceny, uzupełnij wybrane sekcje poniżej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $clientGroups = App::getModel('clientgroup/clientgroup')->getClientGroupAll();
     foreach ($clientGroups as $clientGroup) {
         $group = $pricePane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'field_' . $clientGroup['id'], 'label' => $clientGroup['name'], 'class' => 'priceGroup')));
         $groups[$clientGroup['id']] = $group->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'groupid_' . $clientGroup['id'], 'label' => _('TXT_ENABLE_GROUP_PRICE'), 'default' => '0')));
         $group->AddChild(new FormEngine\Elements\Price(array('name' => 'sellprice_' . $clientGroup['id'], 'label' => _('TXT_SELLPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $groups[$clientGroup['id']], new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals(1)))))));
         $promotion[$clientGroup['id']] = $group->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'promotion_' . $clientGroup['id'], 'label' => _('TXT_ENABLE_CLIENTGROUP_PROMOTION'), 'default' => '0')));
         $group->AddChild(new FormEngine\Elements\Price(array('name' => 'discountprice_' . $clientGroup['id'], 'label' => _('TXT_DISCOUNTPRICE'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_SELLPRICE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'vat_field' => $vat, 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $promotion[$clientGroup['id']], new FormEngine\Conditions\Equals(1))))));
         $group->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionstart_' . $clientGroup['id'], 'label' => _('TXT_START_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $promotion[$clientGroup['id']], new FormEngine\Conditions\Equals(1))))));
         $group->AddChild(new FormEngine\Elements\Date(array('name' => 'promotionend_' . $clientGroup['id'], 'label' => _('TXT_END_DATE'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::SHOW, $promotion[$clientGroup['id']], new FormEngine\Conditions\Equals(1))))));
     }
     $weightPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'weight_pane', 'label' => _('TXT_WEIGHT_DATA'))));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'weight', 'label' => _('TXT_WEIGHT'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_WEIGHT')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'suffix' => 'kg', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), 'default' => 0)));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'width', 'label' => _('TXT_WIDTH'), 'suffix' => 'cm', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()))));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'height', 'label' => _('TXT_HEIGHT'), 'suffix' => 'cm', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()))));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'deepth', 'label' => _('TXT_DEEPTH'), 'suffix' => 'cm', 'filters' => array(new FormEngine\Filters\CommaToDotChanger()))));
     $weightPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz miarę produktu w jakiej sprzedawany jest produkt. Jednostkami możesz zarządzać na stronie <a href="' . $this->registry->router->generate('admin', true, array('controller' => 'unitmeasure')) . '" target="_blank">Katalog &raquo; Jednostka miary</a>. Jeżeli chcesz tylko dodać nową opcję, użyj ikony dodawania obok listy wyboru.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $weightPane->AddChild(new FormEngine\Elements\Select(array('name' => 'unit', 'label' => _('TXT_UNIT_MEASURE'), 'options' => FormEngine\Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('unitmeasure')->getUnitMeasureToSelect()), 'addable' => true, 'onAdd' => 'xajax_AddUnitMeasure', 'add_item_prompt' => 'Podaj nazwę jednostki miary', 'default' => 0)));
     $weightPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wpisz ilość sztuk w opakowaniu. Podczas dodawania produktu do koszyka ilość zostanie zaokrąglona do pełnych opakowań</p>')));
     $weightPane->AddChild(new FormEngine\Elements\TextField(array('name' => 'packagesize', 'label' => _('TXT_PACKAGE_SIZE'), 'comment' => _('TXT_PACKAGE_SIZE_HELP'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_PACKAGE_SIZE')), new FormEngine\Rules\Format(_('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/')), 'filters' => array(new FormEngine\Filters\CommaToDotChanger()), 'default' => 1)));
     $descriptionPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'description_pane', 'label' => _('TXT_DESCRIPTION'))));
     $descriptionLanguageData = $descriptionPane->AddChild(new FormEngine\Elements\FieldsetLanguage(array('name' => 'language_data', 'label' => _('TXT_LANGUAGE_DATA'))));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'shortdescription', 'label' => _('TXT_SHORTDESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000, 'rows' => 20)));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'description', 'label' => _('TXT_DESCRIPTION'), 'comment' => _('TXT_MAX_LENGTH') . ' 5000', 'max_length' => 5000, 'rows' => 30)));
     $descriptionLanguageData->AddChild(new FormEngine\Elements\RichTextEditor(array('name' => 'longdescription', 'label' => _('TXT_ADDITIONAL_INFO'), 'rows' => 30)));
     $photosPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'photos_pane', 'label' => _('TXT_PHOTOS'))));
     $photosPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz zdjęcia dla produktu z biblioteki lub wgraj je z dysku komputera. Zdjęcie oznaczone jako główne będzie wyświetlane w listach produktów oraz w karcie produktu jako pierwsze.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $photosPane->AddChild(new FormEngine\Elements\Image(array('name' => 'photo', 'label' => _('TXT_PHOTOS'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add', 'main_id' => isset($this->populateData['photos_pane']['mainphotoid']) ? $this->populateData['photos_pane']['mainphotoid'] : '')));
     $filePane = $form->addChild(new FormEngine\Elements\Fieldset(array('name' => 'files_pane', 'label' => _('TXT_FILES'))));
     $filePane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz pliki z biblioteki, które chcesz przypisać do tego produktu.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $filePane->AddChild(new FormEngine\Elements\Downloader(array('name' => 'file', 'label' => _('TXT_FILES'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'virtualproduct/add')));
     $warrantyPane = $form->addChild(new FormEngine\Elements\Fieldset(array('name' => 'warranty_pane', 'label' => _('TXT_WARRANTY'))));
     $warrantyPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Wybierz pliki z biblioteki, które chcesz przypisać do tego produktu.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $warrantyPane->AddChild(new FormEngine\Elements\Downloader(array('name' => 'warranty', 'label' => _('TXT_WARRANTY'), 'repeat_min' => 0, 'repeat_max' => FormEngine\FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'virtualproduct/add')));
     $upsellProducts = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'upsell_products', 'label' => _('TXT_UPSELL'))));
     $upsellProducts->AddChild(new FormEngine\Elements\ProductSelectRelated(array('name' => 'upsell', 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'exclude' => array((int) $this->registry->core->getParam()))));
     $similarProducts = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'similar_products', 'label' => _('TXT_SIMILAR_PRODUCT_LIST'))));
     $similarProducts->AddChild(new FormEngine\Elements\ProductSelectRelated(array('name' => 'similar', 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'exclude' => array((int) $this->registry->core->getParam()))));
     $crosssellProducts = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'crosssell_products', 'label' => _('TXT_CROSSSELL'))));
     $crosssellProducts->AddChild(new FormEngine\Elements\ProductSelectRelated(array('name' => 'crosssell', 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'exclude' => array((int) $this->registry->core->getParam()))));
     $statusProductPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'statusproduct_pane', 'label' => _('TXT_PRODUCT_STATUS'))));
     $statusProductPane->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p align="center">Statusy produktów są używane do wyświetlania specjalnych oznaczeń na listach i kartach produktów.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
     $statusProductPane->AddChild(new FormEngine\Elements\MultiSelect(array('name' => 'productstatuses', 'label' => _('TXT_PRODUCT_STATUS'), 'addable' => true, 'onAdd' => 'xajax_AddProductStatus', 'add_item_prompt' => 'Podaj nazwę statusu', 'options' => FormEngine\Option::Make(App::getModel('productstatus')->getProductstatusAll(false)))));
     $idnew = $statusProductPane->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'newactive', 'label' => _('TXT_PRODUCT_IS_NEW'))));
     $newData = $statusProductPane->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'new_data', 'label' => _('TXT_NEW_DATA'), 'dependencies' => array(new FormEngine\Dependency(FormEngine\Dependency::HIDE, $idnew, new FormEngine\Conditions\Not(new FormEngine\Conditions\Equals('1')))))));
     $newData->AddChild(new FormEngine\Elements\Date(array('name' => 'startnew', 'label' => _('TXT_START_DATE'))));
     $newData->AddChild(new FormEngine\Elements\Date(array('name' => 'endnew', 'label' => _('TXT_END_DATE'))));
     $groups = App::getModel('attributegroup/attributegroup')->getGroupsForCategory(0);
     if (!empty($groups)) {
         $variantsPane = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'variants_pane', 'label' => _('TXT_PRODUCT_VARIANTS'))));
         $variantsPane->AddChild(new FormEngine\Elements\ProductVariantsEditor(array('name' => 'variants', 'label' => _('TXT_PRODUCT_VARIANTS'), 'category' => $category, 'price' => $price, 'set' => $set, 'vat_field' => $vat, 'availablity' => $availablity, 'photos' => App::getModel('product')->productSelectedPhotos((int) $this->registry->core->getParam()), 'allow_generate' => App::getModel('order')->checkProductWithAttributes((int) $this->registry->core->getParam()))));
     }
     $Data = Event::dispatch($this, 'admin.product.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Example #26
0
 public function setAjaxShippingCountryId($countryid)
 {
     $objResponse = new xajaxResponse();
     Session::setActiveDispatchmethodChecked(NULL);
     Session::setActiveShippingCountryId($countryid);
     $objResponse->script('window.location.reload(false);');
     return $objResponse;
 }
Example #27
0
    /**
     * Adding an opinion
     *
     * @param
     *        	integer idproduct
     * @param
     *        	string review
     * @return id from generator
     * @throws on error FrontendException object will be returned
     * @access public
     */
    public function addOpinionAboutProduct($productid, $params)
    {
        $sql = 'INSERT INTO productreview (productid, clientid, review, viewid, nick, enable)
				VALUES (:productid, :clientid, :review, :viewid, :nick, :enable)';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('productid', $productid);
        if (Session::getActiveClientid() > 0) {
            $stmt->bindValue('clientid', Session::getActiveClientid());
            $stmt->bindValue('enable', 1);
        } else {
            $stmt->bindValue('clientid', NULL);
            $stmt->bindValue('enable', 0);
        }
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->bindValue('nick', $params['nick']);
        $stmt->bindValue('review', trim(strip_tags($params['htmlopinion'])));
        try {
            $stmt->execute();
        } catch (Exception $e) {
            throw new FrontendException($e->getMessage());
        }
        $reviewid = Db::getInstance()->lastInsertId();
        foreach ($params as $rangetypeid => $value) {
            if (is_numeric($rangetypeid) && $value > 0) {
                $sql = 'INSERT INTO productrange SET
							productid = :productid,
							rangetypeid = :rangetypeid,
							productreviewid = :productreviewid,
							value = :value';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('productid', $productid);
                $stmt->bindValue('rangetypeid', $rangetypeid);
                $stmt->bindValue('productreviewid', $reviewid);
                $stmt->bindValue('value', $value);
                try {
                    $stmt->execute();
                } catch (Exception $e) {
                    throw new FrontendException($e->getMessage());
                }
            }
        }
        return $reviewid;
    }
Example #28
0
 public function index()
 {
     $clientData = App::getModel('client')->getClient();
     $this->registry->xajax->registerFunction(array('addOpinion', $this->productModel, 'addAJAXOpinionAboutProduct'));
     //$this->registry->xajax->registerFunction(array(
     //'addProductRangeOpinion',
     //$this->productModel,
     //'addAJAXProductRangeOpinion'
     //));
     if (isset($this->_boxAttributes['tabbed'])) {
         $tabbed = $this->_boxAttributes['tabbed'];
     } else {
         $tabbed = 1;
     }
     if (isset($this->product['idproduct'])) {
         $range = $this->productModel->getRangeType((int) $this->productid);
         $this->productModel->getPhotos($this->product);
         $this->productModel->getOtherPhotos($this->product);
         $selectAttributes = $this->productModel->getProductAttributeGroups($this->product);
         foreach ($selectAttributes as $key => $val) {
             natsort($val['attributes']);
             $selectAttributes[$key]['attributes'] = $val['attributes'];
         }
         $attset = $this->productModel->getProductVariant($this->product);
         $Data = array();
         foreach ($attset as $group => $data) {
             $keys = array_keys($data['variant']);
             natsort($keys);
             $Data[implode(',', $keys)] = array('setid' => $group, 'stock' => $data['stock'], 'sellprice' => $this->registry->core->processPrice($data['sellprice']), 'sellpricenetto' => $this->registry->core->processPrice($data['sellpricenetto']), 'sellpriceold' => $this->registry->core->processPrice($data['attributepricegrossbeforepromotion']), 'sellpricenettoold' => $this->registry->core->processPrice($data['attributepricenettobeforepromotion']), 'availablity' => $data['availablity'], 'photos' => $data['photos']);
         }
         $productreview = App::getModel('productreview')->getProductReviews((int) $this->productid);
         $delivery = App::getModel('delivery')->getDispatchmethodPriceForProduct($this->product['price'], $this->product['weight']);
         $deliverymin = PHP_INT_MAX;
         foreach ($delivery as $i) {
             $deliverymin = min($deliverymin, $i['dispatchmethodcost']);
         }
         $files = App::getModel('product')->getFilesByProductId((int) $this->productid);
         $warranty = App::getModel('product')->getWarrantyByProductId((int) $this->productid);
         $tabs = $this->registry->template->assign('tabbed', $tabbed);
         $eventData = Event::filter($this, 'frontend.productbox.assign', array(), NULL);
         foreach ($eventData as $Data) {
             foreach ($Data as $tab => $values) {
                 $this->registry->template->assign($tab, $values);
             }
         }
         $opinion = Session::getVolatileOpinionAdded();
         if ($opinion[0] == 1) {
             $this->registry->template->assign('opinionadded', _('TXT_CLIENT_OPINION_ADDED'));
         } elseif ($opinion[0] == 2) {
             $this->registry->template->assign('opinionadded', _('TXT_GUEST_OPINION_ADDED'));
         }
         if ($this->product['enable'] == 0 && (int) Session::getActiveUserid() > 0) {
             $this->registry->template->assign('draft', _('TXT_PRODUCT_DRAFT'));
         }
         $this->registry->template->assign('range', $range);
         $this->registry->template->assign('files', $files);
         $this->registry->template->assign('warranty', $warranty);
         $this->registry->template->assign('variants', json_encode($Data));
         $this->registry->template->assign('product', $this->product);
         $this->registry->template->assign('attributes', $selectAttributes);
         $this->registry->template->assign('attset', $attset);
         $this->registry->template->assign('humanProductReviewCount', App::getModel('productreview')->getHumanOpinionsCount(count($productreview)));
         $this->registry->template->assign('productreview', $productreview);
         $this->registry->template->assign('delivery', $delivery);
         $this->registry->template->assign('deliverymin', $deliverymin);
         $this->productModel->updateViewedCount((int) $this->productid);
     } else {
         App::redirectSeo(App::getURLAdress());
     }
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Example #29
0
    public function getMinimumOrderValue()
    {
        $sql = 'SELECT
					ROUND((V.minimumordervalue * CR.exchangerate) - :globalprice, 2) AS required
				FROM view V
				LEFT JOIN currencyrates CR ON CR.currencyfrom = V.currencyid AND CR.currencyto = :currencyto
				WHERE V.idview = :viewid';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('globalprice', $this->getGlobalPrice());
        $stmt->bindValue('currencyto', Session::getActiveCurrencyId());
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->execute();
        $rs = $stmt->fetch();
        if ($rs) {
            return $rs['required'];
        }
        return 0;
    }
Example #30
0
 public static function Run()
 {
     if (isset(self::$config['profiler']) && self::$config['profiler'] == $_SERVER['REMOTE_ADDR']) {
         Profiler::start();
     }
     App::init();
     self::$registry->router->setVariables();
     self::$registry->xajax = new Xajax();
     if (self::$registry->router->getMode() == 0) {
         $url = preg_replace_callback('~[^a-zA-Z0-9:/\\?,_-]+~', function ($s) {
             return urlencode($s[0]);
         }, self::$registry->router->getUri());
         self::$registry->xajax->configure('requestURI', $url);
     } else {
         // force language in admin mode
         Session::unsetActiveLanguage();
         self::$registry->core->setLanguage('pl');
         Translation::loadTranslations();
     }
     self::$registry->xajaxInterface = new XajaxInterface();
     self::$registry->right = new Right(self::$registry);
     Session::clearTemp();
     DEFINE('URL', App::getHost(1) . '/' . LOCAL_CATALOG);
     App::checkSSL();
     if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
         DEFINE('DESIGNPATH', str_replace('http://', 'https://', App::getURLForDesignDirectory()));
     } else {
         DEFINE('DESIGNPATH', App::getURLForDesignDirectory());
     }
     // remember login and password
     if (self::$registry->router->getModeFromRoute() == 'admin') {
         if ((int) Session::getActiveUserid() === 0) {
             App::getModel('login')->getAdminAutologinKey();
         }
     } else {
         if ((int) Session::getActiveClientid() === 0) {
             App::getModel('clientlogin')->getAutologinKey();
         }
     }
     self::$registry->template = new Template(self::$registry, self::$registry->router->getMode());
     self::$registry->template->setStaticTemplateVariables();
     $content = self::$registry->router->controllerLoader();
     if (isset(self::$config['profiler']) && self::$config['profiler'] == $_SERVER['REMOTE_ADDR']) {
         Profiler::stop();
         $content .= Profiler::getInfo();
     }
     $response = new Response($content);
     $response->send();
     App::getModel('csrfprotection')->reindex();
 }