model = App::getModel('product'); } public function index () { $this->registry->xajaxInterface->registerFunction(array( 'LoadCategoryChildren', $this->model, 'loadCategoryChildren' )); $this->registry->xajax->registerFunction(array( 'doDeleteProduct', $this->model, 'doAJAXDeleteProduct' )); $this->registry->xajax->registerFunction(array( 'doChangeProductStatus', $this->model, 'doAJAXChangeProductStatus' )); $this->registry->xajax->registerFunction(array( 'setProductEnable', $this->model, 'setProductEnable' )); $this->registry->xajax->registerFunction(array( 'LoadAllProduct', $this->model, 'getProductForAjax' )); $this->registry->xajax->registerFunction(array( 'GetNameSuggestions', $this->model, 'getNamesForAjax' )); $this->registry->xajax->registerFunction(array( 'doUpdateProduct', $this->model, 'doAJAXUpdateProduct' )); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->xajax->processRequest(); $this->registry->template->assign('datagrid_filter', $this->model->getDatagridFilterData()); $this->registry->template->assign('productStatuses', json_encode(App::getModel('productstatus')->getProductstatusAll())); $this->registry->template->display($this->loadTemplate('index.tpl')); } public function add () { $form = new FE_Form(Array( 'name' => 'add_product', 'action' => '', 'method' => 'post' )); $basicPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'basic_pane', 'label' => $this->registry->core->getMessage('TXT_BASIC_INFORMATION') ))); $basicLanguageData = $basicPane->AddChild(new FE_FieldsetLanguage(Array( 'name' => 'language_data', 'label' => $this->registry->core->getMessage('TXT_LANGUAGE_DATA') ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'name', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_NAME'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_PRODUCT_NAME')), new FE_RuleLanguageUnique($this->registry->core->getMessage('ERR_NAME_ALREADY_EXISTS'), 'producttranslation', 'name') ) ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'seo', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_SEO'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_PRODUCT_SEO')), new FE_RuleFormat($this->registry->core->getMessage('ERR_ALPHANUMERIC_INVALID'), '/^[A-Za-z0-9-_\",\'\s]+$/') ) ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'keywordtitle', 'label' => $this->registry->core->getMessage('TXT_KEYWORD_TITLE') ))); $basicLanguageData->AddChild(new FE_Textarea(Array( 'name' => 'keyword', 'label' => $this->registry->core->getMessage('TXT_KEYWORDS'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000 ))); $basicLanguageData->AddChild(new FE_Textarea(Array( 'name' => 'keyworddescription', 'label' => $this->registry->core->getMessage('TXT_KEYWORD_DESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000 ))); $basicPane->AddChild(new FE_Checkbox(Array( 'name' => 'enable', 'label' => $this->registry->core->getMessage('TXT_ENABLE_PRODUCT'), 'default' => '1' ))); $basicPane->AddChild(new FE_TextField(Array( 'name' => 'ean', 'label' => $this->registry->core->getMessage('TXT_EAN') ))); $basicPane->AddChild(new FE_TextField(Array( 'name' => 'delivelercode', 'label' => $this->registry->core->getMessage('TXT_DELIVELERCODE') ))); $basicPane->AddChild(new FE_Select(Array( 'name' => 'producerid', 'label' => $this->registry->core->getMessage('TXT_PRODUCER'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('producer')->getProducerToSelect()) ))); $basicPane->AddChild(new FE_Select(Array( 'name' => 'delivererid', 'label' => $this->registry->core->getMessage('TXT_DELIVERER'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('deliverer')->getDelivererToSelect()) ))); $stockPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'stock_pane', 'label' => $this->registry->core->getMessage('TXT_STOCK') ))); $stockPane->AddChild(new FE_TextField(Array( 'name' => 'stock', 'label' => $this->registry->core->getMessage('TXT_STOCK'), 'comment' => $this->registry->core->getMessage('TXT_STANDARD_STOCK'), 'rules' => Array( new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'suffix' => $this->registry->core->getMessage('TXT_QTY'), 'default' => '0' ))); $stockPane->AddChild(new FE_Checkbox(Array( 'name' => 'trackstock', 'label' => $this->registry->core->getMessage('TXT_TRACKSTOCK') ))); $categoryPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'category_pane', 'label' => $this->registry->core->getMessage('TXT_CATEGORY') ))); $categoryPane->AddChild(new FE_StaticText(Array( 'text' => '

' . $this->registry->core->getMessage('TXT_EMPTY_CATEGORY_INSTRUCTION') . '

' ))); $category = $categoryPane->AddChild(new FE_Tree(Array( 'name' => 'category', 'label' => $this->registry->core->getMessage('TXT_CATEGORY'), 'choosable' => false, 'selectable' => true, 'sortable' => false, 'clickable' => false, 'items' => App::getModel('category')->getChildCategories(), 'load_children' => Array( App::getModel('category'), 'getChildCategories' ) ))); $pricePane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'price_pane', 'label' => $this->registry->core->getMessage('TXT_PRICE') ))); $vat = $pricePane->AddChild(new FE_Select(Array( 'name' => 'vatid', 'label' => $this->registry->core->getMessage('TXT_VAT'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('VAT')->getVATAll()), 'suffix' => '%', 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_VAT')) ) ))); $currencies = App::getModel('currencieslist')->getCurrencyForSelect(); $sellcurrency = $pricePane->AddChild(new FE_Select(Array( 'name' => 'sellcurrencyid', 'label' => $this->registry->core->getMessage('TXT_SELL_CURRENCY'), 'options' => FE_Option::Make($currencies), 'default' => $this->registry->session->getActiveShopCurrencyId() ))); $buycurrency = $pricePane->AddChild(new FE_Select(Array( 'name' => 'buycurrencyid', 'label' => $this->registry->core->getMessage('TXT_BUY_CURRENCY'), 'options' => FE_Option::Make($currencies), 'default' => $this->registry->session->getActiveShopCurrencyId() ))); $pricePane->AddChild(new FE_Price(Array( 'name' => 'buyprice', 'label' => $this->registry->core->getMessage('TXT_BUYPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_BUYPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'filters' => Array( new FE_FilterCommaToDotChanger() ), 'vat_field' => $vat ))); $standardPrice = $pricePane->AddChild(new FE_Fieldset(Array( 'name' => 'standard_price', 'label' => $this->registry->core->getMessage('TXT_STANDARD_SELLPRICE') ))); $price = $standardPrice->AddChild(new FE_Price(Array( 'name' => 'sellprice', 'label' => $this->registry->core->getMessage('TXT_SELLPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat ))); $enablePromotion = $standardPrice->AddChild(new FE_Checkbox(Array( 'name' => 'promotion', 'label' => $this->registry->core->getMessage('TXT_ENABLE_PROMOTION'), 'default' => '0' ))); $standardPrice->AddChild(new FE_Price(Array( 'name' => 'discountprice', 'label' => $this->registry->core->getMessage('TXT_DISCOUNTPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat, 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $enablePromotion, new FE_ConditionEquals(1)) ) ))); $standardPrice->AddChild(new FE_Date(Array( 'name' => 'promotionstart', 'label' => $this->registry->core->getMessage('TXT_START_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $enablePromotion, new FE_ConditionEquals(1)) ) ))); $standardPrice->AddChild(new FE_Date(Array( 'name' => 'promotionend', 'label' => $this->registry->core->getMessage('TXT_END_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $enablePromotion, new FE_ConditionEquals(1)) ) ))); $clientGroups = App::getModel('clientgroup/clientgroup')->getClientGroupAll(); foreach ($clientGroups as $clientGroup){ $pricePane->AddChild(new FE_Fieldset(Array( 'name' => 'field_' . $clientGroup['id'], 'label' => $clientGroup['name'] ))); $groups[$clientGroup['id']] = $pricePane->AddChild(new FE_Checkbox(Array( 'name' => 'groupid_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_ENABLE_GROUP_PRICE'), 'default' => '0' ))); $pricePane->AddChild(new FE_Price(Array( 'name' => 'sellprice_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_SELLPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat, 'dependencies' => Array( new FE_Dependency(FE_Dependency::HIDE, $groups[$clientGroup['id']], new FE_ConditionNot(new FE_ConditionEquals(1))) ) ))); $promotion[$clientGroup['id']] = $pricePane->AddChild(new FE_Checkbox(Array( 'name' => 'promotion_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_ENABLE_CLIENTGROUP_PROMOTION'), 'default' => '0' ))); $pricePane->AddChild(new FE_Price(Array( 'name' => 'discountprice_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_DISCOUNTPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat, 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $promotion[$clientGroup['id']], new FE_ConditionEquals(1)) ) ))); $pricePane->AddChild(new FE_Date(Array( 'name' => 'promotionstart_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_START_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $promotion[$clientGroup['id']], new FE_ConditionEquals(1)) ) ))); $pricePane->AddChild(new FE_Date(Array( 'name' => 'promotionend_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_END_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $promotion[$clientGroup['id']], new FE_ConditionEquals(1)) ) ))); } $weightPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'weight_pane', 'label' => $this->registry->core->getMessage('TXT_WEIGHT_DATA') ))); $weightPane->AddChild(new FE_TextField(Array( 'name' => 'weight', 'label' => $this->registry->core->getMessage('TXT_WEIGHT'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_WEIGHT')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'suffix' => 'kg', 'filters' => Array( new FE_FilterCommaToDotChanger() ), 'default' => 1 ))); $descriptionPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'description_pane', 'label' => $this->registry->core->getMessage('TXT_DESCRIPTION') ))); $descriptionLanguageData = $descriptionPane->AddChild(new FE_FieldsetLanguage(Array( 'name' => 'language_data', 'label' => $this->registry->core->getMessage('TXT_LANGUAGE_DATA') ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'shortdescription', 'label' => $this->registry->core->getMessage('TXT_SHORTDESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000, 'rows' => 20 ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'description', 'label' => $this->registry->core->getMessage('TXT_DESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 5000', 'max_length' => 5000, 'rows' => 30 ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'longdescription', 'label' => $this->registry->core->getMessage('TXT_ADDITIONAL_INFO'), 'rows' => 30 ))); $technicalDataPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'technical_data_pane', 'label' => $this->registry->core->getMessage('TXT_TECHNICAL_DATA') ))); $technicalDataPane->AddChild(new FE_TechnicalDataEditor(Array( 'name' => 'technical_data', 'label' => $this->registry->core->getMessage('TXT_TECHNICAL_DATA'), 'product_id' => '', 'set_id' => '' ))); $photosPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'photos_pane', 'label' => $this->registry->core->getMessage('TXT_PHOTOS') ))); $photosPane->AddChild(new FE_Image(Array( 'name' => 'photo', 'label' => $this->registry->core->getMessage('TXT_PHOTOS'), 'repeat_min' => 0, 'repeat_max' => FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add' ))); $filePane = $form->addChild(new FE_Fieldset(Array( 'name' => 'files_pane', 'label' => $this->registry->core->getMessage('TXT_FILES') ))); $filePane->AddChild(new FE_Downloader(Array( 'name' => 'file', 'label' => $this->registry->core->getMessage('TXT_FILES'), 'repeat_min' => 0, 'repeat_max' => FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'virtualproduct/add' ))); $statusProductPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'statusproduct_pane', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_STATUS') ))); $idnew = $statusProductPane->AddChild(new FE_Checkbox(Array( 'name' => 'newactive', 'label' => $this->registry->core->getMessage('TXT_NEW') ))); $newData = $statusProductPane->AddChild(new FE_Fieldset(Array( 'name' => 'new_data', 'label' => $this->registry->core->getMessage('TXT_NEW_DATA'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::HIDE, $idnew, new FE_ConditionNot(new FE_ConditionEquals('1'))) ) ))); $newData->AddChild(new FE_Date(Array( 'name' => 'endnew', 'label' => $this->registry->core->getMessage('TXT_END_DATE') ))); $groups = App::getModel('attributegroup/attributegroup')->getGroupsForCategory(0); if (! empty($groups)){ $variantsPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'variants_pane', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_VARIANTS') ))); $variantsPane->AddChild(new FE_ProductVariantsEditor(Array( 'name' => 'variants', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_VARIANTS'), 'category' => $category, 'price' => $price, 'vat_field' => $vat ))); } $form->AddFilter(new FE_FilterTrim()); if ($form->Validate(FE::SubmittedData())){ $this->model->addNewProduct($form->getSubmitValues(FE_Form::FORMAT_FLAT)); if (FE::IsAction('next')){ App::redirect(__ADMINPANE__ . '/product/add'); } else{ App::redirect(__ADMINPANE__ . '/product'); } } $this->registry->template->assign('form', $form); $this->registry->xajax->processRequest(); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->display($this->loadTemplate('add.tpl')); } public function edit () { $PopulateData = $this->model->getProductAndAttributesById((int) $this->registry->core->getParam()); $form = new FE_Form(Array( 'name' => 'edit_product', 'action' => '', 'method' => 'post' )); $basicPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'basic_pane', 'label' => $this->registry->core->getMessage('TXT_BASIC_INFORMATION') ))); $basicLanguageData = $basicPane->AddChild(new FE_FieldsetLanguage(Array( 'name' => 'language_data', 'label' => $this->registry->core->getMessage('TXT_LANGUAGE_DATA') ))); $seoname = $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'name', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_NAME'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_PRODUCT_NAME')), new FE_RuleLanguageUnique($this->registry->core->getMessage('ERR_NAME_ALREADY_EXISTS'), 'producttranslation', 'name', null, Array( 'column' => 'productid', 'values' => (int) $this->registry->core->getParam() )) ) ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'keywordtitle', 'label' => $this->registry->core->getMessage('TXT_KEYWORD_TITLE') ))); $basicLanguageData->AddChild(new FE_Textarea(Array( 'name' => 'keyword', 'label' => $this->registry->core->getMessage('TXT_KEYWORDS'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000 ))); $basicLanguageData->AddChild(new FE_Textarea(Array( 'name' => 'keyworddescription', 'label' => $this->registry->core->getMessage('TXT_KEYWORD_DESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000 ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'seo', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_SEO'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_PRODUCT_SEO')), new FE_RuleFormat($this->registry->core->getMessage('ERR_ALPHANUMERIC_INVALID'), '/^[A-Za-z0-9-_\",\'\s]+$/') ) ))); $basicLanguageData->AddChild(new FE_Checkbox(Array( 'name' => 'refreshseo', 'label' => $this->registry->core->getMessage('TXT_REFRESH_SEO_META'), 'default' => '0' ))); $basicPane->AddChild(new FE_Checkbox(Array( 'name' => 'enable', 'label' => $this->registry->core->getMessage('TXT_ENABLE_PRODUCT'), 'default' => '0' ))); $basicPane->AddChild(new FE_TextField(Array( 'name' => 'ean', 'label' => $this->registry->core->getMessage('TXT_EAN') ))); $basicPane->AddChild(new FE_TextField(Array( 'name' => 'delivelercode', 'label' => $this->registry->core->getMessage('TXT_DELIVELERCODE') ))); $basicPane->AddChild(new FE_Select(Array( 'name' => 'producerid', 'label' => $this->registry->core->getMessage('TXT_PRODUCER'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('producer')->getProducerToSelect()) ))); $basicPane->AddChild(new FE_Select(Array( 'name' => 'delivererid', 'label' => $this->registry->core->getMessage('TXT_DELIVERER'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('deliverer')->getDelivererToSelect()) ))); $stockPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'stock_pane', 'label' => $this->registry->core->getMessage('TXT_STOCK') ))); $stockPane->AddChild(new FE_TextField(Array( 'name' => 'stock', 'label' => $this->registry->core->getMessage('TXT_STOCK'), 'comment' => $this->registry->core->getMessage('TXT_STANDARD_STOCK'), 'rules' => Array( new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'suffix' => $this->registry->core->getMessage('TXT_QTY') ))); $stockPane->AddChild(new FE_Checkbox(Array( 'name' => 'trackstock', 'label' => $this->registry->core->getMessage('TXT_TRACKSTOCK') ))); $categoryPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'category_pane', 'label' => $this->registry->core->getMessage('TXT_CATEGORY') ))); $categoryPane->AddChild(new FE_StaticText(Array( 'text' => '

' . $this->registry->core->getMessage('TXT_EMPTY_CATEGORY_INSTRUCTION') . '

' ))); $category = $categoryPane->AddChild(new FE_Tree(Array( 'name' => 'category', 'label' => $this->registry->core->getMessage('TXT_CATEGORY'), 'choosable' => false, 'selectable' => true, 'sortable' => false, 'clickable' => false, 'items' => App::getModel('category')->getChildCategories(), 'load_children' => Array( App::getModel('category'), 'getChildCategories' ) ))); $pricePane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'price_pane', 'label' => $this->registry->core->getMessage('TXT_PRICE') ))); $vat = $pricePane->AddChild(new FE_Select(Array( 'name' => 'vatid', 'label' => $this->registry->core->getMessage('TXT_VAT'), 'options' => FE_Option::Make(App::getModel('vat')->getVATAll()), 'suffix' => '%' ))); $currencies = App::getModel('currencieslist')->getCurrencyForSelect(); $sellcurrency = $pricePane->AddChild(new FE_Select(Array( 'name' => 'sellcurrencyid', 'label' => $this->registry->core->getMessage('TXT_SELL_CURRENCY'), 'options' => FE_Option::Make($currencies), 'default' => $this->registry->session->getActiveShopCurrencyId() ))); $buycurrency = $pricePane->AddChild(new FE_Select(Array( 'name' => 'buycurrencyid', 'label' => $this->registry->core->getMessage('TXT_BUY_CURRENCY'), 'options' => FE_Option::Make($currencies), 'default' => $this->registry->session->getActiveShopCurrencyId() ))); $pricePane->AddChild(new FE_Price(Array( 'name' => 'buyprice', 'label' => $this->registry->core->getMessage('TXT_BUYPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_BUYPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'filters' => Array( new FE_FilterCommaToDotChanger() ), 'vat_field' => $vat ))); $standardPrice = $pricePane->AddChild(new FE_Fieldset(Array( 'name' => 'standard_price', 'label' => $this->registry->core->getMessage('TXT_STANDARD_SELLPRICE') ))); $price = $standardPrice->AddChild(new FE_Price(Array( 'name' => 'sellprice', 'label' => $this->registry->core->getMessage('TXT_SELLPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat ))); $enablePromotion = $standardPrice->AddChild(new FE_Checkbox(Array( 'name' => 'promotion', 'label' => $this->registry->core->getMessage('TXT_ENABLE_PROMOTION'), 'default' => '0' ))); $standardPrice->AddChild(new FE_Price(Array( 'name' => 'discountprice', 'label' => $this->registry->core->getMessage('TXT_DISCOUNTPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat, 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $enablePromotion, new FE_ConditionEquals(1)) ) ))); $standardPrice->AddChild(new FE_Date(Array( 'name' => 'promotionstart', 'label' => $this->registry->core->getMessage('TXT_START_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $enablePromotion, new FE_ConditionEquals(1)) ) ))); $standardPrice->AddChild(new FE_Date(Array( 'name' => 'promotionend', 'label' => $this->registry->core->getMessage('TXT_END_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $enablePromotion, new FE_ConditionEquals(1)) ) ))); $clientGroups = App::getModel('clientgroup/clientgroup')->getClientGroupAll(); foreach ($clientGroups as $clientGroup){ $pricePane->AddChild(new FE_Fieldset(Array( 'name' => 'field_' . $clientGroup['id'], 'label' => $clientGroup['name'] ))); $groups[$clientGroup['id']] = $pricePane->AddChild(new FE_Checkbox(Array( 'name' => 'groupid_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_ENABLE_GROUP_PRICE'), 'default' => '0' ))); $pricePane->AddChild(new FE_Price(Array( 'name' => 'sellprice_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_SELLPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat, 'dependencies' => Array( new FE_Dependency(FE_Dependency::HIDE, $groups[$clientGroup['id']], new FE_ConditionNot(new FE_ConditionEquals(1))) ) ))); $promotion[$clientGroup['id']] = $pricePane->AddChild(new FE_Checkbox(Array( 'name' => 'promotion_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_ENABLE_CLIENTGROUP_PROMOTION'), 'default' => '0' ))); $pricePane->AddChild(new FE_Price(Array( 'name' => 'discountprice_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_DISCOUNTPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat, 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $promotion[$clientGroup['id']], new FE_ConditionEquals(1)) ) ))); $pricePane->AddChild(new FE_Date(Array( 'name' => 'promotionstart_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_START_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $promotion[$clientGroup['id']], new FE_ConditionEquals(1)) ) ))); $pricePane->AddChild(new FE_Date(Array( 'name' => 'promotionend_' . $clientGroup['id'], 'label' => $this->registry->core->getMessage('TXT_END_DATE'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::SHOW, $promotion[$clientGroup['id']], new FE_ConditionEquals(1)) ) ))); } $weightPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'weight_pane', 'label' => $this->registry->core->getMessage('TXT_WEIGHT_DATA') ))); $weightPane->AddChild(new FE_TextField(Array( 'name' => 'weight', 'label' => $this->registry->core->getMessage('TXT_VALUE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_WEIGHT')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'suffix' => 'kg', 'filters' => Array( new FE_FilterCommaToDotChanger() ) ))); $descriptionPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'description_pane', 'label' => $this->registry->core->getMessage('TXT_DESCRIPTION') ))); $descriptionLanguageData = $descriptionPane->AddChild(new FE_FieldsetLanguage(Array( 'name' => 'language_data', 'label' => $this->registry->core->getMessage('TXT_LANGUAGE_DATA') ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'shortdescription', 'label' => $this->registry->core->getMessage('TXT_SHORTDESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000, 'rows' => 20 ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'description', 'label' => $this->registry->core->getMessage('TXT_DESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 5000', 'max_length' => 5000, 'rows' => 30 ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'longdescription', 'label' => $this->registry->core->getMessage('TXT_ADDITIONAL_INFO'), 'rows' => 30 ))); $technicalDataPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'technical_data_pane', 'label' => $this->registry->core->getMessage('TXT_TECHNICAL_DATA') ))); $technicalDataPane->AddChild(new FE_TechnicalDataEditor(Array( 'name' => 'technical_data', 'label' => $this->registry->core->getMessage('TXT_TECHNICAL_DATA'), 'product_id' => (int) $this->registry->core->getParam() ))); $photosPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'photos_pane', 'label' => $this->registry->core->getMessage('TXT_PHOTOS') ))); $photosPane->AddChild(new FE_Image(Array( 'name' => 'photo', 'label' => $this->registry->core->getMessage('TXT_PHOTOS'), 'repeat_min' => 0, 'repeat_max' => FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add', 'main_id' => $PopulateData['mainphotoid'] ))); $filePane = $form->addChild(new FE_Fieldset(Array( 'name' => 'files_pane', 'label' => $this->registry->core->getMessage('TXT_FILES') ))); $filePane->AddChild(new FE_Downloader(Array( 'name' => 'file', 'label' => $this->registry->core->getMessage('TXT_FILES'), 'repeat_min' => 0, 'repeat_max' => FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'virtualproduct/add' ))); $statusProductPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'statusproduct_pane', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_STATUS') ))); $idnew = $statusProductPane->AddChild(new FE_Checkbox(Array( 'name' => 'newactive', 'label' => $this->registry->core->getMessage('TXT_NEW') ))); $newData = $statusProductPane->AddChild(new FE_Fieldset(Array( 'name' => 'new_data', 'label' => $this->registry->core->getMessage('TXT_NEW_DATA'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::HIDE, $idnew, new FE_ConditionNot(new FE_ConditionEquals('1'))) ) ))); $newData->AddChild(new FE_Date(Array( 'name' => 'endnew', 'label' => $this->registry->core->getMessage('TXT_END_DATE') ))); $set = App::getModel('attributegroup')->getSugestVariant((int) $this->registry->core->getParam()); $groups = App::getModel('attributegroup/attributegroup')->getGroupsForCategory(0); if (! empty($groups)){ $variantsPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'variants_pane', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_VARIANTS') ))); $variantsPane->AddChild(new FE_ProductVariantsEditor(Array( 'name' => 'variants', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_VARIANTS'), 'category' => $category, // pole z kategoria, aby pobrac sugerowane zestawy cech (nieobslugiwane przez baze) 'price' => $price, // pole z cena, aby moc na jej podstawie wyliczac cene wariantu produktu 'set' => $set, // id zestawu cech dla tego produktu 'vat_field' => $vat // Pole ze stawka VAT ))); } $form->AddFilter(new FE_FilterTrim()); $groupPrice = App::getModel('product')->getProductGroupPrice($this->registry->core->getParam()); $CurrentViewData = Array( 'basic_pane' => Array( 'language_data' => $PopulateData['language'], 'ean' => $PopulateData['ean'], 'enable' => $PopulateData['enable'], 'delivelercode' => $PopulateData['delivelercode'], 'producerid' => $PopulateData['producerid'], 'delivererid' => $PopulateData['delivererid'] ), 'category_pane' => Array( 'category' => $PopulateData['category'] ), 'price_pane' => Array( 'vatid' => $PopulateData['vatid'], 'buyprice' => $PopulateData['buyprice'], 'buycurrencyid' => $PopulateData['buycurrencyid'], 'sellcurrencyid' => $PopulateData['sellcurrencyid'], 'standard_price' => Array( 'sellprice' => $PopulateData['sellprice'], 'promotion' => $PopulateData['promotion'], 'discountprice' => $PopulateData['discountprice'], 'promotionstart' => $PopulateData['promotionstart'], 'promotionend' => $PopulateData['promotionend'] ) ), 'weight_pane' => Array( 'weight' => $PopulateData['weight'] ), 'stock_pane' => Array( 'stock' => $PopulateData['standardstock'], 'trackstock' => $PopulateData['trackstock'] ), 'description_pane' => Array( 'language_data' => $PopulateData['language'] ), 'technical_data_pane' => Array( 'technical_data' => App::getModel('TechnicalData')->GetValuesForProduct((int) $this->registry->core->getParam()) ), 'photos_pane' => Array( 'photo' => $PopulateData['photo'] ), 'files_pane' => Array( 'file' => $PopulateData['file'] ), 'statusproduct_pane' => Array( 'newactive' => $PopulateData['productnew']['newactive'], 'new_data' => Array( 'endnew' => $PopulateData['productnew']['endnew'] ) ), 'variants_pane' => Array( 'variants' => $PopulateData['variants'] ) ); foreach ($groupPrice as $key => $val){ $CurrentViewData['price_pane'][$key] = $val; } $form->Populate($CurrentViewData); if ($form->Validate(FE::SubmittedData())){ try{ $this->model->productUpdateAll($form->getSubmitValues(FE_Form::FORMAT_FLAT), $this->registry->core->getParam()); } catch (Exception $e){ $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/product'); } $this->registry->template->assign('form', $form); $this->registry->xajax->processRequest(); $this->registry->template->assign('productName', $PopulateData['language'][Helper::getLanguageId()]['name']); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->display($this->loadTemplate('edit.tpl')); } public function duplicate () { $form = new FE_Form(Array( 'name' => 'duplicate_product', 'action' => '', 'method' => 'post' )); $basicPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'basic_pane', 'label' => $this->registry->core->getMessage('TXT_BASIC_INFORMATION') ))); $basicLanguageData = $basicPane->AddChild(new FE_FieldsetLanguage(Array( 'name' => 'language_data', 'label' => $this->registry->core->getMessage('TXT_LANGUAGE_DATA') ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'name', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_NAME'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_PRODUCT_NAME')), new FE_RuleLanguageUnique($this->registry->core->getMessage('ERR_NAME_ALREADY_EXISTS'), 'producttranslation', 'name'), new FE_RuleFormat($this->registry->core->getMessage('ERR_ALPHANUMERIC_INVALID'), '/^[A-Za-z0-9-_\",\'\s]+$/') ) ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'seo', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_SEO'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_PRODUCT_SEO')), new FE_RuleFormat($this->registry->core->getMessage('ERR_ALPHANUMERIC_INVALID'), '/^[A-Za-z0-9-_\",\'\s]+$/') ) ))); $basicLanguageData->AddChild(new FE_TextField(Array( 'name' => 'keywordtitle', 'label' => $this->registry->core->getMessage('TXT_KEYWORD_TITLE') ))); $basicLanguageData->AddChild(new FE_Textarea(Array( 'name' => 'keyword', 'label' => $this->registry->core->getMessage('TXT_KEYWORDS'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000 ))); $basicLanguageData->AddChild(new FE_Textarea(Array( 'name' => 'keyworddescription', 'label' => $this->registry->core->getMessage('TXT_KEYWORD_DESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000 ))); $basicPane->AddChild(new FE_Checkbox(Array( 'name' => 'enable', 'label' => $this->registry->core->getMessage('TXT_ENABLE_PRODUCT'), 'default' => '1' ))); $basicPane->AddChild(new FE_TextField(Array( 'name' => 'ean', 'label' => $this->registry->core->getMessage('TXT_EAN') ))); $basicPane->AddChild(new FE_TextField(Array( 'name' => 'delivelercode', 'label' => $this->registry->core->getMessage('TXT_DELIVELERCODE') ))); $basicPane->AddChild(new FE_Select(Array( 'name' => 'producerid', 'label' => $this->registry->core->getMessage('TXT_PRODUCER'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('producer')->getProducerToSelect()) ))); $basicPane->AddChild(new FE_Select(Array( 'name' => 'delivererid', 'label' => $this->registry->core->getMessage('TXT_DELIVERER'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('deliverer')->getDelivererToSelect()) ))); $stockPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'stock_pane', 'label' => $this->registry->core->getMessage('TXT_STOCK') ))); $stockPane->AddChild(new FE_TextField(Array( 'name' => 'stock', 'label' => $this->registry->core->getMessage('TXT_STOCK'), 'comment' => $this->registry->core->getMessage('TXT_STANDARD_STOCK'), 'rules' => Array( new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'suffix' => $this->registry->core->getMessage('TXT_QTY'), 'default' => '0' ))); $stockPane->AddChild(new FE_Checkbox(Array( 'name' => 'trackstock', 'label' => $this->registry->core->getMessage('TXT_TRACKSTOCK') ))); $categoryPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'category_pane', 'label' => $this->registry->core->getMessage('TXT_CATEGORY') ))); $categoryPane->AddChild(new FE_StaticText(Array( 'text' => '

