forked from verdnatura/hedera-web
37 lines
734 B
PHP
37 lines
734 B
PHP
<?php
|
|
|
|
require_once ('vn/web/file.php');
|
|
require_once ('vn/hedera/web.php');
|
|
|
|
use Vn\Hedera\Web;
|
|
|
|
Web::init ();
|
|
|
|
try {
|
|
if (!Web::login ())
|
|
throw new Exception (s('Invalid login'));
|
|
if (!isset ($_GET['invoice']))
|
|
throw new Exception (s('Invoice id not sent by client'));
|
|
|
|
$query = file_get_contents (__DIR__ .'/get-invoice-path.sql');
|
|
|
|
if (empty ($query))
|
|
throw new Exception (s('Can not load query from file'));
|
|
|
|
$pdfPath = Web::$conn->getValue ($query, ['invoice' => (int) $_GET['invoice']]);
|
|
|
|
if (!$pdfPath)
|
|
throw new Exception (s('Invoice id not found'));
|
|
|
|
Vn\Web\printFile ($pdfPath);
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
error_log ($e->getMessage ());
|
|
header ('HTTP/1.0 500 Internal Server Error');
|
|
}
|
|
|
|
Web::deinit ();
|
|
|
|
?>
|