Example #1
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     if (isset($this->_attributes['vat_field']) && is_subclass_of($this->_attributes['vat_field'], 'FormEngine\\Elements\\Field')) {
         $this->_attributes['vat_field_name'] = $this->_attributes['vat_field']->GetName();
     }
     $this->_attributes['prefixes'] = array(Translation::get('TXT_PRICE_NET'), Translation::get('TXT_PRICE_GROSS'));
 }
Example #2
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     if (isset($this->_attributes['allow_vat']) && !$this->_attributes['allow_vat']) {
         $this->_attributes['vat_values'] = array();
     } else {
         $this->_attributes['vat_values'] = App::getModel('vat/vat')->getVATAllForRangeEditor();
     }
     if (!isset($this->_attributes['range_precision'])) {
         $this->_attributes['range_precision'] = 2;
     }
     $this->_attributes['prefixes'] = array(Translation::get('TXT_PRICE_NET'), Translation::get('TXT_PRICE_GROSS'));
 }
Example #3
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     if (!isset($this->_attributes['products_source_field']) || !$this->_attributes['products_source_field'] instanceof ProductSelect) {
         throw new Exception("Source field (attribute: products_source_field) not set for field '{$this->_attributes['name']}'.");
     }
     $this->_attributes['products_source_field_name'] = $this->_attributes['products_source_field']->GetName();
     $this->_attributes['vat_values'] = App::getModel('vat/vat')->getVATAll();
     $this->_attributes['prefixes'] = array(Translation::get('TXT_PRICE_NET'), Translation::get('TXT_PRICE_GROSS'));
     $this->_jsFunction = 'LoadProductDataForAggregation_' . $this->_id;
     $this->_attributes['jsfunction'] = 'xajax_' . $this->_jsFunction;
     App::getRegistry()->xajaxInterface->registerFunction(array($this->_jsFunction, $this, 'loadProductData'));
 }
Example #4
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     $this->_jsGetChildren = 'GetChildren_' . $this->_id;
     if (isset($this->_attributes['load_children']) && is_callable($this->_attributes['load_children'])) {
         $this->_attributes['get_children'] = 'xajax_' . $this->_jsGetChildren;
         App::getRegistry()->xajaxInterface->registerFunction(array($this->_jsGetChildren, $this, 'getChildren'));
     }
     if (!isset($this->_attributes['addLabel'])) {
         $this->_attributes['addLabel'] = \Gekosale\Translation::get('TXT_ADD');
     }
     if (!isset($this->_attributes['retractable'])) {
         $this->_attributes['retractable'] = true;
     }
     $this->_attributes['total'] = count($this->_attributes['items']);
 }
Example #5
0
 public function initForm()
 {
     $form = new FormEngine\Elements\Form(array('name' => 'attributeproduct', 'action' => '', 'method' => 'post'));
     $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'required_data', 'label' => Translation::get('TXT_MAIN_DATA'))));
     $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'attributeproductname', 'label' => Translation::get('TXT_ATTRIBUTE_PRODUCT_GROUP_NAME'), 'rules' => array(new FormEngine\Rules\Required(Translation::get('ERR_EMPTY_ATTRIBUTE_PRODUCT_GROUP')), new FormEngine\Rules\Unique(Translation::get('ERR_ATTRIBUTE_PRODUCT_GROUP_ALREADY_EXISTS'), 'attributeproduct', 'name', null, array('column' => 'idattributeproduct', 'values' => $this->registry->core->getParam()))))));
     $attributesData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'attributes_data', 'label' => Translation::get('TXT_ATTRIBUTES_DATA'))));
     $attributesData->AddChild(new FormEngine\Elements\TextField(array('name' => 'attributeproductvalues', 'label' => Translation::get('TXT_ATTRIBUTE_PRODUCT'), 'repeat_min' => 1, 'repeat_max' => FormEngine\FE::INFINITE, 'rules' => array(new FormEngine\Rules\Required(Translation::get('ERR_EMPTY_ATTRIBUTE_PRODUCT'))))));
     $Data = Event::dispatch($this, 'admin.attributeproduct.initForm', array('form' => $form, 'id' => (int) $this->registry->core->getParam(), 'data' => $this->populateData));
     if (!empty($Data)) {
         $form->Populate($Data);
     }
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\NoCode());
     $form->AddFilter(new FormEngine\Filters\Secure());
     return $form;
 }
