Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl admin-dev/themes/default/template/controllers/modules_positions/form.tpl admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl admin-dev/themes/default/template/controllers/products/input_text_lang.tpl admin-dev/themes/default/template/controllers/products/shipping.tpl admin-dev/themes/default/template/controllers/shipping/content.tpl admin-dev/themes/default/template/helpers/form/form.tpl admin-dev/themes/default/template/helpers/list/list_header.tpl admin-dev/themes/default/template/toolbar.tpl classes/helper/HelperList.php controllers/admin/AdminCategoriesController.php controllers/admin/AdminManufacturersController.php controllers/admin/AdminModulesPositionsController.php controllers/admin/AdminPerformanceController.php controllers/admin/AdminStockInstantStateController.php css/admin.css js/admin-products.js js/admin.js
This commit is contained in:
@@ -52,6 +52,8 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
'count_values' => array(
|
||||
'title' => $this->l('Values count'),
|
||||
'align' => 'center',
|
||||
'orderby' => false,
|
||||
'search' => false
|
||||
),
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
@@ -322,6 +324,11 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
'label' => $this->l('Current texture:'),
|
||||
'name' => 'current_texture'
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'closediv',
|
||||
'name' => ''
|
||||
);
|
||||
|
||||
$this->fields_form['submit'] = array(
|
||||
'title' => $this->l('Save '),
|
||||
|
||||
@@ -0,0 +1,933 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminCarrierWizardControllerCore extends AdminController
|
||||
{
|
||||
protected $wizard_access;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->display = 'view';
|
||||
$this->table = 'carrier';
|
||||
$this->identifier = 'id_carrier';
|
||||
$this->className = 'Carrier';
|
||||
$this->lang = false;
|
||||
$this->deleted = true;
|
||||
$this->step_number = 0;
|
||||
|
||||
$this->fieldImageSettings = array(
|
||||
'name' => 'logo',
|
||||
'dir' => 's'
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, Tab::getIdFromClassName('AdminCarriers'));
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJqueryPlugin('smartWizard');
|
||||
$this->addJqueryPlugin('typewatch');
|
||||
$this->addJs(_PS_JS_DIR_.'admin_carrier_wizard.js');
|
||||
}
|
||||
|
||||
public function initWizard()
|
||||
{
|
||||
$this->wizard_steps = array(
|
||||
'name' => 'carrier_wizard',
|
||||
'steps' => array(
|
||||
array(
|
||||
'title' => $this->l('General settings'),
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('Shipping locations and costs'),
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('Size, weight, and group access'),
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('Summary'),
|
||||
),
|
||||
|
||||
));
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
$multistore_step = array(
|
||||
array(
|
||||
'title' => $this->l('MultiStore'),
|
||||
'desc' => $this->l('MultiStore'),
|
||||
)
|
||||
);
|
||||
array_splice($this->wizard_steps['steps'], 1, 0, $multistore_step);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
$this->initWizard();
|
||||
|
||||
if (Tools::getValue('id_carrier') && $this->tabAccess['edit'])
|
||||
$carrier = $this->loadObject();
|
||||
elseif ($this->tabAccess['add'])
|
||||
$carrier = new Carrier();
|
||||
|
||||
if ((!$this->tabAccess['edit'] && Tools::getValue('id_carrier')) || (!$this->tabAccess['add'] && !Tools::getValue('id_carrier')))
|
||||
{
|
||||
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
|
||||
return ;
|
||||
}
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$this->tpl_view_vars = array(
|
||||
'currency_sign' => $currency->sign,
|
||||
'PS_WEIGHT_UNIT' => Configuration::get('PS_WEIGHT_UNIT'),
|
||||
'enableAllSteps' => Validate::isLoadedObject($carrier),
|
||||
'wizard_steps' => $this->wizard_steps,
|
||||
'validate_url' => $this->context->link->getAdminLink('AdminCarrierWizard'),
|
||||
'carrierlist_url' => $this->context->link->getAdminLink('AdminCarriers').'&conf='.((int)Validate::isLoadedObject($carrier) ? 4 : 3),
|
||||
'wizard_contents' => array(
|
||||
'contents' => array(
|
||||
0 => $this->renderStepOne($carrier),
|
||||
1 => $this->renderStepThree($carrier),
|
||||
2 => $this->renderStepFour($carrier),
|
||||
3 => $this->renderStepFive($carrier),
|
||||
)),
|
||||
'labels' => array('next' => $this->l('Next'), 'previous' => $this->l('Previous'), 'finish' => $this->l('Finish'))
|
||||
);
|
||||
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
array_splice($this->tpl_view_vars['wizard_contents']['contents'], 1, 0, array(0 => $this->renderStepTwo($carrier)));
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'carrier_logo' => (Validate::isLoadedObject($carrier) && file_exists(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg') ? _THEME_SHIP_DIR_.$carrier->id.'.jpg' : false)
|
||||
));
|
||||
$this->content .= $this->createTemplate('logo.tpl')->fetch();
|
||||
$this->addjQueryPlugin(array('ajaxfileupload'));
|
||||
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
public function initToolbarTitle()
|
||||
{
|
||||
$bread_extended = array_unique($this->breadcrumbs);
|
||||
|
||||
if (Tools::getValue('id_carrier'))
|
||||
$bread_extended[1] = $this->l('Edit');
|
||||
else
|
||||
$bread_extended[1] = $this->l('Add new');
|
||||
|
||||
$this->toolbar_title = $bread_extended;
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
$this->toolbar_btn['back']['href'] = $this->context->link->getAdminLink('AdminCarriers');
|
||||
}
|
||||
|
||||
public function renderStepOne($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_general',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Carrier name:'),
|
||||
'name' => 'name',
|
||||
'size' => 25,
|
||||
'required' => true,
|
||||
'hint' => sprintf($this->l('Allowed characters: letters, spaces and %s'), '().-'),
|
||||
'desc' => array(
|
||||
$this->l('Carrier name displayed during checkout'),
|
||||
$this->l('For in-store pickup, enter 0 to replace the carrier name with your shop name.')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Transit time:'),
|
||||
'name' => 'delay',
|
||||
'lang' => true,
|
||||
'required' => true,
|
||||
'size' => 41,
|
||||
'maxlength' => 128,
|
||||
'desc' => $this->l('Estimated delivery time will be displayed during checkout.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Speed grade:'),
|
||||
'name' => 'grade',
|
||||
'required' => false,
|
||||
'size' => 1,
|
||||
'desc' => $this->l('Enter "0" for a longest shipping delay, or "9" for the shortest shipping delay.')
|
||||
),
|
||||
array(
|
||||
'type' => 'logo',
|
||||
'label' => $this->l('Logo:'),
|
||||
'name' => 'logo',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Tracking URL:'),
|
||||
'name' => 'url',
|
||||
'size' => 40,
|
||||
'desc' => $this->l('Delivery tracking URL: Type \'@\' where the tracking number should appear. It will then be automatically replaced by the tracking number.')
|
||||
),
|
||||
)),
|
||||
);
|
||||
|
||||
$tpl_vars = array('max_image_size' => (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE') / 1024 / 1024);
|
||||
$fields_value = $this->getStepOneFieldsValues($carrier);
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value, $tpl_vars);
|
||||
}
|
||||
|
||||
public function renderStepTwo($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_shops',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'shop',
|
||||
'label' => $this->l('Shop association:'),
|
||||
'name' => 'checkBoxShopAsso',
|
||||
),
|
||||
))
|
||||
);
|
||||
$fields_value = $this->getStepTwoFieldsValues($carrier);
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value);
|
||||
}
|
||||
|
||||
public function renderStepThree($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_ranges',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Shipping and handling:'),
|
||||
'name' => 'shipping_handling',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'shipping_handling_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'shipping_handling_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'desc' => $this->l('Include the shipping and handling costs in the carrier price.')
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Apply shipping cost:'),
|
||||
'name' => 'is_free',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'is_free_off',
|
||||
'value' => 0,
|
||||
'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" />'
|
||||
),
|
||||
array(
|
||||
'id' => 'is_free_on',
|
||||
'value' => 1,
|
||||
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" />'
|
||||
)
|
||||
),
|
||||
'desc' => $this->l('Apply both regular shipping cost and product-specific shipping costs.')
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Billing:'),
|
||||
'name' => 'shipping_method',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'br' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'billing_price',
|
||||
'value' => Carrier::SHIPPING_METHOD_PRICE,
|
||||
'label' => $this->l('According to total price')
|
||||
),
|
||||
array(
|
||||
'id' => 'billing_weight',
|
||||
'value' => Carrier::SHIPPING_METHOD_WEIGHT,
|
||||
'label' => $this->l('According to total weight')
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Tax:'),
|
||||
'name' => 'id_tax_rules_group',
|
||||
'options' => array(
|
||||
'query' => TaxRulesGroup::getTaxRulesGroups(true),
|
||||
'id' => 'id_tax_rules_group',
|
||||
'name' => 'name',
|
||||
'default' => array(
|
||||
'label' => $this->l('No Tax'),
|
||||
'value' => 0
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'zone',
|
||||
'name' => 'zones'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Out-of-range behavior:'),
|
||||
'name' => 'range_behavior',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 0,
|
||||
'name' => $this->l('Apply the cost of the highest defined range')
|
||||
),
|
||||
array(
|
||||
'id' => 1,
|
||||
'name' => $this->l('Disable carrier')
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Out-of-range behavior occurs when no defined range matches the customer\'s cart (e.g. when the weight of the cart is greater than the highest weight limit defined by the weight ranges)')
|
||||
)
|
||||
),
|
||||
|
||||
));
|
||||
|
||||
$tpl_vars = array();
|
||||
$tpl_vars['PS_WEIGHT_UNIT'] = Configuration::get('PS_WEIGHT_UNIT');
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$tpl_vars['currency_sign'] = $currency->sign;
|
||||
|
||||
$fields_value = $this->getStepThreeFieldsValues($carrier);
|
||||
|
||||
$this->getTplRangesVarsAndValues($carrier, $tpl_vars, $fields_value);
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value, $tpl_vars);
|
||||
}
|
||||
|
||||
public function renderStepFour($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_conf',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximum package height ('.Configuration::get('PS_DIMENSION_UNIT').'):'),
|
||||
'name' => 'max_height',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum height managed by this carrier. Set the value to "0", or leave this field blank to ignore.').' '.$this->l('The value must be an integer
|
||||
.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximum package width ('.Configuration::get('PS_DIMENSION_UNIT').'):'),
|
||||
'name' => 'max_width',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum width managed by this carrier. Set the value to "0", or leave this field blank to ignore.').' '.$this->l('The value must be an integer
|
||||
.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximum package depth ('.Configuration::get('PS_DIMENSION_UNIT').'):'),
|
||||
'name' => 'max_depth',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum depth managed by this carrier. Set the value to "0", or leave this field blank to ignore.').' '.$this->l('The value must be an integer
|
||||
.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximum package weight ('.Configuration::get('PS_WEIGHT_UNIT').'):'),
|
||||
'name' => 'max_weight',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum weight managed by this carrier. Set the value to "0", or leave this field blank to ignore.')
|
||||
),
|
||||
array(
|
||||
'type' => 'group',
|
||||
'label' => $this->l('Group access:'),
|
||||
'name' => 'groupBox',
|
||||
'values' => Group::getGroups(Context::getContext()->language->id),
|
||||
'desc' => $this->l('Mark the groups that are allowed access to this carrier.')
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
$fields_value = $this->getStepFourFieldsValues($carrier);
|
||||
|
||||
// Added values of object Group
|
||||
$carrier_groups = $carrier->getGroups();
|
||||
$carrier_groups_ids = array();
|
||||
if (is_array($carrier_groups))
|
||||
foreach ($carrier_groups as $carrier_group)
|
||||
$carrier_groups_ids[] = $carrier_group['id_group'];
|
||||
|
||||
$groups = Group::getGroups($this->context->language->id);
|
||||
|
||||
foreach ($groups as $group)
|
||||
$fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], (in_array($group['id_group'], $carrier_groups_ids) || empty($carrier_groups_ids) && !$carrier->id));
|
||||
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value);
|
||||
}
|
||||
|
||||
public function renderStepFive($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_summary',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Status:'),
|
||||
'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('Enable the carrier in the Front Office')
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
$template = $this->createTemplate('controllers/carrier_wizard/summary.tpl');
|
||||
|
||||
$fields_value = $this->getStepFiveFieldsValues($carrier);
|
||||
|
||||
$active_form = $this->renderGenericForm(array('form' => $this->fields_form), $fields_value);
|
||||
|
||||
$active_form = str_replace(array('<fieldset id="fieldset_form">', '</fieldset>'), '', $active_form);
|
||||
|
||||
$template->assign('active_form', $active_form);
|
||||
|
||||
return $template->fetch('controllers/carrier_wizard/summary.tpl');
|
||||
}
|
||||
|
||||
protected function getTplRangesVarsAndValues($carrier, &$tpl_vars, &$fields_value)
|
||||
{
|
||||
$tpl_vars['zones'] = Zone::getZones(false);
|
||||
$carrier_zones = $carrier->getZones();
|
||||
$carrier_zones_ids = array();
|
||||
if (is_array($carrier_zones))
|
||||
foreach ($carrier_zones as $carrier_zone)
|
||||
$carrier_zones_ids[] = $carrier_zone['id_zone'];
|
||||
|
||||
$range_table = $carrier->getRangeTable();
|
||||
$shipping_method = $carrier->getShippingMethod();
|
||||
|
||||
$zones = Zone::getZones(false);
|
||||
foreach ($zones as $zone)
|
||||
$fields_value['zones'][$zone['id_zone']] = Tools::getValue('zone_'.$zone['id_zone'], (in_array($zone['id_zone'], $carrier_zones_ids)));
|
||||
|
||||
if ($shipping_method == Carrier::SHIPPING_METHOD_FREE)
|
||||
{
|
||||
$range_obj = $carrier->getRangeObject($carrier->shipping_method);
|
||||
$price_by_range = array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$range_obj = $carrier->getRangeObject();
|
||||
$price_by_range = Carrier::getDeliveryPriceByRanges($range_table, (int)$carrier->id);
|
||||
}
|
||||
|
||||
foreach ($price_by_range as $price)
|
||||
$tpl_vars['price_by_range'][$price['id_'.$range_table]][$price['id_zone']] = $price['price'];
|
||||
|
||||
$tmp_range = $range_obj->getRanges((int)$carrier->id);
|
||||
$tpl_vars['ranges'] = array();
|
||||
if ($shipping_method != Carrier::SHIPPING_METHOD_FREE)
|
||||
foreach ($tmp_range as $id => $range)
|
||||
{
|
||||
$tpl_vars['ranges'][$range['id_'.$range_table]] = $range;
|
||||
$tpl_vars['ranges'][$range['id_'.$range_table]]['id_range'] = $range['id_'.$range_table];
|
||||
}
|
||||
|
||||
// init blank range
|
||||
if (!count($tpl_vars['ranges']))
|
||||
$tpl_vars['ranges'][] = array('id_range' => 0, 'delimiter1' => 0, 'delimiter2' => 0);
|
||||
}
|
||||
|
||||
public function renderGenericForm($fields_form, $fields_value, $tpl_vars = array())
|
||||
{
|
||||
$helper = new HelperForm();
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = $this->table;
|
||||
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
$helper->default_form_language = $lang->id;
|
||||
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
|
||||
$this->fields_form = array();
|
||||
$helper->id = (int)Tools::getValue('id_carrier');
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->tpl_vars = array_merge(array(
|
||||
'fields_value' => $fields_value,
|
||||
'languages' => $this->getLanguages(),
|
||||
'id_language' => $this->context->language->id
|
||||
), $tpl_vars);
|
||||
$helper->override_folder = 'carrier_wizard/';
|
||||
|
||||
return $helper->generateForm($fields_form);
|
||||
}
|
||||
|
||||
public function getStepOneFieldsValues($carrier)
|
||||
{
|
||||
return array(
|
||||
'id_carrier' => $this->getFieldValue($carrier, 'id_carrier'),
|
||||
'name' => $this->getFieldValue($carrier, 'name'),
|
||||
'delay' => $this->getFieldValue($carrier, 'delay'),
|
||||
'grade' => $this->getFieldValue($carrier, 'grade'),
|
||||
'url' => $this->getFieldValue($carrier, 'url'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getStepTwoFieldsValues($carrier)
|
||||
{
|
||||
return array('shop' => $this->getFieldValue($carrier, 'shop'));
|
||||
|
||||
}
|
||||
|
||||
public function getStepThreeFieldsValues($carrier)
|
||||
{
|
||||
$id_tax_rules_group = (is_object($this->object) && !$this->object->id) ? Carrier::getIdTaxRulesGroupMostUsed() : $this->getFieldValue($carrier, 'id_tax_rules_group');
|
||||
|
||||
$shipping_handling = (is_object($this->object) && !$this->object->id) ? 0 : $this->getFieldValue($carrier, 'shipping_handling');
|
||||
|
||||
return array(
|
||||
'is_free' => $this->getFieldValue($carrier, 'is_free'),
|
||||
'id_tax_rules_group' => (int)$id_tax_rules_group,
|
||||
'shipping_handling' => $shipping_handling,
|
||||
'shipping_method' => $this->getFieldValue($carrier, 'shipping_method'),
|
||||
'range_behavior' => $this->getFieldValue($carrier, 'range_behavior'),
|
||||
'zones' => $this->getFieldValue($carrier, 'zones'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getStepFourFieldsValues($carrier)
|
||||
{
|
||||
return array(
|
||||
'range_behavior' => $this->getFieldValue($carrier, 'range_behavior'),
|
||||
'max_height' => $this->getFieldValue($carrier, 'max_height'),
|
||||
'max_width' => $this->getFieldValue($carrier, 'max_width'),
|
||||
'max_depth' => $this->getFieldValue($carrier, 'max_depth'),
|
||||
'max_weight' => $this->getFieldValue($carrier, 'max_weight'),
|
||||
'group' => $this->getFieldValue($carrier, 'group'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getStepFiveFieldsValues($carrier)
|
||||
{
|
||||
return array('active' => $this->getFieldValue($carrier, 'active'));
|
||||
}
|
||||
|
||||
public function ajaxProcessChangeRanges()
|
||||
{
|
||||
if ((Validate::isLoadedObject($this->object) && !$this->tabAccess['edit']) || !$this->tabAccess['add'])
|
||||
{
|
||||
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
|
||||
return;
|
||||
}
|
||||
if ((!(int)$shipping_method = Tools::getValue('shipping_method')) || !in_array($shipping_method, array(Carrier::SHIPPING_METHOD_PRICE, Carrier::SHIPPING_METHOD_WEIGHT)))
|
||||
return ;
|
||||
|
||||
$carrier = $this->loadObject(true);
|
||||
$carrier->shipping_method = $shipping_method;
|
||||
|
||||
$tpl_vars = array();
|
||||
$fields_value = $this->getStepThreeFieldsValues($carrier);
|
||||
$this->getTplRangesVarsAndValues($carrier, $tpl_vars, $fields_value);
|
||||
$template = $this->createTemplate('controllers/carrier_wizard/helpers/form/form_ranges.tpl');
|
||||
$template->assign($tpl_vars);
|
||||
$template->assign('change_ranges', 1);
|
||||
|
||||
$template->assign('fields_value', $fields_value);
|
||||
$template->assign('input', array('type' => 'zone', 'name' => 'zones' ));
|
||||
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$template->assign('currency_sign', $currency->sign);
|
||||
$template->assign('PS_WEIGHT_UNIT', Configuration::get('PS_WEIGHT_UNIT'));
|
||||
|
||||
die($template->fetch());
|
||||
}
|
||||
|
||||
public function ajaxProcessValidateStep()
|
||||
{
|
||||
$step_number = (int)Tools::getValue('step_number');
|
||||
$return = array('has_error' => false);
|
||||
|
||||
if (!$this->tabAccess['edit'])
|
||||
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
|
||||
else
|
||||
{
|
||||
if (Shop::isFeatureActive() && $step_number == 2)
|
||||
{
|
||||
if (!Tools::getValue('checkBoxShopAsso_carrier'))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('You must choose at least one shop or group shop.');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->validateRules('AdminCarrierWizardControllerCore');
|
||||
}
|
||||
|
||||
if (count($this->errors))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'] = $this->errors;
|
||||
}
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
|
||||
public function processRanges($id_carrier)
|
||||
{
|
||||
if (!$this->tabAccess['edit'] || !$this->tabAccess['add'])
|
||||
{
|
||||
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
|
||||
return;
|
||||
}
|
||||
|
||||
$carrier = new Carrier((int)$id_carrier);
|
||||
if (!Validate::isLoadedObject($carrier))
|
||||
return false;
|
||||
|
||||
$range_inf = Tools::getValue('range_inf');
|
||||
$range_sup = Tools::getValue('range_sup');
|
||||
$range_type = Tools::getValue('shipping_method');
|
||||
|
||||
$fees = Tools::getValue('fees');
|
||||
|
||||
$carrier->deleteDeliveryPrice($carrier->getRangeTable());
|
||||
if ($range_type != Carrier::SHIPPING_METHOD_FREE)
|
||||
{
|
||||
foreach ($range_inf as $key => $delimiter1)
|
||||
{
|
||||
if (!isset($range_sup[$key]))
|
||||
continue;
|
||||
$add_range = true;
|
||||
if ($range_type == Carrier::SHIPPING_METHOD_WEIGHT)
|
||||
{
|
||||
if (!RangeWeight::rangeExist((int)$carrier->id, (float)$delimiter1, (float)$range_sup[$key]))
|
||||
$range = new RangeWeight();
|
||||
else
|
||||
{
|
||||
$range = new RangeWeight((int)$key);
|
||||
$add_range = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($range_type == Carrier::SHIPPING_METHOD_PRICE)
|
||||
{
|
||||
if (!RangePrice::rangeExist((int)$carrier->id, (float)$delimiter1, (float)$range_sup[$key]))
|
||||
$range = new RangePrice();
|
||||
else
|
||||
{
|
||||
$range = new RangePrice((int)$key);
|
||||
$add_range = false;
|
||||
}
|
||||
}
|
||||
if ($add_range)
|
||||
{
|
||||
$range->id_carrier = (int)$carrier->id;
|
||||
$range->delimiter1 = (float)$delimiter1;
|
||||
$range->delimiter2 = (float)$range_sup[$key];
|
||||
$range->save();
|
||||
}
|
||||
|
||||
if (!Validate::isLoadedObject($range))
|
||||
return false;
|
||||
$price_list = array();
|
||||
if (is_array($fees) && count($fees))
|
||||
{
|
||||
foreach ($fees as $id_zone => $fee)
|
||||
$price_list[] = array(
|
||||
'id_range_price' => ($range_type == Carrier::SHIPPING_METHOD_PRICE ? (int)$range->id : null),
|
||||
'id_range_weight' => ($range_type == Carrier::SHIPPING_METHOD_WEIGHT ? (int)$range->id : null),
|
||||
'id_carrier' => (int)$carrier->id,
|
||||
'id_zone' => (int)$id_zone,
|
||||
'price' => (float)$fee[$key]
|
||||
);
|
||||
}
|
||||
|
||||
if (count($price_list) && !$carrier->addDeliveryPrice($price_list, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ajaxProcessUploadLogo()
|
||||
{
|
||||
if (!$this->tabAccess['edit'])
|
||||
die('<return result="error" message="'.Tools::displayError('You do not have permission to use this wizard.').'" />');
|
||||
|
||||
$allowedExtensions = array('jpeg', 'gif', 'png', 'jpg');
|
||||
|
||||
$logo = (isset($_FILES['carrier_logo_input']) ? $_FILES['carrier_logo_input'] : false);
|
||||
if ($logo && !empty($logo['tmp_name']) && $logo['tmp_name'] != 'none'
|
||||
&& (!isset($logo['error']) || !$logo['error'])
|
||||
&& preg_match('/\.(jpe?g|gif|png)$/', $logo['name'])
|
||||
&& is_uploaded_file($logo['tmp_name']))
|
||||
{
|
||||
$file = $logo['tmp_name'];
|
||||
do $tmp_name = uniqid().'.jpg';
|
||||
while (file_exists(_PS_TMP_IMG_DIR_.$tmp_name));
|
||||
if (!ImageManager::resize($file, _PS_TMP_IMG_DIR_.$tmp_name))
|
||||
die('<return result="error" message="Impossible to resize the image into '.Tools::safeOutput(_PS_TMP_IMG_DIR_).'" />');
|
||||
@unlink($file);
|
||||
die('<return result="success" message="'.Tools::safeOutput(_PS_TMP_IMG_.$tmp_name).'" />');
|
||||
}
|
||||
else
|
||||
die('<return result="error" message="Cannot upload file" />');
|
||||
}
|
||||
|
||||
public function ajaxProcessFinishStep()
|
||||
{
|
||||
$return = array('has_error' => false);
|
||||
|
||||
if (!$this->tabAccess['edit'])
|
||||
$return = array(
|
||||
'has_error' => true,
|
||||
$return['errors'][] = Tools::displayError('You do not have permission to use this wizard.')
|
||||
);
|
||||
else
|
||||
{
|
||||
if ($id_carrier = Tools::getValue('id_carrier'))
|
||||
{
|
||||
$current_carrier = new Carrier((int)$id_carrier);
|
||||
// if update we duplicate current Carrier
|
||||
$new_carrier = $current_carrier->duplicateObject();
|
||||
if (Validate::isLoadedObject($new_carrier))
|
||||
{
|
||||
// Set flag deteled to true for historization
|
||||
$current_carrier->deleted = true;
|
||||
$current_carrier->update();
|
||||
|
||||
// Fill the new carrier object
|
||||
$this->copyFromPost($new_carrier, $this->table);
|
||||
$new_carrier->position = $current_carrier->position;
|
||||
$new_carrier->update();
|
||||
|
||||
$this->updateAssoShop((int)$new_carrier->id);
|
||||
$this->duplicateLogo((int)$new_carrier->id, (int)$current_carrier->id);
|
||||
$this->changeGroups((int)$new_carrier->id);
|
||||
// Call of hooks
|
||||
Hook::exec('actionCarrierUpdate', array(
|
||||
'id_carrier' => (int)$current_carrier->id,
|
||||
'carrier' => $new_carrier
|
||||
));
|
||||
$this->postImage($new_carrier->id);
|
||||
$this->changeZones($new_carrier->id);
|
||||
$new_carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group'));
|
||||
$carrier = $new_carrier;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$carrier = new Carrier();
|
||||
$this->copyFromPost($carrier, $this->table);
|
||||
if (!$carrier->add())
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving this carrier.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($carrier->is_free)
|
||||
{
|
||||
//if carrier is free delete shipping cost
|
||||
$carrier->deleteDeliveryPrice('range_weight');
|
||||
$carrier->deleteDeliveryPrice('range_price');
|
||||
}
|
||||
|
||||
if (Validate::isLoadedObject($carrier))
|
||||
{
|
||||
if (!$this->changeGroups((int)$carrier->id))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving carrier groups.');
|
||||
}
|
||||
|
||||
if (!$this->changeZones((int)$carrier->id))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving carrier zones.');
|
||||
}
|
||||
|
||||
if (!$carrier->is_free)
|
||||
if (!$this->processRanges((int)$carrier->id))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving carrier ranges.');
|
||||
}
|
||||
|
||||
if (Shop::isFeatureActive() && !$this->updateAssoShop((int)$carrier->id))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving associations of shops.');
|
||||
}
|
||||
|
||||
if (!$carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group')))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving the tax rules group.');
|
||||
}
|
||||
|
||||
if (Tools::getValue('logo'))
|
||||
{
|
||||
if (Tools::getValue('logo') == 'null' && file_exists(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg'))
|
||||
unlink(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg');
|
||||
else
|
||||
{
|
||||
$logo = basename(Tools::getValue('logo'));
|
||||
if (!file_exists(_PS_TMP_IMG_DIR_.$logo) || !copy(_PS_TMP_IMG_DIR_.$logo, _PS_SHIP_IMG_DIR_.$carrier->id.'.jpg'))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving carrier logo.');
|
||||
}
|
||||
}
|
||||
}
|
||||
$return['id_carrier'] = $carrier->id;
|
||||
}
|
||||
}
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
|
||||
protected function changeGroups($id_carrier, $delete = true)
|
||||
{
|
||||
$carrier = new Carrier((int)$id_carrier);
|
||||
if (!Validate::isLoadedObject($carrier))
|
||||
return false;
|
||||
|
||||
return $carrier->setGroups(Tools::getValue('groupBox'));
|
||||
}
|
||||
|
||||
public function changeZones($id)
|
||||
{
|
||||
$return = true;
|
||||
$carrier = new Carrier($id);
|
||||
if (!Validate::isLoadedObject($carrier))
|
||||
die (Tools::displayError('The object cannot be loaded.'));
|
||||
$zones = Zone::getZones(false);
|
||||
foreach ($zones as $zone)
|
||||
if (count($carrier->getZone($zone['id_zone'])))
|
||||
{
|
||||
if (!isset($_POST['zone_'.$zone['id_zone']]) || !$_POST['zone_'.$zone['id_zone']])
|
||||
$return &= $carrier->deleteZone((int)$zone['id_zone']);
|
||||
}
|
||||
else
|
||||
if (isset($_POST['zone_'.$zone['id_zone']]) && $_POST['zone_'.$zone['id_zone']])
|
||||
$return &= $carrier->addZone((int)$zone['id_zone']);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getValidationRules()
|
||||
{
|
||||
$step_number = Tools::getValue('step_number');
|
||||
|
||||
if ($step_number == 4 && !Shop::isFeatureActive() || $step_number == 5 && Shop::isFeatureActive())
|
||||
return array();
|
||||
|
||||
$step_fields = array(
|
||||
1 => array('name', 'delay', 'grade', 'url'),
|
||||
2 => array('is_free', 'id_tax_rules_group', 'shipping_handling', 'shipping_method', 'range_behavior'),
|
||||
3 => array('range_behavior', 'max_height', 'max_width', 'max_depth', 'max_weight'),
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
$multistore_field = array(array('shop'));
|
||||
$tmp = $step_fields;
|
||||
$step_fields = array(1 => $tmp[1]) + $multistore_field;
|
||||
array_shift($tmp);
|
||||
foreach ($tmp as $row)
|
||||
$step_field[] = $row;
|
||||
}
|
||||
|
||||
$rules = Carrier::getValidationRules('Carrier');
|
||||
|
||||
foreach ($rules as $key_r => $rule)
|
||||
foreach ($rule as $key_f => $field)
|
||||
{
|
||||
if (in_array($key_r, array('required', 'requiredLang')))
|
||||
{
|
||||
if(!in_array($field, $step_fields[$step_number]))
|
||||
unset($rules[$key_r][$key_f]);
|
||||
}
|
||||
else if(!in_array($key_f, $step_fields[$step_number]))
|
||||
unset($rules[$key_r][$key_f]);
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public static function displayFieldName($field)
|
||||
{
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function duplicateLogo($new_id, $old_id)
|
||||
{
|
||||
$old_logo = _PS_SHIP_IMG_DIR_.'/'.(int)$old_id.'.jpg';
|
||||
if (file_exists($old_logo))
|
||||
copy($old_logo, _PS_SHIP_IMG_DIR_.'/'.(int)$new_id.'.jpg');
|
||||
|
||||
$old_tmp_logo = _PS_TMP_IMG_DIR_.'/carrier_mini_'.(int)$old_id.'.jpg';
|
||||
if (file_exists($old_tmp_logo))
|
||||
{
|
||||
if (!isset($_FILES['logo']))
|
||||
copy($old_tmp_logo, _PS_TMP_IMG_DIR_.'/carrier_mini_'.$new_id.'.jpg');
|
||||
unlink($old_tmp_logo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,11 +83,7 @@ class AdminCarriersControllerCore extends AdminController
|
||||
'is_free' => array(
|
||||
'title' => $this->l('Free Shipping'),
|
||||
'align' => 'center',
|
||||
'icon' => array(
|
||||
0 => 'disabled.gif',
|
||||
1 => 'enabled.gif',
|
||||
'default' => 'disabled.gif'
|
||||
),
|
||||
'active' => 'isFree',
|
||||
'type' => 'bool',
|
||||
'orderby' => false,
|
||||
),
|
||||
@@ -150,33 +146,16 @@ class AdminCarriersControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
if (isset($this->toolbar_btn['new']))
|
||||
$this->toolbar_btn['new']['href'] = $this->context->link->getAdminLink('AdminCarrierWizard');
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->displayInformation(
|
||||
' <b>'.$this->l('How do I create a new carrier?').'</b>
|
||||
<br />
|
||||
<ul>
|
||||
<li>'.$this->l('Click "Add New."').'<br /></li>
|
||||
<li>'.$this->l('Fill in the fields and click "Save."').'</li>
|
||||
<li>'.
|
||||
$this->l('You need to set a price range -- or weight range -- for which the new carrier will be available.').' '.
|
||||
$this->l('Under the "Shipping" menu, click either "Price ranges" or "Weight ranges.".').'
|
||||
</li>
|
||||
<li>'.$this->l('Click "Add New."').'</li>
|
||||
<li>'.
|
||||
$this->l('Select the name of the carrier before defining the price or weight range.').' '.
|
||||
$this->l('For example, the carrier can be made available for a weight range between 0 and 5lbs. Another carrier can have a range between 5 and 10lbs.').'
|
||||
</li>
|
||||
<li>'.$this->l('When you\'re done, click "Save."').'</li>
|
||||
<li>'.$this->l('Click on the "Shipping" menu.').'</li>
|
||||
<li>'.
|
||||
$this->l('You need to set the fees that will be applied for this carrier.').' '.
|
||||
$this->l('At the bottom on the page -- in the "Fees" section -- select the name of the carrier.').'
|
||||
</li>
|
||||
<li>'.$this->l('For each zone, enter a price and then click "Save."').'</li>
|
||||
<li>'.$this->l('You\'re all set! The new carrier will now be displayed to customers.').'</li>
|
||||
</ul>'
|
||||
);
|
||||
$this->_select = 'b.*';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'carrier_lang` b ON a.id_carrier = b.id_carrier'.Shop::addSqlRestrictionOnLang('b').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'carrier_tax_rules_group_shop` ctrgs ON (a.`id_carrier` = ctrgs.`id_carrier`
|
||||
@@ -537,6 +516,10 @@ class AdminCarriersControllerCore extends AdminController
|
||||
else
|
||||
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
|
||||
}
|
||||
else if (isset($_GET['isFree'.$this->table]))
|
||||
{
|
||||
$this->processIsFree();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Tools::isSubmit('submitDel'.$this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox')))
|
||||
@@ -569,6 +552,17 @@ class AdminCarriersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function processIsFree()
|
||||
{
|
||||
$carrier = new Carrier($this->id_object);
|
||||
if (!Validate::isLoadedObject($carrier))
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating carrier information.');
|
||||
$carrier->is_free = $carrier->is_free ? 0 : 1;
|
||||
if (!$carrier->update())
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating carrier information.');
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overload the property $fields_value
|
||||
*
|
||||
@@ -682,6 +676,22 @@ class AdminCarriersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function displayEditLink($token = null, $id, $name = null)
|
||||
{
|
||||
if ($this->tabAccess['edit'] == 1)
|
||||
return '<a href="'.$this->context->link->getAdminLink('AdminCarrierWizard').'&id_carrier='.(int)$id.'"><img src="../img/admin/edit.gif"/></a>';
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
public function displayDeleteLink($token = null, $id, $name = null)
|
||||
{
|
||||
if ($this->tabAccess['delete'] == 1)
|
||||
return '<a href="'.$this->context->link->getAdminLink('AdminCarriers').'&id_carrier='.(int)$id.'&deletecarrier=1"><img src="../img/admin/delete.gif"/></a>';
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
/** @var boolean does the product have to be disable during the delete process */
|
||||
public $disable_products = false;
|
||||
|
||||
private $original_filter = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
@@ -130,7 +132,7 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$id_parent = $this->context->shop->id_category;
|
||||
|
||||
$this->_select = 'sa.position position';
|
||||
$this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' ';
|
||||
$this->original_filter = $this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' ';
|
||||
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP)
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = '.(int)$this->context->shop->id.') ';
|
||||
@@ -174,6 +176,9 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
if (isset($this->_filter) && trim($this->_filter) == '')
|
||||
$this->_filter = $this->original_filter;
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
$this->addRowAction('add');
|
||||
@@ -388,25 +393,6 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
'use_context' => true,
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Root Category:'),
|
||||
'name' => 'is_root_category',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'is_root_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Yes')
|
||||
),
|
||||
array(
|
||||
'id' => 'is_root_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('No')
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Description:'),
|
||||
@@ -471,12 +457,36 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
|
||||
$this->tpl_form_vars['shared_category'] = Validate::isLoadedObject($obj) && $obj->hasMultishopEntries();
|
||||
$this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
|
||||
|
||||
// Display this field only if multistore option is enabled
|
||||
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE'))
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Root Category:'),
|
||||
'name' => 'is_root_category',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'is_root_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Yes')
|
||||
),
|
||||
array(
|
||||
'id' => 'is_root_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('No')
|
||||
)
|
||||
)
|
||||
);
|
||||
// Display this field only if multistore option is enabled AND there are several stores configured
|
||||
if (Shop::isFeatureActive())
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'shop',
|
||||
'label' => $this->l('Shop association:'),
|
||||
'name' => 'checkBoxShopAsso',
|
||||
);
|
||||
|
||||
// remove category tree and radio button "is_root_category" if this category has the root category as parent category to avoid any conflict
|
||||
if ($this->_category->id_parent == Category::getTopCategory()->id && Tools::isSubmit('updatecategory'))
|
||||
foreach ($this->fields_form['input'] as $k => $input)
|
||||
|
||||
@@ -140,7 +140,8 @@ class AdminCountriesControllerCore extends AdminController
|
||||
array('address2'),
|
||||
array('postcode', 'city'),
|
||||
array('Country:name'),
|
||||
array('phone'));
|
||||
array('phone'),
|
||||
array('phone_mobile'));
|
||||
|
||||
foreach ($default_layout_tab as $line)
|
||||
$default_layout .= implode(' ', $line)."\r\n";
|
||||
|
||||
@@ -459,7 +459,7 @@ class AdminFeaturesControllerCore extends AdminController
|
||||
* AdminController::getList() override
|
||||
* @see AdminController::getList()
|
||||
*/
|
||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = false, $id_lang_shop = false)
|
||||
{
|
||||
if ($this->table == 'feature_value')
|
||||
$this->_where .= ' AND a.custom = 0';
|
||||
|
||||
@@ -71,10 +71,15 @@ class AdminHomeControllerCore extends AdminController
|
||||
$indexRebuiltAfterUpdate = 2;
|
||||
|
||||
$smartyOptimized = 0;
|
||||
// Forcing compilation is not good, really slow
|
||||
if (in_array(Configuration::get('PS_SMARTY_FORCE_COMPILE'), array(_PS_SMARTY_CHECK_COMPILE_, _PS_SMARTY_NO_COMPILE_)))
|
||||
++$smartyOptimized;
|
||||
// Enabling cache is better
|
||||
if (Configuration::get('PS_SMARTY_CACHE'))
|
||||
++$smartyOptimized;
|
||||
// If the console is enabled, not good for production
|
||||
if (Configuration::get('PS_SMARTY_CONSOLE') != _PS_SMARTY_CONSOLE_CLOSE_)
|
||||
$smartyOptimized = 0;
|
||||
|
||||
$cccOptimized = Configuration::get('PS_CSS_THEME_CACHE');
|
||||
$cccOptimized += Configuration::get('PS_JS_THEME_CACHE');
|
||||
@@ -170,10 +175,16 @@ class AdminHomeControllerCore extends AdminController
|
||||
|
||||
$shop = Context::getContext()->shop;
|
||||
if ($_SERVER['HTTP_HOST'] != $shop->domain && $_SERVER['HTTP_HOST'] != $shop->domain_ssl && Tools::getValue('ajax') == false)
|
||||
$this->displayWarning($this->l('You are currently connected under the following domain name:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />'.
|
||||
$this->l('This is different from the main shop domain name set in the "Multistore" page under the "Advanced Parameters" menu:').' <span style="color: #CC0000;">'.$shop->domain.'</span><br />
|
||||
<a href="index.php?controller=AdminMeta&token='.Tools::getAdminTokenLite('AdminMeta').'#conf_id_domain">'.
|
||||
$this->l('Click here if you want to modify your main shop\'s domain name.').'</a>');
|
||||
{
|
||||
$warning = $this->l('You are currently connected under the following domain name:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />';
|
||||
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE'))
|
||||
$warning .= sprintf($this->l('This is different from the shop domain name set in the Multistore settings: "%s".'), $shop->domain).'
|
||||
'.preg_replace('@{link}(.*){/link}@', '<a href="index.php?controller=AdminShopUrl&id_shop_url='.(int)$shop->id.'&updateshop_url&token='.Tools::getAdminTokenLite('AdminShopUrl').'">$1</a>', $this->l('If this is your main domain, please {link}change it now{/link}.'));
|
||||
else
|
||||
$warning .= $this->l('This is different from the domain name set in the "SEO & URLs" tab.').'
|
||||
'.preg_replace('@{link}(.*){/link}@', '<a href="index.php?controller=AdminMeta&token='.Tools::getAdminTokenLite('AdminMeta').'#conf_id_domain">$1</a>', $this->l('If this is your main domain, please {link}change it now{/link}.'));
|
||||
$this->displayWarning($warning);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getQuickLinks()
|
||||
@@ -475,7 +486,7 @@ class AdminHomeControllerCore extends AdminController
|
||||
$result = array();
|
||||
$content = '';
|
||||
|
||||
$protocol = Tools::usingSecureMode() ? 'https' : 'http';
|
||||
$protocol = Tools::getCurrentUrlProtocolPrefix();
|
||||
$isoUser = Context::getContext()->language->iso_code;
|
||||
$isoCountry = Context::getContext()->country->iso_code;
|
||||
$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 2)));
|
||||
@@ -483,16 +494,15 @@ class AdminHomeControllerCore extends AdminController
|
||||
// SCREENCAST
|
||||
$result['screencast'] = 'OK';
|
||||
|
||||
|
||||
// PREACTIVATION
|
||||
$result['partner_preactivation'] = $this->getBlockPartners();
|
||||
|
||||
// DISCOVER PRESTASHOP
|
||||
$result['discover_prestashop'] = '<div id="block_tips">'.$this->getBlockDiscover().'</div>';
|
||||
$result['discover_prestashop'] .= '<div class="row-news"><div id="block_discover"><iframe frameborder="no" style="margin: 0px; padding: 0px; width: 100%; height:300px; overflow:hidden;" src="'.$protocol.'://api.prestashop.com/rss2/news2.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe></div>';
|
||||
$result['discover_prestashop'] .= '<div class="row-news"><div id="block_discover"><iframe frameborder="no" style="margin: 0px; padding: 0px; width: 100%; height:300px; overflow:hidden;" src="'.$protocol.'api.prestashop.com/rss2/news2.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe></div>';
|
||||
|
||||
// SHOW TIPS OF THE DAY
|
||||
$content = Tools::file_get_contents($protocol.'://api.prestashop.com/partner/tipsoftheday/?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser), false, $stream_context);
|
||||
$content = Tools::file_get_contents($protocol.'api.prestashop.com/partner/tipsoftheday/?iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser), false, $stream_context);
|
||||
$content = explode('|', $content);
|
||||
if ($content[0] == 'OK' && Validate::isCleanHtml($content[1]))
|
||||
$result['discover_prestashop'] .= '<div id="block_partner_tips">'.$content[1].'</div></div>';
|
||||
@@ -518,7 +528,7 @@ class AdminHomeControllerCore extends AdminController
|
||||
{
|
||||
// Init var
|
||||
$return = '';
|
||||
$protocol = Tools::getShopProtocol();
|
||||
$protocol = Tools::getCurrentUrlProtocolPrefix();
|
||||
$isoCountry = Context::getContext()->country->iso_code;
|
||||
$isoUser = Context::getContext()->language->iso_code;
|
||||
|
||||
@@ -526,7 +536,7 @@ class AdminHomeControllerCore extends AdminController
|
||||
if (is_writable('../config/xml/') && (!file_exists('../config/xml/preactivation.xml') || (time() - filemtime('../config/xml/preactivation.xml')) > 86400))
|
||||
{
|
||||
$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => AdminHomeController::TIPS_TIMEOUT)));
|
||||
$content = Tools::file_get_contents('http://api.prestashop.com/partner/premium/get_partners.php?protocol='.$protocol.'&iso_country='.Tools::strtoupper($isoCountry).'&iso_lang='.Tools::strtolower($isoUser).'&ps_version='._PS_VERSION_.'&ps_creation='._PS_CREATION_DATE_.'&host='.urlencode($_SERVER['HTTP_HOST']).'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')), false, $stream_context);
|
||||
$content = Tools::file_get_contents($protocol.'api.prestashop.com/partner/premium/get_partners.php?iso_country='.Tools::strtoupper($isoCountry).'&iso_lang='.Tools::strtolower($isoUser).'&ps_version='._PS_VERSION_.'&ps_creation='._PS_CREATION_DATE_.'&host='.urlencode($_SERVER['HTTP_HOST']), false, $stream_context);
|
||||
@unlink('../config/xml/preactivation.xml');
|
||||
file_put_contents('../config/xml/preactivation.xml', $content);
|
||||
}
|
||||
@@ -658,15 +668,12 @@ class AdminHomeControllerCore extends AdminController
|
||||
$smarty->assign('protocol', $protocol);
|
||||
$isoUser = $this->context->language->iso_code;
|
||||
$smarty->assign('isoUser', $isoUser);
|
||||
$upgrade = null;
|
||||
$tpl_vars['refresh_check_version'] = 0;
|
||||
if (@ini_get('allow_url_fopen'))
|
||||
{
|
||||
$upgrade = new Upgrader(true);
|
||||
// if this information is outdated, the version will be checked after page loading
|
||||
if (Configuration::get('PS_LAST_VERSION_CHECK') < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))
|
||||
$tpl_vars['refresh_check_version'] = 1;
|
||||
}
|
||||
$upgrade = new Upgrader(true);
|
||||
|
||||
// if this information is outdated, the version will be checked after page loading
|
||||
if (Configuration::get('PS_LAST_VERSION_CHECK') < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))
|
||||
$tpl_vars['refresh_check_version'] = 1;
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
|
||||
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));
|
||||
|
||||
@@ -529,18 +529,16 @@ class AdminImagesControllerCore extends AdminController
|
||||
protected function _regenerateNoPictureImages($dir, $type, $languages)
|
||||
{
|
||||
$errors = false;
|
||||
foreach ($type as $imageType)
|
||||
{
|
||||
foreach ($type as $image_type)
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
$file = $dir.$language['iso_code'].'.jpg';
|
||||
if (!file_exists($file))
|
||||
$file = _PS_PROD_IMG_DIR_.Language::getIsoById((int)(Configuration::get('PS_LANG_DEFAULT'))).'.jpg';
|
||||
if (!file_exists($dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg'))
|
||||
if (!ImageManager::resize($file, $dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg', (int)$imageType['width'], (int)$imageType['height']))
|
||||
$file = _PS_PROD_IMG_DIR_.Language::getIsoById((int)Configuration::get('PS_LANG_DEFAULT')).'.jpg';
|
||||
if (!file_exists($dir.$language['iso_code'].'-default-'.stripslashes($image_type['name']).'.jpg'))
|
||||
if (!ImageManager::resize($file, $dir.$language['iso_code'].'-default-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height']))
|
||||
$errors = true;
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,43 +117,22 @@ class AdminManufacturersControllerCore extends AdminController
|
||||
|
||||
$this->content .= parent::renderList();
|
||||
}
|
||||
|
||||
public function initListManufacturerAddresses()
|
||||
|
||||
protected function getAddressFieldsList()
|
||||
{
|
||||
$this->toolbar_title = $this->l('Addresses');
|
||||
// reset actions and query vars
|
||||
$this->actions = array();
|
||||
unset($this->fields_list, $this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
|
||||
$this->table = 'address';
|
||||
$this->identifier = 'id_address';
|
||||
$this->deleted = true;
|
||||
$this->_orderBy = null;
|
||||
|
||||
$this->addRowAction('editaddresses');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
// test if a filter is applied for this list
|
||||
if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false)
|
||||
$this->filter = true;
|
||||
|
||||
// test if a filter reset request is required for this list
|
||||
if (isset($_POST['submitReset'.$this->table]))
|
||||
$this->action = 'reset_filters';
|
||||
else
|
||||
$this->action = '';
|
||||
|
||||
// Sub tab addresses
|
||||
$countries = Country::getCountries($this->context->language->id);
|
||||
foreach ($countries as $country)
|
||||
$this->countries_array[$country['id_country']] = $country['name'];
|
||||
|
||||
$this->fields_list = array(
|
||||
return array(
|
||||
'id_address' => array(
|
||||
'title' => $this->l('ID')
|
||||
),
|
||||
'manufacturer_name' => array(
|
||||
'title' => $this->l('Manufacturer')
|
||||
'title' => $this->l('Manufacturer'),
|
||||
'width' => 'auto',
|
||||
'filter_key' => 'm!name'
|
||||
),
|
||||
'firstname' => array(
|
||||
'title' => $this->l('First name')
|
||||
@@ -176,6 +155,32 @@ class AdminManufacturersControllerCore extends AdminController
|
||||
'filter_key' => 'cl!id_country'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function initListManufacturerAddresses()
|
||||
{
|
||||
$this->toolbar_title = $this->l('Addresses');
|
||||
// reset actions and query vars
|
||||
$this->actions = array();
|
||||
unset($this->fields_list, $this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
|
||||
$this->table = 'address';
|
||||
$this->list_id = 'address';
|
||||
$this->identifier = 'id_address';
|
||||
$this->deleted = true;
|
||||
$this->_orderBy = null;
|
||||
|
||||
$this->addRowAction('editaddresses');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
// test if a filter is applied for this list
|
||||
if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false)
|
||||
$this->filter = true;
|
||||
|
||||
// test if a filter reset request is required for this list
|
||||
$this->action = (isset($_POST['submitReset'.$this->table]) ? 'reset_filters' : '');
|
||||
|
||||
$this->fields_list = $this->getAddressFieldsList();
|
||||
|
||||
$this->_select = 'cl.`name` as country, m.`name` AS manufacturer_name';
|
||||
$this->_join = '
|
||||
@@ -671,12 +676,13 @@ class AdminManufacturersControllerCore extends AdminController
|
||||
|
||||
public function initProcess()
|
||||
{
|
||||
if (Tools::getValue('submitAddaddress') || Tools::isSubmit('deleteaddress') || Tools::isSubmit('submitBulkdeleteaddress'))
|
||||
if (Tools::getValue('submitAddaddress') || Tools::isSubmit('deleteaddress') || Tools::isSubmit('submitBulkdeleteaddress') || Tools::isSubmit('exportaddress'))
|
||||
{
|
||||
$this->table = 'address';
|
||||
$this->className = 'Address';
|
||||
$this->identifier = 'id_address';
|
||||
$this->deleted = true;
|
||||
$this->fields_list = $this->getAddressFieldsList();
|
||||
}
|
||||
parent::initProcess();
|
||||
}
|
||||
|
||||
@@ -479,11 +479,21 @@ class AdminMetaControllerCore extends AdminController
|
||||
public function updateOptionPsRewritingSettings()
|
||||
{
|
||||
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
|
||||
Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'), false, Tools::getValue('PS_HTACCESS_DISABLE_MODSEC'));
|
||||
|
||||
Tools::enableCache();
|
||||
Tools::clearCache($this->context->smarty);
|
||||
Tools::restoreCacheSettings();
|
||||
if (Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'), false, Tools::getValue('PS_HTACCESS_DISABLE_MODSEC')))
|
||||
{
|
||||
Tools::enableCache();
|
||||
Tools::clearCache($this->context->smarty);
|
||||
Tools::restoreCacheSettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
Configuration::updateValue('PS_REWRITING_SETTINGS', 0);
|
||||
// Message copied/pasted from the information tip
|
||||
$message = $this->l('Before being able to use this tool, you need to:');
|
||||
$message .= '<br />- '.$this->l('Create a blank .htaccess in your root directory.');
|
||||
$message .= '<br />- '.$this->l('Give it write permissions (CHMOD 666 on Unix system)');
|
||||
$this->errors[] = $message;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateOptionPsRouteProductRule()
|
||||
|
||||
@@ -768,6 +768,11 @@ class AdminModulesControllerCore extends AdminController
|
||||
Tools::redirectAdmin('index.php?controller=adminmodules&configure='.Tools::getValue('module_name').'&token='.Tools::getValue('token').'&module_name='.Tools::getValue('module_name').$params);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(isset($modules_list_save) ? '&modules_list='.$modules_list_save : '').$params);
|
||||
}
|
||||
|
||||
if(isset($_GET['update']))
|
||||
{
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&updated=1tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(isset($modules_list_save) ? '&modules_list='.$modules_list_save : '').$params);
|
||||
}
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
@@ -1014,6 +1019,14 @@ class AdminModulesControllerCore extends AdminController
|
||||
// Browse modules list
|
||||
foreach ($modules as $km => $module)
|
||||
{
|
||||
//Add succes message for one module update
|
||||
if (Tools::getValue('updated') && Tools::getValue('module_name'))
|
||||
{
|
||||
if ($module->name === (string)Tools::getValue('module_name'))
|
||||
$module_success[] = array('name' => $module->displayName, 'message' => array(
|
||||
0 => $this->l('Current version:').$module->version));
|
||||
}
|
||||
|
||||
//if we are in favorites view we only display installed modules
|
||||
if (Tools::getValue('select') == 'favorites' && !$module->id)
|
||||
{
|
||||
|
||||
@@ -399,20 +399,31 @@ class AdminModulesPositionsControllerCore extends AdminController
|
||||
if (!is_array($file_list))
|
||||
$file_list = ($file_list) ? array($file_list) : array();
|
||||
|
||||
$content = '<p><input type="text" name="exceptions['.$shop_id.']" size="40" value="'.implode(', ', $file_list).'" id="em_text_'.$shop_id.'"/></p>';
|
||||
$content = '<p><input type="text" name="exceptions['.$shop_id.']" value="'.implode(', ', $file_list).'" id="em_text_'.$shop_id.'"/></p>';
|
||||
|
||||
if ($shop_id)
|
||||
{
|
||||
$shop = new Shop($shop_id);
|
||||
$content .= ' ('.$shop->name.')';
|
||||
}
|
||||
|
||||
$content .= '<p>
|
||||
<select id="em_list_'.$shop_id.'">';
|
||||
<select id="em_list_'.$shop_id.'" multiple="multiple">
|
||||
<option disabled="disabled">'.$this->l('___________ CUSTOM ___________').'</option>';
|
||||
|
||||
// @todo do something better with controllers
|
||||
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
||||
ksort($controllers);
|
||||
|
||||
foreach ($file_list as $k => $v)
|
||||
if ( ! array_key_exists ($v, $controllers))
|
||||
$content .= '<option value="'.$v.'">'.$v.'</option>';
|
||||
|
||||
$content .= '<option disabled="disabled">'.$this->l('____________ CORE ____________').'</option>';
|
||||
|
||||
foreach ($controllers as $k => $v)
|
||||
$content .= '<option value="'.$k.'">'.$k.'</option>';
|
||||
|
||||
$content .= '</select>
|
||||
</p>
|
||||
<p>
|
||||
|
||||
@@ -298,7 +298,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'{shipping_number}' => $order->shipping_number,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
|
||||
if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit'), $templateVars,
|
||||
$customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
|
||||
_PS_MAIL_DIR_, true, (int)$order->id_shop))
|
||||
{
|
||||
|
||||
@@ -117,7 +117,8 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
array('id' => '3', 'name' => $this->l('Product modified date')),
|
||||
array('id' => '4', 'name' => $this->l('Position inside category')),
|
||||
array('id' => '5', 'name' => $this->l('Manufacturer')),
|
||||
array('id' => '6', 'name' => $this->l('Product quantity'))
|
||||
array('id' => '6', 'name' => $this->l('Product quantity')),
|
||||
array('id' => '7', 'name' => $this->l('Product reference'))
|
||||
),
|
||||
'identifier' => 'id'
|
||||
),
|
||||
|
||||
@@ -116,12 +116,20 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Debug console Key'),
|
||||
'name' => 'smarty_console_key',
|
||||
'size' => 30,
|
||||
'desc' => $this->l('SMARTY_DEBUG parameter in the URL.')
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value['smarty_force_compile'] = Configuration::get('PS_SMARTY_FORCE_COMPILE');
|
||||
$this->fields_value['smarty_cache'] = Configuration::get('PS_SMARTY_CACHE');
|
||||
$this->fields_value['smarty_console'] = Configuration::get('PS_SMARTY_CONSOLE');
|
||||
$this->fields_value['smarty_console_key'] = Configuration::get('PS_SMARTY_CONSOLE_KEY');
|
||||
}
|
||||
|
||||
public function initFieldsetFeaturesDetachables()
|
||||
@@ -456,24 +464,6 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
$this->tpl_form_vars['servers'] = CacheMemcache::getMemcachedServers();
|
||||
}
|
||||
|
||||
public function initFieldsetCloudCache()
|
||||
{
|
||||
if (!class_exists('CloudCache'))
|
||||
$this->fields_form[6]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('CloudCache'),
|
||||
'icon' => 'icon-cloud'
|
||||
),
|
||||
'desc' =>
|
||||
'<div class="alert alert-block">
|
||||
<p>'.$this->l('Performance matters! Improve speed and conversions the easy way.').'</p>'.
|
||||
'<p>'.$this->l('CloudCache supercharges your site in minutes through its state-of-the-art content delivery network.').'</p>'.
|
||||
'<p>'.$this->l('Subscribe now using the code "presta25" and get an exclusive 25% monthly discount on every available package.').'</p>
|
||||
<p><a href="index.php?controller=AdminModules&token='.Tools::getAdminTokenLite('AdminModules').'&filtername=cloudcache" id="installCloudCache">> '.$this->l('Click here to install the CloudCache module for PrestaShop').'</a></p>
|
||||
</div>'
|
||||
);
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
// Initialize fieldset for a form
|
||||
@@ -483,7 +473,6 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
$this->initFieldsetMediaServer();
|
||||
$this->initFieldsetCiphering();
|
||||
$this->initFieldsetCaching();
|
||||
$this->initFieldsetCloudCache();
|
||||
|
||||
// Activate multiple fieldset
|
||||
$this->multiple_fieldsets = true;
|
||||
@@ -590,7 +579,8 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
Configuration::updateValue('PS_SMARTY_FORCE_COMPILE', Tools::getValue('smarty_force_compile', _PS_SMARTY_NO_COMPILE_));
|
||||
Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0));
|
||||
Configuration::updateValue('PS_SMARTY_CONSOLE', Tools::getValue('smarty_console', 0));
|
||||
$redirectAdmin = true;
|
||||
Configuration::updateValue('PS_SMARTY_CONSOLE_KEY', Tools::getValue('smarty_console_key', 'SMARTY_DEBUG'));
|
||||
$redirecAdmin = true;
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
|
||||
@@ -821,4 +811,4 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
die;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,8 +800,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
|
||||
if ($this->isProductFieldUpdated('available_date_attribute') && !Validate::isDateFormat(Tools::getValue('available_date_attribute')))
|
||||
if ($this->isProductFieldUpdated('available_date_attribute') && (Tools::getValue('available_date_attribute') != '' &&!Validate::isDateFormat(Tools::getValue('available_date_attribute'))))
|
||||
$this->errors[] = Tools::displayError('Invalid date format.');
|
||||
else
|
||||
{
|
||||
@@ -2408,18 +2407,23 @@ class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
if ($product = $this->loadObject(true))
|
||||
{
|
||||
if ($this->tabAccess['edit'])
|
||||
{
|
||||
$this->toolbar_btn['save'] = array(
|
||||
'short' => 'Save',
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save'),
|
||||
);
|
||||
|
||||
$this->toolbar_btn['save-and-stay'] = array(
|
||||
'short' => 'SaveAndStay',
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
);
|
||||
}
|
||||
|
||||
if ((bool)$product->id)
|
||||
{
|
||||
// adding button for delete this product
|
||||
if ($this->tabAccess['delete'] && $this->display != 'add')
|
||||
$this->toolbar_btn['delete'] = array(
|
||||
'short' => 'Delete',
|
||||
'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&deleteproduct',
|
||||
'desc' => $this->l('Delete this product.'),
|
||||
'confirm' => 1,
|
||||
'js' => 'if (confirm(\''.$this->l('Delete product?').'\')){return true;}else{event.preventDefault();}'
|
||||
);
|
||||
|
||||
// adding button for duplicate this product
|
||||
if ($this->tabAccess['add'] && $this->display != 'add')
|
||||
$this->toolbar_btn['duplicate'] = array(
|
||||
@@ -2453,22 +2457,17 @@ class AdminProductsControllerCore extends AdminController
|
||||
'desc' => $this->l('New combination'),
|
||||
'class' => 'toolbar-new'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->tabAccess['edit'])
|
||||
{
|
||||
$this->toolbar_btn['save'] = array(
|
||||
'short' => 'Save',
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save'),
|
||||
);
|
||||
|
||||
$this->toolbar_btn['save-and-stay'] = array(
|
||||
'short' => 'SaveAndStay',
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
);
|
||||
}
|
||||
|
||||
// adding button for delete this product
|
||||
if ($this->tabAccess['delete'] && $this->display != 'add')
|
||||
$this->toolbar_btn['delete'] = array(
|
||||
'short' => 'Delete',
|
||||
'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&deleteproduct',
|
||||
'desc' => $this->l('Delete this product.'),
|
||||
'confirm' => 1,
|
||||
'js' => 'if (confirm(\''.$this->l('Delete product?').'\')){return true;}else{event.preventDefault();}'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -69,75 +69,11 @@ class AdminShippingControllerCore extends AdminController
|
||||
<li>'.$this->l('Coupons are not taken into account when calculating free shipping').'</li>
|
||||
</ul>',
|
||||
'submit' => array()
|
||||
),
|
||||
'billing' => array(
|
||||
'title' => $this->l('Billing'),
|
||||
'icon' => 'money',
|
||||
'fields' => array(
|
||||
'PS_SHIPPING_METHOD' => array(
|
||||
'title' => $this->l('Billing'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
0 => $this->l('According to total price'),
|
||||
1 => $this->l('According to total weight')
|
||||
),
|
||||
'validation' => 'isBool'
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$array_carrier = array();
|
||||
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
|
||||
foreach ($carriers as $key => $carrier)
|
||||
if ($carrier['is_free'])
|
||||
unset($carriers[$key]);
|
||||
else
|
||||
$array_carrier[] = $carrier['id_carrier'];
|
||||
|
||||
$id_carrier = (int)Tools::getValue('id_carrier');
|
||||
|
||||
if (count($carriers) && isset($array_carrier[0]))
|
||||
{
|
||||
if (!$id_carrier)
|
||||
$id_carrier = (int)$array_carrier[0];
|
||||
|
||||
$carrierSelected = new Carrier((int)$id_carrier);
|
||||
}
|
||||
else
|
||||
$carrierSelected = new Carrier((int)$id_carrier);
|
||||
|
||||
$currency = $this->context->currency;
|
||||
$rangeObj = $carrierSelected->getRangeObject();
|
||||
$rangeTable = $carrierSelected->getRangeTable();
|
||||
$suffix = $carrierSelected->getRangeSuffix();
|
||||
|
||||
$rangeIdentifier = 'id_'.$rangeTable;
|
||||
$ranges = $rangeObj->getRanges($id_carrier);
|
||||
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
|
||||
$deliveryArray = array();
|
||||
foreach ($delivery as $deliv)
|
||||
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'zones' => $carrierSelected->getZones(),
|
||||
'carriers' => $carriers,
|
||||
'ranges' => $ranges,
|
||||
'currency' => $currency,
|
||||
'deliveryArray' => $deliveryArray,
|
||||
'carrierSelected' => $carrierSelected,
|
||||
'id_carrier' => $id_carrier,
|
||||
'suffix' => $suffix,
|
||||
'rangeIdentifier' => $rangeIdentifier,
|
||||
'action_fees' => self::$currentIndex.'&token='.$this->token
|
||||
));
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
|
||||
@@ -225,14 +225,6 @@ class AdminStatusesControllerCore extends AdminController
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
if (Tools::isSubmit('updateorder_state') || Tools::isSubmit('addorder_state'))
|
||||
return $this->renderOrderStatusForm();
|
||||
else if (Tools::isSubmit('updateorder_return_state') || Tools::isSubmit('addorder_return_state'))
|
||||
return $this->renderOrderReturnsForm();
|
||||
}
|
||||
|
||||
protected function renderOrderStatusForm()
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'tinymce' => true,
|
||||
@@ -362,7 +354,17 @@ class AdminStatusesControllerCore extends AdminController
|
||||
'class' => 'button'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (Tools::isSubmit('updateorder_state') || Tools::isSubmit('addorder_state'))
|
||||
return $this->renderOrderStatusForm();
|
||||
else if (Tools::isSubmit('updateorder_return_state') || Tools::isSubmit('addorder_return_state'))
|
||||
return $this->renderOrderReturnsForm();
|
||||
else
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
protected function renderOrderStatusForm()
|
||||
{
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
),
|
||||
'valuation' => array(
|
||||
'title' => $this->l('Valuation'),
|
||||
'orderby' => true,
|
||||
'orderby' => false,
|
||||
'search' => false,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
@@ -88,7 +88,7 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
'real_quantity' => array(
|
||||
'title' => $this->l('Real quantity'),
|
||||
'width' => 80,
|
||||
'orderby' => true,
|
||||
'orderby' => false,
|
||||
'search' => false,
|
||||
'hint' => $this->l('Physical quantity (usable) - Client orders + Supply Orders'),
|
||||
),
|
||||
|
||||
@@ -40,6 +40,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
$this->bootstrap = true;
|
||||
$this->context = Context::getContext();
|
||||
$this->table = 'supply_order';
|
||||
|
||||
$this->className = 'SupplyOrder';
|
||||
$this->identifier = 'id_supply_order';
|
||||
$this->lang = false;
|
||||
@@ -457,6 +458,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
$this->_where .= ' AND st.enclosed != 1';
|
||||
self::$currentIndex .= '&filter_status=on';
|
||||
}
|
||||
|
||||
$this->list_id = 'orders';
|
||||
$first_list = parent::renderList();
|
||||
|
||||
if (Tools::isSubmit('csv_orders') || Tools::isSubmit('csv_orders_details') || Tools::isSubmit('csv_order_details'))
|
||||
@@ -509,6 +512,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
'href' => self::$currentIndex.'&add'.$this->table.'&mod=template&token='.$this->token,
|
||||
'desc' => $this->l('Add new template')
|
||||
);
|
||||
|
||||
$this->list_id = 'templates';
|
||||
// inits list
|
||||
$second_list = parent::renderList();
|
||||
|
||||
@@ -1061,9 +1066,12 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError($this->l('The date you specified cannot be in the past.'));
|
||||
|
||||
// gets threshold
|
||||
$quantity_threshold = null;
|
||||
if (Tools::getValue('load_products') && Validate::isInt(Tools::getValue('load_products')))
|
||||
$quantity_threshold = (int)Tools::getValue('load_products');
|
||||
$quantity_threshold = Tools::getValue('load_products');
|
||||
|
||||
if (is_numeric($quantity_threshold))
|
||||
$quantity_threshold = (int)$quantity_threshold;
|
||||
else
|
||||
$quantity_threshold = null;
|
||||
|
||||
if (!count($this->errors))
|
||||
{
|
||||
@@ -1082,15 +1090,14 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
|
||||
//specific discount check
|
||||
$_POST['discount_rate'] = (float)str_replace(array(' ', ','), array('', '.'), Tools::getValue('discount_rate', 0));
|
||||
|
||||
}
|
||||
|
||||
// manage each associated product
|
||||
$this->manageOrderProducts();
|
||||
|
||||
// if the threshold is defined and we are saving the order
|
||||
if (Tools::isSubmit('submitAddsupply_order') && $quantity_threshold != null)
|
||||
$this->loadProducts($quantity_threshold);
|
||||
if (Tools::isSubmit('submitAddsupply_order') && Validate::isInt($quantity_threshold))
|
||||
$this->loadProducts((int)$quantity_threshold);
|
||||
}
|
||||
|
||||
// Manage state change
|
||||
@@ -1349,7 +1356,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
// first, converts the price to the default currency
|
||||
$price_converted_to_default_currency = Tools::convertPrice($supply_order_detail->unit_price_te, $supply_order->id_currency, false);
|
||||
|
||||
// then, converts the newly calculated price from the default currency to the needed currency
|
||||
// then, converts the newly calculated pri-ce from the default currency to the needed currency
|
||||
$price = Tools::ps_round(Tools::convertPrice($price_converted_to_default_currency,
|
||||
$warehouse->id_currency,
|
||||
true),
|
||||
@@ -1365,14 +1372,27 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
$price,
|
||||
true,
|
||||
$supply_order->id);
|
||||
if ($res) // if product has been added
|
||||
|
||||
if (!$res)
|
||||
$this->errors[] = Tools::displayError($this->l('Something went wrong when adding products to the warehouse.'));
|
||||
|
||||
$location = Warehouse::getProductLocation($supply_order_detail->id_product,
|
||||
$supply_order_detail->id_product_attribute,
|
||||
$warehouse->id);
|
||||
|
||||
$res = Warehouse::setProductlocation($supply_order_detail->id_product,
|
||||
$supply_order_detail->id_product_attribute,
|
||||
$warehouse->id,
|
||||
$location ? $location : '');
|
||||
|
||||
if ($res)
|
||||
{
|
||||
$supplier_receipt_history->add();
|
||||
$supply_order_detail->save();
|
||||
$supply_order->save();
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError($this->l('Something went wrong when adding products to the warehouse.'));
|
||||
$this->errors[] = Tools::displayError($this->l('Something went wrong when setting warehouse on product record'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1951,7 +1971,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
*/
|
||||
protected function afterAdd($object)
|
||||
{
|
||||
if (Tools::getValue('load_products') && Validate::isInt(Tools::getValue('load_products')))
|
||||
if (is_numeric(Tools::getValue('load_products')))
|
||||
$this->loadProducts((int)Tools::getValue('load_products'));
|
||||
|
||||
$this->object = $object;
|
||||
@@ -2024,7 +2044,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
$diff = (int)$threshold - (int)$real_quantity;
|
||||
}
|
||||
|
||||
if ($diff > 0)
|
||||
if ($diff >= 0)
|
||||
{
|
||||
// sets supply_order_detail
|
||||
$supply_order_detail = new SupplyOrderDetail();
|
||||
@@ -2037,7 +2057,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
$supply_order_detail->name = Product::getProductName($item['id_product'], $item['id_product_attribute'], $supply_order->id_lang);
|
||||
$supply_order_detail->ean13 = $item['ean13'];
|
||||
$supply_order_detail->upc = $item['upc'];
|
||||
$supply_order_detail->quantity_expected = (int)$diff;
|
||||
$supply_order_detail->quantity_expected = ((int)$diff == 0) ? 1 : (int)$diff;
|
||||
$supply_order_detail->exchange_rate = $order_currency->conversion_rate;
|
||||
|
||||
$product_currency = new Currency($item['id_currency']);
|
||||
|
||||
@@ -78,6 +78,7 @@ class AdminTrackingControllerCore extends AdminController
|
||||
public function getCustomListCategoriesEmpty()
|
||||
{
|
||||
$this->table = 'category';
|
||||
$this->list_id = 'empty_categories';
|
||||
$this->lang = true;
|
||||
$this->className = 'Category';
|
||||
$this->identifier = 'id_category';
|
||||
@@ -118,6 +119,7 @@ class AdminTrackingControllerCore extends AdminController
|
||||
return;
|
||||
|
||||
$this->table = 'product';
|
||||
$this->list_id = 'no_stock_products_attributes';
|
||||
$this->lang = true;
|
||||
$this->identifier = 'id_product';
|
||||
$this->_orderBy = 'id_product';
|
||||
@@ -162,6 +164,7 @@ class AdminTrackingControllerCore extends AdminController
|
||||
return;
|
||||
|
||||
$this->table = 'product';
|
||||
$this->list_id = 'no_stock_products';
|
||||
$this->className = 'Product';
|
||||
$this->lang = true;
|
||||
$this->identifier = 'id_product';
|
||||
@@ -202,13 +205,13 @@ class AdminTrackingControllerCore extends AdminController
|
||||
public function getCustomListProductsDisabled()
|
||||
{
|
||||
$this->table = 'product';
|
||||
$this->list_id = 'disabled_products';
|
||||
$this->className = 'Product';
|
||||
$this->lang = true;
|
||||
$this->identifier = 'id_product';
|
||||
$this->_orderBy = 'id_product';
|
||||
$this->_orderWay = 'DESC';
|
||||
$this->_filter = 'AND product_shop.`active` = 0';
|
||||
$this->list_no_filter = true;
|
||||
$this->tpl_list_vars = array('sub_title' => $this->l('List of disabled products:'));
|
||||
$this->show_toolbar = false;
|
||||
$this->_list_index = 'index.php?controller=AdminProducts';
|
||||
@@ -265,8 +268,17 @@ class AdminTrackingControllerCore extends AdminController
|
||||
|
||||
protected function clearFilters()
|
||||
{
|
||||
if ((Tools::isSubmit('submitResetcategory') && $this->table == 'category' ) || (Tools::isSubmit('submitResetproduct') && $this->table == 'product' ))
|
||||
$this->processResetFilters();
|
||||
if (Tools::isSubmit('submitResetcategory'))
|
||||
$this->processResetFilters('empty_categories');
|
||||
|
||||
if (Tools::isSubmit('submitResetproduct'))
|
||||
$this->processResetFilters('no_stock_products_attributes');
|
||||
|
||||
if (Tools::isSubmit('submitResetno_stock_products'))
|
||||
$this->processResetFilters('no_stock_products');
|
||||
|
||||
if (Tools::isSubmit('submitResetdisabled_products'))
|
||||
$this->processResetFilters('disabled_products');
|
||||
}
|
||||
|
||||
public function clearListOptions()
|
||||
@@ -280,7 +292,6 @@ class AdminTrackingControllerCore extends AdminController
|
||||
$this->_filter = '';
|
||||
$this->_group = '';
|
||||
$this->_where = '';
|
||||
$this->list_no_filter = true;
|
||||
$this->list_title = $this->l('Product disabled');
|
||||
}
|
||||
|
||||
|
||||
@@ -723,9 +723,8 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$arr_import_lang = explode('|', Tools::getValue('params_import_language')); /* 0 = Language ISO code, 1 = PS version */
|
||||
if (Validate::isLangIsoCode($arr_import_lang[0]))
|
||||
{
|
||||
if ($content = Tools::file_get_contents(
|
||||
'http://www.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.Tools::strtolower($arr_import_lang[0]).'.gzip', false,
|
||||
@stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5)))))
|
||||
$content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.Tools::strtolower($arr_import_lang[0]).'.gzip');
|
||||
if ($content)
|
||||
{
|
||||
$file = _PS_TRANSLATIONS_DIR_.$arr_import_lang[0].'.gzip';
|
||||
if ((bool)@file_put_contents($file, $content))
|
||||
@@ -2355,7 +2354,8 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
|
||||
foreach ($files_by_directiories['php'] as $dir => $files)
|
||||
foreach ($files as $file)
|
||||
if (Tools::file_exists_cache($dir.$file) && is_file($dir.$file) && !in_array($file, self::$ignore_folder) && preg_match('/\.php$/', $file))
|
||||
// If file exist and is not in ignore_folder, in the next step we check if a folder or mail
|
||||
if (Tools::file_exists_cache($dir.$file) && !in_array($file, self::$ignore_folder))
|
||||
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
|
||||
|
||||
// Get path of directory for find a good path of translation file
|
||||
@@ -2411,30 +2411,37 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
*/
|
||||
protected function getSubjectMail($dir, $file, $subject_mail)
|
||||
{
|
||||
$content = file_get_contents($dir.'/'.$file);
|
||||
$content = str_replace("\n", ' ', $content);
|
||||
// If is file and is not in ignore_folder
|
||||
if (is_file($dir.'/'.$file) && !in_array($file, self::$ignore_folder) && preg_match('/\.php$/', $file))
|
||||
{
|
||||
$content = file_get_contents($dir.'/'.$file);
|
||||
$content = str_replace("\n", ' ', $content);
|
||||
|
||||
// Subject must match with a template, therefor we first grep the Mail::Send() function then the Mail::l() inside.
|
||||
if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab))
|
||||
for ($i = 0; isset($tab[1][$i]); $i++)
|
||||
// Subject must match with a template, therefor we first grep the Mail::Send() function then the Mail::l() inside.
|
||||
if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab))
|
||||
{
|
||||
$tab2 = explode(',', $tab[1][$i]);
|
||||
if (is_array($tab2) && isset($tab2[1]))
|
||||
for ($i = 0; isset($tab[1][$i]); $i++)
|
||||
{
|
||||
$template = trim(str_replace('\'', '', $tab2[1]));
|
||||
foreach ($tab2 as $tab3)
|
||||
if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'\)/Us', $tab3.')', $matches))
|
||||
{
|
||||
if (!isset($subject_mail[$template]))
|
||||
$subject_mail[$template] = array();
|
||||
if (!in_array($matches[1], $subject_mail[$template]))
|
||||
$subject_mail[$template][] = $matches[1];
|
||||
}
|
||||
$tab2 = explode(',', $tab[1][$i]);
|
||||
if (is_array($tab2) && isset($tab2[1]))
|
||||
{
|
||||
$template = trim(str_replace('\'', '', $tab2[1]));
|
||||
foreach ($tab2 as $tab3)
|
||||
if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'\)/Us', $tab3.')', $matches))
|
||||
{
|
||||
if (!isset($subject_mail[$template]))
|
||||
$subject_mail[$template] = array();
|
||||
if (!in_array($matches[1], $subject_mail[$template]))
|
||||
$subject_mail[$template][] = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array($file, self::$ignore_folder) && is_dir($dir.'/'.$file))
|
||||
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
|
||||
}
|
||||
// Of if is colder, we scan colder for check if find in folder and subfolder
|
||||
else if (!in_array($file, self::$ignore_folder) && is_dir($dir.'/'.$file))
|
||||
foreach( scandir($dir.'/'.$file ) as $temp )
|
||||
$subject_mail = $this->getSubjectMail($dir.'/'.$file, $temp, $subject_mail);
|
||||
|
||||
return $subject_mail;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user