immun updates (#4145)
[openemr.git] / interface / super / layout_listitems_ajax.php
blob0a60f75d361e13b44fdc9bf24cebc15d2ca00608
1 <?php
3 /**
4 * Given a list ID, name of a target form field and a default value, this creates
5 * JavaScript that will write Option values into the target selection list.
7 * @package OpenEMR
8 * @link http://www.open-emr.org
9 * @author Rod Roark <rod@sunsetsystems.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2014-2016 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../globals.php");
18 use OpenEMR\Common\Csrf\CsrfUtils;
20 //verify csrf
21 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
22 CsrfUtils::csrfNotVerified();
25 $listid = $_GET['listid'];
26 $target = $_GET['target'];
27 $current = $_GET['current'];
29 $res = sqlStatement("SELECT option_id FROM list_options WHERE list_id = ? AND activity = 1 " .
30 "ORDER BY seq, option_id", array($listid));
32 echo "var itemsel = document.forms[0][" . js_escape($target) . "];\n";
33 echo "var j = 0;\n";
34 echo "itemsel.options[j++] = new Option(" . js_escape("-- " . xl('Please Select') . " --") . ",'',false,false);\n";
35 while ($row = sqlFetchArray($res)) {
36 $tmp = js_escape($row['option_id']);
37 $def = $row['option_id'] == $current ? 'true' : 'false';
38 echo "itemsel.options[j++] = new Option($tmp,$tmp,$def,$def);\n";