Highway to PSR2
[openemr.git] / sites / default / LBF / LBTref.plugin.php
blob6cdeacc050ac491e7c7f15c3f5318f7cafe640b5
1 <?php
2 // Copyright (C) 2009, 2015 Rod Roark <rod@sunsetsystems.com>
3 //
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 provides enhancement functions for the referral (REF) form.
10 // It is invoked by interface/patient_file/transaction/add_transaction.php.
12 // The purpose of this function is to create JavaScript for the <head>
13 // section of the page. This in turn defines desired javaScript
14 // functions.
16 function LBTref_javascript()
18 // This JavaScript function is to reload the "Refer To" options when
19 // the "External Referral" selection changes.
20 echo "// onChange handler for form_refer_external.
21 var poptions = new Array();
22 function external_changed() {
23 var f = document.forms[0];
24 var eix = f.form_refer_external.selectedIndex;
25 var psel = f.form_refer_to;
26 var i = psel.selectedIndex < 0 ? 0 : psel.selectedIndex;
27 var pvalue = psel.options[i].value;
28 if (poptions.length == 0) {
29 for (i = 0; i < psel.options.length; ++i) {
30 poptions[i] = psel.options[i];
33 psel.options.length = 1;
34 var selindex = 0;
35 for (i = 1; i < poptions.length; ++i) {
36 var local = poptions[i].title == 'Local';
37 if (eix == 1 && !local) continue;
38 if (eix == 2 && local) continue;
39 if (poptions[i].value == pvalue) selindex = psel.options.length;
40 psel.options[psel.options.length] = poptions[i];
42 psel.selectedIndex = selindex;
47 // The purpose of this function is to create JavaScript that is run
48 // once when the page is loaded.
50 function LBTref_javascript_onload()
52 echo "
53 external_changed();
54 var f = document.forms[0];
55 f.form_refer_external.onchange = function () { external_changed(); };