private function _displayFormCategory() { global $cookie; // Check if the module is configured if (!Configuration::get('EBAY_PAYPAL_EMAIL')) { return '<p><b>' . $this->l('You have to configure "General Settings" tab before using this tab.') . '</b></p><br />'; } // Load categories only if necessary if (Db::getInstance()->getValue('SELECT COUNT(`id_ebay_category_configuration`) FROM `' . _DB_PREFIX_ . 'ebay_category_configuration`') >= 1 && Tools::getValue('section') != 'category') { return '<p align="center"><b>' . $this->l('Your categories have already been configured.') . '</b></p> <form action="index.php?tab=' . Tools::safeOutput($_GET['tab']) . '&configure=' . Tools::safeOutput($_GET['configure']) . '&token=' . Tools::safeOutput($_GET['token']) . '&tab_module=' . Tools::safeOutput($_GET['tab_module']) . '&module_name=' . Tools::safeOutput($_GET['module_name']) . '&id_tab=2§ion=category" method="post" class="form"> <p align="center"><input class="button" name="submitSave" type="submit" value="' . $this->l('See Categories') . '" /></p></form>'; } // Display eBay Categories if (!Configuration::get('EBAY_CATEGORY_LOADED')) { $ebay = new eBayRequest(); $ebay->saveCategories(); Configuration::updateValue('EBAY_CATEGORY_LOADED', 1); Configuration::updateValue('EBAY_CATEGORY_LOADED_DATE', date('Y-m-d H:i:s')); } // Loading categories $categoryConfigList = array(); $categoryConfigListTmp = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'ebay_category_configuration`'); foreach ($categoryConfigListTmp as $c) { $categoryConfigList[$c['id_category']] = $c; } $categoryList = $this->_getChildCategories(Category::getCategories($cookie->id_lang), 0); $eBayCategoryList = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'ebay_category` WHERE `id_category_ref` = `id_category_ref_parent`'); // Display header $html = '<p><b>' . $this->l('To export your products on eBay, you have to associate each one of your shop categories to an eBay category. You can also define an impact of your price on eBay.') . '</b></p><br /> <form action="index.php?tab=' . Tools::safeOutput($_GET['tab']) . '&configure=' . Tools::safeOutput($_GET['configure']) . '&token=' . Tools::safeOutput($_GET['token']) . '&tab_module=' . Tools::safeOutput($_GET['tab_module']) . '&module_name=' . Tools::safeOutput($_GET['module_name']) . '&id_tab=2§ion=category&action=suggestCategories" method="post" class="form" id="configForm2SuggestedCategories"> <p><b>' . $this->l('You can use the button below to associate automatically the categories which have no association for the moment with an eBay suggested category.') . '</b> <input class="button" name="submitSave" type="submit" value="' . $this->l('Suggest Categories') . '" /> </p><br /> </form> <form action="index.php?tab=' . Tools::safeOutput($_GET['tab']) . '&configure=' . Tools::safeOutput($_GET['configure']) . '&token=' . Tools::safeOutput($_GET['token']) . '&tab_module=' . Tools::safeOutput($_GET['tab_module']) . '&module_name=' . Tools::safeOutput($_GET['module_name']) . '&id_tab=2§ion=category" method="post" class="form" id="configForm2"> <table class="table tableDnD" cellpadding="0" cellspacing="0" width="100%"> <thead> <tr class="nodrag nodrop"> <th style="width:120px">' . $this->l('Category') . '</th> <th>' . $this->l('eBay Category') . '</th> <th style="width:80px">' . $this->l('Price impact') . '</th> </tr> </thead> <tbody>'; // Displaying categories if (!$categoryList) { $html .= '<tr><td colspan="4">' . $this->l('No category found.') . '</td></tr>'; } foreach ($categoryList as $k => $c) { // Display line $alt = 0; if ($k % 2 != 0) { $alt = ' class="alt_row"'; } $html .= '<tr' . $alt . '> <td>' . $c['name'] . '</td> <td id="categoryPath' . $c['id_category'] . '"> <select name="category' . $c['id_category'] . '" id="categoryLevel1-' . $c['id_category'] . '" rel="' . $c['id_category'] . '" style="font-size: 12px; width: 160px;" OnChange="changeCategoryMatch(1, ' . $c['id_category'] . ');"> <option value="0">' . $this->l('No category selected') . '</option>'; foreach ($eBayCategoryList as $ec) { $html .= '<option value="' . $ec['id_ebay_category'] . '">' . $ec['name'] . ($ec['is_multi_sku'] == 1 ? ' *' : '') . '</option>'; } $html .= '</select>'; if (isset($categoryConfigList[$c['id_category']])) { $html .= '<script>$(document).ready(function() { loadCategoryMatch(' . $c['id_category'] . '); });</script>'; } $html .= '</td> <td><select name="percent' . $c['id_category'] . '" id="percent' . $c['id_category'] . '" rel="' . $c['id_category'] . '" style="font-size: 12px;">'; for ($i = 5; $i >= -80; $i--) { $html .= '<option value="' . $i . '" ' . (isset($categoryConfigList[$c['id_category']]) && $categoryConfigList[$c['id_category']]['percent'] == $i || !isset($categoryConfigList[$c['id_category']]) && $i == 0 ? 'selected="selected"' : '') . '>' . ($i >= 0 ? $i : '- ' . $i * -1) . ' %</option>'; } $html .= '</select></td></tr>'; } $html .= ' </tbody> </table><br /> <div class="margin-form"><input class="button" name="submitSave" type="submit" value="' . $this->l('Save') . '" /></div> </form> <p><b>' . $this->l('Beware : Only product default categories are used for this configuration.') . '</b></p><br /> <p align="left"> * Certaines catégories bénéficient du nouveau format d’annonces multi-versions qui permet de publier 1 seule annonce pour plusieurs versions du même produit.<br /> Pour les catégories ne bénéficiant pas de ce format multi-versions, une annonce sera créée pour chaque version du produit.<br /> <a href="http://sellerupdate.ebay.fr/may2011/multi-variation-listings.html" target="_blank">Cliquez ici pour plus d’informations sur les catégories multi-versions</a> </p><br /><br /> <script> function loadCategoryMatch(id_category) { $.ajax({ async: false, url: "' . _MODULE_DIR_ . 'ebay/ajax/loadCategoryMatch.php?token=' . Configuration::get('EBAY_SECURITY_TOKEN') . '&id_category=" + id_category + "&time=' . pSQL(date('Ymdhis')) . '", success: function(data) { $("#categoryPath" + id_category).html(data); } }); } function changeCategoryMatch(level, id_category) { var levelParams = "&level1=" + $("#categoryLevel1-" + id_category).val(); if (level > 1) levelParams += "&level2=" + $("#categoryLevel2-" + id_category).val(); if (level > 2) levelParams += "&level3=" + $("#categoryLevel3-" + id_category).val(); if (level > 3) levelParams += "&level4=" + $("#categoryLevel4-" + id_category).val(); if (level > 4) levelParams += "&level5=" + $("#categoryLevel5-" + id_category).val(); $.ajax({ url: "' . _MODULE_DIR_ . 'ebay/ajax/changeCategoryMatch.php?token=' . Configuration::get('EBAY_SECURITY_TOKEN') . '&time=' . pSQL(date('Ymdhis')) . '&id_category=" + id_category + "&level=" + level + levelParams, success: function(data) { $("#categoryPath" + id_category).html(data); } }); } </script>'; return $html; }
private function _displayFormCategory() { // Check if the module is configured if (!Configuration::get('EBAY_PAYPAL_EMAIL')) { return '<p><b>' . $this->l('You have to configure "General Settings" tab before using this tab.') . '</b></p><br />'; } // Load categories only if necessary if (Db::getInstance()->getValue('SELECT COUNT(`id_ebay_category_configuration`) FROM `' . _DB_PREFIX_ . 'ebay_category_configuration`') >= 1 && Tools::getValue('section') != 'category') { return '<p align="center"><b>' . $this->l('Your categories have already been configured.') . '</b></p> <form action="index.php?' . ($this->isVersionOneDotFive() ? 'controller=' . Tools::safeOutput($_GET['controller']) : 'tab=' . Tools::safeOutput($_GET['tab'])) . '&configure=' . Tools::safeOutput($_GET['configure']) . '&token=' . Tools::safeOutput($_GET['token']) . '&tab_module=' . Tools::safeOutput($_GET['tab_module']) . '&module_name=' . Tools::safeOutput($_GET['module_name']) . '&id_tab=2§ion=category" method="post" class="form"> <p align="center"><input class="button" name="submitSave" type="submit" value="' . $this->l('See Categories') . '" /></p></form>'; } // Display eBay Categories if (!Configuration::get('EBAY_CATEGORY_LOADED')) { $ebay = new eBayRequest(); $ebay->saveCategories(); $this->setConfiguration('EBAY_CATEGORY_LOADED', 1); $this->setConfiguration('EBAY_CATEGORY_LOADED_DATE', date('Y-m-d H:i:s')); } // Loading categories $categoryConfigList = array(); $categoryConfigListTmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'ebay_category_configuration`'); foreach ($categoryConfigListTmp as $c) { $categoryConfigList[$c['id_category']] = $c; } $categoryList = $this->_getChildCategories(Category::getCategories($this->context->language->id), $this->isVersionOneDotFive() ? 1 : 0); $eBayCategoryList = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'ebay_category` WHERE `id_category_ref` = `id_category_ref_parent`'); $tabHelp = "&id_tab=6"; // Display header $html = $this->getAlertCategories(); $html .= '<p><b>' . $this->l('To export your products on eBay, you have to associate each one of your shop categories to an eBay category. You can also define an impact of your price on eBay.') . '</b></p><br /> <form action="index.php?' . ($this->isVersionOneDotFive() ? 'controller=' . Tools::safeOutput($_GET['controller']) : 'tab=' . Tools::safeOutput($_GET['tab'])) . '&configure=' . Tools::safeOutput($_GET['configure']) . '&token=' . Tools::safeOutput($_GET['token']) . '&tab_module=' . Tools::safeOutput($_GET['tab_module']) . '&module_name=' . Tools::safeOutput($_GET['module_name']) . '&id_tab=2§ion=category&action=suggestCategories" method="post" class="form" id="configForm2SuggestedCategories"> <p><b>' . $this->l('You can use the button below to associate automatically the categories which have no association for the moment with an eBay suggested category.') . '</b> <input class="button" name="submitSave" type="submit" value="' . $this->l('Suggest Categories') . '" /> </p><br /> </form> <form action="index.php?' . ($this->isVersionOneDotFive() ? 'controller=' . Tools::safeOutput($_GET['controller']) : 'tab=' . Tools::safeOutput($_GET['tab'])) . '&configure=' . Tools::safeOutput($_GET['configure']) . '&token=' . Tools::safeOutput($_GET['token']) . '&tab_module=' . Tools::safeOutput($_GET['tab_module']) . '&module_name=' . Tools::safeOutput($_GET['module_name']) . '&id_tab=2§ion=category" method="post" class="form" id="configForm2"> <table class="table tableDnD" cellpadding="0" cellspacing="0" width="100%"> <thead> <tr class="nodrag nodrop"> <th style="width:110px">' . $this->l('Category') . ' <br/>(' . $this->l('Quantity in stock') . ')</th> <th>' . $this->l('eBay Category') . '</th> <th style="width:128px">' . $this->l('Price impact') . '<a title="' . $this->l('Help') . '" href="' . $_SERVER['REQUEST_URI'] . $tabHelp . '" ><img src="' . $this->_path . 'help.png" width="25" alt="help_picture"/></a></th> </tr> </thead> <tbody>'; // Displaying categories if (!$categoryList) { $html .= '<tr><td colspan="4">' . $this->l('No category found.') . '</td></tr>'; } foreach ($categoryList as $k => $c) { if ($this->isVersionOneDotFive()) { $rq_getCatInStock = ' SELECT SUM( s.quantity ) AS instockProduct FROM `' . _DB_PREFIX_ . 'product` AS p INNER JOIN `' . _DB_PREFIX_ . 'stock_available` AS s ON p.id_product = s.id_product WHERE p.id_category_default =' . $c['id_category'] . $this->addSqlRestrictionOnLang('s'); } else { $rq_getCatInStock = 'SELECT SUM( quantity ) AS instockProduct FROM `' . _DB_PREFIX_ . 'product` WHERE id_category_default = ' . $c['id_category']; } $getCatInStock = Db::getInstance()->ExecuteS($rq_getCatInStock); // Display line $alt = 0; if ($k % 2 != 0) { $alt = ' class="alt_row"'; } $html .= '<tr' . $alt . '> <td>' . $c['name'] . ' (' . $getCatInStock[0]['instockProduct'] . ')</td> <td id="categoryPath' . $c['id_category'] . '"> <select name="category' . $c['id_category'] . '" id="categoryLevel1-' . $c['id_category'] . '" rel="' . $c['id_category'] . '" style="font-size: 12px; width: 160px;" OnChange="changeCategoryMatch(1, ' . $c['id_category'] . ');"> <option value="0">' . $this->l('No category selected') . '</option>'; foreach ($eBayCategoryList as $ec) { $html .= '<option value="' . $ec['id_ebay_category'] . '">' . $ec['name'] . ($ec['is_multi_sku'] == 1 ? ' *' : '') . '</option>'; } $html .= '</select>'; if (isset($categoryConfigList[$c['id_category']])) { $html .= '<script>$(document).ready(function() { loadCategoryMatch(' . $c['id_category'] . '); });</script>'; } $html .= '</td> <td><select name="percent' . $c['id_category'] . '" id="percent' . $c['id_category'] . '" rel="' . $c['id_category'] . '" style="font-size: 12px;">'; for ($i = 5; $i >= -80; $i--) { $html .= '<option value="' . $i . '" ' . (isset($categoryConfigList[$c['id_category']]) && $categoryConfigList[$c['id_category']]['percent'] == $i || !isset($categoryConfigList[$c['id_category']]) && $i == 0 ? 'selected="selected"' : '') . '>' . ($i >= 0 ? $i : '- ' . $i * -1) . ' %</option>'; } $html .= '</select></td></tr>'; } $html .= ' </tbody> </table><br /> <div class="margin-form"><input class="button" name="submitSave" type="submit" value="' . $this->l('Save') . '" /></div> </form> <p><b>' . $this->l('Warning : Only defaults products categories are used for the configuration.') . '</b></p><br /> <p align="left"> * ' . $this->l('Some categories benefit from eBay\'s multi-version from which allows to publish one product with multiple versions.') . '<br /> ' . $this->l('For the categories which do not gain this functionality, one ad will be added for each version of the product.') . '<br /> <a href="http://sellerupdate.ebay.fr/autumn2012/improvements-multi-variation-listings" target="_blank">' . $this->l('Click here for more informations on multi-variation listings') . '</a> </p><br /><br /> <script> function loadCategoryMatch(id_category) { $.ajax({ async: false, url: "' . _MODULE_DIR_ . 'ebay/ajax/loadCategoryMatch.php?token=' . Configuration::get('EBAY_SECURITY_TOKEN') . '&id_category=" + id_category + "&time=' . pSQL(date('Ymdhis')) . '", success: function(data) { $("#categoryPath" + id_category).html(data); } }); } function changeCategoryMatch(level, id_category) { var levelParams = "&level1=" + $("#categoryLevel1-" + id_category).val(); if (level > 1) levelParams += "&level2=" + $("#categoryLevel2-" + id_category).val(); if (level > 2) levelParams += "&level3=" + $("#categoryLevel3-" + id_category).val(); if (level > 3) levelParams += "&level4=" + $("#categoryLevel4-" + id_category).val(); if (level > 4) levelParams += "&level5=" + $("#categoryLevel5-" + id_category).val(); $.ajax({ url: "' . _MODULE_DIR_ . 'ebay/ajax/changeCategoryMatch.php?token=' . Configuration::get('EBAY_SECURITY_TOKEN') . '&time=' . pSQL(date('Ymdhis')) . '&id_category=" + id_category + "&level=" + level + levelParams, success: function(data) { $("#categoryPath" + id_category).html(data); } }); } </script>'; return $html; }
private function _displayFormCategory() { $isOneDotFive = $this->isVersionOneDotFive(); if ($isOneDotFive) { $smarty = $this->context->smarty; $cookie = $this->context->cookie; } else { global $smarty, $cookie; } // Load prestashop ebay's configuration $configs = Configuration::getMultiple(array('EBAY_PAYPAL_EMAIL', 'EBAY_CATEGORY_LOADED', 'EBAY_SECURITY_TOKEN')); // Check if the module is configured if (!isset($configs['EBAY_PAYPAL_EMAIL']) || $configs['EBAY_PAYPAL_EMAIL'] === false) { return $this->display(dirname(__FILE__), '/views/templates/hook/error_paypal_email.tpl'); } // Load categories only if necessary if (Db::getInstance()->getValue('SELECT COUNT(`id_ebay_category_configuration`) FROM `' . _DB_PREFIX_ . 'ebay_category_configuration`') >= 1 && Tools::getValue('section') != 'category') { $smarty->assign(array('isOneDotFive' => $isOneDotFive, 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'))); return $this->display(dirname(__FILE__), '/views/templates/hook/pre_form_categories.tpl'); } // Display eBay Categories if (!$configs['EBAY_CATEGORY_LOADED']) { $ebay = new eBayRequest(); $ebay->saveCategories(); $this->setConfiguration('EBAY_CATEGORY_LOADED', 1); $this->setConfiguration('EBAY_CATEGORY_LOADED_DATE', date('Y-m-d H:i:s')); } $tabHelp = "&id_tab=7"; // Smarty $datasSmarty = array('alerts' => $this->getAlertCategories(), 'tabHelp' => $tabHelp, 'id_lang' => $cookie->id_lang, '_path' => $this->_path, 'configs' => $configs, '_module_dir_' => _MODULE_DIR_, 'isOneDotFive' => $isOneDotFive, 'request_uri' => $_SERVER['REQUEST_URI'], 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'date' => pSQL(date('Ymdhis'))); $smarty->assign($datasSmarty); return $this->display(dirname(__FILE__), '/views/templates/hook/form_categories.tpl'); }