' . $this->registry->core->getMessage('TXT_EMPTY_CATEGORY_INSTRUCTION') . '

' ))); $category = $categoryPane->AddChild(new FE_Tree(Array( 'name' => 'category', 'label' => $this->registry->core->getMessage('TXT_CATEGORY'), 'choosable' => false, 'selectable' => true, 'sortable' => false, 'clickable' => false, 'items' => App::getModel('category')->getChildCategories(), 'load_children' => Array( App::getModel('category'), 'getChildCategories' ) ))); $pricePane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'price_pane', 'label' => $this->registry->core->getMessage('TXT_PRICE') ))); $vat = $pricePane->AddChild(new FE_Select(Array( 'name' => 'vatid', 'label' => $this->registry->core->getMessage('TXT_VAT'), 'options' => FE_Option::Make($this->registry->core->getDefaultValueToSelect() + App::getModel('VAT')->getVATAll()), 'suffix' => '%', 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_VAT')) ) ))); $currencies = App::getModel('currencieslist')->getCurrencyForSelect(); $sellcurrency = $pricePane->AddChild(new FE_Select(Array( 'name' => 'sellcurrencyid', 'label' => $this->registry->core->getMessage('TXT_SELL_CURRENCY'), 'options' => FE_Option::Make($currencies), 'default' => $this->registry->session->getActiveShopCurrencyId() ))); $buycurrency = $pricePane->AddChild(new FE_Select(Array( 'name' => 'buycurrencyid', 'label' => $this->registry->core->getMessage('TXT_BUY_CURRENCY'), 'options' => FE_Option::Make($currencies), 'default' => $this->registry->session->getActiveShopCurrencyId() ))); $price = $pricePane->AddChild(new FE_Price(Array( 'name' => 'sellprice', 'label' => $this->registry->core->getMessage('TXT_SELLPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_SELLPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'vat_field' => $vat ))); $pricePane->AddChild(new FE_Price(Array( 'name' => 'buyprice', 'label' => $this->registry->core->getMessage('TXT_BUYPRICE'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_BUYPRICE')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'filters' => Array( new FE_FilterCommaToDotChanger() ), 'vat_field' => $vat ))); $weightPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'weight_pane', 'label' => $this->registry->core->getMessage('TXT_WEIGHT_DATA') ))); $weightPane->AddChild(new FE_TextField(Array( 'name' => 'weight', 'label' => $this->registry->core->getMessage('TXT_WEIGHT'), 'rules' => Array( new FE_RuleRequired($this->registry->core->getMessage('ERR_EMPTY_WEIGHT')), new FE_RuleFormat($this->registry->core->getMessage('ERR_NUMERIC_INVALID'), '/[0-9]{1,}/') ), 'suffix' => 'kg', 'filters' => Array( new FE_FilterCommaToDotChanger() ) ))); $descriptionPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'description_pane', 'label' => $this->registry->core->getMessage('TXT_DESCRIPTION') ))); $descriptionLanguageData = $descriptionPane->AddChild(new FE_FieldsetLanguage(Array( 'name' => 'language_data', 'label' => $this->registry->core->getMessage('TXT_LANGUAGE_DATA') ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'shortdescription', 'label' => $this->registry->core->getMessage('TXT_SHORTDESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 1000', 'max_length' => 1000, 'rows' => 20 ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'description', 'label' => $this->registry->core->getMessage('TXT_DESCRIPTION'), 'comment' => $this->registry->core->getMessage('TXT_MAX_LENGTH') . ' 5000', 'max_length' => 5000, 'rows' => 30 ))); $descriptionLanguageData->AddChild(new FE_RichTextEditor(Array( 'name' => 'longdescription', 'label' => $this->registry->core->getMessage('TXT_ADDITIONAL_INFO'), 'rows' => 30 ))); $technicalDataPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'technical_data_pane', 'label' => $this->registry->core->getMessage('TXT_TECHNICAL_DATA') ))); $technicalDataPane->AddChild(new FE_TechnicalDataEditor(Array( 'name' => 'technical_data', 'label' => $this->registry->core->getMessage('TXT_TECHNICAL_DATA'), 'product_id' => '', 'set_id' => '' ))); $photosPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'photos_pane', 'label' => $this->registry->core->getMessage('TXT_PHOTOS') ))); $photosPane->AddChild(new FE_Image(Array( 'name' => 'photo', 'label' => $this->registry->core->getMessage('TXT_PHOTOS'), 'repeat_min' => 0, 'repeat_max' => FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'files/add' ))); $filePane = $form->addChild(new FE_Fieldset(Array( 'name' => 'files_pane', 'label' => $this->registry->core->getMessage('TXT_FILES') ))); $filePane->AddChild(new FE_Downloader(Array( 'name' => 'file', 'label' => $this->registry->core->getMessage('TXT_FILES'), 'repeat_min' => 0, 'repeat_max' => FE::INFINITE, 'upload_url' => App::getURLAdressWithAdminPane() . 'virtualproduct/add' ))); $statusProductPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'statusproduct_pane', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_STATUS') ))); $idnew = $statusProductPane->AddChild(new FE_Checkbox(Array( 'name' => 'newactive', 'label' => $this->registry->core->getMessage('TXT_NEW') ))); $newData = $statusProductPane->AddChild(new FE_Fieldset(Array( 'name' => 'new_data', 'label' => $this->registry->core->getMessage('TXT_NEW_DATA'), 'dependencies' => Array( new FE_Dependency(FE_Dependency::HIDE, $idnew, new FE_ConditionNot(new FE_ConditionEquals('1'))) ) ))); $newData->AddChild(new FE_Date(Array( 'name' => 'endnew', 'label' => $this->registry->core->getMessage('TXT_END_DATE') ))); $groups = App::getModel('attributegroup/attributegroup')->getGroupsForCategory(0); if (! empty($groups)){ $variantsPane = $form->AddChild(new FE_Fieldset(Array( 'name' => 'variants_pane', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_VARIANTS') ))); $variantsPane->AddChild(new FE_ProductVariantsEditor(Array( 'name' => 'variants', 'label' => $this->registry->core->getMessage('TXT_PRODUCT_VARIANTS'), 'category' => $category, 'price' => $price, 'vat_field' => $vat ))); } $form->AddFilter(new FE_FilterTrim()); $PopulateData = $this->model->getProductAndAttributesById((int) $this->registry->core->getParam()); foreach ($PopulateData['language'] as $languageid => $values){ $PopulateData['language'][$languageid]['name'] = ''; $PopulateData['language'][$languageid]['seo'] = ''; } $CurrentViewData = Array( 'basic_pane' => Array( 'language_data' => $PopulateData['language'], 'ean' => $PopulateData['ean'], 'enable' => $PopulateData['enable'], 'delivelercode' => $PopulateData['delivelercode'], 'producerid' => $PopulateData['producerid'], 'delivererid' => $PopulateData['delivererid'] ), 'category_pane' => Array( 'category' => $PopulateData['category'] ), 'price_pane' => Array( 'vatid' => $PopulateData['vatid'], 'sellprice' => $PopulateData['sellprice'], 'buyprice' => $PopulateData['buyprice'], 'buycurrencyid' => $PopulateData['buycurrencyid'], 'sellcurrencyid' => $PopulateData['sellcurrencyid'] ), 'weight_pane' => Array( 'weight' => $PopulateData['weight'] ), 'stock_pane' => Array( 'stock' => $PopulateData['standardstock'], 'trackstock' => $PopulateData['trackstock'] ), 'description_pane' => Array( 'language_data' => $PopulateData['language'] ), 'technical_data_pane' => Array( 'technical_data' => App::getModel('TechnicalData')->GetValuesForProduct((int) $this->registry->core->getParam()) ), 'photos_pane' => Array( 'photo' => $PopulateData['photo'] ), 'files_pane' => Array( 'file' => isset($PopulateData['file'][0]) ? $PopulateData['file'][0] : '' ), 'statusproduct_pane' => Array( 'newactive' => $PopulateData['productnew']['newactive'], 'new_data' => Array( 'endnew' => $PopulateData['productnew']['endnew'] ) ), 'variants_pane' => Array( 'variants' => $PopulateData['variants'] ) ); $form->Populate($CurrentViewData); if ($form->Validate(FE::SubmittedData())){ $this->model->addNewProduct($form->getSubmitValues(FE_Form::FORMAT_FLAT)); App::redirect(__ADMINPANE__ . '/product'); } $this->registry->template->assign('form', $form); $this->registry->xajax->processRequest(); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->display($this->loadTemplate('duplicate.tpl')); } }