public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $shops = Shop::getShops();
     if (count($this->context->employee->getAssociatedShops()) > 1) {
         $shops = array_merge(array(0 => array('id_shop' => 0, 'name' => $this->l('All shops'))), $shops);
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Specific price rules')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 33, 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop:'), 'name' => 'id_shop', 'options' => array('query' => $shops, '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', 'size' => 6, 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.):'), 'name' => 'price', 'size' => 6, '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' => 'date', 'label' => $this->l('From:'), 'name' => 'from', 'size' => 12), array('type' => 'date', 'label' => $this->l('To:'), 'name' => 'to', 'size' => 12), 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' => 'text', 'label' => $this->l('Reduction:'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 2);
     } 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, 2), '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();
 }
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $this->fields_form = array('legend' => array('title' => $this->trans('Catalog price rules', array(), 'Admin.Catalog.Feature'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->trans('Name', array(), 'Admin.Global'), 'name' => 'name', 'maxlength' => 255, 'required' => true), array('type' => 'select', 'label' => $this->trans('Shop', array(), 'Admin.Global'), '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->trans('Currency', array(), 'Admin.Global'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->trans('All currencies', array(), 'Admin.Global'))), Currency::getCurrencies(false, true, true)), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Country', array(), 'Admin.Global'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->trans('All countries', array(), 'Admin.Global'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Group', array(), 'Admin.Global'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->trans('All groups', array(), 'Admin.Global'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->trans('From quantity', array(), 'Admin.Catalog.Feature'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->trans('Price (tax excl.)', array(), 'Admin.Catalog.Feature'), '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->trans('Leave initial price', array(), 'Admin.Catalog.Feature'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->trans('From', array(), 'Admin.Global'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->trans('To', array(), 'Admin.Global'), 'name' => 'to'), array('type' => 'select', 'label' => $this->trans('Reduction type', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->trans('Amount', array(), 'Admin.Global')), array('reduction_type' => 'percentage', 'name' => $this->trans('Percentage', array(), 'Admin.Global'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Reduction with or without taxes', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->trans('Tax included', array(), 'Admin.Global'), 'val' => 1), array('lab' => $this->trans('Tax excluded', array(), 'Admin.Global'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->trans('Reduction', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions')));
     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, 'shop_id' => ($value = $this->getFieldValue($this->object, 'id_shop')) ? $value : 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();
 }
 public function initRuleForm()
 {
     $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('New tax rule'), 'icon' => 'icon-money'), 'input' => array(array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'country', 'id' => 'country', 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('All')))), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'states[]', 'id' => 'states', 'multiple' => true, 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('All')))), array('type' => 'hidden', 'name' => 'action'), array('type' => 'text', 'label' => $this->l('Zip/postal code range'), 'name' => 'zipcode', 'required' => false, 'hint' => $this->l('You can define a range of Zip/postal codes (e.g., 75000-75015) or simply use one Zip/postal code.')), array('type' => 'select', 'label' => $this->l('Behavior'), 'name' => 'behavior', 'required' => false, 'options' => array('query' => array(array('id' => 0, 'name' => $this->l('This tax only')), array('id' => 1, 'name' => $this->l('Combine')), array('id' => 2, 'name' => $this->l('One after another'))), 'id' => 'id', 'name' => 'name'), 'hint' => array($this->l('You must define the behavior if an address matches multiple rules:') . '<br>', $this->l('- This tax only: Will apply only this tax') . '<br>', $this->l('- Combine: Combine taxes (e.g.: 10% + 5% = 15%)') . '<br>', $this->l('- One after another: Apply taxes one after another (e.g.: 0 + 10% = 0 + 5% = 5.5)'))), array('type' => 'select', 'label' => $this->l('Tax'), 'name' => 'id_tax', 'required' => false, 'options' => array('query' => Tax::getTaxes((int) $this->context->language->id), 'id' => 'id_tax', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('No Tax'))), 'hint' => sprintf($this->l('(Total tax: %s)'), '9%')), array('type' => 'select', 'label' => $this->l('Grupos'), 'name' => 'id_group', 'required' => false, 'options' => array('query' => Group::getGroups($this->default_form_language, true), 'id' => 'id_group', 'name' => 'name', 'default' => array('value' => 0, 'label' => $this->l('Default'))), 'hint' => sprintf($this->l('(Total tax: %s)'), '9%')), array('type' => 'text', 'label' => $this->l('Description'), 'name' => 'description')), 'submit' => array('title' => $this->l('Save and stay'), 'stay' => true));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $this->fields_value = array('action' => 'create_rule', 'id_tax_rules_group' => $obj->id, 'id_tax_rule' => '');
     $this->getlanguages();
     $helper = new HelperForm();
     $helper->override_folder = $this->tpl_folder;
     $helper->currentIndex = self::$currentIndex;
     $helper->token = $this->token;
     $helper->table = 'tax_rule';
     $helper->identifier = 'id_tax_rule';
     $helper->id = $obj->id;
     $helper->toolbar_scroll = true;
     $helper->show_toolbar = true;
     $helper->languages = $this->_languages;
     $helper->default_form_language = $this->default_form_language;
     $helper->allow_employee_form_lang = $this->allow_employee_form_lang;
     $helper->fields_value = $this->getFieldsValue($this->object);
     $helper->toolbar_btn['save_new_rule'] = array('href' => self::$currentIndex . '&amp;id_tax_rules_group=' . $obj->id . '&amp;action=create_rule&amp;token=' . $this->token, 'desc' => 'Save tax rule', 'class' => 'process-icon-save');
     $helper->submit_action = 'create_rule';
     return $helper->generateForm($this->fields_form);
 }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'group';
        $this->className = 'Group';
        $this->list_id = 'group';
        $this->lang = true;
        $this->addRowAction('edit');
        $this->addRowAction('view');
        $this->addRowAction('delete');
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $groups_to_keep = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
        $this->fields_list = array('id_group' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Group name'), 'filter_key' => 'b!name'), 'reduction' => array('title' => $this->l('Discount (%)'), 'align' => 'right', 'type' => 'percent'), 'nb' => array('title' => $this->l('Members'), 'align' => 'center', 'havingFilter' => true), 'show_prices' => array('title' => $this->l('Show prices'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printShowPricesIcon', 'orderby' => false), 'date_add' => array('title' => $this->l('Creation date'), 'type' => 'date', 'align' => 'right'));
        $this->addRowActionSkipList('delete', $groups_to_keep);
        parent::__construct();
        $this->_select .= '(SELECT COUNT(jcg.`id_customer`)
		FROM `' . _DB_PREFIX_ . 'customer_group` jcg
		LEFT JOIN `' . _DB_PREFIX_ . 'customer` jc ON (jc.`id_customer` = jcg.`id_customer`)
		WHERE jc.`deleted` != 1
		' . Shop::addSqlRestriction(Shop::SHARE_CUSTOMER) . '
		AND jcg.`id_group` = a.`id_group`) AS nb';
        $groups = Group::getGroups(Context::getContext()->language->id, true);
        if (Shop::isFeatureActive()) {
            $this->fields_options = array('general' => array('title' => $this->l('Default groups options'), 'fields' => array('PS_UNIDENTIFIED_GROUP' => array('title' => $this->l('Visitors group'), 'desc' => $this->l('The group defined for your un-identified visitors.'), 'cast' => 'intval', 'type' => 'select', 'list' => $groups, 'identifier' => 'id_group'), 'PS_GUEST_GROUP' => array('title' => $this->l('Guests group'), 'desc' => $this->l('The group defined for your identified guest customers (used in guest checkout).'), 'cast' => 'intval', 'type' => 'select', 'list' => $groups, 'identifier' => 'id_group'), 'PS_CUSTOMER_GROUP' => array('title' => $this->l('Customers group'), 'desc' => $this->l('The group defined for your identified registered customers.'), 'cast' => 'intval', 'type' => 'select', 'list' => $groups, 'identifier' => 'id_group')), 'submit' => array('title' => $this->l('Save'))));
        }
    }
 public function xdInstall()
 {
     foreach ($this->Options->getValue('carrierList') as $carrier_key => $carrier_name) {
         $carrierId = \Configuration::get($carrier_key);
         $deleted = false;
         if ($carrierId > 0) {
             $carrier = new \Carrier($carrierId);
             $deleted = $carrier->deleted;
         }
         if ($carrierId < 1 || $deleted) {
             // Create carrier
             $carrier = new \Carrier();
             $carrier->name = $carrier_name;
             $carrier->id_tax_rules_group = 0;
             $carrier->active = 1;
             $carrier->deleted = 0;
             foreach (\Language::getLanguages(true) as $language) {
                 // TODO Carrier delay
                 $carrier->delay[(int) $language['id_lang']] = ' ';
             }
             $carrier->shipping_handling = 0;
             $carrier->range_behavior = 1;
             $carrier->is_module = 1;
             $carrier->shipping_external = 1;
             $carrier->external_module_name = $this->moduleInstance->name;
             $carrier->need_range = 1;
             if (!$carrier->add()) {
                 return false;
             }
             // Associate carrier to all groups
             $groups = \Group::getGroups(true);
             foreach ($groups as $group) {
                 \Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']));
             }
             // Create price range
             $rangePrice = new \RangePrice();
             $rangePrice->id_carrier = $carrier->id;
             $rangePrice->delimiter1 = '0';
             $rangePrice->delimiter2 = '10000';
             $rangePrice->add();
             // Create weight range
             $rangeWeight = new \RangeWeight();
             $rangeWeight->id_carrier = $carrier->id;
             $rangeWeight->delimiter1 = '0';
             $rangeWeight->delimiter2 = '10000';
             $rangeWeight->add();
             // Associate carrier to all zones
             $zones = \Zone::getZones(true);
             foreach ($zones as $zone) {
                 \Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
                 \Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
                 \Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
             }
             copy(self::$instanceBaseDir . '/img/logo.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
             \Configuration::updateValue($carrier_key, $carrier->id);
         }
     }
     return true;
 }
예제 #6
0
 protected function prepareTwig()
 {
     $groups = Group::getGroups($this->getMe()->getId());
     Service::getTemplateEngine()->addGlobal("groups", $groups);
     $creator = new MessageSearchFormCreator();
     $searchForm = $creator->create();
     Service::getTemplateEngine()->addGlobal("searchForm", $searchForm->createView());
 }
예제 #7
0
 public function installCarriers()
 {
     $id_lang_default = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'));
     $carriers_list = array('MYMOD_CA_CLDE' => 'Classic delivery', 'MYMOD_CA_REPO' => 'Relay Point');
     foreach ($carriers_list as $carrier_key => $carrier_name) {
         if (Configuration::get($carrier_key) < 1) {
             // Create new carrier
             $carrier = new Carrier();
             $carrier->name = $carrier_name;
             $carrier->id_tax_rules_group = 0;
             $carrier->active = 1;
             $carrier->deleted = 0;
             foreach (Language::getLanguages(true) as $language) {
                 $carrier->delay[(int) $language['id_lang']] = 'Delay ' . $carrier_name;
             }
             $carrier->shipping_handling = false;
             $carrier->range_behavior = 0;
             $carrier->is_module = true;
             $carrier->shipping_external = true;
             $carrier->external_module_name = $this->name;
             $carrier->need_range = true;
             if (!$carrier->add()) {
                 return false;
             }
             // Associate carrier to all groups
             $groups = Group::getGroups(true);
             foreach ($groups as $group) {
                 Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']));
             }
             // Create price range
             $rangePrice = new RangePrice();
             $rangePrice->id_carrier = $carrier->id;
             $rangePrice->delimiter1 = '0';
             $rangePrice->delimiter2 = '10000';
             $rangePrice->add();
             // Create weight range
             $rangeWeight = new RangeWeight();
             $rangeWeight->id_carrier = $carrier->id;
             $rangeWeight->delimiter1 = '0';
             $rangeWeight->delimiter2 = '10000';
             $rangeWeight->add();
             // Associate carrier to all zones
             $zones = Zone::getZones(true);
             foreach ($zones as $zone) {
                 Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
                 Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
                 Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
             }
             // Copy the carrier logo
             copy(dirname(__FILE__) . '/views/img/' . $carrier_key . '.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
             // Save the carrier ID in the Configuration table
             Configuration::updateValue($carrier_key, $carrier->id);
         }
     }
     return true;
 }
 public function installExternalCarrier($config)
 {
     $carrier = new Carrier();
     $carrier->name = $config['name'];
     $carrier->id_tax_rules_group = $config['id_tax_rules_group'];
     $carrier->active = $config['active'];
     $carrier->deleted = $config['deleted'];
     $carrier->delay = $config['delay'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behavior = $config['range_behavior'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $languages = Context::getContext()->language->getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'cs') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         } else {
             $carrier->delay[(int) $language['id_lang']] = '2 days';
         }
     }
     if ($carrier->add()) {
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = '0';
         $rangePrice->delimiter2 = '1000000';
         $rangePrice->add();
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = '0';
         $rangeWeight->delimiter2 = '10000';
         $rangeWeight->add();
         $sql = 'SELECT DISTINCT id_zone FROM ' . _DB_PREFIX_ . 'country WHERE iso_code="CZ" OR iso_code="SK"';
         $zones = Db::getInstance()->executeS($sql);
         if (is_array($zones)) {
             foreach ($zones as $zone) {
                 Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
                 Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
                 Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
             }
         }
         $this->module->copyLogo($carrier->id);
         if (Configuration::get('PS_TAX')) {
             $carrier->setTaxRulesGroup(1, true);
         }
         return (int) $carrier->id;
     }
     $this->messages[] = 'Failed to create external carrier ' . $config['name'];
     return false;
 }
예제 #9
0
 public function initContent()
 {
     Configuration::updateValue('SEGMENT_CUSTOMER_TOKEN', Tools::getValue('token'));
     if (version_compare(_PS_VERSION_, '1.5', '>=')) {
         Context::getContext()->controller->addJqueryUI('ui.datepicker');
     }
     $this->clearCacheLang();
     $this->initLang();
     Context::getContext()->smarty->assign(array('mj__PS_BASE_URI__' => __PS_BASE_URI__, 'mj_PS_JS_DIR_' => _PS_JS_DIR_, 'mj_MODULE_DIR_' => _MODULE_DIR_, 'mj_hint_fieldset' => array($this->l('This module enables you to create segments of customers according to any criteria you think of. You can then either display and export the selected customers or associate them to an existing customer group.', 'mailjet'), $this->l('These segments are particularly useful to create special offers associated with customer groups (e.g., send a coupon to the customers interested in some products)', 'mailjet'), $this->l('Create an infinite number of filters corresponding to your needs!', 'mailjet')), 'mj_datePickerJsFormat' => Context::getContext()->cookie->id_lang == Language::getIdByIso('fr') ? 'dd-mm-yy' : 'yy-mm-dd', 'mj_datepickerPersonnalized' => version_compare(_PS_VERSION_, '1.5', '<') ? '<script type="text/javascript" src="' . _PS_JS_DIR_ . 'jquery/datepicker/jquery-ui-personalized-1.6rc4.packed.js"></script>' : '', 'mj_token' => Tools::getValue('token'), 'mj_ajaxFile' => _MODULE_DIR_ . 'mailjet/ajax/ajax.php', 'mj_ajaxSyncFile' => _MODULE_DIR_ . 'mailjet/ajax/sync.php', 'mj_ajaxBundle' => _MODULE_DIR_ . 'mailjet/ajax/bundlejs_prestashop.php', 'mj_id_employee' => (int) Context::getContext()->cookie->id_employee, 'mj_lblMan' => stripReturn($this->ll(20)), 'mj_lblWoman' => stripReturn($this->ll(21)), 'mj_lblUnknown' => stripReturn($this->ll(43)), 'mj_trads' => array_map('stripReturn', $this->trad), 'mj_groups' => Group::getGroups((int) Context::getContext()->cookie->id_lang), 'mj_filter_list' => Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'mj_filter`'), 'mj_base_select' => Db::getInstance()->ExecuteS('SELECT id_basecondition, label FROM `' . _DB_PREFIX_ . 'mj_basecondition`')));
     return '';
 }
