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....");
85 $enrow = sqlQuery("SELECT p.fname, p.mname, p.lname, fe.date FROM " .
86 "form_encounter AS fe, forms AS f, patient_data AS p WHERE " .
87 "p.pid = '$pid' AND f.pid = '$pid' AND f.encounter = '$encounter' AND " .
88 "f.formdir = 'newpatient' AND f.deleted = 0 AND " .
89 "fe.id = f.form_id LIMIT 1");
92 $pprow = sqlQuery("SELECT * FROM form_ippf_srh WHERE " .
93 "id = '$formid' AND activity = '1'");
98 <?php
html_header_show();?
>
99 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
102 td
, input
, select
, textarea
{
103 font
-family
: Arial
, Helvetica
, sans
-serif
;
110 border
-color
: #0000ff;
117 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
119 <script language
="JavaScript">
121 // Supports customizable forms (currently just for IPPF).
122 function divclick(cb
, divid
) {
123 var divstyle
= document
.getElementById(divid
).style
;
125 divstyle
.display
= 'block';
127 divstyle
.display
= 'none';
135 <body
<?php
echo $top_bg_line; ?
> topmargin
="0" rightmargin
="0" leftmargin
="2" bottommargin
="0" marginwidth
="2" marginheight
="0">
136 <form method
="post" action
="<?php echo $rootdir ?>/forms/ippf_srh/new.php?id=<?php echo $formid ?>"
137 onsubmit
="return top.restoreSession()">
139 <p
class='title' style
='margin-top:8px;margin-bottom:8px;text-align:center'>
141 echo xl('IPPF SRH Data for') . ' ';
142 echo $enrow['fname'] . ' ' . $enrow['mname'] . ' ' . $enrow['lname'];
143 echo ' ' . xl('on') . ' ' . substr($enrow['date'], 0, 10);
148 $shrow = getHistoryData($pid);
150 // echo "<div id='ippf_srh' style='display:none'>\n";
152 $fres = sqlStatement("SELECT * FROM layout_options " .
153 "WHERE form_id = 'SRH' AND uor > 0 " .
154 "ORDER BY group_name, seq");
158 $display_style = 'block';
160 while ($frow = sqlFetchArray($fres)) {
161 $this_group = $frow['group_name'];
162 $titlecols = $frow['titlecols'];
163 $datacols = $frow['datacols'];
164 $data_type = $frow['data_type'];
165 $field_id = $frow['field_id'];
166 $list_id = $frow['list_id'];
170 if ($frow['edit_options'] == 'H') {
171 // This data comes from static history
172 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
174 if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id];
177 // Handle a data category (group) change.
178 if (strcmp($this_group, $last_group) != 0) {
180 $group_seq = 'srh' . substr($this_group, 0, 1);
181 $group_name = substr($this_group, 1);
182 $last_group = $this_group;
183 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
184 "onclick='return divclick(this,\"div_$group_seq\");'";
185 if ($display_style == 'block') echo " checked";
186 echo " /><b>$group_name</b></span>\n";
187 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
188 echo " <table border='0' cellpadding='0' width='100%'>\n";
189 $display_style = 'none';
192 // Handle starting of a new row.
193 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
198 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
200 // Handle starting of a new label cell.
201 if ($titlecols > 0) {
203 echo "<td valign='top' colspan='$titlecols' width='1%' nowrap";
204 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
205 if ($cell_count == 2) echo " style='padding-left:10pt'";
207 $cell_count +
= $titlecols;
212 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
215 // Handle starting of a new data cell.
218 echo "<td valign='top' colspan='$datacols' class='text'";
219 if ($cell_count > 0) echo " style='padding-left:5pt'";
221 $cell_count +
= $datacols;
226 if ($frow['edit_options'] == 'H')
227 echo generate_display_field($frow, $currvalue);
229 generate_form_field($frow, $currvalue);
236 <p style
='text-align:center'>
237 <input type
='submit' name
='bn_save' value
='Save' />
239 <input type
='button' value
='Cancel' onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
246 // TBD: If $alertmsg, display it with a JavaScript alert().