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;
46 if (strlen($last_group) > 0) {
53 function issue_ippf_gcac_newtype()
55 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
56 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
59 function issue_ippf_gcac_save($issue)
61 $sets = "id = '" . add_escape_custom($issue) . "'";
62 $fres = sqlStatement("SELECT * FROM layout_options " .
63 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
64 "ORDER BY group_name, seq");
65 while ($frow = sqlFetchArray($fres)) {
66 $field_id = $frow['field_id'];
67 $value = get_layout_form_value($frow);
68 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
71 // This replaces the row if its id exists, otherwise inserts it.
72 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
75 function issue_ippf_gcac_form($issue, $thispid)
77 global $pprow, $item_count, $cell_count, $last_group;
79 $shrow = getHistoryData($thispid);
82 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
87 echo "<div id='ippf_gcac' style='display:none'>\n";
89 $fres = sqlStatement("SELECT * FROM layout_options " .
90 "WHERE form_id = 'GCA' AND uor > 0 " .
91 "ORDER BY group_name, seq");
95 $display_style = 'block';
97 while ($frow = sqlFetchArray($fres)) {
98 $this_group = $frow['group_name'];
99 $titlecols = $frow['titlecols'];
100 $datacols = $frow['datacols'];
101 $data_type = $frow['data_type'];
102 $field_id = $frow['field_id'];
103 $list_id = $frow['list_id'];
107 if ($frow['edit_options'] == 'H') {
108 // This data comes from static history
109 if (isset($shrow[$field_id])) {
110 $currvalue = $shrow[$field_id];
113 if (isset($pprow[$field_id])) {
114 $currvalue = $pprow[$field_id];
118 // Handle a data category (group) change.
119 if (strcmp($this_group, $last_group) != 0) {
121 $group_seq = 'gca' . substr($this_group, 0, 1);
122 $group_name = substr($this_group, 1);
123 $last_group = $this_group;
124 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
125 "onclick='return divclick(this,\"div_$group_seq\");'";
126 if ($display_style == 'block') {
130 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
131 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
132 echo " <table border='0' cellpadding='0' width='100%'>\n";
133 $display_style = 'none';
136 // Handle starting of a new row.
137 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
142 if ($item_count == 0 && $titlecols == 0) {
146 // Handle starting of a new label cell.
147 if ($titlecols > 0) {
149 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
150 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
151 if ($cell_count == 2) {
152 echo " style='padding-left:10pt'";
156 $cell_count +
= $titlecols;
162 if ($frow['title']) {
163 echo (xl_layout_label($frow['title']) . ":");
170 // Handle starting of a new data cell.
173 echo "<td valign='top' colspan='$datacols' class='text'";
174 if ($cell_count > 0) {
175 echo " style='padding-left:5pt'";
179 $cell_count +
= $datacols;
184 if ($frow['edit_options'] == 'H') {
185 echo generate_display_field($frow, $currvalue);
187 generate_form_field($frow, $currvalue);
195 function issue_ippf_con_newtype()
197 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
198 echo " document.getElementById('ippf_con').style.display = condisp;\n";
201 function issue_ippf_con_save($issue)
203 $sets = "id = '" . add_escape_custom($issue) . "'";
204 $fres = sqlStatement("SELECT * FROM layout_options " .
205 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
206 "ORDER BY group_name, seq");
207 while ($frow = sqlFetchArray($fres)) {
208 $field_id = $frow['field_id'];
209 $value = get_layout_form_value($frow);
210 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
213 // This replaces the row if its id exists, otherwise inserts it.
214 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
217 function issue_ippf_con_form($issue, $thispid)
219 global $pprow, $item_count, $cell_count, $last_group;
221 $shrow = getHistoryData($thispid);
224 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
229 echo "<div id='ippf_con' style='display:none'>\n";
231 $fres = sqlStatement("SELECT * FROM layout_options " .
232 "WHERE form_id = 'CON' AND uor > 0 " .
233 "ORDER BY group_name, seq");
237 $display_style = 'block';
239 while ($frow = sqlFetchArray($fres)) {
240 $this_group = $frow['group_name'];
241 $titlecols = $frow['titlecols'];
242 $datacols = $frow['datacols'];
243 $data_type = $frow['data_type'];
244 $field_id = $frow['field_id'];
245 $list_id = $frow['list_id'];
249 if ($frow['edit_options'] == 'H') {
250 // This data comes from static history
251 if (isset($shrow[$field_id])) {
252 $currvalue = $shrow[$field_id];
255 if (isset($pprow[$field_id])) {
256 $currvalue = $pprow[$field_id];
260 // Handle a data category (group) change.
261 if (strcmp($this_group, $last_group) != 0) {
263 $group_seq = 'con' . substr($this_group, 0, 1);
264 $group_name = substr($this_group, 1);
265 $last_group = $this_group;
266 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
267 "onclick='return divclick(this,\"div_$group_seq\");'";
268 if ($display_style == 'block') {
272 echo " /><b>$group_name</b></span>\n";
273 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
274 echo " <table border='0' cellpadding='0' width='100%'>\n";
275 $display_style = 'none';
278 // Handle starting of a new row.
279 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
284 if ($item_count == 0 && $titlecols == 0) {
288 // Handle starting of a new label cell.
289 if ($titlecols > 0) {
291 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
292 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
293 if ($cell_count == 2) {
294 echo " style='padding-left:10pt'";
298 $cell_count +
= $titlecols;
304 if ($frow['title']) {
305 echo $frow['title'] . ":";
312 // Handle starting of a new data cell.
315 echo "<td valign='top' colspan='$datacols' class='text'";
316 if ($cell_count > 0) {
317 echo " style='padding-left:5pt'";
321 $cell_count +
= $datacols;
326 if ($frow['edit_options'] == 'H') {
327 echo generate_display_field($frow, $currvalue);
329 generate_form_field($frow, $currvalue);
337 /*********************************************************************
339 function issue_ippf_srh_newtype() {
340 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
341 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
344 function issue_ippf_srh_save($issue) {
345 $sets = "id = '" add_escape_custom($issue) . "'";
346 $fres = sqlStatement("SELECT * FROM layout_options " .
347 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
348 "ORDER BY group_name, seq");
349 while ($frow = sqlFetchArray($fres)) {
350 $field_id = $frow['field_id'];
351 $value = get_layout_form_value($frow);
352 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
354 // This replaces the row if its id exists, otherwise inserts it.
355 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
358 function issue_ippf_srh_form($issue, $thispid) {
359 global $pprow, $item_count, $cell_count, $last_group;
361 $shrow = getHistoryData($thispid);
364 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
369 echo "<div id='ippf_srh' style='display:none'>\n";
371 $fres = sqlStatement("SELECT * FROM layout_options " .
372 "WHERE form_id = 'SRH' AND uor > 0 " .
373 "ORDER BY group_name, seq");
377 $display_style = 'block';
379 while ($frow = sqlFetchArray($fres)) {
380 $this_group = $frow['group_name'];
381 $titlecols = $frow['titlecols'];
382 $datacols = $frow['datacols'];
383 $data_type = $frow['data_type'];
384 $field_id = $frow['field_id'];
385 $list_id = $frow['list_id'];
389 if ($frow['edit_options'] == 'H') {
390 // This data comes from static history
391 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
393 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
396 // Handle a data category (group) change.
397 if (strcmp($this_group, $last_group) != 0) {
399 $group_seq = 'srh' . substr($this_group, 0, 1);
400 $group_name = substr($this_group, 1);
401 $last_group = $this_group;
402 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
403 "onclick='return divclick(this,\"div_$group_seq\");'";
404 if ($display_style == 'block') echo " checked";
405 echo " /><b>$group_name</b></span>\n";
406 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
407 echo " <table border='0' cellpadding='0' width='100%'>\n";
408 $display_style = 'none';
411 // Handle starting of a new row.
412 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
417 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
419 // Handle starting of a new label cell.
420 if ($titlecols > 0) {
422 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
423 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
424 if ($cell_count == 2) echo " style='padding-left:10pt'";
426 $cell_count += $titlecols;
431 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
434 // Handle starting of a new data cell.
437 echo "<td valign='top' colspan='$datacols' class='text'";
438 if ($cell_count > 0) echo " style='padding-left:5pt'";
440 $cell_count += $datacols;
445 if ($frow['edit_options'] == 'H')
446 echo generate_display_field($frow, $currvalue);
448 generate_form_field($frow, $currvalue);
454 *********************************************************************/