예제 #10
0
 /**
  * @todo Implement testGetGroups().
  */
 public function testGetGroups()
 {
     $groups = $this->object->getGroups();
     if (!is_array($groups)) {
         $this->fail();
     }
     foreach ($groups as $group) {
         if (!$group instanceof Group) {
             $this->fail();
         }
     }
 }
function setAllGroupsOnHomeCategory()
{
    $results = Group::getGroups(Configuration::get('PS_LANG_DEFAULT'));
    $groups = array();
    foreach ($results as $result) {
        $groups[] = $result['id_group'];
    }
    if (is_array($groups) && sizeof($groups)) {
        $category = new Category(1);
        $category->cleanGroups();
        $category->addGroups($groups);
    }
}
예제 #12
0
 public function getContent()
 {
     $connected = Configuration::get('NEWSMAN_CONNECTED');
     $helper = new HelperForm();
     // Module, token and currentIndex
     $helper->module = $this;
     //$helper->table = $this->table;
     $helper->name_controller = $this->name;
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
     // Language
     // Get default Language
     $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     $helper->default_form_language = $default_lang;
     $helper->allow_employee_form_lang = $default_lang;
     // Title and toolbar
     $helper->title = $this->displayName;
     $helper->show_toolbar = true;
     // false -> remove toolbar
     $helper->toolbar_scroll = true;
     // yes - > Toolbar is always visible on the top of the screen.
     $helper->submit_action = 'submit' . $this->name;
     // Load current value
     $helper->fields_value['api_key'] = Configuration::get('NEWSMAN_API_KEY');
     $helper->fields_value['user_id'] = Configuration::get('NEWSMAN_USER_ID');
     $helper->fields_value['cron_url'] = $this->context->shop->getBaseURL() . 'modules/newsman/cron_task.php';
     $helper->fields_value['cron_option'] = Configuration::get('NEWSMAN_CRON');
     $mappingSection = array(array('type' => 'select', 'label' => 'Newsman list', 'name' => 'sel_list', 'options' => array('query' => array())), array('type' => 'html', 'name' => 'unused', 'html_content' => $this->l('Newsman destination segment')));
     //check for newsletter module
     if (Module::isInstalled('blocknewsletter')) {
         $mappingSection[] = array('type' => 'select', 'label' => $this->l('Newsletter subscribers'), 'name' => 'map_newsletter', 'class' => 'id-map-select', 'options' => array('query' => array()));
     }
     //list groups
     foreach (Group::getGroups($default_lang) as $row) {
         if ($row['id_group'] < 3) {
             continue;
         }
         $mappingSection[] = array('type' => 'select', 'label' => $row['name'] . ' ' . $this->l('Group'), 'name' => 'map_group_' . $row['id_group'], 'class' => 'id-map-select', 'options' => array('query' => array()));
     }
     $out = '<div id="newsman-msg"></div>';
     $out .= $helper->generateForm(array(array('form' => array('legend' => array('title' => $this->l('API Settings'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'text', 'label' => $this->l('API KEY'), 'name' => 'api_key', 'size' => 40, 'required' => true), array('type' => 'text', 'label' => $this->l('User ID'), 'name' => 'user_id', 'size' => 40, 'required' => true)), 'buttons' => array(array('title' => 'Connect', 'class' => 'pull-right', 'icon' => $connected ? 'process-icon-ok' : 'process-icon-next', 'js' => 'connectAPI(this)')))), array('form' => array('legend' => array('title' => $this->l('Synchronization mapping')), 'input' => $mappingSection, 'buttons' => array(array('title' => $this->l('Save mapping'), 'class' => 'pull-right', 'icon' => 'process-icon-save', 'js' => 'saveMapping(this)'), array('title' => $this->l('Refresh segments'), 'icon' => 'process-icon-refresh', 'js' => 'connectAPI(this)')))), array('form' => array('legend' => array('title' => $this->l('Automatic synchronization')), 'input' => array(array('label' => 'Automatic synchronization', 'type' => 'select', 'name' => 'cron_option', 'options' => array('query' => array(array('value' => '', 'label' => $this->l('never (disabled)')), array('value' => 'd', 'label' => $this->l('every day')), array('value' => 'w', 'label' => $this->l('every week'))), 'id' => 'value', 'name' => 'label'))), 'buttons' => array(array('title' => $this->l('Synchronize now'), 'icon' => 'process-icon-next', 'js' => 'synchronizeNow(this)'), array('title' => $this->l('Save option'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'js' => 'saveCron(this)'))))));
     //the script
     $this->context->controller->addJS($this->_path . 'views/js/newsman.js');
     $ajaxURL = $this->context->link->getAdminLink('AdminModules') . '&configure=' . $this->name;
     $mapExtra = array(array('', $this->l('Do not import')), array('none', $this->l('Import, no segment')));
     $data = Configuration::get('NEWSMAN_DATA');
     $mapping = Configuration::get('NEWSMAN_MAPPING');
     $out .= '<script>var newsman=' . Tools::jsonEncode(array('data' => $data ? Tools::jsonDecode($data) : false, 'mapExtra' => $mapExtra, 'mapping' => $mapping ? Tools::jsonDecode($mapping) : false, 'ajaxURL' => $ajaxURL, 'strings' => array('needConnect' => $this->l('You need to connect to Newsman first!'), 'needMapping' => $this->l('You need to save mapping first!')))) . '</script>';
     return $out;
 }
예제 #13
0
/**
* Prints out the display/edit UI to add/remove groups for this user
* @param string $memberid id of the member to to change groups for
*/
function print_edit($edit, &$user)
{
    $group = new Group(new GroupDB());
    $non_user_groups = $group->getGroups($user->get_id());
    $user_groups = $user->groups;
    begin_table($user->get_name());
    if ($edit) {
        print_groups_to_add($non_user_groups);
        print_move_buttons();
        print_groups_to_remove($user_groups);
        print_save_button($user->get_id());
    } else {
        print_groups_to_view($user_groups);
    }
    end_table();
}
예제 #14
0
 protected static function assignCustomerGroupsForCarrier($carrier)
 {
     $groups = array();
     foreach (Group::getGroups((int) Context::getContext()->language->id) as $group) {
         $groups[] = $group['id_group'];
     }
     if (version_compare(_PS_VERSION_, '1.5.5', '<')) {
         if (!self::setGroups14((int) $carrier->id, $groups)) {
             return false;
         }
     } else {
         if (!$carrier->setGroups($groups)) {
             return false;
         }
     }
     return true;
 }
예제 #15
0
 /**
  * @param $module
  * @return array
  */
 protected static function getCustomerGroups($module)
 {
     /**
      * customer groups
      */
     $customerGroupsItems = Group::getGroups($module->context->language->id, $module->context->shop->id ? $module->context->shop->id : false);
     $customerGroups = array();
     if (is_array($customerGroupsItems)) {
         foreach ($customerGroupsItems as $customerGroupsItem) {
             $group = array();
             $group['id'] = $customerGroupsItem['id_group'];
             $group['name'] = $customerGroupsItem['name'];
             $group['is_default'] = $group['id'] == (int) Configuration::get('PS_GUEST_GROUP') ? true : false;
             $customerGroups[] = $group;
         }
     }
     return $customerGroups;
 }
예제 #16
0
파일: Generic.php 프로젝트: knatorski/SMS
 public function baseInit()
 {
     $groups = new Group();
     $group = $groups->getGroups();
     $profiles = new Profile();
     $profile = $profiles->getProfiles();
     foreach ($group as $single_group) {
         $group_arr[$single_group['id']] = $single_group['id'] . ' ' . $single_group['group_name'];
     }
     $this->addElement('Select', 'id_group', array('required' => false, 'label' => 'Assign to group:', 'MultiOptions' => $this->addClearStart($group_arr)));
     $resources = new LinkResource();
     $resource = $resources->getLinkResources();
     foreach ($resource as $single_resource) {
         $resource_arr[$single_resource['id']] = $single_resource['controller'] . ' ' . $single_resource['action'];
     }
     asort($resource_arr);
     $this->addElement('Select', 'id_resource', array('required' => false, 'label' => 'Assign link resource:', 'MultiOptions' => $this->addClearStart($resource_arr)));
     $this->submit();
     $this->cancel();
 }
예제 #17
0
 public function display()
 {
     global $cookie;
     foreach ($this->paymentModules as $module) {
         if ($module->active and $module->warning) {
             $this->displayWarning($module->displayName . ' - ' . stripslashes(pSQL($module->warning)));
         }
     }
     $currencies = Currency::getCurrencies();
     $countries = Country::getCountries(intval($cookie->id_lang));
     $groups = Group::getGroups(intval($cookie->id_lang));
     $this->displayModules();
     echo '<br /><h2 class="space">' . $this->l('Payment module restrictions') . '</h2>';
     $textCurrencies = $this->l('Please mark the checkbox(es) for the currency or currencies in which you want the payment module(s) available.');
     $textCountries = $this->l('Please mark the checkbox(es) for the country or countries in which you want the payment module(s) available.');
     $textGroups = $this->l('Please mark the checkbox(es) for the groups in which you want the payment module(s) available.');
     $this->displayModuleRestrictions($currencies, $this->l('Currencies restrictions'), 'currency', $textCurrencies, 'dollar');
     echo '<br />';
     $this->displayModuleRestrictions($groups, $this->l('Groups restrictions'), 'group', $textGroups, 'group');
     echo '<br />';
     $this->displayModuleRestrictions($countries, $this->l('Countries restrictions'), 'country', $textCountries, 'world');
 }
예제 #18
0
 public function renderForm()
 {
     $this->display = 'edit';
     $this->initToolbar();
     if (!$this->loadObject(true)) {
         return;
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Payment Systems'), 'icon' => 'icon-money'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'required' => true, 'lang' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'switch', 'label' => $this->l('Displayed:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'textarea', 'label' => $this->l('Short description:'), 'name' => 'description_short', 'lang' => true, 'rows' => 5, 'cols' => 40, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Displayed in payment selection page.')), array('type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'autoload_rte' => true, 'lang' => true, 'rows' => 5, 'cols' => 40, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('%total% will be replaced with total amount.')), array('type' => 'textarea', 'label' => $this->l('Description success:'), 'name' => 'description_success', 'autoload_rte' => true, 'lang' => true, 'rows' => 5, 'cols' => 40, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('%order_number% will be replaced with order reference, %order_number% - order id, %total% - total amount')), array('type' => 'file', 'label' => $this->l('Image:'), 'name' => 'logo', 'display_image' => true, 'desc' => $this->l('Upload payment logo from your computer')), array('type' => 'select', 'label' => $this->l('Order state:'), 'name' => 'id_order_state', 'desc' => $this->l('Order state after create.'), 'options' => array('query' => OrderState::getOrderStates($this->context->language->id), 'name' => 'name', 'id' => 'id_order_state')), array('type' => 'checkbox', 'label' => $this->l('Carriers:'), 'name' => 'carrierBox', 'values' => array('query' => Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::ALL_CARRIERS), 'id' => 'id_carrier', 'name' => 'name'), 'desc' => $this->l('The carriers in which this paysystem is to be used')), array('type' => 'group', 'label' => $this->l('Groups:'), 'name' => 'groupBox', 'values' => Group::getGroups($this->context->language->id), 'desc' => $this->l('The customer groups in which this paysystem is to be used'))), 'submit' => array('title' => $this->l('Save')));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     // Added values of object Group
     $universalpay_system_carrier_ids = $obj->getCarriers();
     $carriers = Carrier::getCarriers($this->context->language->id, false, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     foreach ($carriers as $carrier) {
         $this->fields_value['carrierBox_' . $carrier['id_carrier']] = Tools::getValue('carrierBox_' . $carrier['id_carrier'], in_array($carrier['id_carrier'], $universalpay_system_carrier_ids));
     }
     $universalpay_system_group_ids = $obj->getGroups();
     $groups = Group::getGroups($this->context->language->id);
     foreach ($groups as $group) {
         $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $universalpay_system_group_ids));
     }
     return parent::renderForm();
 }
