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();
 }
 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()
 {
     $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:') . ' &lt;&gt;;=#{}'), array('type' => 'textarea', 'label' => $this->l('Other'), 'name' => 'other', 'required' => false, 'cols' => 15, 'rows' => 3, 'hint' => $this->l('Forbidden characters:') . ' &lt;&gt;;=#{}')), '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:') . ' &lt;&gt;;=#{}');
             $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!&amp;lt;&amp;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!&amp;lt;&amp;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();
 }
 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();
 }
Beispiel #5
0
 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));
     }
 }
 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();
 }
 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:') . ' &lt;&gt;;=#{}'), 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:') . ' &lt;&gt;;=#{}', $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:') . ' &lt;&gt;;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:') . ' &lt;&gt;;=#{}'), 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:') . ' &lt;&gt;;=#{}')), 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();
 }
Beispiel #8
0
    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();
    }
 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 __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);
     }
 }
 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');
 }
 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');
 }
 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);
     }
 }
 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();
 }
 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;
 }
    public function hookAdminStatsModules($params)
    {
        global $cookie;
        $totals = $this->getTotals();
        $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
        if (($id_export = (int) Tools::getValue('export')) == 1) {
            $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 2) {
            $this->csvExport(array('layers' => 0, 'type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 3) {
            $this->csvExport(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country')));
        }
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" style="float: right; margin-left: 10px;">
				<select name="id_country">
					<option value="0"' . (!Tools::getValue('id_order_state') ? ' selected="selected"' : '') . '>' . $this->l('All') . '</option>';
        foreach (Country::getCountries($cookie->id_lang) as $country) {
            $this->_html .= '<option value="' . $country['id_country'] . '"' . ($country['id_country'] == Tools::getValue('id_country') ? ' selected="selected"' : '') . '>' . $country['name'] . '</option>';
        }
        $this->_html .= '</select>
				<input type="submit" name="submitCountry" value="' . $this->l('Filter') . '" class="button" />
			</form>
			<p><center><img src="../img/admin/down.gif" />
				' . $this->l('These graphs represent the evolution of your orders and sales turnover for a given period. This tool allows for quick overview of the viability of your shop. You can also keep watch on the difference between time periods (like the holiday season). Only valid orders are included in these two graphs.') . '
			</center></p>
			<p>' . $this->l('Orders placed:') . ' ' . (int) $totals['orderCount'] . '</p>
			<p>' . $this->l('Products bought:') . ' ' . (int) $totals['products'] . '</p>
			<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country'), 'layers' => 2)) . '</center>
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" alt="" />' . $this->l('CSV Export') . '</a></p>
			<p>' . $this->l('Sales:') . ' ' . Tools::displayPrice($totals['orderSum'], $currency) . '</p>
			<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country'))) . '</center></p>
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=2"><img src="../img/admin/asterisk.gif" alt="" />' . $this->l('CSV Export') . '</a></p>
			<p class="space"><img src="../img/admin/down.gif" />
				' . $this->l('You can see the order state distribution below.') . '
			</p><br />
			' . ($totals['orderCount'] ? ModuleGraph::engine(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country'))) : $this->l('No orders for this period.')) . '</center>
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=3"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>
		</fieldset>
		<br class="clear" />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
			<h2>' . $this->l('Various order statuses') . '</h2>
			<p>
				' . $this->l('In your back-office, you can find the following order statuses : Awaiting check payment, Payment accepted, Preparation in progress, Shipping, Delivered, Cancelled, Refund, Payment error, Out of stock, and Awaiting bank wire payment.') . '<br />
				' . $this->l('Statuses cannot be removed from the back-office, but you have the option to add more.') . '
			</p>
		</fieldset>';
        return $this->_html;
    }
