2 // Copyright (C) 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 require_once("../../globals.php");
10 require_once("$srcdir/api.inc");
11 require_once("$srcdir/forms.inc");
12 require_once("$srcdir/options.inc.php");
13 require_once("$srcdir/patient.inc");
15 $CPR = 4; // cells per row
19 if (! $encounter) { // comes from globals.php
20 die("Internal error: we do not seem to be in an encounter!");
24 global $item_count, $cell_count;
25 if ($item_count > 0) {
32 global $cell_count, $CPR;
34 if ($cell_count > 0) {
35 for (; $cell_count < $CPR; ++
$cell_count) echo "<td></td>";
41 function end_group() {
43 if (strlen($last_group) > 0) {
50 $formid = $_GET['id'];
52 // If Save was clicked, save the info.
54 if ($_POST['bn_save']) {
56 $fres = sqlStatement("SELECT * FROM layout_options " .
57 "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND " .
58 "edit_options != 'H' " .
59 "ORDER BY group_name, seq");
60 while ($frow = sqlFetchArray($fres)) {
61 $field_id = $frow['field_id'];
62 $value = get_layout_form_value($frow);
63 if ($sets) $sets .= ", ";
64 $sets .= "$field_id = '$value'";
68 // Updating an existing form.
69 $query = "UPDATE form_ippf_srh SET $sets WHERE id = '$formid'";
74 $query = "INSERT INTO form_ippf_srh SET $sets";
75 $newid = sqlInsert($query);
76 addForm($encounter, "IPPF SRH Data", $newid, "ippf_srh", $pid, $userauthorized);
79 formHeader("Redirecting....");
86 $pprow = sqlQuery ("SELECT * FROM form_ippf_srh WHERE " .
87 "id = '$formid' AND activity = '1'") ;
92 <?php
html_header_show();?
>
93 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
96 td
, input
, select
, textarea
{
97 font
-family
: Arial
, Helvetica
, sans
-serif
;
104 border
-color
: #0000ff;
111 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
113 <script language
="JavaScript">
115 // Supports customizable forms (currently just for IPPF).
116 function divclick(cb
, divid
) {
117 var divstyle
= document
.getElementById(divid
).style
;
119 divstyle
.display
= 'block';
121 divstyle
.display
= 'none';
129 <body
<?php
echo $top_bg_line; ?
> topmargin
="0" rightmargin
="0" leftmargin
="2" bottommargin
="0" marginwidth
="2" marginheight
="0">
130 <form method
="post" action
="<?php echo $rootdir ?>/forms/ippf_srh/new.php?id=<?php echo $formid ?>"
131 onsubmit
="return top.restoreSession()">
133 <p
class='title' style
='margin-top:8px;margin-bottom:8px;text-align:center'>IPPF SRH Data
</p
>
136 $shrow = getHistoryData($pid);
138 // echo "<div id='ippf_srh' style='display:none'>\n";
140 $fres = sqlStatement("SELECT * FROM layout_options " .
141 "WHERE form_id = 'SRH' AND uor > 0 " .
142 "ORDER BY group_name, seq");
146 $display_style = 'block';
148 while ($frow = sqlFetchArray($fres)) {
149 $this_group = $frow['group_name'];
150 $titlecols = $frow['titlecols'];
151 $datacols = $frow['datacols'];
152 $data_type = $frow['data_type'];
153 $field_id = $frow['field_id'];
154 $list_id = $frow['list_id'];
158 if ($frow['edit_options'] == 'H') {
159 // This data comes from static history
160 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
162 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
165 // Handle a data category (group) change.
166 if (strcmp($this_group, $last_group) != 0) {
168 $group_seq = 'srh' . substr($this_group, 0, 1);
169 $group_name = substr($this_group, 1);
170 $last_group = $this_group;
171 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
172 "onclick='return divclick(this,\"div_$group_seq\");'";
173 if ($display_style == 'block') echo " checked";
174 echo " /><b>$group_name</b></span>\n";
175 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
176 echo " <table border='0' cellpadding='0' width='100%'>\n";
177 $display_style = 'none';
180 // Handle starting of a new row.
181 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
186 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
188 // Handle starting of a new label cell.
189 if ($titlecols > 0) {
191 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
192 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
193 if ($cell_count == 2) echo " style='padding-left:10pt'";
195 $cell_count +
= $titlecols;
200 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
203 // Handle starting of a new data cell.
206 echo "<td valign='top' colspan='$datacols' class='text'";
207 if ($cell_count > 0) echo " style='padding-left:5pt'";
209 $cell_count +
= $datacols;
214 if ($frow['edit_options'] == 'H')
215 echo generate_display_field($frow, $currvalue);
217 generate_form_field($frow, $currvalue);
224 <p style
='text-align:center'>
225 <input type
='submit' name
='bn_save' value
='Save' />
227 <input type
='button' value
='Cancel' onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
234 // TBD: If $alertmsg, display it with a JavaScript alert().