Exemplo n.º 1
0
 function edit()
 {
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $cid = JRequest::getInt("category_id");
     $category = JTable::getInstance("category", "jshop");
     $category->load($cid);
     $_lang = $this->getModel("languages");
     $languages = $_lang->getAllLanguages(1);
     $multilang = count($languages) > 1;
     $nofilter = array();
     JFilterOutput::objectHTMLSafe($category, ENT_QUOTES, $nofilter);
     if ($cid) {
         $parentid = $category->category_parent_id;
         $rows = $this->_getAllCategoriesLevel($category->category_parent_id, $category->ordering);
     } else {
         $category->category_publish = 1;
         $parentid = JRequest::getInt("catid");
         $rows = $this->_getAllCategoriesLevel($parentid);
     }
     $lists['templates'] = getTemplates('category', $category->category_template);
     $lists['onelevel'] = $rows;
     $parentTop = new stdClass();
     $parentTop->category_id = 0;
     $parentTop->name = _JSHOP_TOP_LEVEL;
     $categories = buildTreeCategory(0, 1, 0);
     array_unshift($categories, $parentTop);
     $lists['treecategories'] = JHTML::_('select.genericlist', $categories, 'category_parent_id', 'class="inputbox" size="1" onchange = "changeCategory()"', 'category_id', 'name', $parentid);
     $lists['parentid'] = $parentid;
     $accessgroups = getAccessGroups();
     $lists['access'] = JHTML::_('select.genericlist', $accessgroups, 'access', 'class = "inputbox" size = "1"', 'id', 'title', $category->access);
     $view = $this->getView("category", 'html');
     $view->setLayout("edit");
     $view->assign('category', $category);
     $view->assign('lists', $lists);
     $view->assign('languages', $languages);
     $view->assign('multilang', $multilang);
     $view->assign('etemplatevar', '');
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeEditCategories', array(&$view));
     $view->displayEdit();
 }