Beispiel #17
0
 public function __construct()
 {
     global $cookie;
     $this->table = 'country';
     $this->className = 'Country';
     $this->lang = true;
     $this->edit = true;
     $this->deleted = false;
     $this->_select = 'z.`name` AS zone';
     $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'zone` z ON (z.`id_zone` = a.`id_zone`)';
     $this->fieldsDisplay = array('id_country' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Country'), 'width' => 130, 'filter_key' => 'b!name'), 'iso_code' => array('title' => $this->l('ISO code'), 'width' => 70, 'align' => 'center'), 'zone' => array('title' => $this->l('Zone'), 'width' => 100, 'filter_key' => 'z!name'), 'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'));
     $this->optionTitle = $this->l('Countries options');
     $this->_fieldsOptions = array('PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries(intval($cookie->id_lang))));
     parent::__construct();
 }
    public function hookAdminStatsModules($params)
    {
        $totals = $this->getTotals();
        $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
        if (($id_export = (int) Tools::getValue('export')) == 1) {
            $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 2) {
            $this->csvExport(array('layers' => 0, 'type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 3) {
            $this->csvExport(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country')));
        }
        $this->_html = '
		<div class="blocStats"><h2 class="icon-' . $this->name . '"><span></span>' . $this->displayName . '</h2>
			<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" style="float: right; margin-left: 10px;">
				<select name="id_country">
					<option value="0"' . (!Tools::getValue('id_order_state') ? ' selected="selected"' : '') . '>' . $this->l('All') . '</option>';
        foreach (Country::getCountries($this->context->language->id) as $country) {
            $this->_html .= '<option value="' . $country['id_country'] . '"' . ($country['id_country'] == Tools::getValue('id_country') ? ' selected="selected"' : '') . '>' . $country['name'] . '</option>';
        }
        $this->_html .= '</select>
				<input type="submit" name="submitCountry" value="' . $this->l('Filter') . '" class="button" />
			</form>
			<p><img src="../img/admin/down.gif" />
				' . $this->l('The following graphs represent the evolution of your e-store\'s orders and sales turnover for a selected period. This tool is one that you should use often as it allows you to quickly monitor your store\'s viability. This feature also allows you to monitor multiple time periods, and only valid orders are graphically represented.') . '
			</p>
			<p>' . $this->l('Orders placed:') . ' <span class="totalStats">' . (int) $totals['orderCount'] . '</span></p>
			<p>' . $this->l('Products bought:') . ' <span class="totalStats">' . (int) $totals['products'] . '</span></p>
			<div>' . $this->engine(array('type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country'), 'layers' => 2)) . '</div>
			<p><a class="button export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1"><span>' . $this->l('CSV Export') . '</span></a></p>
			<h4>' . $this->l('Sales:') . ' ' . Tools::displayPrice($totals['orderSum'], $currency) . '</h4>
			<div>' . $this->engine(array('type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country'))) . '</div>
			<p><a class="button export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=2"><span>' . $this->l('CSV Export') . '</span></a></p>
			<p class="space"><img src="../img/admin/down.gif" />
				' . $this->l('You can view order distribution below.') . '
			</p><br />
			' . ($totals['orderCount'] ? $this->engine(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country'))) : $this->l('No orders for this period.')) . '</center>
			<p><a class="button export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=3"><span>' . $this->l('CSV Export') . '</span></a></p>
		</div >
		<br />
		<div class="blocStats"><h2 class="icon-guide"><span></span>' . $this->l('Guide') . '</h2>
			<h2>' . $this->l('Various order statuses') . '</h2>
			<p>
				' . $this->l('In your Back Office, you can modify the following order statuses: Awaiting Check Payment, Payment Accepted, Preparation in Progress, Shipping, Delivered, Cancelled, Refund, Payment Error, Out of Stock, and Awaiting Bank Wire Payment.') . '<br />
				' . $this->l('These order statuses cannot be removed from the Back Office, however you have the option to add more.') . '
			</p>
		</div >';
        return $this->_html;
    }
 private function _getDefaultFieldsContent()
 {
     global $cookie;
     $countryList = array();
     $countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'));
     foreach (Country::getCountries(intval($cookie->id_lang)) as $country) {
         $countryList[] = array('id' => $country['id_country'], 'name' => $country['name']);
     }
     $stateList = array();
     $stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'));
     foreach (State::getStates(intval($cookie->id_lang)) as $state) {
         $stateList[] = array('id' => $state['id_state'], 'name' => $state['name']);
     }
     $formFields = array('PS_SHOP_NAME' => array('title' => $this->l('Shop name:'), 'desc' => $this->l('Displayed in e-mails and page titles'), 'validation' => 'isGenericName', 'required' => true, 'size' => 30, 'type' => 'text'), 'PS_SHOP_EMAIL' => array('title' => $this->l('Shop e-mail:'), 'desc' => $this->l('Displayed in e-mails sent to customers'), 'validation' => 'isEmail', 'required' => true, 'size' => 30, 'type' => 'text'), 'PS_SHOP_DETAILS' => array('title' => $this->l('Registration:'), 'desc' => $this->l('Shop registration information (e.g., SIRET or RCS)'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'textarea', 'cols' => 30, 'rows' => 5), 'PS_SHOP_ADDR1' => array('title' => $this->l('Shop address line 1:'), 'validation' => 'isAddress', 'size' => 30, 'type' => 'text'), 'PS_SHOP_ADDR2' => array('title' => $this->l('Address line 2'), 'validation' => 'isAddress', 'size' => 30, 'type' => 'text'), 'PS_SHOP_CODE' => array('title' => $this->l('Post/Zip code:'), 'validation' => 'isGenericName', 'size' => 6, 'type' => 'text'), 'PS_SHOP_CITY' => array('title' => $this->l('City:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'), 'PS_SHOP_COUNTRY_ID' => array('title' => $this->l('Country:'), 'validation' => 'isInt', 'size' => 30, 'type' => 'select', 'list' => $countryList, 'identifier' => 'id', 'cast' => 'intval'), 'PS_SHOP_STATE_ID' => array('title' => $this->l('State:'), 'validation' => 'isInt', 'size' => 30, 'type' => 'select', 'list' => $stateList, 'identifier' => 'id', 'cast' => 'intval'), 'PS_SHOP_PHONE' => array('title' => $this->l('Phone:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'), 'PS_SHOP_FAX' => array('title' => $this->l('Fax:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'));
     return $formFields;
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if ($this->customer->birthday) {
         $birthday = explode('-', $this->customer->birthday);
     } else {
         $birthday = array('-', '-', '-');
     }
     /* Generate years, months and days */
     $this->context->smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders()));
     if (Module::isInstalled('blocknewsletter')) {
         $this->context->smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
     }
     // start of implementation of the module code - taxamo
     // Get selected country
     if (Tools::isSubmit('taxamoisocountryresidence') && !is_null(Tools::getValue('taxamoisocountryresidence'))) {
         $selected_country = Tools::getValue('taxamoisocountryresidence');
     } else {
         $selected_country = Taxamoeuvat::getCountryByCustomer($this->customer->id);
     }
     // Generate countries list
     if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
         $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
     } else {
         $countries = Country::getCountries($this->context->language->id, true);
     }
     /* todo use helper */
     $list = '<option value="">-</option>';
     foreach ($countries as $country) {
         $selected = $country['iso_code'] == $selected_country ? 'selected="selected"' : '';
         $list .= '<option value="' . $country['iso_code'] . '" ' . $selected . '>' . htmlentities($country['name'], ENT_COMPAT, 'UTF-8') . '</option>';
     }
     // Get selected cc prefix
     if (Tools::isSubmit('taxamoccprefix') && !is_null(Tools::getValue('taxamoccprefix'))) {
         $taxamo_cc_prefix = Tools::getValue('taxamoccprefix');
     } else {
         $taxamo_cc_prefix = Taxamoeuvat::getPrefixByCustomer($this->customer->id);
     }
     if ($this->customer->id) {
         $this->context->smarty->assign(array('countries_list' => $list, 'taxamoisocountryresidence' => $selected_country, 'taxamoccprefix' => $taxamo_cc_prefix));
     }
     // end of code implementation module - taxamo
     $this->setTemplate(_PS_THEME_DIR_ . 'identity.tpl');
 }
Beispiel #21
0
    public function __construct()
    {
        global $cookie;
        $this->table = 'store';
        $this->className = 'Store';
        $this->lang = false;
        $this->edit = true;
        $this->delete = true;
        $this->fieldImageSettings = array('name' => 'image', 'dir' => 'st');
        $this->_select = 'cl.`name` country, st.`name` state';
        $this->_join = '
		LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = ' . (int) $cookie->id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'state` st ON (st.`id_state` = a.`id_state`)';
        foreach (Country::getCountries((int) $cookie->id_lang, false, false, false) as $country) {
            $this->countriesArray[$country['id_country']] = $country['name'];
        }
        $this->fieldsDisplay = array('id_store' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'country' => array('title' => $this->l('Country'), 'width' => 100, 'filter_key' => 'cl!name'), 'state' => array('title' => $this->l('State'), 'width' => 100, 'filter_key' => 'st!name'), 'city' => array('title' => $this->l('City'), 'width' => 100), 'postcode' => array('title' => $this->l('Zip code'), 'width' => 50), 'name' => array('title' => $this->l('Name'), 'width' => 120, 'filter_key' => 'a!name'), 'phone' => array('title' => $this->l('Phone'), 'width' => 70), 'fax' => array('title' => $this->l('Fax'), 'width' => 70), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
        $this->optionTitle = $this->l('Parameters');
        $this->_fieldsOptions = array('PS_STORES_DISPLAY_FOOTER' => array('title' => $this->l('Display in the footer:'), 'desc' => $this->l('Display a link to the store locator in the footer'), 'cast' => 'intval', 'type' => 'bool'), 'PS_STORES_DISPLAY_SITEMAP' => array('title' => $this->l('Display in the sitemap page:'), 'desc' => $this->l('Display a link to the store locator in the sitemap page'), 'cast' => 'intval', 'type' => 'bool'), 'PS_STORES_SIMPLIFIED' => array('title' => $this->l('Show a simplified store locator:'), 'desc' => $this->l('No map, no search, only a store directory'), 'cast' => 'intval', 'type' => 'bool'), 'PS_STORES_CENTER_LAT' => array('title' => $this->l('Latitude by default:'), 'desc' => $this->l('Used for the default map position'), 'cast' => 'floatval', 'type' => 'float', 'size' => '10'), 'PS_STORES_CENTER_LONG' => array('title' => $this->l('Longitude by default:'), 'desc' => $this->l('Used for the default map position'), 'cast' => 'floatval', 'type' => 'float', 'size' => '10'));
        parent::__construct();
    }
Beispiel #22
0
    public function hookAdminStatsModules($params)
    {
        global $cookie;
        $totals = $this->getTotals();
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" style="float: right; margin-left: 10px;">
				<select name="id_country">
					<option value="0"' . (!Tools::getValue('id_order_state') ? ' selected="selected"' : '') . '>' . $this->l('All') . '</option>';
        foreach (Country::getCountries($cookie->id_lang) as $country) {
            $this->_html .= '<option value="' . $country['id_country'] . '"' . ($country['id_country'] == Tools::getValue('id_country') ? ' selected="selected"' : '') . '>' . $country['name'] . '</option>';
        }
        $this->_html .= '</select>
				<input type="submit" name="submitCountry" value="' . $this->l('Filter') . '" class="button" />
			</form>
			<p><center><img src="../img/admin/down.gif" />
				' . $this->l('These graphs represent the evolution of your orders and sales turnover for a given period. It is not an advanced analysis tools, but at least you can overview the rentability of your shop in a flash. You can also keep a watch on the difference with some periods like Christmas. Only valid orders are included in theses two graphs.') . '
			</center></p>
			<p>' . $this->l('Total orders placed:') . ' ' . intval($totals['allOrderCount']) . '</p>
			<p>' . $this->l('Total orders placed (valid):') . ' ' . intval($totals['orderCount']) . '</p>
			<p>' . $this->l('Total products ordered (valid):') . ' ' . intval($totals['products']) . '</p>
			<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '1-' . intval(Tools::getValue('id_country')), 'layers' => 3)) . '</center>
			<p>' . $this->l('Sales:') . ' ' . Tools::displayPrice($totals['orderSum'], $currency) . '</p>
			<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '2-' . intval(Tools::getValue('id_country')))) . '<br /><br />
			<p class="space"><img src="../img/admin/down.gif" />
				' . $this->l('You can see the order state distribution below.') . '
			</p><br />
			' . ($totals['orderCount'] ? ModuleGraph::engine(array('type' => 'pie', 'option' => '3-' . intval(Tools::getValue('id_country')))) : $this->l('No order for this period')) . '</center>
		</fieldset>
		<br class="clear" />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
			<h2>' . $this->l('Various order status') . '</h2>
			<p>
				' . $this->l('In your back-office, you can find many order status : Awaiting cheque payment, Payment accepted, Preparation in progress, Shipping, Delivered, Canceled, Refund, Payment error, Out of stock, and Awaiting bank wire payment.') . '<br />
				' . $this->l('These status cannot be removed from the back-office, but you have the possibility to add some more.') . '
			</p>
		</fieldset>';
        return $this->_html;
    }
Beispiel #23
0
 public function getCountriesSelect($record = null)
 {
     $objCountry = new Country();
     $countries = $objCountry->getCountries();
     if (!empty($countries)) {
         $out = "<select name=\"country\" id=\"country\" class=\"sel\">";
         if (empty($record)) {
             $out .= "<option value=\"\">Select one&hellip;</option>";
         }
         foreach ($countries as $country) {
             $out .= "<option value=\"";
             $out .= $country['id'];
             $out .= "\"";
             $out .= $this->stickySelect('country', $country['id'], $record);
             $out .= ">";
             $out .= $country['name'];
             $out .= "</option>";
         }
         $out .= "</select>";
         return $out;
     }
 }
Beispiel #24
0
    public function __construct()
    {
        global $cookie;
        $this->table = 'address';
        $this->className = 'Address';
        $this->lang = false;
        $this->edit = true;
        $this->delete = true;
        $this->addressType = 'customer';
        if (!Tools::getValue('realedit')) {
            $this->deleted = true;
        }
        $this->_select = 'cl.`name` as country';
        $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON 
		(cl.`id_country` = a.`id_country` AND cl.`id_lang` = ' . intval($cookie->id_lang) . ')';
        $countries = Country::getCountries(intval($cookie->id_lang));
        foreach ($countries as $country) {
            $this->countriesArray[$country['id_country']] = $country['name'];
        }
        $this->fieldsDisplay = array('id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'firstname' => array('title' => $this->l('First name'), 'width' => 80, 'filter_key' => 'a!firstname'), 'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!lastname'), 'address1' => array('title' => $this->l('Address'), 'width' => 200), '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'));
        parent::__construct();
    }
 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');
 }
Beispiel #26
0
    public function getContent()
    {
        $echo = '';
        if (Tools::isSubmit('submitVatNumber')) {
            if (Configuration::updateValue('VATNUMBER_COUNTRY', (int) Tools::getValue('vatnumber_country'))) {
                $echo .= $this->displayConfirmation($this->l('Your country has been updated.'));
            }
            $check = (int) Tools::getValue('vatnumber_checking');
            if (Configuration::get('VATNUMBER_CHECKING') != $check and Configuration::updateValue('VATNUMBER_CHECKING', $check)) {
                $echo .= $check ? $this->displayConfirmation($this->l('The check of the VAT number with the WebService is now enabled.')) : $this->displayConfirmation($this->l('The check of the VAT number with the WebService is now disabled.'));
            }
        }
        $echo .= '
		<fieldset><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<form action="' . htmlentities($_SERVER['REQUEST_URI']) . '" method="post">
				<label>' . $this->l('Your country') . '</label>
				<div class="margin-form">
					<select name="vatnumber_country">
						<option value="0">' . $this->l('-- Choose a country --') . '</option>';
        foreach (Country::getCountries($this->context->language->id) as $country) {
            $echo .= '		<option value="' . $country['id_country'] . '" ' . (Tools::getValue('VATNUMBER_COUNTRY', Configuration::get('VATNUMBER_COUNTRY')) == $country['id_country'] ? 'selected="selected"' : '') . '>' . $country['name'] . '</option>';
        }
        $echo .= '		</select>
				</div>
				<div class="clear">&nbsp;</div>
				<label>' . $this->l('Enable checking of the VAT number with the WebService') . '</label>
				<div class="margin-form">
					<input type="checkbox" name="vatnumber_checking" ' . (Configuration::get('VATNUMBER_CHECKING') ? 'checked="checked"' : '') . ' value="1"/>
					<p>' . $this->l('The verification by the webservice is slow. Enabling this option can slow down your shop.') . '</p>
				</div>
				<div class="clear">&nbsp;</div>
				<div class="margin-form">
					<input type="submit" class="button" name="submitVatNumber" value="' . $this->l('   Save   ') . '" />
				</div>
			</form>
		</fieldset>';
        return $echo;
    }
Beispiel #27
0
    }
    $months = Tools::dateMonths();
    if (isset($_POST['days']) and is_numeric($_POST['days'])) {
        $selectedDays = intval($_POST['days']);
    }
    $days = Tools::dateDays();
    /* Select the most appropriate country */
    if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) {
        $selectedCountry = intval($_POST['id_country']);
    } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
        if (Validate::isLanguageIsoCode($array[0])) {
            $selectedCountry = Country::getByIso($array[0]);
            if (!$selectedCountry) {
                $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
            }
        }
    }
    if (!isset($selectedCountry)) {
        $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
    }
    $countries = Country::getCountries(intval($cookie->id_lang), true);
    $smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0));
    /* Call a hook to display more information on form */
    $smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')));
}
include dirname(__FILE__) . '/header.php';
$smarty->assign('errors', $errors);
Tools::safePostVars();
$smarty->display(_PS_THEME_DIR_ . 'authentication.tpl');
include dirname(__FILE__) . '/footer.php';
Beispiel #28
0
 public function renderForm()
 {
     $countries = Country::getCountries($this->context->language->id);
     $countries_fmt = array(0 => array('id' => 0, 'name' => $this->l('-- Choose a country --')));
     foreach ($countries as $country) {
         $countries_fmt[] = array('id' => $country['id_country'], 'name' => $country['name']);
     }
     $fields_form = array('form' => array('legend' => array('title' => $this->l('Settings'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'select', 'label' => $this->l('Customers\' country'), 'desc' => $this->l('Operate a filter on customers\' country.'), 'name' => 'VATNUMBER_COUNTRY', 'required' => false, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => $countries_fmt, 'id' => 'id', 'name' => 'name')), array('type' => 'switch', 'label' => $this->l('Enable checking of the VAT number with the web service'), 'name' => 'VATNUMBER_CHECKING', 'is_bool' => true, 'desc' => $this->l('The verification by the web service is slow. Enabling this option can slow down your shop.'), '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'))));
     $helper = new HelperForm();
     $helper->module = $this;
     $helper->show_toolbar = false;
     $helper->table = $this->table;
     $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
     $helper->default_form_language = $lang->id;
     $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
     $this->fields_form = array();
     $helper->identifier = $this->identifier;
     $helper->submit_action = 'submitVatNumber';
     $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name;
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id);
     return $helper->generateForm(array($fields_form));
 }
 public function process()
 {
     parent::process();
     $back = Tools::getValue('back');
     $key = Tools::safeOutput(Tools::getValue('key'));
     if (!empty($key)) {
         $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key;
     }
     if (!empty($back)) {
         self::$smarty->assign('back', Tools::safeOutput($back));
         if (strpos($back, 'order.php') !== false) {
             if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
                 $countries = Carrier::getDeliveredCountries((int) self::$cookie->id_lang, true, true);
             } else {
                 $countries = Country::getCountries((int) self::$cookie->id_lang, true);
             }
             self::$smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'sl_country' => (int) Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')), 'countries' => $countries));
         }
     }
 }
 protected function processCreateRule()
 {
     $zip_code = Tools::getValue('zipcode');
     $id_rule = (int) Tools::getValue('id_tax_rule');
     $id_tax = (int) Tools::getValue('id_tax');
     $id_tax_rules_group = (int) Tools::getValue('id_tax_rules_group');
     $behavior = (int) Tools::getValue('behavior');
     $description = pSQL(Tools::getValue('description'));
     if ((int) ($id_country = Tools::getValue('country')) == 0) {
         $countries = Country::getCountries($this->context->language->id);
         $this->selected_countries = array();
         foreach ($countries as $country) {
             $this->selected_countries[] = (int) $country['id_country'];
         }
     } else {
         $this->selected_countries = array($id_country);
     }
     $this->selected_states = Tools::getValue('states');
     if (empty($this->selected_states) || count($this->selected_states) == 0) {
         $this->selected_states = array(0);
     }
     $tax_rules_group = new TaxRulesGroup((int) $id_tax_rules_group);
     foreach ($this->selected_countries as $id_country) {
         $first = true;
         foreach ($this->selected_states as $id_state) {
             if ($tax_rules_group->hasUniqueTaxRuleForCountry($id_country, $id_state, $id_rule)) {
                 $this->errors[] = Tools::displayError('A tax rule already exists for this country/state with tax only behavior.');
                 continue;
             }
             $tr = new TaxRule();
             // update or creation?
             if (isset($id_rule) && $first) {
                 $tr->id = $id_rule;
                 $first = false;
             }
             $tr->id_tax = $id_tax;
             $tax_rules_group = new TaxRulesGroup((int) $id_tax_rules_group);
             $tr->id_tax_rules_group = (int) $tax_rules_group->id;
             $tr->id_country = (int) $id_country;
             $tr->id_state = (int) $id_state;
             list($tr->zipcode_from, $tr->zipcode_to) = $tr->breakDownZipCode($zip_code);
             // Construct Object Country
             $country = new Country((int) $id_country, (int) $this->context->language->id);
             if ($zip_code && $country->need_zip_code) {
                 if ($country->zip_code_format) {
                     foreach (array($tr->zipcode_from, $tr->zipcode_to) as $zip_code) {
                         if ($zip_code) {
                             if (!$country->checkZipCode($zip_code)) {
                                 $this->errors[] = sprintf(Tools::displayError('The Zip/postal code is invalid. It must be typed as follows: %s for %s.'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))), $country->name);
                             }
                         }
                     }
                 }
             }
             $tr->behavior = (int) $behavior;
             $tr->description = $description;
             $this->tax_rule = $tr;
             $_POST['id_state'] = $tr->id_state;
             $this->errors = array_merge($this->errors, $this->validateTaxRule($tr));
             if (count($this->errors) == 0) {
                 $tax_rules_group = $this->updateTaxRulesGroup($tax_rules_group);
                 $tr->id = (int) $tax_rules_group->getIdTaxRuleGroupFromHistorizedId((int) $tr->id);
                 $tr->id_tax_rules_group = (int) $tax_rules_group->id;
                 if (!$tr->save()) {
                     $this->errors[] = Tools::displayError('An error has occurred: Cannot save the current tax rule.');
                 }
             }
         }
     }
     if (count($this->errors) == 0) {
         Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . (int) $tax_rules_group->id . '&conf=4&update' . $this->table . '&token=' . $this->token);
     } else {
         $this->display = 'edit';
     }
 }