function edit() { $jshopConfig = JSFactory::getConfig(); $db = JFactory::getDBO(); $lang = JSFactory::getLang(); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onLoadEditProduct', array()); $id_vendor_cuser = getIdVendorForCUser(); $category_id = JRequest::getInt('category_id'); $tmpl_extra_fields = null; $product_id = JRequest::getInt('product_id'); $product_attr_id = JRequest::getInt('product_attr_id'); //parent product if ($product_attr_id) { //JRequest::setVar("hidemainmenu", 1); $product_attr = JSFactory::getTable('productAttribut', 'jshop'); $product_attr->load($product_attr_id); if ($product_attr->ext_attribute_product_id) { $product_id = $product_attr->ext_attribute_product_id; } else { $product = JSFactory::getTable('product', 'jshop'); $product->parent_id = $product_attr->product_id; $product->store(); $product_id = $product->product_id; $product_attr->ext_attribute_product_id = $product_id; $product_attr->store(); } } if ($id_vendor_cuser && $product_id) { checkAccessVendorToProduct($id_vendor_cuser, $product_id); } $products = JSFactory::getModel("products"); $product = JSFactory::getTable('product', 'jshop'); $product->load($product_id); $_productprice = JSFactory::getTable('productPrice', 'jshop'); $product->product_add_prices = $_productprice->getAddPrices($product_id); $product->product_add_prices = array_reverse($product->product_add_prices); $product->name = $product->getName(); $_lang = JSFactory::getModel("languages"); $languages = $_lang->getAllLanguages(1); $multilang = count($languages) > 1; $nofilter = array(); JFilterOutput::objectHTMLSafe($product, ENT_QUOTES, $nofilter); $edit = intval($product_id); if (!$product_id) { $rows = array(); $product->product_quantity = 1; $product->product_publish = 1; } $product->product_quantity = floatval($product->product_quantity); $_tax = JSFactory::getModel("taxes"); $all_taxes = $_tax->getAllTaxes(); if ($edit) { $images = $product->getImages(); $videos = $product->getVideos(); $files = $product->getFiles(); $categories_select = $product->getCategories(); $categories_select_list = array(); foreach ($categories_select as $v) { $categories_select_list[] = $v->category_id; } $related_products = $products->getRelatedProducts($product_id); } else { $images = array(); $videos = array(); $files = array(); $categories_select = null; if ($category_id) { $categories_select = $category_id; } $related_products = array(); $categories_select_list = array(); } if ($jshopConfig->tax) { $list_tax = array(); foreach ($all_taxes as $tax) { $list_tax[] = JHTML::_('select.option', $tax->tax_id, $tax->tax_name . ' (' . $tax->tax_value . '%)', 'tax_id', 'tax_name'); } $withouttax = 0; } else { $withouttax = 1; } $categories = buildTreeCategory(0, 1, 0); if (count($categories) == 0) { JError::raiseNotice(0, _JSHOP_PLEASE_ADD_CATEGORY); } $lists['images'] = $images; $lists['videos'] = $videos; $lists['files'] = $files; $manuf1 = array(); $manuf1[0] = new stdClass(); $manuf1[0]->manufacturer_id = '0'; $manuf1[0]->name = _JSHOP_NONE; $_manufacturer = JSFactory::getModel('manufacturers'); $manufs = $_manufacturer->getList(); $manufs = array_merge($manuf1, $manufs); //Attributes $_attribut = JSFactory::getModel('attribut'); $list_all_attributes = $_attribut->getAllAttributes(2, $categories_select_list); $_attribut_value = JSFactory::getModel('attributValue'); $lists['attribs'] = $product->getAttributes(); $lists['ind_attribs'] = $product->getAttributes2(); $lists['attribs_values'] = $_attribut_value->getAllAttributeValues(2); $all_attributes = $list_all_attributes['dependent']; $lists['ind_attribs_gr'] = array(); foreach ($lists['ind_attribs'] as $v) { $lists['ind_attribs_gr'][$v->attr_id][] = $v; } foreach ($lists['attribs'] as $key => $attribs) { $lists['attribs'][$key]->count = floatval($attribs->count); } $first = array(); $first[] = JHTML::_('select.option', '0', _JSHOP_SELECT, 'value_id', 'name'); foreach ($all_attributes as $key => $value) { $values_for_attribut = $_attribut_value->getAllValues($value->attr_id); $all_attributes[$key]->values_select = JHTML::_('select.genericlist', array_merge($first, $values_for_attribut), 'value_id[' . $value->attr_id . ']', 'class = "inputbox" size = "5" multiple="multiple" id = "value_id_' . $value->attr_id . '"', 'value_id', 'name'); $all_attributes[$key]->values = $values_for_attribut; } $lists['all_attributes'] = $all_attributes; $product_with_attribute = count($lists['attribs']) > 0; //independent attribute $all_independent_attributes = $list_all_attributes['independent']; $price_modification = array(); $price_modification[] = JHTML::_('select.option', '+', '+', 'id', 'name'); $price_modification[] = JHTML::_('select.option', '-', '-', 'id', 'name'); $price_modification[] = JHTML::_('select.option', '*', '*', 'id', 'name'); $price_modification[] = JHTML::_('select.option', '/', '/', 'id', 'name'); $price_modification[] = JHTML::_('select.option', '=', '=', 'id', 'name'); $price_modification[] = JHTML::_('select.option', '%', '%', 'id', 'name'); foreach ($all_independent_attributes as $key => $value) { $values_for_attribut = $_attribut_value->getAllValues($value->attr_id); $all_independent_attributes[$key]->values_select = JHTML::_('select.genericlist', array_merge($first, $values_for_attribut), 'attr_ind_id_tmp_' . $value->attr_id . '', 'class = "inputbox middle2" ', 'value_id', 'name'); $all_independent_attributes[$key]->values = $values_for_attribut; $all_independent_attributes[$key]->price_modification_select = JHTML::_('select.genericlist', $price_modification, 'attr_price_mod_tmp_' . $value->attr_id . '', 'class = "inputbox small3" ', 'id', 'name'); $all_independent_attributes[$key]->submit_button = '<input type = "button" class="btn" onclick = "addAttributValue2(' . $value->attr_id . ');" value = "' . _JSHOP_ADD_ATTRIBUT . '" />'; } $lists['all_independent_attributes'] = $all_independent_attributes; $lists['dep_attr_button_add'] = '<input type="button" class="btn" onclick="addAttributValue()" value="' . _JSHOP_ADD . '" />'; // End work with attributes and values // delivery Times if ($jshopConfig->admin_show_delivery_time) { $_deliveryTimes = JSFactory::getModel("deliveryTimes"); $all_delivery_times = $_deliveryTimes->getDeliveryTimes(); $all_delivery_times0 = array(); $all_delivery_times0[0] = new stdClass(); $all_delivery_times0[0]->id = '0'; $all_delivery_times0[0]->name = _JSHOP_NONE; $lists['deliverytimes'] = JHTML::_('select.genericlist', array_merge($all_delivery_times0, $all_delivery_times), 'delivery_times_id', 'class = "inputbox" size = "1"', 'id', 'name', $product->delivery_times_id); } // // units $_units = JSFactory::getModel("units"); $allunits = $_units->getUnits(); if ($jshopConfig->admin_show_product_basic_price) { $lists['basic_price_units'] = JHTML::_('select.genericlist', $allunits, 'basic_price_unit_id', 'class = "inputbox"', 'id', 'name', $product->basic_price_unit_id); } if (!$product->add_price_unit_id) { $product->add_price_unit_id = $jshopConfig->product_add_price_default_unit; } $lists['add_price_units'] = JHTML::_('select.genericlist', $allunits, 'add_price_unit_id', 'class = "inputbox middle"', 'id', 'name', $product->add_price_unit_id); // // product labels if ($jshopConfig->admin_show_product_labels) { $_labels = JSFactory::getModel("productLabels"); $alllabels = $_labels->getList(); $first = array(); $first[] = JHTML::_('select.option', '0', _JSHOP_SELECT, 'id', 'name'); $lists['labels'] = JHTML::_('select.genericlist', array_merge($first, $alllabels), 'label_id', 'class = "inputbox" size = "1"', 'id', 'name', $product->label_id); } // // access rights $accessgroups = getAccessGroups(); $lists['access'] = JHTML::_('select.genericlist', $accessgroups, 'access', 'class = "inputbox" size = "1"', 'id', 'title', $product->access); //currency $current_currency = $product->currency_id; if (!$current_currency) { $current_currency = $jshopConfig->mainCurrency; } $_currency = JSFactory::getModel("currencies"); $currency_list = $_currency->getAllCurrencies(); $lists['currency'] = JHTML::_('select.genericlist', $currency_list, 'currency_id', 'class = "inputbox small2"', 'currency_id', 'currency_code', $current_currency); // vendors $display_vendor_select = 0; if ($jshopConfig->admin_show_vendors) { $_vendors = JSFactory::getModel("vendors"); $listvebdorsnames = $_vendors->getAllVendorsNames(1); $first = array(); $lists['vendors'] = JHTML::_('select.genericlist', array_merge($first, $listvebdorsnames), 'vendor_id', 'class = "inputbox" size = "1"', 'id', 'name', $product->vendor_id); $display_vendor_select = 1; if ($id_vendor_cuser > 0) { $display_vendor_select = 0; } } // //product extra field if ($jshopConfig->admin_show_product_extra_field) { $categorys_id = array(); if (is_array($categories_select)) { foreach ($categories_select as $tmp) { $categorys_id[] = $tmp->category_id; } } $tmpl_extra_fields = $this->_getHtmlProductExtraFields($categorys_id, $product); } // //free attribute if ($jshopConfig->admin_show_freeattributes) { $_freeattributes = JSFactory::getModel("freeattribut"); $listfreeattributes = $_freeattributes->getAll(); $activeFreeAttribute = $product->getListFreeAttributes(); $listIdActiveFreeAttribute = array(); foreach ($activeFreeAttribute as $_obj) { $listIdActiveFreeAttribute[] = $_obj->id; } foreach ($listfreeattributes as $k => $v) { if (in_array($v->id, $listIdActiveFreeAttribute)) { $listfreeattributes[$k]->pactive = 1; } } } $lists['manufacturers'] = JHTML::_('select.genericlist', $manufs, 'product_manufacturer_id', 'class = "inputbox" size = "1"', 'manufacturer_id', 'name', $product->product_manufacturer_id); $tax_value = 0; if ($jshopConfig->tax) { foreach ($all_taxes as $tax) { if ($tax->tax_id == $product->product_tax_id) { $tax_value = $tax->tax_value; break; } } } if ($product_id) { $product->product_price = formatEPrice($product->product_price); if ($jshopConfig->display_price_admin == 0) { $product->product_price2 = formatEPrice($product->product_price / (1 + $tax_value / 100)); } else { $product->product_price2 = formatEPrice($product->product_price * (1 + $tax_value / 100)); } } else { $product->product_price2 = ''; } $category_select_onclick = ""; if ($jshopConfig->admin_show_product_extra_field) { $category_select_onclick = 'onclick="reloadProductExtraField(\'' . $product_id . '\')"'; } if ($jshopConfig->tax) { $lists['tax'] = JHTML::_('select.genericlist', $list_tax, 'product_tax_id', 'class = "inputbox" size = "1" onchange = "updatePrice2(' . $jshopConfig->display_price_admin . ');"', 'tax_id', 'tax_name', $product->product_tax_id); } $lists['categories'] = JHTML::_('select.genericlist', $categories, 'category_id[]', 'class="inputbox" size="10" multiple = "multiple" ' . $category_select_onclick, 'category_id', 'name', $categories_select); $lists['templates'] = getTemplates('product', $product->product_template); $_product_option = JSFactory::getTable('productOption', 'jshop'); $product_options = $_product_option->getProductOptions($product_id); $product->product_options = $product_options; if ($jshopConfig->return_policy_for_product) { $_statictext = JSFactory::getModel("statictext"); $first = array(); $first[] = JHTML::_('select.option', '0', _JSHP_STPAGE_return_policy, 'id', 'alias'); $statictext_list = $_statictext->getList(1); $lists['return_policy'] = JHTML::_('select.genericlist', array_merge($first, $statictext_list), 'options[return_policy]', 'class = "inputbox"', 'id', 'alias', $product_options['return_policy']); } $dispatcher->trigger('onBeforeDisplayEditProduct', array(&$product, &$related_products, &$lists, &$listfreeattributes, &$tax_value)); $view = $this->getView("product_edit", 'html'); $view->setLayout("default"); $view->assign('product', $product); $view->assign('lists', $lists); $view->assign('related_products', $related_products); $view->assign('edit', $edit); $view->assign('product_with_attribute', $product_with_attribute); $view->assign('tax_value', $tax_value); $view->assign('languages', $languages); $view->assign('multilang', $multilang); $view->assign('tmpl_extra_fields', $tmpl_extra_fields); $view->assign('withouttax', $withouttax); $view->assign('display_vendor_select', $display_vendor_select); $view->assign('listfreeattributes', $listfreeattributes); $view->assign('product_attr_id', $product_attr_id); foreach ($languages as $lang) { $view->assign('plugin_template_description_' . $lang->language, ''); } $view->assign('plugin_template_info', ''); $view->assign('plugin_template_attribute', ''); $view->assign('plugin_template_freeattribute', ''); $view->assign('plugin_template_images', ''); $view->assign('plugin_template_related', ''); $view->assign('plugin_template_files', ''); $view->assign('plugin_template_extrafields', ''); $dispatcher->trigger('onBeforeDisplayEditProductView', array(&$view)); $view->display(); }
echo _JSHOP_DELETE; ?> </th> </tr> </thead> <?php $add_prices = $row->product_add_prices; $count = count($add_prices); for ($i = 0; $i < $count; $i++) { if ($jshopConfig->product_price_qty_discount == 1) { $_add_price = $row->product_price - $add_prices[$i]->discount; } else { $_add_price = $row->product_price - $row->product_price * $add_prices[$i]->discount / 100; } $_add_price = formatEPrice($_add_price); ?> <tr id="add_price_<?php print $i; ?> "> <td> <input type="text" class="small3" name="quantity_start[]" id="quantity_start_<?php print $i; ?> " value="<?php echo $add_prices[$i]->product_quantity_start; ?> " /> </td> <td>