예제 #19
0
function upgrade_module_1_2_2_9($object)
{
    // Make sure that posts for logged only are properly assigned to new access system:
    $posts = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'simpleblog_post`');
    $available_groups = Group::getGroups(Context::getContext()->language->id);
    foreach ($posts as $post) {
        $post_access = array();
        if ($post['logged'] == 1) {
            foreach ($available_groups as $group) {
                if ($group['id_group'] == Configuration::get('PS_UNIDENTIFIED_GROUP') || $group['id_group'] == Configuration::get('PS_GUEST_GROUP')) {
                    $post_access[$group['id_group']] = false;
                } else {
                    $post_access[$group['id_group']] = true;
                }
            }
        } else {
            foreach ($available_groups as $group) {
                $post_access[$group['id_group']] = true;
            }
        }
        Db::getInstance()->update('simpleblog_post', array('access' => serialize($post_access)), 'id_simpleblog_post = ' . $post['id_simpleblog_post']);
    }
    return true;
}
 public function renderForm()
 {
     $this->initToolbar();
     $obj = $this->loadObject(true);
     $id_shop = Context::getContext()->shop->id;
     $selected_cat = array(isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop) ? (int) $obj->id_parent : (int) Tools::getValue('id_parent', Category::getRootCategory()->id));
     $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP'));
     $guest = new Group(Configuration::get('PS_GUEST_GROUP'));
     $default = new Group(Configuration::get('PS_CUSTOMER_GROUP'));
     $unidentified_group_information = sprintf($this->l('%s - All people without a validated customer account.'), '<b>' . $unidentified->name[$this->context->language->id] . '</b>');
     $guest_group_information = sprintf($this->l('%s - Customer who placed an order with the Guest Checkout.'), '<b>' . $guest->name[$this->context->language->id] . '</b>');
     $default_group_information = sprintf($this->l('%s - All people who have created an account on this site.'), '<b>' . $default->name[$this->context->language->id] . '</b>');
     $root_category = Category::getRootCategory();
     $root_category = array('id_category' => $root_category->id, 'name' => $root_category->name);
     $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Category'), 'image' => '../img/admin/tab-categories.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'lang' => true, 'size' => 48, 'required' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'radio', 'label' => $this->l('Displayed:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'categories', 'label' => $this->l('Parent category:'), 'name' => 'id_parent', 'values' => array('trads' => array('Root' => $root_category, 'selected' => $this->l('selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All')), 'selected_cat' => $selected_cat, 'input_name' => 'id_parent', 'use_radio' => true, 'use_search' => false, 'disabled_categories' => array(4), 'top_category' => Category::getTopCategory(), 'use_context' => true)), array('type' => 'radio', 'label' => $this->l('Root Category:'), 'name' => 'is_root_category', 'required' => false, 'is_bool' => true, 'class' => 't', 'values' => array(array('id' => 'is_root_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'is_root_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'lang' => true, 'rows' => 10, 'cols' => 100, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'file', 'label' => $this->l('Image:'), 'name' => 'image', 'display_image' => true, 'desc' => $this->l('Upload category logo from your computer')), array('type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description:'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords:'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}', 'desc' => $this->l('To add "tags" click in the field, write something, then press "Enter"')), array('type' => 'text', 'label' => $this->l('Friendly URL:'), 'name' => 'link_rewrite', 'lang' => true, 'required' => true, 'hint' => $this->l('Only letters and the minus (-) character are allowed')), array('type' => 'group', 'label' => $this->l('Group access:'), 'name' => 'groupBox', 'values' => Group::getGroups(Context::getContext()->language->id), 'info_introduction' => $this->l('You now have three default customer groups.'), 'unidentified' => $unidentified_group_information, 'guest' => $guest_group_information, 'customer' => $default_group_information, 'desc' => $this->l('Mark all customer groups you want to give access to this category'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     $this->tpl_form_vars['shared_category'] = Validate::isLoadedObject($obj) && $obj->hasMultishopEntries();
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     // remove category tree and radio button "is_root_category" if this category has the root category as parent category to avoid any conflict
     if ($this->_category->id_parent == Category::getTopCategory()->id && Tools::isSubmit('updatecategory')) {
         foreach ($this->fields_form['input'] as $k => $input) {
             if (in_array($input['name'], array('id_parent', 'is_root_category'))) {
                 unset($this->fields_form['input'][$k]);
             }
         }
     }
     if (Tools::isSubmit('add' . $this->table . 'root')) {
         unset($this->fields_form['input'][2], $this->fields_form['input'][3]);
     }
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $image = ImageManager::thumbnail(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true);
     $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg') / 1000 : false);
     // Added values of object Group
     $category_groups_ids = $obj->getGroups();
     $groups = Group::getGroups($this->context->language->id);
     // if empty $carrier_groups_ids : object creation : we set the default groups
     if (empty($category_groups_ids)) {
         $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
         $category_groups_ids = array_merge($category_groups_ids, $preselected);
     }
     foreach ($groups as $group) {
         $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $category_groups_ids));
     }
     return parent::renderForm();
 }
