xml form generator (version from 1/28/2011)
[openemr.git] / contrib / forms / xmlformgen / xslt / field_objects.xslt
blob10ea0883880fc75d31ecd57737b4c1cdfb200a35
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!-- Generated by Hand -->
3 <!--
4 Copyright (C) 2011 Julia Longtin <julia.longtin@gmail.com>
6 This program is free software; you can redistribute it and/or
7 Modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 -->
12 <!-- templates in this file are meant as manual replacements for the layouts engine. AKA, this file should not be used in pure layout forms. -->
13 <xsl:stylesheet version="1.0"
14 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
15 <!-- the default template for the 'manual' container object -->
16 <xsl:template match="manual">
17 <xsl:text disable-output-escaping="yes"><![CDATA[<!-- display the form's manual based fields -->
18 <table border='0' cellpadding='0' width='100%'>
19 ]]></xsl:text>
20 <xsl:apply-templates select="field|div|section"/>
21 <xsl:text disable-output-escaping="yes"><![CDATA[</table>
22 ]]></xsl:text>
23 </xsl:template>
24 <!-- section template. For print pages, prepend print_ to the name of the div, so we can reference it seperately in the stylesheet -->
25 <xsl:template match="section">
26 <xsl:text disable-output-escaping="yes"><![CDATA[<tr><td class='sectionlabel'><input type='checkbox' id='form_cb_m_]]></xsl:text>
27 <xsl:value-of select="position()"/>
28 <xsl:text disable-output-escaping="yes"><![CDATA[' value='1' onclick='return divclick(this,"]]></xsl:text>
29 <xsl:value-of select="@name"/>
30 <xsl:text disable-output-escaping="yes"><![CDATA[")' checked="checked" />]]></xsl:text>
31 <xsl:value-of select="@label"/>
32 <xsl:text disable-output-escaping="yes"><![CDATA[</td></tr><tr><td>]]></xsl:text>
33 <xsl:text disable-output-escaping="yes"><![CDATA[<div id="]]></xsl:text>
34 <xsl:if test="$page='print'">
35 <xsl:text disable-output-escaping="yes"><![CDATA[print_]]></xsl:text>
36 </xsl:if>
37 <xsl:value-of select="@name"/>
38 <xsl:text disable-output-escaping="yes"><![CDATA[" class='section'><table>
39 ]]></xsl:text>
40 <xsl:call-template name="consumeRows">
41 <xsl:with-param name="fields" select="field"/>
42 <xsl:with-param name="checked" select="1"/>
43 <xsl:with-param name="consumedcols" select="0"/>
44 <xsl:with-param name="numofCols" select="//style/@cells_per_row"/>
45 </xsl:call-template>
46 <xsl:text disable-output-escaping="yes"><![CDATA[</table></div>
47 </td></tr> <!-- end section ]]></xsl:text>
48 <xsl:value-of select="@name"/>
49 <xsl:text disable-output-escaping="yes"><![CDATA[ -->
50 ]]></xsl:text>
51 </xsl:template>
52 <xsl:template name="consumeRows">
53 <xsl:param name="fields" />
54 <xsl:param name="checked" />
55 <xsl:param name="consumedcols" />
56 <xsl:param name="numofCols" />
57 <xsl:text disable-output-escaping="yes"><![CDATA[<!-- called consumeRows ]]></xsl:text>
58 <xsl:value-of select="$consumedcols"/>
59 <xsl:value-of select="$checked"/>
60 <xsl:value-of select="$numofCols"/>
61 <xsl:text disable-output-escaping="yes"><![CDATA[--> ]]></xsl:text>
62 <xsl:choose>
63 <!-- exit condition -->
64 <xsl:when test="not($fields)">
65 <xsl:text disable-output-escaping="yes"><![CDATA[<!-- Exiting not($fields) and generating ]]></xsl:text>
66 <xsl:value-of select="$numofCols - $consumedcols"/>
67 <xsl:text disable-output-escaping="yes"><![CDATA[ empty fields -->]]></xsl:text>
68 <xsl:call-template name="EmptyFields">
69 <xsl:with-param name="fields" select="$numofCols - $consumedcols"/>
70 </xsl:call-template>
71 <xsl:text disable-output-escaping="yes"><![CDATA[</tr>
72 ]]></xsl:text>
73 </xsl:when>
74 <xsl:otherwise>
75 <xsl:choose>
76 <xsl:when test="not($fields[$checked+1])">
77 <xsl:text disable-output-escaping="yes"><![CDATA[<!-- generating not($fields[$checked+1]) and calling last ]]></xsl:text>
78 <xsl:text disable-output-escaping="yes"><![CDATA[-->]]></xsl:text>
79 <xsl:apply-templates select="$fields[position() &lt;= $checked]"/>
80 <xsl:call-template name="consumeRows">
81 <xsl:with-param name="fields" select="$fields[position() > $checked]"/>
82 <xsl:with-param name="checked" select="$checked"/>
83 <xsl:with-param name="consumedcols" select="$fields[$checked]/@cols + $fields[$checked]/@labelcols + $consumedcols"/>
84 <xsl:with-param name="numofCols" select="$numofCols"/>
85 </xsl:call-template>
86 </xsl:when>
87 <xsl:when test="$fields[$checked]/@cols + $fields[$checked]/@labelcols + $consumedcols >= $numofCols and $fields[$checked+1]/@cols!=0">
88 <xsl:text disable-output-escaping="yes"><![CDATA[<!-- generating ]]></xsl:text>
89 <xsl:value-of select="$consumedcols + $fields[$checked]/@cols + $fields[$checked]/@labelcols"/>
90 <xsl:text disable-output-escaping="yes"><![CDATA[ cells and calling -->]]></xsl:text>
91 <xsl:apply-templates select="$fields[position() &lt;= $checked]"/>
92 <xsl:if test="$numofCols - $consumedcols > 0">
93 <xsl:text disable-output-escaping="yes"><![CDATA[<!-- generating empties -->]]></xsl:text>
94 <xsl:call-template name="EmptyFields">
95 <xsl:with-param name="fields" select="$numofCols - $consumedcols"/>
96 </xsl:call-template>
97 </xsl:if>
98 <xsl:text disable-output-escaping="yes"><![CDATA[</tr>
99 ]]></xsl:text>
100 <xsl:call-template name="consumeRows">
101 <xsl:with-param name="fields" select="$fields[position() > $checked]"/>
102 <xsl:with-param name="checked" select="1"/>
103 <xsl:with-param name="consumedcols" select="0"/>
104 <xsl:with-param name="numofCols" select="$numofCols"/>
105 </xsl:call-template>
106 </xsl:when>
107 <xsl:otherwise>
108 <xsl:text disable-output-escaping="yes"><![CDATA[<!-- just calling -->]]></xsl:text>
109 <xsl:call-template name="consumeRows">
110 <xsl:with-param name="fields" select="$fields"/>
111 <xsl:with-param name="checked" select="$checked+1"/>
112 <xsl:with-param name="consumedcols" select="$fields[$checked]/@cols + $fields[$checked]/@labelcols + $consumedcols"/>
113 <xsl:with-param name="numofCols" select="$numofCols"/>
114 </xsl:call-template>
115 </xsl:otherwise>
116 </xsl:choose>
117 </xsl:otherwise>
118 </xsl:choose>
119 </xsl:template>
120 <xsl:template name="EmptyFields">
121 <xsl:param name="fields"/>
122 <xsl:if test="$fields > 1">
123 <xsl:call-template name="EmptyFields">
124 <xsl:with-param name="fields" select="$fields=1"/>
125 </xsl:call-template>
126 </xsl:if>
127 <xsl:if test="$fields > 0">
128 <xsl:text disable-output-escaping="yes"><![CDATA[<td class='emptycell' colspan='1'></td>]]></xsl:text>
129 </xsl:if>
130 </xsl:template>
131 <xsl:template match="field[@type='checkbox_list' or @type='exams' or @type='textbox' or @type='textarea' or @type='provider' or @type='textfield' or @type='dropdown_list']">
132 <xsl:if test="@labelcols>0">
133 <xsl:text disable-output-escaping="yes"><![CDATA[<td class='fieldlabel' colspan=']]></xsl:text>
134 <xsl:value-of select="@labelcols"/>
135 <xsl:text disable-output-escaping="yes"><![CDATA['><?php echo xl_layout_label(']]></xsl:text>
136 <xsl:value-of select="@label"/>
137 <xsl:text disable-output-escaping="yes"><![CDATA[','e').':'; ?></td>]]></xsl:text>
138 </xsl:if>
139 <xsl:if test="@cols>0">
140 <xsl:text disable-output-escaping="yes"><![CDATA[<td class='text data' colspan=']]></xsl:text>
141 <xsl:value-of select="@cols"/>
142 <xsl:text disable-output-escaping="yes"><![CDATA['>]]></xsl:text>
143 </xsl:if>
144 <xsl:text disable-output-escaping="yes"><![CDATA[<?php echo generate_form_field($manual_layouts[']]></xsl:text>
145 <xsl:value-of select="@name"/>
146 <xsl:text disable-output-escaping="yes"><![CDATA['], ]]></xsl:text>
147 <xsl:if test="$fetchrow!=''">
148 <xsl:text disable-output-escaping="yes"><![CDATA[$]]></xsl:text>
149 <xsl:value-of select="$fetchrow"/>
150 <xsl:text disable-output-escaping="yes"><![CDATA[[']]></xsl:text>
151 <xsl:value-of select="@name"/>
152 <xsl:text disable-output-escaping="yes"><![CDATA[']]]></xsl:text>
153 </xsl:if>
154 <xsl:if test="$fetchrow=''">
155 <xsl:text disable-output-escaping="yes"><![CDATA['']]></xsl:text>
156 </xsl:if>
157 <xsl:text disable-output-escaping="yes"><![CDATA[); ?>]]></xsl:text>
158 <xsl:choose>
159 <xsl:when test="following-sibling::field[position()=1][@cols=0]">
160 </xsl:when>
161 <xsl:otherwise>
162 <xsl:text disable-output-escaping="yes"><![CDATA[</td>]]></xsl:text>
163 </xsl:otherwise>
164 </xsl:choose>
165 </xsl:template>
166 <!-- the default template for date fields -->
167 <xsl:template match="field[@type='date']">
168 <xsl:text disable-output-escaping="yes"><![CDATA[<td>
169 <span class="fieldlabel"><?php xl(']]></xsl:text>
170 <xsl:value-of select="@label" />
171 <xsl:text disable-output-escaping="yes"><![CDATA[','e'); ?>]]></xsl:text>
172 <xsl:if test="$page!='print' and @name!='effective_date'">
173 <xsl:text disable-output-escaping="yes"><![CDATA[ (yyyy-mm-dd)]]></xsl:text>
174 </xsl:if>
175 <xsl:text disable-output-escaping="yes"><![CDATA[: </span>
176 </td><td>
177 <input type='text' size='10' name=']]></xsl:text>
178 <xsl:value-of select="@name" />
179 <xsl:text disable-output-escaping="yes"><![CDATA[' id=']]></xsl:text>
180 <xsl:value-of select="@name" />
181 <xsl:if test="@hoverover!=''">
182 <xsl:text disable-output-escaping="yes"><![CDATA[' title=']]></xsl:text>
183 <xsl:value-of select="@hoverover" />
184 </xsl:if>
185 <xsl:text disable-output-escaping="yes"><![CDATA['
186 ]]></xsl:text>
187 <xsl:if test="$fetchrow!=''">
188 <xsl:text disable-output-escaping="yes"><![CDATA[ value="<?php $result=chkdata_Date($]]></xsl:text>
189 <xsl:value-of select="$fetchrow"/>
190 <xsl:text disable-output-escaping="yes"><![CDATA[,']]></xsl:text>
191 <xsl:value-of select="@name" />
192 <xsl:text disable-output-escaping="yes"><![CDATA['); echo $result; ?>"
193 ]]></xsl:text>
194 </xsl:if>
195 <xsl:if test="$page='new'">
196 <xsl:text disable-output-escaping="yes"><![CDATA[ value="<?php echo date('Y-m-d', time()); ?>"
197 title="<?php xl('yyyy-mm-dd','e'); ?>"
198 ]]></xsl:text>
199 </xsl:if>
200 <xsl:if test="$page!='print' and @name!='effective_date'">
201 <xsl:text disable-output-escaping="yes"><![CDATA[ onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
202 ]]></xsl:text>
203 </xsl:if>
204 <xsl:if test="$page='print' or @name='effective_date'">
205 <xsl:text disable-output-escaping="yes"><![CDATA[ />
206 ]]></xsl:text>
207 </xsl:if>
208 <xsl:if test="$page!='print' and @name!='effective_date'">
209 <xsl:text disable-output-escaping="yes"><![CDATA[ <img src='../../pic/show_calendar.gif' width='24' height='22'
210 id='img_]]></xsl:text>
211 <xsl:value-of select="@name" />
212 <xsl:text disable-output-escaping="yes"><![CDATA[' alt='[?]' style='cursor:pointer'
213 title="<?php xl('Click here to choose a date','e'); ?>" />
214 <script type="text/javascript">
215 Calendar.setup({inputField:']]></xsl:text>
216 <xsl:value-of select="@name" />
217 <xsl:text disable-output-escaping="yes"><![CDATA[', ifFormat:'%Y-%m-%d', button:'img_]]></xsl:text>
218 <xsl:value-of select="@name" />
219 <xsl:text disable-output-escaping="yes"><![CDATA['});
220 </script>
221 ]]></xsl:text>
222 </xsl:if>
223 <xsl:text disable-output-escaping="yes"><![CDATA[</td>
224 ]]></xsl:text>
225 </xsl:template>
226 <!-- div template. For print pages, prepend print_ to the name of the div, so we can reference it seperately in the stylesheet -->
227 <xsl:template match="div">
228 <xsl:text disable-output-escaping="yes"><![CDATA[<div id="]]></xsl:text>
229 <xsl:if test="$page='print'">
230 <xsl:text disable-output-escaping="yes"><![CDATA[print_]]></xsl:text>
231 </xsl:if>
232 <xsl:value-of select="@name"/>
233 <xsl:if test="@style">
234 <xsl:text disable-output-escaping="yes"><![CDATA[" style="]]></xsl:text>
235 </xsl:if>
236 <xsl:value-of select="@style"/>
237 <xsl:text disable-output-escaping="yes"><![CDATA[">
238 ]]></xsl:text>
239 <xsl:apply-templates select="field|div"/>
240 <xsl:text disable-output-escaping="yes"><![CDATA[</div> <!-- end ]]></xsl:text>
241 <xsl:value-of select="@name"/>
242 <xsl:text disable-output-escaping="yes"><![CDATA[ -->
243 </td></tr>
244 ]]></xsl:text>
245 </xsl:template>
246 </xsl:stylesheet>