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_id, 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 // Load array of properties for this layout and its groups.
91 getLayoutProperties('GCA', $grparr);
93 $fres = sqlStatement("SELECT * FROM layout_options " .
94 "WHERE form_id = 'GCA' AND uor > 0 " .
95 "ORDER BY group_id, seq");
99 $display_style = 'block';
101 while ($frow = sqlFetchArray($fres)) {
102 $this_group = $frow['group_id'];
103 $titlecols = $frow['titlecols'];
104 $datacols = $frow['datacols'];
105 $data_type = $frow['data_type'];
106 $field_id = $frow['field_id'];
107 $list_id = $frow['list_id'];
111 if ($frow['edit_options'] == 'H') {
112 // This data comes from static history
113 if (isset($shrow[$field_id])) {
114 $currvalue = $shrow[$field_id];
117 if (isset($pprow[$field_id])) {
118 $currvalue = $pprow[$field_id];
122 // Handle a data category (group) change.
123 if (strcmp($this_group, $last_group) != 0) {
125 $group_seq = 'gca' . substr($this_group, 0, 1);
126 $group_name = $grparr[$this_group]['grp_title'];
127 $last_group = $this_group;
128 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
129 "onclick='return divclick(this,\"div_$group_seq\");'";
130 if ($display_style == 'block') {
134 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
135 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
136 echo " <table border='0' cellpadding='0' width='100%'>\n";
137 $display_style = 'none';
140 // Handle starting of a new row.
141 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
146 if ($item_count == 0 && $titlecols == 0) {
150 // Handle starting of a new label cell.
151 if ($titlecols > 0) {
153 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
154 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
155 if ($cell_count == 2) {
156 echo " style='padding-left:10pt'";
160 $cell_count +
= $titlecols;
166 if ($frow['title']) {
167 echo (xl_layout_label($frow['title']) . ":");
174 // Handle starting of a new data cell.
177 echo "<td valign='top' colspan='$datacols' class='text'";
178 if ($cell_count > 0) {
179 echo " style='padding-left:5pt'";
183 $cell_count +
= $datacols;
188 if ($frow['edit_options'] == 'H') {
189 echo generate_display_field($frow, $currvalue);
191 generate_form_field($frow, $currvalue);
199 function issue_ippf_con_newtype()
201 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
202 echo " document.getElementById('ippf_con').style.display = condisp;\n";
205 function issue_ippf_con_save($issue)
207 $sets = "id = '" . add_escape_custom($issue) . "'";
208 $fres = sqlStatement("SELECT * FROM layout_options " .
209 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
210 "ORDER BY group_id, seq");
211 while ($frow = sqlFetchArray($fres)) {
212 $field_id = $frow['field_id'];
213 $value = get_layout_form_value($frow);
214 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
217 // This replaces the row if its id exists, otherwise inserts it.
218 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
221 function issue_ippf_con_form($issue, $thispid)
223 global $pprow, $item_count, $cell_count, $last_group;
225 $shrow = getHistoryData($thispid);
228 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
233 echo "<div id='ippf_con' style='display:none'>\n";
235 // Load array of properties for this layout and its groups.
237 getLayoutProperties('CON', $grparr);
239 $fres = sqlStatement("SELECT * FROM layout_options " .
240 "WHERE form_id = 'CON' AND uor > 0 " .
241 "ORDER BY group_id, seq");
245 $display_style = 'block';
247 while ($frow = sqlFetchArray($fres)) {
248 $this_group = $frow['group_id'];
249 $titlecols = $frow['titlecols'];
250 $datacols = $frow['datacols'];
251 $data_type = $frow['data_type'];
252 $field_id = $frow['field_id'];
253 $list_id = $frow['list_id'];
257 if ($frow['edit_options'] == 'H') {
258 // This data comes from static history
259 if (isset($shrow[$field_id])) {
260 $currvalue = $shrow[$field_id];
263 if (isset($pprow[$field_id])) {
264 $currvalue = $pprow[$field_id];
268 // Handle a data category (group) change.
269 if (strcmp($this_group, $last_group) != 0) {
271 $group_seq = 'con' . substr($this_group, 0, 1);
272 $group_name = $grparr[$this_group]['grp_title'];
273 $last_group = $this_group;
274 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
275 "onclick='return divclick(this,\"div_$group_seq\");'";
276 if ($display_style == 'block') {
280 echo " /><b>$group_name</b></span>\n";
281 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
282 echo " <table border='0' cellpadding='0' width='100%'>\n";
283 $display_style = 'none';
286 // Handle starting of a new row.
287 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
292 if ($item_count == 0 && $titlecols == 0) {
296 // Handle starting of a new label cell.
297 if ($titlecols > 0) {
299 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
300 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
301 if ($cell_count == 2) {
302 echo " style='padding-left:10pt'";
306 $cell_count +
= $titlecols;
312 if ($frow['title']) {
313 echo $frow['title'] . ":";
320 // Handle starting of a new data cell.
323 echo "<td valign='top' colspan='$datacols' class='text'";
324 if ($cell_count > 0) {
325 echo " style='padding-left:5pt'";
329 $cell_count +
= $datacols;
334 if ($frow['edit_options'] == 'H') {
335 echo generate_display_field($frow, $currvalue);
337 generate_form_field($frow, $currvalue);
345 /*********************************************************************
347 function issue_ippf_srh_newtype() {
348 echo " var srhdisp = (aitypes[index] == 5) ? '' : 'none';\n";
349 echo " document.getElementById('ippf_srh').style.display = srhdisp;\n";
352 function issue_ippf_srh_save($issue) {
353 $sets = "id = '" add_escape_custom($issue) . "'";
354 $fres = sqlStatement("SELECT * FROM layout_options " .
355 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND edit_options != 'H' " .
356 "ORDER BY group_name, seq");
357 while ($frow = sqlFetchArray($fres)) {
358 $field_id = $frow['field_id'];
359 $value = get_layout_form_value($frow);
360 $sets .= ", $field_id = '" . add_escape_custom($value) . "'";
362 // This replaces the row if its id exists, otherwise inserts it.
363 sqlStatement("REPLACE INTO lists_ippf_srh SET $sets");
366 function issue_ippf_srh_form($issue, $thispid) {
367 global $pprow, $item_count, $cell_count, $last_group;
369 $shrow = getHistoryData($thispid);
372 $pprow = sqlQuery("SELECT * FROM lists_ippf_srh WHERE id = '$issue'");
377 echo "<div id='ippf_srh' style='display:none'>\n";
379 $fres = sqlStatement("SELECT * FROM layout_options " .
380 "WHERE form_id = 'SRH' AND uor > 0 " .
381 "ORDER BY group_name, seq");
385 $display_style = 'block';
387 while ($frow = sqlFetchArray($fres)) {
388 $this_group = $frow['group_name'];
389 $titlecols = $frow['titlecols'];
390 $datacols = $frow['datacols'];
391 $data_type = $frow['data_type'];
392 $field_id = $frow['field_id'];
393 $list_id = $frow['list_id'];
397 if ($frow['edit_options'] == 'H') {
398 // This data comes from static history
399 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
401 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
404 // Handle a data category (group) change.
405 if (strcmp($this_group, $last_group) != 0) {
407 $group_seq = 'srh' . substr($this_group, 0, 1);
408 $group_name = substr($this_group, 1);
409 $last_group = $this_group;
410 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
411 "onclick='return divclick(this,\"div_$group_seq\");'";
412 if ($display_style == 'block') echo " checked";
413 echo " /><b>$group_name</b></span>\n";
414 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
415 echo " <table border='0' cellpadding='0' width='100%'>\n";
416 $display_style = 'none';
419 // Handle starting of a new row.
420 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
425 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
427 // Handle starting of a new label cell.
428 if ($titlecols > 0) {
430 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
431 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
432 if ($cell_count == 2) echo " style='padding-left:10pt'";
434 $cell_count += $titlecols;
439 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
442 // Handle starting of a new data cell.
445 echo "<td valign='top' colspan='$datacols' class='text'";
446 if ($cell_count > 0) echo " style='padding-left:5pt'";
448 $cell_count += $datacols;
453 if ($frow['edit_options'] == 'H')
454 echo generate_display_field($frow, $currvalue);
456 generate_form_field($frow, $currvalue);
462 *********************************************************************/