2 // Copyright (C) 2008 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
20 global $item_count, $cell_count;
21 if ($item_count > 0) {
28 global $cell_count, $CPR;
30 if ($cell_count > 0) {
31 for (; $cell_count < $CPR; ++
$cell_count) echo "<td></td>";
37 function end_group() {
39 if (strlen($last_group) > 0) {
46 function issue_ippf_gcac_newtype() {
47 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
48 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
51 function issue_ippf_gcac_save($issue) {
52 $sets = "id = '$issue'";
53 $fres = sqlStatement("SELECT * FROM layout_options " .
54 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
55 "ORDER BY group_name, seq");
56 while ($frow = sqlFetchArray($fres)) {
57 $field_id = $frow['field_id'];
58 $value = get_layout_form_value($frow);
59 $sets .= ", $field_id = '$value'";
61 // This replaces the row if its id exists, otherwise inserts it.
62 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
65 function issue_ippf_gcac_form($issue, $thispid) {
66 global $pprow, $item_count, $cell_count, $last_group;
68 $shrow = getHistoryData($thispid);
71 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
76 echo "<div id='ippf_gcac' style='display:none'>\n";
78 $fres = sqlStatement("SELECT * FROM layout_options " .
79 "WHERE form_id = 'GCA' AND uor > 0 " .
80 "ORDER BY group_name, seq");
84 $display_style = 'block';
86 while ($frow = sqlFetchArray($fres)) {
87 $this_group = $frow['group_name'];
88 $titlecols = $frow['titlecols'];
89 $datacols = $frow['datacols'];
90 $data_type = $frow['data_type'];
91 $field_id = $frow['field_id'];
92 $list_id = $frow['list_id'];
96 if ($frow['edit_options'] == 'H') {
97 // This data comes from static history
98 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
100 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
103 // Handle a data category (group) change.
104 if (strcmp($this_group, $last_group) != 0) {
106 $group_seq = 'gca' . substr($this_group, 0, 1);
107 $group_name = substr($this_group, 1);
108 $last_group = $this_group;
109 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
110 "onclick='return divclick(this,\"div_$group_seq\");'";
111 if ($display_style == 'block') echo " checked";
112 echo " /><b>$group_name</b></span>\n";
113 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
114 echo " <table border='0' cellpadding='0' width='100%'>\n";
115 $display_style = 'none';
118 // Handle starting of a new row.
119 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
124 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
126 // Handle starting of a new label cell.
127 if ($titlecols > 0) {
129 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
130 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
131 if ($cell_count == 2) echo " style='padding-left:10pt'";
133 $cell_count +
= $titlecols;
138 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
141 // Handle starting of a new data cell.
144 echo "<td valign='top' colspan='$datacols' class='text'";
145 if ($cell_count > 0) echo " style='padding-left:5pt'";
147 $cell_count +
= $datacols;
152 if ($frow['edit_options'] == 'H')
153 echo generate_display_field($frow, $currvalue);
155 generate_form_field($frow, $currvalue);
162 function issue_ippf_con_newtype() {
163 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
164 echo " document.getElementById('ippf_con').style.display = condisp;\n";
167 function issue_ippf_con_save($issue) {
168 $sets = "id = '$issue'";
169 $fres = sqlStatement("SELECT * FROM layout_options " .
170 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
171 "ORDER BY group_name, seq");
172 while ($frow = sqlFetchArray($fres)) {
173 $field_id = $frow['field_id'];
174 $value = get_layout_form_value($frow);
175 $sets .= ", $field_id = '$value'";
177 // This replaces the row if its id exists, otherwise inserts it.
178 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
181 function issue_ippf_con_form($issue, $thispid) {
182 global $pprow, $item_count, $cell_count, $last_group;
184 $shrow = getHistoryData($thispid);
187 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
192 echo "<div id='ippf_con' style='display:none'>\n";
194 $fres = sqlStatement("SELECT * FROM layout_options " .
195 "WHERE form_id = 'CON' AND uor > 0 " .
196 "ORDER BY group_name, seq");
200 $display_style = 'block';
202 while ($frow = sqlFetchArray($fres)) {
203 $this_group = $frow['group_name'];
204 $titlecols = $frow['titlecols'];
205 $datacols = $frow['datacols'];
206 $data_type = $frow['data_type'];
207 $field_id = $frow['field_id'];
208 $list_id = $frow['list_id'];
212 if ($frow['edit_options'] == 'H') {
213 // This data comes from static history
214 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
216 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
219 // Handle a data category (group) change.
220 if (strcmp($this_group, $last_group) != 0) {
222 $group_seq = 'con' . substr($this_group, 0, 1);
223 $group_name = substr($this_group, 1);
224 $last_group = $this_group;
225 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
226 "onclick='return divclick(this,\"div_$group_seq\");'";
227 if ($display_style == 'block') echo " checked";
228 echo " /><b>$group_name</b></span>\n";
229 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
230 echo " <table border='0' cellpadding='0' width='100%'>\n";
231 $display_style = 'none';
234 // Handle starting of a new row.
235 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
240 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
242 // Handle starting of a new label cell.
243 if ($titlecols > 0) {
245 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
246 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
247 if ($cell_count == 2) echo " style='padding-left:10pt'";
249 $cell_count +
= $titlecols;
254 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
257 // Handle starting of a new data cell.
260 echo "<td valign='top' colspan='$datacols' class='text'";
261 if ($cell_count > 0) echo " style='padding-left:5pt'";
263 $cell_count +
= $datacols;
268 if ($frow['edit_options'] == 'H')
269 echo generate_display_field($frow, $currvalue);
271 generate_form_field($frow, $currvalue);
278 /*********************************************************************
280 function issue_ippf_srh_newtype() {
281 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
282 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
285 function issue_ippf_srh_save($issue) {
286 $sets = "id = '$issue'";
287 $fres = sqlStatement("SELECT * FROM layout_options " .
288 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
289 "ORDER BY group_name, seq");
290 while ($frow = sqlFetchArray($fres)) {
291 $field_id = $frow['field_id'];
292 $value = get_layout_form_value($frow);
293 $sets .= ", $field_id = '$value'";
295 // This replaces the row if its id exists, otherwise inserts it.
296 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
299 function issue_ippf_srh_form($issue, $thispid) {
300 global $pprow, $item_count, $cell_count, $last_group;
302 $shrow = getHistoryData($thispid);
305 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
310 echo "<div id='ippf_srh' style='display:none'>\n";
312 $fres = sqlStatement("SELECT * FROM layout_options " .
313 "WHERE form_id = 'SRH' AND uor > 0 " .
314 "ORDER BY group_name, seq");
318 $display_style = 'block';
320 while ($frow = sqlFetchArray($fres)) {
321 $this_group = $frow['group_name'];
322 $titlecols = $frow['titlecols'];
323 $datacols = $frow['datacols'];
324 $data_type = $frow['data_type'];
325 $field_id = $frow['field_id'];
326 $list_id = $frow['list_id'];
330 if ($frow['edit_options'] == 'H') {
331 // This data comes from static history
332 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
334 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
337 // Handle a data category (group) change.
338 if (strcmp($this_group, $last_group) != 0) {
340 $group_seq = 'srh' . substr($this_group, 0, 1);
341 $group_name = substr($this_group, 1);
342 $last_group = $this_group;
343 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
344 "onclick='return divclick(this,\"div_$group_seq\");'";
345 if ($display_style == 'block') echo " checked";
346 echo " /><b>$group_name</b></span>\n";
347 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
348 echo " <table border='0' cellpadding='0' width='100%'>\n";
349 $display_style = 'none';
352 // Handle starting of a new row.
353 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
358 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
360 // Handle starting of a new label cell.
361 if ($titlecols > 0) {
363 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
364 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
365 if ($cell_count == 2) echo " style='padding-left:10pt'";
367 $cell_count += $titlecols;
372 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
375 // Handle starting of a new data cell.
378 echo "<td valign='top' colspan='$datacols' class='text'";
379 if ($cell_count > 0) echo " style='padding-left:5pt'";
381 $cell_count += $datacols;
386 if ($frow['edit_options'] == 'H')
387 echo generate_display_field($frow, $currvalue);
389 generate_form_field($frow, $currvalue);
395 *********************************************************************/