本文整理汇总了PHP中Country::getCountries方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::getCountries方法的具体用法?PHP Country::getCountries怎么用?PHP Country::getCountries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::getCountries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderForm
public function renderForm()
{
//tinymce setup
$this->context->smarty->assign('path_css', _THEME_CSS_DIR_);
$this->context->smarty->assign('ad', __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_));
$this->context->smarty->assign('autoload_rte', true);
$this->context->smarty->assign('lang', true);
$this->context->smarty->assign('iso', $this->context->language->iso_code);
$obj_countries = new Country();
$countries_var = Country::getCountries($this->context->language->id);
if ($this->display == 'add') {
$this->context->smarty->assign('country_var', $countries_var);
} elseif ($this->display == 'edit') {
$this->context->smarty->assign('edit', 1);
$hotel_id = Tools::getValue('id');
$hotel_branch_info_obj = new HotelBranchInformation();
$hotel_branch_info = $hotel_branch_info_obj->hotelBranchInfoById($hotel_id);
$country_id = $hotel_branch_info['country_id'];
$statesbycountry = State::getStatesByIdCountry($country_id);
if ($statesbycountry) {
$states = array();
foreach ($statesbycountry as $key => $value) {
$states[$key]['id'] = $value['id_state'];
$states[$key]['name'] = $value['name'];
}
}
$this->context->smarty->assign('country_var', $countries_var);
$this->context->smarty->assign('state_var', $states);
$this->context->smarty->assign('hotel_info', $hotel_branch_info);
}
$this->fields_form = array('submit' => array('title' => $this->l('Save')));
return parent::renderForm();
}
示例2: 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();
}
示例3: renderForm
public function renderForm()
{
$this->fields_form = array('legend' => array('title' => $this->l('Addresses'), 'icon' => 'icon-envelope-alt'), 'input' => array(array('type' => 'text_customer', 'label' => $this->l('Customer'), 'name' => 'id_customer', 'required' => false), array('type' => 'text', 'label' => $this->l('Identification Number'), 'name' => 'dni', 'required' => false, 'col' => '4', 'hint' => $this->l('DNI / NIF / NIE')), array('type' => 'text', 'label' => $this->l('Floor'), 'name' => 'floor', 'required' => true, 'col' => '4', 'hint' => $this->l('Floor')), array('type' => 'text', 'label' => $this->l('Lift'), 'name' => 'lift', 'required' => true, 'col' => '4', 'hint' => $this->l('Lift')), array('type' => 'text', 'label' => $this->l('Code_intercom'), 'name' => 'code_intercom', 'required' => false, 'col' => '4', 'hint' => $this->l('Code_intercom')), array('type' => 'text', 'label' => $this->l('Address alias'), 'name' => 'alias', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'textarea', 'label' => $this->l('Other'), 'name' => 'other', 'required' => false, 'cols' => 15, 'rows' => 3, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}')), 'submit' => array('title' => $this->l('Save')));
$id_customer = (int) Tools::getValue('id_customer');
if (!$id_customer && Validate::isLoadedObject($this->object)) {
$id_customer = $this->object->id_customer;
}
if ($id_customer) {
$customer = new Customer((int) $id_customer);
$token_customer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id);
}
$this->tpl_form_vars = array('customer' => isset($customer) ? $customer : null, 'tokenCustomer' => isset($token_customer) ? $token_customer : null);
// Order address fields depending on country format
$addresses_fields = $this->processAddressFormat();
// we use delivery address
$addresses_fields = $addresses_fields['dlv_all_fields'];
// get required field
$required_fields = AddressFormat::getFieldsRequired();
// Merge with field required
$addresses_fields = array_unique(array_merge($addresses_fields, $required_fields));
$temp_fields = array();
foreach ($addresses_fields as $addr_field_item) {
if ($addr_field_item == 'company') {
$temp_fields[] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company', 'required' => in_array('company', $required_fields), 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}');
$temp_fields[] = array('type' => 'text', 'label' => $this->l('VAT number'), 'col' => '2', 'name' => 'vat_number', 'required' => in_array('vat_number', $required_fields));
} elseif ($addr_field_item == 'lastname') {
if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) {
$default_value = $customer->lastname;
} else {
$default_value = '';
}
$temp_fields[] = array('type' => 'text', 'label' => $this->l('Last Name'), 'name' => 'lastname', 'required' => in_array('lastname', $required_fields), 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"�{}_$%:', 'default_value' => $default_value);
} elseif ($addr_field_item == 'firstname') {
if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) {
$default_value = $customer->firstname;
} else {
$default_value = '';
}
$temp_fields[] = array('type' => 'text', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => in_array('firstname', $required_fields), 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"�{}_$%:', 'default_value' => $default_value);
} elseif ($addr_field_item == 'address1') {
$temp_fields[] = array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'col' => '6', 'required' => in_array('address1', $required_fields));
} elseif ($addr_field_item == 'address2') {
$temp_fields[] = array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'col' => '6', 'required' => in_array('address2', $required_fields));
} elseif ($addr_field_item == 'postcode') {
$temp_fields[] = array('type' => 'text', 'label' => $this->l('Zip/Postal Code'), 'name' => 'postcode', 'col' => '2', 'required' => in_array('postcode', $required_fields));
} elseif ($addr_field_item == 'city') {
$temp_fields[] = array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'col' => '4', 'required' => in_array('city', $required_fields));
} elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') {
$temp_fields[] = array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => in_array('Country:name', $required_fields) || in_array('country', $required_fields), 'col' => '4', 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name'));
$temp_fields[] = array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => false, 'col' => '4', 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name'));
} elseif ($addr_field_item == 'phone') {
$temp_fields[] = array('type' => 'text', 'label' => $this->l('Home phone'), 'name' => 'phone', 'required' => in_array('phone', $required_fields) || Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'col' => '4', 'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : '');
} elseif ($addr_field_item == 'phone_mobile') {
$temp_fields[] = array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'required' => in_array('phone_mobile', $required_fields) || Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'col' => '4', 'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : '');
}
}
// merge address format with the rest of the form
array_splice($this->fields_form['input'], 3, 0, $temp_fields);
return AdminController::renderForm();
}
示例4: renderOptions
public function renderOptions()
{
// This field is not declared in class constructor because we want it to be manually post processed
$this->fields_options['geolocationCountries']['fields']['countries'] = array('title' => $this->l('Select the countries from which your store is accessible'), 'type' => 'checkbox_table', 'identifier' => 'iso_code', 'list' => Country::getCountries($this->context->language->id), 'auto_value' => false);
$this->tpl_option_vars = array('allowed_countries' => explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')));
return parent::renderOptions();
}
示例5: __construct
public function __construct()
{
global $cookie;
$this->name = 'newsletter';
$this->tab = 'administration';
$this->version = 2.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Newsletter');
$this->description = $this->l('Generates a .CSV file for mass mailings');
if ($this->id) {
$this->_file = 'export_' . Configuration::get('PS_NEWSLETTER_RAND') . '.csv';
$this->_postValid = array();
// Getting data...
$_countries = Country::getCountries((int) $cookie->id_lang);
// ...formatting array
$countries[0] = $this->l('All countries');
foreach ($_countries as $country) {
$countries[$country['id_country']] = $country['name'];
}
// And filling fields to show !
$this->_fieldsExport = array('COUNTRY' => array('title' => $this->l('Customers\' country'), 'desc' => $this->l('Operate a filter on customers\' country.'), 'type' => 'select', 'value' => $countries, 'value_default' => 0), 'SUSCRIBERS' => array('title' => $this->l('Newsletter subscribers'), 'desc' => $this->l('Filter newsletter subscribers.'), 'type' => 'select', 'value' => array(0 => $this->l('All customers'), 2 => $this->l('Subscribers'), 1 => $this->l('Non-subscribers')), 'value_default' => 2), 'OPTIN' => array('title' => $this->l('Opted-in subscribers'), 'desc' => $this->l('Filter opted-in subscribers.'), 'type' => 'select', 'value' => array(0 => $this->l('All customers'), 2 => $this->l('Subscribers'), 1 => $this->l('Non-subscribers')), 'value_default' => 0));
}
}
示例6: renderForm
public function renderForm()
{
// loads current warehouse
if (!($obj = $this->loadObject(true))) {
return;
}
$this->fields_form = array('legend' => array('title' => $this->l('Suppliers'), 'image' => '../img/admin/suppliers.gif'), 'input' => array(array('type' => 'hidden', 'name' => 'id_address'), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'size' => 40, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'cols' => 60, 'rows' => 10, 'lang' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Will appear in the supplier list')), array('type' => 'text', 'label' => $this->l('Phone:'), 'name' => 'phone', 'size' => 15, 'maxlength' => 16, 'desc' => $this->l('Phone number for this supplier')), array('type' => 'text', 'label' => $this->l('Address:'), 'name' => 'address', 'size' => 100, 'maxlength' => 128, 'required' => true), array('type' => 'text', 'label' => $this->l('Address:') . ' (2)', 'name' => 'address2', 'size' => 100, 'maxlength' => 128), array('type' => 'text', 'label' => $this->l('Postal Code/Zip Code:'), 'name' => 'postcode', 'size' => 10, 'maxlength' => 12, 'required' => true), array('type' => 'text', 'label' => $this->l('City:'), 'name' => 'city', 'size' => 20, 'maxlength' => 32, 'required' => true), array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id, false), 'id' => 'id_country', 'name' => 'name'), 'desc' => $this->l('Country where the state, region or city is located')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'options' => array('id' => 'id_state', 'query' => array(), 'name' => 'name')), array('type' => 'file', 'label' => $this->l('Logo:'), 'name' => 'logo', 'display_image' => true, 'desc' => $this->l('Upload a supplier 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 and then press "Enter"')), array('type' => 'radio', 'label' => $this->l('Enable:'), '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'))))), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button'));
// loads current address for this supplier - if possible
$address = null;
if (isset($obj->id)) {
$id_address = Address::getAddressIdBySupplierId($obj->id);
if ($id_address > 0) {
$address = new Address((int) $id_address);
}
}
// force specific fields values (address)
if ($address != null) {
$this->fields_value = array('id_address' => $address->id, 'phone' => $address->phone, 'address' => $address->address1, 'address2' => $address->address2, 'postcode' => $address->postcode, 'city' => $address->city, 'id_country' => $address->id_country, 'id_state' => $address->id_state);
} else {
$this->fields_value = array('id_address' => 0, 'id_country' => Configuration::get('PS_COUNTRY_DEFAULT'));
}
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
}
// set logo image
$image = ImageManager::thumbnail(_PS_SUPP_IMG_DIR_ . '/' . $this->object->id . '.jpg', $this->table . '_' . (int) $this->object->id . '.' . $this->imageType, 350, $this->imageType, true);
$this->fields_value['image'] = $image ? $image : false;
$this->fields_value['size'] = $image ? filesize(_PS_SUPP_IMG_DIR_ . '/' . $this->object->id . '.jpg') / 1000 : false;
return parent::renderForm();
}
示例7: renderForm
public function renderForm()
{
// loads current warehouse
if (!($obj = $this->loadObject(true))) {
return;
}
$image = _PS_SUPP_IMG_DIR_ . $obj->id . '.jpg';
$image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true);
$image_size = file_exists($image) ? filesize($image) / 1000 : false;
$tmp_addr = new Address();
$res = $tmp_addr->getFieldsRequiredDatabase();
$required_fields = array();
foreach ($res as $row) {
$required_fields[(int) $row['id_required_field']] = $row['field_name'];
}
$this->fields_form = array('legend' => array('title' => $this->l('Suppliers'), 'icon' => 'icon-truck'), 'input' => array(array('type' => 'hidden', 'name' => 'id_address'), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => true, 'col' => 4, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), in_array('company', $required_fields) ? array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company', 'display' => in_array('company', $required_fields), 'required' => in_array('company', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Company name for this supplier')) : null, array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'hint' => array($this->l('Invalid characters:') . ' <>;=#{}', $this->l('Will appear in the list of suppliers.')), 'autoload_rte' => 'rte'), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone', 'required' => in_array('phone', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Phone number for this supplier')), array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'required' => in_array('phone_mobile', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Mobile phone number for this supplier.')), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address', 'maxlength' => 128, 'col' => 6, 'required' => true), array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'required' => in_array('address2', $required_fields), 'col' => 6, 'maxlength' => 128), array('type' => 'text', 'label' => $this->l('Zip/postal code'), 'name' => 'postcode', 'required' => in_array('postcode', $required_fields), 'maxlength' => 12, 'col' => 2), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'maxlength' => 32, 'col' => 4, 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'col' => 4, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id, false), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'col' => 4, 'options' => array('id' => 'id_state', 'query' => array(), 'name' => 'name')), array('type' => 'file', 'label' => $this->l('Logo'), 'name' => 'logo', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Upload a supplier logo from your computer.')), array('type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'col' => 6, 'hint' => array($this->l('To add "tags" click in the field, write something and then press "Enter".'), $this->l('Forbidden characters:') . ' <>;=#{}')), array('type' => 'switch', 'label' => $this->l('Enable'), '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'))))), 'submit' => array('title' => $this->l('Save')));
// loads current address for this supplier - if possible
$address = null;
if (isset($obj->id)) {
$id_address = Address::getAddressIdBySupplierId($obj->id);
if ($id_address > 0) {
$address = new Address((int) $id_address);
}
}
// force specific fields values (address)
if ($address != null) {
$this->fields_value = array('id_address' => $address->id, 'phone' => $address->phone, 'phone_mobile' => $address->phone_mobile, 'address' => $address->address1, 'address2' => $address->address2, 'postcode' => $address->postcode, 'city' => $address->city, 'id_country' => $address->id_country, 'id_state' => $address->id_state);
} else {
$this->fields_value = array('id_address' => 0, 'id_country' => Configuration::get('PS_COUNTRY_DEFAULT'));
}
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
}
return parent::renderForm();
}
示例8: __construct
public function __construct()
{
global $cookie;
$this->table = 'manufacturer';
$this->className = 'Manufacturer';
$this->lang = false;
$this->edit = true;
$this->delete = true;
// Sub tab addresses
$countries = Country::getCountries(intval($cookie->id_lang));
foreach ($countries as $country) {
$this->countriesArray[$country['id_country']] = $country['name'];
}
$this->fieldsDisplayAddresses = array('id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'm!manufacturer_name' => array('title' => $this->l('Manufacturer'), 'width' => 100), 'firstname' => array('title' => $this->l('First name'), 'width' => 80), 'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!name'), 'postcode' => array('title' => $this->l('Post/Zip code'), 'align' => 'right', 'width' => 50), 'city' => array('title' => $this->l('City'), 'width' => 150), 'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
$this->_includeTabTitle = array($this->l('Manufacturers addresses'));
$this->_joinAddresses = 'LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON
(cl.`id_country` = a.`id_country` AND cl.`id_lang` = ' . intval($cookie->id_lang) . ') ';
$this->_joinAddresses .= 'LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (a.`id_manufacturer` = m.`id_manufacturer`)';
$this->_selectAddresses = 'cl.`name` as country, m.`name` AS manufacturer_name';
$this->_includeTab = array('Addresses' => array('addressType' => 'manufacturer', 'fieldsDisplay' => $this->fieldsDisplayAddresses, '_join' => $this->_joinAddresses, '_select' => $this->_selectAddresses));
$this->view = true;
$this->_select = 'COUNT(`id_product`) AS `products`, (SELECT COUNT(ad.`id_manufacturer`) as `addresses` FROM `' . _DB_PREFIX_ . 'address` ad WHERE ad.`id_manufacturer` = a.`id_manufacturer` GROUP BY ad.`id_manufacturer`) as `addresses`';
$this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON (a.`id_manufacturer` = p.`id_manufacturer`)';
$this->_joinCount = false;
$this->_group = 'GROUP BY a.`id_manufacturer`';
$this->fieldImageSettings = array('name' => 'logo', 'dir' => 'm');
$this->fieldsDisplay = array('id_manufacturer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 200), 'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 'm', 'orderby' => false, 'search' => false), 'addresses' => array('title' => $this->l('Addresses'), 'align' => 'right', 'tmpTableFilter' => true, 'width' => 20), 'products' => array('title' => $this->l('Products'), 'align' => 'right', 'tmpTableFilter' => true, 'width' => 20));
$countries = Country::getCountries(intval($cookie->id_lang));
foreach ($countries as $country) {
$this->countriesArray[$country['id_country']] = $country['name'];
}
parent::__construct();
}
示例9: 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();
}
示例10: __construct
public function __construct()
{
parent::__construct();
$this->fields_options = array('general' => array('title' => $this->l('Configuration'), 'fields' => array('PS_LANG_DEFAULT' => array('title' => $this->l('Default language:'), 'desc' => $this->l('The default language used in your shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_lang', 'list' => Language::getlanguages(false)), 'PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in your shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries($this->context->language->id)), 'PS_CURRENCY_DEFAULT' => array('title' => $this->l('Default currency:'), 'desc' => $this->l('The default currency used in your shop') . '<div class="warn">' . $this->l('If you change the default currency, you will have to manually edit every product price.') . '</div>', 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_currency', 'list' => Currency::getCurrencies())), 'submit' => array()), 'localization' => array('title' => $this->l('Localization'), 'width' => 'width2', 'icon' => 'localization', 'fields' => array('PS_WEIGHT_UNIT' => array('title' => $this->l('Weight unit:'), 'desc' => $this->l('The default weight unit for your shop (e.g. kg or lbs)'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'), 'PS_DISTANCE_UNIT' => array('title' => $this->l('Distance unit:'), 'desc' => $this->l('The default distance unit for your shop (e.g. km or mi)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text'), 'PS_VOLUME_UNIT' => array('title' => $this->l('Volume unit:'), 'desc' => $this->l('The default volume unit for your shop'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'), 'PS_DIMENSION_UNIT' => array('title' => $this->l('Dimension unit:'), 'desc' => $this->l('The default dimension unit for your shop (e.g. cm or in)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')), 'options' => array('title' => $this->l('Advanced'), 'width' => 'width2', 'icon' => 'localization', 'fields' => array('PS_LOCALE_LANGUAGE' => array('title' => $this->l('Language locale:'), 'desc' => $this->l('Your server\'s language locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL), 'PS_LOCALE_COUNTRY' => array('title' => $this->l('Country locale:'), 'desc' => $this->l('Your server\'s country locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')));
if (function_exists('date_default_timezone_set')) {
$this->fields_options['general']['fields']['PS_TIMEZONE'] = array('title' => $this->l('Time zone:'), 'validation' => 'isAnything', 'type' => 'select', 'list' => Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT name FROM ' . _DB_PREFIX_ . 'timezone'), 'identifier' => 'name', 'visibility' => Shop::CONTEXT_ALL);
}
}
示例11: hookShoppingCart
public function hookShoppingCart($params)
{
global $cookie, $smarty, $currency;
if (!$this->isModuleAvailable()) {
return;
}
$smarty->assign(array('countries' => Country::getCountries((int) $cookie->id_lang), 'id_carrier' => $params['cart']->id_carrier ? $params['cart']->id_carrier : Configuration::get('PS_CARRIER_DEFAULT'), 'id_country' => isset($cookie->id_country) ? $cookie->id_country : Configuration::get('PS_COUNTRY_DEFAULT'), 'id_state' => isset($cookie->id_state) ? $cookie->id_state : 0, 'zipcode' => isset($cookie->postcode) ? $cookie->postcode : '', 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank));
return $this->display(__FILE__, 'carriercompare.tpl');
}
示例12: hookShoppingCart
public function hookShoppingCart($params)
{
global $cookie, $smarty;
if ($cookie->id_customer) {
return;
}
$smarty->assign(array('countries' => Country::getCountries((int) $cookie->id_lang), 'id_carrier' => $params['cart']->id_carrier ? $params['cart']->id_carrier : Configuration::get('PS_CARRIER_DEFAULT'), 'id_country' => isset($cookie->id_country) ? $cookie->id_country : Configuration::get('PS_COUNTRY_DEFAULT'), 'id_state' => isset($cookie->id_state) ? $cookie->id_state : 0, 'zipcode' => isset($cookie->postcode) ? $cookie->postcode : ''));
return $this->display(__FILE__, 'carriercompare.tpl');
}
示例13: __construct
public function __construct()
{
$this->bootstrap = true;
parent::__construct();
$this->fields_options = array('general' => array('title' => $this->trans('Configuration', array(), 'Admin.Global'), 'fields' => array('PS_LANG_DEFAULT' => array('title' => $this->l('Default language'), 'hint' => $this->l('The default language used in your shop.'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_lang', 'list' => Language::getLanguages(false)), 'PS_DETECT_LANG' => array('title' => $this->l('Set language from browser'), 'desc' => $this->l('Set browser language as default language'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '1'), 'PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country'), 'hint' => $this->l('The default country used in your shop.'), 'cast' => 'intval', 'type' => 'select', 'class' => 'chosen', 'identifier' => 'id_country', 'list' => Country::getCountries($this->context->language->id)), 'PS_DETECT_COUNTRY' => array('title' => $this->l('Set default country from browser language'), 'desc' => $this->l('Set country corresponding to browser language'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '1'), 'PS_CURRENCY_DEFAULT' => array('title' => $this->l('Default currency'), 'hint' => $this->l('The default currency used in your shop.') . ' - ' . $this->l('If you change the default currency, you will have to manually edit every product price.'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_currency', 'list' => Currency::getCurrencies(false, true, true))), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))), 'localization' => array('title' => $this->l('Local units'), 'icon' => 'icon-globe', 'fields' => array('PS_WEIGHT_UNIT' => array('title' => $this->l('Weight unit'), 'hint' => $this->l('The default weight unit for your shop (e.g. "kg" for kilograms, "lbs" for pound-mass, etc.).'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text', 'class' => 'fixed-width-sm'), 'PS_DISTANCE_UNIT' => array('title' => $this->l('Distance unit'), 'hint' => $this->l('The default distance unit for your shop (e.g. "km" for kilometer, "mi" for mile, etc.).'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text', 'class' => 'fixed-width-sm'), 'PS_VOLUME_UNIT' => array('title' => $this->l('Volume unit'), 'hint' => $this->l('The default volume unit for your shop (e.g. "L" for liter, "gal" for gallon, etc.).'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text', 'class' => 'fixed-width-sm'), 'PS_DIMENSION_UNIT' => array('title' => $this->l('Dimension unit'), 'hint' => $this->l('The default dimension unit for your shop (e.g. "cm" for centimeter, "in" for inch, etc.).'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text', 'class' => 'fixed-width-sm')), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))), 'options' => array('title' => $this->l('Advanced'), 'fields' => array('PS_LOCALE_LANGUAGE' => array('title' => $this->l('Language identifier'), 'hint' => $this->l('The ISO 639-1 identifier for the language of the country where your web server is located (en, fr, sp, ru, pl, nl, etc.).'), 'validation' => 'isLanguageIsoCode', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL, 'class' => 'fixed-width-sm'), 'PS_LOCALE_COUNTRY' => array('title' => $this->l('Country identifier'), 'hint' => $this->l('The ISO 3166-1 alpha-2 identifier for the country/region where your web server is located, in lowercase (us, gb, fr, sp, ru, pl, nl, etc.).'), 'validation' => 'isLanguageIsoCode', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL, 'class' => 'fixed-width-sm')), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))));
if (function_exists('date_default_timezone_set')) {
$this->fields_options['general']['fields']['PS_TIMEZONE'] = array('title' => $this->l('Time zone'), 'validation' => 'isAnything', 'type' => 'select', 'class' => 'chosen', 'list' => Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT name FROM ' . _DB_PREFIX_ . 'timezone'), 'identifier' => 'name', 'visibility' => Shop::CONTEXT_ALL);
}
}
示例14: renderForm
public function renderForm()
{
/** @var Shop $obj */
if (!($obj = $this->loadObject(true))) {
return;
}
$image = _PS_CITY_IMG_DIR_ . $obj->id . '.jpg';
$image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true);
$image_size = file_exists($image) ? filesize($image) / 1000 : false;
$this->fields_form = array('legend' => array('title' => $this->l('Città'), 'icon' => 'icon-globe'), 'input' => array(array('type' => 'text', 'label' => $this->l('Nome'), 'name' => 'name', 'maxlength' => 255, 'lang' => true, 'required' => true, 'hint' => $this->l('Indica il nome della città.')), array('type' => 'text', 'label' => $this->l('Codice ISTAT'), 'name' => 'iso_code', 'maxlength' => 255, 'required' => true, 'class' => 'uppercase', 'hint' => $this->l('Inserisci il codice alfanumerico ISTAT.')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) Context::getContext()->country->id, 'options' => array('query' => Country::getCountries(Context::getContext()->language->id, false, true), 'id' => 'id_country', 'name' => 'name'), 'hint' => $this->l('Nazione della città.')), array('type' => 'text', 'label' => $this->l('Link rewrite'), 'name' => 'link_rewrite', 'maxlength' => 255, 'lang' => true, 'required' => true, 'havingFilter' => 'url', 'hint' => $this->l('URL della città.')), array('type' => 'file', 'label' => $this->l('Immagine'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Storefront picture.')), array('type' => 'text', 'label' => $this->l('Legend'), 'name' => 'legend', 'maxlength' => 255, 'lang' => true, 'required' => true, 'hint' => $this->l("Didascalia dell'immagine"))), 'submit' => array('title' => $this->l('Save')));
return parent::renderForm();
}
示例15: getContent
public function getContent()
{
if (Tools::isSubmit('btnSubmit')) {
$this->postProcess();
}
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
$id_lang = Configuration::get('PS_LANG_DEFAULT');
$carriers = Carrier::getCarriers($id_lang, false, false, false, null, 0);
$config = Configuration::getMultiple(array('COD_ENABLED', 'COD_SHOW_ZERO', 'COD_TITLE', 'COD_ORDER_STATUS', 'COD_SPECIFIC_COUNTRY', 'COD_COUNTRY', 'COD_MINIMUM_ORDER', 'COD_MAXIMUM_ORDER', 'COD_COST_CALCULATION', 'COD_COST_INLAND', 'COD_COST_FOREIGN', 'COD_FREE_FROM', 'COD_CUSTOM_TEXT', 'COD_DISALLOW_METHODS', 'COD_DISALLOWED_METHODS', 'COD_ORDER_TIME'));
$this->context->smarty->assign(array('module_name' => $this->name, 'displayName' => $this->displayName, 'order_time' => $config['COD_ORDER_TIME'], 'request_uri' => $_SERVER['REQUEST_URI'], 'enabled' => $config['COD_ENABLED'], 'show_zero' => $config['COD_SHOW_ZERO'], 'title' => $config['COD_TITLE'], 'orders_status' => OrderStateCore::getOrderStates((int) $this->context->language->id), 'order_status' => $config['COD_ORDER_STATUS'], 'specific_country' => $config['COD_SPECIFIC_COUNTRY'], 'country' => ($a = unserialize($config['COD_COUNTRY'])) ? $a : array(), 'all_countrys' => Country::getCountries((int) $this->context->language->id, true), 'minimum_order' => $config['COD_MINIMUM_ORDER'], 'maximum_order' => $config['COD_MAXIMUM_ORDER'], 'cost_calculation' => $config['COD_COST_CALCULATION'], 'cost_inland' => $config['COD_COST_INLAND'], 'cost_foreign' => $config['COD_COST_FOREIGN'], 'free_from' => $config['COD_FREE_FROM'], 'custom_text' => $config['COD_CUSTOM_TEXT'], 'disallow_methods' => $config['COD_DISALLOW_METHODS'], 'carriers' => $carriers, 'disallowed_methods' => ($a = unserialize($config['COD_DISALLOWED_METHODS'])) ? $a : array(), 'currency_sign' => $currency->sign));
$this->context->controller->addJS($this->local_path . '/views/js/script.js', 'all');
$output = $this->context->smarty->fetch($this->local_path . '/views/templates/admin/configure.tpl');
return $output;
}