示例#1
0
 public function displayFormSettings()
 {
     $veykuwqwjkus = "currency";
     ${"GLOBALS"}["tthknplj"] = "currencies";
     $lfapjegsknsa = "currency_list";
     $this->context->controller->addCSS($this->_path . "css/agilepaypal.css", "all");
     ${${"GLOBALS"}["teujyh"]} = array();
     array_push(${$lfapjegsknsa}, array("id" => 0, "name" => $this->l('Please choose')));
     $tfcoqgvrd = "helper";
     ${${"GLOBALS"}["sajaoqav"]} = Currency::getCurrencies(false, false);
     foreach (${${"GLOBALS"}["tthknplj"]} as ${$veykuwqwjkus}) {
         $unlqgrxvnkrh = "currency";
         array_push(${${"GLOBALS"}["teujyh"]}, array("id" => ${${"GLOBALS"}["duxtnwtj"]}["id_currency"], "name" => ${$unlqgrxvnkrh}["name"]));
     }
     ${${"GLOBALS"}["ogzmjfmjkidg"]} = array("form" => array("legend" => array("title" => $this->l('Settings'), "image" => $this->_path . "logo.gif"), "input" => array(array("type" => "text", "label" => $this->l('PayPal business e-mail'), "class" => "width10", "name" => "business", "size" => 33), array("type" => "select", "label" => $this->l('Paypal Account Currency'), "name" => "paypal_currency", "options" => array("query" => ${${"GLOBALS"}["teujyh"]}, "id" => "id", "name" => "name"), "desc" => $this->l('Please select the your Paypal Account Currency.')), array("type" => "radio", "label" => $this->l('Sandbox mode (Test)'), "name" => "sandbox", "values" => array(array("id" => "sandbox_yes", "value" => 1, "label" => $this->l('Yes')), array("id" => "sandbox_no", "value" => 0, "label" => $this->l('No')))), array("type" => "radio", "label" => $this->l('Mutiple Sellers Mode'), "name" => "support_sellers", "hint" => $this->l('If you have installed the Agile Multiple Seller module'), "form_group_class" => Module::isInstalled("agilemultipleseller") ? "" : "hidden", "values" => array(array("id" => "support_sellers_yes", "value" => 1, "label" => $this->l('Yes')), array("id" => "support_sellers_no", "value" => 0, "label" => $this->l('No'))), "desc" => array($this->l('All settings are the same for all sellers, except the Paypal account information which is managed in the Agile Multiple Seller module'))), array("type" => "htmlhr", "name" => "section1", "values" => array()), array("type" => "text", "label" => $this->l('Banner image URL'), "class" => "width10", "name" => "header", "size" => 82, "desc" => $this->l('The image should be hosted on a secured server in order to avoid security warnings. Size should be limited to 750x90px.')), array("type" => "htmlhr", "name" => "section2", "values" => array()), array("type" => "agile_radio_checkbox", "label" => $this->l('Express Checkout Enabled'), "name" => "express_enabled", "values" => array(array("id" => "express_enabled_yes", "value" => 1, "label" => $this->l('Yes'), "onclick" => "showitem('.express_enabled_yes')", "checkbox_list" => array("class" => "express_enabled_yes agile-radio-checkbox", "query" => array(array("id" => "hidecountry", "val" => 1, "name" => $this->l('Hide Countries') . "<font color=red>&nbsp;--&nbsp;" . $this->l('If your store ships to one country only.') . "</font>"), array("id" => "hidecarrier", "val" => 1, "name" => $this->l('Hide Carriers') . "<font color=red>&nbsp;--&nbsp;" . $this->l('If your store has one carrier, or no carrier') . "</font>"), array("id" => "hideterms", "val" => 1, "name" => $this->l('Hide Terms and Conditions') . "&nbsp;&nbsp;" . $this->l('Hide Terms and Conditions') . "&nbsp;--&nbsp;" . $this->l('If your want to hide the "Terms & Conditions" agreement checkbox at the express checkout screen'))), "id" => "id", "name" => "name")), array("id" => "express_enabled_no", "value" => 0, "label" => $this->l('No'), "onclick" => "hideitem('.express_enabled_yes')"))), array("type" => "htmlhr", "name" => "section3", "values" => array()), array("type" => "radio", "label" => $this->l('Force "Checkout" goes though summary page'), "name" => "force_summary", "values" => array(array("id" => "force_summary_yes", "value" => 1, "label" => $this->l('Yes')), array("id" => "force_summary_no", "value" => 0, "label" => $this->l('No'))), "desc" => $this->l('There are two buttons (Cart and Checkout) in the cart block. The "Checkout" button will bypass the order summary page, so the user will not be able to choose Express Checkout. Selecting "Yes" will force Checkout to go though the order summary page')), array("type" => "htmlhr", "name" => "section4", "values" => array()), array("type" => "agile_radio_checkbox", "label" => $this->l('Enable Recurring Payment'), "name" => "recurringpayment", "hint" => $this->l('Determine whether allow customers to subcribe for automatic, periodic payments, such as membership payments, etc.'), "values" => array(array("id" => "recurringpayment_yes", "value" => 1, "label" => $this->l('Yes'), "p" => $this->l('This will allow customers to subcribe for automatic, periodic payments, such as membership payments, etc.'), "onclick" => "showitem('.recurringpayment_yes')", "checkbox_list" => array("class" => "recurringpayment_yes agile-radio-checkbox", "query" => array(array("id" => "recurringdaily", "val" => 1, "name" => $this->l('Daily')), array("id" => "recurringweekly", "val" => 1, "name" => $this->l('Weekly')), array("id" => "recurringmonthly", "val" => 1, "name" => $this->l('Mobthly')), array("id" => "recurringyearly", "val" => 1, "name" => $this->l('Yearly'))), "id" => "id", "name" => "name")), array("id" => "recurringpayment_no", "value" => 0, "label" => $this->l('No'), "onclick" => "hideitem('.recurringpayment_yes')"))), array("type" => "htmlhr", "name" => "section5", "values" => array()), array("type" => "agile_text_addon", "label" => $this->l('Paypal Micropayment Account(Optional)'), "class" => "width10", "name" => "business2", "hint" => $this->l('Please leave this field empty if you are not using it'), "size" => 33, "addon_text" => $this->l('Max Amount:'), "addon_name" => "micro_amount", "addon_id" => "micro_amount", "size_addon" => 10, "desc" => array($this->l('What is Paypal Micropayment Account?'), $this->l('PayPal offers support for Micropayments to merchants for US to US, GB to GB, AU to AU, and EU to EU transactions for Business and Premier accounts. This feature is offered at a special rate of 5% + $0.05 per transaction. ') . "<a href=\"https://www.paypalobjects.com/IntegrationCenter/ic_micropayments.html\" target=\"_blank\" style=\"color:Blue\">" . $this->l('See here for detail') . "</a>")), array("type" => "agile_radio_checkbox", "label" => $this->l('Membership Integrattion'), "name" => "am_integrated", "hint" => $this->l(' Integrated with membership module'), "form_group_class" => Module::isInstalled("agilemembership") ? "" : "hidden", "values" => array(array("id" => "am_integrated_yes", "value" => 1, "label" => $this->l('Yes'), "onclick" => "showitem('.am_integrated_yes')", "checkbox_list" => array("class" => "am_integrated_yes agile-radio-checkbox", "query" => array(array("id" => "am_show_choice", "val" => 1, "name" => $this->l('Allow customer to choose repeating times')), array("id" => "am_mix_product", "val" => 1, "name" => $this->l('Prevent Membership and other product mix in the shopping cart')), array("id" => "subscribe_only", "val" => 1, "name" => $this->l('Make this module for membership payment only'))), "id" => "id", "name" => "name")), array("id" => "am_integrated_no", "value" => 0, "label" => $this->l('No'), "onclick" => "hideitem('.am_integrated_yes')")))), "submit" => array("title" => $this->l('Update settings'))));
     $fjxhbnyyanl = "lang";
     ${$tfcoqgvrd} = new HelperForm();
     $helper->show_toolbar = false;
     $helper->table = $this->name;
     ${$fjxhbnyyanl} = new Language((int) Configuration::get("PS_LANG_DEFAULT"));
     $helper->default_form_language = $lang->id;
     $helper->module = $this;
     $helper->allow_employee_form_lang = Configuration::get("PS_BO_ALLOW_EMPLOYEE_FORM_LANG") ? Configuration::get("PS_BO_ALLOW_EMPLOYEE_FORM_LANG") : 0;
     $helper->identifier = $this->identifier;
     $helper->submit_action = "submitPaypal";
     $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);
     $this->_html .= $helper->generateForm(array(${${"GLOBALS"}["ogzmjfmjkidg"]}));
     $this->context->controller->addCSS($this->_path . "css/agilepaypal.css", "all");
     $this->context->controller->addJS($this->_path . "js/agilepaypal.js");
 }
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $this->fields_form = array('legend' => array('title' => $this->trans('Catalog price rules', array(), 'Admin.Catalog.Feature'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->trans('Name', array(), 'Admin.Global'), 'name' => 'name', 'maxlength' => 255, 'required' => true), array('type' => 'select', 'label' => $this->trans('Shop', array(), 'Admin.Global'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->trans('Currency', array(), 'Admin.Global'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->trans('All currencies', array(), 'Admin.Global'))), Currency::getCurrencies(false, true, true)), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Country', array(), 'Admin.Global'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->trans('All countries', array(), 'Admin.Global'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Group', array(), 'Admin.Global'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->trans('All groups', array(), 'Admin.Global'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->trans('From quantity', array(), 'Admin.Catalog.Feature'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->trans('Price (tax excl.)', array(), 'Admin.Catalog.Feature'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->trans('Leave initial price', array(), 'Admin.Catalog.Feature'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->trans('From', array(), 'Admin.Global'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->trans('To', array(), 'Admin.Global'), 'name' => 'to'), array('type' => 'select', 'label' => $this->trans('Reduction type', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->trans('Amount', array(), 'Admin.Global')), array('reduction_type' => 'percentage', 'name' => $this->trans('Percentage', array(), 'Admin.Global'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->trans('Reduction with or without taxes', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->trans('Tax included', array(), 'Admin.Global'), 'val' => 1), array('lab' => $this->trans('Tax excluded', array(), 'Admin.Global'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->trans('Reduction', array(), 'Admin.Catalog.Feature'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions')));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 6);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1, 'shop_id' => ($value = $this->getFieldValue($this->object, 'id_shop')) ? $value : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
示例#3
0
 public function __construct()
 {
     global $cookie;
     $this->table = 'order';
     $this->className = 'Order';
     $this->view = true;
     $this->colorOnBackground = true;
     $this->_select = '
         a.id_order AS id_pdf,
         CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
         cc.`iso_code` AS `iso_code`,
         osl.`name` AS `osname`,
         os.`color`,
         IF((SELECT COUNT(so.id_order) FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
         (SELECT COUNT(od.`id_order`) FROM `' . _DB_PREFIX_ . 'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
     $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (c.`id_customer` = a.`id_customer`)
      LEFT JOIN `' . _DB_PREFIX_ . 'order_history` oh ON (oh.`id_order` = a.`id_order`)
     LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
     LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int) $cookie->id_lang . ')
     LEFT JOIN `' . _DB_PREFIX_ . 'currency` cc  on (cc.`id_currency` = a.`id_currency`)';
     $this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `' . _DB_PREFIX_ . 'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';
     $statesArray = array();
     $states = OrderState::getOrderStates((int) $cookie->id_lang);
     foreach ($states as $state) {
         $statesArray[$state['id_order_state']] = $state['name'];
     }
     $currenciesArray = array();
     $currencies = Currency::getCurrencies(false, 0);
     foreach ($currencies as $currency) {
         $currenciesArray[$currency['id_currency']] = $currency['iso_code'];
     }
     $this->fieldsDisplay = array('id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false), 'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true), 'iso_code' => array('title' => $this->l('Currency'), 'width' => 60, 'align' => 'center', 'type' => 'select', 'select' => $currenciesArray, 'filter_key' => 'cc!id_currency', 'filter_type' => 'int'), 'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true), 'payment' => array('title' => $this->l('Payment'), 'width' => 100), 'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200), 'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'), 'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
     parent::__construct();
 }
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $shops = Shop::getShops();
     if (count($this->context->employee->getAssociatedShops()) > 1) {
         $shops = array_merge(array(0 => array('id_shop' => 0, 'name' => $this->l('All shops'))), $shops);
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Specific price rules')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 33, 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop:'), 'name' => 'id_shop', 'options' => array('query' => $shops, 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency:'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group:'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity:'), 'name' => 'from_quantity', 'size' => 6, 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.):'), 'name' => 'price', 'size' => 6, 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'date', 'label' => $this->l('From:'), 'name' => 'from', 'size' => 12), array('type' => 'date', 'label' => $this->l('To:'), 'name' => 'to', 'size' => 12), array('type' => 'select', 'label' => $this->l('Reduction type:'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Reduction:'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 2);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 2), 'leave_bprice_on' => $price ? 0 : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
    public function renderForm()
    {
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
        if ($value = Tools::getValue('address_layout')) {
            $address_layout = $value;
        }
        $default_layout = '';
        $default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
        foreach ($default_layout_tab as $line) {
            $default_layout .= implode(' ', $line) . "\r\n";
        }
        $this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'image' => '../img/admin/world.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country:'), 'name' => 'name', 'lang' => true, 'size' => 30, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Country name')), array('type' => 'text', 'label' => $this->l('ISO code:'), 'name' => 'iso_code', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Two -- or three -- letter ISO code (e.g. U.S. for United States)') . '.
							<a href="http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm" target="_blank">' . $this->l('Official list here') . '
							</a>.'), array('type' => 'text', 'label' => $this->l('Call prefix:'), 'name' => 'call_prefix', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('International call prefix, (e.g. 1 for United States)')), array('type' => 'select', 'label' => $this->l('Default currency:'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone:'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'desc' => $this->l('Geographical region')), array('type' => 'radio', 'label' => $this->l('Need zip/postal code:'), 'name' => 'need_zip_code', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/post code format:'), 'name' => 'zip_code_format', 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Zip Code format (L for a letter, N for a number and C for the ISO code). For example, NNNNN for the United States. No verification if undefined.')), array('type' => 'address_layout', 'label' => $this->l('Address format:'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields()), array('type' => 'radio', 'label' => $this->l('Address Standardization:'), 'name' => 'standardization', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'standardization_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'standardization_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Active:'), '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'))), 'desc' => $this->l('Display this country to your customers (the selected country will always be displayed in the Back Office)')), array('type' => 'radio', 'label' => $this->l('Contains following  states:'), 'name' => 'contains_states', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Display tax label (e.g. "Tax incl."):'), 'name' => 'display_tax_label', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
        if (Shop::isFeatureActive()) {
            $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
        }
        $this->fields_form['submit'] = array('title' => $this->l('Save   '), 'class' => 'button');
        if ($this->object->iso_code == 'US') {
            $this->object->standardization = Configuration::get('PS_TAASC');
        }
        return parent::renderForm();
    }
 public function getWidgetVariables($hookName, array $configuration)
 {
     $current_currency = null;
     $serializer = new ObjectPresenter();
     $currencies = array_map(function ($currency) use($serializer, &$current_currency) {
         $currencyArray = $serializer->present($currency);
         // serializer doesn't see 'sign' because it is not a regular
         // ObjectModel field.
         $currencyArray['sign'] = $currency->sign;
         $url = $this->context->link->getLanguageLink($this->context->language->id);
         $extraParams = array('SubmitCurrency' => 1, 'id_currency' => $currency->id);
         $partialQueryString = http_build_query($extraParams);
         $separator = empty(parse_url($url)['query']) ? '?' : '&';
         $url .= $separator . $partialQueryString;
         $currencyArray['url'] = $url;
         if ($currency->id === $this->context->currency->id) {
             $currencyArray['current'] = true;
             $current_currency = $currencyArray;
         } else {
             $currencyArray['current'] = false;
         }
         return $currencyArray;
     }, Currency::getCurrencies(true, true));
     return array('currencies' => $currencies, 'current_currency' => $current_currency);
 }
 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 __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);
     }
 }
 /**
  * Returns module content for header
  *
  * @param array $params Parameters
  * @return string Content
  */
 function hookRightColumn($params)
 {
     global $smarty;
     $currencies = Currency::getCurrencies();
     if (!sizeof($currencies)) {
         return '';
     }
     $smarty->assign('currencies', $currencies);
     return $this->display(__FILE__, 'blockcurrenciesincolumn.tpl');
 }
 /**
  * @covers \SebastianBergmann\Money\Currency::getCurrencies
  */
 public function testRegisteredCurrenciesCanBeAccessed()
 {
     $currencies = Currency::getCurrencies();
     $this->assertInternalType('array', $currencies);
     $this->assertArrayHasKey('EUR', $currencies);
     $this->assertInternalType('array', $currencies['EUR']);
     $this->assertArrayHasKey('display_name', $currencies['EUR']);
     $this->assertArrayHasKey('numeric_code', $currencies['EUR']);
     $this->assertArrayHasKey('default_fraction_digits', $currencies['EUR']);
     $this->assertArrayHasKey('sub_unit', $currencies['EUR']);
 }
 private function getCurrencies()
 {
     $currencies = array();
     $shopCurrencies = Currency::getCurrencies();
     if ($shopCurrencies && count($shopCurrencies)) {
         foreach ($shopCurrencies as $currency) {
             $currencies[] = $currency['iso_code'];
         }
     }
     return $currencies;
 }
示例#12
0
 private function _prepareHook($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return false;
     }
     if (!count(Currency::getCurrencies())) {
         return false;
     }
     $this->smarty->assign('blockcurrencies_sign', $this->context->currency->sign);
     return true;
 }
 /**
  * Returns module content for header
  *
  * @param array $params Parameters
  * @return string Content
  */
 public function hookTop($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return;
     }
     global $smarty;
     $currencies = Currency::getCurrencies();
     if (!sizeof($currencies)) {
         return '';
     }
     $smarty->assign('currencies', $currencies);
     return $this->display(__FILE__, 'blockcurrencies.tpl');
 }
 public function __construct()
 {
     $this->table = 'currency';
     $this->className = 'Currency';
     $this->lang = false;
     $this->edit = true;
     $this->delete = true;
     $this->fieldsDisplay = array('id_currency' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Currency'), 'width' => 100), 'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 35), 'iso_code_num' => array('title' => $this->l('ISO code num'), 'align' => 'center', 'width' => 35), 'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false), 'conversion_rate' => array('title' => $this->l('Conversion rate'), 'float' => true, 'align' => 'center', 'width' => 50, 'search' => false), 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
     $this->optionTitle = $this->l('Currencies options');
     $this->_fieldsOptions = array('PS_CURRENCY_DEFAULT' => array('title' => $this->l('Default currency:'), 'desc' => $this->l('The default currency used in shop') . '<div class=warn"><img src="../img/admin/warn2.png" />' . $this->l('If you change default currency, you will have to manually edit every product price.') . '</div>', 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_currency', 'list' => Currency::getCurrencies()));
     $this->_where = 'AND a.`deleted` = 0';
     parent::__construct();
 }
示例#15
0
 public function __construct()
 {
     $this->table = 'currency';
     $this->className = 'Currency';
     $this->lang = false;
     $this->edit = true;
     $this->delete = true;
     $this->fieldsDisplay = array('id_currency' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Currency'), 'width' => 100), 'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 35), 'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false), 'conversion_rate' => array('title' => $this->l('Conversion rate'), 'float' => true, 'align' => 'center', 'width' => 50, 'search' => false));
     $this->optionTitle = $this->l('Currencies options');
     $this->_fieldsOptions = array('PS_CURRENCY_DEFAULT' => array('title' => $this->l('Default currency:'), 'desc' => $this->l('The default currency used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_currency', 'list' => Currency::getCurrencies()));
     $this->_where = 'AND a.`deleted` = 0';
     parent::__construct();
 }
 /**
  * AdminController::renderForm() override
  * @see AdminController::renderForm()
  */
 public function renderForm()
 {
     // gets the product
     $id_product = (int) Tools::getValue('id_product');
     $id_product_attribute = (int) Tools::getValue('id_product_attribute');
     // gets warehouses
     $warehouses_add = $warehouses_remove = Warehouse::getWarehousesByProductId($id_product, $id_product_attribute);
     // displays warning if no warehouses
     if (!$warehouses_add) {
         $this->displayWarning($this->l('You must choose a warehouses before adding stock. See Stock/Warehouses.'));
     }
     //get currencies list
     $currencies = Currency::getCurrencies();
     $id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
     $default_currency = Currency::getCurrency($id_default_currency);
     if ($default_currency) {
         $currencies = array_merge(array($default_currency, '-'), $currencies);
     }
     // switch, in order to display the form corresponding to the current action
     switch ($this->display) {
         case 'addstock':
             // gets the last stock mvt for this product, so we can display the last unit price te and the last quantity added
             $last_sm_unit_price_te = $this->l('N/A');
             $last_sm_quantity = 0;
             $last_sm_quantity_is_usable = -1;
             $last_sm = StockMvt::getLastPositiveStockMvt($id_product, $id_product_attribute);
             // if there is a stock mvt
             if ($last_sm != false) {
                 $last_sm_currency = new Currency((int) $last_sm['id_currency']);
                 $last_sm_quantity = (int) $last_sm['physical_quantity'];
                 $last_sm_quantity_is_usable = (int) $last_sm['is_usable'];
                 if (Validate::isLoadedObject($last_sm_currency)) {
                     $last_sm_unit_price_te = Tools::displayPrice((double) $last_sm['price_te'], $last_sm_currency);
                 }
             }
             $this->displayInformation($this->l('Moving the mouse cursor over the quantity and price fields will give you the details about the last stock movement.'));
             // fields in the form
             $this->fields_form[]['form'] = array('legend' => array('title' => $this->l('Add a product to your stock.'), 'icon' => 'icon-long-arrow-up'), 'input' => array(array('type' => 'hidden', 'name' => 'is_post'), array('type' => 'hidden', 'name' => 'id_product'), array('type' => 'hidden', 'name' => 'id_product_attribute'), array('type' => 'hidden', 'name' => 'check'), array('type' => 'text', 'label' => $this->l('Product reference'), 'name' => 'reference', 'disabled' => true), array('type' => 'text', 'label' => $this->l('EAN-13 or JAN barcode'), 'name' => 'ean13', 'disabled' => true), array('type' => 'text', 'label' => $this->l('UPC barcode'), 'name' => 'upc', 'disabled' => true), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'disabled' => true), array('type' => 'text', 'label' => $this->l('Quantity to add'), 'name' => 'quantity', 'maxlength' => 6, 'required' => true, 'hint' => array($this->l('Indicate the physical quantity of this product that you want to add.'), $this->l('Last physical quantity added: %s items (usable for sale: %s).'), $last_sm_quantity > 0 ? $last_sm_quantity : $this->l('N/A'), $last_sm_quantity > 0 ? $last_sm_quantity_is_usable >= 0 ? $this->l('Yes') : $this->l('No') : $this->l('N/A'))), array('type' => 'switch', 'label' => $this->l('Usable for sale?'), 'name' => 'usable', 'required' => true, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Is this quantity ready to be displayed in your shop, or is it reserved in the warehouse for other purposes?')), array('type' => 'select', 'label' => $this->l('Warehouse'), 'name' => 'id_warehouse', 'required' => true, 'options' => array('query' => $warehouses_add, 'id' => 'id_warehouse', 'name' => 'name'), 'hint' => $this->l('Please select the warehouse that you\'ll be adding products to.')), array('type' => 'text', 'label' => $this->l('Unit price (tax excl.)'), 'name' => 'price', 'required' => true, 'size' => 10, 'maxlength' => 10, 'hint' => array($this->l('Unit purchase price or unit manufacturing cost for this product (tax excl.).'), sprintf($this->l('Last unit price (tax excl.): %s.'), $last_sm_unit_price_te))), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'required' => true, 'options' => array('query' => $currencies, 'id' => 'id_currency', 'name' => 'name'), 'hint' => $this->l('The currency associated to the product unit price.')), array('type' => 'select', 'label' => $this->l('Label'), 'name' => 'id_stock_mvt_reason', 'required' => true, 'options' => array('query' => StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, array(Configuration::get('PS_STOCK_MVT_TRANSFER_TO')), 1), 'id' => 'id_stock_mvt_reason', 'name' => 'name'), 'hint' => $this->l('Label used in stock movements.'))), 'submit' => array('title' => $this->l('Add to stock')));
             $this->fields_value['usable'] = 1;
             break;
         case 'removestock':
             $this->fields_form[]['form'] = array('legend' => array('title' => $this->l('Remove the product from your stock.'), 'icon' => 'icon-long-arrow-down'), 'input' => array(array('type' => 'hidden', 'name' => 'is_post'), array('type' => 'hidden', 'name' => 'id_product'), array('type' => 'hidden', 'name' => 'id_product_attribute'), array('type' => 'hidden', 'name' => 'check'), array('type' => 'text', 'label' => $this->l('Product reference'), 'name' => 'reference', 'disabled' => true), array('type' => 'text', 'label' => $this->l('EAN-13 or JAN barcode'), 'name' => 'ean13', 'disabled' => true), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'disabled' => true), array('type' => 'text', 'label' => $this->l('Quantity to remove'), 'name' => 'quantity', 'maxlength' => 6, 'required' => true, 'hint' => $this->l('Indicate the physical quantity of this product that you want to remove.')), array('type' => 'switch', 'label' => $this->l('Usable for sale'), 'name' => 'usable', 'required' => true, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Do you want to remove this quantity from the usable quantity (yes) or the physical quantity (no)?')), array('type' => 'select', 'label' => $this->l('Warehouse'), 'name' => 'id_warehouse', 'required' => true, 'options' => array('query' => $warehouses_remove, 'id' => 'id_warehouse', 'name' => 'name'), 'hint' => $this->l('Select the warehouse you\'d like to remove the product from.')), array('type' => 'select', 'label' => $this->l('Label'), 'name' => 'id_stock_mvt_reason', 'required' => true, 'options' => array('query' => StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, array(Configuration::get('PS_STOCK_MVT_TRANSFER_FROM')), -1), 'id' => 'id_stock_mvt_reason', 'name' => 'name'), 'hint' => $this->l('Label used in stock movements.'))), 'submit' => array('title' => $this->l('Remove from stock')));
             break;
         case 'transferstock':
             $this->fields_form[]['form'] = array('legend' => array('title' => $this->l('Transfer a product from one warehouse to another'), 'icon' => 'icon-share-alt'), 'input' => array(array('type' => 'hidden', 'name' => 'is_post'), array('type' => 'hidden', 'name' => 'id_product'), array('type' => 'hidden', 'name' => 'id_product_attribute'), array('type' => 'hidden', 'name' => 'check'), array('type' => 'text', 'label' => $this->l('Product reference'), 'name' => 'reference', 'disabled' => true), array('type' => 'text', 'label' => $this->l('EAN-13 or JAN barcode'), 'name' => 'ean13', 'disabled' => true), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'disabled' => true), array('type' => 'text', 'label' => $this->l('Quantity to transfer'), 'name' => 'quantity', 'maxlength' => 6, 'required' => true, 'hint' => $this->l('Indicate the physical quantity of this product that you want to transfer.')), array('type' => 'select', 'label' => $this->l('Source warehouse'), 'name' => 'id_warehouse_from', 'required' => true, 'options' => array('query' => $warehouses_remove, 'id' => 'id_warehouse', 'name' => 'name'), 'hint' => $this->l('Select the warehouse you\'d like to transfer the product from.')), array('type' => 'switch', 'label' => $this->l('Is this product usable for sale in your source warehouse?'), 'name' => 'usable_from', 'required' => true, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Is this the usable quantity for sale?')), array('type' => 'select', 'label' => $this->l('Destination warehouse'), 'name' => 'id_warehouse_to', 'required' => true, 'options' => array('query' => $warehouses_add, 'id' => 'id_warehouse', 'name' => 'name'), 'hint' => $this->l('Select the warehouse you\'d like to transfer your product(s) to. ')), array('type' => 'switch', 'label' => $this->l('Is this product usable for sale in your destination warehouse?'), 'name' => 'usable_to', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Do you want it to be for sale/usable?'))), 'submit' => array('title' => $this->l('Transfer')));
             break;
     }
     $this->initToolbar();
 }
 public function getContent()
 {
     $html = '';
     if (Tools::isSubmit('submitModule')) {
         Configuration::updateValue('PAYNETZ_API_MERCHANT_URL', Tools::getvalue('api_merchant_url'));
         Configuration::updateValue('PAYNETZ_API_SERVER_PORT', Tools::getvalue('api_server_port'));
         Configuration::updateValue('PAYNETZ_API_LOGIN_ID', Tools::getvalue('api_login_id'));
         Configuration::updateValue('PAYNETZ_API_PASSWORD', Tools::getvalue('api_password'));
         Configuration::updateValue('PAYNETZ_API_PRODUCT_ID', Tools::getvalue('api_product_id'));
         $html .= $this->displayConfirmation($this->l('Configuration updated'));
     }
     // For "Hold for Review" order status
     $currencies = Currency::getCurrencies(false, true);
     $order_states = OrderState::getOrderStates((int) $this->context->cookie->id_lang);
     $this->context->smarty->assign(array('available_currencies' => $this->aim_available_currencies, 'currencies' => $currencies, 'module_dir' => $this->_path, 'order_states' => $order_states, 'PAYNETZ_API_MERCHANT_URL' => Configuration::get('PAYNETZ_API_MERCHANT_URL'), 'PAYNETZ_API_SERVER_PORT' => Configuration::get('PAYNETZ_API_SERVER_PORT'), 'PAYNETZ_API_LOGIN_ID' => Configuration::get('PAYNETZ_API_LOGIN_ID'), 'PAYNETZ_API_PASSWORD' => Configuration::get('PAYNETZ_API_PASSWORD'), 'PAYNETZ_API_PRODUCT_ID' => Configuration::get('PAYNETZ_API_PRODUCT_ID')));
     return $this->context->smarty->fetch($this->local_path . 'views/templates/admin/configuration.tpl');
 }
 public function uninstall()
 {
     Configuration::deleteByName('PAYFORT_START_SANDBOX');
     Configuration::deleteByName('PAYFORT_START_TEST_MODE');
     Configuration::deleteByName('PAYFORT_START_LIVE_OPEN_KEY');
     Configuration::deleteByName('PAYFORT_START_TEST_OPEN_KEY');
     Configuration::deleteByName('PAYFORT_START_LIVE_SECRET_KEY');
     Configuration::deleteByName('PAYFORT_START_LIVE_SECRET_KEY');
     Configuration::deleteByName('PAYFORT_START_HOLD_REVIEW_OS');
     /* Removing credentials configuration variables */
     $currencies = Currency::getCurrencies(false, true);
     foreach ($currencies as $currency) {
         if (in_array($currency['iso_code'], $this->start_available_currencies)) {
             Configuration::deleteByName('PAYFORT_START_LOGIN_ID_' . $currency['iso_code']);
             Configuration::deleteByName('PAYFORT_START_KEY_' . $currency['iso_code']);
         }
     }
     return parent::uninstall();
 }
function upgrade_module_1_4_8($object)
{
    $upgrade_version = '1.4.8';
    $object->upgrade_detail[$upgrade_version] = array();
    // Variables name for Login and Key have now the currency
    if (Configuration::get('PAYFORT_FORT_LOGIN_ID') && Configuration::get('PAYFORT_FORT_KEY')) {
        $currencies = Currency::getCurrencies(false, true);
        foreach ($currencies as $currency) {
            if (in_array($currency['iso_code'], $object->start_available_currencies)) {
                $configuration_id_name = 'PAYFORT_FORT_LOGIN_ID_' . $currency['iso_code'];
                $configuration_key_name = 'PAYFORT_FORT_KEY_' . $currency['iso_code'];
                Configuration::updateValue($configuration_id_name, Configuration::get('PAYFORT_FORT_LOGIN_ID'));
                Configuration::updateValue($configuration_key_name, Configuration::get('PAYFORT_FORT_KEY'));
            }
        }
    }
    Configuration::deleteByName('PAYFORT_FORT_LOGIN_ID');
    Configuration::deleteByName('PAYFORT_FORT_KEY');
    Configuration::updateValue('PAYFORT_FORT', $upgrade_version);
    return true;
}
示例#20
0
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
     if ($value = Tools::getValue('address_layout')) {
         $address_layout = $value;
     }
     $default_layout = '';
     $default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
     foreach ($default_layout_tab as $line) {
         $default_layout .= implode(' ', $line) . "\r\n";
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'icon' => 'icon-globe'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country'), 'name' => 'name', 'lang' => true, 'required' => true, 'hint' => $this->l('Country name') . ' - ' . $this->l('Invalid characters:') . ' &lt;&gt;;=#{} '), array('type' => 'text', 'label' => $this->l('ISO code'), 'name' => 'iso_code', 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'hint' => $this->l('Two -- or three -- letter ISO code (e.g. "us for United States).')), array('type' => 'text', 'label' => $this->l('Call prefix'), 'name' => 'call_prefix', 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'hint' => $this->l('International call prefix, (e.g. 1 for United States).')), array('type' => 'select', 'label' => $this->l('Default currency'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'hint' => $this->l('Geographical region.')), array('type' => 'switch', 'label' => $this->l('Does it need Zip/postal code?'), 'name' => 'need_zip_code', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/postal code format'), 'name' => 'zip_code_format', 'required' => true, 'desc' => $this->l('Indicate the format of the postal code: use L for a letter, N for a number, and C for the country\'s ISO 3166-1 alpha-2 code. For example, NNNNN for the United States, France, Poland and many other; LNNNNLLL for Argentina, etc. If you do not want PrestaShop to verify the postal code for this country, leave it blank.')), array('type' => 'address_layout', 'label' => $this->l('Address format'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields()), array('type' => 'switch', 'label' => $this->l('Active'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Display this country to your customers (the selected country will always be displayed in the Back Office).')), array('type' => 'switch', 'label' => $this->l('Contains states'), 'name' => 'contains_states', 'required' => false, 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Display tax label (e.g. "Tax incl.")'), 'name' => 'display_tax_label', 'required' => false, 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     return parent::renderForm();
 }
示例#21
0
 public function display()
 {
     global $cookie;
     foreach ($this->paymentModules as $module) {
         if ($module->active and $module->warning) {
             $this->displayWarning($module->displayName . ' - ' . stripslashes(pSQL($module->warning)));
         }
     }
     $currencies = Currency::getCurrencies();
     $countries = Country::getCountries(intval($cookie->id_lang));
     $groups = Group::getGroups(intval($cookie->id_lang));
     $this->displayModules();
     echo '<br /><h2 class="space">' . $this->l('Payment module restrictions') . '</h2>';
     $textCurrencies = $this->l('Please mark the checkbox(es) for the currency or currencies in which you want the payment module(s) available.');
     $textCountries = $this->l('Please mark the checkbox(es) for the country or countries in which you want the payment module(s) available.');
     $textGroups = $this->l('Please mark the checkbox(es) for the groups in which you want the payment module(s) available.');
     $this->displayModuleRestrictions($currencies, $this->l('Currencies restrictions'), 'currency', $textCurrencies, 'dollar');
     echo '<br />';
     $this->displayModuleRestrictions($groups, $this->l('Groups restrictions'), 'group', $textGroups, 'group');
     echo '<br />';
     $this->displayModuleRestrictions($countries, $this->l('Countries restrictions'), 'country', $textCountries, 'world');
 }
示例#22
0
    private function _displayForm()
    {
        $divLangName = 'cpara¤dd';
        $currencies = Currency::getCurrencies();
        $this->_html .= '
		<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post">
		<fieldset>
			<legend><img src="' . _PS_ADMIN_IMG_ . 'prefs.gif" alt="' . $this->l('Settings') . '" />' . $this->l('Settings') . '</legend>
			<p>
				<label class="t" for="order_quantity">' . $this->l('Minimum number of orders a sponsored friend must place to get their voucher:') . '</label>
				<input type="text" name="order_quantity" id="order_quantity" value="' . Tools::safeOutput(Tools::getValue('order_quantity', Configuration::get('REFERRAL_ORDER_QUANTITY'))) . '" style="width: 50px; text-align: right;" />
			</p>
			<p>
				<label class="t" for="nb_friends">' . $this->l('Number of friends in the referral program invitation form (customer account, referral program section):') . '</label>
				<input type="text" name="nb_friends" id="nb_friends" value="' . Tools::safeOutput(Tools::getValue('nb_friends', Configuration::get('REFERRAL_NB_FRIENDS'))) . '" style="width: 50px; text-align: right;" />
			</p>
			<p>
				<label class="t">' . $this->l('Voucher type:') . '</label>
				<input type="radio" name="discount_type" id="discount_type1" value="1" onclick="$(\'#voucherbycurrency\').hide(); $(\'#voucherbypercentage\').show();" ' . (Tools::getValue('discount_type', Configuration::get('REFERRAL_DISCOUNT_TYPE')) == 1 ? 'checked="checked"' : '') . ' />
				<label class="t" for="discount_type1">' . $this->l('Voucher offering a percentage') . '</label>
				&nbsp;
				<input type="radio" name="discount_type" id="discount_type2" value="2" onclick="$(\'#voucherbycurrency\').show(); $(\'#voucherbypercentage\').hide();" ' . (Tools::getValue('discount_type', Configuration::get('REFERRAL_DISCOUNT_TYPE')) == 2 ? 'checked="checked"' : '') . ' />
				<label class="t" for="discount_type2">' . $this->l('Voucher offering a fixed amount (by currency)') . '</label>
			</p>
			<p id="voucherbypercentage"' . (Configuration::get('REFERRAL_DISCOUNT_TYPE') == 2 ? ' style="display: none;"' : '') . '><label class="t">' . $this->l('Percentage:') . '</label> <input type="text" id="discount_value_percentage" name="discount_value_percentage" value="' . Tools::safeOutput(Tools::getValue('discount_value_percentage', Configuration::get('REFERRAL_PERCENTAGE'))) . '" style="width: 50px; text-align: right;" /> %</p>
			<table id="voucherbycurrency" cellpadding="5" style="border: 1px solid #BBB;' . (Configuration::get('REFERRAL_DISCOUNT_TYPE') == 1 ? ' display: none;' : '') . '" border="0">
				<tr>
					<th style="width: 80px;">' . $this->l('Currency') . '</th>
					<th>' . $this->l('Voucher amount') . '</th>
				</tr>';
        foreach ($currencies as $currency) {
            $this->_html .= '
			<tr>
				<td>' . (Configuration::get('PS_CURRENCY_DEFAULT') == $currency['id_currency'] ? '<span style="font-weight: bold;">' : '') . htmlentities($currency['name'], ENT_NOQUOTES, 'utf-8') . (Configuration::get('PS_CURRENCY_DEFAULT') == $currency['id_currency'] ? '<span style="font-weight: bold;">' : '') . '</td>
				<td><input type="text" name="discount_value[' . (int) $currency['id_currency'] . ']" id="discount_value[' . (int) $currency['id_currency'] . ']" value="' . Tools::safeOutput(Tools::getValue('discount_value[' . (int) $currency['id_currency'] . ']', Configuration::get('REFERRAL_DISCOUNT_VALUE_' . (int) $currency['id_currency']))) . '" style="width: 50px; text-align: right;" /> ' . $currency['sign'] . '</td>
			</tr>';
        }
        $this->_html .= '
		</table>
			<p>
				 <div style="float: left"><label class="t" for="discount_description">' . $this->l('Voucher description:') . '</label></div>';
        $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
        $languages = Language::getLanguages(true);
        foreach ($languages as $language) {
            $this->_html .= '
				<div id="dd_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $id_lang_default ? 'block' : 'none') . '; float: left; margin-left: 4px;">
					<input type="text" name="discount_description[' . $language['id_lang'] . ']" id="discount_description[' . $language['id_lang'] . ']" value="' . (isset($_POST['discount_description'][(int) $language['id_lang']]) ? $_POST['discount_description'][(int) $language['id_lang']] : $this->_configuration['REFERRAL_DISCOUNT_DESCRIPTION'][(int) $language['id_lang']]) . '" style="width: 200px;" />
				</div>';
        }
        $this->_html .= $this->displayFlags($languages, $id_lang_default, $divLangName, 'dd', true);
        $this->_html .= '
			</p>
			<div class="clear center"><input class="button" style="margin-top: 10px" name="submitReferralProgram" id="submitReferralProgram" value="' . $this->l('Update settings') . '" type="submit" /></div>
		</fieldset>
		</form><br/>';
    }
示例#23
0
 public function init()
 {
     /*
      * Globals are DEPRECATED as of version 1.5.
      * Use the Context to access objects instead.
      * Example: $this->context->cart
      */
     global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     parent::init();
     // If current URL use SSL, set it true (used a lot for module redirect)
     if (Tools::usingSecureMode()) {
         $useSSL = true;
     }
     // For compatibility with globals, DEPRECATED as of version 1.5
     $css_files = $this->css_files;
     $js_files = $this->js_files;
     // If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol
     if (Configuration::get('PS_SSL_ENABLED') && $_SERVER['REQUEST_METHOD'] != 'POST' && $this->ssl != Tools::usingSecureMode()) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Cache-Control: no-cache');
         if ($this->ssl) {
             header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
         } else {
             header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']);
         }
         exit;
     }
     if ($this->ajax) {
         $this->display_header = false;
         $this->display_footer = false;
     }
     // if account created with the 2 steps register process, remove 'accoun_created' from cookie
     if (isset($this->context->cookie->account_created)) {
         $this->context->smarty->assign('account_created', 1);
         unset($this->context->cookie->account_created);
     }
     ob_start();
     // Init cookie language
     // @TODO This method must be moved into switchLanguage
     Tools::setCookieLanguage($this->context->cookie);
     $protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
     $useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
     $protocol_content = $useSSL ? 'https://' : 'http://';
     $link = new Link($protocol_link, $protocol_content);
     $this->context->link = $link;
     if ($id_cart = (int) $this->recoverCart()) {
         $this->context->cookie->id_cart = (int) $id_cart;
     }
     if ($this->auth && !$this->context->customer->isLogged($this->guestAllowed)) {
         Tools::redirect('index.php?controller=authentication' . ($this->authRedirection ? '&back=' . $this->authRedirection : ''));
     }
     /* Theme is missing */
     if (!is_dir(_PS_THEME_DIR_)) {
         throw new PrestaShopException(sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\'))));
     }
     if (Configuration::get('PS_GEOLOCATION_ENABLED')) {
         if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault)) {
             $this->context->country = $newDefault;
         }
     }
     $currency = Tools::setCurrency($this->context->cookie);
     if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) {
         $this->context->customer->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     } elseif (isset($_GET['mylogout'])) {
         $this->context->customer->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     }
     /* Cart already exists */
     if ((int) $this->context->cookie->id_cart) {
         $cart = new Cart($this->context->cookie->id_cart);
         if ($cart->OrderExists()) {
             unset($this->context->cookie->id_cart, $cart, $this->context->cookie->checkedTOS);
             $this->context->cookie->check_cgv = false;
         } elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 && !FrontController::isInWhitelistForGeolocation() && !in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
             unset($this->context->cookie->id_cart, $cart);
         } elseif ($this->context->cookie->id_customer != $cart->id_customer || $this->context->cookie->id_lang != $cart->id_lang || $currency->id != $cart->id_currency) {
             if ($this->context->cookie->id_customer) {
                 $cart->id_customer = (int) $this->context->cookie->id_customer;
             }
             $cart->id_lang = (int) $this->context->cookie->id_lang;
             $cart->id_currency = (int) $currency->id;
             $cart->update();
         }
         /* Select an address if not set */
         if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $this->context->cookie->id_customer) {
             $to_update = false;
             if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
                 $to_update = true;
                 $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
                 $to_update = true;
                 $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if ($to_update) {
                 $cart->update();
             }
         }
     }
     if (!isset($cart) || !$cart->id) {
         $cart = new Cart();
         $cart->id_lang = (int) $this->context->cookie->id_lang;
         $cart->id_currency = (int) $this->context->cookie->id_currency;
         $cart->id_guest = (int) $this->context->cookie->id_guest;
         $cart->id_shop_group = (int) $this->context->shop->id_shop_group;
         $cart->id_shop = $this->context->shop->id;
         if ($this->context->cookie->id_customer) {
             $cart->id_customer = (int) $this->context->cookie->id_customer;
             $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             $cart->id_address_invoice = $cart->id_address_delivery;
         } else {
             $cart->id_address_delivery = 0;
             $cart->id_address_invoice = 0;
         }
         // Needed if the merchant want to give a free product to every visitors
         $this->context->cart = $cart;
         CartRule::autoAddToCart($this->context);
     } else {
         $this->context->cart = $cart;
     }
     /* get page name to display it in body id */
     // Are we in a payment module
     $module_name = '';
     if (Validate::isModuleName(Tools::getValue('module'))) {
         $module_name = Tools::getValue('module');
     }
     if (!empty($this->page_name)) {
         $page_name = $this->page_name;
     } elseif (!empty($this->php_self)) {
         $page_name = $this->php_self;
     } elseif (Tools::getValue('fc') == 'module' && $module_name != '' && Module::getInstanceByName($module_name) instanceof PaymentModule) {
         $page_name = 'module-payment-submit';
     } elseif (preg_match('#^' . preg_quote($this->context->shop->physical_uri, '#') . 'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
         $page_name = 'module-' . $m[1] . '-' . str_replace(array('.php', '/'), array('', '-'), $m[2]);
     } else {
         $page_name = Dispatcher::getInstance()->getController();
         $page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name;
     }
     $this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
     $this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
     /* Breadcrumb */
     $navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>';
     $this->context->smarty->assign('navigationPipe', $navigationPipe);
     // Automatically redirect to the canonical URL if needed
     if (!empty($this->php_self) && !Tools::getValue('ajax')) {
         $this->canonicalRedirection($this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id));
     }
     Product::initPricesComputation();
     $display_tax_label = $this->context->country->display_tax_label;
     if (isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) {
         $infos = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
         $country = new Country((int) $infos['id_country']);
         $this->context->country = $country;
         if (Validate::isLoadedObject($country)) {
             $display_tax_label = $country->display_tax_label;
         }
     }
     $languages = Language::getLanguages(true, $this->context->shop->id);
     $meta_language = array();
     foreach ($languages as $lang) {
         $meta_language[] = $lang['iso_code'];
     }
     $compared_products = array();
     if (Configuration::get('PS_COMPARATOR_MAX_ITEM') && isset($this->context->cookie->id_compare)) {
         $compared_products = CompareProduct::getCompareProducts($this->context->cookie->id_compare);
     }
     $this->context->smarty->assign(array('mobile_device' => $this->context->getMobileDevice(), 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $this->context->cookie, 'page_name' => $page_name, 'hide_left_column' => !$this->display_column_left, 'hide_right_column' => !$this->display_column_right, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__, 'base_uri' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__ . (!Configuration::get('PS_REWRITING_SETTINGS') ? 'index.php' : ''), 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $this->context->language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace(array('\'', '\\'), '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => $languages, 'meta_language' => implode(',', $meta_language), 'priceDisplay' => Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer), 'is_logged' => (bool) $this->context->customer->isLogged(), 'is_guest' => (bool) $this->context->customer->isGuest(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'show_taxes' => (int) (Configuration::get('PS_TAX_DISPLAY') == 1 && (int) Configuration::get('PS_TAX')), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE') || !(bool) Group::getCurrent()->show_prices, 'b2b_enable' => (bool) Configuration::get('PS_B2B_ENABLE'), 'request' => $link->getPaginationLink(false, false, false, true), 'PS_STOCK_MANAGEMENT' => Configuration::get('PS_STOCK_MANAGEMENT'), 'quick_view' => (bool) Configuration::get('PS_QUICK_VIEW'), 'shop_phone' => Configuration::get('PS_SHOP_PHONE'), 'compared_products' => is_array($compared_products) ? $compared_products : array(), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     // Add the tpl files directory for mobile
     if ($this->useMobileTheme()) {
         $this->context->smarty->assign(array('tpl_mobile_uri' => _PS_THEME_MOBILE_DIR_));
     }
     // Deprecated
     $this->context->smarty->assign(array('id_currency_cookie' => (int) $currency->id, 'logged' => $this->context->customer->isLogged(), 'customerName' => $this->context->customer->logged ? $this->context->cookie->customer_firstname . ' ' . $this->context->cookie->customer_lastname : false));
     $assign_array = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_);
     // Add the images directory for mobile
     if ($this->useMobileTheme()) {
         $assign_array['img_mobile_dir'] = _THEME_MOBILE_IMG_DIR_;
     }
     // Add the CSS directory for mobile
     if ($this->useMobileTheme()) {
         $assign_array['css_mobile_dir'] = _THEME_MOBILE_CSS_DIR_;
     }
     foreach ($assign_array as $assign_key => $assign_value) {
         if (substr($assign_value, 0, 1) == '/' || $protocol_content == 'https://') {
             $this->context->smarty->assign($assign_key, $protocol_content . Tools::getMediaServer($assign_value) . $assign_value);
         } else {
             $this->context->smarty->assign($assign_key, $assign_value);
         }
     }
     /*
      * These shortcuts are DEPRECATED as of version 1.5.
      * Use the Context to access objects instead.
      * Example: $this->context->cart
      */
     self::$cookie = $this->context->cookie;
     self::$cart = $cart;
     self::$smarty = $this->context->smarty;
     self::$link = $link;
     $defaultCountry = $this->context->country;
     $this->displayMaintenancePage();
     if ($this->restrictedCountry) {
         $this->displayRestrictedCountryPage();
     }
     if (Tools::isSubmit('live_edit') && !$this->checkLiveEditAccess()) {
         Tools::redirect('index.php?controller=404');
     }
     $this->iso = $iso;
     $this->context->cart = $cart;
     $this->context->currency = $currency;
 }
    public function renderForm()
    {
        $back = Tools::safeOutput(Tools::getValue('back', ''));
        if (empty($back)) {
            $back = self::$currentIndex . '&token=' . $this->token;
        }
        $this->toolbar_btn['save-and-stay'] = array('href' => '#', 'desc' => $this->l('Save and Stay'));
        $current_object = $this->loadObject(true);
        // All the filter are prefilled with the correct information
        $customer_filter = '';
        if (Validate::isUnsignedId($current_object->id_customer) && ($customer = new Customer($current_object->id_customer)) && Validate::isLoadedObject($customer)) {
            $customer_filter = $customer->firstname . ' ' . $customer->lastname . ' (' . $customer->email . ')';
        }
        $gift_product_filter = '';
        if (Validate::isUnsignedId($current_object->gift_product) && ($product = new Product($current_object->gift_product, false, $this->context->language->id)) && Validate::isLoadedObject($product)) {
            $gift_product_filter = !empty($product->reference) ? $product->reference : $product->name;
        }
        $reduction_product_filter = '';
        if (Validate::isUnsignedId($current_object->reduction_product) && ($product = new Product($current_object->reduction_product, false, $this->context->language->id)) && Validate::isLoadedObject($product)) {
            $reduction_product_filter = !empty($product->reference) ? $product->reference : $product->name;
        }
        $product_rule_groups = $this->getProductRuleGroupsDisplay($current_object);
        $attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
        $currencies = Currency::getCurrencies();
        $languages = Language::getLanguages();
        $countries = $current_object->getAssociatedRestrictions('country', true, true);
        $groups = $current_object->getAssociatedRestrictions('group', false, true);
        $shops = $current_object->getAssociatedRestrictions('shop', false, false);
        $cart_rules = $current_object->getAssociatedRestrictions('cart_rule', false, true);
        $carriers = $current_object->getAssociatedRestrictions('carrier', true, false);
        foreach ($carriers as &$carriers2) {
            foreach ($carriers2 as &$carrier) {
                foreach ($carrier as $field => &$value) {
                    if ($field == 'name' && $value == '0') {
                        $value = Configuration::get('PS_SHOP_NAME');
                    }
                }
            }
        }
        $gift_product_select = '';
        $gift_product_attribute_select = '';
        if ((int) $current_object->gift_product) {
            $search_products = $this->searchProducts($gift_product_filter);
            foreach ($search_products['products'] as $product) {
                $gift_product_select .= '
				<option value="' . $product['id_product'] . '" ' . ($product['id_product'] == $current_object->gift_product ? 'selected="selected"' : '') . '>
					' . $product['name'] . (count($product['combinations']) == 0 ? ' - ' . $product['formatted_price'] : '') . '
				</option>';
                if (count($product['combinations'])) {
                    $gift_product_attribute_select .= '<select class="id_product_attribute" id="ipa_' . $product['id_product'] . '" name="ipa_' . $product['id_product'] . '">';
                    foreach ($product['combinations'] as $combination) {
                        $gift_product_attribute_select .= '
						<option ' . ($combination['id_product_attribute'] == $current_object->gift_product_attribute ? 'selected="selected"' : '') . ' value="' . $combination['id_product_attribute'] . '">
							' . $combination['attributes'] . ' - ' . $combination['formatted_price'] . '
						</option>';
                    }
                    $gift_product_attribute_select .= '</select>';
                }
            }
        }
        $product = new Product($current_object->gift_product);
        $this->context->smarty->assign(array('show_toolbar' => true, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => $this->toolbar_scroll, 'title' => array($this->l('Payment: '), $this->l('Cart Rules')), 'defaultDateFrom' => date('Y-m-d H:00:00'), 'defaultDateTo' => date('Y-m-d H:00:00', strtotime('+1 month')), 'customerFilter' => $customer_filter, 'giftProductFilter' => $gift_product_filter, 'gift_product_select' => $gift_product_select, 'gift_product_attribute_select' => $gift_product_attribute_select, 'reductionProductFilter' => $reduction_product_filter, 'defaultCurrency' => Configuration::get('PS_CURRENCY_DEFAULT'), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'languages' => $languages, 'currencies' => $currencies, 'countries' => $countries, 'carriers' => $carriers, 'groups' => $groups, 'shops' => $shops, 'cart_rules' => $cart_rules, 'product_rule_groups' => $product_rule_groups, 'product_rule_groups_counter' => count($product_rule_groups), 'attribute_groups' => $attribute_groups, 'currentIndex' => self::$currentIndex, 'currentToken' => $this->token, 'currentObject' => $current_object, 'currentTab' => $this, 'hasAttribute' => $product->hasAttributes()));
        $this->content .= $this->createTemplate('form.tpl')->fetch();
        $this->addJqueryUI('ui.datepicker');
        return parent::renderForm();
    }
 /**
  * AdminController::renderForm() override
  * @see AdminController::renderForm()
  */
 public function renderForm()
 {
     /** @var Warehouse $obj */
     // loads current warehouse
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     // gets the manager of the warehouse
     $query = new DbQuery();
     $query->select('id_employee, CONCAT(lastname," ",firstname) as name');
     $query->from('employee');
     $query->where('active = 1');
     $employees_array = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
     // sets the title of the toolbar
     if (Tools::isSubmit('add' . $this->table)) {
         $this->toolbar_title = $this->l('Stock: Create a warehouse');
     } else {
         $this->toolbar_title = $this->l('Stock: Warehouse management');
     }
     $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'];
     }
     // sets the fields of the form
     $this->fields_form = array('legend' => array('title' => $this->l('Warehouse information'), 'icon' => 'icon-pencil'), 'input' => array(array('type' => 'hidden', 'name' => 'id_address'), array('type' => 'text', 'label' => $this->l('Reference'), 'name' => 'reference', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Reference for this warehouse.')), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 45, 'required' => true, 'hint' => array($this->l('Name of this warehouse.'), $this->l('Invalid characters:') . ' !&lt;&gt;,;?=+()@#"�{}_$%:')), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone', 'maxlength' => 16, 'hint' => $this->l('Phone number for this warehouse.'), 'required' => in_array('phone', $required_fields)), array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'required' => in_array('phone_mobile', $required_fields), 'maxlength' => 16, 'hint' => $this->l('Mobile phone number for this supplier.')), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address', 'maxlength' => 128, 'required' => true), array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'maxlength' => 128, 'hint' => $this->l('Complementary address (optional).'), 'required' => in_array('address2', $required_fields)), array('type' => 'text', 'label' => $this->l('Zip/postal code'), 'name' => 'postcode', 'maxlength' => 12, 'required' => in_array('postcode', $required_fields)), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', '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'), 'hint' => $this->l('Country of location of the warehouse.')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => true, 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Manager'), 'name' => 'id_employee', 'required' => true, 'options' => array('query' => $employees_array, 'id' => 'id_employee', 'name' => 'name')), array('type' => 'swap', 'label' => $this->l('Carriers'), 'name' => 'ids_carriers', 'required' => false, 'multiple' => true, 'options' => array('query' => Carrier::getCarriers($this->context->language->id, false, false, false, null, Carrier::ALL_CARRIERS), 'id' => 'id_reference', 'name' => 'name'), 'hint' => array($this->l('Associated carriers.'), $this->l('You can choose which carriers can ship orders from particular warehouses.'), $this->l('If you do not select any carrier, all the carriers will be able to ship from this warehouse.')), 'desc' => $this->l('If no carrier is selected, all the carriers will be allowed to ship from this warehouse. Use CTRL+Click to select more than one carrier.'))));
     // Shop Association
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso', 'disable_shared' => Shop::SHARE_STOCK);
     }
     // if it is still possible to change currency valuation and management type
     if (Tools::isSubmit('addwarehouse') || Tools::isSubmit('submitAddwarehouse')) {
         // adds input management type
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Management type'), 'hint' => $this->l('Inventory valuation method. Be careful! You won\'t be able to change this value later!'), 'name' => 'management_type', 'required' => true, 'options' => array('query' => array(array('id' => 'WA', 'name' => $this->l('Weighted Average')), array('id' => 'FIFO', 'name' => $this->l('First In, First Out')), array('id' => 'LIFO', 'name' => $this->l('Last In, First Out'))), 'id' => 'id', 'name' => 'name'));
         // adds input valuation currency
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Stock valuation currency'), 'hint' => $this->l('Be careful! You won\'t be able to change this value later!'), 'name' => 'id_currency', 'required' => true, 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name'));
     } else {
         // else hide input
         $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'management_type');
         $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'id_currency');
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     $address = null;
     // loads current address for this warehouse - if possible
     if ($obj->id_address > 0) {
         $address = new Address($obj->id_address);
     }
     // loads current shops associated with this warehouse
     $shops = $obj->getShops();
     $ids_shop = array();
     foreach ($shops as $shop) {
         $ids_shop[] = $shop['id_shop'];
     }
     // loads current carriers associated with this warehouse
     $carriers = $obj->getCarriers(true);
     // if an address is available : force specific fields values
     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 {
         // loads default country
         $this->fields_value = array('id_address' => 0, 'id_country' => Configuration::get('PS_COUNTRY_DEFAULT'));
     }
     // loads shops and carriers
     $this->fields_value['ids_shops[]'] = $ids_shop;
     $this->fields_value['ids_carriers'] = $carriers;
     if (!Validate::isLoadedObject($obj)) {
         $this->fields_value['id_currency'] = (int) Configuration::get('PS_CURRENCY_DEFAULT');
     }
     return parent::renderForm();
 }
