2 // Copyright (C) 2008-2009 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This module is invoked by add_edit_issue.php as an extension to
10 // add support for issue types that are specific to IPPF.
12 require_once("$srcdir/options.inc.php");
13 require_once("$srcdir/patient.inc");
15 $CPR = 4; // cells per row
21 global $item_count, $cell_count;
22 if ($item_count > 0) {
30 global $cell_count, $CPR;
32 if ($cell_count > 0) {
33 for (; $cell_count < $CPR;
34 ++
$cell_count) echo "<td></td>";
43 if (strlen($last_group) > 0) {
50 function issue_ippf_gcac_newtype()
52 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
53 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
56 function issue_ippf_gcac_save($issue)
58 $sets = "id = '" . add_escape_custom($issue) . "'";
59 $fres = sqlStatement("SELECT * FROM layout_options " .
60 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
61 "ORDER BY group_name, seq");
62 while ($frow = sqlFetchArray($fres)) {
63 $field_id = $frow['field_id'];
64 $value = get_layout_form_value($frow);
65 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
67 // This replaces the row if its id exists, otherwise inserts it.
68 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
71 function issue_ippf_gcac_form($issue, $thispid)
73 global $pprow, $item_count, $cell_count, $last_group;
75 $shrow = getHistoryData($thispid);
78 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
83 echo "<div id='ippf_gcac' style='display:none'>\n";
85 $fres = sqlStatement("SELECT * FROM layout_options " .
86 "WHERE form_id = 'GCA' AND uor > 0 " .
87 "ORDER BY group_name, seq");
91 $display_style = 'block';
93 while ($frow = sqlFetchArray($fres)) {
94 $this_group = $frow['group_name'];
95 $titlecols = $frow['titlecols'];
96 $datacols = $frow['datacols'];
97 $data_type = $frow['data_type'];
98 $field_id = $frow['field_id'];
99 $list_id = $frow['list_id'];
103 if ($frow['edit_options'] == 'H') {
104 // This data comes from static history
105 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
107 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
110 // Handle a data category (group) change.
111 if (strcmp($this_group, $last_group) != 0) {
113 $group_seq = 'gca' . substr($this_group, 0, 1);
114 $group_name = substr($this_group, 1);
115 $last_group = $this_group;
116 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
117 "onclick='return divclick(this,\"div_$group_seq\");'";
118 if ($display_style == 'block') echo " checked";
119 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
120 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
121 echo " <table border='0' cellpadding='0' width='100%'>\n";
122 $display_style = 'none';
125 // Handle starting of a new row.
126 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
131 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
133 // Handle starting of a new label cell.
134 if ($titlecols > 0) {
136 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
137 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
138 if ($cell_count == 2) echo " style='padding-left:10pt'";
140 $cell_count +
= $titlecols;
145 if ($frow['title']) echo (xl_layout_label($frow['title']) . ":");
149 // Handle starting of a new data cell.
152 echo "<td valign='top' colspan='$datacols' class='text'";
153 if ($cell_count > 0) echo " style='padding-left:5pt'";
155 $cell_count +
= $datacols;
160 if ($frow['edit_options'] == 'H')
161 echo generate_display_field($frow, $currvalue);
163 generate_form_field($frow, $currvalue);
170 function issue_ippf_con_newtype()
172 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
173 echo " document.getElementById('ippf_con').style.display = condisp;\n";
176 function issue_ippf_con_save($issue)
178 $sets = "id = '" . add_escape_custom($issue) . "'";
179 $fres = sqlStatement("SELECT * FROM layout_options " .
180 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
181 "ORDER BY group_name, seq");
182 while ($frow = sqlFetchArray($fres)) {
183 $field_id = $frow['field_id'];
184 $value = get_layout_form_value($frow);
185 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
187 // This replaces the row if its id exists, otherwise inserts it.
188 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
191 function issue_ippf_con_form($issue, $thispid)
193 global $pprow, $item_count, $cell_count, $last_group;
195 $shrow = getHistoryData($thispid);
198 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
203 echo "<div id='ippf_con' style='display:none'>\n";
205 $fres = sqlStatement("SELECT * FROM layout_options " .
206 "WHERE form_id = 'CON' AND uor > 0 " .
207 "ORDER BY group_name, seq");
211 $display_style = 'block';
213 while ($frow = sqlFetchArray($fres)) {
214 $this_group = $frow['group_name'];
215 $titlecols = $frow['titlecols'];
216 $datacols = $frow['datacols'];
217 $data_type = $frow['data_type'];
218 $field_id = $frow['field_id'];
219 $list_id = $frow['list_id'];
223 if ($frow['edit_options'] == 'H') {
224 // This data comes from static history
225 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
227 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
230 // Handle a data category (group) change.
231 if (strcmp($this_group, $last_group) != 0) {
233 $group_seq = 'con' . substr($this_group, 0, 1);
234 $group_name = substr($this_group, 1);
235 $last_group = $this_group;
236 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
237 "onclick='return divclick(this,\"div_$group_seq\");'";
238 if ($display_style == 'block') echo " checked";
239 echo " /><b>$group_name</b></span>\n";
240 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
241 echo " <table border='0' cellpadding='0' width='100%'>\n";
242 $display_style = 'none';
245 // Handle starting of a new row.
246 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
251 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
253 // Handle starting of a new label cell.
254 if ($titlecols > 0) {
256 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
257 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
258 if ($cell_count == 2) echo " style='padding-left:10pt'";
260 $cell_count +
= $titlecols;
265 if ($frow['title']) echo $frow['title'] . ":";
269 // Handle starting of a new data cell.
272 echo "<td valign='top' colspan='$datacols' class='text'";
273 if ($cell_count > 0) echo " style='padding-left:5pt'";
275 $cell_count +
= $datacols;
280 if ($frow['edit_options'] == 'H')
281 echo generate_display_field($frow, $currvalue);
283 generate_form_field($frow, $currvalue);
290 /*********************************************************************
292 function issue_ippf_srh_newtype() {
293 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
294 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
297 function issue_ippf_srh_save($issue) {
298 $sets = "id = '" add_escape_custom($issue) . "'";
299 $fres = sqlStatement("SELECT * FROM layout_options " .
300 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
301 "ORDER BY group_name, seq");
302 while ($frow = sqlFetchArray($fres)) {
303 $field_id = $frow['field_id'];
304 $value = get_layout_form_value($frow);
305 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
307 // This replaces the row if its id exists, otherwise inserts it.
308 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
311 function issue_ippf_srh_form($issue, $thispid) {
312 global $pprow, $item_count, $cell_count, $last_group;
314 $shrow = getHistoryData($thispid);
317 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
322 echo "<div id='ippf_srh' style='display:none'>\n";
324 $fres = sqlStatement("SELECT * FROM layout_options " .
325 "WHERE form_id = 'SRH' AND uor > 0 " .
326 "ORDER BY group_name, seq");
330 $display_style = 'block';
332 while ($frow = sqlFetchArray($fres)) {
333 $this_group = $frow['group_name'];
334 $titlecols = $frow['titlecols'];
335 $datacols = $frow['datacols'];
336 $data_type = $frow['data_type'];
337 $field_id = $frow['field_id'];
338 $list_id = $frow['list_id'];
342 if ($frow['edit_options'] == 'H') {
343 // This data comes from static history
344 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
346 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
349 // Handle a data category (group) change.
350 if (strcmp($this_group, $last_group) != 0) {
352 $group_seq = 'srh' . substr($this_group, 0, 1);
353 $group_name = substr($this_group, 1);
354 $last_group = $this_group;
355 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
356 "onclick='return divclick(this,\"div_$group_seq\");'";
357 if ($display_style == 'block') echo " checked";
358 echo " /><b>$group_name</b></span>\n";
359 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
360 echo " <table border='0' cellpadding='0' width='100%'>\n";
361 $display_style = 'none';
364 // Handle starting of a new row.
365 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
370 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
372 // Handle starting of a new label cell.
373 if ($titlecols > 0) {
375 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
376 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
377 if ($cell_count == 2) echo " style='padding-left:10pt'";
379 $cell_count += $titlecols;
384 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
387 // Handle starting of a new data cell.
390 echo "<td valign='top' colspan='$datacols' class='text'";
391 if ($cell_count > 0) echo " style='padding-left:5pt'";
393 $cell_count += $datacols;
398 if ($frow['edit_options'] == 'H')
399 echo generate_display_field($frow, $currvalue);
401 generate_form_field($frow, $currvalue);
407 *********************************************************************/