Visual Report Writer and The Web (VII)
by
, 12-May-2013 at 01:00 AM (13050 Views)
In this seventh blog about Visual Report Writer and the Web we look at the next report that is available on the Live Demo website (European Server, USA server) named Inventory Stock Levels. If this is the first blog you read I encourage you to read the six other blogs (1: The Solution, 2: Invoices Report, 3: The Cleanup, 4: The CustomerList, 5: The Orderlist and 6: The Credit and Balances Overview). Between the fourth and the fifth blog we have been able to release the Alpha I version of Visual Report Writer 3.0 and the 2.1+ Library only setup. The latter one is needed to make the web reporting using the 17.1 DataFlex Web Framework easy and look like at the demo website.
The Report
The report uses DataFlex embedded database, the same database that is used for the WebOrder example that comes with Visual DataFlex 17.1. The tables invt and vendor are used for the report. The report groups the inventory data per vendor, sorted by name. The specialties in this report are a calculated column that contains the result of the inventory unit price times the number on hand. The value is not shown in the report, it is suppressed printed in the details section. The field's content is used for a sum operation in the group footer and the report footer. The report footer can be suppressed via a parameter in the report which can be set from integration. Another speciality is the use of a barcode font to convert the item_id into a barcode. The font is used is named "C39HrP24DlTt". If you install this font on your web-server you need to reboot the server in order to make it active.
The Integration
For the integration we create two cWebView components. One view creates a PDF when you browse through the vendors and allows you to suppress the report footer while the second component directly shows the report without filtering on vendor or allowing report footer suppress.
The OverView
First take a look at the overview implementation. This is the cWebView that immediately show the full report. While Visual Report Writer is fast (also depends in the number of simultaneously accesses and the speed of hardware and internet connections it should not be used when the amount of data is so big that a huge amount of pages is generated or when filters should be really applied. Web server access should be short and not time consuming. Users don't want to wait a long time. In this case it is fine, the report is only 3 pages long.
Note the difference between the report display in Chrome and Firefox. In Chrome your barcode is shown, in FireFox (version 20) it does not show. FireFox reads the PDF and converts it to HTML and while the barcode font is stored in the PDF it does not make use of it. In FireFox the report display is slower too.
The report start is triggered by the OnShow event of the cWebView component. So each time you open the view the report is build and shown in an iFrame control.
The report generating code is as in the other reports that create a PDF file.Code:Procedure OnShow Forward Send OnShow Send GenerateReport of oReport End_Procedure End_Object
Per VendorCode:Object oWebMainPanel is a cWebPanel Object oReport is a cVRWReport Set psReportName to "320 Inventory Stock levels per Vendor.vrw" Procedure GenerateReport String sReportId sFile sUrl VRWPDFExportOptions PDFExportOptions Boolean bCanceled Get OpenReport to sReportId If (sReportId <> "") Begin Get DefaultPDFExportOptions to PDFExportOptions Set pPDFExportOptions to PDFExportOptions Get ReportCacheFileName ".pdf" to sFile If (sFile <> "") Begin Send ExportReport C_vrwPDF sFile Get pbCanceled to bCanceled If (not (bCanceled)) Begin Get DownloadURL of ghoWebResourceManager sFile to sUrl If (sUrl <> "") Begin WebSet psUrl of oViewer to sUrl End End End Send CloseReport sReportId End End_Procedure End_Object Object oViewer is a cWebIFrame Set pbFillHeight to True Set pbShowBorder to True End_Object End_Object
In the second cWebView component that uses the same report the generation of the report results is trigged from an OnPostFind event in the vendor data dictionary object, like it is done in Credit And Balances report view.
The special code in this view is the use of a parameter in the report. The view has a checkbox (cWebCheckbox) that let the user indicate if the report footer should be suppressed or not. The status of this checkbox is read in the OnInitializeReport event of the cVRWReport object.Code:Object oVendor_DD is a cVendorDataDictionary Procedure OnPostFind Integer eMessage Boolean bFound Boolean bSyncing Forward Send OnPostFind eMessage bFound Get AppSynching of ghoWebApp to bSyncing If (not (bSyncing)) Begin Send GenerateReport of oReport End End_Procedure End_Object
The filtering is done by taking the value of the vendor ID cWebForm object and add it as a filter to the report using the AddFilter message.Code:Procedure OnInitializeReport Boolean bSuppress Integer iParameter Get GetChecked of oSuppressFooterSection to bSuppress Get ParameterIdByName C_USEMAINVRWREPORTID 'SuppressFooter' to iParameter Set psParameterValue C_USEMAINVRWREPORTID iParameter to bSuppress Send SetFilters End_Procedure
This blog was again written to show you what power there is behind Visual Report Writer and the Web and how easy it is to implement, integrate the reports. Make sure your customers get to know the product and deliver nice looking reports to you for integration.Code:Procedure SetFilters Integer iVendorId WebGet psValue of oVendorID to iVendorId Send RemoveAllFilters C_USEMAINVRWREPORTID If (iVendorId <> 0) Begin Send AddFilter C_USEMAINVRWREPORTID "{Vendor.Id}" C_VRWEqual iVendorId End End_Procedure