本文整理汇总了PHP中Group::getGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::getGroups方法的具体用法?PHP Group::getGroups怎么用?PHP Group::getGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::getGroups方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderForm
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();
}
示例2: 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();
}
示例3: initRuleForm
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 . '&id_tax_rules_group=' . $obj->id . '&action=create_rule&token=' . $this->token, 'desc' => 'Save tax rule', 'class' => 'process-icon-save');
$helper->submit_action = 'create_rule';
return $helper->generateForm($this->fields_form);
}
示例4: __construct
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'))));
}
}
示例5: xdInstall
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: prepareTwig
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: installCarriers
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;
}
示例8: installExternalCarrier
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: initContent
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: testGetGroups
/**
* @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();
}
}
}
示例11: setAllGroupsOnHomeCategory
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: getContent
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: print_edit
/**
* 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: assignCustomerGroupsForCarrier
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: getCustomerGroups
/**
* @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;
}