Exemplo n.º 2
0
 function editlist()
 {
     $cid = JRequest::getVar('cid');
     if (count($cid) == 1) {
         $this->setRedirect("index.php?option=com_jshopping&controller=products&task=edit&product_id=" . $cid[0]);
         return 0;
     }
     $id_vendor_cuser = getIdVendorForCUser();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onLoadEditListProduct', array());
     $products = $this->getModel("products");
     $product = JTable::getInstance('product', 'jshop');
     $_lang = $this->getModel("languages");
     $_tax = $this->getModel("taxes");
     $all_taxes = $_tax->getAllTaxes();
     $list_tax = array();
     $list_tax[] = JHTML::_('select.option', -1, "- - -", 'tax_id', 'tax_name');
     foreach ($all_taxes as $tax) {
         $list_tax[] = JHTML::_('select.option', $tax->tax_id, $tax->tax_name . ' (' . $tax->tax_value . '%)', 'tax_id', 'tax_name');
     }
     if (count($all_taxes) == 0) {
         $withouttax = 1;
     } else {
         $withouttax = 0;
     }
     $categories = buildTreeCategory(0, 1, 0);
     $manuf1 = array();
     $manuf1[-1] = new stdClass();
     $manuf1[-1]->manufacturer_id = '-1';
     $manuf1[-1]->name = "- - -";
     $manuf1[0] = new stdClass();
     $manuf1[0]->manufacturer_id = '0';
     $manuf1[0]->name = _JSHOP_NONE;
     $_manufacturer = $this->getModel('manufacturers');
     $manufs = $_manufacturer->getList();
     $manufs = array_merge($manuf1, $manufs);
     $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');
     $lists['price_mod_price'] = JHTML::_('select.genericlist', $price_modification, 'mod_price', '', 'id', 'name');
     $lists['price_mod_old_price'] = JHTML::_('select.genericlist', $price_modification, 'mod_old_price', '', 'id', 'name');
     if ($jshopConfig->admin_show_delivery_time) {
         $_deliveryTimes = $this->getModel("deliveryTimes");
         $all_delivery_times = $_deliveryTimes->getDeliveryTimes();
         $all_delivery_times0 = array();
         $all_delivery_times0[-1] = new stdClass();
         $all_delivery_times0[-1]->id = '-1';
         $all_delivery_times0[-1]->name = "- - -";
         $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');
     }
     //
     // units
     $_units = $this->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 labels
     if ($jshopConfig->admin_show_product_labels) {
         $_labels = $this->getModel("productLabels");
         $alllabels = $_labels->getList();
         $first = array();
         $first[] = JHTML::_('select.option', '-1', "- - -", 'id', 'name');
         $first[] = JHTML::_('select.option', '0', _JSHOP_SELECT, 'id', 'name');
         $lists['labels'] = JHTML::_('select.genericlist', array_merge($first, $alllabels), 'label_id', 'class = "inputbox"', 'id', 'name');
     }
     //
     // access rights
     $accessgroups = getAccessGroups();
     $first = array();
     $first[] = JHTML::_('select.option', '-1', "- - -", 'id', 'title');
     $lists['access'] = JHTML::_('select.genericlist', array_merge($first, $accessgroups), 'access', 'class = "inputbox"', 'id', 'title');
     //currency
     $current_currency = $product->currency_id;
     if (!$current_currency) {
         $current_currency = $jshopConfig->mainCurrency;
     }
     $_currency = $this->getModel("currencies");
     $currency_list = $_currency->getAllCurrencies();
     $lists['currency'] = JHTML::_('select.genericlist', $currency_list, 'currency_id', 'class = "inputbox"', 'currency_id', 'currency_code', $current_currency);
     // vendors
     $display_vendor_select = 0;
     if ($jshopConfig->admin_show_vendors) {
         $_vendors = $this->getModel("vendors");
         $listvebdorsnames = $_vendors->getAllVendorsNames(1);
         $first = array();
         $first[] = JHTML::_('select.option', '-1', "- - -", 'id', 'name');
         $lists['vendors'] = JHTML::_('select.genericlist', array_merge($first, $listvebdorsnames), 'vendor_id', 'class = "inputbox" size = "1"', 'id', 'name');
         $display_vendor_select = 1;
         if ($id_vendor_cuser > 0) {
             $display_vendor_select = 0;
         }
     }
     //
     $published = array();
     $published[] = JHTML::_('select.option', '-1', "- - -", 'value', 'name');
     $published[] = JHTML::_('select.option', 0, _JSHOP_UNPUBLISH, 'value', 'name');
     $published[] = JHTML::_('select.option', 1, _JSHOP_PUBLISH, 'value', 'name');
     $lists['product_publish'] = JHTML::_('select.genericlist', $published, 'product_publish', '', 'value', 'name');
     $lists['manufacturers'] = JHTML::_('select.genericlist', $manufs, 'product_manufacturer_id', 'class = "inputbox" size = "1"', 'manufacturer_id', 'name');
     $lists['tax'] = JHTML::_('select.genericlist', $list_tax, 'product_tax_id', 'class = "inputbox" size = "1"', 'tax_id', 'tax_name');
     $lists['categories'] = JHTML::_('select.genericlist', $categories, 'category_id[]', 'class="inputbox" size="10" multiple = "multiple" ', 'category_id', 'name');
     $lists['templates'] = getTemplates('product', "", 1);
     $view = $this->getView("product_edit", 'html');
     $view->setLayout("editlist");
     $view->assign('lists', $lists);
     $view->assign('cid', $cid);
     $view->assign('config', $jshopConfig);
     $view->assign('withouttax', $withouttax);
     $view->assign('display_vendor_select', $display_vendor_select);
     $view->assign('etemplatevar', '');
     $dispatcher->trigger('onBeforeDisplayEditListProductView', array(&$view));
     $view->editGroup();
 }