Example #6
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     $this->_attributes['session_name'] = session_name();
     $this->_attributes['session_id'] = session_id();
     $this->_attributes['file_types'] = array('jpg', 'png', 'gif', 'swf');
     if (!isset($this->_attributes['file_source'])) {
         $this->_attributes['file_source'] = 'upload/';
     }
     $this->_attributes['file_types_description'] = \Gekosale\Translation::get('TXT_FILE_TYPES_IMAGE');
     $this->_attributes['upload_url'] = App::getURLAdressWithAdminPane() . 'files/add/' . base64_encode($this->_attributes['file_source']);
     $this->_attributes['load_handler'] = 'xajax_LoadFiles_' . $this->_id;
     App::getRegistry()->xajaxInterface->registerFunction(array('LoadFiles_' . $this->_id, $this, 'LoadFiles'));
     $this->_attributes['delete_handler'] = 'xajax_DeleteFile_' . $this->_id;
     App::getRegistry()->xajaxInterface->registerFunction(array('DeleteFile_' . $this->_id, $this, 'DeleteFile'));
     $this->_attributes['type_icons'] = array('cdup' => DESIGNPATH . '_images_panel/icons/filetypes/cdup.png', 'unknown' => DESIGNPATH . '_images_panel/icons/filetypes/unknown.png', 'directory' => DESIGNPATH . '_images_panel/icons/filetypes/directory.png', 'gif' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'png' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'jpg' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'bmp' => DESIGNPATH . '_images_panel/icons/filetypes/image.png', 'txt' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'doc' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'rtf' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'odt' => DESIGNPATH . '_images_panel/icons/filetypes/text.png', 'htm' => DESIGNPATH . '_images_panel/icons/filetypes/document.png', 'html' => DESIGNPATH . '_images_panel/icons/filetypes/document.png', 'php' => DESIGNPATH . '_images_panel/icons/filetypes/document.png');
 }
Example #7
0
 public function processVariants($productId)
 {
     if (!isset($this->_attributes['clientgroupid'])) {
         $this->_attributes['clientgroupid'] = 0;
     }
     if (!isset($this->_attributes['currencyid'])) {
         $this->_attributes['currencyid'] = 0;
     }
     $rawVariants = App::getModel('product/product')->getAttributeCombinationsForProduct($productId, $this->_attributes['clientgroupid'], $this->_attributes['currencyid']);
     $variants = array();
     $variants[] = array('id' => '', 'caption' => Translation::get('TXT_CHOOSE_VARIANT'), 'price' => '');
     foreach ($rawVariants as $variant) {
         $caption = array();
         foreach ($variant['attributes'] as $attribute) {
             $caption[] = str_replace('"', '\'', $attribute['name']);
         }
         $variants[] = array('id' => $variant['id'], 'caption' => implode(', ', $caption), 'options' => array('price' => $variant['price'], 'stock' => $variant['qty'], 'weight' => $variant['weight'], 'ean' => $variant['symbol'], 'thumb' => App::getModel('product')->getThumbPathForId($variant['photoid'])));
     }
     return json_encode($variants);
 }
Example #8
0
 public function add()
 {
     $this->registry->xajaxInterface->registerFunction(array('AddClientGroup', App::getModel('clientgroup'), 'addEmptyClientGroup'));
     $form = $this->formModel->initForm();
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         $generatedPassword = Core::passwordGenerate();
         $clientId = $this->model->addNewClient($form->getSubmitValues(), $generatedPassword);
         $Data = $form->getSubmitValues();
         $Data['personal_data']['password'] = $generatedPassword;
         $this->registry->template->assign('personal_data', $Data['personal_data']);
         $this->registry->template->assign('address', $Data['billing_data']);
         App::getModel('mailer')->sendEmail(array('template' => 'addClientFromAdmin', 'email' => array($Data['personal_data']['email']), 'bcc' => false, 'subject' => Translation::get('TXT_REGISTRATION_NEW'), 'viewid' => $Data['personal_data']['viewid']));
         if (FormEngine\FE::IsAction('next')) {
             App::redirect(__ADMINPANE__ . '/client/add');
         } else {
             App::redirect(__ADMINPANE__ . '/client');
         }
     }
     $this->renderLayout(array('form' => $form->Render()));
 }
Example #9
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     $this->_attributes['file_types'] = array('octet-stream', 'jpg', 'jpeg', 'png', 'gif', 'psd', 'doc', 'csv', 'xls', 'tgz', 'rar', 'zip', 'pdf', 'avi', 'mov', 'mpg', 'mpeg');
     $this->_attributes['file_types_description'] = Translation::get('TXT_FILE_TYPES_IMAGE');
 }
Example #10
0
 public function Validate($values = array())
 {
     // CSRF
     if ($this->_attributes['csrf'] == true) {
         $this->form->AddChild(new TextFieldCSRF(array('name' => '__csrf', 'default' => App::getModel('csrfprotection')->getCode(), 'rules' => array(new Rules\Required(Translation::get('ERR_CSRF')), new Rules\Custom(Translation::get('ERR_CSRF'), array(App::getModel('csrfprotection'), 'isValid'))))));
     }
     if (!isset($values[$this->_attributes['name'] . '_submitted']) or !$values[$this->_attributes['name'] . '_submitted']) {
         return false;
     }
     $this->Populate($values);
     return parent::Validate();
 }
Example #11
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();
 }
Example #12
0
 public function processVariants($productId)
 {
     $rawVariants = App::getModel('product/product')->getAttributeCombinationsForProduct($productId);
     $variants = array();
     $variants[] = array('id' => '', 'caption' => Translation::get('TXT_ANY_VARIANT'));
     foreach ($rawVariants as $variant) {
         $caption = array();
         foreach ($variant['attributes'] as $attribute) {
             $caption[] = $attribute['name'];
         }
         $variants[] = array('id' => $variant['id'], 'caption' => implode(', ', $caption));
     }
     return json_encode($variants);
 }
Example #13
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     $this->_attributes['file_types'] = array('jpg', 'jpeg', 'png', 'gif', 'swf');
     $this->_attributes['file_types_description'] = Translation::get('TXT_FILE_TYPES_IMAGE');
 }