Allow deleting of unreferenced account groups.
[capital-apms-progress.git] / inc / method / m-htmlrep.i
blob30f689d5b65ff00c22374440313691065ff69f96
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Method-Library
4 /*--------------------------------------------------------------------------
5 Library : m-htmlrep.i
6 Purpose : Methods for producing HTML-based reports
7 Author(s) : Andrew McMillan
8 Notes : This should be a replacement for m-txtrep.i, except
9 that it probably _won't_ work on the batch queue.
10 and lot's of other changes will be needed to work
11 for a different metaphor really.
12 ------------------------------------------------------------------------*/
14 DEF VAR htmlrep-print-file AS CHAR NO-UNDO.
15 DEF VAR htmlrep-header-file AS CHAR NO-UNDO.
16 DEF VAR htmlrep-filename AS CHAR NO-UNDO.
17 DEF VAR htmlrep-prefix AS CHAR INITIAL "R" NO-UNDO.
19 DEF VAR htmlrep-headers AS CHAR NO-UNDO INITIAL "<html>~n".
20 DEF VAR htmlrep-body AS CHAR NO-UNDO INITIAL "</head>~n".
21 DEF VAR htmlrep-hdr-sent AS LOGI NO-UNDO INITIAL No.
22 DEF VAR htmlrep-current-tag AS CHAR NO-UNDO INITIAL "".
24 /* _UIB-CODE-BLOCK-END */
25 &ANALYZE-RESUME
28 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
30 /* ******************** Preprocessor Definitions ******************** */
34 /* _UIB-PREPROCESSOR-BLOCK-END */
35 &ANALYZE-RESUME
38 /* ************************ Function Prototypes ********************** */
40 &IF DEFINED(EXCLUDE-html-entities) = 0 &THEN
42 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD html-entities Method-Library
43 FUNCTION html-entities RETURNS CHARACTER
44 ( INPUT base-text AS CHAR ) FORWARD.
46 /* _UIB-CODE-BLOCK-END */
47 &ANALYZE-RESUME
49 &ENDIF
51 &IF DEFINED(EXCLUDE-tag) = 0 &THEN
53 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD tag Method-Library
54 FUNCTION tag RETURNS CHARACTER
55 ( INPUT tagtype AS CHAR, INPUT tagtext AS CHAR, INPUT attributes AS CHAR ) FORWARD.
57 /* _UIB-CODE-BLOCK-END */
58 &ANALYZE-RESUME
60 &ENDIF
63 /* *********************** Procedure Settings ************************ */
65 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
66 /* Settings for THIS-PROCEDURE
67 Type: Method-Library
68 Allow:
69 Frames: 0
70 Add Fields to: Neither
71 Other Settings: INCLUDE-ONLY
73 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
75 /* ************************* Create Window ************************** */
77 &ANALYZE-SUSPEND _CREATE-WINDOW
78 /* DESIGN Window definition (used by the UIB)
79 CREATE WINDOW Method-Library ASSIGN
80 HEIGHT = .1
81 WIDTH = 39.86.
82 /* END WINDOW DEFINITION */
84 &ANALYZE-RESUME
86 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Method-Library
87 /* ************************* Included-Libraries *********************** */
89 {inc/method/m-bqmgr.i}
90 {src/adm/method/attribut.i}
91 {inc/string.i}
93 /* _UIB-CODE-BLOCK-END */
94 &ANALYZE-RESUME
100 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Method-Library
103 /* *************************** Main Block *************************** */
105 RUN htmlrep-initialise.
107 /* _UIB-CODE-BLOCK-END */
108 &ANALYZE-RESUME
111 /* ********************** Internal Procedures *********************** */
113 &IF DEFINED(EXCLUDE-htmlrep-initialise) = 0 &THEN
115 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE htmlrep-initialise Method-Library
116 PROCEDURE htmlrep-initialise :
117 /*------------------------------------------------------------------------------
118 Purpose: Initialise the important parameters
119 ------------------------------------------------------------------------------*/
120 DEF VAR temp-dir AS CHAR NO-UNDO.
122 temp-dir = OS-GETENV("TEMP":U).
123 IF temp-dir = ? OR temp-dir = "" THEN temp-dir = SESSION:TEMP-DIRECTORY .
124 temp-dir = temp-dir + "\".
126 htmlrep-print-file = temp-dir + "HB" + STRING( TIME, "99999") + ".TMP".
127 htmlrep-header-file = temp-dir + "HH" + STRING( TIME, "99999") + ".TMP".
128 htmlrep-filename = temp-dir + "H" + STRING( TIME, "99999") + ".html" .
130 DO WHILE INDEX( htmlrep-print-file, "/" ) > 0:
131 SUBSTRING( htmlrep-print-file, INDEX( htmlrep-print-file, "/" ), 1) = "\".
132 END.
133 DO WHILE INDEX( htmlrep-header-file, "/" ) > 0:
134 SUBSTRING( htmlrep-header-file, INDEX( htmlrep-header-file, "/" ), 1) = "\".
135 END.
136 DO WHILE INDEX( htmlrep-filename, "/" ) > 0:
137 SUBSTRING( htmlrep-filename, INDEX( htmlrep-filename, "/" ), 1) = "\".
138 END.
140 htmlrep-headers = "<html>~n<head>~n".
142 END PROCEDURE.
144 /* _UIB-CODE-BLOCK-END */
145 &ANALYZE-RESUME
147 &ENDIF
149 &IF DEFINED(EXCLUDE-htmlrep-line) = 0 &THEN
151 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE htmlrep-line Method-Library
152 PROCEDURE htmlrep-line :
153 /*------------------------------------------------------------------------------
154 Purpose: Print a line in a selected font
155 ------------------------------------------------------------------------------*/
156 DEF INPUT PARAMETER line-text AS CHAR NO-UNDO.
158 IF line-text = ? THEN line-text = "".
160 DEF VAR i AS INT NO-UNDO.
162 htmlrep-body = htmlrep-body + line-text + "~n".
164 /* PUT UNFORMATTED line-text SKIP. */
166 END PROCEDURE.
168 /* _UIB-CODE-BLOCK-END */
169 &ANALYZE-RESUME
171 &ENDIF
173 &IF DEFINED(EXCLUDE-pclrep-start) = 0 &THEN
175 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pclrep-start Method-Library
176 PROCEDURE pclrep-start :
177 /*------------------------------------------------------------------------------
178 Purpose:
179 ------------------------------------------------------------------------------*/
180 DEF INPUT PARAMETER preview AS LOGICAL NO-UNDO.
182 htmlrep-headers = "<html>~n".
183 htmlrep-body = "</head>~n".
185 END PROCEDURE.
187 /* _UIB-CODE-BLOCK-END */
188 &ANALYZE-RESUME
190 &ENDIF
192 &IF DEFINED(EXCLUDE-set-title) = 0 &THEN
194 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-title Method-Library
195 PROCEDURE set-title :
196 /*------------------------------------------------------------------------------
197 Purpose: Set the title in the report viewer window.
198 ------------------------------------------------------------------------------*/
199 DEF INPUT PARAMETER title-text AS CHAR NO-UNDO.
201 htmlrep-headers = htmlrep-headers
202 + "<title>" + html-entities(title-text) + "</title>~n".
204 END PROCEDURE.
206 /* _UIB-CODE-BLOCK-END */
207 &ANALYZE-RESUME
209 &ENDIF
211 &IF DEFINED(EXCLUDE-view-output-file) = 0 &THEN
213 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE view-output-file Method-Library
214 PROCEDURE view-output-file :
215 /*------------------------------------------------------------------------------
216 Purpose: Close the output file now that we've finished with it.
217 ------------------------------------------------------------------------------*/
218 DEF INPUT PARAMETER txtrep-is-preview AS LOGI NO-UNDO.
220 OUTPUT TO VALUE(html-filename) .
221 PUT UNFORMATTED htmlrep-headers htmlrep-body .
222 OUTPUT CLOSE.
224 IF txtrep-is-preview THEN DO:
225 OS-COMMAND "iexplore " + htmlrep-filename .
226 END.
227 ELSE DO:
228 /* do nothing */
229 END.
231 END PROCEDURE.
233 /* _UIB-CODE-BLOCK-END */
234 &ANALYZE-RESUME
236 &ENDIF
238 /* ************************ Function Implementations ***************** */
240 &IF DEFINED(EXCLUDE-html-entities) = 0 &THEN
242 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION html-entities Method-Library
243 FUNCTION html-entities RETURNS CHARACTER
244 ( INPUT base-text AS CHAR ) :
245 /*------------------------------------------------------------------------------
246 Purpose: Convert awkward characters to HTML entities
247 Notes:
248 ------------------------------------------------------------------------------*/
249 DEF VAR replaced AS CHAR NO-UNDO.
251 replaced = REPLACE( base-text, "&", "&amp;" ).
252 replaced = REPLACE( replaced, "<", "&lt;" ).
253 replaced = REPLACE( replaced, ">", "&gt;" ).
255 RETURN replaced.
257 END FUNCTION.
259 /* _UIB-CODE-BLOCK-END */
260 &ANALYZE-RESUME
262 &ENDIF
264 &IF DEFINED(EXCLUDE-tag) = 0 &THEN
266 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION tag Method-Library
267 FUNCTION tag RETURNS CHARACTER
268 ( INPUT tagtype AS CHAR, INPUT tagtext AS CHAR, INPUT attributes AS CHAR ) :
269 /*------------------------------------------------------------------------------
270 Purpose: Enclose the tagtext value in quotes
271 Notes:
272 ------------------------------------------------------------------------------*/
274 RETURN "<" + tagtype + " " + attributes + ">"
275 + tagtext
276 + "</" + tagtype + ">".
278 END FUNCTION.
280 /* _UIB-CODE-BLOCK-END */
281 &ANALYZE-RESUME
283 &ENDIF