Correzione content-type API

This commit is contained in:
Thomas Zilio 2018-06-29 15:57:12 +02:00
parent fe94eeb2ac
commit 3b73c25c0b
4 changed files with 13 additions and 23 deletions

View File

@ -9,9 +9,6 @@ function serverError()
} }
} }
// Impostazioni di Content-Type e Charset Header
header('Content-Type: application/json; charset=UTF-8');
// Gestione degli errori // Gestione degli errori
set_error_handler('serverError'); set_error_handler('serverError');
register_shutdown_function('serverError'); register_shutdown_function('serverError');
@ -70,5 +67,14 @@ try {
$result = API::error('serverError'); $result = API::error('serverError');
} }
json_decode($result);
// Impostazioni di Content-Type e Charset Header
if (json_last_error() == JSON_ERROR_NONE) {
header('Content-Type: application/json; charset=UTF-8');
} else {
header('Content-Type: text/plain; charset=UTF-8');
}
// Stampa dei risultati // Stampa dei risultati
echo $result; echo $result;

View File

@ -165,16 +165,6 @@ switch (post('op')) {
return [ return [
'delete-bulk' => tr('Elimina selezionati'), 'delete-bulk' => tr('Elimina selezionati'),
'export-bulk' => [
'text' => tr('Esporta stampe'),
'data' => [
'msg' => tr('Vuoi davvero esportare tutte le stampe in un archivio?'),
'button' => tr('Procedi'),
'class' => 'btn btn-lg btn-warning',
'blank' => true,
],
],
'creafatturavendita' => [ 'creafatturavendita' => [
'text' => tr('Crea fattura'), 'text' => tr('Crea fattura'),
'data' => [ 'data' => [

View File

@ -25,12 +25,9 @@ switch (post('op')) {
$rapportino_nome = sanitizeFilename($numero.' '.$r['data'].' '.$r['ragione_sociale'].'.pdf'); $rapportino_nome = sanitizeFilename($numero.' '.$r['data'].' '.$r['ragione_sociale'].'.pdf');
$filename = slashes($dir.'tmp/'.$rapportino_nome); $filename = slashes($dir.'tmp/'.$rapportino_nome);
$ptype = 'fatture'; $print = Prints::getModuleMainPrint($id_module);
$print = $dbo->fetchArray('SELECT id, previous FROM zz_prints WHERE directory = '.prepare($ptype).' ORDER BY main DESC LIMIT 1'); Prints::render($print['id'], $r['id'], $filename);
$id_print = $print[0]['id'];
Prints::render($id_print, $r['id'], $filename);
} }
$dir = slashes($dir); $dir = slashes($dir);

View File

@ -32,12 +32,9 @@ switch (post('op')) {
$rapportino_nome = sanitizeFilename($numero.' '.date('Y_m_d', strtotime($r['data_richiesta'])).' '.$r['ragione_sociale'].'.pdf'); $rapportino_nome = sanitizeFilename($numero.' '.date('Y_m_d', strtotime($r['data_richiesta'])).' '.$r['ragione_sociale'].'.pdf');
$filename = slashes($dir.'tmp/'.$rapportino_nome); $filename = slashes($dir.'tmp/'.$rapportino_nome);
$ptype = 'interventi'; $print = Prints::getModuleMainPrint($id_module);
$print = $dbo->fetchArray('SELECT id, previous FROM zz_prints WHERE directory = '.prepare($ptype).' ORDER BY main DESC LIMIT 1'); Prints::render($print['id'], $r['id'], $filename);
$id_print = $print[0]['id'];
Prints::render($id_print, $r['id'], $filename);
} }
$dir = slashes($dir); $dir = slashes($dir);