//FIxed Added Controller AdminCarrierController

This commit is contained in:
lLefevre
2011-10-19 14:36:25 +00:00
parent 41140ad21d
commit 99aa249393
9 changed files with 934 additions and 27 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ class AdminOrders extends AdminTab
'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));
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDtFIcons', 'orderby' => false, 'search' => false));
$this->shopLinkType = 'shop';
$this->shopShareDatas = Shop::SHARE_ORDER;
parent::__construct();
+3 -3
View File
@@ -26,7 +26,7 @@
*/
include(_PS_ADMIN_DIR_.'/tabs/AdminOrdersStates.php');
include(_PS_ADMIN_DIR_.'/tabs/AdminReturnStates.php');
include(_PS_CONTROLLER_DIR_.'/admin/AdminReturnStatesController.php');
class AdminStatuses extends AdminTab
{
@@ -37,7 +37,7 @@ class AdminStatuses extends AdminTab
{
$this->table = array('order_state', 'order_return_state');
$this->adminOrdersStates = new adminOrdersStates();
$this->adminReturnStates = new adminReturnStates();
$this->adminReturnStates = new AdminReturnStatesController();
parent::__construct();
}
@@ -77,7 +77,7 @@ class AdminStatuses extends AdminTab
if (!Tools::isSubmit('updateorder_return_state') AND !Tools::isSubmit('submitAddorder_return_state'))
echo '<div style="margin:10px">&nbsp;</div>';
echo '<h2>'.$this->l('Order return statuses').'</h2>';
$this->adminReturnStates->display($this->token);
$this->adminReturnStates->initContent($this->token);
}
}
}
+9
View File
@@ -318,8 +318,14 @@
'AdminAliasesController' => '',
'AdminBackupControllerCore' => 'controllers/admin/AdminBackupController.php',
'AdminBackupController' => '',
'AdminCarriersControllerCore' => 'controllers/admin/AdminCarriersController.php',
'AdminCarriersController' => '',
'AdminContactsControllerCore' => 'controllers/admin/AdminContactsController.php',
'AdminContactsController' => '',
'AdminCurrenciesControllerCore' => 'controllers/admin/AdminCurrenciesController.php',
'AdminCurrenciesController' => '',
'AdminDbControllerCore' => 'controllers/admin/AdminDbController.php',
'AdminDbController' => '',
'AdminGendersController' => 'controllers/admin/AdminGendersController.php',
'AdminGroupShopControllerCore' => 'controllers/admin/AdminGroupShopController.php',
'AdminGroupShopController' => '',
@@ -330,6 +336,7 @@
'AdminQuickAccessesController' => 'controllers/admin/AdminQuickAccessesController.php',
'AdminRequestSqlControllerCore' => 'controllers/admin/AdminRequestSqlController.php',
'AdminRequestSqlController' => '',
'AdminReturnStatesController' => 'controllers/admin/AdminReturnStatesController.php',
'AdminSearchEnginesControllerCore' => 'controllers/admin/AdminSearchEnginesController.php',
'AdminSearchEnginesController' => '',
'AdminShopUrlControllerCore' => 'controllers/admin/AdminShopUrlController.php',
@@ -343,6 +350,8 @@
'AdminStockManagementController' => 'controllers/admin/AdminStockManagementController.php',
'AdminStoresControllerCore' => 'controllers/admin/AdminStoresController.php',
'AdminStoresController' => '',
'AdminTaxRulesGroupControllerCore' => 'controllers/admin/AdminTaxRulesGroupController.php',
'AdminTaxRulesGroupController' => '',
'AdminToolsControllerCore' => 'controllers/admin/AdminToolsController.php',
'AdminToolsController' => 'override/controllers/admin/AdminToolsController.php',
'AdminTrackingController' => 'controllers/admin/AdminTrackingController.php',
+3 -3
View File
@@ -225,7 +225,6 @@ abstract class AdminTabCore
// if ($className == 'AdminCategories' OR $className == 'AdminProducts')
// $className = 'AdminCatalog';
$this->token = Tools::getAdminToken($className.(int)$this->id.(int)$this->context->employee->id);
if (!Shop::isFeatureActive())
$this->shopLinkType = '';
}
@@ -561,6 +560,7 @@ abstract class AdminTabCore
{
if (!isset($this->table))
return false;
// set token
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
@@ -1271,7 +1271,7 @@ abstract class AdminTabCore
$limit = ((!isset($this->context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[1] : $limit = $this->context->cookie->{$this->table.'_pagination'});
if (!Validate::isTableOrIdentifier($this->table))
die (Tools::displayError('Table name is invalid:').' "'.$this->table.'"');
$this->_errors[] = Tools::displayError('Table name is invalid:').' "'.$this->table.'"';
if (empty($orderBy))
$orderBy = $this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy;
@@ -1340,7 +1340,7 @@ abstract class AdminTabCore
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filterKey).'`? *sa#', $this->_join))
$filterShop = 'JOIN `'._DB_PREFIX_.$this->table.'_'.$filterKey.'` sa ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filterKey.' IN ('.implode(', ', $idenfierShop).'))';
}
///////////////////////
/* Query in order to get results with all fields */
$sql = 'SELECT SQL_CALC_FOUND_ROWS
'.($this->_tmpTableFilter ? ' * FROM (SELECT ' : '').'
-20
View File
@@ -923,26 +923,6 @@ class OrderCore extends ObjectModel
$this->update();
}
public static function printPDFIcons($id_order, $tr)
{
$order = new Order($id_order);
$orderState = OrderHistory::getLastOrderState($id_order);
if (!Validate::isLoadedObject($orderState) OR !Validate::isLoadedObject($order))
die(Tools::displayError('Invalid objects'));
echo '<span style="width:20px; margin-right:5px;">';
if (($orderState->invoice AND $order->invoice_number) AND (int)($tr['product_number']))
echo '<a href="pdf.php?id_order='.(int)($order->id).'&pdf"><img src="../img/admin/tab-invoice.gif" alt="invoice" /></a>';
else
echo '&nbsp;';
echo '</span>';
echo '<span style="width:20px;">';
if ($orderState->delivery AND $order->delivery_number)
echo '<a href="pdf.php?id_delivery='.(int)($order->delivery_number).'"><img src="../img/admin/delivery.gif" alt="delivery" /></a>';
else
echo '&nbsp;';
echo '</span>';
}
public static function getByDelivery($id_delivery)
{
$sql = 'SELECT id_order
@@ -0,0 +1,611 @@
<?php
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 8971 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminCarriersControllerCore extends AdminController
{
public function __construct()
{
$this->table = 'carrier';
$this->className = 'Carrier';
$this->lang = false;
$this->deleted = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->requiredDatabase = true;
$this->context = Context::getContext();
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fieldImageSettings = array(
'name' => 'logo',
'dir' => 'st'
);
parent::__construct();
}
public function initList()
{
$this->_select = 'b.*';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'carrier_lang` b ON a.id_carrier = b.id_carrier';
$this->_where = 'AND b.id_lang = '.$this->context->language->id;
$this->fieldsDisplay = array(
'id_carrier' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
'name' => array(
'title' => $this->l('Name'),
'width' => 100
),
'image' => array(
'title' => $this->l('Logo'),
'align' => 'center',
'image' => 's',
'orderby' => false,
'search' => false
),
'delay' => array(
'title' => $this->l('Delay'),
'width' => 300,
'orderby' => false
),
'active' => array(
'title' => $this->l('Status'),
'align' => 'center',
'active' => 'status',
'type' => 'bool',
'orderby' => false
),
'is_free' => array(
'title' => $this->l('Is Free'),
'align' => 'center',
'icon' => array(
0 => 'disabled.gif',
1 => 'enabled.gif',
'default' => 'disabled.gif'
),
'type' => 'bool',
'orderby' => false
),
'position' => array(
'title' => $this->l('Position'),
'width' => 40,
'filter_key' => 'cp!position',
'align' => 'center',
'position' => 'position'
)
);
}
public function initOptions()
{
$carrier_default_sort = array(
array('value' => Carrier::SORT_BY_PRICE, 'name' => $this->l('Price')),
array('value' => Carrier::SORT_BY_POSITION, 'name' => $this->l('Position'))
);
$this->options = array(
'general' => array(
'title' => $this->l('Carrier options'),
'fields' => array(
'PS_CARRIER_DEFAULT' => array(
'title' => $this->l('Default carrier:'),
'desc' => $this->l('The default carrier used in shop'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_carrier',
'list' => Carrier::getCarriers((int)Configuration::get('PS_LANG_DEFAULT'), true, false, false, null, Carrier::ALL_CARRIERS)
),
'PS_CARRIER_DEFAULT_SORT' => array(
'title' => $this->l('Carrier default sort:'),
'desc' => $this->l('This default sort will be available only on front-office'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'value',
'list' => $carrier_default_sort
),
),
'submit' => array()
)
);
}
public function initForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Carriers'),
'image' => '../img/admin/delivery.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Company:'),
'name' => 'name',
'size' => 25,
'required' => true,
'hint' => $this->l('Allowed characters: letters, spaces and').' ().-',
'p' => array(
$this->l('Carrier name displayed during checkout'),
$this->l('With a value of 0, the carrier name will be replaced by the shop name')
)
),
array(
'type' => 'file',
'label' => $this->l('Logo:'),
'name' => 'logo',
'p' => $this->l('Upload logo from your computer').' (.gif, .jpg, .jpeg '.$this->l('or').' .png)'
),
array(
'type' => 'text',
'label' => $this->l('Transit time:'),
'name' => 'delay',
'lang' => true,
'attributeLang' => 'delay',
'required' => true,
'size' => 41,
'maxlength' => 128,
'p' => $this->l('Time taken for product delivery; displayed during checkout')
),
array(
'type' => 'text',
'label' => $this->l('URL:'),
'name' => 'url',
'size' => 40,
'p' => $this->l('URL for the tracking number; type \'@\' where the tracking number will appear')
),
array(
'type' => 'checkbox',
'label' => $this->l('Zone:'),
'name' => 'zone',
'values' => array(
'query' => Zone::getZones(false),
'id' => 'id_zone',
'name' => 'name'
),
'p' => $this->l('The zone in which this carrier is to be used')
),
array(
'type' => 'group',
'label' => $this->l('Group access:'),
'name' => 'groupBox',
'values' => Group::getGroups(Context::getContext()->language->id),
'p' => $this->l('Mark all groups you want to give access to this carrier')
),
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')
)
),
'p' => $this->l('Include or exclude carrier from list of carriers on Front Office')
),
array(
'type' => 'radio',
'label' => $this->l('Apply shipping cost:'),
'name' => 'is_free',
'required' => false,
'class' => 't',
'values' => array(
array(
'id' => 'is_free_on',
'value' => 0,
'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" />'
),
array(
'id' => 'is_free_off',
'value' => 1,
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" />'
)
),
'p' => $this->l('Apply shipping costs and additional shipping costs by products in carrier price')
),
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' => 'radio',
'label' => $this->l('Shipping & 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')
)
),
'p' => $this->l('Include the shipping & handling costs in carrier price')
),
array(
'type' => 'radio',
'label' => $this->l('Billing:'),
'name' => 'shipping_method',
'required' => false,
'class' => 't',
'br' => true,
'values' => array(
array(
'id' => 'billing_default',
'value' => Carrier::SHIPPING_METHOD_DEFAULT,
'label' => $this->l('Default behavior')
),
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('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'
),
'p' => $this->l('Out-of-range behavior when none is defined (e.g., when a customer\'s cart weight is greater than the highest range limit)')
),
array(
'type' => 'hidden',
'label' => $this->l('Module:'),
'name' => 'is_module'
),
array(
'type' => 'hidden',
'name' => 'external_module_name',
),
array(
'type' => 'hidden',
'name' => 'shipping_external'
),
array(
'type' => 'hidden',
'name' => 'need_range'
)
)
);
if (Shop::isFeatureActive())
{
$this->fields_form['input'][] = array(
'type' => 'shop',
'label' => $this->l('Shop association:'),
'name' => 'checkBoxShopAsso',
'values' => Shop::getTree()
);
}
$this->fields_form['submit'] = array(
'title' => $this->l(' Save '),
'class' => 'button'
);
}
public function postProcess()
{
if (Tools::getValue('submitAdd'.$this->table))
{
/* Checking fields validity */
$this->validateRules();
if (!count($this->_errors))
{
$id = (int)Tools::getValue('id_'.$this->table);
/* Object update */
if (isset($id) && !empty($id))
{
if ($this->tabAccess['edit'] === '1')
{
$object = new $this->className($id);
if (Validate::isLoadedObject($object))
{
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$id);
$object->deleted = 1;
$object->update();
$object_new = new $this->className();
$this->copyFromPost($object_new, $this->table);
$object_new->position = $object->position;
$result = $object_new->add();
$this->updateAssoShop($object->id, $object_new->id);
if (Validate::isLoadedObject($object_new))
{
$this->afterDelete($object_new, $object->id);
Hook::updateCarrier((int)$object->id, $object_new);
}
$this->changeGroups($object_new->id);
if (!$result)
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b>';
else if ($this->postImage($object_new->id))
{
$this->changeZones($object_new->id);
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4&token='.$this->token);
}
}
else
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.
$this->table.'</b> '.Tools::displayError('(cannot load object)');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
/* Object creation */
else
{
if ($this->tabAccess['add'] === '1')
{
$object = new $this->className();
$this->copyFromPost($object, $this->table);
$object->position = Carrier::getHigherPosition() + 1;
if (!$object->add())
$this->_errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.'</b>';
else if (($_POST['id_'.$this->table] = $object->id /* voluntary */) && $this->postImage($object->id) && $this->_redirect)
{
$this->changeZones($object->id);
$this->changeGroups($object->id);
$this->updateAssoShop($object->id);
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3&token='.$this->token);
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
}
}
else if ((isset($_GET['status'.$this->table]) || isset($_GET['status'])) && Tools::getValue($this->identifier))
{
if ($this->tabAccess['edit'] === '1')
{
if (Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT'))
$this->_errors[] = Tools::displayError('You can\'t disable the default carrier, please change your default carrier first.');
else
parent::postProcess();
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
else
{
if ((Tools::isSubmit('submitDel'.$this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox')))
|| (isset($_GET['delete'.$this->table]) && Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT')))
$this->_errors[] = $this->l('Please set another carrier as default before deleting');
else
parent::postProcess();
}
}
/**
* Overload the property $fields_value
*
* @param object $obj
*/
public function getFieldsValues($obj)
{
if ($this->getFieldValue($obj, 'is_module'))
$this->fields_value['is_module'] = 1;
if ($this->getFieldValue($obj, 'shipping_external'))
$this->fields_value['shipping_external'] = 1;
if ($this->getFieldValue($obj, 'need_range'))
$this->fields_value['need_range'] = 1;
// Added values of object Zone
$carrier_zones = $obj->getZones();
$carrier_zones_ids = array();
if (is_array($carrier_zones))
foreach ($carrier_zones as $carrier_zone)
$carrier_zones_ids[] = $carrier_zone['id_zone'];
$zones = Zone::getZones(false);
foreach ($zones as $zone)
$this->fields_value['zone_'.$zone['id_zone']] = Tools::getValue('zone_'.$zone['id_zone'], (in_array($zone['id_zone'], $carrier_zones_ids)));
// Added values of object Group
$carrier_groups = $obj->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)
$this->fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], (in_array($group['id_group'], $carrier_groups_ids)));
//Added values of object Shop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
}
}
public function initContent()
{
if (!($obj = $this->loadObject(true)))
return;
if ($this->display != 'edit' && $this->display != 'add')
$this->display = 'list';
$this->getFieldsValues($obj);
parent::initContent();
if ($this->display == 'list')
{
$this->displayInformation(
'&nbsp;<b>'.$this->l('How to 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 decide a price range or a weight range for which the new carrier will be available.
Under the "Shipping" tab, click either "Price Ranges" or "Weight Ranges".').'
</li>
<li>'.$this->l('Click "Add new".').'</li>
<li>'.
$this->l('Select the name of the carrier and define the price range or the weight range.
For example the carrier can be made available for a weight range between 0 and 5kgs. Another carrier will have a range between 5 and 10kgs.').'
</li>
<li>'.$this->l('When you are done, click "Save".').'</li>
<li>'.$this->l('Click on the "Shipping" tab.').'</li>
<li>'.
$this->l('You need to choose the fees that will be applied for this carrier.
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. Click "Save".').'</li>
<li>'.$this->l('You\'re set! The new carrier will be displayed to your customers.').'</li>
</ul>'
);
}
}
public function beforeDelete($object)
{
return $object->isUsed();
}
public function afterDelete($object, $old_id)
{
$object->copyCarrierData((int)$old_id);
}
private function changeGroups($id_carrier, $delete = true)
{
if ($delete)
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$id_carrier);
$groups = Db::getInstance()->executeS('SELECT id_group FROM `'._DB_PREFIX_.'group`');
foreach ($groups as $group)
if (Tools::getIsset('groupBox') && in_array($group['id_group'], Tools::getValue('groupBox')))
Db::getInstance()->execute('
INSERT INTO '._DB_PREFIX_.'carrier_group (id_group, id_carrier)
VALUES('.(int)$group['id_group'].','.(int)$id_carrier.')
');
}
public function changeZones($id)
{
$carrier = new $this->className($id);
if (!Validate::isLoadedObject($carrier))
die (Tools::displayError('Object cannot be loaded'));
$zones = Zone::getZones(true);
foreach ($zones as $zone)
if (count($carrier->getZone($zone['id_zone'])))
{
if (!isset($_POST['zone_'.$zone['id_zone']]) || !$_POST['zone_'.$zone['id_zone']])
$carrier->deleteZone($zone['id_zone']);
}
else
if (isset($_POST['zone_'.$zone['id_zone']]) && $_POST['zone_'.$zone['id_zone']])
$carrier->addZone($zone['id_zone']);
}
public function displayListContent($token = null)
{
foreach ($this->_list as $key => $list)
if ($list['name'] == '0')
$this->_list[$key]['name'] = Configuration::get('PS_SHOP_NAME');
parent::displayListContent($token);
}
/**
* Modifying initial getList method to display position feature (drag and drop)
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if ($order_by && $this->context->cookie->__get($this->table.'Orderby'))
$order_by = $this->context->cookie->__get($this->table.'Orderby');
else
$order_by = 'position';
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 190 KiB

+307
View File
@@ -1,7 +1,314 @@
<?php
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
//
// IMPORTANT : don't forget to delete the underscore _ in the file name if you want to use it !
//
// if FB class is already loaded, just enable it. else, enable it only if fb.php exists and is loaded
if (!defined('PS_USE_FIREPHP') AND class_exists('FB'))
define('PS_USE_FIREPHP',true);
elseif (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'fb.php'))
{
if (!defined('PS_USE_FIREPHP'))
{
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'fb.php');
define('PS_USE_FIREPHP',true);
}
else
define('PS_USE_FIREPHP',false);
}
else
define('PS_USE_FIREPHP',class_exists('FB'));
class Tools extends ToolsCore
{
/**
* Redirect user to another page after 5 sec
*
* @param string $url Desired URL
* @param string $baseUri Base URI (optional)
*/
public static function redirect($url, $baseUri = __PS_BASE_URI__, Link $link = null)
{
if (!$link)
$link = Context::getContext()->link;
if (strpos($url, 'http://') === FALSE && strpos($url, 'https://') === FALSE)
{
if (strpos($url, $baseUri) !== FALSE && strpos($url, $baseUri) == 0)
$url = substr($url, strlen($baseUri));
$explode = explode('?', $url);
$url = $link->getPageLink($explode[0], true);
if (isset($explode[1]))
$url .= '?'.$explode[1];
$baseUri = '';
}
if (isset($_SERVER['HTTP_REFERER']) AND ($url == $_SERVER['HTTP_REFERER']))
header('Refresh: 5; url='.$_SERVER['HTTP_REFERER']);
else
header('Refresh: 5; url='.$baseUri.$url);
echo '<h1>Redirection automatique dans 5 secondes</h1><a href='.$url.'>'.$url.'</a>';
exit;
}
/**
* Redirect url wich allready PS_BASE_URI after 5 sec
*
* @param string $url Desired URL
*/
public static function redirectLink($url)
{
if (!preg_match('@^https?://@i', $url))
{
if (strpos($url, __PS_BASE_URI__) !== FALSE && strpos($url, __PS_BASE_URI__) == 0)
$url = substr($url, strlen(__PS_BASE_URI__));
$explode = explode('?', $url);
$url = Context::getContext()->link->getPageLink($explode[0]);
if (isset($explode[1]))
$url .= '?'.$explode[1];
}
header('Refresh: 5; url='.$url);
echo '<h1>Redirection automatique dans 5 secondes</h1><a href='.$url.'>'.$url.'</a>';
exit;
}
/**
* Redirect user to another admin page after 5 sec
*
* @param string $url Desired URL
*/
public static function redirectAdmin($url)
{
header('Refresh: 5; url='.$url);
echo '<h1>Redirection automatique dans 5 secondes</h1><a href='.$url.'>'.$url.'</a>';
exit;
}
/**
* Display an error with detailed object
* (display in firefox console if Firephp is enabled)
*
* @param mixed $object
* @param boolean $kill
* @return $object if $kill = false;
*/
public static function dieObject($object, $kill = true)
{
if(PS_USE_FIREPHP)
FB::error($object);
else
return parent::dieObject($object,$kill);
if ($kill)
die('END');
return $object;
}
/**
* ALIAS OF dieObject() - Display an error with detailed object
* (display in firefox console if Firephp is enabled)
*
* @param object $object Object to display
*/
public static function d($obj, $kill = true)
{
if(PS_USE_FIREPHP)
FB::error($obj);
else
parent::d($obj,$kill);
if ($kill)
die('END');
return $object;
}
/**
* ALIAS OF dieObject() - Display an error with detailed object but don't stop the execution
* (display in firefox console if Firephp is enabled)
*
* @param object $object Object to display
*/
public static function p($object)
{
if(PS_USE_FIREPHP)
FB::info($object);
else
return parent::p($object);
return $object;
}
/**
* Display a warning message indicating that the method is deprecated
* (display in firefox console if Firephp is enabled)
*/
public static function displayAsDeprecated()
{
if (_PS_DISPLAY_COMPATIBILITY_WARNING_)
{
$backtrace = debug_backtrace();
$callee = next($backtrace);
if (PS_USE_FIREPHP)
FB::warn('Function <strong>'.$callee['function'].'()</strong> is deprecated in <strong>'.$callee['file'].'</strong> on line <strong>'.$callee['line'].'</strong><br />', 'Deprecated method');
else
trigger_error('Function <strong>'.$callee['function'].'()</strong> is deprecated in <strong>'.$callee['file'].'</strong> on line <strong>'.$callee['line'].'</strong><br />', E_USER_WARNING);
$message = Tools::displayError('The function').' '.$callee['function'].' ('.Tools::displayError('Line').' '.$callee['line'].') '.Tools::displayError('is deprecated and will be removed in the next major version.');
Logger::addLog($message, 3, $callee['class']);
}
}
/**
* Display a warning message indicating that the parameter is deprecated
* (display in firefox console if Firephp is enabled)
*/
public static function displayParameterAsDeprecated($parameter)
{
if (_PS_DISPLAY_COMPATIBILITY_WARNING_)
{
$backtrace = debug_backtrace();
$callee = next($backtrace);
trigger_error('Parameter <strong>'.$parameter.'</strong> in function <strong>'.$callee['function'].'()</strong> is deprecated in <strong>'.$callee['file'].'</strong> on line <strong>'.$callee['Line'].'</strong><br />', E_USER_WARNING);
if(PS_USE_FIREPHP)
FB::trace('Parameter <strong>'.$parameter.'</strong> in function <strong>'.$callee['function'].'()</strong> is deprecated in <strong>'.$callee['file'].'</strong> on line <strong>'.$callee['Line'].'</strong><br />', 'deprecated parameter');
else
$message = Tools::displayError('The parameter').' '.$parameter.' '.Tools::displayError(' in function ').' '.$callee['function'].' ('.Tools::displayError('Line').' '.$callee['Line'].') '.Tools::displayError('is deprecated and will be removed in the next major version.');
Logger::addLog($message, 3, $callee['class']);
}
}
/**
* use of FirePHP::error() if allowed
*
* @param mixed $obj
* @param string $label
* @return void
*/
public static function error($obj, $label = '')
{
if(PS_USE_FIREPHP)
FB::error($obj, $label);
}
/**
* use of FirePHP::warn() if allowed
*
* @param mixed $obj
* @param string $label
* @return void
*/
public static function warn($obj, $label = '')
{
if(PS_USE_FIREPHP)
FB::warn($obj, $label);
}
/**
* use of FirePHP::info() if allowed
*
* @param mixed $obj
* @param string $label
* @return void
*/
public static function info($obj, $label = '')
{
if(PS_USE_FIREPHP)
FB::info($obj, $label);
}
/**
* use of FirePHP::log() if allowed
*
* @param mixed $obj
* @param string $label
* @return void
*/
public static function log($obj, $label = '')
{
if(PS_USE_FIREPHP)
FB::log($obj,$label);
}
/**
* display debug_backtrace()
* (display in firefox console if Firephp is enabled)
*
* @param mixed $obj
* @return void
*/
public static function trace($obj = NULL, $label = '')
{
if(PS_USE_FIREPHP)
FB::trace($obj, $label);
else{
Tools::p($obj);
echo'<pre><h1>'.$label.'</h1><br/>';
debug_print_backtrace();
echo '</pre>';
}
}
}
// Add some convenient shortcut
if (!function_exists('error'))
{
function error($obj, $label = ''){
return Tools::error($obj, $label);
}
}
if (!function_exists('warn'))
{
function warn($obj, $label = ''){
return Tools::warn($obj,$label);
}
}
if (!function_exists('info'))
{
function info($obj, $label = ''){
return Tools::info($obj, $label);
}
}
if (!function_exists('log'))
{
function log($obj, $label = ''){
return Tools::log($obj, $label);
}
}
if (!function_exists('trace'))
{
function trace($obj, $label = ''){
return Tools::trace($obj, $label);
}
}