69 lines
2.2 KiB
PHP
69 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* TNT OFFICIAL MODULE FOR PRESTASHOP.
|
|
*
|
|
* @author GFI Informatique <www.gfi.fr>
|
|
* @copyright 2016-2017 GFI Informatique, 2016-2017 TNT
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
|
*/
|
|
|
|
require_once _PS_MODULE_DIR_.'tntofficiel/libraries/TNTOfficiel_Debug.php';
|
|
|
|
class TNTOfficielTrackingModuleFrontController extends ModuleFrontController
|
|
{
|
|
/**
|
|
* TNTOfficielTrackingModuleFrontController constructor.
|
|
* Controller always used for AJAX response.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__));
|
|
|
|
parent::__construct();
|
|
|
|
// No header/footer.
|
|
$this->ajax = true;
|
|
}
|
|
|
|
/**
|
|
* Display the tracking popup.
|
|
*/
|
|
public function displayAjaxTracking()
|
|
{
|
|
TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__));
|
|
|
|
$intOrderID = (int)Tools::getValue('orderId');
|
|
try {
|
|
$arrTNTOrder = TNTOfficiel_OrderHelper::getInstance()->getOrderData($intOrderID);
|
|
} catch (Exception $objException) {
|
|
$objFileLogger = new FileLogger();
|
|
$objFileLogger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_tnt_exception.log');
|
|
$objFileLogger->logError($objException->getMessage());
|
|
|
|
Controller::getController('PageNotFoundController')->run();
|
|
//$this->smartyOutputContent(_PS_THEME_DIR_.'404.tpl');
|
|
|
|
return false;
|
|
}
|
|
|
|
//get parcels and for each parcel get its tracking data
|
|
$parcels = TNTOfficiel_ParcelsHelper::getInstance()->getParcels($intOrderID);
|
|
foreach ($parcels as &$parcel) {
|
|
$parcel['trackingData'] = TNTOfficiel_ParcelsHelper::getInstance()->getTrackingData($parcel);
|
|
}
|
|
|
|
$this->context->smarty->assign(
|
|
array(
|
|
'order' => $arrTNTOrder,
|
|
'parcels' => $parcels,
|
|
)
|
|
);
|
|
|
|
$this->context->smarty->display(
|
|
_PS_MODULE_DIR_.$this->module->name.'/views/templates/front/displayAjaxTracking.tpl'
|
|
);
|
|
|
|
return true;
|
|
}
|
|
}
|