Documents
We will start our application improvements by adding a couple of documents to the configuration.
Printable statement
With this feature users will be able to invoke the operation that will display a PDF document listing loans, reservations, fees and payments of a particular member. Users will then be able to print out this document. Users should be able to invoke this operation while they are viewing/editing the form of a particular member.
Before we can configure such an operation we need to configure a document. This document will need to list loans, reservations, fees and payments of a member. There are different types of documents that Aware IM supports (MS-Word, MS Excel, Text etc), however, the only document type capable of iteration is “Report” (see also the “Reports” section). Also, report is only capable of displaying lists of one particular object and we need to display lists of several different objects. Fortunately report supports a concept of “sub-reports”, where there is a single master document containing one or more sub-report documents, each of them performing its own iteration. This means that we need to define several reports – one to display loans, another - to display reservations etc; and we also need a master report to combine all these reports in one document.
We will start by configuring documents that will be used as sub-reports within our master document. To add a new document to the configuration right click on the “Document templates, reports” node in the Elements Tree and select “New” from the pop-up menu. Enter the name of the new document “Member payments” in the list of document properties and select the type of the document “Report”. The report editor will be displayed in the working area of the screen. The Report Designer is described in detail in the “Working with Report/Presentation Designer” section and we will not be going through it in detail here. You can have a look at the final document in the sample configuration of the Library application located in the “samples” directory of your Aware IM installation.
Once we are happy with the layout of the document we click on the “Save” button in the toolbar or select File/Save from the menu of the Configuration Tool. The new document appears in the list of documents in the Elements Tree.
In a similar fashion we can define other documents that will be used as sub-reports – “Member loans” (to display Loan
objects), “Member fees” (to display Fee
objects) and “Member reservations” (to display Reservation
objects).
Now we can define the master report called “Member details”. The layout of this report includes several sub-report elements (take a look at the final layout of the document in the sample configuration). Note that this report assumes that there is a particular instance of the Member
object in the context – that’s why it refers to the attributes of the Member object inside its tags. It is also worth drawing your attention to the queries that identify the source of data for sub-report elements. If we look, for example, at the sub-report element that prints out “Member payment” report we will see that the query for the sub-report element looks like this:
FIND Payment WHERE Payment IN Member.Payments ORDER BY Payment.AppliedOn
This query finds all payments of the member object that is assumed to be in the context.
Note also that the report has no “Details” section – this is because the report itself does not display any lists (lists are shown inside the sub-reports).
Now that we have finally defined all our documents we can define the operation that will display the master report. The operation will be invoked from the form of the Member
object, so we open the Member
object for editing, select the “Main” form in the Forms tab, click on the Panel Operations property of the form and then click on the “Add” button to define a new panel operation. We define an operation called “Printable version” of the “Create Document” type and select the name of the document “Member details”. Then we save the changes to the Member object. Note that Aware IM automatically puts the Member
object being viewed/edited into the context, so it is available for the “Member details” report, which expects it.
Payment receipt
Another improvement that we will introduce is the improvement to the “Register Payment” operation. Once the user finishes registering the payment the system will ask the user if she wants to display the receipt. If the user answers yes, the system will display the page, which lists the details of the member, the payment amount, description etc.
The page that will be displayed if the user asks for the receipt will be represented by an HTML document. We add the new document to our configuration in much the same way we have defined our reports. The difference is that the type of the document is “HTML” and that we prepare the document template not in the Report Designer but in any HTML editor of our choice. We define a new document of the HTML type, enter its name “Payment receipt” and click on the “Import” button on the documents editor to import the layout of the page that we have prepared in the HTML editor. We need to put all the layout files (including the HTML file and any images and/or styles) into a separate directory and specify the name of this directory when we import the layout. You can have a look at the layout of the “Payment receipt” document in the configuration of the Library application located in the “samples” directory of your Aware IM installation.
note
The document expects thePayment
object to be in the context of any operation that is using the document.Now we need to modify our RegisterPayment process to:
- Ask the user if she wants the system to display a receipt
- Display the “Payment receipt” document if required.
We do this by adding the following rules to the RegisterPayment process:
DISPLAY QUESTION 'Display receipt?' IF Question.Reply = 'Yes' THEN DISPLAY DOCUMENT 'Payment receipt'
The entire process, therefore, looks like this:
ENTER NEW Payment WITH Payment.Member = Member DISPLAY QUESTION 'Display receipt?' IF Question.Reply = 'Yes' THEN DISPLAY DOCUMENT 'Payment receipt'
note
The first action puts thePayment
object that the “Payment receipt” document expects in the context.