public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Catalog price rules'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.)'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->l('From'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->l('To'), 'name' => 'to'), array('type' => 'select', 'label' => $this->l('Reduction type'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Reduction with or without taxes'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->l('Tax included'), 'val' => 1), array('lab' => $this->l('Tax excluded'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->l('Reduction'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save')));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 6);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
示例#2
0
 public function install()
 {
     include_once dirname(__FILE__) . '/LoyaltyStateModule.php';
     if (!parent::install() || !$this->installDB() || !$this->registerHook('extraRight') || !$this->registerHook('updateOrderStatus') || !$this->registerHook('newOrder') || !$this->registerHook('adminCustomers') || !$this->registerHook('shoppingCart') || !$this->registerHook('orderReturn') || !$this->registerHook('cancelProduct') || !$this->registerHook('customerAccount') || !Configuration::updateValue('PS_LOYALTY_POINT_VALUE', '0.20') || !Configuration::updateValue('PS_LOYALTY_MINIMAL', 0) || !Configuration::updateValue('PS_LOYALTY_POINT_RATE', '10') || !Configuration::updateValue('PS_LOYALTY_NONE_AWARD', '1')) {
         return false;
     }
     $defaultTranslations = array('en' => 'Loyalty reward', 'fr' => 'Récompense fidélité');
     $conf = array((int) Configuration::get('PS_LANG_DEFAULT') => $this->l('Loyalty reward'));
     foreach (Language::getLanguages() as $language) {
         if (isset($defaultTranslations[$language['iso_code']])) {
             $conf[(int) $language['id_lang']] = $defaultTranslations[$language['iso_code']];
         }
     }
     Configuration::updateValue('PS_LOYALTY_VOUCHER_DETAILS', $conf);
     $category_config = '';
     $categories = Category::getSimpleCategories((int) Configuration::get('PS_LANG_DEFAULT'));
     foreach ($categories as $category) {
         $category_config .= (int) $category['id_category'] . ',';
     }
     $category_config = rtrim($category_config, ',');
     Configuration::updateValue('PS_LOYALTY_VOUCHER_CATEGORY', $category_config);
     /* This hook is optional */
     $this->registerHook('displayMyAccountBlock');
     if (!LoyaltyStateModule::insertDefaultData()) {
         return false;
     }
     return true;
 }
function regenerate_level_depth()
{
    $category = new Category();
    $cats = $category->getSimpleCategories((int) Configuration::get('PS_LANG_DEFAULT'));
    foreach ($cats as $cat) {
        $category = new Category((int) $cat['id_category']);
        $catParent = new Category((int) $category->id_parent);
        $category->level_depth = $catParent->level_depth + 1;
        Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'category` SET `level_depth` = ' . (int) $category->level_depth . ' WHERE `id_category` = ' . (int) $category->id);
    }
    Category::regenerateEntireNtree();
}
function update_module_loyalty()
{
    if (Configuration::get('PS_LOYALTY_POINT_VALUE') !== false) {
        $category_list = '';
        foreach (Category::getSimpleCategories(Configuration::get('PS_LANG_DEFAULT')) as $category) {
            $category_list .= $category['id_category'] . ',';
        }
        if (!empty($category_list)) {
            $category_list = rtrim($category_list, ',');
            Configuration::updateValue('PS_LOYALTY_VOUCHER_CATEGORY', $category_list);
        }
    }
}
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $products = Product::getProducts((int) $this->context->language->id, 0, 0, 'id_product', 'ASC');
     foreach ($products as $product) {
         $productList[] = array('key' => $product['id_product'], 'name' => '(' . $product['id_product'] . ') ' . $product['name']);
     }
     $categories = Category::getSimpleCategories((int) $this->context->language->id);
     foreach ($categories as $category) {
         $categoryList[] = array('key' => $category['id_category'], 'name' => '(' . $category['id_category'] . ') ' . $category['name']);
     }
     $cmss = CMS::listCms();
     foreach ($cmss as $cms) {
         $cmsList[] = array('key' => $cms['id_cms'], 'name' => '(' . $cms['id_cms'] . ') ' . $cms['meta_title']);
     }
     $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Slideshow'), 'image' => '../img/admin/cog.gif'), 'input' => array(array('type' => 'text', 'lang' => true, 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 40), array('type' => 'text', 'label' => $this->l('Width:'), 'name' => 'width', 'size' => 10, 'desc' => $this->l('If you change the width of the it will be necessary to upload images again')), array('type' => 'text', 'label' => $this->l('Height:'), 'name' => 'height', 'size' => 10, 'desc' => $this->l('If you change the height of the it will be necessary to upload images again')), array('type' => 'select', 'label' => $this->l('Effect:'), 'name' => 'effect', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('random')), array('key' => 1, 'name' => $this->l('swirl')), array('key' => 2, 'name' => $this->l('rain')), array('key' => 3, 'name' => $this->l('straight'))), 'name' => 'name', 'id' => 'key')), array('type' => 'text', 'label' => $this->l('Squares per width:'), 'name' => 'spw', 'size' => 10, 'desc' => $this->l('large number can cause transitions problems, Example: 7')), array('type' => 'text', 'label' => $this->l('Squares per height:'), 'name' => 'sph', 'size' => 10, 'desc' => $this->l('large number can cause transitions problems, Example: 5')), array('type' => 'text', 'label' => $this->l('Delay:'), 'name' => 'delay', 'size' => 10, 'desc' => $this->l('delay between images in ms, Example: 3000')), array('type' => 'text', 'label' => $this->l('Square delay:'), 'name' => 'sDelay', 'size' => 10, 'desc' => $this->l('delay beetwen squares in ms. Example: 30')), array('type' => 'text', 'label' => $this->l('Opacity:'), 'name' => 'opacity', 'size' => 10, 'desc' => $this->l('opacity of title and navigation. Example: 0.7')), array('type' => 'text', 'label' => $this->l('Title speed:'), 'name' => 'titleSpeed', 'size' => 10, 'desc' => $this->l('speed of title appereance in ms. Example: 500')), array('type' => 'select', 'label' => $this->l('Navigation:'), 'name' => 'navigation', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Links:'), 'name' => 'links', 'desc' => $this->l('Enable links.'), 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Hover pause:'), 'name' => 'hoverpause', 'desc' => $this->l('pause on hover.'), 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Show on home:'), 'name' => 'home', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Show on all category:'), 'name' => 'showOnCat', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Categories:'), 'name' => 'categories[]', 'id' => 'categories', 'options' => array('query' => $categoryList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several category s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Show on all product:'), 'name' => 'showOnProd', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Products:'), 'name' => 'products[]', 'id' => 'products', 'options' => array('query' => $productList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several product s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Show on all cms page:'), 'name' => 'showOnCms', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Cms:'), 'name' => 'cms[]', 'id' => 'cms', 'options' => array('query' => $cmsList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several cms s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Hook:'), 'name' => 'hook', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('name' => 'displayTop'), array('name' => 'displayHome'), array('name' => 'displayLeftColumn'), array('name' => 'displayRightColumn'), array('name' => 'displayOpartSlideshowHook')), 'name' => 'name', 'id' => 'name'), 'desc' => $this->l('You must hook the module for display your slideshow on each position. Go to modules/positions menu for setup this')), array('type' => 'select', 'label' => $this->l('Statut:'), 'name' => 'active', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('disable')), array('key' => 1, 'name' => $this->l('enable'))), 'name' => 'name', 'id' => 'key'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (is_numeric($obj->id)) {
         //products value
         $sql = 'SELECT id_product FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_product WHERE id_opartslideshow_slideshow = ' . $obj->id;
         $array = Db::getInstance()->executeS($sql);
         if (count($array)) {
             foreach ($array as $row) {
                 $productValues[] = $row['id_product'];
             }
             $this->fields_value['products[]'] = $productValues;
         }
         //categories value
         $sql = 'SELECT id_category FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_category WHERE id_opartslideshow_slideshow = ' . $obj->id;
         $array = Db::getInstance()->executeS($sql);
         if (count($array)) {
             foreach ($array as $row) {
                 $categoriesValues[] = $row['id_category'];
             }
             $this->fields_value['categories[]'] = $categoriesValues;
         }
         //cms value
         $sql = 'SELECT id_cms FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_cms WHERE id_opartslideshow_slideshow = ' . $obj->id;
         $array = Db::getInstance()->executeS($sql);
         if (count($array)) {
             foreach ($array as $row) {
                 $cmsValues[] = $row['id_cms'];
             }
             $this->fields_value['cms[]'] = $cmsValues;
         }
     }
     $html = $header = $this->context->smarty->fetch(parent::getTemplatePath() . 'header.tpl');
     $html .= parent::renderForm();
     return $html;
 }
