'.
- ' '.$this->l('How to create a new carrier?').''.
- ' '.
- '
'.'
-
'.$this->l('Click "Add new".').' '.'
-
'.$this->l('Fill in the fields and click "Save".').'
-
'.$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".').'
-
'.$this->l('Click "Add new".').'
-
'.$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.').'
-
'.$this->l('When you are done, click "Save".').'
-
'.$this->l('Click on the "Shipping" tab.').'
-
'.$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.').'
-
'.$this->l('For each zone, enter a price. Click "Save".').'
-
'.$this->l('You\'re set! The new carrier will be displayed to your customers.').'
-
-
';
- }
-
- public function displayForm($isMainTab = true)
- {
- parent::displayForm();
-
- if (!($obj = $this->loadObject(true)))
- return;
-
- echo '
- ';
- }
-
- public function beforeDelete($object)
- {
- return $object->isUsed();
- }
-
- public function afterDelete($object, $oldId)
- {
- $object->copyCarrierData((int)($oldId));
- }
-
- 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 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();
- 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.').' '.$this->table.'';
- 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.').' '.$this->table.' '.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.').' '.$this->table.'';
- else if (($_POST['id_'.$this->table] = $object->id /* voluntary */) && $this->postImage($object->id) && $this->_redirect)
- {
- $this->changeZones($object->id);
- $this->changeGroups($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();
- }
- }
-
-
- 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)
- {
- $order_by = ($order_by && $this->context->cookie->__get($this->table.'Orderby')) ? $this->context->cookie->__get($this->table.'Orderby'): 'position';
- parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
- }
-}
\ No newline at end of file
diff --git a/admin-dev/themes/template/carriers/form.tpl b/admin-dev/themes/template/carriers/form.tpl
new file mode 100644
index 000000000..41b93ee61
--- /dev/null
+++ b/admin-dev/themes/template/carriers/form.tpl
@@ -0,0 +1,295 @@
+{*
+* 2007-2011 PrestaShop
+*
+* NOTICE OF LICENSE
+*
+* This source file is subject to the Academic Free License (AFL 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/afl-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
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 8971 $
+* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*}
+
+{if $firstCall}
+
+
+{/if}
+
+
+
+
diff --git a/admin-dev/themes/template/form_group.tpl b/admin-dev/themes/template/form_group.tpl
new file mode 100644
index 000000000..d7565517b
--- /dev/null
+++ b/admin-dev/themes/template/form_group.tpl
@@ -0,0 +1,49 @@
+{*
+* 2007-2011 PrestaShop
+*
+* NOTICE OF LICENSE
+*
+* This source file is subject to the Academic Free License (AFL 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/afl-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
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 8971 $
+* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*}
+
+{if count($groups) && isset($groups)}
+
+{/if}
\ No newline at end of file
diff --git a/admin-dev/themes/template/form_shop.tpl b/admin-dev/themes/template/form_shop.tpl
new file mode 100644
index 000000000..199ac05ae
--- /dev/null
+++ b/admin-dev/themes/template/form_shop.tpl
@@ -0,0 +1,131 @@
+{*
+* 2007-2011 PrestaShop
+*
+* NOTICE OF LICENSE
+*
+* This source file is subject to the Academic Free License (AFL 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/afl-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
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 8971 $
+* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*}
+
+
+
+