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 to add support
10 // for issue types that are specific to IPPF.
12 require_once("$srcdir/options.inc.php");
14 $CPR = 4; // cells per row
19 global $item_count, $cell_count;
20 if ($item_count > 0) {
27 global $cell_count, $CPR;
29 if ($cell_count > 0) {
30 for (; $cell_count < $CPR; ++
$cell_count) echo "<td></td>";
36 function end_group() {
38 if (strlen($last_group) > 0) {
45 function issue_ippf_gcac_newtype() {
46 echo " var gcadisp = (aitypes[index] == 3) ? '' : 'none';\n";
47 echo " document.getElementById('ippf_gcac').style.display = gcadisp;\n";
50 function issue_ippf_gcac_save($issue) {
51 $sets = "id = '$issue'";
52 $fres = sqlStatement("SELECT * FROM layout_options " .
53 "WHERE form_id = 'GCA' AND uor > 0 AND field_id != '' " .
54 "ORDER BY group_name, seq");
55 while ($frow = sqlFetchArray($fres)) {
56 $field_id = $frow['field_id'];
57 $value = get_layout_form_value($frow);
58 $sets .= ", $field_id = '$value'";
60 // This replaces the row if its id exists, otherwise inserts it.
61 sqlStatement("REPLACE INTO lists_ippf_gcac SET $sets");
64 function issue_ippf_gcac_form($issue) {
65 global $pprow, $item_count, $cell_count, $last_group;
68 $pprow = sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = '$issue'");
73 echo "<div id='ippf_gcac' style='display:none'>\n";
75 $fres = sqlStatement("SELECT * FROM layout_options " .
76 "WHERE form_id = 'GCA' AND uor > 0 " .
77 "ORDER BY group_name, seq");
81 $display_style = 'block';
83 while ($frow = sqlFetchArray($fres)) {
84 $this_group = $frow['group_name'];
85 $titlecols = $frow['titlecols'];
86 $datacols = $frow['datacols'];
87 $data_type = $frow['data_type'];
88 $field_id = $frow['field_id'];
89 $list_id = $frow['list_id'];
92 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
94 // Handle a data category (group) change.
95 if (strcmp($this_group, $last_group) != 0) {
97 $group_seq = 'gca' . substr($this_group, 0, 1);
98 $group_name = substr($this_group, 1);
99 $last_group = $this_group;
100 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
101 "onclick='return divclick(this,\"div_$group_seq\");'";
102 if ($display_style == 'block') echo " checked";
103 echo " /><b>$group_name</b></span>\n";
104 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
105 echo " <table border='0' cellpadding='0' width='100%'>\n";
106 $display_style = 'none';
109 // Handle starting of a new row.
110 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
115 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
117 // Handle starting of a new label cell.
118 if ($titlecols > 0) {
120 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
121 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
122 if ($cell_count == 2) echo " style='padding-left:10pt'";
124 $cell_count +
= $titlecols;
129 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
132 // Handle starting of a new data cell.
135 echo "<td valign='top' colspan='$datacols' class='text'";
136 if ($cell_count > 0) echo " style='padding-left:5pt'";
138 $cell_count +
= $datacols;
142 generate_form_field($frow, $currvalue);
149 function issue_ippf_con_newtype() {
150 echo " var condisp = (aitypes[index] == 4) ? '' : 'none';\n";
151 echo " document.getElementById('ippf_con').style.display = condisp;\n";
154 function issue_ippf_con_save($issue) {
155 $sets = "id = '$issue'";
156 $fres = sqlStatement("SELECT * FROM layout_options " .
157 "WHERE form_id = 'CON' AND uor > 0 AND field_id != '' " .
158 "ORDER BY group_name, seq");
159 while ($frow = sqlFetchArray($fres)) {
160 $field_id = $frow['field_id'];
161 $value = get_layout_form_value($frow);
162 $sets .= ", $field_id = '$value'";
164 // This replaces the row if its id exists, otherwise inserts it.
165 sqlStatement("REPLACE INTO lists_ippf_con SET $sets");
168 function issue_ippf_con_form($issue) {
169 global $pprow, $item_count, $cell_count, $last_group;
172 $pprow = sqlQuery("SELECT * FROM lists_ippf_con WHERE id = '$issue'");
177 echo "<div id='ippf_con' style='display:none'>\n";
179 $fres = sqlStatement("SELECT * FROM layout_options " .
180 "WHERE form_id = 'CON' AND uor > 0 " .
181 "ORDER BY group_name, seq");
185 $display_style = 'block';
187 while ($frow = sqlFetchArray($fres)) {
188 $this_group = $frow['group_name'];
189 $titlecols = $frow['titlecols'];
190 $datacols = $frow['datacols'];
191 $data_type = $frow['data_type'];
192 $field_id = $frow['field_id'];
193 $list_id = $frow['list_id'];
196 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
198 // Handle a data category (group) change.
199 if (strcmp($this_group, $last_group) != 0) {
201 $group_seq = 'con' . substr($this_group, 0, 1);
202 $group_name = substr($this_group, 1);
203 $last_group = $this_group;
204 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
205 "onclick='return divclick(this,\"div_$group_seq\");'";
206 if ($display_style == 'block') echo " checked";
207 echo " /><b>$group_name</b></span>\n";
208 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
209 echo " <table border='0' cellpadding='0' width='100%'>\n";
210 $display_style = 'none';
213 // Handle starting of a new row.
214 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
219 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
221 // Handle starting of a new label cell.
222 if ($titlecols > 0) {
224 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
225 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
226 if ($cell_count == 2) echo " style='padding-left:10pt'";
228 $cell_count +
= $titlecols;
233 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
236 // Handle starting of a new data cell.
239 echo "<td valign='top' colspan='$datacols' class='text'";
240 if ($cell_count > 0) echo " style='padding-left:5pt'";
242 $cell_count +
= $datacols;
246 generate_form_field($frow, $currvalue);