示例#26
0
 function getDocBody()
 {
     // Get currencies
     $currencies = Currency::getCurrencies();
     // Get categories
     $categories = Category::getCategories($this->id_lang, true, false);
     // Generate XML here
     $xml = new DomDocument('1.0', 'UTF-8');
     $catalog = $xml->createElement("yml_catalog");
     $catalog->setAttribute("date", date('Y-m-d H:i'));
     $shop = $xml->createElement("shop");
     $elem = $xml->createElement("name");
     $elem->appendChild($xml->createCDATASection(html_entity_decode(Configuration::get('PS_SHOP_NAME'))));
     $shop->appendChild($elem);
     $elem = $xml->createElement("company");
     $elem->appendChild($xml->createCDATASection(Configuration::get('YAMARKET_COMPANY_NAME')));
     $shop->appendChild($elem);
     $shop->appendChild($xml->createElement("url", $this->proto_prefix . __PS_BASE_URI__));
     $shop->appendChild($xml->createElement("platform", "PrestaShop"));
     $elem = $xml->createElement("currencies");
     foreach ($currencies as $cur) {
         if ($cur['iso_code'] != 'GBP') {
             if ($cur['iso_code'] == 'RUB') {
                 $cur['iso_code'] = 'RUR';
             }
             $subelem = $xml->createElement("currency");
             $subelem->setAttribute("id", $cur['iso_code']);
             $subelem->setAttribute("rate", 1 / $cur['conversion_rate']);
             $elem->appendChild($subelem);
         }
     }
     $shop->appendChild($elem);
     $elem = $xml->createElement("categories");
     foreach ($categories as $category) {
         if ($category['id_category'] == 1) {
             continue;
         }
         $subelem = $xml->createElement("category", $category['name']);
         $subelem->setAttribute("id", $category['id_category']);
         if (array_key_exists('id_parent', $category) && $category['id_parent'] != 1) {
             $subelem->setAttribute("parentId", $category['id_parent']);
         }
         $elem->appendChild($subelem);
     }
     $shop->appendChild($elem);
     $local_delivery_price = Configuration::get('YAMARKET_DELIVERY_PRICE');
     if ($local_delivery_price or $local_delivery_price === "0") {
         $shop->appendChild($xml->createElement("local_delivery_cost", $local_delivery_price));
     }
     $catalog->appendChild($shop);
     $xml->appendChild($catalog);
     return $xml;
 }