示例#6
0
 public function __construct()
 {
     $this->name = 'topshop';
     $this->tab = 'smart_shopping';
     $this->version = '1.7.7';
     $this->author = 'Roman Prokofyev';
     $this->need_instance = 1;
     $this->display = 'view';
     $this->bootstrap = true;
     //$this->ps_versions_compliancy = array('min' => '1.5.0.0', 'max' => '1.6');
     $this->module_key = '2149d8638f786d69c1a762f1fbfb8124';
     $this->custom_attributes = array('YAMARKET_COMPANY_NAME', 'YAMARKET_DELIVERY_PRICE', 'YAMARKET_SALES_NOTES', 'YAMARKET_COUNTRY_OF_ORIGIN', 'YAMARKET_EXPORT_TYPE', 'YAMARKET_MODEL_NAME', 'YAMARKET_DESC_TYPE', 'YAMARKET_DELIVERY_DELIVERY', 'YAMARKET_DELIVERY_PICKUP', 'YAMARKET_DELIVERY_STORE');
     $this->country_of_origin_attr = Configuration::get('YAMARKET_COUNTRY_OF_ORIGIN');
     $this->model_name_attr = Configuration::get('YAMARKET_MODEL_NAME');
     parent::__construct();
     $this->displayName = $this->l('Yandex Market');
     if ($this->id && !Configuration::get('YAMARKET_COMPANY_NAME')) {
         $this->warning = $this->l('You have not yet set your Company Name');
     }
     $this->description = $this->l('Provides price list export to Yandex Market');
     $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
     // Variables fro price list
     $this->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     $this->proto_prefix = _PS_BASE_URL_;
     // Get groups
     $attribute_groups = AttributeGroup::getAttributesGroups($this->id_lang);
     $this->attibute_groups = array();
     foreach ($attribute_groups as $group) {
         $this->attibute_groups[$group['id_attribute_group']] = $group['public_name'];
     }
     // Get categories
     $this->excluded_cats = explode(',', Configuration::get('TOPSHOP_EXCLUDED_CATS'));
     if (!$this->excluded_cats) {
         $this->excluded_cats = array();
     }
     $all_cats = Category::getSimpleCategories($this->id_lang);
     $this->selected_cats = array();
     $this->all_cats = array();
     foreach ($all_cats as $cat) {
         $this->all_cats[] = $cat['id_category'];
         if (!in_array($cat['id_category'], $this->excluded_cats)) {
             $this->selected_cats[] = $cat['id_category'];
         }
     }
     //determine image type
     $this->image_type = 'large_default';
     if (Tools::substr(_PS_VERSION_, 0, 5) == '1.5.0') {
         $this->image_type = 'large';
     }
 }
 public function renderForm()
 {
     $id_lang = (int) Context::getContext()->language->id;
     $categories = Category::getSimpleCategories($id_lang);
     $array_day = $voucher_type = $array_hour = array();
     for ($i = 1; $i < 32; $i++) {
         $array_day[] = array('id_day' => $i, 'name' => $i . ' Days');
     }
     for ($i = 1; $i < 25; $i++) {
         $array_hour[] = array('id_hour' => $i, 'name' => $i . ' Hours');
     }
     $voucher_type[] = array('voucher_type' => 'fixe', 'name' => 'Fixed');
     $voucher_type[] = array('voucher_type' => 'percent', 'name' => 'Percent');
     $this->fields_form = array('legend' => array('title' => $this->l('Create new campaign')), 'input' => array(array('type' => 'text', 'label' => $this->l('Campaign name : '), 'name' => 'name', 'required' => true, 'class' => 't', 'desc' => 'Also mail subject'), array('type' => 'select', 'label' => $this->l('After how many day(s) send campaign ? : '), 'name' => 'execution_time_day', 'required' => true, 'class' => 't', 'options' => array('query' => $array_day, 'id' => 'id_day', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('After how many hour(s) send campaign ? : '), 'name' => 'execution_time_hour', 'required' => true, 'class' => 't', 'options' => array('query' => $array_hour, 'id' => 'id_hour', 'name' => 'name')), array('type' => 'textarea', 'label' => $this->l('Mail Template : '), 'name' => 'email_tpl', 'size' => 60, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'required' => true, 'desc' => $this->l('Available variables : {firstname} , {lastname} , {coupon_name} , {coupon_code} , {coupon_value} , {coupon_valid_to} , {campaign_name}, {cart_content} , {track_url} , {track_request}')), array('type' => 'radio', 'label' => $this->l('Include voucher'), 'name' => 'include_voucher', 'class' => 't include_voucher', 'is_bool' => true, 'values' => array(array('id' => 'include_voucher_enable', 'value' => 1, 'checked' => 'checked', 'label' => $this->l('Enabled')), array('id' => 'include_voucher_disable', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'text', 'label' => $this->l('Voucher prefix : '), 'name' => 'voucher_prefix', 'size' => 60, 'class' => 'voucher_mode', 'desc' => $this->l('Prefix for the voucher create')), array('type' => 'select', 'label' => $this->l('Voucher percent or fixed  : '), 'name' => 'voucher_amount_type', 'desc' => $this->l('Is an percentage or fixe voucher?'), 'class' => 'voucher_mode', 'options' => array('query' => $voucher_type, 'id' => 'voucher_type', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Voucher value : '), 'name' => 'voucher_amount', 'class' => 'voucher_mode', 'size' => 60, 'desc' => $this->l('Voucher value ?')), array('type' => 'text', 'label' => $this->l('Voucher valid in day :'), 'name' => 'voucher_day', 'size' => 60, 'class' => 'voucher_mode', 'desc' => $this->l('How many days voucher will be valid? ')), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     if (!($BlogCategory = $this->loadObject(true))) {
         return;
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save   '), 'class' => 'button');
     //update way :
     $extra = '';
     if ($id_campaign = Tools::getValue('id_campaign')) {
         $campaign = new Campaign($id_campaign);
         // If no voucher disable voucher display only
         if ($campaign->voucher_prefix == '') {
             $extra = '<script> $( function()
     							 { 
     								$("#include_voucher_disable").attr("checked","checked");
     								$(".voucher_mode").parent().parent(".form-group").fadeOut();
     							 } ); </script>';
         }
     }
     return $extra . parent::renderForm();
 }
}
include dirname(__FILE__) . '/../../header.php';
$orders = LoyaltyModule::getAllByIdCustomer((int) $cookie->id_customer, (int) $cookie->id_lang);
$displayorders = LoyaltyModule::getAllByIdCustomer((int) $cookie->id_customer, (int) $cookie->id_lang, false, true, (int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10, (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1);
$smarty->assign(array('orders' => $orders, 'displayorders' => $displayorders, 'pagination_link' => __PS_BASE_URI__ . 'modules/loyalty/loyalty-program.php', 'totalPoints' => (int) $customerPoints, 'voucher' => LoyaltyModule::getVoucherValue($customerPoints, (int) $context->currency->id), 'validation_id' => LoyaltyStateModule::getValidationId(), 'transformation_allowed' => $customerPoints > 0, 'page' => (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1, 'nbpagination' => (int) (Tools::getValue('n') > 0) ? (int) Tools::getValue('n') : 10, 'nArray' => array(10, 20, 50), 'max_page' => floor(sizeof($orders) / ((int) (Tools::getValue('n') > 0) ? (int) Tools::getValue('n') : 10))));
/* Discounts */
$nbDiscounts = 0;
$discounts = array();
if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer((int) $cookie->id_customer)) {
    $nbDiscounts = count($ids_discount);
    foreach ($ids_discount as $key => $discount) {
        $discounts[$key] = new Discount((int) $discount['id_cart_rule'], (int) $cookie->id_lang);
        $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount((int) $discount['id_cart_rule']);
    }
}
$allCategories = Category::getSimpleCategories((int) $cookie->id_lang);
$voucherCategories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY');
if ($voucherCategories != '' and $voucherCategories != 0) {
    $voucherCategories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'));
} else {
    die(Tools::displayError());
}
if (sizeof($voucherCategories) == sizeof($allCategories)) {
    $categoriesNames = null;
} else {
    $categoriesNames = array();
    foreach ($allCategories as $k => $allCategory) {
        if (in_array($allCategory['id_category'], $voucherCategories)) {
            $categoriesNames[$allCategory['id_category']] = trim($allCategory['name']);
        }
    }
示例#9
0
    public function getContent()
    {
        if (isset($_POST['submitSettings'])) {
            $this->_postProcess();
        }
        $id_lang = Configuration::get('PS_LANG_DEFAULT');
        $categories = Category::getSimpleCategories($id_lang);
        $carriers = Carrier::getCarriers($id_lang);
        $this->_html .= '
		<fieldset><legend>FIA-NET - Système d\'Analyse des Commandes</legend>
			<img src="../modules/' . $this->name . '/logo.jpg" style="float:right;margin:5px 10px 5px 0" />
			FIA-NET, le leader français de la lutte contre la fraude à la carte bancaire sur internet !<br /><br />
			Avec son réseau mutualisé de plus de 1 700 sites marchands, et sa base de données de 14 millions de cyber-acheteurs, le Système d’Analyse des Commandes vous offre une protection complète et unique contre le risque d’impayé.<br /><br />
			Le logiciel expert (SAC) score vos transactions en quasi temps réel à partir de plus de 200 critères pour valider plus de 92 % de vos transactions.<br />
			Le contrôle humain, prenant en charge les transactions les plus risqués, associé à l’assurance FIA-NET vous permet de valider et garantir jusqu’à 100 % de vos transactions.<br /><br />
			Ne restez pas isolé face à l’explosion des réseaux de fraudeurs !
			<p>' . $this->l('To sign in, check out: ') . ' <u><a href="https://www.fia-net.com/marchands/devispartenaire.php?p=185" target="_blank">' . $this->l('Fia-net Website') . '</a></u></p>
		</fieldset><br />
		<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post">
			<fieldset>
				<legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend>
				<label>' . $this->l('Login') . '</label>
				<div class="margin-form">
					<input type="text" name="fianetfraud_login" value="' . Configuration::get('SAC_LOGIN') . '"/>
				</div>
				<label>' . $this->l('Password') . '</label>
				<div class="margin-form">
					<input type="text" name="fianetfraud_password" value="' . Configuration::get('SAC_PASSWORD') . '"/>
				</div>
				<label>' . $this->l('Site ID') . '</label>
				<div class="margin-form">
					<input type="text" name="fianetfraud_siteid" value="' . Configuration::get('SAC_SITEID') . '"/>
				</div>
				<label>' . $this->l('Production mode') . '</label>
				<div class="margin-form">
					<input type="checkbox" name="fianetfraud_production" id="activated_on" value="1" ' . (Configuration::get('SAC_PRODUCTION') == 1 ? 'checked="checked" ' : '') . '/>
				</div>
				<label>' . $this->l('Default Product Type') . '</label>
				<div class="margin-form">
					<select name="fianetfraud_product_type">
						<option value="0">' . $this->l('-- Choose --') . '</option>';
        foreach ($this->_product_type as $k => $product_type) {
            $this->_html .= '<option value="' . $k . '"' . (Configuration::get('SAC_DEFAULT_PRODUCT_TYPE') == $k ? ' selected="selected"' : '') . '>' . $product_type . '</option>';
        }
        $this->_html .= '</select>
				</div>
			</fieldset><br />
			<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Category Detail') . '</legend>
			<label>' . $this->l('Category Detail') . '</label>
			<div class="margin-form">
			<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Category') . '</th><th>' . $this->l('Category Type') . '</th></tr></thead><tbody>';
        foreach ($categories as $category) {
            $this->_html .= '<tr><td>' . $category['name'] . '</td><td>
			<select name="cat_' . $category['id_category'] . '" id="cat_' . $category['id_category'] . '">
				<option value="0">' . $this->l('Choose a category...') . '</option>';
            foreach ($this->_product_type as $id => $cat) {
                $this->_html .= '<option value="' . $id . '" ' . (Configuration::get('SAC_CATEGORY_TYPE_' . $category['id_category']) == $id ? ' selected="true"' : '') . '>' . $cat . '</option>';
            }
            $this->_html .= '</select></td></tr>';
        }
        $this->_html .= '</tbody></table></div>
			</fieldset>
			<div class="clear">&nbsp;</div>
			<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Carrier Configuration') . '</legend>
				<label>' . $this->l('Carrier Detail') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Carrier') . '</th><th>' . $this->l('Carrier Type') . '</th></tr></thead><tbody>';
        foreach ($carriers as $carrier) {
            $this->_html .= '<tr><td>' . $carrier['name'] . '</td><td><select name="carrier_' . $carrier['id_carrier'] . '" id="cat_' . $carrier['id_carrier'] . '">
			<option value="0">' . $this->l('Choose a carrier type...') . '</option>';
            foreach ($this->_carrier_type as $id => $type) {
                $this->_html .= '<option value="' . $id . '"' . (Configuration::get('SAC_CARRIER_TYPE_' . $carrier['id_carrier']) == $id ? ' selected="true"' : '') . '>' . $type . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>
			<div class="clear">&nbsp;</div>
			<label>' . $this->l('Default Carrier Type') . '</label>
			<div class="margin-form">
				<select name="fianetfraud_default_carrier">';
        foreach ($this->_carrier_type as $k => $type) {
            $this->_html .= '<option value="' . $k . '"' . ($k == Configuration::get('SAC_DEFAULT_CARRIER_TYPE') ? ' selected' : '') . '>' . $type . '</option>';
        }
        $this->_html .= '</select>
			</div>
			</fieldset><div class="clear">&nbsp;</div>';
        /* Get all modules then select only payment ones*/
        $modules = Module::getModulesOnDisk();
        $modules_is_fianet = explode(',', Configuration::get('SAC_PAYMENT_MODULE'));
        $this->paymentModules = array();
        foreach ($modules as $module) {
            if (method_exists($module, 'hookPayment')) {
                if ($module->id) {
                    $module->country = array();
                    $countries = DB::getInstance()->ExecuteS('SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country WHERE id_module = ' . (int) $module->id);
                    foreach ($countries as $country) {
                        $module->country[] = $country['id_country'];
                    }
                    $module->currency = array();
                    $currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency WHERE id_module = ' . (int) $module->id);
                    foreach ($currencies as $currency) {
                        $module->currency[] = $currency['id_currency'];
                    }
                    $module->group = array();
                    $groups = DB::getInstance()->ExecuteS('SELECT id_group FROM ' . _DB_PREFIX_ . 'module_group WHERE id_module = ' . (int) $module->id);
                    foreach ($groups as $group) {
                        $module->group[] = $group['id_group'];
                    }
                } else {
                    $module->country = NULL;
                    $module->currency = NULL;
                    $module->group = NULL;
                }
                $this->paymentModules[] = $module;
            }
        }
        $this->_html .= '<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Payment Configuration') . '</legend>
				<label>' . $this->l('Payment Detail') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table" ><thead><tr>
						<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'payementBox[]\', this.checked)" /></th>	
						<th>' . $this->l('Payment Module') . '</th><th>' . $this->l('Payment Type') . '</th></tr></thead><tbody>';
        foreach ($this->paymentModules as $module) {
            $this->_html .= '<tr><td><input type="checkbox" class="noborder" value="' . substr($module->name, 0, 15) . '" name="payementBox[]" ' . (in_array(substr($module->name, 0, 15), $modules_is_fianet) ? 'checked="checked"' : '') . '></td>';
            $this->_html .= '<td><img src="' . __PS_BASE_URI__ . 'modules/' . $module->name . '/logo.gif" alt="' . $module->name . '" title="' . $module->displayName . '" />' . stripslashes($module->displayName) . '</td><td><select name="' . substr($module->name, 0, 15) . '">';
            $this->_html .= '<option value="0">' . $this->l('-- Choose --') . '</option>';
            foreach ($this->_payement_type as $type) {
                $this->_html .= '<option ' . (Configuration::get('SAC_PAYMENT_TYPE_' . substr($module->name, 0, 15)) == $type ? 'selected="true"' : '') . '>' . $type . '</option>';
            }
            $this->_html .= '</select></tr>';
        }
        $this->_html .= '</tbody></table></margin></fieldset><br class="clear" /><br />
			<center><input type="submit" name="submitSettings" value="' . $this->l('Save') . '" class="button" /></center>
		</form>
		<div class="clear">&nbsp;</div>';
        return $this->_html;
    }
示例#10
0
    public function getContent()
    {
        global $cookie;
        $html = '<h2>' . $this->displayName . '</h2>';
        if (isset($_POST['submit_settings'])) {
            if ((int) Tools::getValue('product_id') == (int) Tools::getValue('product_share_id')) {
                $html .= $this->displayError($this->l('Product and share product are the same.'));
            } else {
                $res = self::getShareProductRules((int) Tools::getValue('product_id'));
                if ($res) {
                    $res = self::updateShareProductRules(Tools::getValue('product_id'), Tools::getValue('product_share_id'), Tools::getValue('share_days'), Tools::getvalue('SHAREZBLOCK_SEP'), Tools::getvalue('SHAREZBLOCK_PROP'), Tools::getvalue('SHAREZBLOCK_PRICE'), Tools::getvalue('SHAREZBLOCK_DESCR'));
                    $html .= $res ? $this->displayConfirmation($this->l('Settings updated.')) : $this->displayError($this->l('Settings not updated.'));
                } else {
                    $html .= $this->displayError($this->l('Supplement products are not set.'));
                }
            }
        }
        if (Tools::isSubmit('submit_bind')) {
            if ((int) Tools::getValue('product_id') == (int) Tools::getValue('product_share_id')) {
                $html .= $this->displayError($this->l('Product and share product are the same.'));
            } else {
                $res = self::getShareProductRules((int) Tools::getValue('product_id'));
                if ($res) {
                    $res = self::updateShareProductRules((int) Tools::getValue('product_id'), (int) Tools::getValue('product_share_id'), (int) Tools::getValue('share_days'));
                } else {
                    $res = self::bindProducts((int) Tools::getValue('product_id'), (int) Tools::getValue('product_share_id'), (int) Tools::getValue('share_days'));
                }
            }
            $html .= $res ? $this->displayConfirmation($this->l('Settings updated.')) : $this->displayError($this->l('Settings not updated.'));
        } elseif (Tools::isSubmit('submit_unbind')) {
            $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'share_product` WHERE id_product=' . (int) Tools::getValue('product_id') . ' AND id_share_product=' . (int) Tools::getValue('product_share_id');
            $res = Db::getInstance()->Execute($sql);
            $html .= $res ? $this->displayConfirmation($this->l('Settings updated.')) : $this->displayError($this->l('Settings not updated.'));
        }
        if (Tools::isSubmit('products_cat') || Tools::isSubmit('products_share_cat')) {
            $product_cats = Product::getProducts((int) $cookie->id_lang, null, null, 'name', 'ASC', (int) Tools::getValue('products_cat'));
            $product_share_cats = Product::getProducts((int) $cookie->id_lang, null, null, 'name', 'ASC', (int) Tools::getValue('products_share_cat'));
        } else {
            $product_cats = array(0 => array('id_product' => 0, 'name' => $this->l('No products in this category')));
            $product_share_cats = array(0 => array('id_product' => 0, 'name' => $this->l('No products in this category')));
        }
        $html .= '
			<script type="text/javascript">
			// <![CDATA[
				var sep_chk=false;
				var price_chk=false;
				function handleProductSelection(id_product)
				{
					$.ajax({
					  url: "' . $this->_path . 'controllers/admin/settings.php",
					  cache: false,
					  data: "select_field=1&id_product="+id_product,
					  success: function(html){
						var a = html.split("_");
 						$("#product_share_id option[value="+a[0]+"]").attr("selected", "selected");
 						$("#product_share_id option[value!="+a[0]+"]").removeAttr("selected");
 						$("#share_days").val(a[1]);
 						$("#date").html(a[2]);
						$("#SHAREZBLOCK_PROP").val(a[4]);

 						$("#SHAREZBLOCK_SEP").attr("checked", (parseInt(a[3])==1?"checked":""));

						$("#SHAREZBLOCK_PRICE").val(a[5]);
						$("#SHAREZBLOCK_PRICE_STAT").attr("checked", (parseFloat(a[5])>0?"checked":""));

						$("#SHAREZBLOCK_DESCR").attr("checked", (parseInt(a[6])==1?"checked":""));
					  }
					});
				}
			//]]>
			</script>
			<div>
			<fieldset style="width: 868px">
				<legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Supplement products') . '</legend>
					<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="fm_submit">
						<b>' . $this->l('Days number of the special offer:') . '</b>
						<input type="text" id="share_days" name="share_days" value="' . (Tools::getValue('share_days') ? Tools::getValue('share_days') : 14) . '" size="3">
						<span style="color:#7F7F7F; font-size:0.85em; font-weight: bold">(' . $this->l('start at:') . ' <span id="date"></span>)</span><br/><br/>
						<b>' . $this->l('Select product from left column and bind it with special offer product from right column by clicking to the Bind button. The same should be done to unbind.') . '</b><br/><br/>
						<div style="float: left;">
							' . $this->l('Product category:') . '
							<select name="products_cat" onchange="document.forms.fm_submit.submit()">';
        $cats = Category::getSimpleCategories((int) $cookie->id_lang);
        foreach ($cats as $k => $c) {
            $html .= '<option value="' . $c['id_category'] . '" ' . (Tools::getValue('products_cat') == $c['id_category'] ? 'selected="selected"' : '') . '>' . $c['name'] . '</option>';
        }
        $html .= '
							</select>
							<br/><br/>
							' . $this->l('Products') . '<br/>
							<select name="product_id" size="30">';
        foreach ($product_cats as $k => $p) {
            $html .= '<option value="' . $p['id_product'] . '" onclick="handleProductSelection(\'' . $p['id_product'] . '\')">' . Tools::truncate($p['name'], 63) . '</option>';
        }
        $html .= '
							</select>
						</div>
						<div style="float: left; margin-left: 10px">
							' . $this->l('Special offer product category:') . '
							<select name="products_share_cat" onchange="document.forms.fm_submit.submit()">';
        foreach ($cats as $k => $c) {
            $html .= '<option value="' . $c['id_category'] . '" ' . (Tools::getValue('products_share_cat') == $c['id_category'] ? 'selected="selected"' : '') . '>' . $c['name'] . '</option>';
        }
        $html .= '
							</select>
							<br/><br/>
							' . $this->l('Special offer products') . '<br/>
							<select id="product_share_id" name="product_share_id" size="30">';
        foreach ($product_share_cats as $k => $p) {
            $html .= '<option value="' . $p['id_product'] . '">' . Tools::truncate($p['name'], 63) . '</option>';
        }
        $html .= '
							</select>
						</div>
						<br class="clear"><br class="clear">
						<center>
							<input type="submit" name="submit_bind" value="' . $this->l(' Bind ') . '" class="button" />
							<input type="submit" name="submit_unbind" value="' . $this->l(' Unbind ') . '" class="button" />
						</center>
						<br class="clear"/><br class="clear"/>

						<hr/>
						<label>' . $this->l('Show product description') . '</label>
						<div class="margin-form">
							<input type="checkbox" name="SHAREZBLOCK_DESCR" id="SHAREZBLOCK_DESCR" value="1">
						</div><br/>
						<div id="sep_option">
							<label>' . $this->l('Add products to the cart separately') . ' (1)</label>
							<div class="margin-form">
								<input type="checkbox" id="SHAREZBLOCK_SEP" name="SHAREZBLOCK_SEP" value="1" onclick="$(\'#SHAREZBLOCK_PRICE_STAT\').attr(\'checked\', \'\')">
								&nbsp;' . $this->l('(Allows to buy a special product separately from a basic product. This option will cancel all another options.)') . '
							</div>
						</div>
						<br class="clear">

						<div id="quantity_man">
							<label>' . $this->l('Quantity management') . ' (2)</label>
							<div class="margin-form">
								<select name="SHAREZBLOCK_PROP" id="SHAREZBLOCK_PROP">';
        foreach ($this->quantity_prop as $k => $v) {
            $html .= '<option value="' . $k . '" onclick="$(\'#SHAREZBLOCK_PRICE_STAT\').attr(\'checked\', \'\'); $(\'#SHAREZBLOCK_SEP\').attr(\'checked\', \'\'); $(\'#SHAREZBLOCK_PRICE\').val(\'0\');">' . $v . '</option>';
        }
        $html .= '
								</select>
								<br/>' . $this->l('(1. Only one</b> - allows to buy only one special product. 2. Proportional - amount of basic and special products should be proportional in the cart. 3. Many - a customer can buy any number of a special product. Quantity management option will cancel all another options.)') . '
							</div>
						</div>
						<div id="price_params">
							<label>' . $this->l('Customer get product for free if he have cart total price more or equal some value:') . ' (3)</label>
							<div class="margin-form">
								<input type="checkbox" id="SHAREZBLOCK_PRICE_STAT" name="SHAREZBLOCK_PRICE_STAT" value="1"  onclick="$(\'#SHAREZBLOCK_SEP\').attr(\'checked\', \'\'); $(\'#SHAREZBLOCK_PRICE\').val(\'0\');">
								' . $this->l('(Uncheck it to disable. This option will cancel all another options.)') . '
							</div>
							<div id="price">
								<div class="margin-form">
									<input type="text" id="SHAREZBLOCK_PRICE" name="SHAREZBLOCK_PRICE" value="0" size="10"> ' . $this->defaultCurrency->sign . '
									<br/>' . $this->l('(Price for free.)') . '
								</div>
							</div>
						</div>
						<br/><br/>
						<center><input type="submit" name="submit_settings" value="' . $this->l('Save') . '" class="button" /></center>
					</form>
			</fieldset>
			</div>
			<br class="clear"><br class="clear">
		';
        return $html;
    }
示例#11
0
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $groupReductions = $obj->id ? GroupReduction::getGroupReductions($obj->id, (int) $cookie->id_lang) : array();
        $categories = Category::getSimpleCategories((int) $cookie->id_lang);
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset class="width3"><legend><img src="../img/admin/tab-groups.gif" alt="" />' . $this->l('Customer group') . '</legend>
				<label>' . $this->l('Name:') . ' </label>
				<div class="margin-form">';
        foreach ($this->_languages as $language) {
            echo '
					<div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input size="33" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
						<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
        $reduction = htmlentities($this->getFieldValue($obj, 'reduction'), ENT_COMPAT, 'UTF-8');
        echo '
				</div>
				<div class="clear">&nbsp;</div>
				<label>' . $this->l('Discount:') . ' </label>
				<div class="margin-form">
					<input type="text" size="5" name="reduction" value="' . ($reduction ? $reduction : '0') . '" /> ' . $this->l('%') . '
					<p>' . $this->l('Will automatically apply this value as a discount on ALL shop\'s products for this group\'s members.') . '</p>
				</div>';
        if ($obj->id) {
            echo '
				<label>' . $this->l('Current category discount:') . '</label>
				<div class="margin-form">';
            if ($groupReductions) {
                echo '<table>
						<tr>
							<th>' . $this->l('Category') . '</th>
							<th>' . $this->l('Value') . '</th>
							<th>' . $this->l('Action') . '</th>
						</tr>';
                foreach ($groupReductions as $groupReduction) {
                    echo '
						<tr>
							<td>' . Tools::htmlentitiesUTF8($groupReduction['category_name']) . '</td>
							<td><input type="hidden" name="gr_id_group_reduction[]" value="' . (int) $groupReduction['id_group_reduction'] . '" /><input type="text" name="gr_reduction[]" value="' . $groupReduction['reduction'] * 100 . '" /></td>
							<td><a href="' . $currentIndex . '&deleteGroupReduction&id_group_reduction=' . (int) $groupReduction['id_group_reduction'] . '&id_group=' . (int) $obj->id . '&token=' . $this->token . '"><img src="" alt="' . $this->l('Delete') . '" /></a></td>
						</tr>';
                }
                echo '</table>';
            } else {
                echo $this->l('No discount');
            }
            echo '	</div>';
        }
        echo '
				<label>' . $this->l('Price display method:') . ' </label>
				<div class="margin-form">
					<select name="price_display_method">
						<option value="' . PS_TAX_EXC . '"' . ((int) $this->getFieldValue($obj, 'price_display_method') == PS_TAX_EXC ? ' selected="selected"' : '') . '>' . $this->l('Tax excluded') . '</option>
						<option value="' . PS_TAX_INC . '"' . ((int) $this->getFieldValue($obj, 'price_display_method') == PS_TAX_INC ? ' selected="selected"' : '') . '>' . $this->l('Tax included') . '</option>
					</select>
					<p>' . $this->l('How the prices are displayed on order summary for this customer group (tax included or excluded).') . '</p>
				</div>
				<div class="clear">&nbsp;</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><br />';
        if ($obj->id) {
            echo '
			<form action="' . $currentIndex . '&update' . $this->table . '&id_group=' . $obj->id . '&token=' . $this->token . '" method="post" class="width3">
				<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />
				<fieldset><legend><img src="../img/admin/tab-groups.gif" />' . $this->l('New group discount') . '</legend>
					<label>' . $this->l('Category:') . ' </label>
					<div class="margin-form">
						<select name="id_category">';
            foreach ($categories as $category) {
                echo '	<option value="' . (int) $category['id_category'] . '">' . Tools::htmlentitiesUTF8($category['name']) . '</option>';
            }
            echo '	</select><sup>*</sup>
					<p>' . $this->l('Only products that have this category as default category will be affected') . '.</p>
					</div>
					<label>' . $this->l('Discount (in %):') . ' </label>
					<div class="margin-form">
						<input type="text" name="reductionByCategory" value="" /><sup>*</sup>
					</div>
					<div class="clear">&nbsp;</div>
					<div class="margin-form">
						<input type="submit" value="' . $this->l('   Add   ') . '" name="submitAddGroupReduction" class="button" />
					</div>
					<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
				</fieldset>
			</form>';
        }
    }
示例#12
0
 /**
  * Load shop product categories
  * 
  * @return type
  */
 private function loadProductCategories()
 {
     $categories = Category::getSimpleCategories($this->context->language->id);
     $shop_categories = array();
     foreach ($categories as $category) {
         $kwixo_type = Tools::isSubmit('kwixo_' . $category['id_category'] . '_product_type') ? Tools::getValue('kwixo_' . $category['id_category'] . '_product_type') : Configuration::get('KWIXO_PRODUCT_TYPE_' . $category['id_category'] . '');
         $kwixo_delivery = Tools::isSubmit('kwixo_' . $category['id_category'] . '_product_type_delivery') ? Tools::getValue('kwixo_' . $category['id_category'] . '_product_type_delivery') : Configuration::get('KWIXO_PRODUCT_TYPE_DELIVERY_' . $category['id_category'] . '');
         $shop_categories[$category['id_category']] = array('name' => $category['name'], 'kwixo_type' => $kwixo_type, 'kwixo_delivery' => $kwixo_delivery);
     }
     return $shop_categories;
 }
    private function _displayForm()
    {
        $responsiveLinksConfiguration = unserialize(Configuration::get('RESPONSIVELINKS_CONFIGURATION'));
        $responsiveLink = null;
        $category = null;
        $cms = null;
        $product = null;
        $custom = null;
        if (Tools::getIsset('action') && Tools::getValue('action') == 'edit') {
            $responsiveLink = new ResponsiveLinksClass((int) Tools::getValue('id'));
            if ($responsiveLink->id_category != 0) {
                $category = new Category((int) $responsiveLink->id_category, $this->context->cookie->id_lang);
            }
            if ($responsiveLink->id_cms != 0) {
                $cms = new CMS((int) $responsiveLink->id_cms, $this->context->cookie->id_lang);
            }
            if ($responsiveLink->id_cms_category != 0) {
                $cmsCategory = new CMSCategory((int) $responsiveLink->id_cms_category, $this->context->cookie->id_lang);
            }
            if ($responsiveLink->id_product != 0) {
                $product = new Product((int) $responsiveLink->id_product, $this->context->cookie->id_lang);
            }
            if ($responsiveLink->id_category == 0 && $responsiveLink->id_cms == 0 && $responsiveLink->id_cms_category == 0 && $responsiveLink->id_product == 0) {
                $custom = true;
            }
        }
        /* Languages preliminaries */
        $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
        $languages = Language::getLanguages(false);
        $divLangName = 'title¤url';
        $this->_html .= '
        <script type="text/javascript">
            var urlAjaxModule = "' . _PS_BASE_URL_ . $this->_path . 'ajax.php";
        </script>
        <link type="text/css" rel="stylesheet" href="' . $this->_path . '../responsiveextension/stylesheets/admin-common.css" />
        <link type="text/css" rel="stylesheet" href="' . $this->_path . 'stylesheets/jquery.treeTable.css" />
        <link type="text/css" rel="stylesheet" href="' . $this->_path . 'stylesheets/responsivelinks.css" />

        <script type="text/javascript" src="' . $this->_path . '../responsiveextension/javascripts/admin-common.js"></script>
        <script type="text/javascript" src="' . _PS_JS_DIR_ . 'jquery/plugins/jquery.tablednd.js"></script>
        <script type="text/javascript" src="' . $this->_path . 'javascripts/jquery.treeTable.js"></script>
        <script type="text/javascript" src="' . $this->_path . 'javascripts/responsivelinks.js"></script>
        <script type="text/javascript">id_language = Number(' . $defaultLanguage . ');</script>';
        if (isset($responsiveLink)) {
            $this->_html .= '
            <a href="' . $this->getPageUrl(array('action=newlink')) . '" class="button"><span>' . $this->l('New link') . '</span></a>
            <form id="link-form" style="display:block;"';
        } else {
            $this->_html .= '
            <button class="button dropdown" section="link-form"><span>' . $this->l('Add a link') . '</span></button>
            <form id="link-form" ' . (Tools::getIsset('action') && Tools::getValue('action') == 'newlink' ? 'style="display:block;"' : '') . '';
        }
        $this->_html .= '
            class="dropdown-content" action="' . $this->getPageUrl() . '" method="post" enctype="multipart/form-data">
            <fieldset>
                <legend><img src="../img/admin/information.png" class="middle"> ' . $this->l('Link configuration') . '</legend>
                ';
        // Where the link will be displayed
        $this->_html .= '
            <div class="page_category step-1' . (isset($responsiveLink) ? ' hidden' : '') . '">
                <h3>' . $this->l('Step 1 : Choose where you want to display the link') . '.</h3>
                <div>
                    <label for="page_category">' . $this->l('Choose link location') . ' : </label>
                    <div class="margin-form">
                        <select name="page_category" id="page_category">
                            <option value="header" ' . (isset($responsiveLink) && $responsiveLink->page_category == 'header' ? 'selected="selected"' : '') . '>' . $this->l('Header') . '</option>
                            <option value="footer" ' . (isset($responsiveLink) && $responsiveLink->page_category == 'footer' ? 'selected="selected"' : '') . '>' . $this->l('Footer') . '</option>
                        </select>
                    </div>
                </div>';
        // If footer is the choice, select the column
        $this->_html .= '
                <div class="hide page_category_column_choice">
                    <label for="page_category_column">' . $this->l('Choose your column') . ' : </label>
                    <div class="margin-form">
                        <select name="page_category_column" id="page_category_column">
                            <option value="1" ' . (isset($responsiveLink) && $responsiveLink->page_category_column == '1' ? 'selected="selected"' : '') . '>' . $this->l('Browse') . '</option>
                            <option value="2" ' . (isset($responsiveLink) && $responsiveLink->page_category_column == '2' ? 'selected="selected"' : '') . '>' . $this->l('Site info') . '</option>
                        </select>
                    </div>
                </div>
            </div>';
        // parent ou non
        $this->_html .= '
            <div class="link-type' . (isset($responsiveLink) ? ' link-type-edition' : '') . '">
                <div class="option-parent step-2' . (isset($responsiveLink) ? ' hidden' : '') . '">
                <h3>' . $this->l('Step 2 : Choose is the link has a parent or not') . '.</h3>
                    <div class="option">
                        <label for="isparent">' . $this->l('Has a parent link?') . '</label>
                        <div class="margin-form">
                            <input type="radio" name="isparent" class="link-option" value="1">
                            <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                            <input type="radio" name="isparent" class="link-option" value="0" checked="checked">
                            <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                        </div>
                    </div>

                    <div class="option-block">
                        <label for="parent">' . $this->l('Choose your Parent link :') . '</label>
                        <div class="margin-form">
                            <select name="parent" id="parent" size="5">';
        /** @var $parentTemp ResponsiveLinksClass */
        foreach (ResponsiveLinksClass::findAll($this->context->cookie->id_lang, false) as $parentTemp) {
            $parentCategory = null;
            $parentCms = null;
            $parentProduct = null;
            if ($parentTemp->id_category != 0) {
                $parentCategory = new Category((int) $parentTemp->id_category, $this->context->cookie->id_lang);
                $this->_html .= '<option value="' . $parentTemp->id . '">' . $parentTemp->id . ' - ' . $parentCategory->name . '</option>';
            } elseif ($parentTemp->id_cms != 0) {
                $parentCms = new CMS((int) $parentTemp->id_cms, $this->context->cookie->id_lang);
                $this->_html .= '<option value="' . $parentTemp->id . '">' . $parentTemp->id . ' - ' . $parentCms->meta_title . '</option>';
            } elseif ($parentTemp->id_cms_category != 0) {
                $parentCmsCategory = new CMSCategory((int) $parentTemp->id_cms_category, $this->context->cookie->id_lang);
                $this->_html .= '<option value="' . $parentTemp->id . '">' . $parentTemp->id . ' - ' . $parentCmsCategory->name . '</option>';
            } elseif ($parentTemp->id_product != 0) {
                $parentProduct = new Product((int) $parentTemp->id_product, false, $this->context->cookie->id_lang);
                $this->_html .= '<option value="' . $parentTemp->id . '">' . $parentTemp->id . ' - ' . $parentProduct->name . '</option>';
            } else {
                $this->_html .= '<option value="' . $parentTemp->id . '">' . $parentTemp->id . ' - ' . $parentTemp->title . '</option>';
            }
        }
        $this->_html .= '
                            </select>
                            <p class="clear">' . $this->l('Choose a parent link for your link and a dropdown will appear in the nav bar for the parent') . '.</p>
                        </div>
                    </div>
                </div>';
        // category ou non
        $this->_html .= '
                <div class="step-3">
                    <h3 class="' . (isset($responsiveLink) ? 'hidden' : '') . '">' . $this->l('Step 3 : Choose your link type') . '.</h3>
                    <div class="option ' . (isset($responsiveLink) ? 'hidden' : '') . '">
                        <label for="iscategory">' . $this->l('Is a category link?') . '</label>
                        <div class="margin-form">
                            <input type="radio" name="iscategory" class="link-choice" value="1" ' . (isset($category) ? 'checked="checked"' : '') . '>
                            <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                            <input type="radio" name="iscategory" class="link-choice" value="0" ' . (isset($category) ? '' : 'checked="checked"') . '>
                            <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                        </div>
                    </div>

                    <div class="option-block ' . (isset($category) ? 'active' : '') . '">
                        <label for="category">' . $this->l('Choose your category page :') . '</label>
                        <div class="margin-form">
                            <select name="category" id="category" size="5">';
        foreach (Category::getSimpleCategories($this->context->cookie->id_lang) as $categoryTemp) {
            $this->_html .= '
                                <option value="' . $categoryTemp['id_category'] . '" ' . (isset($category) && $category->id == $categoryTemp['id_category'] ? 'selected="selected"' : '') . '>' . $categoryTemp['name'] . '</option>';
        }
        $this->_html .= '
                            </select>
                        </div>
                    </div>';
        // cms ou non
        $this->_html .= '
                    <div class="option ' . (isset($responsiveLink) ? 'hidden' : '') . '">
                        <label for="iscms">' . $this->l('Is a CMS link?') . '</label>
                        <div class="margin-form">
                            <input type="radio" name="iscms" class="link-choice" value="1" ' . (isset($cms) ? 'checked="checked"' : '') . '>
                            <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                            <input type="radio" name="iscms" class="link-choice" value="0" ' . (isset($cms) ? '' : 'checked="checked"') . '>
                            <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                        </div>
                    </div>

                    <div class="option-block ' . (isset($cms) ? 'active' : '') . '">
                        <label for="cms">' . $this->l('Choose your CMS page :') . '</label>
                        <div class="margin-form">
                            <select name="cms" id="cms"  size="5">';
        foreach (CMS::listCms($this->context->cookie->id_lang) as $cmsTemp) {
            $this->_html .= '
                                <option value="' . $cmsTemp['id_cms'] . '" ' . (isset($cms) && $cms->id == $cmsTemp['id_cms'] ? 'selected="selected"' : '') . '>' . $cmsTemp['meta_title'] . '</option>';
        }
        $this->_html .= '
                            </select>
                        </div>
                    </div>';
        // cms category or not
        $this->_html .= '
                    <div class="option ' . (isset($responsiveLink) ? 'hidden' : '') . '">
                        <label for="iscmscategory">' . $this->l('Is a CMS category link?') . '</label>
                        <div class="margin-form">
                            <input type="radio" name="iscmscategory" class="link-choice" value="1" ' . (isset($cmsCategory) ? 'checked="checked"' : '') . '>
                            <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                            <input type="radio" name="iscmscategory" class="link-choice" value="0" ' . (isset($cmsCategory) ? '' : 'checked="checked"') . '>
                            <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                        </div>
                    </div>

                    <div class="option-block ' . (isset($cmsCategory) ? 'active' : '') . '">
                        <label for="cms">' . $this->l('Choose your CMS Category page :') . '</label>
                        <div class="margin-form">
                            <select name="cmscategory" id="cmscategory" size="5">';
        foreach (CMSCategory::getSimpleCategories($this->context->cookie->id_lang) as $cmsCategoryTemp) {
            $this->_html .= '
                                <option value="' . $cmsCategoryTemp['id_cms_category'] . '" ' . (isset($cmsCategory) && $cmsCategory->id == $cmsCategoryTemp['id_cms_category'] ? 'selected="selected"' : '') . '>' . $cmsCategoryTemp['name'] . '</option>';
        }
        $this->_html .= '
                            </select>
                        </div>
                    </div>';
        // product ou non
        $this->_html .= '
                    <div class="option ' . (isset($responsiveLink) ? 'hidden' : '') . '">
                        <label for="isproduct">' . $this->l('Is a product link?') . '</label>
                        <div class="margin-form">
                            <input type="radio" name="isproduct" class="link-choice" value="1" ' . (isset($product) ? 'checked="checked"' : '') . '>
                            <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                            <input type="radio" name="isproduct" class="link-choice" value="0" ' . (isset($product) ? '' : 'checked="checked"') . '>
                            <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                        </div>
                    </div>

                    <div class="option-block ' . (isset($product) ? 'active' : '') . '">
                        <label for="product">' . $this->l('Choose your product page :') . '</label>
                        <div class="margin-form">
                            <input type="text" id="product_auto" name="product_auto" size="50"/>
                            <input type="hidden" id="product" name="product" />
                            <p class="clear">' . $this->l('Type a word to search products') . '.</p>
                        </div>
                    </div>';
        // custom ou non
        $this->_html .= '
                    <div class="option ' . (isset($responsiveLink) ? 'hidden' : '') . '">
                        <label for="iscustom">' . $this->l('Is a custom link?') . '</label>
                        <div class="margin-form">
                            <input type="radio" name="iscustom" class="link-choice" value="1" ' . (isset($custom) ? 'checked="checked"' : '') . '>
                            <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                            <input type="radio" name="iscustom" class="link-choice" value="0" ' . (isset($custom) ? '' : 'checked="checked"') . '>
                            <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                        </div>
                    </div>';
        //title field
        $this->_html .= '
                    <div class="option-block ' . (isset($custom) ? 'active' : '') . '">
                        <label>' . $this->l('Title :') . '</label>
                        <div class="margin-form">';
        foreach ($languages as $language) {
            $this->_html .= '
                            <div id="title_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">
                                <input class="required" type="text" name="title_' . $language['id_lang'] . '" id="title_' . $language['id_lang'] . '" size="35" value="' . (isset($responsiveLink->title[$language['id_lang']]) ? $responsiveLink->title[$language['id_lang']] : '') . '" />
                            </div>';
        }
        $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'title', true);
        $this->_html .= '
                            <p class="clear">' . $this->l('Link title') . '.</p>
                        </div>';
        //champ url
        $this->_html .= '
                        <label>' . $this->l('Url :') . '</label>
                        <div class="margin-form">';
        foreach ($languages as $language) {
            $this->_html .= '
                            <div id="url_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">
                                <input class="required" type="text" name="url_' . $language['id_lang'] . '" id="url_' . $language['id_lang'] . '" size="70" value="' . (isset($responsiveLink->url[$language['id_lang']]) ? $responsiveLink->url[$language['id_lang']] : '') . '" />
                            </div>';
        }
        $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'url', true);
        $this->_html .= '
                            <p class="clear">' . $this->l('Url of the link (leave blank is no url)') . '.</p>
                        </div>
                        </div>';
        $this->_html .= '
                        <div class="margin-form">';
        if (Tools::getIsset('action') && Tools::getIsset('action') == 'edit') {
            $this->_html .= '<input type="submit" value="' . $this->l('Save') . '" name="editLink" class="button">
                                    <input type="hidden" value="' . $responsiveLink->id . '" name="id" class="button">';
        } else {
            $this->_html .= '<input type="submit" value="' . $this->l('Save') . '" name="addLink" class="button">';
        }
        $this->_html .= '
                    </div>
                </div>
                </div>
            </fieldset>
        </form>';
        $this->_html .= '
        <fieldset>
            <legend><img src="../img/admin/tab-preferences.gif" class="middle"> ' . $this->l('Nav bar links') . '</legend>
            <p>' . $this->l('Edit your main nav links with the edit button and save it.') . '</p>
            <hr>
            <table id="links" class="table tableDnD updatePosition" cellpadding="0" cellspacing="0" style="width: 100%;">
                <thead>
                    <tr>
                        <th class="center">' . $this->l('Expand') . '</th>
                        <th class="center">' . $this->l('Id') . '</th>
                        <th class="center">' . $this->l('Position') . '</th>
                        <th>' . $this->l('Title') . '</th>
                        <th class="center">' . $this->l('Actions') . '</th>
                    </tr>
                </thead>
                <tbody>';
        /** @var $responsiveLink ResponsiveLinksClass */
        foreach (ResponsiveLinksClass::findAll($this->context->cookie->id_lang, true) as $responsiveLink) {
            $category = null;
            $cms = null;
            $product = null;
            if ($responsiveLink->id_category != 0) {
                $category = new Category((int) $responsiveLink->id_category, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_cms != 0) {
                $cms = new CMS((int) $responsiveLink->id_cms, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_cms_category != 0) {
                $cmsCategory = new CMSCategory((int) $responsiveLink->id_cms_category, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_product != 0) {
                $product = new Product((int) $responsiveLink->id_product, false, $this->context->cookie->id_lang);
            }
            $this->_html .= '
                    <tr id="node-' . $responsiveLink->id . '">
                        <td class="center"><img src="' . $this->_path . 'img/folder.png" alt="" /></td>
                        <td class="center">' . $responsiveLink->id . '</td>
                        <td class="center position"></td>
                        <td>';
            if (isset($category)) {
                $this->_html .= $category->name;
            } elseif (isset($cms)) {
                $this->_html .= $cms->meta_title;
            } elseif (isset($cmsCategory)) {
                $this->_html .= $cmsCategory->name;
            } elseif (isset($product)) {
                $this->_html .= $product->name;
            } else {
                $this->_html .= $responsiveLink->title;
            }
            $this->_html .= '
                        </td>
                        <td class="center">
                            <a href="' . $this->getPageUrl(array('id=' . $responsiveLink->id, 'action=edit')) . '" title="' . $this->l('Edit') . '">
                                <img src="../img/admin/edit.gif" alt="' . $this->l('Edit') . '" alt="' . $this->l('Edit') . '">
                            </a>
                            <a class="delete" href="' . $this->getPageUrl(array('id=' . $responsiveLink->id, 'action=delete')) . '" id="' . $responsiveLink->id . '" title="' . $this->l('Delete the link ?') . '">
                                <img src="../img/admin/delete.gif" alt="' . $this->l('Delete') . '" alt="' . $this->l('Delete') . '">
                            </a>
                        </td>
                    </tr>';
            $this->getSubLinks($responsiveLink->id, $this->context->cookie->id_lang);
        }
        $this->_html .= '
                </tbody>
            </table>
        </fieldset>

        <fieldset>
            <legend><img src="../img/admin/tab-preferences.gif" class="middle"> ' . $this->l('Footer links') . '</legend>
            <p>' . $this->l('Edit your footer links and save it') . '.</p>
            <hr>
            <h3>' . $this->l('Browse column') . '</h3>
            <table id="footer-browse-links" class="table tableDnD" cellpadding="0" cellspacing="0" style="width: 100%;">
                <thead>
                    <tr>
                        <th class="center">' . $this->l('Id') . '</th>
                        <th class="center">' . $this->l('Position') . '</th>
                        <th>' . $this->l('Title') . '</th>
                        <th class="center">' . $this->l('Actions') . '</th>
                    </tr>
                </thead>
                <tbody>';
        /** @var $responsiveLink ResponsiveLinksClass */
        foreach (ResponsiveLinksClass::findAll($this->context->cookie->id_lang, true, 'footer', 1) as $responsiveLink) {
            $category = null;
            $cms = null;
            $product = null;
            if ($responsiveLink->id_category != 0) {
                $category = new Category((int) $responsiveLink->id_category, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_cms != 0) {
                $cms = new CMS((int) $responsiveLink->id_cms, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_cms_category != 0) {
                $cmsCategory = new CMSCategory((int) $responsiveLink->id_cms_category, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_product != 0) {
                $product = new Product((int) $responsiveLink->id_product, false, $this->context->cookie->id_lang);
            }
            $this->_html .= '
                    <tr id="node-' . $responsiveLink->id . '">
                        <td class="center">' . $responsiveLink->id . '</td>
                        <td class="center position"></td>
                        <td>';
            if (isset($category)) {
                $this->_html .= $category->name;
            } elseif (isset($cms)) {
                $this->_html .= $cms->meta_title;
            } elseif (isset($cmsCategory)) {
                $this->_html .= $cmsCategory->name;
            } elseif (isset($product)) {
                $this->_html .= $product->name;
            } else {
                $this->_html .= $responsiveLink->title;
            }
            $this->_html .= '
                        </td>
                        <td class="center">
                            <a href="' . $this->getPageUrl(array('id=' . $responsiveLink->id, 'action=edit')) . '" title="' . $this->l('Edit') . '">
                                <img src="../img/admin/edit.gif" alt="' . $this->l('Edit') . '" alt="' . $this->l('Edit') . '">
                            </a>
                            <a class="delete" href="' . $this->getPageUrl(array('id=' . $responsiveLink->id, 'action=delete')) . '" id="' . $responsiveLink->id . '" title="' . $this->l('Delete the link ?') . '">
                                <img src="../img/admin/delete.gif" alt="' . $this->l('Delete') . '" alt="' . $this->l('Delete') . '">
                            </a>
                        </td>
                    </tr>';
        }
        $this->_html .= '
                </tbody>
            </table>
            <h3 style="margin-top: 10px;">' . $this->l('Site info column') . '</h3>
            <table id="footer-siteinfo-links" class="table tableDnD" cellpadding="0" cellspacing="0" style="width: 100%;">
                <thead>
                    <tr>
                        <th class="center">' . $this->l('Id') . '</th>
                        <th class="center">' . $this->l('Position') . '</th>
                        <th>' . $this->l('Title') . '</th>
                        <th class="center">' . $this->l('Actions') . '</th>
                    </tr>
                </thead>
                <tbody>';
        /** @var $responsiveLink ResponsiveLinksClass */
        foreach (ResponsiveLinksClass::findAll($this->context->cookie->id_lang, true, 'footer', 2) as $responsiveLink) {
            $category = null;
            $cms = null;
            $product = null;
            if ($responsiveLink->id_category != 0) {
                $category = new Category((int) $responsiveLink->id_category, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_cms != 0) {
                $cms = new CMS((int) $responsiveLink->id_cms, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_cms_category != 0) {
                $cmsCategory = new CMSCategory((int) $responsiveLink->id_cms_category, $this->context->cookie->id_lang);
            } elseif ($responsiveLink->id_product != 0) {
                $product = new Product((int) $responsiveLink->id_product, false, $this->context->cookie->id_lang);
            }
            $this->_html .= '
                    <tr id="node-' . $responsiveLink->id . '">
                        <td class="center">' . $responsiveLink->id . '</td>
                        <td class="center position"></td>
                        <td>';
            if (isset($category)) {
                $this->_html .= $category->name;
            } elseif (isset($cms)) {
                $this->_html .= $cms->meta_title;
            } elseif (isset($cmsCategory)) {
                $this->_html .= $cmsCategory->name;
            } elseif (isset($product)) {
                $this->_html .= $product->name;
            } else {
                $this->_html .= $responsiveLink->title;
            }
            $this->_html .= '
                        </td>
                        <td class="center">
                            <a href="' . $this->getPageUrl(array('id=' . $responsiveLink->id, 'action=edit')) . '" title="' . $this->l('Edit') . '">
                                <img src="../img/admin/edit.gif" alt="' . $this->l('Edit') . '" alt="' . $this->l('Edit') . '">
                            </a>
                            <a class="delete" href="' . $this->getPageUrl(array('id=' . $responsiveLink->id, 'action=delete')) . '" id="' . $responsiveLink->id . '" title="' . $this->l('Delete the link ?') . '">
                                <img src="../img/admin/delete.gif" alt="' . $this->l('Delete') . '" alt="' . $this->l('Delete') . '">
                            </a>
                        </td>
                    </tr>';
        }
        $this->_html .= '
                </tbody>
            </table>
        </fieldset>

        <form action="' . $this->getPageUrl() . '" method="post" enctype="multipart/form-data">
        <fieldset class="follow-type">
            <legend><img src="../img/admin/tab-preferences.gif" class="middle"> ' . $this->l('Follow us links') . '</legend>
            <p>' . $this->l('Edit your social links and save it') . '.</p>
            <hr>';
        // cms ou non
        $this->_html .= '
            <div class="option">
                <label for="isfacebook">' . $this->l('Facebook') . '</label>
                <div class="margin-form">
                    <input type="radio" name="isfacebook" class="link-option" value="1" ' . (isset($responsiveLinksConfiguration['FOLLOWFACEBOOK']) && $responsiveLinksConfiguration['FOLLOWFACEBOOK']['option'] == 1 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                    <input type="radio" name="isfacebook" class="link-option" value="0" ' . (!isset($responsiveLinksConfiguration['FOLLOWFACEBOOK']) || $responsiveLinksConfiguration['FOLLOWFACEBOOK']['option'] == 0 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                </div>
            </div>

            <div class="option-block ' . (isset($responsiveLinksConfiguration['FOLLOWFACEBOOK']) && $responsiveLinksConfiguration['FOLLOWFACEBOOK']['option'] == 1 ? 'active' : '') . '">
                <label for="facebookcontent">' . $this->l('Facebook page') . ' : </label>
                <div class="margin-form">
                    <input type="text" name="facebookcontent" size="150" value="' . $responsiveLinksConfiguration['FOLLOWFACEBOOK']['value'] . '"/>
                    <p class="clear">' . $this->l('Enter your Facebook page') . '</p>
                </div>
            </div>

            <div class="option">
                <label for="isyoutube">' . $this->l('Youtube') . ' : </label>
                <div class="margin-form">
                    <input type="radio" name="isyoutube" class="link-option" value="1" ' . (isset($responsiveLinksConfiguration['FOLLOWYOUTUBE']) && $responsiveLinksConfiguration['FOLLOWYOUTUBE']['option'] == 1 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                    <input type="radio" name="isyoutube" class="link-option" value="0" ' . (!isset($responsiveLinksConfiguration['FOLLOWYOUTUBE']) || $responsiveLinksConfiguration['FOLLOWYOUTUBE']['option'] == 0 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                </div>
            </div>

            <div class="option-block ' . (isset($responsiveLinksConfiguration['FOLLOWYOUTUBE']) && $responsiveLinksConfiguration['FOLLOWYOUTUBE']['option'] == 1 ? 'active' : '') . '">
                <label for="youtubecontent">' . $this->l('Youtube page ') . ' : </label>
                <div class="margin-form">
                    <input type="text" name="youtubecontent" size="150" value="' . $responsiveLinksConfiguration['FOLLOWYOUTUBE']['value'] . '"/>
                    <p class="clear">' . $this->l('Enter your Youtube page') . '</p>
                </div>
            </div>

            <div class="option">
                <label for="istwitter">' . $this->l('Twitter') . ' : </label>
                <div class="margin-form">
                    <input type="radio" name="istwitter" class="link-option" value="1" ' . (isset($responsiveLinksConfiguration['FOLLOWTWITTER']) && $responsiveLinksConfiguration['FOLLOWTWITTER']['option'] == 1 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                    <input type="radio" name="istwitter" class="link-option" value="0" ' . (!isset($responsiveLinksConfiguration['FOLLOWTWITTER']) || $responsiveLinksConfiguration['FOLLOWTWITTER']['option'] == 0 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                </div>
            </div>

            <div class="option-block ' . (isset($responsiveLinksConfiguration['FOLLOWTWITTER']) && $responsiveLinksConfiguration['FOLLOWTWITTER']['option'] == 1 ? 'active' : '') . '">
                <label for="twittercontent">' . $this->l('Twitter page') . ' : </label>
                <div class="margin-form">
                    <input type="text" name="twittercontent" size="150" value="' . $responsiveLinksConfiguration['FOLLOWTWITTER']['value'] . '"/>
                    <p class="clear">' . $this->l('Enter your Twitter page') . '</p>
                </div>
            </div>

            <div class="option">
                <label for="islinkedin">' . $this->l('LinkedIn') . ' : </label>
                <div class="margin-form">
                    <input type="radio" name="islinkedin" class="link-option" value="1" ' . (isset($responsiveLinksConfiguration['FOLLOWLINKEDIN']) && $responsiveLinksConfiguration['FOLLOWLINKEDIN']['option'] == 1 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '"></label>
                    <input type="radio" name="islinkedin" class="link-option" value="0" ' . (!isset($responsiveLinksConfiguration['FOLLOWLINKEDIN']) || $responsiveLinksConfiguration['FOLLOWLINKEDIN']['option'] == 0 ? 'checked="checked"' : '') . '>
                    <label class="t"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '"></label>
                </div>
            </div>

            <div class="option-block ' . (isset($responsiveLinksConfiguration['FOLLOWLINKEDIN']) && $responsiveLinksConfiguration['FOLLOWLINKEDIN']['option'] == 1 ? 'active' : '') . '">
                <label for="linkedincontent">' . $this->l('LinkedIn page') . ' : </label>
                <div class="margin-form">
                    <input type="text" name="linkedincontent" size="150" value="' . $responsiveLinksConfiguration['FOLLOWLINKEDIN']['value'] . '"/>
                    <p class="clear">' . $this->l('Enter your LinkedIn page') . '</p>
                </div>
            </div>

            <div class="margin-form">
                <input type="submit" value="' . $this->l('Save') . '" name="editFollow" class="button">
            </div>
        </fieldset>
        </form>';
    }
示例#14
0
 /**
  * returns the product categories list as an array indexed by category_id and containing the category name and the corresponding fia-net product family
  * 
  * @return array
  */
 private function loadProductCategories()
 {
     $categories = Category::getSimpleCategories($this->context->language->id);
     if (_PS_VERSION_ < '1.5') {
         $id_shop = 1;
     } else {
         $id_shop = Context::getContext()->shop->id;
     }
     $shop_categories = array();
     foreach ($categories as $category) {
         $fianetsceau_type = Tools::isSubmit('fianetsceau_' . $category['id_category'] . '_subcategory') ? Tools::getValue('fianetsceau_' . $category['id_category'] . '_subcategory') : $this->getFianetSubCategoryId($category['id_category'], $id_shop);
         $parent_id = $this->getFianetCategoryId($fianetsceau_type);
         $shop_categories[$category['id_category']] = array('name' => $category['name'], 'fianetsceau_type' => $fianetsceau_type, 'parent_id' => $parent_id);
     }
     return $shop_categories;
 }
示例#15
0
    private function updateCat()
    {
        $moduleName = Tools::getValue('moduleName');
        Db::getInstance()->execute('UPDATE
									' . _DB_PREFIX_ . 'category c
									INNER JOIN
									' . _DB_PREFIX_ . 'category c2
									ON
									c.id_parent = c2.`id_category_' . bqSQL($moduleName) . '`
									SET
									c.id_parent = c2.id_category
									WHERE c.`id_category_' . bqSQL($moduleName) . '` != 0');
        $category = new Category();
        $cats = $category->getSimpleCategories((int) Configuration::get('PS_LANG_DEFAULT'));
        foreach ($cats as $cat) {
            $cat = new Category((int) $cat['id_category']);
            $cat->level_depth = $cat->calcLevelDepth();
            $cat->update();
        }
    }
示例#16
0
 /**
  * Assign summary template
  */
 public function assignSummaryExecution()
 {
     $customer_points = (int) LoyaltyModule::getPointsByCustomer((int) $this->context->customer->id);
     $orders = LoyaltyModule::getAllByIdCustomer((int) $this->context->customer->id, (int) $this->context->language->id);
     $displayorders = LoyaltyModule::getAllByIdCustomer((int) $this->context->customer->id, (int) $this->context->language->id, false, true, (int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10, (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1);
     $this->context->smarty->assign(array('orders' => $orders, 'displayorders' => $displayorders, 'totalPoints' => (int) $customer_points, 'voucher' => LoyaltyModule::getVoucherValue($customer_points, (int) $this->context->currency->id), 'validation_id' => LoyaltyStateModule::getValidationId(), 'transformation_allowed' => $customer_points > 0, 'page' => (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1, 'nbpagination' => (int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10, 'nArray' => array(10, 20, 50), 'max_page' => floor(count($orders) / ((int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10)), 'pagination_link' => $this->getSummaryPaginationLink(array(), $this->context->smarty)));
     /* Discounts */
     $nb_discounts = 0;
     $discounts = array();
     if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer((int) $this->context->customer->id)) {
         $nb_discounts = count($ids_discount);
         foreach ($ids_discount as $key => $discount) {
             $discounts[$key] = new CartRule((int) $discount['id_cart_rule'], (int) $this->context->cookie->id_lang);
             $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount((int) $discount['id_cart_rule']);
         }
     }
     $all_categories = Category::getSimpleCategories((int) $this->context->cookie->id_lang);
     $voucher_categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY');
     if ($voucher_categories != '' && $voucher_categories != 0) {
         $voucher_categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'));
     } else {
         die(Tools::displayError());
     }
     if (count($voucher_categories) == count($all_categories)) {
         $categories_names = null;
     } else {
         $categories_names = array();
         foreach ($all_categories as $k => $all_category) {
             if (in_array($all_category['id_category'], $voucher_categories)) {
                 $categories_names[$all_category['id_category']] = trim($all_category['name']);
             }
         }
         if (!empty($categories_names)) {
             $categories_names = Tools::truncate(implode(', ', $categories_names), 100) . '.';
         } else {
             $categories_names = null;
         }
     }
     $this->context->smarty->assign(array('nbDiscounts' => (int) $nb_discounts, 'discounts' => $discounts, 'minimalLoyalty' => (double) Configuration::get('PS_LOYALTY_MINIMAL'), 'categories' => $categories_names));
     $this->setTemplate('loyalty.tpl');
 }
示例#17
0
    private function displayform()
    {
        $id_lang = $this->context->language->id;
        $pdf_dir_is_writable = is_writable(_PS_ROOT_DIR_ . '/modules/' . $this->name . '/pdf');
        $categories = Category::getSimpleCategories((int) $this->context->language->id);
        $manufacturers = Manufacturer::getManufacturers();
        $cat = '';
        foreach ($categories as $value) {
            $cat .= '<option value="' . $value['id_category'] . '">' . $value['name'] . '</option>';
        }
        $man = '<option value="0">' . $this->l('All manufacturers') . '</option>';
        foreach ($manufacturers as $value) {
            $man .= '<option value="' . $value['id_manufacturer'] . '">' . $value['name'] . '</option>';
        }
        // $tab = Tools::getValue('tab');
        // $token = Tools::getValue('token');
        $css = $this->_path . 'css';
        $js = $this->_path . 'js/';
        if (!$pdf_dir_is_writable) {
            $this->html .= '<div class=" alert-warning warning warn clear">';
            $this->html .= $this->l('To save bardcode in PDF, please assign CHMOD 777 to the directory:') . _PS_ROOT_DIR_ . '/modules/' . $this->name . '/pdf' . '</div>';
        }
        $this->html .= '
		<script type="text/javascript">
		var ajax_uri = "' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/ajaxsearch.php' . '";
		</script>
		<script type="text/javascript" src="' . $js . 'bqbarcodegeneration.js"></script>';
        $this->html .= '<script type="text/javascript" src="' . $js . 'jscolor.js"></script>';
        $this->html .= '<link type="text/css" rel="stylesheet" href="' . $css . '/css.css" />';
        $upcpdflink = $enapdflink = '';
        if (file_exists('../modules/' . $this->name . '/pdf/ean13.pdf')) {
            $enapdflink = '<a href="../modules/' . $this->name . '/pdf/ean13.pdf" class="button">' . $this->l('Download EAN13 PDF') . '</a>';
        }
        if (file_exists('../modules/' . $this->name . '/pdf/upc.pdf')) {
            $upcpdflink = '<a href="../modules/' . $this->name . '/pdf/upc.pdf" class="button">' . $this->l('Download UPC PDF') . '</a>';
        }
        $tb = Tools::getValue('tb');
        if (!$tb) {
            $tb = 1;
        }
        $this->html .= " <script>\r\n\t\t   \$(document).ready(function() {\r\n\t\t\t\r\n\t\t   //hiding tab content except first one\r\n\t\t\t  \$('.tabContent').not('#tab" . $tb . "').hide();\r\n\t\t\t  // adding Active class to first selected tab and show \r\n\t\t\t  \$('ul.tabs li.tab" . $tb . "').addClass('active').show();\r\n\t\t   \r\n\t\t\t  // Click event on tab\r\n\t\t\t  \$('ul.tabs li').click(function () {\r\n\t\t\t\t  // Removing class of Active tab\r\n\t\t\t\t  \$('ul.tabs li.active').removeClass('active');\r\n\t\t\t\t  // Adding Active class to Clicked tab\r\n\t\t\t\t  \$(this).addClass('active');\r\n\t\t\t\t  // hiding all the tab contents\r\n\t\t\t\t  \$('.tabContent').hide();\r\n\t\t\t\t  // showing the clicked tabs content using fading effect\r\n\t\t\t\t  \$(\$('a', this).attr('href')).fadeIn('slow')\r\n\t\t\t\t  return false;\r\n\t\t\t  });\r\n\t\t   });\r\n\t\t   \r\n\t\t</script>";
        $this->html .= '
			<ul class="tabs">
				<li class="tab1"><a href="#tab1"><img src="' . $this->_path . 'img/prefs.gif" />&nbsp;' . $this->l('Parameters') . '</a></li>
				<li class="tab2"><a href="#tab2"><img src="' . $this->_path . 'logo.gif" />&nbsp;' . $this->l('Generate missing codes') . '</a></li>
				<li class="tab3"><a href="#tab3"><img src="' . $this->_path . 'img/printer.gif" />&nbsp;' . $this->l('Print Barcode') . '</a></li>
				<li class="tab4"><a href="#tab4"><img src="' . $this->_path . 'img/pdf.gif" />' . $this->l('Download PDF') . '</a></li>
			</ul>
			<div class="tabContainer">
				<div id="tab1" class="tabContent">
						<form action="' . htmlentities($_SERVER['REQUEST_URI']) . '&tb=1" method="post">
						<label style="width:40%">' . $this->l('gs1 Prefixe :') . ' </label>
						<div class="margin-form">
						<input type="text" maxlength="3" size="3" value="' . (int) Configuration::get('JC-EANUPC-gs1') . '" id="gs1" name="gs1">
						&nbsp;<label for="gs1" class="t">' . $this->l('Enter gs1 prefix.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('EAN code :') . ' </label>
						<div class="margin-form">
						<input type="checkbox" value="1" id="bean" name="bean" ' . ((int) Configuration::get('JC-EANUPC-EAN') == 1 ? 'checked' : '') . '>
						&nbsp;<label for="bean" class="t">' . $this->l('Generate an EAN code after each product creation.') . '</label>
						</div>
						<div style="clear:both;">&nbsp;</div>
						<label style="width:40%">' . $this->l('UPC code :') . ' </label>
						<div class="margin-form">
						<input type="checkbox" value="1" id="bupc" name="bupc" ' . ((int) Configuration::get('JC-EANUPC-UPC') == 1 ? 'checked' : '') . '>
						&nbsp;<label for="bupc" class="t">' . $this->l('Generate an UPC code after each product creation.') . '</label>
						</div>
						<div style="clear:both;">&nbsp;</div>
						<label style="width:40%">' . $this->l('Set measure unit:') . ' </label>
						<div class="margin-form">
						<select name="unitmeasure">
						<option value="mm" ' . (Configuration::get('JC-EANUPC-unitmeasure') == 'mm' ? 'selected' : '') . '>' . $this->l(' mm: millimeter ') . '</option>
						<option value="in" ' . (Configuration::get('JC-EANUPC-unitmeasure') == 'in' ? 'selected' : '') . '>' . $this->l('in: inch') . '</option>
						<option value="pt" ' . (Configuration::get('JC-EANUPC-unitmeasure') == 'pt' ? 'selected' : '') . '>' . $this->l('pt:Point') . '</option>
						</select>
						</div>
						<label style="width:40%">' . $this->l('font Size :') . ' </label>
						<div class="margin-form">
						<input type="text" size="3" value="' . (int) Configuration::get('JC-EANUPC-font_size') . '" id="font_size" name="font_size">
						&nbsp;<label for="font_size" class="t">' . $this->l('Enter font size value.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Margin Top:') . ' </label>
						<div class="margin-form">
						<input type="text" size="3" value="' . (int) Configuration::get('JC-EANUPC-margin_top') . '" id="margin" name="margin_top">
						&nbsp;<label for="margin" class="t">' . $this->l('Enter numeric value of top margin.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Margin bottom:') . ' </label>
						<div class="margin-form">
						<input type="text" size="3" value="' . (int) Configuration::get('JC-EANUPC-margin_bottom') . '" id="margin" name="margin_bottom">
						&nbsp;<label for="margin" class="t">' . $this->l('Enter numeric value of bottom margin.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Margin Left:') . ' </label>
						<div class="margin-form">
						<input type="text" size="3" value="' . (int) Configuration::get('JC-EANUPC-margin_left') . '" id="margin" name="margin_left">
						&nbsp;<label for="margin" class="t">' . $this->l('Enter numeric value of left margin.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Margin Right:') . ' </label>
						<div class="margin-form">
						<input type="text" size="3" value="' . (int) Configuration::get('JC-EANUPC-margin_right') . '" id="margin" name="margin_right">
						&nbsp;<label for="margin" class="t">' . $this->l('Enter numeric value of right margin.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Barcode Height :') . ' </label>
						<div class="margin-form">
						<input type="text"size="3" value="' . (double) Configuration::get('JC-EANUPC-barheight') . '" id="barheight" name="barheight">
						&nbsp;<label for="barheight" class="t">' . $this->l('Enter Barcode height.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Block Height :') . ' </label>
						<div class="margin-form">
						<input type="text"size="3" value="' . (double) Configuration::get('JC-EANUPC-blocheight') . '" id="blocheight" name="blocheight">
						&nbsp;<label for="blocheight" class="t">' . $this->l('Enter barcode container height.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Barcode Width :') . ' </label>
						<div class="margin-form">
						<input type="text"size="3" value="' . (double) Configuration::get('JC-EANUPC-barwidth') . '" id="barwidth" name="barwidth">
						&nbsp;<label for="barwidth" class="t">' . $this->l('Enter Barcode width.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Bloc Width :') . ' </label>
						<div class="margin-form">
						<input type="text"size="3" value="' . (double) Configuration::get('JC-EANUPC-blocwidth') . '" id="blocwidth" name="blocwidth">
						&nbsp;<label for="blocwidth" class="t">' . $this->l('Enter barcode container width.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Barcode container width border :') . ' </label>
						<div class="margin-form">
						<select name="blockborder">
						<option value="0" ' . (Configuration::get('JC-EANUPC-blockborder') == 0 ? 'selected' : '') . '>' . $this->l('no ') . '</option>
						<option value="1" ' . (Configuration::get('JC-EANUPC-blockborder') == 1 ? 'selected' : '') . '>' . $this->l('yes') . '</option>
						</select>
						</div>
						<input type="hidden" name="stretch" value="0">
						<label style="width:40%">' . $this->l('Color :') . ' </label>
						<div class="margin-form">
						<input type="text"maxlength="6" value="' . (Configuration::get('JC-EANUPC-color') ? Configuration::get('JC-EANUPC-color') : '000000') . '"
						id="picker" class="color" name="color">
						&nbsp;<label for="color" class="t">' . $this->l('Barcode color in hexa.') . '</label>
						</div>
						<label style="width:40%">' . $this->l('Barcode with border :') . ' </label>
						<div class="margin-form">
						<select name="setborder">
						<option value="1" ' . ((int) Configuration::get('JC-EANUPC-setborder') == 1 ? 'selected' : '') . '>' . $this->l('no ') . '</option>
						<option value="2" ' . ((int) Configuration::get('JC-EANUPC-setborder') == 2 ? 'selected' : '') . '>' . $this->l('yes') . '</option>
						</select>
						</div>
						<label style="width:40%">' . $this->l('Show product name :') . ' </label><div class="margin-form">
						<select name="productname">
						<option value="0" ' . ((int) Configuration::get('JC-EANUPC-productname') == 0 ? 'selected' : '') . '>' . $this->l('no ') . '</option>
						<option value="1" ' . ((int) Configuration::get('JC-EANUPC-productname') == 1 ? 'selected' : '') . '>' . $this->l('yes') . '</option>
						</select>
						</div>
						<label style="width:40%">' . $this->l('Show product price :') . ' </label>
						<div class="margin-form">
						<select name="productprice">
						<option value="0" ' . ((int) Configuration::get('JC-EANUPC-productprice') == 0 ? 'selected' : '') . '>' . $this->l('no ') . '</option>
						<option value="1" ' . ((int) Configuration::get('JC-EANUPC-productprice') == 1 ? 'selected' : '') . '>' . $this->l('yes') . '</option>
						</select>
						</div>
						
						<label style="width:40%">' . $this->l('Use reduced price :') . ' </label>
						<div class="margin-form">
						<select name="usereduction">
						<option value="0" ' . ((int) Configuration::get('JC-EANUPC-usereduction') == 0 ? 'selected' : '') . '>' . $this->l('no ') . '</option>
						<option value="1" ' . ((int) Configuration::get('JC-EANUPC-usereduction') == 1 ? 'selected' : '') . '>' . $this->l('yes') . '</option>
						</select>
						</div>
						
						<label style="width:40%">' . $this->l('Show product reference :') . ' </label>
						<div class="margin-form">
						<select name="productref">
						<option value="0" ' . ((int) Configuration::get('JC-EANUPC-productref') == 0 ? 'selected' : '') . '>' . $this->l('no ') . '</option>
						<option value="1" ' . ((int) Configuration::get('JC-EANUPC-productref') == 1 ? 'selected' : '') . '>' . $this->l('yes') . '</option>
						</select>
						</div> 
						<label style="width:40%">' . $this->l('maximum number of character for the product name:') . ' </label>
						<div class="margin-form">
						<input type="text"size="3" value="' . (int) Configuration::get('JC-EANUPC-truncateproductname') . '" id="blocwidth" name="truncateproductname">
						</div>
						<div class="margin-form">
						<br />
						<input type="submit" value="' . $this->l(' Save ') . '" name="submitParam" class="button" />
						</div>
						</form>
						<div>
						<label for="blocwidth" class="t">' . $this->l('Use a period instead of a comma, it\'s about the fields with height and width') . '</label>
						</div>
				</div>
				<div id="tab2" class="tabContent">
						<form action="' . htmlentities($_SERVER['REQUEST_URI']) . '&tb=2" method="post">
						<div style="clear:both;">&nbsp;</div>
						<label style="width:40%">' . $this->l('Select categorie:') . ' </label>
						<div class="margin-form">
						<select name="categorie_generate_id" id="categorie_generate_id">
						<option value="0">' . $this->l('All categories') . '</option>
						' . $cat . '
						</select>
						</div>
						<label style="width:40%">' . $this->l('Type :') . ' </label>
						<div class="margin-form">
						<select id="type" name="typeTogenerate">
						<option value="0">' . $this->l('EAN13 + UPC') . '</option>
						<option value="ean13">' . $this->l('EAN13') . '</option>
						<option value="upc">' . $this->l('UPC') . '</option>
						</select>
						&nbsp;<label for="gs1" class="t">' . $this->l('Type') . '</label>
						</div>
						<br><br>
						<div class="margin-form">
						<input type="submit" value="' . $this->l(' Generate missing codes ') . '" name="submitUpdate" class="button" />
						</div>
						</form>
						
				</div>
				<div id="tab3" class="tabContent">
						<form action="' . htmlentities($_SERVER['REQUEST_URI']) . '&tb=3" method="post" id="ajaxform">
						<div style="clear:both;">&nbsp;</div>
						<label style="width:40%">' . $this->l('Select categorie:') . ' </label>
						<div class="margin-form">
							<select name="categorie_id" id="categorie_id">
								' . $cat . '
							</select>
						</div>
						<div style="clear:both;">&nbsp;</div>
						<label style="width:40%">' . $this->l('Choose one or more products') . ' </label>
						<div class="margin-form">
							<select name="product_id[]" id="product_id" multiple size=8>
								<option value="0">' . $this->l('Choose') . '</option>
							</select>
							' . $this->l('Hit Ctrl button to select multiple products') . '
						</div>
						<div style="clear:both;">&nbsp;</div>
						
						<label style="width:40%" class="decl">' . $this->l('Choose one or more declinaison') . ' </label>
						<div class="margin-form decl">
							<select name="declinaisons_id[]" id="declinaisons_id" multiple size=8>
								<option value="0">' . $this->l('Choose') . '</option>
							</select>
							' . $this->l('Hit Ctrl button to select multiple declinaisons') . '
						</div>
						<div style="clear:both;">&nbsp;</div>
						
						<label style="width:40%">' . $this->l('Filter by manufacturer:') . ' </label>
						<div class="margin-form">
							<select name="manufacturer_id" id="manufacturer_id">
								' . $man . '
							</select>
						</div>
						<div style="clear:both;">&nbsp;</div>
						<label style="width:40%">' . $this->l('Select the size of print paper') . ' </label>
						<div class="margin-form">
							<select name="printformat">
								<option value="C76">' . $this->l('Tiquet 80mm (C7) ') . '</option>
								<option value="A2">' . $this->l('A2') . '</option>
								<option value="A3">' . $this->l('A3') . '</option>
								<option value="A4">' . $this->l('A4') . '</option>
								<option value="A5">' . $this->l('A5') . '</option>
								<option value="A6">' . $this->l('A6') . '</option>
								<option value="A7">' . $this->l('A7') . '</option>
							</select>
							
						</div>
						/
						<label style="width:40%">' . $this->l('Or enter custom format') . ' </label>
						<div class="margin-form">
						' . $this->l('width') . ' <input type="text" maxlength="6" name="customprintformatwidth"/> ' . $this->l('height') . '  : 
						<input type="text" maxlength="6" name="customprintformatheight"/><br> ' . $this->l('Keep empty if you want to use format in listbox') . '
						</div>
						<label style="width:40%">' . $this->l('Copy number by code') . ' </label>
						<div class="margin-form">
						<input type="text" maxlength="6" name="nbproduct" value="1"/>' . $this->l('If 0, the value of quantity available will be taken.') . ' 
						</div>
						<label style="width:40%">' . $this->l('Orientation:') . ' </label>
						<div class="margin-form">
						<select name="orientation">
						<option value="P" selected>' . $this->l(' P : Portrait ') . '</option>
						<option value="L">' . $this->l('L : Landscape') . '</option>
						</select>
						</div>
						<label style="width:40%">' . $this->l('Type :') . ' </label>
						<div class="margin-form">
						<select id="type" name="type">
						<option value="ean13">' . $this->l('EAN13') . '</option>
						<option value="upc">' . $this->l('UPC') . '</option>
						</select>
						&nbsp;<label for="gs1" class="t">' . $this->l('Type') . '</label>
						</div>
						<div class="margin-form">
						<br>
						<input type="hidden" name="id_lang" id="id_lang" value="' . $id_lang . '">
						<input type="submit" value="' . $this->l(' Print Barecodes ') . '" name="submitPrint" class="button" />
						</div>
						</form>
				</div>
				<div id="tab4" class="tabContent">
						' . $upcpdflink . ' || ' . $enapdflink . '
				</div> 
						 
			</div>';
    }
 /**
  * @return array
  */
 public function getItems()
 {
     $categoryItems = array();
     $result = array();
     $exportRootCategories = Configuration::get('SG_EXPORT_ROOT_CATEGORIES') == 1 ? true : false;
     $skippedRootCategories = array();
     foreach (Category::getSimpleCategories($this->getPlugin()->getLanguageId()) as $category) {
         /** @var CategoryCore $categoryInfo */
         $categoryInfo = new Category($category['id_category']);
         $categoryLinkRewrite = $categoryInfo->getLinkRewrite($categoryInfo->id_category, $this->getPlugin()->getLanguageId());
         $isRootCategory = $categoryInfo->is_root_category;
         /**
          * skip root categories
          */
         if ($categoryInfo->is_root_category && !$exportRootCategories) {
             $skippedRootCategories[] = $categoryInfo->id_category;
             continue;
         }
         $categoryItem = array();
         $categoryItem['category_number'] = $categoryInfo->id_category;
         $categoryItem['category_name'] = $categoryInfo->getName($this->getPlugin()->getLanguageId());
         $categoryItem['parent_id'] = $isRootCategory || in_array($categoryInfo->id_category, $skippedRootCategories) ? '' : $categoryInfo->id_parent;
         $categoryItem['is_active'] = $categoryInfo->active;
         $categoryItem['url_deeplink'] = $this->getPlugin()->getContext()->link->getCategoryLink($categoryInfo->id_category, $categoryLinkRewrite, $this->getPlugin()->getLanguageId());
         $categoryImageUrl = $this->getPlugin()->getContext()->link->getCatImageLink($categoryLinkRewrite, $categoryInfo->id_category, sprintf(self::PS_CONST_IMAGE_TYPE_CATEGORY_DEFAULT, '_'));
         $categoryItem['url_image'] = $categoryImageUrl;
         $categoryItem['order_index'] = $categoryInfo->position;
         $categoryItems[] = $categoryItem;
     }
     /**
      * clean root categories
      */
     if (!$exportRootCategories) {
         foreach ($categoryItems as $key => $categoryItem) {
             if (in_array($categoryItem['parent_id'], $skippedRootCategories)) {
                 $categoryItems[$key]['parent_id'] = '';
             }
         }
     }
     $categoryPositionData = array();
     foreach ($categoryItems as $categoryItem) {
         $key = $categoryItem['parent_id'] == '' ? 'root' : $categoryItem['parent_id'];
         if (!array_key_exists($key, $categoryPositionData)) {
             $categoryPositionData[$key] = 0;
         } else {
             $categoryPositionData[$key]++;
         }
     }
     $categoryNewPositionData = array();
     foreach ($categoryItems as $categoryItem) {
         $key = $categoryItem['parent_id'] == '' ? 'root' : $categoryItem['parent_id'];
         if (!array_key_exists($key, $categoryNewPositionData)) {
             $categoryNewPositionData[$key] = 0;
         } else {
             $categoryNewPositionData[$key]++;
         }
         $categoryItem['order_index'] = $categoryPositionData[$key] - $categoryNewPositionData[$key];
         $result[] = $categoryItem;
     }
     return $result;
 }
 public function postProcess()
 {
     // Warehouse
     $warehouses = Warehouse::getWarehouses(true);
     // if we already pick a warehouse source and location, we filter on twice to not display selections of the other
     if (Tools::isSubmit('warehouseA') && Tools::getValue('warehouseA') != -1 && Tools::isSubmit('warehouseB') && Tools::getValue('warehouseB') != -1) {
         $warehouseA = Tools::getValue('warehouseA');
         $warehouseB = Tools::getValue('warehouseB');
         $warehousesA = array();
         $warehousesB = array();
         foreach ($warehouses as $warehouse) {
             if ($warehouse['id_warehouse'] != $warehouseA) {
                 array_push($warehousesB, $warehouse);
             }
             if ($warehouse['id_warehouse'] != $warehouseB) {
                 array_push($warehousesA, $warehouse);
             }
         }
     } elseif (Tools::isSubmit('warehouseA') && Tools::getValue('warehouseA') != -1) {
         $warehouseA = Tools::getValue('warehouseA');
         $warehousesB = array();
         foreach ($warehouses as $warehouse) {
             if ($warehouse['id_warehouse'] != $warehouseA) {
                 array_push($warehousesB, $warehouse);
             }
         }
         $warehousesA = $warehouses;
         // Restaure B list on no selection
         $this->context->smarty->assign(array('warehouseB' => -1));
     } elseif (Tools::isSubmit('warehouseB') && Tools::getValue('warehouseB') != -1) {
         $warehouseB = Tools::getValue('warehouseB');
         $warehousesA = array();
         foreach ($warehouses as $warehouse) {
             if ($warehouse['id_warehouse'] != $warehouseB) {
                 array_push($warehousesA, $warehouse);
             }
         }
         $warehousesB = $warehouses;
     } else {
         $warehousesA = $warehouses;
         $warehousesB = $warehouses;
     }
     // validate_transfer
     if (Tools::isSubmit('validate_transfer')) {
         $transfer_ok = false;
         if (Tools::isSubmit('id_stockA') && Tools::isSubmit('id_stockB') && Tools::isSubmit('id_employee') && Tools::isSubmit('firstname') && Tools::isSubmit('lastname') && Tools::isSubmit('values')) {
             // After transfert, delete cookies to get a blank display
             if (Tools::isSubmit('deleteCookie')) {
                 $cookie = new Cookie('psAdmin');
                 $cookie->warehouseA = '';
                 $cookie->warehouseB = '';
             }
             /*  Initialisation */
             $ids_mvt = array();
             // Call the helper "traducteur" of the chain transfert
             require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/helpers/StockTransferHelper.php';
             require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/stock/ErpStock.php';
             $values = StockTransferHelper::getTransfertDataAsArray(Tools::getValue('values'));
             /* For each movement recorded */
             foreach ($values as $value) {
                 $id_product = $value['id_product'];
                 $id_product_attribute = $value['id_product_attribute'];
                 $transfer_quantity = $value['quantity'];
                 $id_stock_s1 = $value['id_stock_s1'];
                 $id_stock_s2 = $value['id_stock_s2'];
                 if (empty($id_stock_s1)) {
                     $this->errors[] = 'Error while updating the stock for a product : stock id missing !';
                     return true;
                 }
                 // update stock un warehouse A (source)
                 $stock = new ErpStock((int) $id_stock_s1);
                 $stock->physical_quantity -= $transfer_quantity;
                 $stock->usable_quantity -= $transfer_quantity;
                 if ($stock->physical_quantity < 0) {
                     $stock->physical_quantity = 0;
                 }
                 if ($stock->usable_quantity < 0) {
                     $stock->usable_quantity = 0;
                 }
                 /*  Update Stock */
                 if ($stock->update()) {
                     /*  Movment A to B */
                     $stock_mvt = new ErpStockMvt();
                     $stock_mvt->id_stock = $stock->id;
                     $stock_mvt->id_order = 0;
                     $stock_mvt->id_supply_order = 0;
                     $stock_mvt->id_stock_mvt_reason = 6;
                     $stock_mvt->id_employee = Tools::getValue('id_employee');
                     $stock_mvt->employee_firstname = Tools::getValue('firstname');
                     $stock_mvt->employee_lastname = Tools::getValue('lastname');
                     $stock_mvt->price_te = $stock->getPriceTe();
                     $stock_mvt->current_wa = $stock->getPriceTe();
                     $stock_mvt->sign = -1;
                     $stock_mvt->physical_quantity = $transfer_quantity;
                     // if movment OK, update stock in B warehouse (location)
                     if ($stock_mvt->add(true)) {
                         // add id movment stock generated (useful to generate the warehouse delivery notice)
                         array_push($ids_mvt, $stock_mvt->getLastId());
                         if ((int) $id_stock_s2 > 0) {
                             $stock_s2 = new ErpStock((int) $id_stock_s2);
                             $stock_s2->physical_quantity += $transfer_quantity;
                             $stock_s2->usable_quantity += $transfer_quantity;
                         } else {
                             require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/ErpProduct.php';
                             //get product information
                             $product_stock = new ProductCore((int) $id_product, (int) $id_product_attribute);
                             // stock not existe we add row in stock table
                             $stock_s2 = new ErpStock();
                             $stock_s2->physical_quantity += $transfer_quantity;
                             $stock_s2->usable_quantity += $transfer_quantity;
                             $stock_s2->id_product = (int) $id_product;
                             $stock_s2->id_product_attribute = (int) $id_product_attribute;
                             $stock_s2->id_warehouse = (int) Tools::getValue('id_stockB');
                             $stock_s2->price_te = $product_stock->wholesale_price;
                             $stock_s2->ean13 = $product_stock->ean13;
                             $stock_s2->upc = $product_stock->upc;
                         }
                         /*  of OK, movment from B to A */
                         if ($stock_s2->save()) {
                             $stock_mvt->id_stock = $stock_s2->id;
                             $stock_mvt->id_stock_mvt_reason = 7;
                             $stock_mvt->sign = 1;
                             // add id movment stock generated (useful to generate warehouse inter delivery)
                             if ($stock_mvt->add(true)) {
                                 array_push($ids_mvt, $stock_mvt->getLastId());
                             } else {
                                 $this->errors[] = 'Error while updating the stock for a product';
                             }
                         } else {
                             $this->errors[] = 'Error while updating the stock for a product';
                         }
                     } else {
                         $this->errors[] = 'Error while updating the stock for a product';
                     }
                 } else {
                     $this->errors[] = 'Error while updating the stock for a product';
                 }
                 // synchronize availbale stock ::quantity
                 StockAvailable::synchronize($id_product);
             }
             $ids_mvt = implode('|', $ids_mvt);
             // we reset values
             $transfer_ok = true;
         }
     }
     // transfer is ok, we redirect the user to home page of transfer
     if (Tools::isSubmit('validate_transfer') && isset($transfer_ok) && $transfer_ok) {
         $url_redirect = self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminStockTransfer');
         $url_redirect .= '&validate_transfer&ids_mvt=' . $ids_mvt . '&ids_mvt_csv=' . Tools::getValue('ids_mvt_csv');
         $url_redirect .= '&id_warehouse_src=' . Tools::getValue('id_warehouse_src') . '&id_warehouse_dst=' . Tools::getValue('id_warehouse_dst');
         Tools::redirectAdmin($url_redirect);
     }
     if (Tools::isSubmit('ids_mvt_csv') && Tools::isSubmit('get_csv_transfer')) {
         $this->renderCSV();
     }
     // Generate PDF of tranfert
     if (Tools::isSubmit('ids_mvt') && Tools::isSubmit('action') && Tools::getValue('action') == 'generateTransferPDF') {
         $this->processGenerateTransferPDF();
     }
     // to get erp feature list
     require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpFeature.php';
     // send warehouse liste to template
     $this->context->smarty->assign(array('warehousesA' => $warehousesA, 'warehousesB' => $warehousesB, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'suppliers' => Supplier::getSuppliers(), 'manufacturers' => Manufacturer::getManufacturers(), 'id_category' => -1, 'id_supplier' => -1, 'id_manufacturer' => -1, 'name_or_ean' => '', 'erp_feature' => ErpFeature::getFeaturesWithToken($this->context->language->iso_code), 'template_path' => $this->template_path));
 }
示例#20
0
    public function displayFormSettings()
    {
        $conf = Configuration::getMultiple(array('RNP_MERCHID', 'RNP_TYPE_DISPLAY', 'RNP_CRYPTKEY', 'RNP_DEFAULTCATEGORYID', 'RNP_NBDELIVERYDAYS', 'RNP_AVAILABILITY', 'RNP_PRODUCTION'));
        $production = array_key_exists('rnp_production', $_POST) ? $_POST['rnp_production'] : (array_key_exists('RNP_PRODUCTION', $conf) ? $conf['RNP_PRODUCTION'] : '');
        $merchid = array_key_exists('merchid', $_POST) ? $_POST['merchid'] : (array_key_exists('RNP_MERCHID', $conf) ? $conf['RNP_MERCHID'] : '');
        $merchidtest = array_key_exists('merchidtest', $_POST) ? $_POST['merchidtest'] : (array_key_exists('RNP_MERCHIDTEST', $conf) ? $conf['RNP_MERCHIDTEST'] : '');
        $typeihm = array_key_exists('typeihm', $_POST) ? $_POST['typeihm'] : (array_key_exists('RNP_TYPE_DISPLAY', $conf) ? explode(",", $conf['RNP_TYPE_DISPLAY']) : '');
        $cryptkey = array_key_exists('cryptkey', $_POST) ? $_POST['cryptkey'] : (array_key_exists('RNP_CRYPTKEY', $conf) ? $conf['RNP_CRYPTKEY'] : '');
        $cryptkeytest = array_key_exists('cryptkeytest', $_POST) ? $_POST['cryptkeytest'] : (array_key_exists('RNP_CRYPTKEYTEST', $conf) ? $conf['RNP_CRYPTKEYTEST'] : '');
        $category_id = array_key_exists('category_id', $_POST) ? $_POST['category_id'] : (array_key_exists('RNP_DEFAULTCATEGORYID', $conf) ? $conf['RNP_DEFAULTCATEGORYID'] : '');
        $availability = array_key_exists('rnp_availability', $_POST) ? $_POST['rnp_availability'] : (array_key_exists('RNP_AVAILABILITY', $conf) ? $conf['RNP_AVAILABILITY'] : '');
        $nb_delivery_days = array_key_exists('nb_delivery_days', $_POST) ? $_POST['nb_delivery_days'] : (array_key_exists('RNP_NBDELIVERYDAYS', $conf) ? $conf['RNP_NBDELIVERYDAYS'] : '');
        $id_lang = Configuration::get('PS_LANG_DEFAULT');
        $categories = Category::getSimpleCategories($id_lang);
        $carriers = Carrier::getCarriers($id_lang, false, false, false, NULL, false);
        $rnp_categories = $this->getRNPCategories();
        $this->_html .= '
		<fieldset><legend>' . $this->l('Settings "Kwixo"') . '</legend>
		<p>' . $this->l('The following parameters were provided to you by FIA-NET / KWIXO') . '. ' . $this->l('If you are not yet registered, click ') . ' <a style="color:blue;text-decoration:underline" href="http://recette.kwixo.com/homebo/index.htm">' . $this->l('here') . '</a>
		<!--<a href="http://recette.kwixo.com/homebo/index.htm"><img src="../modules/kwixo/logoKwixo_Cr_V.png" alt="logo" style="width:100px"/></a>-->
		<br/><br/></p>
		<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
			<label for="rnp_production">' . $this->l('Environment') . '</label>
			<div class="margin-form">
				<!--<input type="checkbox" value="1" id="rnp_production" name="rnp_production" ' . ($production == 1 ? 'checked="checked"' : '') . ' />-->
				<input type="radio" value="1" name="rnp_production" ' . ($production == 1 ? 'checked="checked"' : '') . ' /> <label class="t">' . $this->l('Production') . '</label> ' . $this->l('(in this mode, you will receive real payments)') . '<br/>
				<input type="radio" value="0" name="rnp_production" ' . ($production == 0 ? 'checked="checked"' : '') . ' /> <label class="t">' . $this->l('Test') . '</label> ' . $this->l('(this mode only allows you to test if this Kwixo module is working well but you won\'t receive payments)') . '
			</div>
			<label for="merchid">' . $this->l('Merch Id') . '</label>
			<div class="margin-form"><input type="text" name="merchid" id="merchid" value="' . Tools::safeOutput($merchid) . '" size="10" /></div>
			<label for="cryptkey">' . $this->l('Crypt key') . '</label>
			<div class="margin-form"><input type="text" name="cryptkey" id="cryptkey" value="' . Tools::safeOutput($cryptkey) . '" size="40" /></div>
			<br />
			<label>' . $this->l('Type of payment accepted') . '</label>
			<div class="margin-form">
				<input type="checkbox" name="typeihm[]" id="typeihm1" value="1" ' . (in_array('1', $typeihm) ? 'checked="checked"' : '') . ' />
				<label for="typeihm1" class="t">' . $this->l('Comptant') . '</label>
				<br/>
				<input type="checkbox" name="typeihm[]" id="typeihm2" value="2" ' . (in_array('2', $typeihm) ? 'checked="checked"' : '') . ' />
				<label for="typeihm2" class="t">' . $this->l('Crédit') . '</label>
				<br/>
				<input type="checkbox" name="typeihm[]" id="typeihm2" value="3" ' . (in_array('3', $typeihm) ? 'checked="checked"' : '') . ' />
				<label for="typeihm2" class="t">' . $this->l('Standard') . '</label>
				<br/>
			</div>
			<label for="nb_delivery_days">' . $this->l('Delay for delivery') . '</label>
			<div class="margin-form"><input type="text" name="nb_delivery_days" id="nb_delivery_days" value="' . Tools::safeOutput($nb_delivery_days) . '" size="5" /> ' . $this->l('days') . '</div>
			</fieldset>
		<!--<br/>
				<fieldset><legend>' . $this->l('Test account') . '</legend>
					<label for="merchidtest">' . $this->l('Merch Id') . '</label>
					<div class="margin-form"><input type="text" name="merchidtest" id="merchidtest" value="' . Tools::safeOutput($merchidtest) . '" size="10" /></div>
					<label for="cryptkeytest">' . $this->l('Crypt key') . '</label>
					<div class="margin-form"><input type="text" name="cryptkeytest" id="cryptkeytest" value="' . Tools::safeOutput($cryptkeytest) . '" size="40" /></div>
				</fieldset>-->
			<br/>
		<fieldset>
			<legend>' . $this->l('Information on products sold on your shop') . '</legend>
			<p>' . $this->l('For a better assistance, Kwixo needs to know what are the main product types you sell') . ' :</p><br/>
			<label for="category_id">' . $this->l('Default product type') . '</label>
			<div class="margin-form">
				<select name="category_id" id="category_id">
					<option value="0">' . $this->l('Choose a type...') . '</option>';
        $html_category = '';
        foreach ($this->categories as $id => $category) {
            $this->_html .= '<option value="' . $id . '"';
            if ($category_id == $id) {
                $this->_html .= ' selected="selected"';
            }
            $this->_html .= '>' . $category . '</option>';
        }
        $this->_html .= '
				</select> <span style="color:red">*</span>
				</div>';
        foreach ($categories as $category) {
            $this->_html .= '
				<label for="cat_' . $category['id_category'] . '">' . $category['name'] . '</label>
				<div class="margin-form">
					<select name="cat_' . $category['id_category'] . '" id="cat_' . $category['id_category'] . '">
						<option value="0">' . $this->l('Choose a type...') . '</option>';
            foreach ($this->categories as $id => $cat) {
                $this->_html .= '<option value="' . $id . '"' . (Configuration::get('RNP_CAT_TYPE_' . $category['id_category']) == $id ? ' selected="selected"' : '') . '>' . $cat . '</option>';
            }
            $this->_html .= '</select></div><div class="clear"></div>';
        }
        $this->_html .= '
			</fieldset>
			<br class="clear" />
			<fieldset><legend>' . $this->l('Carrier Configuration') . '</legend>
			<p>' . $this->l('Please select a carrier type for each carrier use on your shop') . ' :</p><br/>
				<label>' . $this->l('Carrier Detail') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Carrier') . '</th><th>' . $this->l('Carrier Type') . '</th></tr></thead><tbody>';
        foreach ($carriers as $carrier) {
            $this->_html .= '<tr><td>' . $carrier['name'] . '</td><td><select name="carrier_' . $carrier['id_carrier'] . '" id="carrier_' . $carrier['id_carrier'] . '">
			<option value="0">' . $this->l('Choose a carrier type...') . '</option>';
            foreach ($this->_carrier_type as $k => $type) {
                $this->_html .= '<option value="' . $k . '"' . (Configuration::get('RNP_CARRIER_TYPE_' . $carrier['id_carrier']) == $k ? ' selected="selected"' : '') . '>' . $type . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</fieldset><br class="clear" />
			<div class="center">
				<input type="submit" name="submitReceiveAndPay" value="' . $this->l('Update settings') . '" class="button" />
			</div>
		</form>';
    }
 /**
  * returns the product categories list as an array indexed by category_id and containing the category name and the corresponding fia-net product family
  * 
  * @return array
  */
 private function loadProductCategories()
 {
     $categories = Category::getSimpleCategories($this->context->language->id);
     $shop_categories = array();
     foreach ($categories as $category) {
         $certissim_type = Tools::isSubmit('certissim_' . $category['id_category'] . '_product_type') ? Tools::getValue('certissim_' . $category['id_category'] . '_product_type') : Configuration::get('CERTISSIM_' . $category['id_category'] . '_PRODUCT_TYPE');
         $shop_categories[$category['id_category']] = array('name' => $category['name'], 'certissim_type' => $certissim_type);
     }
     return $shop_categories;
 }
    public function renderList()
    {
        $this->toolbar_title = $this->l('Products list');
        if (Tools::isSubmit('id_display')) {
            self::$currentIndex .= '&id_display=' . (int) Tools::getValue('id_display');
        }
        if (Tools::isSubmit('id_warehouse') && Tools::getValue('id_warehouse') != '-1') {
            self::$currentIndex .= '&id_warehouse=' . (int) Tools::getValue('id_warehouse');
        }
        if (Tools::isSubmit('areaFilter')) {
            self::$currentIndex .= '&areaFilter=' . Tools::getValue('areaFilter');
        }
        if (Tools::isSubmit('subareaFilter')) {
            self::$currentIndex .= '&subareaFilter=' . Tools::getValue('subareaFilter');
        }
        if (Tools::isSubmit('id_category') && Tools::getValue('id_category') != '-1') {
            self::$currentIndex .= '&id_category=' . (int) Tools::getValue('id_category');
        }
        if (Tools::isSubmit('id_supplier') && Tools::getValue('id_supplier') != '-1') {
            self::$currentIndex .= '&id_supplier=' . (int) Tools::getValue('id_supplier');
        }
        if (Tools::isSubmit('id_manufacturer') && Tools::getValue('id_manufacturer') != '-1') {
            self::$currentIndex .= '&id_manufacturer=' . (int) Tools::getValue('id_manufacturer');
        }
        // Get display type
        $id_display = $this->getCurrentValue('id_display');
        // qubquery : return the first provider reference for principal product
        $this->_select = '
				cl.name as category_name,
				i.id_image,
				a.id_product as mvt_reason,
                                area.name as area_name, 
                                sub_area.name as sub_area_name, 
                                wpl.location as location,
				a.id_product as new_quantity,
				(
					SELECT ps.product_supplier_reference
					FROM ' . _DB_PREFIX_ . 'product_supplier ps
					WHERE ps.id_product = a.id_product
					AND ps.id_product_attribute = 0
					LIMIT 1
				)as first_supplier_ref,
                                (
                                    EXISTS(SELECT pa.id_product FROM ' . _DB_PREFIX_ . 'product_attribute pa WHERE pa.id_product = a.id_product LIMIT 1)
                                ) 
                                as have_attribute,
                                ';
        $this->_join = ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.id_product = a.id_product)' . 'INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (a.id_product = pl.id_product AND pl.id_lang = ' . (int) $this->context->language->id . ')
                                 INNER JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (a.id_category_default = cl.id_category AND cl.id_lang = ' . (int) $this->context->language->id . ')
                                 LEFT JOIN ' . _DB_PREFIX_ . 'image i ON a.id_product = i.id_product ';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'warehouse_product_location wpl ON (wpl.id_product = a.id_product AND wpl.id_product_attribute = IFNULL(pa.id_product_attribute, 0))';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'erpip_warehouse_product_location ewpl ON wpl.id_warehouse_product_location = ewpl.id_warehouse_product_location ';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone area ON area.id_erpip_zone = ewpl.id_zone_parent ';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone sub_area ON sub_area.id_erpip_zone = ewpl.id_zone ';
        // Render 1 : mix products and declination to sort by area
        if ($id_display == 1) {
            $this->_select .= 'IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as product_name,
                                        IFNULL((CONCAT(a.id_product, ";", pa.id_product_attribute)), a.id_product) as id_product,';
            $this->_join .= '
                            LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = pa.id_product_attribute)
                            LEFT JOIN `' . _DB_PREFIX_ . 'attribute` atr ON (atr.id_attribute = pac.id_attribute)
                            LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (al.id_attribute = pac.id_attribute AND al.id_lang = ' . (int) $this->context->language->id . ')
                            LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = ' . (int) $this->context->language->id . ')
                            ';
        } else {
            $this->_select .= 'pl.name as product_name,';
        }
        $this->tpl_list_vars['advanced_stock_token'] = $this->advanced_stock_token;
        // FILTERS
        // Init filters variables
        $this->tpl_list_vars['id_category'] = -1;
        $this->tpl_list_vars['id_supplier'] = -1;
        $this->tpl_list_vars['id_manufacturer'] = -1;
        $this->tpl_list_vars['id_warehouse'] = -1;
        $this->tpl_list_vars['areaFilter'] = -1;
        $this->tpl_list_vars['subareaFilter'] = -1;
        $this->tpl_list_vars['id_display'] = 0;
        // Add additional filters
        $this->tpl_list_vars['warehouses'] = Warehouse::getWarehouses();
        $this->tpl_list_vars['categories'] = Category::getSimpleCategories((int) $this->context->language->id);
        $this->tpl_list_vars['suppliers'] = Supplier::getSuppliers();
        $this->tpl_list_vars['manufacturers'] = Manufacturer::getManufacturers();
        $this->tpl_list_vars['controller_status'] = $this->controller_status;
        // Get inventory containers
        $this->tpl_list_vars['containers'] = ErpInventory::getContainers();
        // get conf stock gap
        $this->tpl_list_vars['gap_stock'] = Configuration::getGlobalValue('ERP_GAP_STOCK');
        require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpFeature.php';
        $this->tpl_list_vars['erp_feature'] = ErpFeature::getFeaturesWithToken($this->context->language->iso_code);
        $this->tpl_list_vars['template_path'] = $this->template_path;
        // get default inventory reasons
        if ($this->context->language->iso_code == 'fr') {
            $this->tpl_list_vars['reason_increase'] = ErpStockMvtReason::existsByName('Augmentation d\'inventaire');
            $this->tpl_list_vars['reason_decrease'] = ErpStockMvtReason::existsByName('Diminution d\'inventaire');
        } else {
            $this->tpl_list_vars['reason_increase'] = ErpStockMvtReason::existsByName('Increase of inventory');
            $this->tpl_list_vars['reason_decrease'] = ErpStockMvtReason::existsByName('Decrease of inventory');
        }
        // specify advanced stock manager or not
        if ($this->advanced_stock_management) {
            // Get the selected warehouse, if there's not, get the first one
            if (($id_warehouse = $this->getCurrentValue('id_warehouse')) == false) {
                $id_warehouse = $this->getCookie('id_warehouse');
                $this->tpl_list_vars['id_warehouse'] = $id_warehouse;
            }
            // filters warehouse location
            $area = $this->getCurrentValue('areaFilter');
            $subarea = $this->getCurrentValue('subareaFilter');
            $this->tpl_list_vars['areas'] = ErpZone::getZonesName($id_warehouse);
            $this->tpl_list_vars['sub_areas'] = $area ? ErpZone::getZonesName($id_warehouse, 'sub_area', $area) : array();
            // if an area AND an under area are specified, we filter the area and the under area for the specified area
            if ($area != false && $subarea != false) {
                $this->_where .= ' AND wpl.id_warehouse = ' . (int) $id_warehouse . '
                                                AND area.id_erpip_zone = "' . (int) $area . '" AND sub_area.id_erpip_zone = ' . (int) $subarea;
                $this->_group = 'GROUP BY a.id_product';
            } elseif ($area != false) {
                $this->_where .= ' AND wpl.id_warehouse=' . (int) $id_warehouse . ' AND area.id_erpip_zone = ' . (int) $area;
                //$this->_where .= ' AND area.id_erpip_zone = '.(int)$area;
                if ($id_display == 1) {
                    $this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
                } else {
                    $this->_group = 'GROUP BY a.id_product';
                }
            } else {
                $this->_where .= ' AND wpl.id_warehouse = ' . (int) $id_warehouse;
                if ($id_display == 1) {
                    $this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
                } else {
                    $this->_group = 'GROUP BY a.id_product';
                }
            }
        } else {
            if ($id_display == 1) {
                $this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
            } else {
                $this->_group = 'GROUP BY a.id_product';
            }
        }
        // filter the query with applied filters
        //category filter
        if (($id_category = $this->getCurrentValue('id_category')) != false) {
            $this->_where .= ' AND a.id_product IN (
                                    SELECT cp.id_product
                                    FROM ' . _DB_PREFIX_ . 'category_product cp
                                    WHERE cp.id_category = ' . (int) $id_category . '
                            )';
        }
        // provider filter
        if (($id_supplier = $this->getCurrentValue('id_supplier')) != false) {
            $this->_where .= ' AND a.id_product IN (
                                SELECT ps.id_product
                                FROM ' . _DB_PREFIX_ . 'product_supplier ps
                                WHERE ps.id_supplier = ' . (int) $id_supplier . '
                        )';
        }
        // Brand filter
        if (($id_manufacturer = $this->getCurrentValue('id_manufacturer')) != false) {
            $this->_where .= ' AND a.id_manufacturer = ' . (int) $id_manufacturer;
        }
        $this->displayInformation($this->l('Be careful, if you are using advanced [respectively simple] stock management, only products using advanced [respectively simple] stock management will be exported.'));
        $this->displayInformation($this->l('In advanced sotck managment, products that are not stocked in a warehouse will not appear.'));
        // Show information or confirm message / error at the end of the inventory
        /*switch(Tools::getValue('submitFilterproduct'))
        		{
        			case 0:
        				$this->displayInformation($this->l('New inventory'));
        			break;
        			case 1:
        				$this->confirmations[] = $this->l('Inventory completed');
        			break;
        			case 2:
        				$this->errors[] = Tools::displayError('There has been a problem while handling products');
        			break;
        			default:
        				$this->displayInformation($this->l('New inventory'));
        			break;
        		}*/
        // Add plugin simple tooltip
        $this->addJqueryPlugin('cluetip', _MODULE_DIR_ . 'erpillicopresta/js/cluetip/');
        // add jquery dialog
        $this->addJqueryUI('ui.dialog');
        // add plugin validity
        $this->addJqueryPlugin('validity.min', _MODULE_DIR_ . 'erpillicopresta/js/validity/');
        // Load JS
        $this->addJS(_MODULE_DIR_ . 'erpillicopresta/js/inventory_tools.js');
        $this->addJS(_MODULE_DIR_ . 'erpillicopresta/js/inventory.js');
        // Load CSS
        $this->addCSS(_MODULE_DIR_ . 'erpillicopresta/css/jquery.validity.css');
        $this->addCSS(_MODULE_DIR_ . 'erpillicopresta/css/jquery.cluetip.css');
        $list = parent::renderList();
        return $list;
    }
    public function getCustomListInstantStock()
    {
        $this->context = Context::getContext();
        $this->lang = false;
        $this->multishop_context = Shop::CONTEXT_ALL;
        $this->list_no_link = true;
        $this->show_toolbar = true;
        // retrieving the type of inventory management and send to template
        $this->advanced_stock_management = Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT');
        $this->context->smarty->assign(array('advanced_stock_management' => $this->advanced_stock_management));
        // smarty values
        $this->context->smarty->assign(array('advanced_stock_management' => $this->advanced_stock_management, 'warehouses' => Warehouse::getWarehouses(), 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'suppliers' => Supplier::getSuppliers(), 'manufacturers' => Manufacturer::getManufacturers(), 'controller_status' => $this->controller_status, 'quantity_filter' => 0, 'tokens' => array(array('value' => '=', 'label' => $this->l('Equal')), array('value' => '>', 'label' => $this->l('Strictly greater than')), array('value' => '<', 'label' => $this->l('Strictly less than'))), 'list' => 'first'));
        // if advanced stock, we work in stock table
        if ($this->advanced_stock_management) {
            $this->table = 'product';
            $this->className = 'Product';
            $this->identifier = 'id_product';
            $this->_orderBy = 'id_product';
            // determination of the warehouse, if no selected warehouse, select the first
            if (($id_warehouse = $this->getCurrentValue('id_warehouse')) == false) {
                $id_warehouse = -1;
            }
            $this->fields_list = array('ids' => array('title' => $this->l('#'), 'search' => false), 'name' => array('title' => $this->l('Name'), 'havingFilter' => true, 'width' => 200, 'callback' => 'renderNameColumn'), 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 50, 'havingFilter' => true), 'first_supplier_ref' => array('title' => $this->l('Supplier reference'), 'search' => false, 'callback' => 'renderFirstSupplierRefColumn'), 'category_name' => array('title' => $this->l('Categorie'), 'search' => false, 'callback' => 'renderCategoryNameColumn'), 'manufacturer' => array('title' => $this->l('Manufacturer'), 'search' => false), 'first_supplier_price' => array('title' => $this->l('Supplier price'), 'width' => 80, 'orderby' => true, 'search' => false, 'align' => 'right', 'callback' => 'renderSupplierPriceColumn'), 'price' => array('title' => $this->l('Price(te)'), 'width' => 80, 'orderby' => true, 'search' => false, 'type' => 'price', 'align' => 'right'), 'price_ttc' => array('title' => $this->l('Price(ti)'), 'width' => 80, 'type' => 'price', 'search' => false, 'align' => 'right', 'orderby' => false), 'valuation' => array('title' => $this->l('Valuation'), 'width' => 150, 'orderby' => false, 'search' => false, 'type' => 'price', 'currency' => true, 'hint' => $this->l('Total value of the physical quantity. The sum (for all prices) is not available for all warehouses, please filter by warehouse.')), 'physical_quantity' => array('title' => $this->l('Physical quantity'), 'width' => 50, 'search' => false, 'align' => 'right'), 'usable_quantity' => array('title' => $this->l('Usable quantity'), 'width' => 50, 'search' => false, 'align' => 'right'), 'real_quantity' => array('title' => $this->l('Real quantity'), 'width' => 50, 'align' => 'right', 'hint' => $this->l('Physical quantity (usable) - Customer orders + suppliers orders'), 'search' => false, 'orderby' => false), 'advanced_stock_management' => array('title' => $this->l('Stock management'), 'width' => 70, 'align' => 'center', 'hint' => $this->l('Adv stock mgt ? (Product->Quantities)'), 'search' => false, 'callback' => 'renderAdvancedStockManagementColumn'));
            if ($this->controller_status) {
                $this->fields_list = array_merge($this->fields_list, array('id_product' => array('title' => $this->l('Location'), 'width' => 70, 'align' => 'center', 'search' => false, 'class' => 'location_column', 'callback' => 'renderLocationColumn', 'orderby' => false)));
            }
            // building query
            $this->_select = '  IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
                                            IFNULL(CONCAT(a.id_product, ";", pa.id_product_attribute), a.id_product) as ids,
                                           ps.product_supplier_reference as first_supplier_ref,
                                           ps.product_supplier_price_te as first_supplier_price,
                                           w.id_currency, 
                                           cl.name as category_name, 
                                           m.name as manufacturer, 
                                           if (pa.wholesale_price = 0.000000, a.wholesale_price, pa.wholesale_price) as wholesale_price,
                                           IFNULL(pa.reference, a.reference) as reference,
                                           pa.price as price_attribute, 
                                           a.price as price_product, 
                                           a.id_tax_rules_group, 
                                           IFNULL(pa.id_product_attribute, 0) as id_product_attribute,
                                           wpl.id_warehouse_product_location, 
                                           ewpl.id_erpip_warehouse_product_location,
                                           area.id_erpip_zone as id_area, 
                                           area.name as area_name, 
                                           sub_area.id_erpip_zone as id_sub_area, 
                                           sub_area.name as sub_area_name, 
                                           wpl.location as location';
            $this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON a.id_product = pa.id_product ';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
					a.id_product = pl.id_product
					AND pl.id_lang = ' . (int) $this->context->language->id . '
			)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = pa.id_product_attribute)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute` atr ON (atr.id_attribute = pac.id_attribute)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (
					al.id_attribute = pac.id_attribute
					AND al.id_lang = ' . (int) $this->context->language->id . '
			)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (
					agl.id_attribute_group = atr.id_attribute_group
					AND agl.id_lang = ' . (int) $this->context->language->id . '
			)';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'stock s ON (a.id_product = s.id_product AND s.id_product_attribute = IFNULL(pa.id_product_attribute, 0)';
            //Si le filtre par entrepôt a été sélectionné, alors il ne faut prendre les quantités que dans cet entrepôt
            if ($id_warehouse != -1) {
                $this->_join .= 'AND s.id_warehouse = ' . $id_warehouse;
            }
            $this->_join .= ') ';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'warehouse_product_location wpl ON (wpl.id_product = a.id_product AND wpl.id_product_attribute = IFNULL(pa.id_product_attribute, 0)) ';
            if ($id_warehouse != -1) {
                $this->_join .= ' AND wpl.id_warehouse=' . $id_warehouse . ' ';
            }
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'erpip_warehouse_product_location ewpl ON wpl.id_warehouse_product_location = ewpl.id_warehouse_product_location ';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone area ON area.id_erpip_zone = ewpl.id_zone_parent ';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone sub_area ON sub_area.id_erpip_zone = ewpl.id_zone ';
            $this->_join .= 'LEFT JOIN `' . _DB_PREFIX_ . 'warehouse` w ON (w.id_warehouse = s.id_warehouse) ';
            $this->_join .= 'INNER JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (a.id_category_default = cl.id_category AND cl.id_lang = ' . (int) $this->context->language->id . ')';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'manufacturer m ON m.id_manufacturer = a.id_manufacturer ';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'product_supplier ps ON
                                        ps.id_product = a.id_product 
                                        AND ps.id_product_attribute = IFNULL(pa.id_product_attribute,0) ';
            $this->context->smarty->assign(array('sub_title' => $this->l('List of products available in stock')));
            // SPECIFIC FILTER
            $area = $this->getCurrentValue('area');
            $subarea = $this->getCurrentValue('subarea');
            if ($id_warehouse > 0) {
                // treatment of filters
                $this->context->smarty->assign(array('areas' => ErpZone::getZonesName($id_warehouse), 'sub_areas' => $area ? ErpZone::getZonesName($id_warehouse, 'sub_area', $area) : array(), 'id_warehouse' => $id_warehouse));
            }
            // If area and sub area specified, filter on warehouse, area and subarea
            if ($area != false && $subarea != false) {
                $this->_where .= ' AND (s.id_warehouse = ' . $id_warehouse . ' OR wpl.id_warehouse=' . $id_warehouse . ') 
                                                AND area.id_erpip_zone = "' . (int) $area . '" AND sub_area.id_erpip_zone = ' . (int) $subarea;
            } elseif ($area != false) {
                $this->_where .= ' AND (s.id_warehouse = ' . $id_warehouse . ' OR wpl.id_warehouse=' . $id_warehouse . ') 
                                                AND area.id_erpip_zone = ' . (int) $area;
            } else {
                // if id = -1 :no filter because all warehouse
                if ($id_warehouse != -1) {
                    $this->_where .= ' AND (s.id_warehouse = ' . $id_warehouse . ' OR wpl.id_warehouse=' . $id_warehouse . ')';
                }
            }
            // filtering Table quantity
            $table_quantity = 'physical_quantity';
            $table_stock = "s";
        } else {
            $this->table = 'stock_available';
            $this->className = 'StockAvailable';
            $this->identifier = 'id_stock_available';
            $this->_orderBy = 'id_product';
            $this->fields_list = array('ids' => array('title' => '#', 'search' => false), 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 50, 'havingFilter' => true), 'first_supplier_ref' => array('title' => $this->l('Supplier reference'), 'search' => false, 'callback' => 'renderFirstSupplierRefColumn'), 'name' => array('title' => $this->l('Name'), 'havingFilter' => true), 'category_name' => array('title' => $this->l('Category'), 'search' => false, 'callback' => 'renderCategoryNameColumn'), 'manufacturer' => array('title' => $this->l('Manufacturer'), 'search' => false), 'wholesale_price' => array('title' => $this->l('Supplier price'), 'width' => 80, 'orderby' => true, 'search' => false, 'align' => 'right'), 'price' => array('title' => $this->l('Price (te)'), 'width' => 80, 'orderby' => true, 'search' => false, 'align' => 'right', 'type' => 'decimal', 'suffix' => '€'), 'price_ttc' => array('title' => $this->l('Price (ti)'), 'width' => 80, 'search' => false, 'type' => 'price', 'align' => 'right', 'orderby' => false), 'quantity' => array('title' => $this->l('Quantity'), 'width' => 50, 'align' => 'right', 'search' => false, 'filter_key' => 'a!quantity'));
            // building query
            $this->_select = '
					IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
					pl.name as id_currency, if (a.id_product_attribute = 0, a.id_product, CONCAT(a.id_product, ";", a.id_product_attribute)) as ids,

							(
								SELECT ps.product_supplier_reference
								FROM ' . _DB_PREFIX_ . 'product_supplier ps
								WHERE ps.id_product = a.id_product
								AND ps.id_product_attribute = a.id_product_attribute
								LIMIT 1
							)as first_supplier_ref, cl.name as category_name, m.name as manufacturer, pa.price as price_attribute, p.price as price_product,
							IFNULL((p.price + pa.price), p.price) as price, if (pa.wholesale_price = 0.000000, p.wholesale_price, pa.wholesale_price) as wholesale_price,
							IFNULL(pa.reference, p.reference) as reference, p.id_tax_rules_group';
            $this->_group = 'GROUP BY a.id_product, a.id_product_attribute';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
					a.id_product = pl.id_product
					AND pl.id_lang = ' . (int) $this->context->language->id . '
			)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.id_product_attribute = a.id_product_attribute)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = a.id_product_attribute)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute` atr ON (atr.id_attribute = pac.id_attribute)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (
					al.id_attribute = pac.id_attribute
					AND al.id_lang = ' . (int) $this->context->language->id . '
			)';
            $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (
					agl.id_attribute_group = atr.id_attribute_group
					AND agl.id_lang = ' . (int) $this->context->language->id . '
			)';
            $this->_join .= 'INNER JOIN ' . _DB_PREFIX_ . 'product p ON a.id_product = p.id_product ';
            $this->_join .= 'INNER JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (p.id_category_default = cl.id_category AND cl.id_lang = ' . (int) $this->context->language->id . ')';
            $this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'manufacturer m ON m.id_manufacturer = p.id_manufacturer ';
            $this->context->smarty->assign(array('sub_title' => $this->l('List of products available in stock')));
            // filtering Table quantity
            $table_quantity = 'quantity';
            $table_stock = "a";
        }
        // FILTERS
        // category filter
        if (($id_category = $this->getCurrentValue('id_category')) != false) {
            $this->_where .= ' AND a.id_product IN (
						SELECT cp.id_product
						FROM ' . _DB_PREFIX_ . 'category_product cp
						WHERE cp.id_category = ' . $id_category . '
						)';
        }
        // supplier filter
        if (($id_supplier = $this->getCurrentValue('id_supplier')) != false) {
            $this->_where .= ' AND a.id_product IN (
						SELECT ps.id_product
						FROM ' . _DB_PREFIX_ . 'product_supplier ps
						WHERE ps.id_supplier = ' . $id_supplier . '
						)';
        }
        // manufacturer filter
        if (($id_manufacturer = $this->getCurrentValue('id_manufacturer')) != false) {
            $this->_where .= ' AND m.id_manufacturer = ' . $id_manufacturer;
        }
        // quantity filter
        if (($moreless = $this->getCurrentValue('moreless')) != false) {
            // quantity
            $quantity = (int) Tools::getValue('quantity_filter');
            if ($quantity < 0) {
                $this->displayWarning($this->l('The quantity filter has not been taken into account because the comparison quantity must be positive or null.'));
            } elseif (!in_array($moreless, array('=', '>', '<'))) {
                $this->displayWarning($this->l('To filter by quantity, the allowed operators are : ">", "=" and "<" !'));
            } else {
                //If filter by warehouse not used, then we check the addition of quantity of the warehouses
                //Therefore we modify the selection in the request to calculate its sum
                //Then we replace where condition by group by having
                //(In this case no need to force to 0 quantity not definied cause Sum manage it)
                if (!$this->advanced_stock_management) {
                    $id_warehouse = -1;
                }
                if ($id_warehouse == -1) {
                    $this->_select .= ', SUM(distinct ' . $table_stock . '.' . $table_quantity . ') as sum_quantity ';
                    $this->_group .= ' HAVING sum_quantity ' . $moreless . $quantity;
                } else {
                    $this->_where .= ' AND (' . $table_stock . '.' . $table_quantity . ' ' . $moreless . ' ' . $quantity;
                    if ($moreless == '=' && $quantity == 0 || $moreless == "<" && $quantity > 0) {
                        $this->_where .= ' OR  ' . $table_stock . '.' . $table_quantity . ' IS NULL)';
                    } else {
                        $this->_where .= ')';
                    }
                }
            }
        }
        $this->context->smarty->assign(array('ps_version_sup_1550' => version_compare(_PS_VERSION_, '1.5.5.0', '>=')));
        $list = $this->renderList();
        return $list;
    }
示例#24
0
    function hookAdminStatsModules()
    {
        global $cookie, $currentIndex;
        if (Tools::isSubmit('submitCategory')) {
            $cookie->statsstock_id_category = Tools::getValue('statsstock_id_category');
        }
        $ru = $currentIndex . '&module=' . $this->name . '&token=' . Tools::getValue('token');
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $filter = (int) $cookie->statsstock_id_category ? 'WHERE p.id_product IN (SELECT cp.id_product FROM ' . _DB_PREFIX_ . 'category_product cp WHERE cp.id_category = ' . (int) $cookie->statsstock_id_category . ')' : '';
        $products = Db::getInstance()->ExecuteS('
		SELECT p.id_product, p.reference, pl.name,
			IFNULL((
				SELECT AVG(pa.wholesale_price)
				FROM ' . _DB_PREFIX_ . 'product_attribute pa WHERE p.id_product = pa.id_product
				AND wholesale_price != 0
			), p.wholesale_price) as wholesale_price,
			IFNULL((
				SELECT SUM(pa.quantity)
				FROM ' . _DB_PREFIX_ . 'product_attribute pa WHERE p.id_product = pa.id_product
			), p.quantity) as quantity,
			IFNULL((
				SELECT SUM(IF(pa.wholesale_price > 0, pa.wholesale_price, p.wholesale_price) * pa.quantity)
				FROM ' . _DB_PREFIX_ . 'product_attribute pa WHERE p.id_product = pa.id_product
			), p.wholesale_price * p.quantity) as stockvalue
		FROM ' . _DB_PREFIX_ . 'product p
		INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = ' . (int) $cookie->id_lang . ')
		' . $filter);
        echo '
		<script type="text/javascript">$(\'#calendar\').slideToggle();</script>
		<h2 style="float:left">' . $this->l('Stock value') . '</h2>
		<form action="' . $ru . '" method="post" style="float:right">
			<input type="hidden" name="submitCategory" value="1" />
			' . $this->l('Category') . ' : <select name="statsstock_id_category" onchange="this.form.submit();">
				<option value="0">-- ' . $this->l('All') . ' --</option>';
        foreach (Category::getSimpleCategories($cookie->id_lang) as $category) {
            echo '<option value="' . (int) $category['id_category'] . '" ' . ($cookie->statsstock_id_category == $category['id_category'] ? 'selected="selected"' : '') . '>' . $category['name'] . '</option>';
        }
        echo '	</select>
		</form>
		<div style="clear:both">&nbsp;</div>';
        if (!count($products)) {
            echo $this->l('Your catalog is empty.');
        } else {
            $rollup = array('quantity' => 0, 'wholesale_price' => 0, 'stockvalue' => 0);
            echo '<table class="table" cellspacing="0" cellpadding="0">
			<tr>
				<th>' . $this->l('ID') . '</th>
				<th>' . $this->l('Ref.') . '</th>
				<th style="width:350px">' . $this->l('Item') . '</th>
				<th>' . $this->l('Stock') . '</th>
				<th>' . $this->l('Price*') . '</th>
				<th>' . $this->l('Value') . '</th>
			</tr>';
            foreach ($products as $product) {
                $rollup['quantity'] += $product['quantity'];
                $rollup['wholesale_price'] += $product['wholesale_price'];
                $rollup['stockvalue'] += $product['stockvalue'];
                echo '<tr>
					<td>' . $product['id_product'] . '</td>
					<td>' . $product['reference'] . '</td>
					<td>' . $product['name'] . '</td>
					<td>' . $product['quantity'] . '</td>
					<td>' . Tools::displayPrice($product['wholesale_price'], $currency) . '</td>
					<td>' . Tools::displayPrice($product['stockvalue'], $currency) . '</td>
				</tr>';
            }
            echo '
				<tr>
					<th colspan="3"></th>
					<th>' . $this->l('Total stock') . '</th>
					<th>' . $this->l('Avg price') . '</th>
					<th>' . $this->l('Total value') . '</th>
				</tr>
				<tr>
					<td colspan="3"></td>
					<td>' . $rollup['quantity'] . '</td>
					<td>' . Tools::displayPrice($rollup['wholesale_price'] / count($products), $currency) . '</td>
					<td>' . Tools::displayPrice($rollup['stockvalue'], $currency) . '</td>
				</tr>
			</table>
			<p>* ' . $this->l('Average price when the product has attributes.') . '</p>';
        }
    }
示例#25
0
 public function createShopInfo()
 {
     $shopInfo = array('category_count' => count(Category::getSimpleCategories($this->getLanguageId())), 'item_count' => count(Product::getSimpleProducts($this->getLanguageId())));
     if ($this->config->getEnableGetReviewsCsv()) {
         /**
          * set review_count
          */
         $shopInfo['review_count'] = 0;
     }
     if ($this->config->getEnableGetMediaCsv()) {
         /**
          * media_count
          */
         $shopInfo['media_count'] = array();
     }
     $shopInfo['plugins_installed'] = array();
     foreach (Module::getModulesInstalled() as $module) {
         $shopInfo['plugins_installed'][] = array('id' => $module['id_module'], 'name' => $module['name'], 'version' => $module['version'], 'active' => $module['active'] ? 1 : 0);
     }
     return $shopInfo;
 }
    public function hookAdminStatsModules()
    {
        if (Tools::isSubmit('submitCategory')) {
            $this->context->cookie->statsstock_id_category = Tools::getValue('statsstock_id_category');
        }
        $ru = AdminController::$currentIndex . '&module=' . $this->name . '&token=' . Tools::getValue('token');
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $filter = (int) $this->context->cookie->statsstock_id_category ? ' AND p.id_product IN (SELECT cp.id_product FROM ' . _DB_PREFIX_ . 'category_product cp WHERE cp.id_category = ' . (int) $this->context->cookie->statsstock_id_category . ')' : '';
        $sql = 'SELECT p.id_product, p.reference, pl.name,
				IFNULL((
					SELECT AVG(product_attribute_shop.wholesale_price)
					FROM ' . _DB_PREFIX_ . 'product_attribute pa
					' . Shop::addSqlAssociation('product_attribute', 'pa') . '
					WHERE p.id_product = pa.id_product
					AND product_attribute_shop.wholesale_price != 0
				), product_shop.wholesale_price) as wholesale_price,
				IFNULL(stock.quantity, 0) as quantity
				FROM ' . _DB_PREFIX_ . 'product p
				' . Shop::addSqlAssociation('product', 'p') . '
				INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl
					ON (p.id_product = pl.id_product AND pl.id_lang = ' . (int) $this->context->language->id . Shop::addSqlRestrictionOnLang('pl') . ')
				' . Product::sqlStock('p', 0) . '
				WHERE 1 = 1
				' . $filter;
        $products = Db::getInstance()->executeS($sql);
        foreach ($products as $key => $p) {
            $products[$key]['stockvalue'] = $p['wholesale_price'] * $p['quantity'];
        }
        $this->html .= '
		<script type="text/javascript">$(\'#calendar\').slideToggle();</script>

		<div class="panel-heading">' . $this->l('Evaluation of available quantities for sale') . '</div>
		<form action="' . Tools::safeOutput($ru) . '" method="post" class="form-horizontal">
			<div class="row row-margin-bottom">
				<label class="control-label col-lg-3">' . $this->l('Category') . '</label>
				<div class="col-lg-6">
					<select name="statsstock_id_category" onchange="this.form.submit();">
						<option value="0">- ' . $this->l('All') . ' -</option>';
        foreach (Category::getSimpleCategories($this->context->language->id) as $category) {
            $this->html .= '<option value="' . (int) $category['id_category'] . '" ' . ($this->context->cookie->statsstock_id_category == $category['id_category'] ? 'selected="selected"' : '') . '>' . $category['name'] . '
					</option>';
        }
        $this->html .= '
					</select>
					<input type="hidden" name="submitCategory" value="1" />
				</div>
			</div>
		</form>';
        if (!count($products)) {
            $this->html .= '<p>' . $this->l('Your catalog is empty.') . '</p>';
        } else {
            $rollup = array('quantity' => 0, 'wholesale_price' => 0, 'stockvalue' => 0);
            $this->html .= '
			<table class="table">
				<thead>
					<tr>
						<th><span class="title_box active">' . $this->l('ID') . '</span></th>
						<th><span class="title_box active">' . $this->l('Ref.') . '</span></th>
						<th><span class="title_box active">' . $this->l('Item') . '</span></th>
						<th><span class="title_box active">' . $this->l('Available quantity for sale') . '</span></th>
						<th><span class="title_box active">' . $this->l('Price*') . '</span></th>
						<th><span class="title_box active">' . $this->l('Value') . '</span></th>
					</tr>
				</thead>
				<tbody>';
            foreach ($products as $product) {
                $rollup['quantity'] += $product['quantity'];
                $rollup['wholesale_price'] += $product['wholesale_price'];
                $rollup['stockvalue'] += $product['stockvalue'];
                $this->html .= '<tr>
						<td>' . $product['id_product'] . '</td>
						<td>' . $product['reference'] . '</td>
						<td>' . $product['name'] . '</td>
						<td>' . $product['quantity'] . '</td>
						<td>' . Tools::displayPrice($product['wholesale_price'], $currency) . '</td>
						<td>' . Tools::displayPrice($product['stockvalue'], $currency) . '</td>
					</tr>';
            }
            $this->html .= '
				</tbody>
				<tfoot>
					<tr>
						<th colspan="3"></th>
						<th><span class="title_box active">' . $this->l('Total quantities') . '</span></th>
						<th><span class="title_box active">' . $this->l('Average price') . '</span></th>
						<th><span class="title_box active">' . $this->l('Total value') . '</span></th>
					</tr>
					<tr>
						<td colspan="3"></td>
						<td>' . $rollup['quantity'] . '</td>
						<td>' . Tools::displayPrice($rollup['wholesale_price'] / count($products), $currency) . '</td>
						<td>' . Tools::displayPrice($rollup['stockvalue'], $currency) . '</td>
					</tr>
				</tfoot>
			</table>
			<i class="icon-asterisk"></i> ' . $this->l('This section corresponds to the default wholesale price according to the default supplier for the product. An average price is used when the product has attributes.');
            return $this->html;
        }
    }
示例#27
0
    function displayFormInformations($obj, $currency)
    {
        parent::displayForm(false);
        global $currentIndex, $cookie, $link;
        $default_country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'));
        $iso = Language::getIsoById((int) $cookie->id_lang);
        $has_attribute = false;
        $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 = '';
        } else {
            $has_attribute = true;
        }
        $cover = Product::getCover($obj->id);
        $this->_applyTaxToEcotax($obj);
        echo '
		<div class="tab-page" id="step1">
			<h4 class="tab">1. ' . $this->l('Info.') . '</h4>
			<script type="text/javascript">
				$(document).ready(function() {
					updateCurrentText();
					updateFriendlyURL();
					$.ajax({
						url: "' . dirname($currentIndex) . '/ajax.php",
						cache: false,
						dataType: "json",
						data: "ajaxProductManufacturers=1",
						success: function(j) {
							var options = $("select#id_manufacturer").html();
							if (j)
							for (var i = 0; i < j.length; i++)
								options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
							$("select#id_manufacturer").html(options);
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							alert(\'Manufacturer ajax error: \'+textStatus);
						}

					});
					$.ajax({
						url: "' . dirname($currentIndex) . '/ajax.php",
						cache: false,
						dataType: "json",
						data: "ajaxProductSuppliers=1",
						success: function(j) {
							var options = $("select#id_supplier").html();
							if (j)
							for (var i = 0; i < j.length; i++)
								options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
							$("select#id_supplier").html(options);
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							alert(\'Supplier ajax error: \'+textStatus);
						}

					});
					if ($(\'#available_for_order\').is(\':checked\')){
						$(\'#show_price\').attr(\'checked\', \'checked\');
						$(\'#show_price\').attr(\'disabled\', \'disabled\');
					}
					else {
						$(\'#show_price\').attr(\'disabled\', \'\');
					}
				});
			</script>
			<b>' . $this->l('Product global information') . '</b>&nbsp;-&nbsp;';
        $preview_url = '';
        if (isset($obj->id)) {
            $preview_url = $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $this->_defaultFormLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), (int) $cookie->id_lang));
            if (!$obj->active) {
                $admin_dir = dirname($_SERVER['PHP_SELF']);
                $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
                $token = Tools::encrypt('PreviewProduct' . $obj->id);
                $preview_url .= $obj->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir;
            }
            echo '
			<a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&deleteproduct&token=' . $this->token . '" style="float:right;"
			onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');">
			<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" title="' . $this->l('Delete this product') . '" /> ' . $this->l('Delete this product') . '</a>
			<a href="' . $preview_url . '" target="_blank"><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=AdminStats&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStats' . (int) Tab::getIdFromClassName('AdminStats') . (int) $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: 50%; float: left; margin-right: 20px; border-right: 1px solid #E0D0B1;">
					<tr>
						<td class="col-left">' . $this->l('Name:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
								<input size="43" 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="if (isArrowKey(event)) return; copy2friendlyURL();"' : '') . ' onkeyup="if (isArrowKey(event)) return; updateCurrentText();" onchange="updateCurrentText();" /><sup> *</sup>
								<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        echo '		</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;" />
							<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;" />
							<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('EAN13 or JAN:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" maxlength="13" type="text" name="ean13" value="' . htmlentities($this->getFieldValue($obj, 'ean13'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 5px;" /> <span class="small">' . $this->l('(Europe, Japan)') . '</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('UPC:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" maxlength="12" type="text" name="upc" value="' . htmlentities($this->getFieldValue($obj, 'upc'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 5px;" /> <span class="small">' . $this->l('(US, Canada)') . '</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Location (warehouse):') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="location" value="' . htmlentities($this->getFieldValue($obj, 'location'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Width ( package ) :') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="width" type="text" value="' . htmlentities($this->getFieldValue($obj, 'width'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Height ( package ) :') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="height" type="text" value="' . htmlentities($this->getFieldValue($obj, 'height'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Deep ( package ) :') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="depth" type="text" value="' . htmlentities($this->getFieldValue($obj, 'depth'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Weight ( package ) :') . '</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="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '
						</td>
					</tr>
				</table>
				<table cellpadding="5" style="width: 40%; float: left; margin-left: 10px;">
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Status:') . '</td>
						<td style="padding-bottom:5px;">
							<input style="float:left;" onclick="toggleDraftWarning(false);showOptions(true);" 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 class="clear" />
							<input style="float:left;" onclick="toggleDraftWarning(true);showOptions(false);"  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') . ($obj->active ? '' : ' (<a href="' . $preview_url . '" alt="" target="_blank">' . $this->l('View product in shop') . '</a>)') . '</label>
						</td>
					</tr>
					<tr id="product_options" ' . (!$obj->active ? 'style="display:none"' : '') . '>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Options:') . '</td>
						<td style="padding-bottom:5px;">
							<input style="float: left;" type="checkbox" name="available_for_order" id="available_for_order" value="1" ' . ($this->getFieldValue($obj, 'available_for_order') ? 'checked="checked" ' : '') . ' onclick="if ($(this).is(\':checked\')){$(\'#show_price\').attr(\'checked\', \'checked\');$(\'#show_price\').attr(\'disabled\', \'disabled\');}else{$(\'#show_price\').attr(\'disabled\', \'\');}"/>
							<label for="available_for_order" class="t"><img src="../img/admin/products.gif" alt="' . $this->l('available for order') . '" title="' . $this->l('available for order') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('available for order') . '</label>
							<br class="clear" />
							<input style="float: left;" type="checkbox" name="show_price" id="show_price" value="1" ' . ($this->getFieldValue($obj, 'show_price') ? 'checked="checked" ' : '') . ' />
							<label for="show_price" class="t"><img src="../img/admin/gold.gif" alt="' . $this->l('display price') . '" title="' . $this->l('show price') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('show price') . '</label>
							<br class="clear" />
							<input style="float: left;" type="checkbox" name="online_only" id="online_only" value="1" ' . ($this->getFieldValue($obj, 'online_only') ? 'checked="checked" ' : '') . ' />
							<label for="online_only" class="t"><img src="../img/admin/basket_error.png" alt="' . $this->l('online only') . '" title="' . $this->l('online only') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('online only (not sold in store)') . '</label>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Condition:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="condition" id="condition">
								<option value="new" ' . ($obj->condition == 'new' ? 'selected="selected"' : '') . '>' . $this->l('New') . '</option>
								<option value="used" ' . ($obj->condition == 'used' ? 'selected="selected"' : '') . '>' . $this->l('Used') . '</option>
								<option value="refurbished" ' . ($obj->condition == 'refurbished' ? 'selected="selected"' : '') . '>' . $this->l('Refurbished') . '</option>
							</select>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $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' . (int) Tab::getIdFromClassName('AdminManufacturers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete product information entered?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $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' . (int) Tab::getIdFromClassName('AdminSuppliers') . (int) $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>
						</td>
					</tr>
				</table>
				<div class="clear"></div>
				<table cellpadding="5" style="width: 100%;">
					<tr><td colspan="2"><hr style="width:100%;" /></td></tr>';
        $this->displayPack($obj);
        echo '		<tr><td colspan="2"><hr style="width:100%;" /></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">
	//<![CDATA[
	function toggleVirtualProduct(elt)
	{
		if (elt.checked)
		{
			$('#virtual_good').show('slow');
			$('#virtual_good_more').show('slow');
			getE('out_of_stock_1').checked = 'checked';
			getE('out_of_stock_2').disabled = 'disabled';
			getE('out_of_stock_3').disabled = 'disabled';
			getE('label_out_of_stock_2').setAttribute('for', '');
			getE('label_out_of_stock_3').setAttribute('for', '');
		}
		else
		{
			$('#virtual_good').hide('slow');
			$('#virtual_good_more').hide('slow');
			getE('out_of_stock_2').disabled = false;
			getE('out_of_stock_3').disabled = 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();
						$('#file_missing').hide();
						$('#delete_downloadable_product').show();
						$('#virtual_product_name').attr('value', fileName);
						$('#upload-confirmation').html(
							'<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'"><?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" src="../js/price.js"></script>
		<script type="text/javascript">
			var newLabel = \'' . $this->l('New label') . '\';
			var choose_language = \'' . $this->l('Choose language:') . '\';
			var required = \'' . $this->l('required') . '\';
			var customizationUploadableFileNumber = ' . (int) $this->getFieldValue($obj, 'uploadable_files') . ';
			var customizationTextFieldNumber = ' . (int) $this->getFieldValue($obj, 'text_fields') . ';
			var uploadableFileLabel = 0;
			var textFieldLabel = 0;
		</script>';
        ?>
	<tr>
		<td colspan="2">
			<p><input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" 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" style="color: black;"><?php 
        echo $this->l('Is this a downloadable product?');
        ?>
</label></p>
			<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()) {
                ?>

				<div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1">
		<?php 
                if ($productDownload->id) {
                    ?>
					<p class="alert" id="file_missing">
						<?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>
					<p><input type="file" id="virtual_product_file" name="virtual_product_file" onchange="uploadFile();" maxlength="<?php 
                    echo $this->maxFileSize;
                    ?>
" /></p>
					<?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>
					<a id="delete_downloadable_product" style="display:none;" 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 
            } 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" style="width:200px" 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 full filename with its extension (e.g., Book.pdf)');
            ?>
</span>
				</p>

				</div>
				<div id="virtual_good_more" style="<?php 
            if (!$productDownload->id or !$productDownload->active) {
                echo 'display:none;';
            }
            ?>
padding:5px;width:40%;float:left;margin-left:10px">

				<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');
            ?>
 - <em>(<?php 
            echo $this->l('set to zero for unlimited access');
            ?>
)</em></span>
				</p>
				</div>
	<?php 
        }
        // check if download directory is writable
        ?>
			</div>
		</td>
	</tr>
	<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
	<script type="text/javascript">
		if ($('#is_virtual_good').attr('checked'))
		{
			$('#virtual_good').show('slow');
			$('#virtual_good_more').show('slow');
		}
	</script>

<?php 
        echo '
					<tr>
						<td class="col-left">' . $this->l('Pre-tax wholesale price:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" name="wholesale_price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'wholesale_price'), ENT_COMPAT, 'UTF-8') . '" onchange="this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $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 % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="' . $this->getFieldValue($obj, 'price') . '" onchange="this.value = this.value.replace(/,/g, \'.\');" onkeyup="if (isArrowKey(event)) return; calcPriceTI();" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '<sup> *</sup>
							<span style="margin-left:2px">' . $this->l('The pre-tax retail price to sell this product') . '</span>
						</td>
					</tr>';
        $tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true);
        $taxesRatesByGroup = TaxRulesGroup::getAssociatedTaxRatesByIdCountry(Country::getDefaultCountryId());
        $ecotaxTaxRate = Tax::getProductEcotaxRate();
        echo '<script type="text/javascript">';
        echo 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false'), ";\n";
        echo 'taxesArray = new Array ();' . "\n";
        echo 'taxesArray[0] = 0', ";\n";
        foreach ($tax_rules_groups as $tax_rules_group) {
            $tax_rate = array_key_exists($tax_rules_group['id_tax_rules_group'], $taxesRatesByGroup) ? $taxesRatesByGroup[$tax_rules_group['id_tax_rules_group']] : 0;
            echo 'taxesArray[' . $tax_rules_group['id_tax_rules_group'] . ']=' . $tax_rate . "\n";
        }
        echo '
						ecotaxTaxRate = ' . $ecotaxTaxRate / 100 . ';
					</script>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Tax rule:') . '</td>
						<td style="padding-bottom:5px;">
					<span ' . (Tax::excludeTaxeOption() ? 'style="display:none;"' : '') . '>
					 <select onChange="javascript:calcPriceTI(); unitPriceWithTax(\'unit\');" name="id_tax_rules_group" id="id_tax_rules_group" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '>
						 <option value="0">' . $this->l('No Tax') . '</option>';
        foreach ($tax_rules_groups as $tax_rules_group) {
            echo '<option value="' . $tax_rules_group['id_tax_rules_group'] . '" ' . ($this->getFieldValue($obj, 'id_tax_rules_group') == $tax_rules_group['id_tax_rules_group'] ? ' selected="selected"' : '') . '>' . Tools::htmlentitiesUTF8($tax_rules_group['name']) . '</option>';
        }
        echo '</select>

				<a href="?tab=AdminTaxRulesGroup&addtax_rules_group&token=' . Tools::getAdminToken('AdminTaxRulesGroup' . (int) Tab::getIdFromClassName('AdminTaxRulesGroup') . (int) $cookie->id_employee) . '&id_product=' . (int) $obj->id . '" 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></span>
				';
        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' . (int) Tab::getIdFromClassName('AdminTaxes') . (int) $cookie->id_employee) . '">' . $this->l('Tax options') . '</a></b>)';
            echo '<input type="hidden" value="' . (int) $this->getFieldValue($obj, 'id_tax_rules_group') . '" name="id_tax_rules_group" />';
        }
        echo '</td>
					</tr>
				';
        if (Configuration::get('PS_USE_ECOTAX')) {
            echo '
					<tr>
						<td class="col-left">' . $this->l('Eco-tax (tax incl.):') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="' . $this->getFieldValue($obj, 'ecotax') . '" onkeyup="if (isArrowKey(event))return; calcPriceTE(); 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 == 0 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">(' . $this->l('already included in price') . ')</span>
						</td>
					</tr>';
        }
        if ($default_country->display_tax_label) {
            echo '
						<tr ' . (Tax::excludeTaxeOption() ? 'style="display:none"' : '') . '>
							<td class="col-left">' . $this->l('Retail price with tax:') . '</td>
							<td style="padding-bottom:5px;">
								' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="priceTI" type="text" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return;  calcPriceTE();" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '
							</td>
						</tr>';
        } else {
            echo '<input size="11" maxlength="14" id="priceTI" type="hidden" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return;  calcPriceTE();" />';
        }
        echo '
					<tr id="tr_unit_price">
						<td class="col-left">' . $this->l('Unit price without tax:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="unit_price" name="unit_price" type="text" value="' . ($this->getFieldValue($obj, 'unit_price_ratio') != 0 ? Tools::ps_round($this->getFieldValue($obj, 'price') / $this->getFieldValue($obj, 'unit_price_ratio'), 2) : 0) . '" onkeyup="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\'); unitPriceWithTax(\'unit\');"/>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('per') . ' <input size="6" maxlength="10" id="unity" name="unity" type="text" value="' . htmlentities($this->getFieldValue($obj, 'unity'), ENT_QUOTES, 'UTF-8') . '" onkeyup="if (isArrowKey(event)) return ;unitySecond();" onchange="unitySecond();"/>' . (Configuration::get('PS_TAX') && $default_country->display_tax_label ? '<span style="margin-left:15px">' . $this->l('or') . ' ' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . '<span id="unit_price_with_tax">0.00</span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('per') . ' <span id="unity_second">' . $this->getFieldValue($obj, 'unity') . '</span> ' . $this->l('with tax') : '') . '</span>
							<p>' . $this->l('Eg. $15 per Lb') . '</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;">
							<span style="' . ($default_country->display_tax_label ? '' : 'display:none') . '">
							' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="finalPrice" style="font-weight: bold;"></span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '<span' . (!Configuration::get('PS_TAX') ? ' style="display:none;"' : '') . '> (' . $this->l('tax incl.') . ')</span>
							</span>
							<span' . (!Configuration::get('PS_TAX') ? ' style="display:none;"' : '') . '>';
        if ($default_country->display_tax_label) {
            echo ' / ';
        }
        echo ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="finalPriceWithoutTax" style="font-weight: bold;"></span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . ($default_country->display_tax_label ? '(' . $this->l('tax excl.') . ')' : '') . '</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">&nbsp;</td>
						<td>
							<div class="hint clear" style="display: block;width: 70%;">' . $this->l('You can define many discounts and specific price rules in the Prices tab') . '</div>
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>';
        if ((int) Configuration::get('PS_STOCK_MANAGEMENT')) {
            if (!$has_attribute) {
                if ($obj->id) {
                    echo '
							<tr><td class="col-left">' . $this->l('Stock Movement:') . '</td>
								<td style="padding-bottom:5px;">
									<select id="id_mvt_reason" name="id_mvt_reason">
										<option value="-1">--</option>';
                    $reasons = StockMvtReason::getStockMvtReasons((int) $cookie->id_lang);
                    foreach ($reasons as $reason) {
                        echo '<option rel="' . $reason['sign'] . '" value="' . $reason['id_stock_mvt_reason'] . '" ' . (Configuration::get('PS_STOCK_MVT_REASON_DEFAULT') == $reason['id_stock_mvt_reason'] ? 'selected="selected"' : '') . '>' . $reason['name'] . '</option>';
                    }
                    echo '</select>
									<input id="mvt_quantity" type="text" name="mvt_quantity" size="3" maxlength="6" value="0"/>&nbsp;&nbsp;
									<span style="display:none;" id="mvt_sign"></span>
								</td>
							</tr>
							<tr>
								<td class="col-left">&nbsp;</td>
								<td>
									<div class="hint clear" style="display: block;width: 70%;">' . $this->l('Choose the reason and enter the quantity that you want to increase or decrease in your stock') . '</div>
								</td>
							</tr>';
                } else {
                    echo '<tr><td class="col-left">' . $this->l('Initial stock:') . '</td>
									<td style="padding-bottom:5px;">
										<input size="3" maxlength="6" name="quantity" type="text" value="0" />
									</td>';
                }
                echo '<tr>
								<td class="col-left">' . $this->l('Minimum quantity:') . '</td>
									<td style="padding-bottom:5px;">
										<input size="3" maxlength="6" name="minimal_quantity" id="minimal_quantity" type="text" value="' . ($this->getFieldValue($obj, 'minimal_quantity') ? $this->getFieldValue($obj, 'minimal_quantity') : 1) . '" />
										<p>' . $this->l('The minimum quantity to buy this product (set to 1 to disable this feature)') . '</p>
									</td>
								</tr>';
            }
            if ($obj->id) {
                echo '
							<tr><td class="col-left">' . $this->l('Quantity in stock:') . '</td>
								<td style="padding-bottom:5px;"><b>' . $qty . '</b><input type="hidden" name="quantity" value="' . $qty . '" /></td>
							</tr>
						';
            }
            if ($has_attribute) {
                echo '<tr>
								<td class="col-left">&nbsp;</td>
								<td>
									<div class="hint clear" style="display: block;width: 70%;">' . $this->l('You used combinations, for this reason you can\'t edit your stock quantity here, but in the Combinations tab') . '</div>
								</td>
							</tr>';
            }
        } else {
            echo '<tr>
							<td colspan="2">' . $this->l('The stock management is disabled') . '</td>
						</tr>';
        }
        echo '
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
					<tr>
						<td class="col-left">' . $this->l('Additional shipping cost:') . '</td>
						<td style="padding-bottom:5px;">
							<input type="text" name="additional_shipping_cost" value="' . $this->getFieldValue($obj, 'additional_shipping_cost') . '" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '');
        if ($default_country->display_tax_label) {
            echo ' (' . $this->l('tax excl.') . ')';
        }
        echo '<p>' . $this->l('Carrier tax will be applied.') . '</p>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when in-stock:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '			</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when allowed to be back-ordered:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div  class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '	</td>
					</tr>

					<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" ' . ((int) $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((int) 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' . (int) Tab::getIdFromClassName('AdminPPreferences') . (int) $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:100%;" />
						</td>
					</tr>
					<tr>
						<td class="col-left"><label for="id_category_default" class="t">' . $this->l('Default category:') . '</label></td>
						<td>
						<div id="no_default_category" style="color: red;font-weight: bold;display: none;">' . $this->l('Please check a category in order to select the default category.') . '</div>
						<script>var post_selected_cat;</script>';
        if (Tools::isSubmit('categoryBox')) {
            $postCat = Tools::getValue('categoryBox');
            $selectedCat = Category::getSimpleCategories($this->_defaultFormLanguage, false, true, 'AND c.`id_category` IN (' . (empty($postCat) ? '1' : implode(',', $postCat)) . ')');
            echo '<script>post_selected_cat = \'' . implode(',', $postCat) . '\';</script>';
        }
        if ($obj->id) {
            $selectedCat = Product::getProductCategoriesFull($obj->id, $this->_defaultFormLanguage);
        } else {
            if (!Tools::isSubmit('categoryBox')) {
                $selectedCat[] = array('id_category' => 1, 'name' => $this->l('Home'));
            }
        }
        echo '<select id="id_category_default" name="id_category_default">';
        foreach ($selectedCat as $cat) {
            echo '<option value="' . $cat['id_category'] . '" ' . ($obj->id_category_default == $cat['id_category'] ? 'selected' : '') . '>' . $cat['name'] . '</option>';
        }
        echo '</select>
						</td> 
					</tr>
					<tr id="tr_categories">
						<td colspan="2">
						';
        // Translations are not automatic for the moment ;)
        $trads = array('Home' => $this->l('Home'), 'selected' => $this->l('selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All'), 'Check All' => $this->l('Check All'), 'Uncheck All' => $this->l('Uncheck All'));
        echo Helper::renderAdminCategorieTree($trads, $selectedCat) . '
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
					<tr><td colspan="2">
						<span onclick="$(\'#seo\').slideToggle();" 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 class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '						<p class="clear">' . $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 class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '						<p class="clear">' . $this->l('A single sentence for HTML header') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Meta keywords:') . '</td>
									<td class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '						<p class="clear">' . $this->l('Keywords for HTML header, separated by a comma') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Friendly URL:') . '</td>
									<td class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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="if (isArrowKey(event)) return ;updateFriendlyURL();" onchange="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>';
        }
        echo '						<p class="clear" style="padding:10px 0 0 0">' . '<a style="cursor:pointer" class="button" onmousedown="updateFriendlyURLByName();">' . $this->l('Generate') . '</a>&nbsp;' . $this->l('Friendly-url from product\'s name.') . '<br /><br />';
        echo '						' . $this->l('Product link will look like this:') . ' ' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/<b>id_product</b>-<span id="friendly-url"></span>.html</p>
									</td>
								</tr>';
        echo '</td></tr></table>
						</div>
					</td></tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></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;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '		</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Description:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '		</td>
					</tr>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Tags:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        if ($obj->id) {
            $obj->tags = Tag::getProductTags((int) $obj->id);
        }
        foreach ($this->_languages as $language) {
            echo '<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? '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>';
        }
        echo '	<p class="clear">' . $this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)') . '</p>
						</td>
					</tr>';
        $accessories = Product::getAccessoriesLight((int) $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'] . (!empty($accessory['reference']) ? ' (' . $accessory['reference'] . ')' : '') . ' <span onclick="delAccessory(' . $accessory['id_product'] . ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" class="middle" alt="" /></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();
							</script>

							<link rel="stylesheet" type="text/css" href="' . __PS_BASE_URI__ . 'css/jquery.autocomplete.css" />
							<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/jquery/jquery.autocomplete.js"></script>
							<div id="ajax_choose_product" style="padding:6px; padding-top:2px; width:600px;">
								<p class="clear">' . $this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:') . '</p>
								<input type="text" value="" id="product_autocomplete_input" />
								<img onclick="$(this).prev().search();" style="cursor: pointer;" src="../img/admin/add.gif" alt="' . $this->l('Add an accessory') . '" title="' . $this->l('Add an accessory') . '" />
							</div>
							<script type="text/javascript">
								urlToCall = null;
								/* function autocomplete */
								$(function() {
									$(\'#product_autocomplete_input\')
										.autocomplete(\'ajax_products_list.php\', {
											minChars: 1,
											autoFill: true,
											max:20,
											matchContains: true,
											mustMatch:true,
											scroll:false,
											cacheLength:0,
											formatItem: function(item) {
												return item[1]+\' - \'+item[0];
											}
										}).result(addAccessory);
									$(\'#product_autocomplete_input\').setOptions({
										extraParams: {excludeIds : getAccessorieIds()}
									});
								});
							</script>
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:10px;"><hr style="width:100%;" /></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>
			<br />
			</div>';
        // TinyMCE
        global $cookie;
        $iso = Language::getIsoById((int) $cookie->id_lang);
        $isoTinyMCE = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
        $ad = dirname($_SERVER["PHP_SELF"]);
        echo '
			<script type="text/javascript">
			var iso = \'' . $isoTinyMCE . '\' ;
			var pathCSS = \'' . _THEME_CSS_DIR_ . '\' ;
			var ad = \'' . $ad . '\' ;
			</script>
			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tiny_mce/tiny_mce.js"></script>
			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tinymce.inc.js"></script>
			<script type="text/javascript">
					toggleVirtualProduct(getE(\'is_virtual_good\'));
					unitPriceWithTax(\'unit\');
			</script>';
        $categoryBox = Tools::getValue('categoryBox', array());
    }
示例#28
0
    private function _displayFormApplicationCriterion()
    {
        include_once dirname(__FILE__) . '/ProductCommentCriterion.php';
        $criterions = ProductCommentCriterion::getCriterions($this->context->language->id, false, true);
        $id_criterion = (int) Tools::getValue('updateCriterion');
        if ($id_criterion) {
            $criterion = new ProductCommentCriterion((int) $id_criterion);
            if ($criterion->id_product_comment_criterion_type == 2) {
                $categories = Category::getSimpleCategories($this->context->language->id);
                $criterion_categories = $criterion->getCategories();
            } else {
                if ($criterion->id_product_comment_criterion_type == 3) {
                    $criterion_products = $criterion->getProducts();
                    $products = Product::getSimpleProducts($this->context->language->id);
                }
            }
        }
        foreach ($criterions as $key => $foo) {
            if ($foo['id_product_comment_criterion_type'] == 1) {
                unset($criterions[$key]);
            }
        }
        if (count($criterions)) {
            $this->_html .= '
			<fieldset class="width2">
				<legend><img src="' . $this->_path . 'img/note_go.png" alt="" title="" />' . $this->l('Manage criterions scope') . '</legend>
				<p style="margin-bottom: 15px;">' . $this->l('Only criterions restricted to categories or products can be configured below:') . '</p>
				<form action="' . Tools::safeOutput($this->_baseUrl) . '" method="post" name="product_criterion_form">
					<label>' . $this->l('Criterion') . '</label>
					<div class="margin-form">
">
						<select name="id_product_comment_criterion" id="id_product_comment_criterion" onchange="window.location=\'' . Tools::safeOutput($this->_baseUrl) . '&updateCriterion=\'+$(\'#id_product_comment_criterion option:selected\').val()">
							<option value="--">-- ' . $this->l('Choose a criterion') . ' --</option>';
            foreach ($criterions as $foo) {
                $this->_html .= '<option value="' . (int) $foo['id_product_comment_criterion'] . '" ' . ($foo['id_product_comment_criterion'] == $id_criterion ? 'selected="selected"' : '') . '>' . $foo['name'] . '</option>';
            }
            $this->_html .= '</select>
					</div>
				</form>';
            if ($id_criterion && $criterion->id_product_comment_criterion_type != 1) {
                $this->_html .= '<label for="id_product_comment_criterion">' . ($criterion->id_product_comment_criterion_type == 3 ? $this->l('Products') : $this->l('Categories')) . '</label>
					<form action="' . Tools::safeOutput($this->_baseUrl) . '" method="post" name="comment_form">
						<div id="product_criterions" class="margin-form">
							<input type="hidden" name="id_criterion" id="id_criterion" value="' . (int) $id_criterion . '" />
							<br /><table class="table" border="0" cellspacing="0" cellpadding="0">
							<thead>
							<tr>
								<th><input class="noborder" type="checkbox" name="id_product[]" onclick="checkDelBoxes(this.form, \'id_product[]\', this.checked);" /></th>
								<th style="width: 30px;">' . $this->l('ID') . '</th>
								<th style="width: 550px;">' . ($criterion->id_product_comment_criterion_type == 3 ? $this->l('Product Name') : $this->l('Category Name')) . '</th>
							</tr>
							</thead>
							<tbody>';
                if ($criterion->id_product_comment_criterion_type == 3) {
                    foreach ($products as $product) {
                        $this->_html .= '<tr><td><input class="noborder" type="checkbox" value="' . (int) $product['id_product'] . '" name="id_product[]" ' . (in_array($product['id_product'], $criterion_products) ? 'checked="checked"' : '') . ' /></td>
											<td>' . (int) $product['id_product'] . '</td><td>' . $product['name'] . '</td></tr>';
                    }
                } else {
                    if ($criterion->id_product_comment_criterion_type == 2) {
                        foreach ($categories as $category) {
                            $this->_html .= '<tr><td><input class="noborder" type="checkbox" value="' . (int) $category['id_category'] . '" name="id_product[]" ' . (in_array($category['id_category'], $criterion_categories) ? 'checked="checked"' : '') . ' /></td>
											<td>' . (int) $category['id_category'] . '</td><td>' . $category['name'] . '</td></tr>';
                        }
                    }
                }
                $this->_html .= '</tbody>
						</table>
						</div>
						<div class="margin-form clear">
							<input type="submit" name="submitApplicationCriterion" value="' . $this->l('Save') . '" class="button" />
						</div>
					</form>';
            }
            $this->_html .= '</fieldset>';
        }
    }
示例#29
0
    /** all the forms */
    private function _displayForm()
    {
        $standardHooks = $this->standardHooks;
        /* permissions*/
        $enabled = false;
        if ($this->context->employee->id_profile == _PS_ADMIN_PROFILE_ || $this->settings['permissions']['hooks'] == 0) {
            $enabled = true;
        }
        if ($sort = Tools::getValue('sort')) {
            //sort order changed but the variable $this->hook is already set and will not be loaded until next page load so use the sort parameter instead
            $this->hook = $sort;
        }
        /** General hook settings */
        if ($enabled) {
            $this->_html .= '
		<form id="sliders_setup" action="' . AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite($this->name) . '" method="post">
			<fieldset>
				<legend><img src="' . $this->module->getBaseUrl() . '/modules/' . $this->module->name . '/logo.png" alt="logo" />' . $this->l('Slides Setup') . ' </legend>
				<p>' . $this->l('Choose where you want your sliders to appear, add new sliders or delete it.') . '</p>
				<table class="table confighooks" >
					<tr >
						<th>' . $this->l('Slider Name') . '</th>
						<th>' . $this->l('Top') . '</th>
						<th>' . $this->l('Home') . '</th>
						<th>' . $this->l('Left Sidebar') . '</th>
						<th>' . $this->l('Left Product Sidebar') . '</th>
						<th>' . $this->l('Right Sidebar') . '</th>
						<th>' . $this->l('Right Product Sidebar') . '</th>
						<th>' . $this->l('Footer') . '</th>
						<th>' . $this->l('Product Footer') . '</th>';
            if ($this->module->isPS6) {
                $this->_html .= '
						<th>' . $this->l('Top column') . '</th>
						<th>' . $this->l('Home Tab Content') . '</th>
						<th>' . $this->l('Product Tab') . '</th>
						<th>' . $this->l('Shopping Cart Foot') . '</th>
						<th>' . $this->l('Banner') . '</th>
						';
            }
            $this->_html .= '
						<th>' . $this->l('Category Image') . '</th>
						<th><b>' . $this->l('Delete') . '</b></th>
					</tr>';
            if (is_array($this->hook) && !empty($this->hook)) {
                $i = 0;
                foreach ($this->hook as $hookid => $hookname) {
                    $this->_html .= '<tr class="' . ($i % 2 == 0 ? 'odd' : 'even') . '">
					<td><i class="handle fa fa-arrows-v"></i>' . $hookname . '<input type="hidden" name="sort[]" value="' . $hookname . '"/></td>';
                    foreach ($this->baseHooks as $shook) {
                        // standard prestashop hooks
                        if (isset($standardHooks[$shook]) && is_array($standardHooks[$shook]) && in_array($hookname, $standardHooks[$shook])) {
                            $checked = "checked='checked'";
                            $class = 'active';
                        } else {
                            $checked = '';
                            $class = '';
                        }
                        $this->_html .= '<td class="' . $class . '">
						<input ' . $checked . ' type="checkbox" name="standardHooks[' . $shook . '][]" value="' . $hookname . '" />
						</td>';
                    }
                    // category hook
                    if (!($chosenCat = $this->module->getCategoryIdBySlide($hookname))) {
                        $chosenCat = '';
                    }
                    $this->_html .= '<td>' . $this->l('Category ID') . ': <input size="2" class="catnumber" type="number" value="' . $chosenCat . '" name="cat[' . $hookname . ']"/></td>';
                    $this->_html .= '<td class="delete"><input type="checkbox" name="hooksetup[' . $hookid . ']" value="' . $hookname . '"/></td>';
                    $this->_html .= '</tr>';
                    $i++;
                }
            }
            /** save hooks */
            $this->_html .= '</table><br/>
			<div class="margin-form">
				<input class="button" type="submit" name="saveHooks" value="' . $this->l('Save Hook Configuration') . '"/>
				<input class="button deleteSlide" type="submit" name="deleteHook" value="' . $this->l('Delete Selected Slides') . '"/>
			</div>';
            $this->_html .= '<hr/><label><span class="fa fa-plus-circle"></span> ' . $this->l('New Slider name') . '</label>
			<div class="margin-form"><input type="text" name="newSlide" value=""/> (' . $this->l('Only lowercase letters and underscores, no special characters, no numbers or blank spaces.') . ')</div>
			<div class="margin-form"><input class="button" type="submit" name="addHook" value="' . $this->l('Add New Slider') . '"/></div>';
            $this->_html .= '</fieldset></form>';
        }
        // end if enabled permissions
        /** End Genearl settings */
        /** slide CHOOSER **/
        $slideArray = array();
        // cache slides to avoide multiple queries
        $this->_html .= '<div class="slideChooserCont">';
        if (is_array($this->hook) && !empty($this->hook)) {
            foreach ($this->hook as $hookId => $hookname) {
                $slideArray[$hookname] = $this->module->getSlides(null, $hookname);
                $empty = !$slideArray[$hookname] ? true : false;
                $count = count($slideArray[$hookname]);
                $this->_html .= '<a class="slideChoose ' . ($hookId == 0 ? 'active' : '') . '" href="#' . $hookname . 'slideConf"><span class="anim">' . $hookname . ' ' . ($empty ? '<span title="' . $this->l('You have not yet added any slides.') . '" class="fa fa-exclamation"></span>' : '<span class="number">' . $count . '</span>') . '</span></a>';
            }
        }
        $this->_html .= '</div>';
        /** slides configuration **/
        $this->_html .= '<form id="sliders_config" class="fixsize" action="' . AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite($this->name) . '" method="post">';
        $confs = $this->configuration;
        $filterData = array();
        // controllers for the filter list;
        $filterData['controllers'] = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
        // categories for the filter list;
        $filterData['categories'] = Category::getSimpleCategories((int) Context::getContext()->language->id);
        // manufacturers for the filter list;
        $filterData['manufacturers'] = Manufacturer::getManufacturers();
        // sliders configuration tabs
        if (is_array($this->hook) && !empty($this->hook)) {
            foreach ($this->hook as $hookId => $hookname) {
                $this->_html .= '<fieldset class="position ' . $hookname . ' ' . ($hookId == 0 ? 'open' : '') . '" id="' . $hookname . 'slideConf"><legend><img src="' . $this->module->getBaseUrl() . '/modules/' . $this->module->name . '/logo.png" alt="logo" /> ' . $this->l('Slider') . ': "' . $hookname . '"</legend>';
                $this->_html .= '<div class="codes">' . $this->l('Custom hook code') . ': <span class="hookCode">{hook h="displaySlidersPro" slider="' . $hookname . '"}</span> ';
                $this->_html .= $this->l('Shortcode for editors') . ': <span class="hookCode">[SE:' . $hookname . ']</span></div>';
                $this->_html .= '<strong class="add_slide_button">
					<a href="' . AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite($this->name) . '&addSlide&hook=' . $hookname . '">
						<i class="fa fa-plus-circle addslide"></i> ' . $this->l('Add Slide') . '
					</a>
				</strong>';
                // tabbed slide configuration options
                $this->renderSlideConfigurations($hookId, $hookname, $confs);
                /* Gets Slides from stored array*/
                $slides = $slideArray[$hookname];
                //sortable list of slides
                $this->renderSortableSlideList($slides, $hookname);
                /* FILTERS */
                $this->renderFiltersConfiguration($confs, $hookname, $filterData);
                $this->_html .= '</fieldset>';
            }
            // enf hook foreach
        }
        $this->_html .= '</form>';
        $this->_html .= "<script type='text/javascript'>\n\n\t\t\t\$('#hints').click(function(){\n\t\t\t\t\$('#hints').parent().find('.margin-form').slideToggle();\n\t\t\t});\n\t\t\t\$('#slide-save').click(function(){\n\t\t\t\t\$('#sliders_config').submit();\n\t\t\t})\n\t\t\n\t\t\t\$('#sliders_config').submit(function(e){\n\t\t\t\t//e.preventDefault();\n\t\t\t\tvar valid = true;\n\t\t\t\t\$('input.config').each(function(){\n\t\t\t\t\tif (\$(this).val() =='' || isNaN(\$(this).val()) ) {\n\t\t\t\t\t\tvalid = false;\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tif (valid == true) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\talert('" . $this->l('Enter a valid number') . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t})\n\t\t</script>";
        $this->_html .= $this->module->getCreds();
    }