Skip to content

Konfiguracja - wydruki

W systemie jest możliwość generowania wydruków

  • wydruki jasper ( wycofany mechanizm ze starego systemu) ale uzywane na klientach platformacrm
  • wydruki paanda : uzywajac handlebars hbs , liquid , fastreport , prefereowana metoda handlebars

DB Objects

Konfiguracja jest zapisana:

  • [configuration].[printout] przechowywanie konfiguracji wydruków dla dokumentów
    • [printoutname] - nazwa wydruku
    • [componentname] ex: order,document,invoice ...
    • [documenttype] ex: RW,PZ,RWP,PW,ZW ...
    • [printorder] kolejnosc jezeli -1 usunięty
    • [action] - url of action
      • przykład jasper http://{host}:8081/jasperserver/rest_v2/reports/Reports/METALBUD/{printoutname}.pdf?paramId={id}&username=sys&REPORT_LOCALE=pl_PL&userLocale=pl_PL&db={db}&j_username=someusername&j_password=somepassword jest przetwarzany na
      • przykład paanda srs {{host}}/api/srs/382-order/order.hbs.pdf?orderid={orderid}
      • zmienne które są podstawiane po serwer side {db} , {username} , {template}, {id}, - {any query string parameter will be replaced}
    • [template] - opcjonalny template który jest zamieniany po serwerside
    • [css] - opcjonalny styl

REST API

List of available printouts

HTTP
GET {{host}}/api/erp/print/list/{componentname}?documenttype={documentType?}

Execute Jasper printout

HTTP
GET {{host}}/api/erp/print/jasper/{printout_uuid}/{id}

URL Parameters:

  • id- remoteid , documentid
  • any querystring może zastąpić dowolny parametr w template.action
  • jezeli file_name - zostanie pobrany

execute SRS printout

HTTP
GET {{host}}/api/srs/382-order/order.hbs.pdf?orderid={orderid}

file_name - zostanie pobrany

Save to storage

HTTP
1
2
3
4
5
GET {{host}}/api/core/files/uploadv2
?file_remote_uuid={file_remote_uuid}
&file_remote_source={file_remote_source}
&file_url={file_url}
&file_name={file_name}
  • jezeli file_name - zostanie pobrany

Dodawanie wydruków automatycznie z zabezpieczeniem

SQL
--BEGIN TRANSACTION; 

-- Step 1: Create a temporary table to hold the data
DECLARE @TempPrintout table (
    componentname NVARCHAR(255),
    documenttype NVARCHAR(255),
    printoutname NVARCHAR(255),
    printorder INT,
    action NVARCHAR(255),
    css NVARCHAR(255)
);

-- Step 2: Insert the data into the temporary table
INSERT INTO @TempPrintout (componentname, documenttype, printoutname, printorder, action, css)
VALUES 
('firm', NULL,      'Kontrahent oswiadczenie EN', NULL, '/api/srs/008/firma_oswiadczenie_fvel_EN.hbs.pdf?firmid={firmid}', NULL),
('firm', NULL,      'Kontrahent oswiadczenie PL', NULL, '/api/srs/008/firma_oswiadczenie_fvel_PL.hbs.pdf?firmid={firmid}', NULL),
('orderinvoice', NULL, 'edokumenty', NULL, '/api/core/srs/602/zakup_edok.hbs.html?invoiceid={id}', NULL),
('order', NULL,     '(nowe) Zamówienie', 1, '/api/srs/382-order/order.hbs.pdf?orderid={orderid}', 'xd-green0'),
('clipboard',   'clipboard', 'Etykieta 10X4', NULL, '/api/srs/700/barcode10x4-items.frx.pdf', NULL),
-- tylko gdzie dziala('saleInvoice',    NULL, '(nowe) Faktura PLN', NULL, '/api/core/srs/524-invoice-print/invoice.hbs.pdf?invoiceid={id}', NULL),
-- tylko gdzie dziala('saleInvoice',    NULL, '(nowe) Faktura EX', NULL, '/api/core/srs/524-invoice-print/invoice_en.hbs.pdf?invoiceid={id}', NULL),
('documentin',  null, '(nowe) Przyjecie', NULL, '/api/core/srs/409-document-print/document_new.hbs.pdf?documentid={documentid}', NULL),
('documentOut', null, '(nowe) Wydanie', NULL, '/api/core/srs/409-document-print/document_new.hbs.pdf?documentid={documentid}', NULL)


Print 'Dodawanie'
SELECT t.componentname, t.documenttype, t.printoutname, t.printorder, t.action, t.css
FROM @TempPrintout t
WHERE NOT EXISTS (
    SELECT 1 
    FROM configuration.printout p 
    WHERE p.componentname = t.componentname 
      AND p.printoutname = t.printoutname)


-- Step 3: Insert the data from the temporary table into the configuration.printout table
INSERT INTO configuration.printout (componentname, documenttype, printoutname, printorder, action, css)
SELECT t.componentname, t.documenttype, t.printoutname, t.printorder, t.action, t.css
FROM @TempPrintout t
WHERE NOT EXISTS (
    SELECT 1 
    FROM configuration.printout p 
    WHERE p.componentname = t.componentname 
      AND p.printoutname = t.printoutname
);


--ROLLBACK TRANSACTION;

FAQ & Scripts examples

Konwertowanie na nowy format wydrukow jasper

SQL
update [configuration].[printout] set template = upper(template), action =
'http://s06.platformacrm.pl:8080/jasperserver/rest_v2/reports/Reports/METALBUD/{template}.pdf?paramId={id}&username=sys&REPORT_LOCALE=pl_PL&userLocale=pl_PL&db={db}&j_username=jasperadmin&j_password=jasperadmin' where action not like '/%' and action is  null

zapytanie ktore wywoluje system do pobrania wydruków

SQL
SELECT
    printout_uuid,
    printoutName,
    documentType,
    componentName,
    permission,
    isDefault,
    css,
    case when action like '%jasper%' then '/api/erp/print/jasper/'+ cast(printout_uuid as varchar(36)) +'/{id}'
    else replace(action,'{template}',isnull(template,'')) end apilink
FROM
    configuration.printout x
where
    componentname = @componentname
    and (documentType = isnull(@documentType, documentType) or documentType is null)
    and isnull(printorder,0) >-1
order by
    x.isDefault desc , x.printorder,x.printoutName

Problemy z wydrukami jasper

UWAGA templaty jasper sa z duzych liter trzeba zrobic, w nowym systemie nie ulega to zadnych to upper

SQL
  update [configuration].[printout] set template = upper(template)