public function __construct()
 {
     global $cookie;
     $this->className = 'Configuration';
     $this->table = 'configuration';
     $max_upload = (int) ini_get('upload_max_filesize');
     $max_post = (int) ini_get('post_max_size');
     $upload_mb = min($max_upload, $max_post);
     $timezones = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT name FROM ' . _DB_PREFIX_ . 'timezone');
     $taxes[] = array('id' => 0, 'name' => $this->l('None'));
     foreach (Tax::getTaxes((int) $cookie->id_lang) as $tax) {
         $taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
     }
     $order_process_type = array(array('value' => PS_ORDER_PROCESS_STANDARD, 'name' => $this->l('Standard (5 steps)')), array('value' => PS_ORDER_PROCESS_OPC, 'name' => $this->l('One page checkout')));
     $round_mode = array(array('value' => PS_ROUND_UP, 'name' => $this->l('superior')), array('value' => PS_ROUND_DOWN, 'name' => $this->l('inferior')), array('value' => PS_ROUND_HALF, 'name' => $this->l('classical')));
     $cms_tab = array(0 => array('id' => 0, 'name' => $this->l('None')));
     foreach (CMS::listCms($cookie->id_lang) as $cms_file) {
         $cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
     }
     $this->_fieldsGeneral = array('PS_SHOP_ENABLE' => array('title' => $this->l('Enable Shop'), 'desc' => $this->l('Activate or deactivate your shop. Deactivate your shop while you perform maintenance on it. Please note that the webservice will not be disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_MAINTENANCE_IP' => array('title' => $this->l('Maintenance IP'), 'desc' => $this->l('IP addresses allowed to access the Front Office even if shop is disabled. Use a comma to separate them (e.g., 42.24.4.2,127.0.0.1,99.98.97.96)'), 'validation' => 'isGenericName', 'type' => 'maintenance_ip', 'size' => 30, 'default' => ''), 'PS_SSL_ENABLED' => array('title' => $this->l('Enable SSL'), 'desc' => $this->l('If your hosting provider allows SSL, you can activate SSL encryption (https://) for customer account identification and order processing'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_COOKIE_CHECKIP' => array('title' => $this->l('Check IP on the cookie'), 'desc' => $this->l('Check the IP address of the cookie in order to avoid your cookie being stolen'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_COOKIE_LIFETIME_FO' => array('title' => $this->l('Lifetime of the Front Office cookie'), 'desc' => $this->l('Indicate the number of hours'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'default' => '480'), 'PS_COOKIE_LIFETIME_BO' => array('title' => $this->l('Lifetime of the Back Office cookie'), 'desc' => $this->l('Indicate the number of hours'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'default' => '480'), 'PS_TOKEN_ENABLE' => array('title' => $this->l('Increase Front Office security'), 'desc' => $this->l('Enable or disable token on the Front Office in order to improve PrestaShop security'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_HELPBOX' => array('title' => $this->l('Back Office help boxes'), 'desc' => $this->l('Enable yellow help boxes which are displayed under form fields in the Back Office'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_ORDER_PROCESS_TYPE' => array('title' => $this->l('Order process type'), 'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $order_process_type, 'identifier' => 'value'), 'PS_GUEST_CHECKOUT_ENABLED' => array('title' => $this->l('Enable guest checkout'), 'desc' => $this->l('Your guest can make an order without registering'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CONDITIONS' => array('title' => $this->l('Terms of service'), 'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'js' => array('on' => 'onchange="changeCMSActivationAuthorization()"', 'off' => 'onchange="changeCMSActivationAuthorization()"')), 'PS_CONDITIONS_CMS_ID' => array('title' => $this->l('Conditions of use of CMS page'), 'desc' => $this->l('Choose the Conditions of use of CMS page'), 'validation' => 'isInt', 'type' => 'select', 'list' => $cms_tab, 'identifier' => 'id', 'cast' => 'intval'), 'PS_GIFT_WRAPPING' => array('title' => $this->l('Offer gift-wrapping'), 'desc' => $this->l('Suggest gift-wrapping to customer and possibility of leaving a message'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_GIFT_WRAPPING_PRICE' => array('title' => $this->l('Gift-wrap pricing'), 'desc' => $this->l('Set a price for gift-wrapping'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'price'), 'PS_GIFT_WRAPPING_TAX' => array('title' => $this->l('Gift-wrapping tax'), 'desc' => $this->l('Set a tax for gift-wrapping'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $taxes, 'identifier' => 'id'), 'PS_ATTACHMENT_MAXIMUM_SIZE' => array('title' => $this->l('Maximum attachment size'), 'desc' => $this->l('Set the maximum size of attached files (in Megabytes ).') . ' ' . $this->l('Maximum:') . ' ' . ((int) str_replace('M', '', ini_get('post_max_size')) > (int) str_replace('M', '', ini_get('upload_max_filesize')) ? ini_get('upload_max_filesize') : ini_get('post_max_size')), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'default' => '2'), 'PS_RECYCLABLE_PACK' => array('title' => $this->l('Offer recycled packaging'), 'desc' => $this->l('Suggest recycled packaging to customer'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CART_FOLLOWING' => array('title' => $this->l('Save cart content and re-display it at login'), 'desc' => $this->l('Recall and display contents of shopping cart following customer login'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_PRICE_ROUND_MODE' => array('title' => $this->l('Round mode'), 'desc' => $this->l('You can choose how to round prices: always round superior; always round inferior, or classic rounding'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $round_mode, 'identifier' => 'value'), 'PRESTASTORE_LIVE' => array('title' => $this->l('Automatically check for module updates'), 'desc' => $this->l('New modules and updates are displayed on the modules page'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_HIDE_OPTIMIZATION_TIPS' => array('title' => $this->l('Hide optimization tips'), 'desc' => $this->l('Hide optimization tips on the back office homepage'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_DISPLAY_SUPPLIERS' => array('title' => $this->l('Display suppliers and manufacturers'), 'desc' => $this->l('Display manufacturers and suppliers list even if corresponding blocks are disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_FORCE_SMARTY_2' => array('title' => $this->l('Use Smarty 2 instead of 3'), 'desc' => $this->l('Enable if your theme is incompatible with Smarty 3 (you should update your theme, since Smarty 2 will be unsupported from PrestaShop v1.5)'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_LIMIT_UPLOAD_FILE_VALUE' => array('title' => $this->l('Limit upload file value'), 'desc' => $this->l('Define the limit upload for a downloadable product, this value has to be inferior or equal to your server\'s maximum upload file ') . sprintf('(%s MB).', $upload_mb), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'limit', 'default' => '1'), 'PS_LIMIT_UPLOAD_IMAGE_VALUE' => array('title' => $this->l('Limit upload image value'), 'desc' => $this->l('Define the limit upload for an image, this value has to be inferior or equal to your server\'s maximum upload file ') . sprintf('(%s MB).', $upload_mb), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'limit', 'default' => '1'));
     if (function_exists('date_default_timezone_set')) {
         $this->_fieldsGeneral['PS_TIMEZONE'] = array('title' => $this->l('Time Zone:'), 'validation' => 'isAnything', 'type' => 'select', 'list' => $timezones, 'identifier' => 'name');
     }
     // No HTTPS activation if you haven't already.
     if (!Tools::usingSecureMode() && !_PS_SSL_ENABLED_) {
         $this->_fieldsGeneral['PS_SSL_ENABLED']['type'] = 'disabled';
         $this->_fieldsGeneral['PS_SSL_ENABLED']['disabled'] = '<a href="https://' . Tools::getShopDomainSsl() . Tools::safeOutput($_SERVER['REQUEST_URI']) . '">' . $this->l('Please click here to use HTTPS protocol before enabling SSL.') . '</a>';
     }
     parent::__construct();
 }
 public function initRuleForm()
 {
     $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('New tax rule'), 'icon' => 'icon-money'), 'input' => array(array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'country', 'id' => 'country', 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('All')))), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'states[]', 'id' => 'states', 'multiple' => true, 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('All')))), array('type' => 'hidden', 'name' => 'action'), array('type' => 'text', 'label' => $this->l('Zip/postal code range'), 'name' => 'zipcode', 'required' => false, 'hint' => $this->l('You can define a range of Zip/postal codes (e.g., 75000-75015) or simply use one Zip/postal code.')), array('type' => 'select', 'label' => $this->l('Behavior'), 'name' => 'behavior', 'required' => false, 'options' => array('query' => array(array('id' => 0, 'name' => $this->l('This tax only')), array('id' => 1, 'name' => $this->l('Combine')), array('id' => 2, 'name' => $this->l('One after another'))), 'id' => 'id', 'name' => 'name'), 'hint' => array($this->l('You must define the behavior if an address matches multiple rules:') . '<br>', $this->l('- This tax only: Will apply only this tax') . '<br>', $this->l('- Combine: Combine taxes (e.g.: 10% + 5% = 15%)') . '<br>', $this->l('- One after another: Apply taxes one after another (e.g.: 0 + 10% = 0 + 5% = 5.5)'))), array('type' => 'select', 'label' => $this->l('Tax'), 'name' => 'id_tax', 'required' => false, 'options' => array('query' => Tax::getTaxes((int) $this->context->language->id), 'id' => 'id_tax', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('No Tax'))), 'hint' => sprintf($this->l('(Total tax: %s)'), '9%')), array('type' => 'select', 'label' => $this->l('Grupos'), 'name' => 'id_group', 'required' => false, 'options' => array('query' => Group::getGroups($this->default_form_language, true), 'id' => 'id_group', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('Default'))), 'hint' => sprintf($this->l('(Total tax: %s)'), '9%')), array('type' => 'text', 'label' => $this->l('Description'), 'name' => 'description')), 'submit' => array('title' => $this->l('Save and stay'), 'stay' => true));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $this->fields_value = array('action' => 'create_rule', 'id_tax_rules_group' => $obj->id, 'id_tax_rule' => '');
     $this->getlanguages();
     $helper = new HelperForm();
     $helper->override_folder = $this->tpl_folder;
     $helper->currentIndex = self::$currentIndex;
     $helper->token = $this->token;
     $helper->table = 'tax_rule';
     $helper->identifier = 'id_tax_rule';
     $helper->id = $obj->id;
     $helper->toolbar_scroll = true;
     $helper->show_toolbar = true;
     $helper->languages = $this->_languages;
     $helper->default_form_language = $this->default_form_language;
     $helper->allow_employee_form_lang = $this->allow_employee_form_lang;
     $helper->fields_value = $this->getFieldsValue($this->object);
     $helper->toolbar_btn['save_new_rule'] = array('href' => self::$currentIndex . '&amp;id_tax_rules_group=' . $obj->id . '&amp;action=create_rule&amp;token=' . $this->token, 'desc' => 'Save tax rule', 'class' => 'process-icon-save');
     $helper->submit_action = 'create_rule';
     return $helper->generateForm($this->fields_form);
 }
Exemple #3
0
 public function getTax($request)
 {
     if ($this->checkDetails($request)) {
         $object = new Tax();
         $array = $object->getTaxes($request["restaurantID"]);
         return $array;
     }
 }
Exemple #4
0
 public function testGetAllTaxes()
 {
     $allTaxesCount = Tax::getTaxes()->getTotalRecordCount();
     $taxEnabled = Tax::getNewInstance('testing');
     $taxEnabled->save();
     $taxDisabled = Tax::getNewInstance('testing');
     $taxDisabled->save();
     $this->assertEqual(Tax::getTaxes()->getTotalRecordCount(), $allTaxesCount + 2);
 }
 public function __construct()
 {
     $this->className = 'Configuration';
     $this->table = 'configuration';
     parent::__construct();
     // List of CMS tabs
     $cms_tab = array(0 => array('id' => 0, 'name' => $this->l('None')));
     foreach (CMS::listCms($this->context->language->id) as $cms_file) {
         $cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
     }
     // List of order process types
     $order_process_type = array(array('value' => PS_ORDER_PROCESS_STANDARD, 'name' => $this->l('Standard (5 steps)')), array('value' => PS_ORDER_PROCESS_OPC, 'name' => $this->l('One page checkout')));
     // Tax list
     $taxes[] = array('id' => 0, 'name' => $this->l('None'));
     foreach (Tax::getTaxes($this->context->language->id) as $tax) {
         $taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
     }
     $this->fields_options = array('general' => array('title' => $this->l('General'), 'icon' => 'tab-preferences', 'fields' => array('PS_ORDER_PROCESS_TYPE' => array('title' => $this->l('Order process type'), 'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $order_process_type, 'identifier' => 'value'), 'PS_GUEST_CHECKOUT_ENABLED' => array('title' => $this->l('Enable guest checkout'), 'desc' => $this->l('Guests can place an order without registering'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_PURCHASE_MINIMUM' => array('title' => $this->l('Minimum purchase total required in order to validate order'), 'desc' => $this->l('Set to 0 to disable this feature'), 'validation' => 'isFloat', 'cast' => 'floatval', 'type' => 'price'), 'PS_ALLOW_MULTISHIPPING' => array('title' => $this->l('Allow multi-shipping'), 'desc' => $this->l('Allow the customer to ship his order to multiple addresses. This option will convert the customer\'s cart into one or more orders.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_SHIP_WHEN_AVAILABLE' => array('title' => $this->l('Delayed shipping'), 'desc' => $this->l('Allow the customer to split his order: one with the products currently "in stock", and another with the other products. This option will convert the customer\'s cart into two orders.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CONDITIONS' => array('title' => $this->l('Terms of service'), 'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'js' => array('on' => 'onchange="changeCMSActivationAuthorization()"', 'off' => 'onchange="changeCMSActivationAuthorization()"')), 'PS_CONDITIONS_CMS_ID' => array('title' => $this->l('Conditions of use CMS page'), 'desc' => $this->l('Choose the Conditions of use CMS page'), 'validation' => 'isInt', 'type' => 'select', 'list' => $cms_tab, 'identifier' => 'id', 'cast' => 'intval'))), 'gift' => array('title' => $this->l('Gift options'), 'icon' => 'tab-preferences', 'fields' => array('PS_GIFT_WRAPPING' => array('title' => $this->l('Offer gift-wrapping'), 'desc' => $this->l('Suggest gift-wrapping to customer and possibility of leaving a message'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_GIFT_WRAPPING_PRICE' => array('title' => $this->l('Gift-wrapping price'), 'desc' => $this->l('Set a price for gift-wrapping'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'price'), 'PS_GIFT_WRAPPING_TAX' => array('title' => $this->l('Gift-wrapping tax'), 'desc' => $this->l('Set a tax for gift-wrapping'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $taxes, 'identifier' => 'id'), 'PS_RECYCLABLE_PACK' => array('title' => $this->l('Offer recycled packaging'), 'desc' => $this->l('Suggest recycled packaging to customer'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')));
 }
function convert_product_price()
{
    $taxes = Tax::getTaxes();
    $taxRates = array();
    foreach ($taxes as $data) {
        $taxRates[$data['id_tax']] = (double) $data['rate'] / 100;
    }
    $resource = DB::getInstance()->ExecuteS('SELECT `id_product`, `price`, `id_tax` FROM `' . _DB_PREFIX_ . 'product`', false);
    while ($row = DB::getInstance()->nextRow($resource)) {
        if ($row['id_tax']) {
            $price = $row['price'] * (1 + $taxRates[$row['id_tax']]);
            $decimalPart = $price - (int) $price;
            if ($decimalPart < 1.0E-6) {
                $newPrice = (double) number_format($price, 6, '.', '');
                $newPrice = Tools::floorf($newPrice / (1 + $taxRates[$row['id_tax']]), 6);
                DB::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'product` SET `price` = ' . $newPrice . ' WHERE `id_product` = ' . (int) $row['id_product']);
            }
        }
    }
}
Exemple #7
0
 public function __construct()
 {
     global $cookie;
     $this->className = 'Configuration';
     $this->table = 'configuration';
     $tmz = Tools::getTimezones();
     $txs = Tax::getTaxes(intval($cookie->id_lang));
     $timezone = array();
     foreach ($tmz as $id => $name) {
         $timezone[] = array('id' => $id, 'name' => $name);
     }
     $taxes[] = array('id' => 0, 'name' => $this->l('None'));
     foreach ($txs as $tax) {
         $taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
     }
     $this->_fieldsGeneral = array('PS_BASE_URI' => array('title' => $this->l('PS directory:'), 'desc' => $this->l('Name of the PrestaShop directory on your Web server, bracketed by forward slashes (e.g., /shop/)'), 'validation' => 'isGenericName', 'type' => 'text', 'size' => 20, 'default' => '/'), 'PS_SHOP_ENABLE' => array('title' => $this->l('Enable Shop:'), 'desc' => $this->l('Activate or deactivate your shop. Deactivate your shop while you perform maintenance on it'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_MAINTENANCE_IP' => array('title' => $this->l('Maintenance IP:'), 'desc' => $this->l('IP address allowed to access the Front Office while the shop is disabled (e.g., 42.24.4.2)'), 'validation' => 'isGenericName', 'type' => 'text', 'size' => 15, 'default' => ''), 'PS_SSL_ENABLED' => array('title' => $this->l('Enable SSL'), 'desc' => $this->l('If your hosting provider allows SSL, you can activate SSL encryption (https://) for customer account identification and order processing'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_TOKEN_ENABLE' => array('title' => $this->l('Increase Front Office security'), 'desc' => $this->l('Enable or disable token on the Front Office in order to improve PrestaShop security'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL:'), 'desc' => $this->l('Enable only if your server allows URL rewriting (recommended)') . '<p class="hint clear" style="display: block;">' . $this->l('If you turn on this feature, you must') . ' <a href="?tab=AdminGenerator&token=' . Tools::getAdminToken('AdminGenerator' . intval(Tab::getIdFromClassName('AdminGenerator')) . intval($cookie->id_employee)) . '">' . $this->l('generate a .htaccess file') . '</a></p><div class="clear"></div>', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_HELPBOX' => array('title' => $this->l('Back Office help boxes:'), 'desc' => $this->l('Enable yellow help boxes which are displayed under form fields in the Back Office'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CONDITIONS' => array('title' => $this->l('Terms of service:'), 'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_GIFT_WRAPPING' => array('title' => $this->l('Offer gift-wrapping:'), 'desc' => $this->l('Suggest gift-wrapping to customer and possibility of leaving a message'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_GIFT_WRAPPING_PRICE' => array('title' => $this->l('Gift-wrapping price:'), 'desc' => $this->l('Set a price for gift-wrapping'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'price'), 'PS_GIFT_WRAPPING_TAX' => array('title' => $this->l('Gift-wrapping tax:'), 'desc' => $this->l('Set a tax for gift-wrapping'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $taxes, 'identifier' => 'id'), 'PS_RECYCLABLE_PACK' => array('title' => $this->l('Offer recycled packaging:'), 'desc' => $this->l('Suggest recycled packaging to customer'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CART_FOLLOWING' => array('title' => $this->l('Cart re-display at login:'******'desc' => $this->l('After customer logs in, recall and display contents of his/her last shopping cart'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'));
     if (function_exists('date_default_timezone_set')) {
         $this->_fieldsGeneral['PS_TIMEZONE'] = array('title' => $this->l('Timezone:'), 'validation' => 'isUnsignedId', 'cast' => 'intval', 'type' => 'select', 'list' => $timezone, 'identifier' => 'id');
     }
     parent::__construct();
 }
 public function __construct()
 {
     global $cookie;
     $this->className = 'Configuration';
     $this->table = 'configuration';
     $timezones = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT name FROM ' . _DB_PREFIX_ . 'timezone');
     $taxes[] = array('id' => 0, 'name' => $this->l('None'));
     foreach (Tax::getTaxes((int) $cookie->id_lang) as $tax) {
         $taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
     }
     $order_process_type = array(array('value' => PS_ORDER_PROCESS_STANDARD, 'name' => $this->l('Standard (5 steps)')), array('value' => PS_ORDER_PROCESS_OPC, 'name' => $this->l('One page checkout')));
     $round_mode = array(array('value' => PS_ROUND_UP, 'name' => $this->l('superior')), array('value' => PS_ROUND_DOWN, 'name' => $this->l('inferior')), array('value' => PS_ROUND_HALF, 'name' => $this->l('classical')));
     $cms_tab = array(0 => array('id' => 0, 'name' => $this->l('None')));
     foreach (CMS::listCms($cookie->id_lang) as $cms_file) {
         $cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
     }
     $this->_fieldsGeneral = array('PS_SHOP_ENABLE' => array('title' => $this->l('Enable Shop'), 'desc' => $this->l('Activate or deactivate your shop. Deactivate your shop while you perform maintenance on it. Please note that the webservice will not be disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_MAINTENANCE_IP' => array('title' => $this->l('Maintenance IP'), 'desc' => $this->l('IP addresses allowed to access the Front Office even if shop is disabled. Use a comma to separate them (e.g., 42.24.4.2,127.0.0.1,99.98.97.96)'), 'validation' => 'isGenericName', 'type' => 'text', 'size' => 15, 'default' => ''), 'PS_SSL_ENABLED' => array('title' => $this->l('Enable SSL'), 'desc' => $this->l('If your hosting provider allows SSL, you can activate SSL encryption (https://) for customer account identification and order processing'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_COOKIE_CHECKIP' => array('title' => $this->l('Check IP on the cookie'), 'desc' => $this->l('Check the IP address of the cookie in order to avoid your cookie being stolen'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_TOKEN_ENABLE' => array('title' => $this->l('Increase Front Office security'), 'desc' => $this->l('Enable or disable token on the Front Office in order to improve PrestaShop security'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'), 'PS_HELPBOX' => array('title' => $this->l('Back Office help boxes'), 'desc' => $this->l('Enable yellow help boxes which are displayed under form fields in the Back Office'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_ORDER_PROCESS_TYPE' => array('title' => $this->l('Order process type'), 'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $order_process_type, 'identifier' => 'value'), 'PS_GUEST_CHECKOUT_ENABLED' => array('title' => $this->l('Enable guest checkout'), 'desc' => $this->l('Your guest can make an order without registering'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CONDITIONS' => array('title' => $this->l('Terms of service'), 'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'js' => array('on' => 'onchange="changeCMSActivationAuthorization()"', 'off' => 'onchange="changeCMSActivationAuthorization()"')), 'PS_CONDITIONS_CMS_ID' => array('title' => $this->l('Conditions of use CMS page'), 'desc' => $this->l('Choose the Conditions of use CMS page'), 'validation' => 'isInt', 'type' => 'select', 'list' => $cms_tab, 'identifier' => 'id', 'cast' => 'intval'), 'PS_GIFT_WRAPPING' => array('title' => $this->l('Offer gift-wrapping'), 'desc' => $this->l('Suggest gift-wrapping to customer and possibility of leaving a message'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_GIFT_WRAPPING_PRICE' => array('title' => $this->l('Gift-wrapping price'), 'desc' => $this->l('Set a price for gift-wrapping'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'price'), 'PS_GIFT_WRAPPING_TAX' => array('title' => $this->l('Gift-wrapping tax'), 'desc' => $this->l('Set a tax for gift-wrapping'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $taxes, 'identifier' => 'id'), 'PS_ATTACHMENT_MAXIMUM_SIZE' => array('title' => $this->l('Attachment maximum size'), 'desc' => $this->l('Set the maximum size of attachment files (in MegaBytes)'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text'), 'PS_RECYCLABLE_PACK' => array('title' => $this->l('Offer recycled packaging'), 'desc' => $this->l('Suggest recycled packaging to customer'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CART_FOLLOWING' => array('title' => $this->l('Cart re-display at login'), 'desc' => $this->l('After customer logs in, recall and display contents of his/her last shopping cart'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_PRICE_ROUND_MODE' => array('title' => $this->l('Round mode'), 'desc' => $this->l('You can choose how to round prices: always round superior; always round inferior, or classic rounding'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $round_mode, 'identifier' => 'value'), 'PRESTASTORE_LIVE' => array('title' => $this->l('Automatically check for module updates'), 'desc' => $this->l('New modules and updates are displayed on the modules page'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_HIDE_OPTIMIZATION_TIPS' => array('title' => $this->l('Hide optimization tips'), 'desc' => $this->l('Hide optimization tips on the back office homepage'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_DISPLAY_SUPPLIERS' => array('title' => $this->l('Display suppliers and manufacturers'), 'desc' => $this->l('Display manufacturers and suppliers list even if corresponding blocks are disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_FORCE_SMARTY_2' => array('title' => $this->l('Use Smarty 2 instead of 3'), 'desc' => $this->l('Enable if your theme is incompatible with Smarty 3 (you should update your theme, since Smarty 2 will be unsupported from PrestaShop v1.5)'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'));
     if (function_exists('date_default_timezone_set')) {
         $this->_fieldsGeneral['PS_TIMEZONE'] = array('title' => $this->l('Time Zone:'), 'validation' => 'isAnything', 'type' => 'select', 'list' => $timezones, 'identifier' => 'name');
     }
     parent::__construct();
 }
    public function getAllTax()
    {
        $all_tax = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT `id_tax_eco`, `rate`
																	FROM  `' . _DB_PREFIX_ . 'ec_ecopresto_tax`');
        $response = '';
        $tax_PS = Tax::getTaxes(self::getInfoEco('ID_LANG'));
        foreach ($all_tax as $tax) {
            $tax_eco = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT id_tax_rules_group FROM `' . _DB_PREFIX_ . 'ec_ecopresto_tax_shop` WHERE `id_tax_eco`=' . (int) $tax['id_tax_eco'] . ' AND `id_shop`=' . (int) self::getInfoEco('ID_SHOP'));
            $response .= '<p>Tax EcoPresto :' . $tax['rate'] . ' =>';
            $response .= ' <select name="tax_ps[]">
							<option value="' . $tax['id_tax_eco'] . '_0"> 0 </option>';
            foreach ($tax_PS as $taxPS) {
                $response .= '<option value="' . $tax['id_tax_eco'] . '_' . $taxPS['id_tax'] . '" ' . ($tax_eco == $taxPS['id_tax'] ? 'selected="selected"' : '') . '>' . $taxPS['rate'] . '</option>';
            }
            $response .= '</select>';
        }
        return $response;
    }
Exemple #10
0
    public function displayForm()
    {
        global $currentIndex, $cookie;
        $obj = $this->loadObject(true);
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $currentLanguage = intval($cookie->id_lang);
        $languages = Language::getLanguages();
        echo '
		<script type="text/javascript">
			id_language = Number(' . $defaultLanguage . ');
		</script>
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset class="width3"><legend><img src="../img/admin/delivery.gif" />' . $this->l('Carriers') . '</legend>
				<label>' . $this->l('Company:') . ' </label>
				<div class="margin-form">
					<input type="text" size="25" name="name" value="' . htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Allowed characters: letters, spaces and') . ' ().-<span class="hint-pointer">&nbsp;</span></span>
					<p class="clear">' . $this->l('Carrier name displayed during checkout') . '<br />' . $this->l('With a value of 0, the carrier name will be replaced by the shop name') . '</p>
				</div>
				<label>' . $this->l('Logo:') . ' </label>
				<div class="margin-form">
					<input type="file" name="logo" />
					<p>' . $this->l('Upload logo from your computer') . ' (.gif, .jpg, .jpeg ' . $this->l('or') . ' .png)</p>
				</div>
				<label>' . $this->l('Transit time:') . ' </label>
				<div class="margin-form">';
        foreach ($languages as $language) {
            echo '
					<div id="delay_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" size="41" maxlength="128" name="delay_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'delay', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, 'delay', 'delay');
        echo '
					<p style="clear: both">' . $this->l('Time taken for product delivery; displayed during checkout') . '</p>
				</div>
				<label>' . $this->l('URL:') . ' </label>
				<div class="margin-form">
					<input type="text" size="40" name="url" value="' . htmlentities($this->getFieldValue($obj, 'url'), ENT_COMPAT, 'UTF-8') . '" />
					<p class="clear">' . $this->l('URL for the tracking number; type \'@\' where the tracking number will appear') . '</p>
				</div>
				<label>' . $this->l('Tax:') . '</label>
				<div class="margin-form">
					<select name="id_tax">
						<option value="0"' . (($obj->id and $obj->id_tax == 0) ? ' selected="selected"' : '') . '>' . $this->l('No tax') . '</option>';
        $tvaList = Tax::getTaxes($currentLanguage);
        foreach ($tvaList as $line) {
            echo '<option value="' . $line['id_tax'] . '"' . (($obj->id and $obj->id_tax == $line['id_tax']) ? ' selected="selected"' : '') . '>' . $line['name'] . '</option>';
        }
        echo '</select>
					<p>' . $this->l('Include tax on carrier, e.g., VAT') . '</p>
				</div>
				<label>' . $this->l('Zone:') . '</label>
				<div class="margin-form">';
        $carrier_zones = $obj->getZones();
        $zones = Zone::getZones(true);
        foreach ($zones as $zone) {
            echo '<input type="checkbox" id="zone_' . $zone['id_zone'] . '" name="zone_' . $zone['id_zone'] . '" value="true" ' . (Tools::getValue('zone_' . $zone['id_zone'], is_array($carrier_zones) and in_array(array('id_carrier' => $obj->id, 'id_zone' => $zone['id_zone']), $carrier_zones)) ? ' checked="checked"' : '') . '><label class="t" for="zone_' . $zone['id_zone'] . '">&nbsp;<b>' . $zone['name'] . '</b></label><br />';
        }
        echo '<p>' . $this->l('The zone in which this carrier is to be used') . '</p>
	</div>
				<label>' . $this->l('Group access:') . '</label>
				<div class="margin-form">';
        $groups = Group::getGroups(intval($cookie->id_lang));
        if (sizeof($groups)) {
            echo '
					<table cellspacing="0" cellpadding="0" class="table" style="width: 28em;">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)"' . (!isset($obj->id) ? 'checked="checked" ' : '') . ' /></th>
							<th>' . $this->l('ID') . '</th>
							<th>' . $this->l('Group name') . '</th>
						</tr>';
            $irow = 0;
            foreach ($groups as $group) {
                echo '
							<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
								<td><input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $group['id_group'] . '" value="' . $group['id_group'] . '" ' . ((Db::getInstance()->getValue('SELECT id_group FROM ' . _DB_PREFIX_ . 'carrier_group WHERE id_carrier=' . intval($obj->id) . ' AND id_group=' . intval($group['id_group'])) or !isset($obj->id)) ? 'checked="checked" ' : '') . '/></td>
								<td>' . $group['id_group'] . '</td>
								<td><label for="groupBox_' . $group['id_group'] . '" class="t">' . $group['name'] . '</label></td>
							</tr>';
            }
            echo '
					</table>
					<p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Mark all groups you want to give access to this carrier') . '</p>
					';
        } else {
            echo '<p>' . $this->l('No group created') . '</p>';
        }
        echo '				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Include or exclude carrier from list of carriers on Front Office') . '</p>
				</div>
				<label>' . $this->l('Shipping & handling:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="shipping_handling" id="shipping_handling_on" value="1" ' . ($this->getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="shipping_handling_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="shipping_handling" id="shipping_handling_off" value="0" ' . (!$this->getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="shipping_handling_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Include the shipping & handling costs in carrier price') . '</p>
				</div>
				<label>' . $this->l('Out-of-range behavior:') . ' </label>
				<div class="margin-form">
					<select name="range_behavior">
						<option value="0"' . (!$this->getFieldValue($obj, 'range_behavior') ? ' selected="selected"' : '') . '>' . $this->l('Apply the cost of the highest defined range') . '</option>
						<option value="1"' . ($this->getFieldValue($obj, 'range_behavior') ? ' selected="selected"' : '') . '>' . $this->l('Disable carrier') . '</option>
					</select>
					<p>' . $this->l('Out-of-range behavior when none is defined (e.g., when a customer\'s cart weight is superior to the highest range limit)') . '</p>
				</div>
				<label>' . $this->l('Module:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="is_module" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'is_module') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="is_module" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'is_module') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Mark this carrier as linked to a module') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
 private function getAvailableTaxesDetails()
 {
     $all_taxes = Tax::getTaxes();
     $return_array = array();
     foreach ($all_taxes as $tax) {
         $tax_obj = new Tax((int) $tax['id_tax']);
         $return_array[(int) $tax['id_tax']] = (string) $tax_obj->name[1];
         unset($tax_obj);
     }
     return $return_array;
 }
 function _getFees($conditions)
 {
     if (empty($conditions)) {
         return;
     }
     $this->FeeSlab->bindModel(array('belongsTo' => array('FrequencyType' => array('className' => 'FrequencyType', 'foreignKey' => '', 'conditions' => 'FeeSlab.frequency_id = FrequencyType.frequency_id', 'fields' => '', 'order' => ''))));
     $resFeeSlabs = $this->FeeSlab->find('all', array('conditions' => $conditions));
     App::import('Model', 'Tax');
     $objTax = new Tax();
     $resultTax = $objTax->getTaxes();
     $feeSlabs = array();
     $x = array();
     foreach ($resFeeSlabs as $k => $v) {
         if (!empty($v['FeeSlab']['entrance_fee'])) {
             $x['entrance_fee'] = $this->_getTaxOnAmt($resultTax, $v['FeeSlab']['entrance_fee']);
         }
         if (!empty($v['FeeSlab']['application_fee'])) {
             $x['application_fee'] = $this->_getTaxOnAmt($resultTax, $v['FeeSlab']['application_fee']);
         }
         $feeSlabs[] = $x;
     }
     return $feeSlabs;
 }
 protected function generateTaxData()
 {
     $delimiter = ';';
     $line = array();
     $titles = array();
     $new_path = new Sampledatainstall();
     $f = fopen($new_path->sendPath() . 'output/taxes.vsc', 'w');
     foreach ($this->tax_fields as $field => $array) {
         $titles[] = $array['label'];
     }
     fputcsv($f, $titles, $delimiter, '"');
     $taxes = Tax::getTaxes();
     if ($taxes) {
         foreach ($taxes as $tax) {
             $t = new Tax($tax['id_tax'], $this->use_lang);
             foreach ($this->tax_fields as $field => $array) {
                 $line[$field] = property_exists('Tax', $field) && !is_array($t->{$field}) && !Tools::isEmpty($t->{$field}) ? $t->{$field} : '';
             }
             if (!$line[$field]) {
                 $line[$field] = '';
             }
             fputcsv($f, $line, $delimiter, '"');
         }
     }
     fclose($f);
 }
    public function initRuleForm()
    {
        $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('New tax rule'), 'image' => '../img/admin/dollar.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'country[]', 'id' => 'country', 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('All')))), array('type' => 'select', 'label' => $this->l('State:'), 'name' => 'states[]', 'id' => 'states', 'multiple' => true, 'size' => 5, 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('All')))), array('type' => 'hidden', 'name' => 'action'), array('type' => 'hidden', 'name' => 'id_tax_rules_group'), array('type' => 'text', 'label' => $this->l('Zip Code range:'), 'name' => 'zipcode', 'required' => false, 'hint' => $this->l('You can define a range (eg: 75000-75015) or a simple zipcode')), array('type' => 'select', 'label' => $this->l('Behavior:'), 'name' => 'behavior', 'required' => false, 'options' => array('query' => array(array('id' => 0, 'name' => $this->l('This tax only')), array('id' => 1, 'name' => $this->l('Combine')), array('id' => 2, 'name' => $this->l('One After Another'))), 'id' => 'id', 'name' => 'name'), 'hint' => $this->l('Define the behavior if an address matches multiple rules:') . '<br />
						<b>' . $this->l('This Tax Only:') . '</b> ' . $this->l('Will apply only this tax') . '<br />
						<b>' . $this->l('Combine:') . '</b> ' . $this->l('Combine taxes (eg: 10% + 5% => 15%)') . '<br />
						<b>' . $this->l('One After Another:') . '</b> ' . $this->l('Apply taxes one after another (eg: 100€ + 10% => 110€ + 5% => 115.5€)')), array('type' => 'select', 'label' => $this->l('Tax:'), 'name' => 'id_tax', 'required' => false, 'options' => array('query' => Tax::getTaxes((int) $this->context->language->id), 'id' => 'id_tax', 'name' => 'name', 'default' => array('value' => 'name', 'label' => $this->l('No Tax'))), 'desc' => sprintf($this->l('(Total tax: %s)'), '9%')), array('type' => 'text', 'label' => $this->l('Description:'), 'name' => 'description', 'size' => 40)), 'submit' => array('title' => $this->l('Save and stay'), 'class' => 'button', 'stay' => true));
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $this->fields_value = array('action' => 'create_rule', 'id_tax_rules_group' => $obj->id, 'id_tax_rule' => '');
        $this->getlanguages();
        $helper = new HelperForm();
        $helper->override_folder = $this->tpl_folder;
        $helper->currentIndex = self::$currentIndex;
        $helper->token = $this->token;
        $helper->table = 'tax_rule';
        $helper->identifier = 'id_tax_rule';
        $helper->id = $obj->id;
        $helper->toolbar_scroll = true;
        $helper->show_toolbar = false;
        $helper->languages = $this->_languages;
        $helper->default_form_language = $this->default_form_language;
        $helper->allow_employee_form_lang = $this->allow_employee_form_lang;
        $helper->fields_value = $this->getFieldsValue($this->object);
        $helper->toolbar_btn = null;
        $helper->submit_action = 'create_rule';
        return $helper->generateForm($this->fields_form);
    }
    public function renderTaxesSelect($id_lang, $default_value, $html_options)
    {
        $opt = '';
        foreach (array('id', 'class', 'name', 'disabled') as $prop) {
            if (array_key_exists($prop, $html_options) && !empty($html_options[$prop])) {
                $opt .= $prop . '="' . $html_options[$prop] . '"';
            }
        }
        $html = '<select ' . $opt . '>
					<option value="0">' . $this->l('No Tax') . '</option>';
        $taxes = Tax::getTaxes((int) $id_lang, true);
        foreach ($taxes as $tax) {
            $selected = $default_value == $tax['id_tax'] ? 'selected="selected"' : '';
            $html .= '<option value="' . (int) $tax['id_tax'] . '" ' . $selected . '>' . Tools::htmlentitiesUTF8($tax['name']) . '</option>';
        }
        $html .= '</select>';
        return $html;
    }
 /**
  * @param $module
  * @return array
  */
 protected static function getProductTaxClasses($module)
 {
     $productTaxClassItems = Tax::getTaxes($module->context->language->id);
     $productTaxClasses = array();
     if (is_array($productTaxClassItems) && Configuration::get('PS_TAX') == 1) {
         foreach ($productTaxClassItems as $productTaxClassItem) {
             $taxClass = array();
             $taxClass['id'] = $productTaxClassItem['id_tax'];
             $taxClass['key'] = $productTaxClassItem['name'];
             $productTaxClasses[] = $taxClass;
         }
     }
     return $productTaxClasses;
 }
    function displayFormInformations($obj, $currency, $languages, $defaultLanguage)
    {
        global $currentIndex, $cookie;
        $iso = Language::getIsoById(intval($cookie->id_lang));
        $divLangName = 'cname¤cdesc¤cdesc_short¤clink_rewrite¤cmeta_description¤cmeta_title¤cmeta_keywords¤ctags¤cavailable_now¤cavailable_later';
        $qty_state = 'readonly';
        $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product'));
        if ($qty === false) {
            if (Validate::isLoadedObject($obj)) {
                $qty = $this->getFieldValue($obj, 'quantity');
            } else {
                $qty = 1;
            }
            $qty_state = '';
        }
        $cover = Product::getCover($obj->id);
        $link = new Link();
        //includeDatepicker(array('reduction_from', 'reduction_to'));
        echo '
		<div class="tab-page" id="step1">
			<h4 class="tab">1. ' . $this->l('Info.') . '</h4>
			<b>' . $this->l('Product global informations') . '</b>&nbsp;-&nbsp;';
        if (isset($obj->id)) {
            echo '
			<a href="' . $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $defaultLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), intval($cookie->id_lang))) . '"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>';
            if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) {
                echo '&nbsp;-&nbsp;
					<a href="index.php?tab=AdminStatsModules&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStatsModules' . intval(Tab::getIdFromClassName('AdminStatsModules')) . intval($cookie->id_employee)) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>';
            }
        }
        echo '	
			<hr class="clear"/>
			<br />
				<table cellpadding="5" style="width:100%">
					<tr>
						<td class="col-left">' . $this->l('Name:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '			<div id="cname_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
								<input size="55" type="text" id="name_' . $language['id_lang'] . '" name="name_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlspecialchars($this->getFieldValue($obj, 'name', $language['id_lang']))) . '"' . (!$obj->id ? ' onkeyup="copy2friendlyURL();"' : '') . ' onchange="updateCurrentText();" /><sup> *</sup>
								<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cname');
        echo '<script type="text/javascript">updateCurrentText();</script>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top">' . $this->l('Status:') . '</td>
						<td style="padding-bottom:5px;">
							<input style="float:left;" type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
							<label for="active_on" class="t"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" style="float:left; padding:0px 5px 0px 5px;" />' . $this->l('Enabled') . '</label>
							<br style="clear:both;" />
							<input style="float:left;" type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
							<label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('Disabled') . '</label>
						</td>
					</tr>
					<tr>
						<td>' . $this->l('Manufacturer:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="id_manufacturer" id="id_manufacturer">
								<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
        if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) {
            echo '				<option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option>
								<option disabled="disabled">----------</option>';
        }
        echo '
							</select>&nbsp;&nbsp;&nbsp;<a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . intval(Tab::getIdFromClassName('AdminManufacturers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
							<script type="text/javascript">
								var ajaxManufacturersClicked = false;
								$("select#id_manufacturer").focus(
									function() {
										if (ajaxManufacturersClicked == true) return; else ajaxManufacturersClicked = true;
										$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductManufacturers:1},
											function(j) {
												var options = \'\';
												for (var i = 0; i < getE("id_manufacturer").options.length; i++)
												{
													if (getE("id_manufacturer").options[i].innerHTML == \'----------\')
														options += \'<option disabled="disabled">----------</option>\';
													else
														options += \'<option value="\' +  getE("id_manufacturer").options[i].value + \'">\' + getE("id_manufacturer").options[i].innerHTML + \'</option>\';
												}
												for (var i = 0; i < j.length; i++)
													options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
												$("select#id_manufacturer").html(options);
											}
										)
									}
								);
							</script>
						</td>
					</tr>
					<tr>
						<td>' . $this->l('Supplier:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="id_supplier" id="id_supplier">
								<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
        if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) {
            echo '				<option value="' . $id_supplier . '" selected="selected">' . Supplier::getNameById($id_supplier) . '</option>
								<option disabled="disabled">----------</option>';
        }
        echo '
							</select>&nbsp;&nbsp;&nbsp;<a href="?tab=AdminSuppliers&addsupplier&token=' . Tools::getAdminToken('AdminSuppliers' . intval(Tab::getIdFromClassName('AdminSuppliers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
							<script type="text/javascript">
								var ajaxSuppliersClicked = false;
								$("select#id_supplier").focus(
									function() {
										if (ajaxSuppliersClicked == true) return; else ajaxSuppliersClicked = true;
										$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductSuppliers:1},
											function(j) {
												var options = \'\';
												for (var i = 0; i < getE("id_supplier").options.length; i++)
												{
													if (getE("id_supplier").options[i].innerHTML == \'----------\')
														options += \'<option disabled="disabled">----------</option>\';
													else
														options += \'<option value="\' +  getE("id_supplier").options[i].value + \'">\' + getE("id_supplier").options[i].innerHTML + \'</option>\';
												}
												for (var i = 0; i < j.length; i++)
													options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
												$("select#id_supplier").html(options);
											}
										)
									}
								);
							</script>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Reference:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="reference" value="' . htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
							' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" name="ean13" value="' . $this->getFieldValue($obj, 'ean13') . '" style="width: 110px; margin-left: 10px;" />
							<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer">&nbsp;</span></span>
						</td>
					</tr>
                	<tr>
						<td class="col-left">' . $this->l('Supplier Reference:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="supplier_reference" value="' . htmlentities($this->getFieldValue($obj, 'supplier_reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
							' . $this->l('Location:') . '<input size="55" type="text" name="location" value="' . $this->getFieldValue($obj, 'location') . '" style="width: 101px; margin-left: 10px;" />
							<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer">&nbsp;</span></span>
						</td>
					</tr>					
					<tr>
						<td class="col-left">' . $this->l('Weight:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="weight" type="text" value="' . htmlentities($this->getFieldValue($obj, 'weight'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '
						</td>
					</tr>
					<tr><td colspan="2"><hr style="width:730px;"></td></tr>';
        $this->displayPack($obj);
        echo '		<tr><td colspan="2"><hr style="width:730px;"></td></tr>';
        /*
         * Form for add a virtual product like software, mp3, etc...
         */
        $productDownload = new ProductDownload();
        if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) {
            $productDownload = new ProductDownload($id_product_download);
        }
        ?>
    <script type="text/javascript">
    // <![CDATA[
    	ThickboxI18nImage = '<?php 
        echo $this->l('Image');
        ?>
';
    	ThickboxI18nOf = '<?php 
        echo $this->l('of');
        ?>
';;
    	ThickboxI18nClose = '<?php 
        echo $this->l('Close');
        ?>
';
    	ThickboxI18nOrEscKey = '<?php 
        echo $this->l('(or "Esc")');
        ?>
';
    	ThickboxI18nNext = '<?php 
        echo $this->l('Next >');
        ?>
';
    	ThickboxI18nPrev = '<?php 
        echo $this->l('< Previous');
        ?>
';
    	tb_pathToImage = '../img/loadingAnimation.gif';
    //]]>
    </script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
jquery/thickbox-modified.js"></script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
jquery/ajaxfileupload.js"></script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
date.js"></script>
	<style type="text/css">
		<!--
		@import url(<?php 
        echo _PS_CSS_DIR_;
        ?>
thickbox.css);
		-->
	</style>
	<script type="text/javascript">
	<!--	
	function toggleVirtualProduct(elt)
	{
		if (elt.checked)
		{
			$('#virtual_good').show('slow');
			getE('out_of_stock_1').checked = 'checked';
			getE('out_of_stock_2').readOnly = true;
			getE('out_of_stock_3').readOnly = true;
			getE('label_out_of_stock_2').setAttribute('for', '');
			getE('label_out_of_stock_3').setAttribute('for', '');
		}
		else
		{
			$('#virtual_good').hide('slow');
			getE('out_of_stock_2').readOnly = false;
			getE('out_of_stock_3').readOnly = false;
			getE('label_out_of_stock_2').setAttribute('for', 'out_of_stock_2');
			getE('label_out_of_stock_3').setAttribute('for', 'out_of_stock_3');
		}
	}
	function uploadFile()
	{
		$.ajaxFileUpload (
			{
				url:'./uploadProductFile.php',
				secureuri:false,
				fileElementId:'virtual_product_file',
				dataType: 'xml',

				success: function (data, status)
				{
					data = data.getElementsByTagName('return')[0];
					var result = data.getAttribute("result");
					var msg = data.getAttribute("msg");
					var fileName = data.getAttribute("filename");

					if(result == "error")
					{
						$("#upload-confirmation").html('<p>error: ' + msg + '</p>');
					}
					else
					{
						$('#virtual_product_file').remove();
						$('#virtual_product_file_label').hide();
						$('#virtual_product_name').attr('value', fileName);
						$('#upload-confirmation').html(
							'<a class="link" href="get-file-admin.php?file=' + msg + '"><?php 
        echo $this->l('The file');
        ?>
&nbsp;"' + fileName + '"&nbsp;<?php 
        echo $this->l('has successfully been uploaded');
        ?>
</a>' +
							'<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />');
					}
				}
			}
		);
	}

	-->
	</script>
	<?php 
        echo '
		<script type="text/javascript">
			var newLabel = \'' . $this->l('New label') . '\';
			var choose_language = \'' . $this->l('Choose language:') . '\';
			var required = \'' . $this->l('required') . '\';
			var customizationUploadableFileNumber = ' . intval($this->getFieldValue($obj, 'uploadable_files')) . ';
			var customizationTextFieldNumber = ' . intval($this->getFieldValue($obj, 'text_fields')) . ';
			var uploadableFileLabel = 0;
			var textFieldLabel = 0;
			var defaultLanguage = ' . intval($defaultLanguage) . ';
			var languages = new Array();';
        $i = 0;
        foreach ($languages as $language) {
            echo 'languages[' . $i++ . '] = new Array(' . intval($language['id_lang']) . ', \'' . $language['iso_code'] . '\', \'' . htmlentities($language['name'], ENT_COMPAT, 'UTF-8') . '\');' . "\n";
        }
        echo '
		</script>';
        ?>
	<tr>
		<td colspan="2">
			<input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onchange="toggleVirtualProduct(this)" onclick="toggleVirtualProduct(this);" <?php 
        if (($productDownload->id or Tools::getValue('is_virtual_good') == 'true') and $productDownload->active) {
            echo 'checked="checked"';
        }
        ?>
 />
			<label for="is_virtual_good" class="t bold"><?php 
        echo $this->l('Is this a downloadable product?');
        ?>
</label>
			<div id="virtual_good" <?php 
        if (!$productDownload->id or !$productDownload->active) {
            echo 'style="display:none;"';
        }
        ?>
 >
	<?php 
        if (!ProductDownload::checkWritableDir()) {
            ?>
		<p class="alert">
			<?php 
            echo $this->l('Your download repository is not writable.');
            ?>
<br/>
			<?php 
            echo realpath(_PS_DOWNLOAD_DIR_);
            ?>
		</p>
	<?php 
        } else {
            ?>
			<?php 
            if ($productDownload->id) {
                echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="' . $productDownload->id . '" />';
            }
            ?>
				<p class="block">
	<?php 
            if (!$productDownload->checkFile()) {
                ?>
		<?php 
                if ($productDownload->id) {
                    ?>
					<p class="alert">
						<?php 
                    echo $this->l('This product is missing');
                    ?>
:<br/>
						<?php 
                    echo realpath(_PS_DOWNLOAD_DIR_) . '/' . $productDownload->physically_filename;
                    ?>
					</p>
		<?php 
                }
                ?>
					<p><?php 
                echo $this->l('Your server\'s maximum upload file size is') . ':&nbsp;' . ini_get('upload_max_filesize');
                ?>
</p>
					<?php 
                if (!strval(Tools::getValue('virtual_product_filename'))) {
                    ?>
					<label id="virtual_product_file_label" for="virtual_product_file" class="t"><?php 
                    echo $this->l('Upload a file');
                    ?>
</label>
					<input type="file" id="virtual_product_file" name="virtual_product_file" value="" class="" onchange="uploadFile()" maxlength="<?php 
                    echo $this->maxFileSize;
                    ?>
" />
					<?php 
                }
                ?>
					<div id="upload-confirmation">
					<?php 
                if ($up_filename = strval(Tools::getValue('virtual_product_filename'))) {
                    ?>
						<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php 
                    echo $up_filename;
                    ?>
" />
					<?php 
                }
                ?>
					</div>
	<?php 
            } else {
                ?>
					<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php 
                echo $productDownload->physically_filename;
                ?>
" />
					<?php 
                echo $this->l('This is the link') . ':&nbsp;' . $productDownload->getHtmlLink(false, true);
                ?>
					<a href="confirm.php?height=200&amp;width=300&amp;modal=true&amp;referer=<?php 
                echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true');
                ?>
" class="thickbox red" title="<?php 
                echo $this->l('Delete this file');
                ?>
"><?php 
                echo $this->l('Delete this file');
                ?>
</a>
	<?php 
            }
            // check if file exists
            ?>
				</p>
				<p class="block">
					<label for="virtual_product_name" class="t"><?php 
            echo $this->l('Filename');
            ?>
</label>
					<input type="text" id="virtual_product_name" name="virtual_product_name" class="" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
            ?>
" />
					<span class="hint" name="help_box" style="display:none;"><?php 
            echo $this->l('The complete filename with its extension (e.g., Our best song.mp3)');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_nb_downloable" class="t"><?php 
            echo $this->l('Number of downloads');
            ?>
</label>
					<input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8');
            ?>
" class="" size="6" />
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('Number of authorized downloads per customer');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_expiration_date" class="t"><?php 
            echo $this->l('Expiration date');
            ?>
</label>
					<input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="<?php 
            echo $productDownload->id > 0 ? (!empty($productDownload->date_expiration) and $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8');
            ?>
" size="11" maxlength="10" autocomplete="off" /> <?php 
            echo $this->l('Format: YYYY-MM-DD');
            ?>
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('No expiration date if you leave this blank');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_nb_days" class="t"><?php 
            echo $this->l('Number of days');
            ?>
</label>
					<input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8');
            ?>
" class="" size="4" /><sup> *</sup>
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('How many days this file can be accessed by customers');
            ?>
</span>
				</p>
	<?php 
        }
        // check if download directory is writable
        ?>
			</div>
		</td>
	</tr>
	<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
	<script type="text/javascript">
		if ($('#is_virtual_good').attr('checked'))
			$('#virtual_good').show('slow');
	</script>

<?php 
        echo '
					<tr>
						<td class="col-left">' . $this->l('Pre-tax wholesale price:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" name="wholesale_price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'wholesale_price'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">' . $this->l('The wholesale price at which you bought this product') . '</span>
						</td>
					</tr>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Pre-tax retail price:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="' . $this->getFieldValue($obj, 'price') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); calcPriceTI();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '<sup> *</sup>
							<span style="margin-left:2px">' . $this->l('The pre-tax retail price to sell this product') . '</span>
						</td>
					</tr>';
        $taxes = Tax::getTaxes(intval($cookie->id_lang));
        echo '<script type="text/javascript">';
        echo 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false'), ";\n";
        echo 'taxesArray = new Array ();' . "\n";
        echo 'taxesArray[0] = 0', ";\n";
        foreach ($taxes as $k => $tax) {
            echo 'taxesArray[' . $tax['id_tax'] . ']=' . $tax['rate'] . "\n";
        }
        echo '
					</script>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Tax:') . '</td>
						<td style="padding-bottom:5px;">
							<select onChange="javascript:calcPriceTI();" name="id_tax" id="id_tax" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '>
								<option value="0"' . ($this->getFieldValue($obj, 'id_tax') == 0 ? ' selected="selected"' : '') . '>' . $this->l('No tax') . '</option>';
        foreach ($taxes as $k => $tax) {
            echo '
								<option value="' . $tax['id_tax'] . '"' . ($this->getFieldValue($obj, 'id_tax') == $tax['id_tax'] ? ' selected="selected"' : '') . '>' . stripslashes($tax['name']) . ' (' . $tax['rate'] . '%)</option>';
        }
        echo '
							</select>';
        if (Tax::excludeTaxeOption()) {
            echo '<span style="margin-left:10px; color:red;">' . $this->l('Taxes are currently disabled') . '</span> (<b><a href="index.php?tab=AdminTaxes&token=' . Tools::getAdminToken('AdminTaxes' . intval(Tab::getIdFromClassName('AdminTaxes')) . intval($cookie->id_employee)) . '">' . $this->l('Tax options') . '</a></b>)';
            echo '<input type="hidden" value="' . intval($this->getFieldValue($obj, 'id_tax')) . '" name="id_tax" />';
        }
        echo '</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Retail price with tax:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="priceTI" type="text" value="" onKeyUp="noComma(\'priceTI\'); calcPriceTE();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Eco-tax:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="' . $this->getFieldValue($obj, 'ecotax') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); if (parseInt(this.value) > getE(\'priceTE\').value) this.value = getE(\'priceTE\').value; if (isNaN(this.value)) this.value = 0;" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">(' . $this->l('already included in price') . ')</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Reduction amount:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? ' ' . $currency->sign . ' ' : '') . '<input size="11" maxlength="14" type="text" name="reduction_price" id="reduction_price" value="' . $this->getFieldValue($obj, 'reduction_price') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPrice();" /> ' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="padding-right: 15px; padding-left: 15px; font-weight: bold">' . $this->l('OR') . '</span>
							<input size="10" maxlength="14" type="text" name="reduction_percent" id="reduction_percent" value="' . $this->getFieldValue($obj, 'reduction_percent') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPercent();" /> %
						</td>
					</tr>
					<tr>
						<td class="col-left">&nbsp;</td>
						<td>' . $this->l('available from') . ' <input type="text" id="reduction_from" name="reduction_from" value="' . (($from = $this->getFieldValue($obj, 'reduction_from') and $from != '0000-00-00' and $from != '1942-01-01') ? $from : date('Y-m-d')) . '" />
							' . $this->l('to') . ' <input type="text" id="reduction_to" name="reduction_to" value="' . (($to = $this->getFieldValue($obj, 'reduction_to') and $to != '0000-00-00' and $to != '1942-01-01') ? $to : date('Y-m-d')) . '" />
							<p>' . $this->l('Leave same dates for undefined duration') . '</p>
						</td>
					</tr>
					<tr>
						<td class="col-left">&nbsp;</td>
						<td style="padding-bottom:5px;">
							<input type="checkbox" name="on_sale" id="on_sale" style="padding-top: 5px;" ' . ($this->getFieldValue($obj, 'on_sale') ? 'checked="checked"' : '') . 'value="1" />&nbsp;<label for="on_sale" class="t">' . $this->l('Display "on sale" icon on product page and text on product listing') . '</label>
						</td>
					</tr>
					<tr>
						<td class="col-left"><b>' . $this->l('Final retail price:') . '</b></td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<span id="finalPrice" style="font-weight: bold;"></span>' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td class="col-left">' . $this->l('Quantity:') . '</td>
						<td style="padding-bottom:5px;"><input size="3" maxlength="6" ' . $qty_state . ' name="quantity" type="text" value="' . $qty . '" ' . ((isset($_POST['attQty']) and $_POST['attQty']) ? 'onclick="alert(\'' . $this->l('Quantity is already defined by Attributes') . '.<br />' . $this->l('Delete attributes first') . '.\');" readonly="readonly" ' : '') . '/><sup> *</sup>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when in-stock:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cavailable_now_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
								<input size="30" type="text" id="available_now_' . $language['id_lang'] . '" name="available_now_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_now', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" />
								<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_now');
        echo '			</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when allowed to be back-ordered:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cavailable_later_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
								<input size="30" type="text" id="available_later_' . $language['id_lang'] . '" name="available_later_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_later', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" />
								<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_later');
        echo '			</td>
					</tr>

					<script type="text/javascript" src="../js/price.js"></script>
					<script type="text/javascript">
						calcPriceTI();
					</script>

					<tr>
						<td class="col-left">' . $this->l('When out of stock:') . '</td>
						<td style="padding-bottom:5px;">
							<input type="radio" name="out_of_stock" id="out_of_stock_1" value="0" ' . (intval($this->getFieldValue($obj, 'out_of_stock')) == 0 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_1" class="t" id="label_out_of_stock_1">' . $this->l('Deny orders') . '</label>
							<br /><input type="radio" name="out_of_stock" id="out_of_stock_2" value="1" ' . ($this->getFieldValue($obj, 'out_of_stock') == 1 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_2" class="t" id="label_out_of_stock_2">' . $this->l('Allow orders') . '</label>
							<br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" ' . ($this->getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_3" class="t" id="label_out_of_stock_3">' . $this->l('Default:') . ' <i>' . $this->l(intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')) ? 'Allow orders' : 'Deny orders') . '</i> (' . $this->l('as set in') . ' <a href="index.php?tab=AdminPPreferences&token=' . Tools::getAdminToken('AdminPPreferences' . intval(Tab::getIdFromClassName('AdminPPreferences')) . intval($cookie->id_employee)) . '"  onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');">' . $this->l('Preferences') . '</a>)</label>
						</td>
					</tr>

					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td class="col-left"><label for="id_category_default" class="t">' . $this->l('Default category:') . '</label></td>
						<td>
							<select id="id_category_default" name="id_category_default" onchange="checkDefaultCategory(this.value);">';
        $categories = Category::getCategories(intval($cookie->id_lang), false);
        Category::recurseCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_category_default') ? $this->getFieldValue($obj, 'id_category_default') : Tools::getValue('id_category', 1));
        echo '
							</select>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Catalog:') . '</td>
						<td>
							<div style="overflow: auto; min-height: 300px; padding-top: 0.6em;" id="categoryList">
							<table cellspacing="0" cellpadding="0" class="table">
									<tr>
										<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th>
										<th>' . $this->l('ID') . '</th>
										<th style="width: 400px">' . $this->l('Name') . '</th>
									</tr>';
        $done = array();
        $index = array();
        $indexedCategories = isset($_POST['categoryBox']) ? $_POST['categoryBox'] : ($obj->id ? Product::getIndexedCategories($obj->id) : array());
        foreach ($indexedCategories as $k => $row) {
            $index[] = $row['id_category'];
        }
        $this->recurseCategoryForInclude($index, $categories, $categories[0][1], 1, $obj->id_category_default);
        echo '
							</table>
							<p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of categories in which product is to appear') . '<sup> *</sup></p>
							</div>
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr><td colspan="2">
						<span onclick="javascript:openCloseLayer(\'seo\');" style="cursor: pointer"><img src="../img/admin/arrow.gif" alt="' . $this->l('SEO') . '" title="' . $this->l('SEO') . '" style="float:left; margin-right:5px;"/>' . $this->l('Click here to improve product\'s rank in search engines (SEO)') . '</span><br />
						<div id="seo" style="display: none; padding-top: 15px;">
							<table>
								<tr>
									<td class="col-left">' . $this->l('Meta title:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="cmeta_title_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_title_' . $language['id_lang'] . '" name="meta_title_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_title');
        echo '
										<p style="clear: both">' . $this->l('Product page title; leave blank to use product name') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Meta description:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="cmeta_description_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_description_' . $language['id_lang'] . '" name="meta_description_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_description', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_description');
        echo '
										<p style="clear: both">' . $this->l('A single sentence for HTML header') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Meta keywords:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="cmeta_keywords_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_keywords_' . $language['id_lang'] . '" name="meta_keywords_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_keywords', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_keywords');
        echo '
										<p style="clear: both">' . $this->l('Keywords for HTML header, separated by a comma') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Friendly URL:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="clink_rewrite_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="link_rewrite_' . $language['id_lang'] . '" name="link_rewrite_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'link_rewrite', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" onkeyup="this.value = str2url(this.value); updateFriendlyURL();" /><sup> *</sup>
											<span class="hint" name="help_box">' . $this->l('Only letters and the "less" character are allowed') . '<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'clink_rewrite');
        global $cookie;
        $iso = Language::getIsoById(intval($cookie->id_lang));
        echo '
										<p style="clear: both; width: 360px; word-wrap: break-word; overflow: auto;">' . $this->l('Product link will look like this:') . ' ' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/id_product-<span id="friendly-url"></span>.html</p>
									</td>
								</tr>
								<script type="text/javascript">updateFriendlyURL();</script>';
        echo '</td></tr></table>
						</div>
					</td></tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td class="col-left">' . $this->l('Short description:') . '<br /><br /><i>(' . $this->l('appears in search results') . ')</i></td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cdesc_short_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">
								<textarea class="rte" cols="100" rows="10" id="description_short_' . $language['id_lang'] . '" name="description_short_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description_short', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc_short');
        echo '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Description:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cdesc_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">
								<textarea class="rte" cols="100" rows="20" id="description_' . $language['id_lang'] . '" name="description_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc');
        echo '
						</td>
					</tr>';
        echo '<tr><td class="col-left">' . $this->l('Tags:') . '</td><td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '<div id="ctags_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
							<input size="55" type="text" id="tags_' . $language['id_lang'] . '" name="tags_' . $language['id_lang'] . '"
							value="' . htmlentities(Tools::getValue('tags_' . $language['id_lang'], $obj->getTags($language['id_lang'], true)), ENT_COMPAT, 'UTF-8') . '" />
							<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' !<>;?=+#"&deg;{}_$%<span class="hint-pointer">&nbsp;</span></span>
						  </div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'ctags');
        echo '<p style="clear: both">' . $this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)') . '</p>';
        echo '</td>
					</tr>';
        $accessories = Product::getAccessoriesLight(intval($cookie->id_lang), $obj->id);
        if ($postAccessories = Tools::getValue('inputAccessories')) {
            $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories'));
            foreach ($postAccessoriesTab as $accessoryId) {
                if (!$this->haveThisAccessory($accessoryId, $accessories) and $accessory = Product::getAccessoryById($accessoryId)) {
                    $accessories[] = $accessory;
                }
            }
        }
        echo '
					<tr>
						<td class="col-left">' . $this->l('Accessories:') . '<br /><br /><i>' . $this->l('(Do not forget to Save the product afterward)') . '</i></td>
						<td style="padding-bottom:5px;">
							<div id="divAccessories">';
        foreach ($accessories as $accessory) {
            echo $accessory['name'] . '<span onclick="delAccessory(' . $accessory['id_product'] . ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />';
        }
        echo '</div>
							<input type="hidden" name="inputAccessories" id="inputAccessories" value="';
        foreach ($accessories as $accessory) {
            echo $accessory['id_product'] . '-';
        }
        echo '" />
							<input type="hidden" name="nameAccessories" id="nameAccessories" value="';
        foreach ($accessories as $accessory) {
            echo $accessory['name'] . '¤';
        }
        echo '" />
							<script type="text/javascript">
								var formProduct;
								var accessories = new Array();
								
								function fillAccessories()
								{
									$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductAccessories:1,id_lang:' . intval($cookie->id_lang) . ',id_product:' . ($obj->id ? intval($obj->id) : 0) . '},
										function(j)
										{
											for (var i = 0; i < j.length; i++)
												accessories[i] = new Array(j[i].value, j[i].text);
												
											formProduct = document.layers ? document.forms.product : document.product;
											formProduct.selectAccessories.length = accessories.length + 1;
											for (i = 0, j = 1; i < accessories.length; i++)
											{
												if (formProduct.filter.value)
													if (accessories[i][1].toLowerCase().indexOf(formProduct.filter.value.toLowerCase()) == -1)
														continue;
												formProduct.selectAccessories.options[j].value = accessories[i][0];
												formProduct.selectAccessories.options[j].text = accessories[i][1];
												j++;
											}
											if (j == 1)
											{
												formProduct.selectAccessories.length = 2;
												formProduct.selectAccessories.options[1].value = -1;
												formProduct.selectAccessories.options[1].text = \'' . $this->l('No match found') . '\';
												formProduct.selectAccessories.options.selectedIndex = 1;
											}
											else
											{
												formProduct.selectAccessories.length = j;
												formProduct.selectAccessories.options.selectedIndex = (formProduct.filter.value == \'\' ? 0 : 1);
											}
										}
									);
								}
							</script>
							<select id="selectAccessories" name="selectAccessories" style="width: 380px;">
								<option value="0" selected="selected">-- ' . $this->l('Choose') . ' --</option>
							</select>
							<script type="text/javascript">
								fillAccessories();
							</script>
							<span onclick="addAccessory();" style="cursor: pointer;"><img src="../img/admin/add.gif" alt="' . $this->l('Add an accessory') . '" title="' . $this->l('Add an accessory') . '" /></span>
							<br />' . $this->l('Filter:') . ' <input type="text" size="25" name="filter" onkeyup="fillAccessories();" class="space" />
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:10px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td colspan="2" style="text-align:center;">
							<input type="submit" value="' . $this->l('Save') . '" name="submitAdd' . $this->table . '" class="button" />
							&nbsp;<input type="submit" value="' . $this->l('Save and stay') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /></td>
					</tr>
				</table>
			</div>

			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
			<script type="text/javascript">
			function tinyMCEInit(element)
			{
				$().ready(function() {
					$(element).tinymce({
						// Location of TinyMCE script
						script_url : \'' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/tiny_mce.js\',
						// General options
						theme : "advanced",
						plugins : "safari,pagebreak,style,layer,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen",
						// Theme options
						theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
						theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor",
						theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen",
						theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,pagebreak",
						theme_advanced_toolbar_location : "top",
						theme_advanced_toolbar_align : "left",
						width : "100",
						theme_advanced_statusbar_location : "bottom",
						theme_advanced_resizing : true,
						content_css : "' . __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/css/global.css",
						// Drop lists for link/image/media/template dialogs
						template_external_list_url : "lists/template_list.js",
						external_link_list_url : "lists/link_list.js",
						external_image_list_url : "lists/image_list.js",
						media_external_list_url : "lists/media_list.js",
						elements : "nourlconvert",
						convert_urls : false,
						language : "' . (file_exists(_PS_ROOT_DIR_ . '/js/tinymce/jscripts/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en') . '"
					});
				});
			}
			tinyMCEInit(\'textarea.rte\');
			toggleVirtualProduct(getE(\'is_virtual_good\'));
			</script>
		';
    }
function generate_tax_rules()
{
    $taxes = Tax::getTaxes(Configuration::get('PS_LANG_DEFAULT'), true);
    $countries = Country::getCountries(Configuration::get('PS_LANG_DEFAULT'));
    foreach ($taxes as $tax) {
        $insert = '';
        $id_tax = $tax['id_tax'];
        $group = new TaxRulesGroup();
        $group->active = 1;
        $group->name = 'Rule ' . $tax['rate'] . '%';
        $group->save();
        $id_tax_rules_group = $group->id;
        $countries = Db::getInstance()->ExecuteS('
		SELECT * FROM `' . _DB_PREFIX_ . 'country` c
		LEFT JOIN `' . _DB_PREFIX_ . 'zone` z ON (c.`id_zone` = z.`id_zone`)
		LEFT JOIN `' . _DB_PREFIX_ . 'tax_zone` tz ON (tz.`id_zone` = z.`id_zone`)
		WHERE `id_tax` = ' . (int) $id_tax);
        if ($countries) {
            foreach ($countries as $country) {
                $res = Db::getInstance()->Execute('
					 INSERT INTO `' . _DB_PREFIX_ . 'tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
					 VALUES (
					 ' . (int) $group->id . ',
					 ' . (int) $country['id_country'] . ',
					 0,
					 0,
					 ' . (int) $id_tax . ')');
            }
        }
        $states = Db::getInstance()->ExecuteS('
		SELECT * FROM `' . _DB_PREFIX_ . 'states s
		LEFT JOIN `' . _DB_PREFIX_ . 'tax_state ts ON (ts.`id_state` = s.`id_state`)
		WHERE `id_tax` = ' . (int) $id_tax);
        if ($states) {
            foreach ($states as $state) {
                if (!in_array($state['tax_behavior'], array(PS_PRODUCT_TAX, PS_STATE_TAX, PS_BOTH_TAX))) {
                    $tax_behavior = PS_PRODUCT_TAX;
                } else {
                    $tax_behavior = $state['tax_behavior'];
                }
                $res = Db::getInstance()->Execute('
					 INSERT INTO `' . _DB_PREFIX_ . 'tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
					 VALUES (
					 ' . (int) $group->id . ',
					 ' . (int) $state['id_country'] . ',
					 ' . (int) $state['id_state'] . ',
					 ' . (int) $tax_behavior . ',
					 ' . (int) $id_tax . ')');
            }
        }
        Db::getInstance()->Execute('
		UPDATE `' . _DB_PREFIX_ . 'product`
		SET `id_tax_rules_group` = ' . (int) $group->id . '
		WHERE `id_tax` = ' . (int) $id_tax);
        Db::getInstance()->Execute('
		UPDATE `' . _DB_PREFIX_ . 'carrier`
		SET `id_tax_rules_group` = ' . (int) $group->id . '
		WHERE `id_tax` = ' . (int) $id_tax);
        if (Configuration::get('SOCOLISSIMO_OVERCOST_TAX') == $id_tax) {
            Configuration::updateValue('SOCOLISSIMO_OVERCOST_TAX', $group->id);
        }
    }
}
    private function _displayForm()
    {
        global $cookie;
        $taxes = Tax::getTaxes(intval($cookie->id_lang));
        $this->_html .= '<script type="text/javascript">';
        $this->_html .= 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false') . ";\n";
        $this->_html .= 'taxesArray = new Array ()' . ";\n";
        $this->_html .= 'taxesArray[0] = 0' . ";\n";
        foreach ($taxes as $k => $tax) {
            $this->_html .= 'taxesArray[' . $tax['id_tax'] . ']=' . $tax['rate'] . ";\n";
        }
        $this->_html .= '</script>';
        $this->_html .= '<script type="text/javascript" src="' . _PS_JS_DIR_ . 'price.js"></script>
		<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" class="form">
		<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" /> ' . $this->l('Description') . '</legend>' . $this->l('SoColissimo is a service offered by La Poste, which allows you to offer your buyer 5 modes of delivery') . ' :
		<br/><br/><ul style ="list-style:disc outside none;margin-left:30px;">
			<li>' . $this->l('At home') . '.</li>
			<li>' . $this->l('At home with appointments') . '.</li>
			<li>' . $this->l('In Cityssimo space') . '.</li>
			<li>' . $this->l('In their post office') . '.</li>
			<li>' . $this->l('In their merchant') . '.</li>
		</ul>
		<p>' . $this->l('This module is free and allows you to activate this offer on your store.') . '</p>
		<p><a href="http://www.prestashop.com/download/partner_modules/docs/Intergation_socolissimo.pdf">
		>' . $this->l('Documentation') . '<</a></p>
		</fieldset>
		<div class="clear">&nbsp;</div>

		<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" /> ' . $this->l('Settings') . '</legend>
		<label style="color:#CC0000;text-decoration : underline;">' . $this->l('Important') . ': </label>
		<div class="margin-form">
		<p  style="width:500px">' . $this->l('To open your account Colissimo So, please contact your local Trading Post or the usual 36.34') . '</p>
		</div>
		<label>' . $this->l('ID So') . ' : </label>
		<div class="margin-form">
		<input type="text" name="id_user" value="' . Tools::getValue('id_user', Configuration::get('SOCOLISSIMO_ID')) . '" />
		<p>' . $this->l('Id user for back office SoColissimo.') . '</p>
		</div>

		<label>' . $this->l('Key') . ' : </label>
		<div class="margin-form">
		<input type="text" name="key" value="' . Tools::getValue('key', Configuration::get('SOCOLISSIMO_KEY')) . '" />
		<p>' . $this->l('Secure key for back office SoColissimo.') . '</p>
		</div>

		<label>' . $this->l('Preparation time') . ' : </label>
		<div class="margin-form">
		<input type="text" size="5" name="dypreparationtime" value="' . intval(Tools::getValue('dypreparationtime', Configuration::get('SOCOLISSIMO_PREPARATION_TIME'))) . '" /> ' . $this->l('Day(s)') . '
		<p>' . $this->l('Average time of preparation of Stuff.') . ' <br><span style="color:red">' . $this->l('Average time must be the same in Coliposte Back office.') . '</span></p>
		</div>
               <label>' . $this->l('Seller expedition cost in France') . ' : </label>
		<div class="margin-form">
		<input type="radio" name="costseller" id="cost_on" value="1" ' . (Configuration::get('SOCOLISSIMO_COST_SELLER') ? 'checked="checked" ' : '') . '/>
			<label class="t" for="cost_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
			<input type="radio" name="costseller" id="cost_off" value="0" ' . (!Configuration::get('SOCOLISSIMO_COST_SELLER') ? 'checked="checked" ' : '') . '/>
			<label class="t" for="cost_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
		<p>' . $this->l('Seller expedition cost in France') . ' <br><span style="color:red">' . $this->l('This cost override the normal cost for seller delivery.') . '</span></p>
		</div>
               <label>' . $this->l('Expedition in belgium') . ' : </label>
		<div class="margin-form">
			<input type="radio" name="exp_bel_active" id="exp_on" value="1" ' . (Configuration::get('SOCOLISSIMO_EXP_BEL') ? 'checked="checked" ' : '') . '/>
			<label class="t" for="exp_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
			<input type="radio" name="exp_bel_active" id="exp_off" value="0" ' . (!Configuration::get('SOCOLISSIMO_EXP_BEL') ? 'checked="checked" ' : '') . '/>
			<label class="t" for="exp_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
			<p>' . $this->l('Enable or disable expedition in belgium.') . '</p>
		</div>
               <label>' . $this->l('Overcost for Belgium') . ' : </label>
		<div class="margin-form">
		<input type="text" size="5" name="supcostbelg" onkeyup="this.value = this.value.replace(/,/g, \'.\');" value="' . (double) Tools::getValue('supcostbelg', Configuration::get('SOCOLISSIMO_SUP_BELG')) . '" /> Euro TTC
		<p>' . $this->l('Overcost for Belgium') . ' <br><span style="color:red">' . $this->l('Additional cost for Belgium must match that of Coliposte back office.') . '</span></p>
		</div>
		<label>' . $this->l('Overcost') . ' : </label>
		<div class="margin-form">
		<input id="priceTE" size="11" onkeyup="calcPriceTI();" type="text" size="5" name="overcost" onkeyup="this.value = this.value.replace(/,/g, \'.\');"
		value="' . floatval(Tools::getValue('overcost', number_format(Configuration::get('SOCOLISSIMO_OVERCOST'), 2, '.', ''))) . '" /> € HT
		<br/><br/>
		<input id="priceTI" size="11" onkeyup="calcPriceTE();" type="text" size="5" onkeyup="this.value = this.value.replace(/,/g, \'.\');" /> € TTC
		</div>
		<script type="text/javascript">
		$(document).ready(function(){
			calcPriceTI();
		});
		</script>
		<label>' . $this->l('Overcost') . ' ' . $this->l('Tax:') . '</label>
		<div class="margin-form">
		<select name="id_tax" id="id_tax" onchange="javascript:calcPriceTI();">
			<option value="0"' . (false ? ' selected="selected"' : '') . '>' . $this->l('No tax') . '</option>';
        $tvaList = Tax::getTaxes(intval($cookie->id_lang));
        foreach ($tvaList as $line) {
            $this->_html .= '<option value="' . $line['id_tax'] . '"' . (Configuration::get('SOCOLISSIMO_OVERCOST_TAX') == $line['id_tax'] ? ' selected="selected"' : '') . '>' . $line['name'] . '</option>';
        }
        $this->_html .= '</select>

		<p>' . $this->l('Additional cost if making appointments.') . ' <br><span style="color:red">' . $this->l('Additional cost must be the same in Coliposte Back office.') . '</span></p>

		</div>
		<label>' . $this->l('Carrier') . ' : </label>
		<div class="margin-form"><select name="carrier"><option value="0">' . $this->l('Select a carrier ...') . '</option>';
        $carriers = Carrier::getCarriers($cookie->id_lang, false);
        $ids = array();
        foreach ($carriers as $carrier) {
            if ($carrier['id_carrier'] != Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER')) {
                $this->_html .= '<option value="' . intval($carrier['id_carrier']) . '" ' . (intval($carrier['id_carrier']) == intval(Configuration::get('SOCOLISSIMO_CARRIER_ID')) ? 'selected="selected"' : '') . '>' . $carrier['name'] . '</option>';
                $ids[] .= htmlentities($carrier['id_carrier'], ENT_NOQUOTES, 'UTF-8');
            }
        }
        $this->_html .= '</select>
		<p>' . $this->l('Choose in carriers list the SoColissimo one.') . '</p>
		' . (!in_array(intval(Configuration::get('SOCOLISSIMO_CARRIER_ID')), $ids) ? '<div class="warning">' . $this->l('Carrier is not set') . '</div>' : '') . '
		</div>
		<div class="margin-form">
		<p>--------------------------------------------------------------------------------------------------------</p>
		<span style="color:red">' . $this->l('Be VERY CAREFUL with these settings, change may cause a malfunction of the module') . '</span>
		</div>
		<label>' . $this->l('Url So') . ' : </label>
		<div class="margin-form">
		<input type="text" size="45" name="url_so" value="' . htmlentities(Tools::getValue('url_so', Configuration::get('SOCOLISSIMO_URL')), ENT_NOQUOTES, 'UTF-8') . '" />
		<p>' . $this->l('Url of back office SoColissimo.') . '</p>
		</div>

		<label>' . $this->l('Supervision') . ' : </label>
		<div class="margin-form">
			<input type="radio" name="sup_active" id="active_on" value="1" ' . (Configuration::get('SOCOLISSIMO_SUP') ? 'checked="checked" ' : '') . '/>
			<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
			<input type="radio" name="sup_active" id="active_off" value="0" ' . (!Configuration::get('SOCOLISSIMO_SUP') ? 'checked="checked" ' : '') . '/>
			<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
			<p>' . $this->l('Allow or disallow check availability of SoColissimo service') . '</p>
		</div>

		<label>' . $this->l('Url Supervision') . ' : </label>
		<div class="margin-form">
		<input type="text" size="45" name="url_sup" value="' . htmlentities(Tools::getValue('url_sup', Configuration::get('SOCOLISSIMO_SUP_URL')), ENT_NOQUOTES, 'UTF-8') . '" />
		<p>' . $this->l('Url of supervision.') . '</p>
		</div>

		<div class="margin-form">
		<input type="submit" value="' . $this->l('Save') . '" name="submitSave" class="button" style="margin:10px 0px 0px 25px;" />
		</div>
		</fieldset></form>

		<div class="clear">&nbsp;</div>

		<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" /> ' . $this->l('Informations') . '</legend>
		<p>' . $this->l('Here are two addresses that you must fill in your Back Office SoColissimo') . ' : </p><br>
		<label>' . $this->l('Validation url') . ' : </label>
		<div class="margin-form">
		<p>' . htmlentities($this->url, ENT_NOQUOTES, 'UTF-8') . '</p>
		</div>
		<label>' . $this->l('Return url') . ' : </label>
		<div class="margin-form">
		<p>' . htmlentities($this->url, ENT_NOQUOTES, 'UTF-8') . '</p>
		</div>
		</fieldset>';
    }