예제 #21
0
    /**
     * Set necessaries values to the created carrier
     *
     * @param $id_carrier
     * @param $dlv_mode
     * @return bool
     */
    private function addDefaultCarrierValue($id_carrier, $dlv_mode)
    {
        $weight_coef = $this->account_shop['MR_WEIGHT_COEFFICIENT'];
        // Default Range value depending of the delivery mode
        $range_weight = array('24R' => array(0, 20000 / $weight_coef), 'DRI' => array(20000 / $weight_coef, 130000 / $weight_coef), 'LD1' => array(0, 60000 / $weight_coef), 'LDS' => array(30000 / $weight_coef, 130000 / $weight_coef));
        // Set range weight for a dlv_mode
        if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'range_weight`
					(`id_carrier`, `delimiter1`, `delimiter2`)
					VALUES (' . (int) $id_carrier . ', ' . $range_weight[$dlv_mode][0] . ', ' . $range_weight[$dlv_mode][1] . ')')) {
            $this->_postErrors[] = $this->l('Range weight can\'t be added');
            return false;
        }
        $range_weight_id = Db::getInstance()->Insert_ID();
        // Set a range price
        if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'range_price`
					 (`id_carrier`, `delimiter1`, `delimiter2`)
					 VALUES (' . (int) $id_carrier . ', 0.000000, 10000.000000)')) {
            $this->_postErrors[] = $this->l('Range price can\'t be added');
            return false;
        }
        $range_price_id = Db::getInstance()->Insert_ID();
        $groups = Group::getGroups(Configuration::get('PS_LANG_DEFAULT'));
        foreach ($groups as $group) {
            if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'carrier_group`
						(id_carrier, id_group)
						VALUES(' . (int) $id_carrier . ', ' . (int) $group['id_group'] . ')')) {
                $this->_postErrors[] = $this->l('Default zone can\'t be added');
                return false;
            }
        }
        // Set default zone
        $zones = Zone::getZones();
        foreach ($zones as $zone) {
            if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'carrier_zone`
						(id_carrier, id_zone)
						VALUES(' . (int) $id_carrier . ', ' . (int) $zone['id_zone'] . ')') || !Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'delivery`
						(id_carrier, id_range_price, id_range_weight, id_zone, price)
						VALUES(' . (int) $id_carrier . ', ' . (int) $range_price_id . ', NULL,' . (int) $zone['id_zone'] . ', 0.00)') || !Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'delivery`
						(id_carrier, id_range_price, id_range_weight, id_zone, price)
						VALUES(' . (int) $id_carrier . ', NULL, ' . (int) $range_weight_id . ',' . (int) $zone['id_zone'] . ', 0.00)')) {
                $this->_postErrors[] = $this->l('Carrier zone or delivery data can\'t be added');
                return false;
            }
        }
        return true;
    }
