Correzione API per anteprima stampa

This commit is contained in:
Dasc3er 2020-10-06 17:58:12 +02:00
parent 5c2c206152
commit fc7edeacb1
2 changed files with 16 additions and 3 deletions

View File

@ -28,17 +28,26 @@ class Stampa extends Resource implements RetrieveInterface
{
public function retrieve($request)
{
$content = '';
$print = PrintTemplate::where('name', $request['name'])->first();
if (!empty($print)) {
$directory = base_dir().'/files/api';
$data = Prints::render($print->id, $request['id_record'], $directory);
download($data['path']);
$string = strpos($request['resource'], 'binary') !== false;
$data = Prints::render($print->id, $request['id_record'], $directory, $string);
if (!$string) {
download($data['path']);
} else {
$content = $data['pdf'];
}
delete($data['path']);
}
return [
'custom' => '',
'content' => base64_encode($content),
'filename' => $data['name'],
];
}
}

View File

@ -232,3 +232,7 @@ UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT JOI
-- Aggiunte note prima nota
ALTER TABLE `co_movimenti` ADD `note` TEXT NOT NULL AFTER `descrizione`;
-- Aggiunta risorse API dedicate alle Stampe in binary formato
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES
(NULL, 'v1', 'retrieve', 'stampa-binary', 'API\\Common\\Stampa', '1');