55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
|
<?php
|
||
|
|
||
|
require_once(dirname(__FILE__).'../../../config/config.inc.php');
|
||
|
require_once(dirname(__FILE__).'../../../init.php');
|
||
|
|
||
|
header('Content-Type: application/json');
|
||
|
if(Tools::getValue('action') != 'getReport') {
|
||
|
http_response_code(418);
|
||
|
die('I\'m a teapot');
|
||
|
}
|
||
|
|
||
|
switch (Tools::getValue('type')) {
|
||
|
case 'ART':
|
||
|
die(getReport('ART'));
|
||
|
break;
|
||
|
case 'CDC':
|
||
|
die(getReport('CDC'));
|
||
|
break;
|
||
|
default:
|
||
|
http_response_code(418);
|
||
|
die(json_encode('I\'m a teapot'));
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
function getReport($type) {
|
||
|
//global $cookie;
|
||
|
$id_sale = (int)Tools::getValue('id_sale', false);
|
||
|
|
||
|
if (!$id_sale) {
|
||
|
http_response_code(500);
|
||
|
return json_encode(array(
|
||
|
'error'=> 'true',
|
||
|
'message'=> Tools::displayError('Vente non trouvée')
|
||
|
));
|
||
|
}
|
||
|
|
||
|
$report = Db::getInstance()->getRow('
|
||
|
SELECT `report_data`
|
||
|
FROM `'._DB_PREFIX_.'philea_syncreport`
|
||
|
WHERE `id_sale` = '.$id_sale.'
|
||
|
AND `filename` LIKE "'.$type.'%"
|
||
|
');
|
||
|
|
||
|
if(isset($report) && $report != false) {
|
||
|
return json_encode(array(
|
||
|
'error' => 'false',
|
||
|
'report' => $report
|
||
|
));
|
||
|
} else {
|
||
|
return json_encode(array(
|
||
|
'error'=> 'true',
|
||
|
'message' => Tools::displayError('Pas de rapport '.$type.' disponible')
|
||
|
));
|
||
|
}
|
||
|
}
|