예제 #22
0
 private function installCarrier($is_COD = 0)
 {
     $carrier = new Carrier();
     $carrier->name = 'Почта России';
     //Проверяем какого перевозчика создаем
     if ($is_COD) {
         $carrier->name .= ' (наложенный платеж)';
     }
     // @deprecated since 1.5.0
     //$carrier->id_tax_rules_group' = 0;
     // TODO: проверить -- это точно обязательно?
     //Способ доставки активен
     $carrier->active = true;
     // TODO: проверить -- это точно обязательно?
     //Не удален. При удалении способа доставки он не удаляется из
     //базы данных, а только помечается как удаленный
     $carrier->deleted = 0;
     // TODO: это может быть интересным -- стоимость упаковки и пр.
     //Доставка и обработка
     $carrier->shipping_handling = false;
     // Что делать, если Out Of Range. 0 -- считать, 1 -- не считать
     // Мы, ведь, сами определяем можем или не можем, настроек range
     // никаких не будет.
     //Исключения: применить наибольшую цену доставки
     $carrier->range_behavior = 0;
     // Тут зависимости от языка
     // TODO: по идее это время доставки, но для разных пунктов
     // оно может сильно отличасться. Посмотреть, можно-ли это как-то
     // динамически править
     $delay_str_list = array('ru' => 'Срок доставки зависит от удаленности', 'default' => 'Delivery time depens on distance');
     $languages = Language::getLanguages(false);
     foreach ($languages as $language) {
         //Проверяем есть ли текущий язык в списке предусмотренных языков
         if (!isset($delay_str_list[$language['iso_code']])) {
             //Если нет, то ставим фразу по умолчанию
             $carrier->delay[(int) $language['id_lang']] = $delay_str_list['default'];
         } else {
             //Иначе берем фразу из конфига
             $carrier->delay[(int) $language['id_lang']] = $delay_str_list[$language['iso_code']];
         }
     }
     // Этот перевозчик связан с модулем
     //Расчет производится из внешнего источника
     $carrier->shipping_external = true;
     //Признак того, что способ доставки принадлежит модулю
     $carrier->is_module = true;
     //Имя модуля, которому принадлежит способ доставки
     $carrier->external_module_name = 'russianpostcarrier';
     // Если я правильно понял, то заданные лимиты
     // нам не уперлись, у нас внутре свои лимиты задаются
     // UPD: Но оно в этом случае, похоже, не работает. Придется задавать лимиты
     $carrier->need_range = true;
     // TODO: еще полезные переменные, мы ими потом займемся,
     // надо понять, как оно считает
     // $carrier->max_width => 1;
     // $carrier->max_height => 1;
     // $carrier->max_depth => 1;
     // $carrier->max_weight => 1; // вот это вот особенно!
     if ($carrier->add()) {
         // Добавим нашего несчастного перевозчика всем группам
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         // Без указания пределов по весу и стоимости оно не заработало
         // Сделаем, хотя оно нам не надо
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = '0';
         $rangePrice->delimiter2 = '100500';
         $rangePrice->add();
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = '0';
         $rangeWeight->delimiter2 = '100500';
         //Предельные тяжеловесные посылки 20 кг
         $rangeWeight->add();
         $zones = Zone::getZones(true);
         foreach ($zones as $z) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $z['id_zone']), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
         }
         copy(dirname(__FILE__) . '/carrier.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
         return $carrier->id;
     }
     return false;
 }
예제 #23
0
 /**
  * Overload the property $fields_value
  *
  * @param object $obj
  */
 public function getFieldsValues($obj)
 {
     if ($this->getFieldValue($obj, 'is_module')) {
         $this->fields_value['is_module'] = 1;
     }
     if ($this->getFieldValue($obj, 'shipping_external')) {
         $this->fields_value['shipping_external'] = 1;
     }
     if ($this->getFieldValue($obj, 'need_range')) {
         $this->fields_value['need_range'] = 1;
     }
     // Added values of object Zone
     $carrier_zones = $obj->getZones();
     $carrier_zones_ids = array();
     if (is_array($carrier_zones)) {
         foreach ($carrier_zones as $carrier_zone) {
             $carrier_zones_ids[] = $carrier_zone['id_zone'];
         }
     }
     $zones = Zone::getZones(false);
     foreach ($zones as $zone) {
         $this->fields_value['zone_' . $zone['id_zone']] = Tools::getValue('zone_' . $zone['id_zone'], in_array($zone['id_zone'], $carrier_zones_ids));
     }
     // Added values of object Group
     $carrier_groups = $obj->getGroups();
     $carrier_groups_ids = array();
     if (is_array($carrier_groups)) {
         foreach ($carrier_groups as $carrier_group) {
             $carrier_groups_ids[] = $carrier_group['id_group'];
         }
     }
     $groups = Group::getGroups($this->context->language->id);
     foreach ($groups as $group) {
         $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $carrier_groups_ids) || empty($carrier_groups_ids) && !$obj->id);
     }
     $this->fields_value['id_tax_rules_group'] = $this->object->getIdTaxRulesGroup($this->context);
 }
예제 #24
0
 protected function createCarriers($eta)
 {
     // Sameday(ETA: 18:00)
     foreach ($this->carriers as $key => $value) {
         //Create new carrier
         $carrier = new Carrier();
         $carrier->name = $key;
         $carrier->active = true;
         $carrier->deleted = 0;
         $carrier->shipping_handling = false;
         $carrier->range_behavior = 0;
         $carrier->delay[Configuration::get('PS_LANG_DEFAULT')] = $eta;
         $carrier->shipping_external = true;
         $carrier->is_module = true;
         $carrier->external_module_name = $this->name;
         $carrier->need_range = true;
         $carrier->url = 'https://send24.com/track?@';
         if ($carrier->add()) {
             $groups = Group::getGroups(true);
             foreach ($groups as $group) {
                 Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
             }
             $rangePrice = new RangePrice();
             $rangePrice->id_carrier = $carrier->id;
             $rangePrice->delimiter1 = '0';
             $rangePrice->delimiter2 = '5';
             $rangePrice->add();
             $rangeWeight = new RangeWeight();
             $rangeWeight->id_carrier = $carrier->id;
             $rangeWeight->delimiter1 = '0';
             $rangeWeight->delimiter2 = '5';
             $rangeWeight->add();
             $zones = Zone::getZones(true);
             foreach ($zones as $z) {
                 if ($z['name'] == 'Europe') {
                     Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $z['id_zone']), 'INSERT');
                     Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
                     Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
                 }
             }
             copy(dirname(__FILE__) . '/views/img/send24.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
             Configuration::updateValue(self::PREFIX . $value, $carrier->id);
             Configuration::updateValue(self::PREFIX . $value . '_reference', $carrier->id);
         }
     }
     return true;
 }
