2 // add_transaction is a misnomer, as this script will now also edit
3 // existing transactions.
5 require_once("../../globals.php");
6 require_once("$srcdir/transactions.inc");
7 require_once("$srcdir/options.inc.php");
9 $transid = empty($_REQUEST['transid']) ?
0 : $_REQUEST['transid'] +
0;
10 $mode = empty($_POST['mode' ]) ?
'' : $_POST['mode' ];
11 $title = empty($_POST['title']) ?
'' : $_POST['title'];
17 "title='" . $_POST['title'] . "'" .
18 ", user = '" . $_SESSION['authUser'] . "'" .
19 ", groupname = '" . $_SESSION['authProvider'] . "'" .
20 ", authorized = '" . $userauthorized . "'" .
23 $fres = sqlStatement("SELECT * FROM layout_options " .
24 "WHERE form_id = 'REF' AND uor > 0 AND field_id != '' " .
25 "ORDER BY group_name, seq");
26 while ($frow = sqlFetchArray($fres)) {
27 $data_type = $frow['data_type'];
28 $field_id = $frow['field_id'];
29 $value = $_POST["form_$field_id"];
30 if ($field_id == 'body' && $title != 'Referral') {
31 $value = $_POST["body"];
33 $sets .= ", $field_id = '$value'";
37 sqlStatement("UPDATE transactions SET $sets WHERE id = '$transid'");
40 $sets .= ", pid = '$pid'";
41 $transid = sqlInsert("INSERT INTO transactions SET $sets");
44 if ($GLOBALS['concurrent_layout'])
45 $body_onload_code = "javascript:location.href='transactions.php';";
47 $body_onload_code = "javascript:parent.Transactions.location.href='transactions.php';";
51 'Referral' => xl('Referral'),
52 'Patient Request' => xl('Patient Request'),
53 'Physician Request' => xl('Physician Request'),
54 'Legal' => xl('Legal'),
55 'Billing' => xl('Billing'),
58 $CPR = 4; // cells per row
61 global $item_count, $cell_count;
62 if ($item_count > 0) {
69 global $cell_count, $CPR;
71 if ($cell_count > 0) {
72 for (; $cell_count < $CPR; ++
$cell_count) echo "<td></td>";
78 function end_group() {
80 if (strlen($last_group) > 0) {
87 // If we are editing a transaction, get its ID and data.
88 $trow = $transid ?
getTransById($transid) : array();
92 <?php
html_header_show(); ?
>
96 td
, input
, select
, textarea
{
97 font
-family
: Arial
, Helvetica
, sans
-serif
;
104 border
-color
: #0000ff;
111 <link rel
='stylesheet' href
="<?php echo $css_header;?>" type
="text/css">
113 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
114 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
115 <script type
="text/javascript" src
="../../../library/dynarch_calendar_en.js"></script
>
116 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
117 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
118 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
120 <script language
="JavaScript">
122 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
124 function titleChanged() {
125 var sel
= document
.forms
[0].title
;
126 var si
= (sel
.selectedIndex
< 0) ?
0 : sel
.selectedIndex
;
127 if (sel
.options
[si
].value
== 'Referral') {
128 document
.getElementById('otherdiv').style
.display
= 'none';
129 document
.getElementById('referdiv').style
.display
= 'block';
131 document
.getElementById('referdiv').style
.display
= 'none';
132 document
.getElementById('otherdiv').style
.display
= 'block';
137 function divclick(cb
, divid
) {
138 var divstyle
= document
.getElementById(divid
).style
;
140 divstyle
.display
= 'block';
142 divstyle
.display
= 'none';
147 // This is for callback by the find-code popup.
148 // Appends to or erases the current list of related codes.
149 function set_related(codetype
, code
, selector
, codedesc
) {
150 var frc
= document
.getElementById('form_related_code');
153 if (s
.length
> 0) s +
= ';';
154 s +
= codetype +
':' + code
;
161 // This invokes the find-code popup.
162 function sel_related() {
163 dlgopen('../encounter/find_code_popup.php', '_blank', 500, 400);
166 // Process click on Delete link.
167 function deleteme() {
168 dlgopen('../deleter.php?transaction=<?php echo $transid ?>', '_blank', 500, 450);
172 // Called by the deleteme.php window on a successful delete.
173 function imdeleted() {
174 top
.restoreSession();
175 location
.href
= 'transaction/transactions.php';
178 // Compute the length of a string without leading and trailing spaces.
179 function trimlen(s
) {
181 var j
= s
.length
- 1;
182 for (; i
<= j
&& s
.charAt(i
) == ' '; ++i
);
183 for (; i
<= j
&& s
.charAt(j
) == ' '; --j
);
188 // Validation logic for form submission.
189 function validate() {
190 var f
= document
.forms
[0];
192 var si
= (sel
.selectedIndex
< 0) ?
0 : sel
.selectedIndex
;
193 if (sel
.options
[si
].value
== 'Referral') {
194 <?php
generate_layout_validation('REF'); ?
>
202 <body
class="body_top" onload
="<?php echo $body_onload_code; ?>" >
204 <form name
='new_transaction' method
='post' action
='add_transaction.php?transid=<?php echo $transid ?>'>
205 <input type
='hidden' name
='mode' value
='add'>
207 <span
class='bold'><?php
xl('Transaction Type','e'); ?
>:</span
> 
;
208 <select name
='title' onchange
='titleChanged()'>
210 foreach ($trans_types as $key => $value) {
211 echo " <option value='$key'";
212 if ($key == $db_title) echo " selected";
213 echo ">$value</option>\n";
219 if ($transid && acl_check('admin', 'super')) {
220 echo " <a href='' onclick='return deleteme()'>" .
221 "<span class='more' style='color:red'>(" . xl('Delete') . ")</span></a>";
226 <div id
='otherdiv' style
='display:none'>
227 <span
class='bold'><?php
xl('Details','e'); ?
>:</span
><br
>
228 <textarea name
='body' rows
='6' cols
='40' wrap
='virtual'></textarea
>
233 <div id
='referdiv' style
='display:none'>
235 $fres = sqlStatement("SELECT * FROM layout_options " .
236 "WHERE form_id = 'REF' AND uor > 0 " .
237 "ORDER BY group_name, seq");
241 $display_style = 'block';
243 while ($frow = sqlFetchArray($fres)) {
244 $this_group = $frow['group_name'];
245 $titlecols = $frow['titlecols'];
246 $datacols = $frow['datacols'];
247 $data_type = $frow['data_type'];
248 $field_id = $frow['field_id'];
249 $list_id = $frow['list_id'];
252 if (isset($trow[$field_id])) $currvalue = $trow[$field_id];
254 // Handle special-case default values.
255 if (!$currvalue && !$transid) {
256 if ($field_id == 'refer_date') {
257 $currvalue = date('Y-m-d');
259 else if ($field_id == 'body') {
260 $tmp = sqlQuery("SELECT reason FROM form_encounter WHERE " .
261 "pid = '$pid' ORDER BY date DESC LIMIT 1");
262 if (!empty($tmp)) $currvalue = $tmp['reason'];
266 // Handle a data category (group) change.
267 if (strcmp($this_group, $last_group) != 0) {
269 $group_seq = substr($this_group, 0, 1);
270 $group_name = substr($this_group, 1);
271 $last_group = $this_group;
272 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " .
273 "onclick='return divclick(this,\"div_$group_seq\");'";
274 if ($display_style == 'block') echo " checked";
275 echo " /><b>$group_name</b></span>\n";
276 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
277 echo " <table border='0' cellpadding='0'>\n";
278 $display_style = 'none';
281 // Handle starting of a new row.
282 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
287 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
289 // Handle starting of a new label cell.
290 if ($titlecols > 0) {
292 echo "<td valign='top' colspan='$titlecols'";
293 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
294 if ($cell_count == 2) echo " style='padding-left:10pt'";
296 $cell_count +
= $titlecols;
301 if ($frow['title']) echo $frow['title'] . ":"; else echo " ";
304 // Handle starting of a new data cell.
307 echo "<td valign='top' colspan='$datacols' class='text'";
308 if ($cell_count > 0) echo " style='padding-left:5pt'";
310 $cell_count +
= $datacols;
314 generate_form_field($frow, $currvalue);
323 <a href
="javascript:document.new_transaction.submit();" class='link_submit'
324 onclick
='return validate()'>
325 [<?php
xl('Save Transaction','e'); ?
>]</a
>
330 <script language
="JavaScript">
331 <?php
echo $date_init; ?
>