PHP7 Project. Commit 20. Fixes in calendar module.
[openemr.git] / interface / super / layout_listitems_ajax.php
blob41f0f9d51e688fb6d87be4f31825b87b06e85119
1 <?php
2 /**
3 * Copyright (C) 2014 Rod Roark <rod@sunsetsystems.com>
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
16 * @package OpenEMR
17 * @author Rod Roark <rod@sunsetsystems.com>
18 * @link http://www.open-emr.org
21 // Given a list ID, name of a target form field and a default value, this creates
22 // JavaScript that will write Option values into the target selection list.
24 $fake_register_globals = false;
25 $sanitize_all_escapes = true;
27 require_once("../globals.php");
28 require_once("$srcdir/formdata.inc.php");
30 $listid = $_GET['listid'];
31 $target = $_GET['target'];
32 $current = $_GET['current'];
34 $res = sqlStatement("SELECT option_id FROM list_options WHERE list_id = ? " .
35 "ORDER BY seq, option_id", array($listid));
37 echo "var itemsel = document.forms[0]['$target'];\n";
38 echo "var j = 0;\n";
39 echo "itemsel.options[j++] = new Option('-- " . xls('Please Select') . " --','',false,false);\n";
40 while ($row = sqlFetchArray($res)) {
41 $tmp = addslashes($row['option_id']);
42 $def = $row['option_id'] == $current ? 'true' : 'false';
43 echo "itemsel.options[j++] = new Option('$tmp','$tmp',$def,$def);\n";