示例#27
0
$smarty->register_function('convertPriceWithoutDisplay', array('Product', 'productPriceWithoutDisplay'));
$smarty->register_function('convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
$smarty->register_function('displayWtPrice', array('Product', 'displayWtPrice'));
$smarty->register_function('displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
$smarty->register_function('displayPrice', array('Tools', 'displayPriceSmarty'));
$smarty->assign(Tools::getMetaTags(intval($cookie->id_lang)));
$smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
/* Breadcrumb */
$navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>';
$smarty->assign('navigationPipe', $navigationPipe);
/* Server Params */
$server_host = Tools::getHttpHost(false, true);
$protocol = 'http://';
$protocol_ssl = 'https://';
$protocol_link = Configuration::get('PS_SSL_ENABLED') ? $protocol_ssl : $protocol;
$protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? $protocol_ssl : $protocol;
define('_PS_BASE_URL_', $protocol . $server_host);
Product::initPricesComputation();
if (!Configuration::get('PS_THEME_V11')) {
    define('_PS_BASE_URL_SSL_', $protocol_ssl . $server_host);
    $smarty->assign(array('base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . $server_host . __PS_BASE_URI__, 'content_dir' => $protocol_content . $server_host . __PS_BASE_URI__, 'img_ps_dir' => $protocol_content . $server_host . _PS_IMG_, 'img_cat_dir' => $protocol_content . $server_host . _THEME_CAT_DIR_, 'img_lang_dir' => $protocol_content . $server_host . _THEME_LANG_DIR_, 'img_prod_dir' => $protocol_content . $server_host . _THEME_PROD_DIR_, 'img_manu_dir' => $protocol_content . $server_host . _THEME_MANU_DIR_, 'img_sup_dir' => $protocol_content . $server_host . _THEME_SUP_DIR_, 'img_ship_dir' => $protocol_content . $server_host . _THEME_SHIP_DIR_, 'img_col_dir' => $protocol_content . $server_host . _THEME_COL_DIR_, 'img_dir' => $protocol_content . $server_host . _THEME_IMG_DIR_, 'css_dir' => $protocol_content . $server_host . _THEME_CSS_DIR_, 'js_dir' => $protocol_content . $server_host . _THEME_JS_DIR_, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'pic_dir' => $protocol_content . $server_host . _THEME_PROD_PIC_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . htmlentities($_SERVER['REQUEST_URI']), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'cart_qties' => intval($cart->nbProducts()), 'cart' => $cart, 'currencies' => Currency::getCurrencies(), 'id_currency_cookie' => intval($currency->id), 'currency' => $currency, 'cookie' => $cookie, 'languages' => Language::getLanguages(), 'logged' => $cookie->isLogged(), 'page_name' => $page_name, 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false, 'priceDisplay' => intval($cookie->id_customer ? Group::getPriceDisplayMethod(intval($cookie->id_customer)) : Group::getDefaultPriceDisplayMethod()), 'roundMode' => intval(Configuration::get('PS_PRICE_ROUND_MODE'))));
} else {
    $protocol = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
    $smarty->assign(array('base_dir' => __PS_BASE_URI__, 'base_dir_ssl' => Tools::getHttpHost(true, true) . __PS_BASE_URI__, 'content_dir' => __PS_BASE_URI__, 'protocol' => $protocol, 'img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . htmlentities($_SERVER['REQUEST_URI']), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'cart_qties' => intval($cart->nbProducts()), 'cart' => $cart, 'currencies' => Currency::getCurrencies(), 'id_currency_cookie' => intval($currency->id), 'currency' => $currency, 'cookie' => $cookie, 'languages' => Language::getLanguages(), 'logged' => $cookie->isLogged(), 'priceDisplay' => intval($cookie->id_customer ? Group::getPriceDisplayMethod(intval($cookie->id_customer)) : Group::getDefaultPriceDisplayMethod()), 'page_name' => $page_name, 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false, 'roundMode' => intval(Configuration::get('PS_PRICE_ROUND_MODE'))));
}
/* Display a maintenance page if shop is closed */
if (isset($maintenance) and (!isset($_SERVER['REMOTE_ADDR']) or !in_array($_SERVER['REMOTE_ADDR'], explode(',', Configuration::get('PS_MAINTENANCE_IP'))))) {
    header('HTTP/1.1 503 temporarily overloaded');
    $smarty->display(_PS_THEME_DIR_ . 'maintenance.tpl');
    exit;
}
示例#28
0
    public static function indexProductPrices($id_product, $smart = true)
    {
        static $groups = null;
        if (is_null($groups)) {
            $groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_group FROM `' . _DB_PREFIX_ . 'group_reduction`');
            if (!$groups) {
                $groups = array();
            }
        }
        $shop_list = Shop::getShops(false, null, true);
        foreach ($shop_list as $id_shop) {
            static $currency_list = null;
            if (is_null($currency_list)) {
                $currency_list = Currency::getCurrencies(false, 1, new Shop($id_shop));
            }
            $min_price = array();
            $max_price = array();
            if ($smart) {
                Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'layered_price_index` WHERE `id_product` = ' . (int) $id_product . ' AND `id_shop` = ' . (int) $id_shop);
            }
            if (Configuration::get('PS_LAYERED_FILTER_PRICE_USETAX')) {
                $max_tax_rate = Db::getInstance()->getValue('
					SELECT max(t.rate) max_rate
					FROM `' . _DB_PREFIX_ . 'product_shop` p
					LEFT JOIN `' . _DB_PREFIX_ . 'tax_rules_group` trg ON (trg.id_tax_rules_group = p.id_tax_rules_group AND p.id_shop = ' . (int) $shop_list . ')
					LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (tr.id_tax_rules_group = trg.id_tax_rules_group)
					LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.id_tax = tr.id_tax AND t.active = 1)
					WHERE id_product = ' . (int) $id_product . '
					GROUP BY id_product');
            } else {
                $max_tax_rate = 0;
            }
            $product_min_prices = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT id_shop, id_currency, id_country, id_group, from_quantity
			FROM `' . _DB_PREFIX_ . 'specific_price`
			WHERE id_product = ' . (int) $id_product);
            // Get min price
            foreach ($currency_list as $currency) {
                $price = Product::priceCalculation($id_shop, (int) $id_product, null, null, null, null, $currency['id_currency'], null, null, false, 6, false, true, true, $specific_price_output, true);
                if (!isset($max_price[$currency['id_currency']])) {
                    $max_price[$currency['id_currency']] = 0;
                }
                if (!isset($min_price[$currency['id_currency']])) {
                    $min_price[$currency['id_currency']] = null;
                }
                if ($price > $max_price[$currency['id_currency']]) {
                    $max_price[$currency['id_currency']] = $price;
                }
                if ($price == 0) {
                    continue;
                }
                if (is_null($min_price[$currency['id_currency']]) || $price < $min_price[$currency['id_currency']]) {
                    $min_price[$currency['id_currency']] = $price;
                }
            }
            foreach ($product_min_prices as $specific_price) {
                foreach ($currency_list as $currency) {
                    if ($specific_price['id_currency'] && $specific_price['id_currency'] != $currency['id_currency']) {
                        continue;
                    }
                    $price = Product::priceCalculation($specific_price['id_shop'] == 0 ? null : (int) $specific_price['id_shop'], (int) $id_product, null, $specific_price['id_country'] == 0 ? null : $specific_price['id_country'], null, null, $currency['id_currency'], $specific_price['id_group'] == 0 ? null : $specific_price['id_group'], $specific_price['from_quantity'], false, 6, false, true, true, $specific_price_output, true);
                    if (!isset($max_price[$currency['id_currency']])) {
                        $max_price[$currency['id_currency']] = 0;
                    }
                    if (!isset($min_price[$currency['id_currency']])) {
                        $min_price[$currency['id_currency']] = null;
                    }
                    if ($price > $max_price[$currency['id_currency']]) {
                        $max_price[$currency['id_currency']] = $price;
                    }
                    if ($price == 0) {
                        continue;
                    }
                    if (is_null($min_price[$currency['id_currency']]) || $price < $min_price[$currency['id_currency']]) {
                        $min_price[$currency['id_currency']] = $price;
                    }
                }
            }
            foreach ($groups as $group) {
                foreach ($currency_list as $currency) {
                    $price = Product::priceCalculation(null, (int) $id_product, null, null, null, null, (int) $currency['id_currency'], (int) $group['id_group'], null, false, 6, false, true, true, $specific_price_output, true);
                    if (!isset($max_price[$currency['id_currency']])) {
                        $max_price[$currency['id_currency']] = 0;
                    }
                    if (!isset($min_price[$currency['id_currency']])) {
                        $min_price[$currency['id_currency']] = null;
                    }
                    if ($price > $max_price[$currency['id_currency']]) {
                        $max_price[$currency['id_currency']] = $price;
                    }
                    if ($price == 0) {
                        continue;
                    }
                    if (is_null($min_price[$currency['id_currency']]) || $price < $min_price[$currency['id_currency']]) {
                        $min_price[$currency['id_currency']] = $price;
                    }
                }
            }
            $values = array();
            foreach ($currency_list as $currency) {
                $values[] = '(' . (int) $id_product . ',
					' . (int) $currency['id_currency'] . ',
					' . $id_shop . ',
					' . (int) $min_price[$currency['id_currency']] . ',
					' . (int) Tools::ps_round($max_price[$currency['id_currency']] * (100 + $max_tax_rate) / 100, 0) . ')';
            }
            Db::getInstance()->execute('
				INSERT INTO `' . _DB_PREFIX_ . 'layered_price_index` (id_product, id_currency, id_shop, price_min, price_max)
				VALUES ' . implode(',', $values) . '
				ON DUPLICATE KEY UPDATE id_product = id_product # avoid duplicate keys');
        }
    }
示例#29
0
 private function _getCurrencySelectHTML($i)
 {
     $currencies = Currency::getCurrencies();
     $curr = explode(";", Configuration::get($this->name . '_curr'));
     $html = '<select name="currency_' . $i . '" style="width:55px">';
     $html .= '<option value="all">ALL</option>';
     foreach ($currencies as $currency) {
         $html .= '<option value="' . $currency['id_currency'] . '"' . (isset($curr[$i - 1]) && $curr[$i - 1] == $currency['id_currency'] ? 'selected="selected"' : '') . '>' . strtoupper($currency['iso_code']) . '</option>';
     }
     return $html .= '</select>';
 }
示例#30
0
 public function generate($cron = false)
 {
     self::setCurrency();
     include 'classes/ymlCatalog.php';
     //Язык по умолчанию
     $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     //Валюта по умолчанию
     $currency_default = new Currency($this->context->cookie->id_currency);
     $this->currency_iso = $currency_default->iso_code;
     //Адрес магазина
     $shop_url = 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__;
     //Категории для экспорта
     $yamarket_с_categories = unserialize(Configuration::get('yamarket_с_categories'));
     //$yamarket_с_suppliers = unserialize(Configuration::get('yamarket_с_supplier'));
     $yamarket_с_combinations = Configuration::get('yamarket_с_combinations');
     $this->yamarket_с_availability = Configuration::get('yamarket_с_availability');
     $this->yamarket_с_shipping = unserialize(Configuration::get('yamarket_с_shipping'));
     //создаем новый магазин
     $catalog = new ymlCatalog();
     $catalog->gzip = Configuration::get('yamarket_с_gzip');
     $shop = new ymlShop();
     $shop->name = Configuration::get('yamarket_с_shop');
     $shop->company = Configuration::get('yamarket_с_company');
     $shop->url = $shop_url;
     $shop->platform = 'PrestaShop';
     $shop->version = _PS_VERSION_;
     $shop->agency = 'PrestaLab';
     $shop->email = '*****@*****.**';
     //Валюты
     $shop->startTag(ymlCurrency::$collectionName);
     if (Configuration::get('yamarket_с_currencies')) {
         $currencies = Currency::getCurrencies();
         foreach ($currencies as $currency) {
             $shop->add(new ymlCurrency($currency['iso_code'], (double) $currency['conversion_rate']));
         }
         unset($currencies);
     } else {
         $shop->add(new ymlCurrency($currency_default->iso_code, (double) $currency_default->conversion_rate));
     }
     $shop->endTag(ymlCurrency::$collectionName);
     //Категории
     $categories = Category::getCategories($id_lang, false, false);
     $shop->startTag(ymlCategory::$collectionName);
     foreach ($categories as $category) {
         if ($category['active'] && in_array($category['id_category'], $yamarket_с_categories)) {
             $shop->add(new ymlCategory($category['id_category'], $category['name'], $category['id_parent']));
         }
     }
     $shop->endTag(ymlCategory::$collectionName);
     //Стоимость доставки
     $shop->addString('<local_delivery_cost>' . Configuration::get('yamarket_с_shippingcost') . '</local_delivery_cost>');
     //Товары
     $shop->startTag(ymlOffer::$collectionName);
     foreach ($categories as $category) {
         if ($category['active'] && in_array($category['id_category'], $yamarket_с_categories)) {
             $category_object = new Category($category['id_category']);
             $products = $category_object->getProducts($id_lang, 1, 10000);
             if ($products) {
                 foreach ($products as $product) {
                     if ($product['id_category_default'] != $category['id_category']) {
                         continue;
                     }
                     //						if (count($yamarket_с_suppliers)&&(!in_array($product['id_supplier'], $yamarket_с_suppliers)))
                     //							continue;
                     //Для комбинаций
                     if ($yamarket_с_combinations) {
                         $product_object = new Product($product['id_product'], false, $id_lang);
                         $combinations = $product_object->getAttributeCombinations($id_lang);
                     } else {
                         $combinations = false;
                     }
                     if (is_array($combinations) && count($combinations) > 0) {
                         $comb_array = array();
                         foreach ($combinations as $combination) {
                             $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
                             $comb_array[$combination['id_product_attribute']]['price'] = Product::getPriceStatic($product['id_product'], true, $combination['id_product_attribute']);
                             $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
                             $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
                             $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity'];
                             $comb_array[$combination['id_product_attribute']]['attributes'][$combination['group_name']] = $combination['attribute_name'];
                             $comb_array[$combination['id_product_attribute']]['oldprice'] = $product['orderprice'] + $combination['price'];
                             if (!isset($comb_array[$combination['id_product_attribute']]['comb_url'])) {
                                 $comb_array[$combination['id_product_attribute']]['comb_url'] = '';
                             }
                             $comb_array[$combination['id_product_attribute']]['comb_url'] .= '/' . (self::combinationUrlPrepare($combination['group_name']) . '-' . self::combinationUrlPrepare($combination['attribute_name']));
                         }
                         foreach ($comb_array as $combination) {
                             self::_addProduct($shop, $product, $combination);
                         }
                     } else {
                         self::_addProduct($shop, $product);
                     }
                 }
             }
             unset($product);
         }
     }
     unset($categories);
     $shop->endTag(ymlOffer::$collectionName);
     $catalog->add($shop);
     if ($cron) {
         if ($fp = fopen(_PS_UPLOAD_DIR_ . 'yml.' . $this->context->shop->id . '.xml' . ($catalog->gzip ? '.gz' : ''), 'w')) {
             fwrite($fp, $catalog->generate());
             fclose($fp);
         }
     } else {
         if ($catalog->gzip) {
             header('Content-type:application/x-gzip');
             header('Content-Disposition: attachment; filename=yml.' . $this->context->shop->id . '.xml.gz');
         } else {
             header('Content-type:application/xml;  charset=utf-8');
         }
         echo $catalog->generate();
     }
 }