예제 #1
0
 public function renderForm()
 {
     global $cookie;
     if (!intval(Tools::getValue('id_product')) and $this->is_seller and AgileSellerManager::limited_by_membership($cookie->id_employee)) {
         $this->errors[] = Tools::displayError('You have not purchased membership yet or you have registered products more than limit allowed by your membership.');
         return;
     }
     return parent::renderForm() . $this->load_module_hooks();
 }
 public function renderForm()
 {
     $this->product_name = $this->object->name[$this->context->language->id];
     if (!method_exists($this, 'initForm' . $this->tab_display)) {
         return;
     }
     $product = $this->object;
     $this->context->smarty->assign('bullet_common_field', '');
     if (Shop::isFeatureActive() && $this->display == 'edit') {
         if (Shop::getContext() != Shop::CONTEXT_SHOP) {
             $this->context->smarty->assign(array('display_multishop_checkboxes' => true, 'multishop_check' => Tools::getValue('multishop_check')));
         }
         if (Shop::getContext() != Shop::CONTEXT_ALL) {
             $this->context->smarty->assign('bullet_common_field', '<i class="icon-circle text-orange"></i>');
             $this->context->smarty->assign('display_common_field', true);
         }
     }
     $this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs;
     $this->tpl_form_vars['product_type'] = (int) Tools::getValue('type_product', $product->getType());
     $this->getLanguages();
     $this->tpl_form_vars['id_lang_default'] = Configuration::get('PS_LANG_DEFAULT');
     $this->tpl_form_vars['currentIndex'] = self::$currentIndex;
     $this->tpl_form_vars['display_multishop_checkboxes'] = Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->display == 'edit';
     $this->fields_form = array('');
     $this->tpl_form_vars['token'] = $this->token;
     $this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs();
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     $this->tpl_form_vars['post_data'] = json_encode($_POST);
     $this->tpl_form_vars['save_error'] = !empty($this->errors);
     $this->tpl_form_vars['mod_evasive'] = Tools::apacheModExists('evasive');
     $this->tpl_form_vars['mod_security'] = Tools::apacheModExists('security');
     $this->tpl_form_vars['ps_force_friendly_product'] = Configuration::get('PS_FORCE_FRIENDLY_PRODUCT');
     $this->tpl_form_vars['tinymce'] = true;
     $iso = $this->context->language->iso_code;
     $this->tpl_form_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     $this->tpl_form_vars['path_css'] = _THEME_CSS_DIR_;
     $this->tpl_form_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_);
     if (Validate::isLoadedObject($this->object)) {
         $id_product = (int) $this->object->id;
     } else {
         $id_product = (int) Tools::getvalue('id_product');
     }
     $this->tpl_form_vars['form_action'] = $this->context->link->getAdminLink('AdminProducts') . '&' . ($id_product ? 'id_product=' . (int) $id_product : 'addproduct');
     $this->tpl_form_vars['id_product'] = $id_product;
     $upload_max_filesize = Tools::getOctets(ini_get('upload_max_filesize'));
     $upload_max_filesize = $upload_max_filesize / 1024 / 1024;
     $this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize;
     $this->tpl_form_vars['country_display_tax_label'] = $this->context->country->display_tax_label;
     $this->tpl_form_vars['has_combinations'] = $this->object->hasAttributes();
     $this->product_exists_in_shop = true;
     if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id)) {
         $this->product_exists_in_shop = false;
         if ($this->tab_display == 'Informations') {
             $this->displayWarning($this->l('Warning: The product does not exist in this shop'));
         }
         $default_product = new Product();
         $definition = ObjectModel::getDefinition($product);
         foreach ($definition['fields'] as $field_name => $field) {
             if (isset($field['shop']) && $field['shop']) {
                 $product->{$field_name} = ObjectModel::formatValue($default_product->{$field_name}, $field['type']);
             }
         }
     }
     if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) {
         $this->errors[] = 'Unable to load object';
     } else {
         $this->_displayDraftWarning($this->object->active);
         if (!empty($this->errors)) {
             $this->copyFromPost($this->object, $this->table);
         }
         $this->initPack($this->object);
         $this->{'initForm' . $this->tab_display}($this->object);
         $this->tpl_form_vars['product'] = $this->object;
         if ($this->ajax) {
             if (!isset($this->tpl_form_vars['custom_form'])) {
                 throw new PrestaShopException('custom_form empty for action ' . $this->tab_display);
             } else {
                 return $this->tpl_form_vars['custom_form'];
             }
         }
     }
     $parent = parent::renderForm();
     $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
     return $parent;
 }