Module cAutoWebreport.pkg
1//****************************************************************************//
2// //
3// $File name : cAutoWebReport.PKG //
4// $File title : cAutoWebreport class //
5// $Author : John Tuohy //
6// //
7// Confidential Trade Secret. //
8// Copyright 1999 Data Access Corporation, Miami FL, USA //
9// All Rights reserved //
10// DataFlex is a registered trademark of Data Access Corporation. //
11// //
12// //
13// $Rev History //
14// 8/12/98 jjt - created //
15// //
16//****************************************************************************//
17Use cWebReport.pkg
18
19{ ClassLibrary=WebApp }
20{ HelpTopic=cAutoWebReport }
21Class cAutoWebReport is a cWebReport
22
23 Procedure Construct_Object
24 Forward send construct_object
25 Delegate Set phAutoWebReport to self
26 { Visibility=Private }
27 Property Boolean pbUseRowIds True
28 // If an auto-report is created, register it in its parent WBO
29 Send RegisterInterface get_AutoReport "get_AutoReport" "string sTable integer iIndex String hRef Integer iMax Integer iStart returns integer" ;
30 "Obsolete (use AutoReport1). Create an auto-report for every field in the DD"
31 End_Procedure
32
33 { NoDoc=True }
34 Procedure OnPageTop
35 integer iFile iFields iField iType
36 integer hDD
37 string sValue sAlign
38 Get server to hDD
39 Get Main_file of hDD to iFile
40 Get_Attribute DF_FILE_NUMBER_FIELDS of iFile to iFields
41
42 Send WriteHtmlTableBegin 'Class="ReportTable"'
43
44 Send WriteHtmlRowBegin
45 For iField from 1 to iFields
46 Get_Attribute DF_FIELD_TYPE of iFile iField to iType
47 If (iType<>DF_OVERLAP and iType<>DF_BINARY) Begin
48 Case Begin
49 Case (iType=DF_BCD) move '"right"' to sAlign
50 Case (iType=DF_TEXT) Move '"left" width="40%"' to sAlign
51 Case (iType=DF_Date or iType=DF_DateTime) Move '"center"' to sAlign
52 Case else Move '"left"' to sAlign
53 Case End
54 Move ('align='-sAlign * 'vAlign="top" bgcolor="Silver" Class="Header"') to sAlign
55 Get File_Field_Label of hDD iFile iField DD_LABEL_SHORT to sValue
56 Send WriteHtmlCellHeader (HtmlEncode(sValue)) sAlign
57 End
58 Loop
59 Send WriteHtmlRowEnd
60 End_Procedure
61
62 { NoDoc=True }
63 Procedure OnBody
64 integer iFile iFields iField iType iPoints
65 integer hDD
66 string sValue sAlign
67 Boolean bUseRowIds
68 Get server to hDD
69 Get Main_file of hDD to iFile
70 Get_Attribute DF_FILE_NUMBER_FIELDS of iFile to iFields
71 Get pbUseRowIds to bUseRowIds
72
73 Send WriteHtmlRowBegin
74 For iField from 1 to iFields
75 Get_Attribute DF_FIELD_TYPE of iFile iField to iType
76 If (iType<>DF_OVERLAP and iType<>DF_BINARY) Begin
77 Case Begin
78 Case (iType=DF_BCD) move '"right"' to sAlign
79 Case (iType=DF_TEXT) Move '"left" width="40%"' to sAlign
80 Case (iType=DF_Date or iType=DF_Datetime) Move '"center"' to sAlign
81 Case else Move '"left"' to sAlign
82 Case End
83 Move ('align='-sAlign * 'vAlign="top" Class="Data"') to sAlign
84 If (iType<>DF_Text) ;
85 Get File_Field_Current_Description of hDD iFile iField to sValue
86 Else ;
87 Get File_Field_Current_Value of hDD iFile iField to sValue
88
89 If (iType=DF_BCD) Begin
90 Get_Attribute DF_FIELD_PRECISION of iFile iField to iPoints
91 Move (FormatNumber(sValue,iPoints)) to sValue
92 end
93 else ;
94 get HtmlEncode sValue to sValue
95 //
96 If (iField=1) Begin
97 If bUseRowIds begin
98 Get AddRowIdLink sValue to sValue //
99 end
100 else begin // we must support old because pages may be
101 Get AddRecordLink sValue to sValue // created that need recnum
102 end
103 end
104 //
105 Send WriteHtmlCell sValue sAlign
106 End
107 Loop
108 Send WriteHtmlRowEnd
109 End_Procedure
110
111 { NoDoc=True }
112 Procedure OnPageBottom
113 Send WriteHtmlTableEnd
114 End_Procedure
115
116 { Obsolete=True }
117 Function DoAutoReport integer iIndex string sHref integer iMax integer iStart Returns integer
118 boolean bUseRowIdsOld
119 If (Server(self)=0) Begin
120 Error DFERR_PROGRAM C_$NoDDOForReport
121 Function_return 0
122 end
123 Get pbUseRowIds to bUseRowIdsOld
124 Set pbUseRowIds to False
125 Set piMaxCount to iMax
126 Set priStartRowId to (NullRowId())
127 Set piStartRecord to iStart
128 Set piOrdering to iIndex
129 set psHRefName to sHref
130 Send Run_Report
131 Set pbUseRowIds to bUseRowIdsOld
132 Function_return (piLastRecord(self))
133 End_Function
134
135 Function DoAutoReport1 integer iIndex string sHref integer iMax String sStart Returns string
136 boolean bUseRowIdsOld
137 RowId riLast
138 string sLast
139 If (Server(self)=0) Begin
140 Error DFERR_PROGRAM C_$NoDDOForReport
141 Function_return ""
142 end
143 Get pbUseRowIds to bUseRowIdsOld
144 Set pbUseRowIds to True
145 Set piMaxCount to iMax
146 Set priStartRowId to (if(sStart="", NullRowId(), DeserializeRowId(sStart)))
147 Set piStartRecord to 0
148 Set piOrdering to iIndex
149 set psHRefName to sHref
150 Send Run_Report
151 Get priLastRowId to riLast
152 Move (if(isNullRowId(riLast), "", SerializeRowId(riLast) )) to sLast
153 Set pbUseRowIds to bUseRowIdsOld
154 Function_return sLast
155 End_Function
156
157
158End_Class
159