|
|
|
@@ -1,39 +1,13 @@
|
|
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* 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 <contact@prestashop.com>
|
|
|
|
|
* @copyright 2007-2011 PrestaShop SA
|
|
|
|
|
* @version Release: $Revision: 1.4 $
|
|
|
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
|
|
|
* International Registered Trademark & Property of PrestaShop SA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Avoid direct access to the file
|
|
|
|
|
if (!defined('_PS_VERSION_'))
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
require_once(_PS_MODULE_DIR_."/tntcarrier/classes/PackageTnt.php");
|
|
|
|
|
require_once(_PS_MODULE_DIR_."/tntcarrier/classes/TntWebService.php");
|
|
|
|
|
require_once(_PS_MODULE_DIR_."/tntcarrier/classes/OrderInfoTnt.php");
|
|
|
|
|
require_once(_PS_MODULE_DIR_."/tntcarrier/classes/serviceCache.php");
|
|
|
|
|
|
|
|
|
|
if (!defined('_PS_VERSION_'))
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
class TntCarrier extends CarrierModule
|
|
|
|
|
{
|
|
|
|
|
public $id_carrier;
|
|
|
|
@@ -52,7 +26,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
{
|
|
|
|
|
$this->name = 'tntcarrier';
|
|
|
|
|
$this->tab = 'shipping_logistics';
|
|
|
|
|
$this->version = '1.2.1';
|
|
|
|
|
$this->version = '1.0';
|
|
|
|
|
$this->author = 'PrestaShop';
|
|
|
|
|
$this->limited_countries = array('fr');
|
|
|
|
|
|
|
|
|
@@ -77,10 +51,8 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
foreach($carriers as $carrier)
|
|
|
|
|
$id_carrier_list[] .= $carrier['id_carrier'];
|
|
|
|
|
|
|
|
|
|
if (count($warning) > 1)
|
|
|
|
|
if (count($warning))
|
|
|
|
|
$this->warning .= implode(' , ',$warning).$this->l('must be configured to use this module correctly.').' ';
|
|
|
|
|
if (count($warning) == 1)
|
|
|
|
|
$this->warning .= implode(' , ',$warning).$this->l('has to be configured to use this module correctly.').' ';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -249,7 +221,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
|
|
|
|
|
public function getContent()
|
|
|
|
|
{
|
|
|
|
|
$this->_html .= '<h2><a href="https://www.tnt.fr/public/utilisateurs/adminExt/new.do"><img src="'.$this->_path.'carrier.jpg" alt="' . $this->l('TNT Carrier').'" /></a></h2>';
|
|
|
|
|
$this->_html .= '<h2><a href="http://www.tnt.fr/"><img src="'.$this->_path.'logo.gif" alt="' . $this->l('TNT Carrier').'" /></a></h2>';
|
|
|
|
|
if (!empty($_POST) AND Tools::isSubmit('submitSave'))
|
|
|
|
|
{
|
|
|
|
|
$this->_postValidation();
|
|
|
|
@@ -257,7 +229,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$this->_postProcess();
|
|
|
|
|
else
|
|
|
|
|
foreach ($this->_postErrors AS $err)
|
|
|
|
|
$this->_html .= '<div class="error"><img src="'._PS_IMG_.'admin/forbbiden.gif" alt="nok" /> '.$err.'</div>';
|
|
|
|
|
$this->_html .= '<div class="alert error"><img src="'._PS_IMG_.'admin/forbbiden.gif" alt="nok" /> '.$err.'</div>';
|
|
|
|
|
}
|
|
|
|
|
$this->_displayForm();
|
|
|
|
|
return $this->_html;
|
|
|
|
@@ -268,14 +240,28 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
global $smarty;
|
|
|
|
|
|
|
|
|
|
$globalVar = array(
|
|
|
|
|
'tab' => htmlentities(Tools::getValue('tab')),
|
|
|
|
|
'configure' => htmlentities(Tools::getValue('configure')),
|
|
|
|
|
'token' => htmlentities(Tools::getValue('token')),
|
|
|
|
|
'tab_module' => htmlentities(Tools::getValue('tab_module')),
|
|
|
|
|
'module_name' => htmlentities(Tools::getValue('module_name')));
|
|
|
|
|
'tab' => Tools::getValue('tab'),
|
|
|
|
|
'configure' => Tools::getValue('configure'),
|
|
|
|
|
'token' => Tools::getValue('token'),
|
|
|
|
|
'tab_module' => Tools::getValue('tab_module'),
|
|
|
|
|
'module_name' => Tools::getValue('module_name'));
|
|
|
|
|
|
|
|
|
|
$smarty->assign('glob', $globalVar);
|
|
|
|
|
|
|
|
|
|
$lang = array(
|
|
|
|
|
'followParameters' => $this->l('The following parameters were provided to you by TNT'), 'registered' => $this->l('If you are not yet registered, click '), 'here' => $this->l('here'),
|
|
|
|
|
'accountSetting' => $this->l('Account settings'), 'shippingSetting' => $this->l('Shipping Settings'), 'serviceSetting' => $this->l('Service Settings'),
|
|
|
|
|
'accountTNT' => $this->l('Account TNT'), 'login' => $this->l('Login'), 'password' => $this->l('Password'), 'numberAccount' => $this->l('Number account'),
|
|
|
|
|
'fillDataInTheForm' => $this->l('Fill Data in the form'), 'shipping' => $this->l('Shipping'), 'collect' => $this->l('Would you like TNT to pick up your package ?'), 'noDeposit' => $this->l('No (Deposit)'),
|
|
|
|
|
'yes' => $this->l('Yes'), 'chooseYourDepositoryLocation' => $this->l('Choose your depository location'), 'pexCode' => $this->l('Pex Code'), 'companyName' => $this->l('Company Name'),
|
|
|
|
|
'lastName' => $this->l('Last name'), 'firstName' => $this->l('First name'), 'address1' => $this->l('Address line 1'), 'address2' => $this->l('Address line 2'), 'zip' => $this->l('Zip / Postal Code'), 'city' => $this->l('Your City'),
|
|
|
|
|
'email' => $this->l('Your Email Address'), 'phone' => $this->l('Your Phone Number'), 'closingTime' => $this->l('Your Closing Time'), 'saturdayDelivery' => $this->l('Saturday Delivery'), 'no' => $this->l('No'),
|
|
|
|
|
'labelFormatPrinting' => $this->l('Label Format for printing (This Label will have to be sticked on the package)'), 'a4printing' => $this->l('A4 printing'), 'withoutPrintingLogoTNT' => $this->l('without printing the logo TNT'), 'withReversePrint' => $this->l('with a reverse print'), 'withoutPrintingLogoTNTWithReversePrint' => $this->l('without printing the logo TNT and with a reverse print'),
|
|
|
|
|
'newService' => $this->l('New Service'), 'id' => $this->l('ID'), 'name' => $this->l('Name'), 'description' => $this->l('Description'), 'code' => $this->l('Code'), 'additionnalCharge' => $this->l('Additionnal charge (Euros)'), 'activated' => $this->l('Activated'), 'edit' => $this->l('edit'), 'delete' => $this->l('delete'), 'place' => $this->l('Place')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$smarty->assign('lang', $lang);
|
|
|
|
|
|
|
|
|
|
$this->_html .= '<fieldset>
|
|
|
|
|
<legend>'.$this->l('TNT Carrier Module Status').'</legend>';
|
|
|
|
|
|
|
|
|
@@ -291,23 +277,14 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$alert['shipping'] = 1;
|
|
|
|
|
if ((Db::getInstance()->getValue('SELECT * FROM `'._DB_PREFIX_.'carrier` WHERE `external_module_name` = "'.$this->_moduleName.'" AND deleted = "0"')) < 1)
|
|
|
|
|
$alert['service'] = 1;
|
|
|
|
|
if (count($alert) < 3)
|
|
|
|
|
{
|
|
|
|
|
$this->_html .= '<img src="'._PS_IMG_.'admin/module_install.png" /><strong>'.$this->l('The following parameters are correctly configured and activated on your online store :').'</strong>';
|
|
|
|
|
$this->_html .= '<ul>';
|
|
|
|
|
$this->_html .= (!isset($alert['account']) ? '<li>'.$this->l('TNT account. (Account setting tab)').'</li>' : '');
|
|
|
|
|
$this->_html .= (!isset($alert['shipping']) ? '<li>'.$this->l('Shipping address. (Shipping settings tab)').'</li>' : '');
|
|
|
|
|
$this->_html .= (!isset($alert['service']) ? '<li>'.$this->l('Choice of specific TNT delivery mode you want to offer to your customers. (Service settings tab)').'</li>' : '');
|
|
|
|
|
$this->_html .= '</ul>';
|
|
|
|
|
}
|
|
|
|
|
if (count($alert) > 0)
|
|
|
|
|
if (!count($alert))
|
|
|
|
|
$this->_html .= '<img src="'._PS_IMG_.'admin/module_install.png" /><strong>'.$this->l('TNT Carrier is configured and online!').'</strong>';
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$this->_html .= '<img src="'._PS_IMG_.'admin/warn2.png" /><strong>'.$this->l('The following parameters have to be configured to be able to use correctly the TNT module :').'</strong>';
|
|
|
|
|
$this->_html .= '<ul>';
|
|
|
|
|
$this->_html .= (isset($alert['account']) ? '<li>'.$this->l('TNT account. (Account setting tab)').'</li>' : '');
|
|
|
|
|
$this->_html .= (isset($alert['shipping']) ? '<li>'.$this->l('Shipping address. (Shipping settings tab)').'</li>' : '');
|
|
|
|
|
$this->_html .= (isset($alert['service']) ? '<li>'.$this->l('Choice of specific TNT delivery mode you want to offer to your customers. (Service settings tab)').'</li>' : '');
|
|
|
|
|
$this->_html .= '</ul>';
|
|
|
|
|
$this->_html .= '<img src="'._PS_IMG_.'admin/warn2.png" /><strong>'.$this->l('TNT Carrier is not configured yet, please:').'</strong>';
|
|
|
|
|
$this->_html .= '<br />'.(isset($alert['account']) ? '<img src="'._PS_IMG_.'admin/warn2.png" />' : '<img src="'._PS_IMG_.'admin/module_install.png" />').' '.$this->l('Make sure you have a tnt account.');
|
|
|
|
|
$this->_html .= '<br />'.(isset($alert['shipping']) ? '<img src="'._PS_IMG_.'admin/warn2.png" />' : '<img src="'._PS_IMG_.'admin/module_install.png" />').' '.$this->l('Make sure you have a correct shipping address.');
|
|
|
|
|
$this->_html .= '<br />'.(isset($alert['service']) ? '<img src="'._PS_IMG_.'admin/warn2.png" />' : '<img src="'._PS_IMG_.'admin/module_install.png" />').' '.$this->l('Make sure services are activated after a bill.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->_html .= '</fieldset><div class="clear"> </div>';
|
|
|
|
@@ -324,9 +301,9 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
if (isset($_GET['id_tab']))
|
|
|
|
|
$html .= '<script>
|
|
|
|
|
$(".menuTabButton.selected").removeClass("selected");
|
|
|
|
|
$("#menuTab'.htmlentities(Tools::getValue('id_tab')).'").addClass("selected");
|
|
|
|
|
$("#menuTab'.Tools::getValue('id_tab').'").addClass("selected");
|
|
|
|
|
$(".tabItem.selected").removeClass("selected");
|
|
|
|
|
$("#menuTab'.htmlentities(Tools::getValue('id_tab')).'Sheet").addClass("selected");
|
|
|
|
|
$("#menuTab'.Tools::getValue('id_tab').'Sheet").addClass("selected");
|
|
|
|
|
</script>';
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
@@ -334,9 +311,8 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
private function _displayFormAccount()
|
|
|
|
|
{
|
|
|
|
|
global $smarty;
|
|
|
|
|
$var = array('login' => htmlentities(Tools::getValue('tnt_carrier_login', Configuration::get('TNT_CARRIER_LOGIN'))),
|
|
|
|
|
'password' => htmlentities(Tools::getValue('tnt_carrier_password', Configuration::get('TNT_CARRIER_PASSWORD'))),
|
|
|
|
|
'account' => htmlentities(Tools::getValue('tnt_carrier_number_account', Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT'))));
|
|
|
|
|
$var = array('login' => Tools::getValue('tnt_carrier_login', Configuration::get('TNT_CARRIER_LOGIN')), 'password' => Tools::getValue('tnt_carrier_password', Configuration::get('TNT_CARRIER_PASSWORD')),
|
|
|
|
|
'account' => Tools::getValue('tnt_carrier_number_account', Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')));
|
|
|
|
|
$smarty->assign('varAccount', $var);
|
|
|
|
|
return $this->display( __FILE__, 'tpl/accountForm.tpl' );
|
|
|
|
|
}
|
|
|
|
@@ -372,13 +348,13 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
foreach ($serviceList as $k => $v)
|
|
|
|
|
{
|
|
|
|
|
$serviceList[$k]['optionId'] = Configuration::get('TNT_CARRIER_'.$v['option'].'_ID');
|
|
|
|
|
$serviceList[$k]['optionOvercost'] = (Configuration::get('TNT_CARRIER_'.$v['option'].'_OVERCOST') ? Configuration::get('TNT_CARRIER_'.$v['option'].'_OVERCOST') : '0');
|
|
|
|
|
$serviceList[$k]['optionOvercost'] = Configuration::get('TNT_CARRIER_'.$v['option'].'_OVERCOST');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$var = array('serviceList' => $serviceList,
|
|
|
|
|
'action' => htmlentities(Tools::getValue('action')),
|
|
|
|
|
'section' => htmlentities(Tools::getValue('section')),
|
|
|
|
|
'form' => $this->_displayFormService(htmlentities(Tools::getValue('service'))));
|
|
|
|
|
'action' => Tools::getValue('action'),
|
|
|
|
|
'section' => Tools::getValue('section'),
|
|
|
|
|
'form' => $this->_displayFormService(Tools::getValue('service')));
|
|
|
|
|
$smarty->assign('varService', $var);
|
|
|
|
|
return $this->display( __FILE__, 'tpl/service.tpl' );
|
|
|
|
|
}
|
|
|
|
@@ -388,35 +364,35 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
if (Tools::getValue('action') == 'del' && Tools::getValue($cat) != '')
|
|
|
|
|
{
|
|
|
|
|
$id = Tools::getValue($cat);
|
|
|
|
|
Db::getInstance()->ExecuteS('DELETE FROM `'._DB_PREFIX_.'tnt_carrier_'.bqSQL($cat).'` WHERE `id_'.bqSQL($cat).'` = '.(int)$id.'');
|
|
|
|
|
Db::getInstance()->ExecuteS('DELETE FROM `'._DB_PREFIX_.'tnt_carrier_'.$cat.'` WHERE `id_'.$cat.'` = '.(int)$id.'');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$html = '
|
|
|
|
|
<a href="index.php?tab='.htmlentities(Tools::getValue('tab')).'&configure='.htmlentities(Tools::getValue('configure')).'&token='.htmlentities(Tools::getValue('token')).'&tab_module='.htmlentities(Tools::getValue('tab_module')).'&module_name='.htmlentities(Tools::getValue('module_name')).'&id_tab=3§ion='.htmlentities($cat).'&action=new">
|
|
|
|
|
<img src="../img/admin/add.gif" alt="add"/> '.$this->l('Add additional charges depending on the package weight').'</a></br><br/>
|
|
|
|
|
<a href="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=3§ion='.$cat.'&action=new">
|
|
|
|
|
<img src="../img/admin/add.gif" alt="add"/> '.$this->l('New weight option').'</a></br><br/>
|
|
|
|
|
<table class="table" cellspacing="0" cellpading="0">
|
|
|
|
|
<tr>
|
|
|
|
|
<th>'.$this->l('ID').'</th><th>'.$this->l('Weight Min').'</th><th>'.$this->l('Weight Max').'</th><th>'.$this->l('Additionnal charge (Euros)').'</th><th></th>
|
|
|
|
|
</tr>';
|
|
|
|
|
$List = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'tnt_carrier_'.bqSQL($cat).'` ORDER BY `id_'.bqSQL($cat).'`');
|
|
|
|
|
$List = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'tnt_carrier_'.$cat.'` ORDER BY `id_'.$cat.'`');
|
|
|
|
|
$irow = 0;
|
|
|
|
|
foreach ($List as $v)
|
|
|
|
|
{
|
|
|
|
|
$html .= '<tr '.($irow++ % 2 ? 'class="alt_row"' : '').'>
|
|
|
|
|
<td>'.$v['id_'.$cat.''].'</td>
|
|
|
|
|
<td>'.$v[''.$cat.'_min'].'</td>
|
|
|
|
|
<td>'.((float)$v[''.$cat.'_max'] == 0 ? '∞' : $v[''.$cat.'_max']).'</td>
|
|
|
|
|
<td>'.$v[''.$cat.'_max'].'</td>
|
|
|
|
|
<td>'.$v['additionnal_charges'].'</td>
|
|
|
|
|
<td>
|
|
|
|
|
<a href="index.php?tab='.htmlentities(Tools::getValue('tab')).'&configure='.htmlentities(Tools::getValue('configure')).'&token='.htmlentities(Tools::getValue('token')).'&tab_module='.htmlentities(Tools::getValue('tab_module')).'&module_name='.htmlentities(Tools::getValue('module_name')).'&id_tab=3§ion='.htmlentities($cat).'&action=edit&'.htmlentities($cat).'='.htmlentities($v['id_'.$cat.'']).'">
|
|
|
|
|
<a href="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=3§ion='.$cat.'&action=edit&'.$cat.'='.$v['id_'.$cat.''].'">
|
|
|
|
|
<img src="../img/admin/edit.gif" alt="edit" title="'.$this->l('Edit').'"/></a>
|
|
|
|
|
<a href="index.php?tab='.htmlentities(Tools::getValue('tab')).'&configure='.htmlentities(Tools::getValue('configure')).'&token='.htmlentities(Tools::getValue('token')).'&tab_module='.htmlentities(Tools::getValue('tab_module')).'&module_name='.htmlentities(Tools::getValue('module_name')).'&id_tab=3§ion='.htmlentities($cat).'&action=del&'.htmlentities($cat).'='.htmlentities($v['id_'.$cat.'']).'">
|
|
|
|
|
<a href="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=3§ion='.$cat.'&action=del&'.$cat.'='.$v['id_'.$cat.''].'">
|
|
|
|
|
<img src="../img/admin/delete.gif" alt="delete" title="'.$this->l('Delete').'"/></a></td>
|
|
|
|
|
</tr>';
|
|
|
|
|
}
|
|
|
|
|
$html .= '
|
|
|
|
|
</table><br/>
|
|
|
|
|
<div id="divForm'.$cat.'Service">'.((Tools::getValue('action') == 'edit' || Tools::getValue('action') == 'new') && Tools::getValue('section') == $cat ? $this->_displayFormInfo(htmlentities($cat), htmlentities(Tools::getValue($cat))) : '').'</div>
|
|
|
|
|
<div id="divForm'.$cat.'Service">'.((Tools::getValue('action') == 'edit' || Tools::getValue('action') == 'new') && Tools::getValue('section') == $cat ? $this->_displayFormInfo($cat, Tools::getValue($cat)) : '').'</div>
|
|
|
|
|
';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
@@ -428,11 +404,11 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
|
|
|
|
|
$var = array(
|
|
|
|
|
'country' => $country,
|
|
|
|
|
'overcost' => (Configuration::get('TNT_CARRIER_'.strtoupper($country).'_OVERCOST') ? Configuration::get('TNT_CARRIER_'.strtoupper($country).'_OVERCOST') : '0'),
|
|
|
|
|
'action' => htmlentities(Tools::getValue('action')),
|
|
|
|
|
'section' => htmlentities(Tools::getValue('section')),
|
|
|
|
|
'getCountry' => htmlentities(Tools::getValue('country')),
|
|
|
|
|
'form' => (Tools::getValue('country') != '' ? $this->_displayFormCountry(htmlentities(Tools::getValue('country'))) : '')
|
|
|
|
|
'overcost' => Configuration::get('TNT_CARRIER_'.strtoupper($country).'_OVERCOST'),
|
|
|
|
|
'action' => Tools::getValue('action'),
|
|
|
|
|
'section' => Tools::getValue('section'),
|
|
|
|
|
'getCountry' => Tools::getValue('country'),
|
|
|
|
|
'form' => (Tools::getValue('country') != '' ? $this->_displayFormCountry(Tools::getValue('country')) : '')
|
|
|
|
|
);
|
|
|
|
|
$smarty->assign('varCountry', $var);
|
|
|
|
|
return $this->display( __FILE__, 'tpl/country.tpl' );
|
|
|
|
@@ -461,7 +437,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$display = $service[0]['deleted'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$var = array('id' => $id, 'name' => $name, 'description' => $description, 'code' => $code, 'charge' => $charge, 'display' => $display);
|
|
|
|
|
$var = array('id' => $id,'name' => $name, 'description' => $description, 'code' => $code, 'charge' => $charge, 'display' => $display);
|
|
|
|
|
$smarty->assign('varServiceForm', $var);
|
|
|
|
|
return $this->display( __FILE__, 'tpl/serviceForm.tpl' );
|
|
|
|
|
}
|
|
|
|
@@ -476,22 +452,22 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
{
|
|
|
|
|
$info = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'tnt_carrier_'.$cat.'` WHERE `id_'.$cat.'` = "'.$id.'"');
|
|
|
|
|
$info_min = $info[0][$cat.'_min'];
|
|
|
|
|
$info_max = ((float)$info[0][$cat.'_max'] == 0 ? '': $info[0][$cat.'_max']);
|
|
|
|
|
$info_max = $info[0][$cat.'_max'];
|
|
|
|
|
$charge = $info[0]['additionnal_charges'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$html = '
|
|
|
|
|
<form action="index.php?tab='.htmlentities(Tools::getValue('tab')).'&configure='.htmlentities(Tools::getValue('configure')).'&token='.htmlentities(Tools::getValue('token')).'&tab_module='.htmlentities(Tools::getValue('tab_module')).'&module_name='.htmlentities(Tools::getValue('module_name')).'&id_tab=3§ion='.htmlentities($cat).'&action=new" method="post" class="form" id="configForm'.htmlentities($cat).'">
|
|
|
|
|
'.($id != null ? '<input type="hidden" name="'.htmlentities($cat).'_id" value="'.htmlentities($id).'"/>' : '').'
|
|
|
|
|
<form action="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=3§ion='.$cat.'&action=new" method="post" class="form" id="configForm'.$cat.'">
|
|
|
|
|
'.($id != null ? '<input type="hidden" name="'.$cat.'_id" value="'.$id.'"/>' : '').'
|
|
|
|
|
<table class="table" cellspacing="0" cellpadding="0">
|
|
|
|
|
<tr>
|
|
|
|
|
<th>'.$this->l('Weight min').'</th><th>'.$this->l('Weight max (can be empty)').'</th><th>'.$this->l('Additionnal charge').'</th><th></th>
|
|
|
|
|
<th>'.$this->l('Weight min').'</th><th>'.$this->l('Weight max').'</th><th>'.$this->l('Additionnal charge').'</th><th></th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><input type="text" name="tnt_carrier_'.$cat.'_min" size="20" value="'.$info_min.'"/></td>
|
|
|
|
|
<td><input type="text" name="tnt_carrier_'.$cat.'_max" size="20" value="'.$info_max.'"/></td>
|
|
|
|
|
<td><input type="text" name="tnt_carrier_'.$cat.'_charge" size="10" value="'.$charge.'"/></td>
|
|
|
|
|
<td><input class="button" name="submitSave" type="submit" value="'.$this->l('save').'"></td>
|
|
|
|
|
<td><input class="button" name="submitSave" type="submit"></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</form>';
|
|
|
|
@@ -535,7 +511,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$password = Tools::getValue('tnt_carrier_password');
|
|
|
|
|
$number = Tools::getValue('tnt_carrier_number_account');
|
|
|
|
|
if (!$login || !$password || !$number)
|
|
|
|
|
$this->_postErrors[] = $this->l('All the fields are required');
|
|
|
|
|
$this->_postErrors[] = $this->l("All the fields are required");
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_LOGIN', $login);
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_PASSWORD', $password);
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_NUMBER_ACCOUNT', $number);
|
|
|
|
@@ -543,7 +519,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
|
|
|
|
|
private function _postValidationShipping()
|
|
|
|
|
{
|
|
|
|
|
$collect = '1';//Tools::getValue('tnt_carrier_shipping_collect');
|
|
|
|
|
$collect = $email = Tools::getValue('tnt_carrier_shipping_collect');
|
|
|
|
|
$company = Tools::getValue('tnt_carrier_shipping_company');
|
|
|
|
|
$pex = Tools::getValue('tnt_carrier_shipping_pex');
|
|
|
|
|
$lname = Tools::getValue('tnt_carrier_shipping_last_name');
|
|
|
|
@@ -559,25 +535,23 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$print = Tools::getValue('tnt_carrier_print_sticker');
|
|
|
|
|
|
|
|
|
|
if (!$collect && $pex == '')
|
|
|
|
|
$this->_postErrors[] = $this->l('The pex code is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("The pex code is missing");
|
|
|
|
|
if ($collect && $company == '')
|
|
|
|
|
$this->_postErrors[] = $this->l('Company name is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your company name is missing");
|
|
|
|
|
if ($collect && !$lname)
|
|
|
|
|
$this->_postErrors[] = $this->l('Contact last name is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your last name is missing");
|
|
|
|
|
if ($collect && !$fname)
|
|
|
|
|
$this->_postErrors[] = $this->l('Contact first name is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your first name is missing");
|
|
|
|
|
if (!$address1)
|
|
|
|
|
$this->_postErrors[] = $this->l('Address is missing');
|
|
|
|
|
if (isset($address2) && strlen($address2) >= 32)
|
|
|
|
|
$this->_postErrors[] = $this->l('Address line 2 must be under 32 characters');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your address is missing");
|
|
|
|
|
if (!$postal_code)
|
|
|
|
|
$this->_postErrors[] = $this->l('Postal code is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your zip code is missing");
|
|
|
|
|
if (!$email)
|
|
|
|
|
$this->_postErrors[] = $this->l('Contact email address is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your email address is missing");
|
|
|
|
|
if (!$phone)
|
|
|
|
|
$this->_postErrors[] = $this->l('Contact phone number is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your phone number is missing");
|
|
|
|
|
if ($collect && $closing == '')
|
|
|
|
|
$this->_postErrors[] = $this->l('Company closing time is missing');
|
|
|
|
|
$this->_postErrors[] = $this->l("Your closing time is missing");
|
|
|
|
|
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_SHIPPING_COLLECT', $collect);
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_SHIPPING_COMPANY', $company);
|
|
|
|
@@ -650,12 +624,12 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
|
|
|
|
|
Db::getInstance()->autoExecute(_DB_PREFIX_.'tnt_carrier_option',
|
|
|
|
|
array('id_carrier' => (int)($id_carrier),
|
|
|
|
|
'option' => pSQL($code),
|
|
|
|
|
'option' => $code,
|
|
|
|
|
'additionnal_charges' => (float)($charge)),'INSERT');
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_ID', (int)($id_carrier));
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_OVERCOST', (float)($charge));
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_OVERCOST'] = (float)($charge);
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_ID'] = (float)($id_carrier);
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.$code.'_ID', (int)($id_carrier));
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.$code.'_OVERCOST', (float)($charge));
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.$code.'_OVERCOST'] = (float)($charge);
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.$code.'_ID'] = (float)($id_carrier);
|
|
|
|
|
$this->_html .= $this->displayConfirmation($this->l('Service updated'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -682,13 +656,13 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
|
|
|
|
|
if (!$this->_postErrors)
|
|
|
|
|
{
|
|
|
|
|
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier` SET `name` = "'.pSQL($name).'", `deleted` = "'.(int)($display).'" WHERE `id_carrier` = '.(int)($id).'');
|
|
|
|
|
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier_lang` SET `delay` = "'.pSQL($description).'" WHERE `id_carrier` = '.(int)($id).'');
|
|
|
|
|
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tnt_carrier_option` SET `option` = "'.pSQL($code).'" WHERE `id_carrier` = '.(int)($id).'');
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_OVERCOST', (float)($charge));
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_ID', (int)($id));
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_OVERCOST'] = (float)($charge);
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_ID'] = (float)($id);
|
|
|
|
|
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier` SET `name` = "'.$name.'", `deleted` = "'.(int)($display).'" WHERE `id_carrier` = '.(int)($id).'');
|
|
|
|
|
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier_lang` SET `delay` = "'.$description.'" WHERE `id_carrier` = '.(int)($id).'');
|
|
|
|
|
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tnt_carrier_option` SET `option` = "'.$code.'" WHERE `id_carrier` = '.(int)($id).'');
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.$code.'_OVERCOST', (float)($charge));
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.$code.'_ID', (int)($id));
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.$code.'_OVERCOST'] = (float)($charge);
|
|
|
|
|
$this->_fieldsList['TNT_CARRIER_'.$code.'_ID'] = (float)($id);
|
|
|
|
|
$this->_html .= $this->displayConfirmation($this->l('Service updated'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -698,10 +672,10 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$info_min = Tools::getValue('tnt_carrier_'.$cat.'_min');
|
|
|
|
|
$info_max = Tools::getValue('tnt_carrier_'.$cat.'_max');
|
|
|
|
|
$charge = Tools::getValue('tnt_carrier_'.$cat.'_charge');
|
|
|
|
|
Db::getInstance()->autoExecute(_DB_PREFIX_.'tnt_carrier_'.bqSQL($cat).'',
|
|
|
|
|
Db::getInstance()->autoExecute(_DB_PREFIX_.'tnt_carrier_'.$cat.'',
|
|
|
|
|
array(
|
|
|
|
|
''.pSQL($cat).'_min' => (float)($info_min),
|
|
|
|
|
''.pSQL($cat).'_max' => (float)($info_max),
|
|
|
|
|
''.$cat.'_min' => (float)($info_min),
|
|
|
|
|
''.$cat.'_max' => (float)($info_max),
|
|
|
|
|
'additionnal_charges' => (float)($charge)),'INSERT');
|
|
|
|
|
$this->_html .= $this->displayConfirmation($this->l('Service updated'));
|
|
|
|
|
}
|
|
|
|
@@ -714,10 +688,10 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$charge = Tools::getValue('tnt_carrier_'.$cat.'_charge');
|
|
|
|
|
|
|
|
|
|
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tnt_carrier_'.$cat.'`
|
|
|
|
|
SET `'.bqSQL($cat).'_min` = "'.(float)($info_min).'",
|
|
|
|
|
`'.bqSQL($cat).'_max` = "'.(float)($info_max).'",
|
|
|
|
|
SET `'.$cat.'_min` = "'.(float)($info_min).'",
|
|
|
|
|
`'.$cat.'_max` = "'.(float)($info_max).'",
|
|
|
|
|
`additionnal_charges` = "'.(float)$charge.'"
|
|
|
|
|
WHERE `id_'.bqSQL($cat).'` = '.(int)($id).'');
|
|
|
|
|
WHERE `id_'.$cat.'` = '.(int)($id).'');
|
|
|
|
|
|
|
|
|
|
$this->_html .= $this->displayConfirmation($this->l('Service updated'));
|
|
|
|
|
}
|
|
|
|
@@ -730,11 +704,6 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.strtoupper($country).'_OVERCOST', $overcost);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_followup($shipping_number)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** Hook update carrier
|
|
|
|
|
**
|
|
|
|
@@ -743,7 +712,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
{
|
|
|
|
|
global $smarty;
|
|
|
|
|
$id_cart = $params['cart']->id;
|
|
|
|
|
$smarty->assign('id_cart', (int)$id_cart);
|
|
|
|
|
$smarty->assign('id_cart', $id_cart);
|
|
|
|
|
return $this->display( __FILE__, 'tpl/relaisColis.tpl' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -854,7 +823,6 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$erreur = null;
|
|
|
|
|
$follow = array();
|
|
|
|
|
$carrierName = Db::getInstance()->ExecuteS('SELECT external_module_name FROM `'._DB_PREFIX_.'carrier` WHERE `id_carrier` = "'.(int)($id_carrier).'"');
|
|
|
|
|
|
|
|
|
|
if ($carrierName != null && $carrierName[0]['external_module_name'] == $this->_moduleName && $shipping_number != '')
|
|
|
|
|
{
|
|
|
|
|
$pack = new PackageTnt($params['order']->id);
|
|
|
|
@@ -866,10 +834,6 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
|
|
|
|
|
public function hookupdateCarrier($params)
|
|
|
|
|
{
|
|
|
|
|
$option = Db::getInstance()->ExecuteS('SELECT option
|
|
|
|
|
FROM `'._DB_PREFIX_.'tnt_carrier_option`
|
|
|
|
|
WHERE id_carrier = "'.(int)$params['id_carrier'].'"');
|
|
|
|
|
Configuration::updateValue('TNT_CARRIER_'.$option[0]['option'].'_ID', (int)($params['carrier']->id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@@ -885,8 +849,6 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
|
|
|
|
|
public function getOrderShippingCost($params, $shipping_cost)
|
|
|
|
|
{
|
|
|
|
|
if (!Tools::getValue('step'))
|
|
|
|
|
return false;
|
|
|
|
|
if ((int)(Tools::getValue('step')) > 2)
|
|
|
|
|
serviceCache::deleteServices($params->id);
|
|
|
|
|
$product = $params->getProducts();
|
|
|
|
@@ -895,7 +857,6 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$id_customer = $params->id_customer;
|
|
|
|
|
$date_exp = $params->date_upd;
|
|
|
|
|
$id_adress_delivery = $params->id_address_delivery;
|
|
|
|
|
$info = Db::getInstance()->ExecuteS('SELECT postcode, city, company FROM `'._DB_PREFIX_.'address` WHERE `id_address` = "'.(int)($id_adress_delivery).'"');
|
|
|
|
|
|
|
|
|
|
foreach($product as $k => $v)
|
|
|
|
|
$weight += (float)($v['weight']);
|
|
|
|
@@ -906,6 +867,7 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
return false;
|
|
|
|
|
if (!Configuration::get('TNT_CARRIER_SHIPPING_ADDRESS1') || !Configuration::get('TNT_CARRIER_SHIPPING_ZIPCODE') || !Configuration::get('TNT_CARRIER_SHIPPING_CITY'))
|
|
|
|
|
return false;
|
|
|
|
|
$info = Db::getInstance()->ExecuteS('SELECT postcode, city, company FROM `'._DB_PREFIX_.'address` WHERE `id_address` = "'.(int)($id_adress_delivery).'"');
|
|
|
|
|
|
|
|
|
|
$serviceCache = new serviceCache($params->id, $info[0]['postcode']);
|
|
|
|
|
if (!$serviceCache->getFaisabilityAtThisTime())
|
|
|
|
@@ -940,13 +902,18 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$priceCarrier = Configuration::get('TNT_CARRIER_'.$v['code'].'_OVERCOST');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isset($priceCarrier))
|
|
|
|
|
if (!isset($priceCarrier))
|
|
|
|
|
{
|
|
|
|
|
if ($option = Db::getInstance()->ExecuteS('SELECT `option` FROM `'._DB_PREFIX_.'tnt_carrier_option` WHERE `id_carrier` = "'.(int)($this->id_carrier).'"'))
|
|
|
|
|
$priceCarrier = Configuration::get('TNT_CARRIER_'.$option[0]['option'].'_OVERCOST');
|
|
|
|
|
if (isset($params->id_carrier) && (int)($params->id_carrier) > 0)
|
|
|
|
|
{
|
|
|
|
|
if ($option = Db::getInstance()->ExecuteS('SELECT `option` FROM `'._DB_PREFIX_.'tnt_carrier_option` WHERE `id_carrier` = "'.(int)($params->id_carrier).'"'))
|
|
|
|
|
$priceCarrier = Configuration::get('TNT_CARRIER_'.$option[0]['option'].'_OVERCOST');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$priceCarrier = 0;
|
|
|
|
|
}
|
|
|
|
|
$zero = 0;
|
|
|
|
|
$weightLimit = Db::getInstance()->ExecuteS('SELECT additionnal_charges FROM `'._DB_PREFIX_.'tnt_carrier_weight` WHERE `weight_min` < "'.(float)($weight).'" AND (`weight_max` > "'.(float)($weight).'" OR `weight_max` = "'.(float)$zero.'")');
|
|
|
|
|
|
|
|
|
|
$weightLimit = Db::getInstance()->ExecuteS('SELECT additionnal_charges FROM `'._DB_PREFIX_.'tnt_carrier_weight` WHERE `weight_min` < "'.(float)($weight).'" AND `weight_max` > "'.(float)($weight).'"');
|
|
|
|
|
$currency = Db::getInstance()->ExecuteS('SELECT conversion_rate FROM `'._DB_PREFIX_.'currency` WHERE `id_currency` = "'.(int)($params->id_currency).'"');
|
|
|
|
|
if ($weightLimit != null)
|
|
|
|
|
$add += (float)($weightLimit[0]['additionnal_charges']);
|
|
|
|
@@ -975,4 +942,4 @@ class TntCarrier extends CarrierModule
|
|
|
|
|
$new = array("ST", " ");
|
|
|
|
|
return (str_replace($old, $new, $city));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|