예제 #25
0
    public function displayForm($isMainTab = true)
    {
        global $currentIndex;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
        $customer_groups = Tools::getValue('groupBox', $obj->getGroups());
        $groups = Group::getGroups($this->_defaultFormLanguage, true);
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" autocomplete="off">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/tab-customers.gif" />' . $this->l('Customer') . '</legend>
				<label>' . $this->l('Gender:') . ' </label>
				<div class="margin-form">
					<input type="radio" size="33" name="id_gender" id="gender_1" value="1" ' . ($this->getFieldValue($obj, 'id_gender') == 1 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_1"> ' . $this->l('Male') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_2" value="2" ' . ($this->getFieldValue($obj, 'id_gender') == 2 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_2"> ' . $this->l('Female') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_3" value="9" ' . (($this->getFieldValue($obj, 'id_gender') == 9 or !$this->getFieldValue($obj, 'id_gender')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_3"> ' . $this->l('Unknown') . '</label>
				</div>
				<label>' . $this->l('Last name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), 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>
				<label>' . $this->l('First name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
				</div>
				<label>' . $this->l('Password:'******' </label>
				<div class="margin-form">
					<input type="password" size="33" name="passwd" value="" /> ' . (!$obj->id ? '<sup>*</sup>' : '') . '
					<p>' . ($obj->id ? $this->l('Leave blank if no change') : $this->l('5 characters min., only letters, numbers, or') . ' -_') . '</p>
				</div>
				<label>' . $this->l('E-mail address:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="email" value="' . htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('Birthday:') . ' </label>';
        $sl_year = $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0;
        $years = Tools::dateYears();
        $sl_month = $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0;
        $months = Tools::dateMonths();
        $sl_day = $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0;
        $days = Tools::dateDays();
        $tab_months = array($this->l('January'), $this->l('February'), $this->l('March'), $this->l('April'), $this->l('May'), $this->l('June'), $this->l('July'), $this->l('August'), $this->l('September'), $this->l('October'), $this->l('November'), $this->l('December'));
        echo '
					<div class="margin-form">
					<select name="days">
						<option value="">-</option>';
        foreach ($days as $v) {
            echo '<option value="' . $v . '" ' . ($sl_day == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '
					</select>
					<select name="months">
						<option value="">-</option>';
        foreach ($months as $k => $v) {
            echo '<option value="' . $k . '" ' . ($sl_month == $k ? 'selected="selected"' : '') . '>' . $this->l($v) . '</option>';
        }
        echo '</select>
					<select name="years">
						<option value="">-</option>';
        foreach ($years as $v) {
            echo '<option value="' . $v . '" ' . ($sl_year == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '</select>
				</div>';
        echo '<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this customer to log in') . '</p>
				</div>
				<label>' . $this->l('Newsletter:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="newsletter" id="newsletter_on" value="1" ' . ($this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="newsletter" id="newsletter_off" value="0" ' . (!$this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your newsletter via e-mail') . '</p>
				</div>
				<label>' . $this->l('Opt-in:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="optin" id="optin_on" value="1" ' . ($this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="optin" id="optin_off" value="0" ' . (!$this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your ads via e-mail') . '</p>
				</div>
				<label>' . $this->l('Default group:') . ' </label>
				<div class="margin-form">
					<select name="id_default_group" onchange="checkDefaultGroup(this.value);">';
        foreach ($groups as $group) {
            echo '<option value="' . (int) $group['id_group'] . '"' . ($group['id_group'] == $obj->id_default_group ? ' selected="selected"' : '') . '>' . htmlentities($group['name'], ENT_NOQUOTES, 'utf-8') . '</option>';
        }
        echo '
					</select>
					<p>' . $this->l('Apply non-cumulative rules (e.g., price, display method, reduction)') . '</p>
				</div>
				<label>' . $this->l('Groups:') . ' </label>
				<div class="margin-form">';
        if (sizeof($groups)) {
            echo '
					<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)" /></th>
							<th>' . $this->l('ID') . '</th>
							<th>' . $this->l('Group name') . '</th>
						</tr>';
            $irow = 0;
            foreach ($groups as $group) {
                echo '
							<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
								<td>' . '<input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $group['id_group'] . '" value="' . $group['id_group'] . '" ' . (in_array($group['id_group'], $customer_groups) ? 'checked="checked" ' : '') . '/></td>
								<td>' . $group['id_group'] . '</td>
								<td><label for="groupBox_' . $group['id_group'] . '" class="t">' . $group['name'] . '</label></td>
							</tr>';
            }
            echo '
					</table>
					<p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Check all the box(es) of groups of which the customer is to be a member') . '<sup> *</sup></p>
					';
        } else {
            echo '<p>' . $this->l('No group created') . '</p>';
        }
        echo '
				</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>';
    }
예제 #26
0
 public function initFormPrices($obj)
 {
     $data = $this->createTemplate($this->tpl_form);
     $product = $obj;
     if ($obj->id) {
         $shops = Shop::getShops();
         $countries = Country::getCountries($this->context->language->id);
         $groups = Group::getGroups($this->context->language->id);
         $currencies = Currency::getCurrencies();
         $attributes = $obj->getAttributesGroups((int) $this->context->language->id);
         $combinations = array();
         foreach ($attributes as $attribute) {
             $combinations[$attribute['id_product_attribute']]['id_product_attribute'] = $attribute['id_product_attribute'];
             if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) {
                 $combinations[$attribute['id_product_attribute']]['attributes'] = '';
             }
             $combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'] . ' - ';
             $combinations[$attribute['id_product_attribute']]['price'] = Tools::displayPrice(Tools::convertPrice(Product::getPriceStatic((int) $obj->id, false, $attribute['id_product_attribute']), $this->context->currency), $this->context->currency);
         }
         foreach ($combinations as &$combination) {
             $combination['attributes'] = rtrim($combination['attributes'], ' - ');
         }
         $data->assign('specificPriceModificationForm', $this->_displaySpecificPriceModificationForm($this->context->currency, $shops, $currencies, $countries, $groups));
         $data->assign('ecotax_tax_excl', $obj->ecotax);
         $this->_applyTaxToEcotax($obj);
         $data->assign(array('shops' => $shops, 'admin_one_shop' => count($this->context->employee->getAssociatedShops()) == 1, 'currencies' => $currencies, 'countries' => $countries, 'groups' => $groups, 'combinations' => $combinations, 'multi_shop' => Shop::isFeatureActive(), 'link' => new Link()));
     } else {
         $this->displayWarning($this->l('You must save this product before adding specific pricing'));
         $product->id_tax_rules_group = (int) Product::getIdTaxRulesGroupMostUsed();
         $data->assign('ecotax_tax_excl', 0);
     }
     // prices part
     $data->assign(array('link' => $this->context->link, 'currency' => $currency = $this->context->currency, 'tax_rules_groups' => TaxRulesGroup::getTaxRulesGroups(true), 'taxesRatesByGroup' => TaxRulesGroup::getAssociatedTaxRatesByIdCountry($this->context->country->id), 'ecotaxTaxRate' => Tax::getProductEcotaxRate(), 'tax_exclude_taxe_option' => Tax::excludeTaxeOption(), 'ps_use_ecotax' => Configuration::get('PS_USE_ECOTAX')));
     $product->price = Tools::convertPrice($product->price, $this->context->currency, true, $this->context);
     if ($product->unit_price_ratio != 0) {
         $data->assign('unit_price', Tools::ps_round($product->price / $product->unit_price_ratio, 2));
     } else {
         $data->assign('unit_price', 0);
     }
     $data->assign('ps_tax', Configuration::get('PS_TAX'));
     $data->assign('country_display_tax_label', $this->context->country->display_tax_label);
     $data->assign(array('currency', $this->context->currency, 'product' => $product, 'token' => $this->token));
     $this->tpl_form_vars['custom_form'] = $data->fetch();
 }
예제 #27
0
 public function renderView()
 {
     $this->toolbar_title = $this->l('Payment: ');
     unset($this->toolbar_btn['back']);
     $shop_context = !Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP;
     if (!$shop_context) {
         $this->tpl_view_vars = array('shop_context' => $shop_context);
         return parent::renderView();
     }
     // link to modules page
     if (isset($this->payment_modules[0])) {
         $token_modules = Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id);
     }
     $display_restrictions = false;
     foreach ($this->payment_modules as $module) {
         if ($module->active) {
             $display_restrictions = true;
             break;
         }
     }
     $lists = array(array('items' => Currency::getCurrencies(), 'title' => $this->l('Currency restrictions'), 'desc' => $this->l('Please mark each checkbox for the currency, or currencies, in which you want the payment module(s) to be available.'), 'name_id' => 'currency', 'identifier' => 'id_currency', 'icon' => 'icon-money'), array('items' => Group::getGroups($this->context->language->id), 'title' => $this->l('Group restrictions'), 'desc' => $this->l('Please mark each checkbox for the customer group(s), in which you want the payment module(s) to be available.'), 'name_id' => 'group', 'identifier' => 'id_group', 'icon' => 'icon-group'), array('items' => Country::getCountries($this->context->language->id), 'title' => $this->l('Country restrictions'), 'desc' => $this->l('Please mark each checkbox for the country, or countries, in which you want the payment module(s) to be available.'), 'name_id' => 'country', 'identifier' => 'id_country', 'icon' => 'icon-globe'));
     foreach ($lists as $key_list => $list) {
         $list['check_list'] = array();
         foreach ($list['items'] as $key_item => $item) {
             $name_id = $list['name_id'];
             foreach ($this->payment_modules as $key_module => $module) {
                 if (isset($module->{$name_id}) && in_array($item['id_' . $name_id], $module->{$name_id})) {
                     $list['items'][$key_item]['check_list'][$key_module] = 'checked';
                 } else {
                     $list['items'][$key_item]['check_list'][$key_module] = 'unchecked';
                 }
                 if (!isset($module->{$name_id})) {
                     $module->{$name_id} = array();
                 }
                 if (!isset($module->currencies_mode)) {
                     $module->currencies_mode = '';
                 }
                 if (!isset($module->currencies)) {
                     $module->currencies = '';
                 }
                 // If is a country list and the country is limited, remove it from list
                 if ($name_id == 'country' && isset($module->limited_countries) && !empty($module->limited_countries) && is_array($module->limited_countries) && !in_array(strtoupper($item['iso_code']), array_map('strtoupper', $module->limited_countries))) {
                     $list['items'][$key_item]['check_list'][$key_module] = null;
                 }
             }
         }
         // update list
         $lists[$key_list] = $list;
     }
     $this->tpl_view_vars = array('modules_list' => $this->renderModulesList(), 'display_restrictions' => $display_restrictions, 'lists' => $lists, 'ps_base_uri' => __PS_BASE_URI__, 'payment_modules' => $this->payment_modules, 'url_submit' => self::$currentIndex . '&token=' . $this->token, 'shop_context' => $shop_context);
     return parent::renderView();
 }
예제 #28
0
    public function displayForm()
    {
        global $currentIndex;
        $obj = $this->loadObject(true);
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
        $customer_groups = $obj->getGroups();
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" class="width3" autocomplete="off">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/tab-customers.gif" />' . $this->l('Customer') . '</legend>
				<label>' . $this->l('Gender:') . ' </label>
				<div class="margin-form">
					<input type="radio" size="33" name="id_gender" id="gender_1" value="1" ' . ($this->getFieldValue($obj, 'id_gender') == 1 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_1"> ' . $this->l('Male') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_2" value="2" ' . ($this->getFieldValue($obj, 'id_gender') == 2 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_2"> ' . $this->l('Female') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_3" value="9" ' . (($this->getFieldValue($obj, 'id_gender') == 9 or !$this->getFieldValue($obj, 'id_gender')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_3"> ' . $this->l('Unknown') . '</label>
				</div>
				<label>' . $this->l('Last name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
				</div>
				<label>' . $this->l('First name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '"/> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
				</div>
				<label>' . $this->l('Password:'******' </label>
				<div class="margin-form">
					<input type="password" size="33" name="passwd" value="" /> ' . (!$obj->id ? '<sup>*</sup>' : '') . '
					<p>' . ($obj->id ? $this->l('Leave blank if no change') : $this->l('5 characters min., only letters, numbers, or') . ' -_') . '</p>
				</div>
				<label>' . $this->l('E-mail address:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="email" value="' . htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				';
        if ($obj->isVendor()) {
            $classifications = $this->getFieldValue($obj, 'classifications');
            $classifications = array_flip(explode(",", $classifications));
            echo '
					<label>Faks</label>
					<div class="margin-form">
						<input type="text" size="10" name="fax" value="' . htmlentities($this->getFieldValue($obj, 'fax'), ENT_COMPAT, 'UTF-8') . '" />
					</div>
					
					<label>Åpningstider</label>
					<div class="margin-form">
						<textarea name="hours" cols="31" rows="3">' . htmlentities($this->getFieldValue($obj, 'hours'), ENT_COMPAT, 'UTF-8') . '</textarea>
					</div>
					
					<label>Klassifikasjoner</label>
					<div class="margin-form">
						<input type="checkbox" name="classifications[broderi]" value="1"' . (isset($classifications['broderi']) ? ' checked' : '') . '/> Ekspert på broderisymaskiner og programvare<br/>
						<input type="checkbox" name="classifications[service]" value="1"' . (isset($classifications['service']) ? ' checked' : '') . '/> Eget serviceverksted<br/>
						<input type="checkbox" name="classifications[kurs]"    value="1"' . (isset($classifications['kurs']) ? ' checked' : '') . '/> Driver kursvirksomhet
					</div>
					
					<label>Blogg</label>
					<div class="margin-form">
						<input type="text" size="33" name="blog_url" value="' . htmlentities($this->getFieldValue($obj, 'blog_url'), ENT_COMPAT, 'UTF-8') . '" />
					</div>
					';
        }
        echo '
				<label>' . $this->l('Birthday:') . ' </label>';
        $sl_year = $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0;
        $years = Tools::dateYears();
        $sl_month = $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0;
        $months = Tools::dateMonths();
        $sl_day = $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0;
        $days = Tools::dateDays();
        $tab_months = array($this->l('January'), $this->l('February'), $this->l('March'), $this->l('April'), $this->l('May'), $this->l('June'), $this->l('July'), $this->l('August'), $this->l('September'), $this->l('October'), $this->l('November'), $this->l('December'));
        echo '
					<div class="margin-form">
					<select name="days">
						<option value="">-</option>';
        foreach ($days as $v) {
            echo '<option value="' . $v . '" ' . ($sl_day == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '
					</select>
					<select name="months">
						<option value="">-</option>';
        foreach ($months as $k => $v) {
            echo '<option value="' . $k . '" ' . ($sl_month == $k ? 'selected="selected"' : '') . '>' . $this->l($v) . '</option>';
        }
        echo '</select>
					<select name="years">
						<option value="">-</option>';
        foreach ($years as $v) {
            echo '<option value="' . $v . '" ' . ($sl_year == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '</select>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this customer to log in') . '</p>
				</div>
				<label>' . $this->l('Newsletter:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="newsletter" id="newsletter_on" value="1" ' . ($this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="newsletter" id="newsletter_off" value="0" ' . (!$this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your newsletter via e-mail') . '</p>
				</div>
				<label>' . $this->l('Opt-in:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="optin" id="optin_on" value="1" ' . ($this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="optin" id="optin_off" value="0" ' . (!$this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your ads via e-mail') . '</p>
				</div>
				<label>' . $this->l('Groups:') . ' </label>
				<div class="margin-form">';
        $groups = Group::getGroups($defaultLanguage, true);
        if (sizeof($groups)) {
            echo '
					<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)" /></th>
							<th>' . $this->l('ID') . '</th>
							<th>' . $this->l('Group name') . '</th>
						</tr>';
            $irow = 0;
            foreach ($groups as $group) {
                echo '
							<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
								<td>' . ($group['id_group'] != 1 ? '<input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $group['id_group'] . '" value="' . $group['id_group'] . '" ' . (in_array($group['id_group'], $customer_groups) ? 'checked="checked" ' : '') . '/>' : '') . '</td>
								<td>' . $group['id_group'] . '</td>
								<td><label for="groupBox_' . $group['id_group'] . '" class="t">' . $group['name'] . '</label></td>
							</tr>';
            }
            echo '
					</table>
					<p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of groups to which the customer is to be member') . '<sup> *</sup></p>
					';
        } else {
            echo '<p>' . $this->l('No group created') . '</p>';
        }
        echo '
				</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>';
    }
 public function renderForm()
 {
     /** @var Customer $obj */
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $genders = Gender::getGenders();
     $list_genders = array();
     foreach ($genders as $key => $gender) {
         /** @var Gender $gender */
         $list_genders[$key]['id'] = 'gender_' . $gender->id;
         $list_genders[$key]['value'] = $gender->id;
         $list_genders[$key]['label'] = $gender->name;
     }
     $years = Tools::dateYears();
     $months = Tools::dateMonths();
     $days = Tools::dateDays();
     $groups = Group::getGroups($this->default_form_language, true);
     $this->fields_form = array('legend' => array('title' => $this->l('Customer'), 'icon' => 'icon-user'), 'input' => array(array('type' => 'radio', 'label' => $this->l('Social title'), 'name' => 'id_gender', 'required' => false, 'class' => 't', 'values' => $list_genders), array('type' => 'text', 'label' => $this->l('First name'), 'name' => 'firstname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"°{}_$%:'), array('type' => 'text', 'label' => $this->l('Last name'), 'name' => 'lastname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"°{}_$%:'), array('type' => 'text', 'prefix' => '<i class="icon-envelope-o"></i>', 'label' => $this->l('Email address'), 'name' => 'email', 'col' => '4', 'required' => true, 'autocomplete' => false), array('type' => 'password', 'label' => $this->l('Password'), 'name' => 'passwd', 'required' => $obj->id ? false : true, 'col' => '4', 'hint' => $obj->id ? $this->l('Leave this field blank if there\'s no change.') : sprintf($this->l('Password should be at least %s characters long.'), Validate::PASSWORD_LENGTH)), array('type' => 'birthday', 'label' => $this->l('Birthday'), 'name' => 'birthday', 'options' => array('days' => $days, 'months' => $months, 'years' => $years)), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Enable or disable customer login.')), array('type' => 'switch', 'label' => $this->l('Newsletter'), 'name' => 'newsletter', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'newsletter_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'newsletter_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_NWSL')), 'hint' => $this->l('This customer will receive your newsletter via email.')), array('type' => 'switch', 'label' => $this->l('Opt-in'), 'name' => 'optin', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'optin_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'optin_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_OPTIN')), 'hint' => $this->l('This customer will receive your ads via email.'))));
     // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups
     if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) {
         $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
         $guest_group = Configuration::get('PS_GUEST_GROUP');
         foreach ($groups as $key => $g) {
             if (in_array($g['id_group'], array($visitor_group, $guest_group))) {
                 unset($groups[$key]);
             }
         }
     }
     $this->fields_form['input'] = array_merge($this->fields_form['input'], array(array('type' => 'group', 'label' => $this->l('Group access'), 'name' => 'groupBox', 'values' => $groups, 'required' => true, 'col' => '6', 'hint' => $this->l('Select all the groups that you would like to apply to this customer.')), array('type' => 'select', 'label' => $this->l('Default customer group'), 'name' => 'id_default_group', 'options' => array('query' => $groups, 'id' => 'id_group', 'name' => 'name'), 'col' => '4', 'hint' => array($this->l('This group will be the user\'s default group.'), $this->l('Only the discount for the selected group will be applied to this customer.')))));
     // if customer is a guest customer, password hasn't to be there
     if ($obj->id && ($obj->is_guest && $obj->id_default_group == Configuration::get('PS_GUEST_GROUP'))) {
         foreach ($this->fields_form['input'] as $k => $field) {
             if ($field['type'] == 'password') {
                 array_splice($this->fields_form['input'], $k, 1);
             }
         }
     }
     if (Configuration::get('PS_B2B_ENABLE')) {
         $risks = Risk::getRisks();
         $list_risks = array();
         foreach ($risks as $key => $risk) {
             /** @var Risk $risk */
             $list_risks[$key]['id_risk'] = (int) $risk->id;
             $list_risks[$key]['name'] = $risk->name;
         }
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('SIRET'), 'name' => 'siret');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('APE'), 'name' => 'ape');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Website'), 'name' => 'website');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Allowed outstanding amount'), 'name' => 'outstanding_allow_amount', 'hint' => $this->l('Valid characters:') . ' 0-9', 'suffix' => $this->context->currency->sign);
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Maximum number of payment days'), 'name' => 'max_payment_days', 'hint' => $this->l('Valid characters:') . ' 0-9');
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Risk rating'), 'name' => 'id_risk', 'required' => false, 'class' => 't', 'options' => array('query' => $list_risks, 'id' => 'id_risk', 'name' => 'name'));
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     $birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
     $this->fields_value = array('years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0, 'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0, 'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0);
     // Added values of object Group
     if (!Validate::isUnsignedId($obj->id)) {
         $customer_groups = array();
     } else {
         $customer_groups = $obj->getGroups();
     }
     $customer_groups_ids = array();
     if (is_array($customer_groups)) {
         foreach ($customer_groups as $customer_group) {
             $customer_groups_ids[] = $customer_group;
         }
     }
     // if empty $carrier_groups_ids : object creation : we set the default groups
     if (empty($customer_groups_ids)) {
         $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
         $customer_groups_ids = array_merge($customer_groups_ids, $preselected);
     }
     foreach ($groups as $group) {
         $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $customer_groups_ids));
     }
     return parent::renderForm();
 }
예제 #30
0
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $currentLanguage = (int) $cookie->id_lang;
        echo '<script type="text/javascript">
			$(document).ready(function(){
				// At the loading
				($("input[name=\'is_free\']:checked").val() == 0) ? $("#shipping_costs_div").show(): $("#shipping_costs_div").hide();
			
				$("input[name=\'is_free\']").live("change", function(){
					($("input[name=\'is_free\']:checked").val() == 0) ? $("#shipping_costs_div").show(): $("#shipping_costs_div").hide();			
				});
			});
		</script>
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/delivery.gif" />' . $this->l('Carriers') . '</legend>
				<label>' . $this->l('Company:') . ' </label>
				<div class="margin-form">
					<input type="text" size="25" name="name" value="' . htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Allowed characters: letters, spaces and') . ' ().-<span class="hint-pointer">&nbsp;</span></span>
					<p class="clear">' . $this->l('Carrier name displayed during checkout') . '<br />' . $this->l('With a value of 0, the carrier name will be replaced by the shop name') . '</p>
				</div>
				<label>' . $this->l('Logo:') . ' </label>
				<div class="margin-form">
					<input type="file" name="logo" />
					<p>' . $this->l('Upload logo from your computer') . ' (.gif, .jpg, .jpeg ' . $this->l('or') . ' .png)</p>
				</div>
				<label>' . $this->l('Transit time:') . ' </label>
				<div class="margin-form">';
        foreach ($this->_languages as $language) {
            echo '
					<div id="delay_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" size="41" maxlength="128" name="delay_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'delay', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					</div>';
        }
        $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'delay', 'delay');
        echo '
					<p style="clear: both">' . $this->l('Time taken for product delivery; displayed during checkout') . '</p>
				</div>
				<label>' . $this->l('URL:') . ' </label>
				<div class="margin-form">
					<input type="text" size="40" name="url" value="' . htmlentities($this->getFieldValue($obj, 'url'), ENT_COMPAT, 'UTF-8') . '" />
					<p class="clear">' . $this->l('URL for the tracking number; type \'@\' where the tracking number will appear') . '</p>
				</div>
				<label>' . $this->l('Zone') . '</label>
				<div class="margin-form">';
        $carrier_zones = $obj->getZones();
        $carrier_zones_ids = array();
        if (is_array($carrier_zones)) {
            foreach ($carrier_zones as $carrier_zone) {
                $carrier_zones_ids[] = $carrier_zone['id_zone'];
            }
        }
        $zones = Zone::getZones(false);
        foreach ($zones as $zone) {
            echo '<input type="checkbox" id="zone_' . $zone['id_zone'] . '" name="zone_' . $zone['id_zone'] . '" value="true" ' . Tools::getValue('zone_' . $zone['id_zone'], in_array($zone['id_zone'], $carrier_zones_ids) ? ' checked="checked"' : '') . '>
							<label class="t" for="zone_' . $zone['id_zone'] . '"> <b>' . $zone['name'] . '</b></label><br />';
        }
        echo '<p>' . $this->l('The zone in which this carrier is to be used') . '</p>
				</div>
				<label>' . $this->l('Group access') . '</label>
				<div class="margin-form">';
        $groups = Group::getGroups((int) $cookie->id_lang);
        if (sizeof($groups)) {
            echo '
					<table cellspacing="0" cellpadding="0" class="table" style="width: 28em;">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)"' . (!isset($obj->id) ? 'checked="checked" ' : '') . ' /></th>
							<th>' . $this->l('ID') . '</th>
							<th>' . $this->l('Group name') . '</th>
						</tr>';
            $irow = 0;
            foreach ($groups as $group) {
                echo '
							<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
								<td><input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $group['id_group'] . '" value="' . $group['id_group'] . '" ' . ((Db::getInstance()->getValue('SELECT id_group FROM ' . _DB_PREFIX_ . 'carrier_group WHERE id_carrier=' . (int) $obj->id . ' AND id_group=' . (int) $group['id_group']) or !isset($obj->id)) ? 'checked="checked" ' : '') . '/></td>
								<td>' . $group['id_group'] . '</td>
								<td><label for="groupBox_' . $group['id_group'] . '" class="t">' . $group['name'] . '</label></td>
							</tr>';
            }
            echo '
					</table>
					<p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Mark all groups you want to give access to this carrier') . '</p>
					';
        } else {
            echo '<p>' . $this->l('No group created') . '</p>';
        }
        echo '				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Include or exclude carrier from list of carriers on Front Office') . '</p>
				</div>
				<label>' . $this->l('Apply shipping cost:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="is_free" id="is_free_on" value="0" ' . (!$this->getFieldValue($obj, 'is_free') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /></label>
					<input type="radio" name="is_free" id="is_free_off" value="1" ' . ($this->getFieldValue($obj, 'is_free') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" /></label>
					<p>' . $this->l('Apply shipping costs and additional shipping costs by products in carrier price') . '</p>
				</div>
				<div id="shipping_costs_div">
				<label>' . $this->l('Tax') . '</label>
				<div class="margin-form">
					 <select name="id_tax_rules_group" id="id_tax_rules_group" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '>
					    <option value="0">' . $this->l('No Tax') . '</option>';
        foreach (TaxRulesGroup::getTaxRulesGroups(true) 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"' : '') . '>' . $tax_rules_group['name'] . '</option>';
        }
        echo '</select>
				</div>
				<label>' . $this->l('Shipping & handling:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="shipping_handling" id="shipping_handling_on" value="1" ' . ($this->getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="shipping_handling_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="shipping_handling" id="shipping_handling_off" value="0" ' . (!$this->getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="shipping_handling_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Include the shipping & handling costs in carrier price') . '</p>
				</div>
				<label>' . $this->l('Billing:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="shipping_method" id="billing_default" value="' . Carrier::SHIPPING_METHOD_DEFAULT . '" ' . ($this->getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_DEFAULT ? 'checked="checked" ' : '') . '/>
					<label class="t" for="billing_default">' . $this->l('Default behavior') . '</label><br />
					<input type="radio" name="shipping_method" id="billing_price" value="' . Carrier::SHIPPING_METHOD_PRICE . '" ' . ($this->getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_PRICE ? 'checked="checked" ' : '') . '/>
					<label class="t" for="billing_price">' . $this->l('According to total price') . '</label><br />
					<input type="radio" name="shipping_method" id="billing_weight" value="' . Carrier::SHIPPING_METHOD_WEIGHT . '" ' . ($this->getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_WEIGHT ? 'checked="checked" ' : '') . '/>
					<label class="t" for="billing_weight">' . $this->l('According to total weight') . '</label><br />
				</div>
				<label>' . $this->l('Out-of-range behavior:') . ' </label>
				<div class="margin-form">
					<select name="range_behavior">
						<option value="0"' . (!$this->getFieldValue($obj, 'range_behavior') ? ' selected="selected"' : '') . '>' . $this->l('Apply the cost of the highest defined range') . '</option>
						<option value="1"' . ($this->getFieldValue($obj, 'range_behavior') ? ' selected="selected"' : '') . '>' . $this->l('Disable carrier') . '</option>
					</select>
					<p>' . $this->l('Out-of-range behavior when none is defined (e.g., when a customer\'s cart weight is greater than the highest range limit)') . '</p>
				</div>';
        if ($this->getFieldValue($obj, 'is_module')) {
            echo '<label>' . $this->l('Module:') . ' </label>
						  <div class="margin-form"><p> - ' . $this->l('This carrier is bound to this module ') . ' => ' . $this->getFieldValue($obj, 'external_module_name') . '</p>
						  <input type="hidden" name="is_module" value="1">
						  <input type="hidden" name="external_module_name" value="' . $this->getFieldValue($obj, 'external_module_name') . '">';
            if ($this->getFieldValue($obj, 'shipping_external')) {
                echo '<p> - ' . $this->l('The shipping costs are calculated outside of your shop') . '</p>
						<input type="hidden" name="shipping_external" value="1">';
            }
            if ($this->getFieldValue($obj, 'need_range')) {
                echo '<p> - ' . $this->l('This carrier uses PrestaShop range to calculate shipping costs') . '</p>
						<input type="hidden" name="need_range" value="1">';
            }
            echo '</div>';
        }
        echo '</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>';
    }