migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / super / edit_globals.php
blob1555d8d82ee99bf3386514ac85234b11c6908c50
1 <?php
2 /**
3 * Script for the globals editor.
5 * Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
6 * Copyright (C) 2016 Brady Miller <brady@sparmy.com>
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Rod Roark <rod@sunsetsystems.com>
21 * @author Brady Miller <brady@sparmy.com>
22 * @link http://www.open-emr.org
25 $fake_register_globals=false;
26 $sanitize_all_escapes=true;
28 require_once("../globals.php");
29 require_once("../../custom/code_types.inc.php");
30 require_once("$srcdir/acl.inc");
31 require_once("$srcdir/globals.inc.php");
32 require_once("$srcdir/user.inc");
33 require_once("$srcdir/classes/CouchDB.class.php");
34 require_once(dirname(__FILE__)."/../../myportal/soap_service/portal_connectivity.php");
36 $userMode = (array_key_exists('mode', $_GET) && $_GET['mode'] == 'user');
38 if (!$userMode) {
39 // Check authorization.
40 $thisauth = acl_check('admin', 'super');
41 if (!$thisauth) die(xlt('Not authorized'));
44 function checkCreateCDB(){
45 $globalsres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
46 ('couchdb_host','couchdb_user','couchdb_pass','couchdb_port','couchdb_dbase','document_storage_method')");
47 $options = array();
48 while($globalsrow = sqlFetchArray($globalsres)){
49 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
51 $directory_created = false;
52 if( !empty($GLOBALS['document_storage_method']) ) {
53 // /documents/temp/ folder is required for CouchDB
54 if(!is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/')){
55 $directory_created = mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/',0777,true);
56 if(!$directory_created){
57 echo htmlspecialchars( xl("Failed to create temporary folder. CouchDB will not work."),ENT_NOQUOTES);
60 $couch = new CouchDB();
61 if(!$couch->check_connection()) {
62 echo "<script type='text/javascript'>alert('".addslashes(xl("CouchDB Connection Failed."))."');</script>";
63 return;
65 if($GLOBALS['couchdb_host'] || $GLOBALS['couchdb_port'] || $GLOBALS['couchdb_dbase']){
66 $couch->createDB($GLOBALS['couchdb_dbase']);
67 $couch->createView($GLOBALS['couchdb_dbase']);
70 return true;
73 /**
74 * Update background_services table for a specific service following globals save.
75 * @author EMR Direct
77 function updateBackgroundService($name,$active,$interval) {
78 //order important here: next_run change dependent on _old_ value of execute_interval so it comes first
79 $sql = 'UPDATE background_services SET active=?, '
80 . 'next_run = next_run + INTERVAL (? - execute_interval) MINUTE, execute_interval=? WHERE name=?';
81 return sqlStatement($sql,array($active,$interval,$interval,$name));
84 /**
85 * Make any necessary changes to background_services table when globals are saved.
86 * To prevent an unexpected service call during startup or shutdown, follow these rules:
87 * 1. Any "startup" operations should occur _before_ the updateBackgroundService() call.
88 * 2. Any "shutdown" operations should occur _after_ the updateBackgroundService() call. If these operations
89 * would cause errors in a running service call, it would be best to make the shutdown function itself
90 * a background service that is activated here, does nothing if active=1 or running=1 for the
91 * parent service, then deactivates itself by setting active=0 when it is done shutting the parent service
92 * down. This will prevent nonresponsiveness to the user by waiting for a service to finish.
93 * 3. If any "previous" values for globals are required for startup/shutdown logic, they need to be
94 * copied to a temp variable before the while($globalsrow...) loop.
95 * @author EMR Direct
97 function checkBackgroundServices(){
98 //load up any necessary globals
99 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
100 ('phimail_enable','phimail_interval')");
101 while($globalsrow = sqlFetchArray($bgservices)){
102 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
105 //Set up phimail service
106 $phimail_active = empty($GLOBALS['phimail_enable']) ? '0' : '1';
107 $phimail_interval = max(0, (int) $GLOBALS['phimail_interval']);
108 updateBackgroundService('phimail', $phimail_active, $phimail_interval);
112 <html>
114 <head>
115 <?php
117 html_header_show();
119 // If we are saving user_specific globals.
121 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && $userMode) {
122 $i = 0;
123 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
124 if (in_array($grpname, $USER_SPECIFIC_TABS)) {
125 foreach ($grparr as $fldid => $fldarr) {
126 if (in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
127 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
128 $label = "global:".$fldid;
129 $fldvalue = trim($_POST["form_$i"]);
130 setUserSetting($label,$fldvalue,$_SESSION['authId'],FALSE);
131 if ( $_POST["toggle_$i"] == "YES" ) {
132 removeUserSetting($label);
134 ++$i;
139 echo "<script type='text/javascript'>";
140 echo "if (parent.left_nav.location) {";
141 echo " parent.left_nav.location.reload();";
142 echo " parent.Title.location.reload();";
143 echo " if(self.name=='RTop'){";
144 echo " parent.RBot.location.reload();";
145 echo " }else{";
146 echo " parent.RTop.location.reload();";
147 echo " }";
148 echo "}";
149 echo "self.location.href='edit_globals.php?mode=user&unique=yes';";
150 echo "</script>";
153 if (array_key_exists('form_download', $_POST) && $_POST['form_download']) {
154 $client = portal_connection();
155 try {
156 $response = $client->getPortalConnectionFiles($credentials);
158 catch(SoapFault $e){
159 error_log('SoapFault Error');
160 error_log(var_dump(get_object_vars($e)));
162 catch(Exception $e){
163 error_log('Exception Error');
164 error_log(var_dump(get_object_vars($e)));
166 if(array_key_exists('status', $response) && $response['status'] == "1") {//WEBSERVICE RETURNED VALUE SUCCESSFULLY
167 $tmpfilename = realpath(sys_get_temp_dir())."/".date('YmdHis').".zip";
168 $fp = fopen($tmpfilename,"wb");
169 fwrite($fp,base64_decode($response['value']));
170 fclose($fp);
171 $practice_filename = $response['file_name'];//practicename.zip
172 ob_clean();
173 // Set headers
174 header("Cache-Control: public");
175 header("Content-Description: File Transfer");
176 header("Content-Disposition: attachment; filename=".$practice_filename);
177 header("Content-Type: application/zip");
178 header("Content-Transfer-Encoding: binary");
179 // Read the file from disk
180 readfile($tmpfilename);
181 unlink($tmpfilename);
182 exit;
184 else{//WEBSERVICE CALL FAILED AND RETURNED AN ERROR MESSAGE
185 ob_end_clean();
187 <script type="text/javascript">
188 alert('<?php echo xls('Offsite Portal web Service Failed').":\\n".text($response['value']);?>');
189 </script>
190 <?php
194 <html>
195 <head>
196 <?php
198 // If we are saving main globals.
200 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && !$userMode) {
201 $force_off_enable_auditlog_encryption = true;
202 // Need to force enable_auditlog_encryption off if the php mycrypt module
203 // is not installed.
204 if (extension_loaded('mcrypt')) {
205 $force_off_enable_auditlog_encryption = false;
208 // Aug 22, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
209 // Check the current status of Audit Logging
210 $auditLogStatusFieldOld = $GLOBALS['enable_auditlog'];
213 * Compare form values with old database values.
214 * Only save if values differ. Improves speed.
217 // Get all the globals from DB
218 $old_globals = sqlGetAssoc( 'SELECT gl_name, gl_index, gl_value FROM `globals` ORDER BY gl_name, gl_index',false,true );
220 $i = 0;
221 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
222 foreach ($grparr as $fldid => $fldarr) {
223 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
224 if($fldtype == 'pwd'){
225 $pass = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array($fldid) );
226 $fldvalueold = $pass['gl_value'];
229 /* Multiple choice fields - do not compare , overwrite */
230 if (!is_array($fldtype) && substr($fldtype, 0, 2) == 'm_') {
231 if (isset($_POST["form_$i"])) {
232 $fldindex = 0;
234 sqlStatement("DELETE FROM globals WHERE gl_name = ?", array( $fldid ) );
236 foreach ($_POST["form_$i"] as $fldvalue) {
237 $fldvalue = trim($fldvalue);
238 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?,?,?)', array( $fldid, $fldindex, $fldvalue ) );
239 ++$fldindex;
243 else {
244 /* check value of single field. Don't update if the database holds the same value */
245 if (isset($_POST["form_$i"])) {
246 $fldvalue = trim($_POST["form_$i"]);
248 else {
249 $fldvalue = "";
251 if($fldtype=='pwd') $fldvalue = $fldvalue ? SHA1($fldvalue) : $fldvalueold; // TODO: salted passwords?
253 // We rely on the fact that set of keys in globals.inc === set of keys in `globals` table!
256 !isset( $old_globals[$fldid]) // if the key not found in database - update database
258 ( isset($old_globals[$fldid]) && $old_globals[ $fldid ]['gl_value'] !== $fldvalue ) // if the value in database is different
260 // Need to force enable_auditlog_encryption off if the php mcrypt module
261 // is not installed.
262 if ( $force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption") ) {
263 error_log("OPENEMR ERROR: UNABLE to support auditlog encryption since the php mcrypt module is not installed",0);
264 $fldvalue=0;
266 // special treatment for some vars
267 switch ($fldid) {
268 case 'first_day_week':
269 // update PostCalendar config as well
270 sqlStatement("UPDATE openemr_module_vars SET pn_value = ? WHERE pn_name = 'pcFirstDayOfWeek'", array($fldvalue));
271 break;
273 // Replace old values
274 sqlStatement( 'DELETE FROM `globals` WHERE gl_name = ?', array( $fldid ) );
275 sqlStatement( 'INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?, ?, ? )', array( $fldid, 0, $fldvalue ) );
276 } else {
277 //error_log("No need to update $fldid");
280 ++$i;
283 checkCreateCDB();
284 checkBackgroundServices();
286 // July 1, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
287 // If Audit Logging status has changed, log it.
288 $auditLogStatusNew = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'enable_auditlog'");
289 $auditLogStatusFieldNew = $auditLogStatusNew['gl_value'];
290 if ( $auditLogStatusFieldOld != $auditLogStatusFieldNew )
292 auditSQLAuditTamper($auditLogStatusFieldNew);
294 echo "<script type='text/javascript'>";
295 echo "if (parent.left_nav.location) {";
296 echo " parent.left_nav.location.reload();";
297 echo " parent.Title.location.reload();";
298 echo " if(self.name=='RTop'){";
299 echo " parent.RBot.location.reload();";
300 echo " }else{";
301 echo " parent.RTop.location.reload();";
302 echo " }";
303 echo "}";
304 echo "self.location.href='edit_globals.php?unique=yes';";
305 echo "</script>";
309 <!-- supporting javascript code -->
310 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
311 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
312 <script type="text/javascript" src="../../library/js/common.js"></script>
313 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
314 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jscolor-1-4-5/jscolor.js"></script>
315 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
317 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
318 <?php if ($userMode) { ?>
319 <title><?php echo xlt('User Settings'); ?></title>
320 <?php } else { ?>
321 <title><?php echo xlt('Global Settings'); ?></title>
322 <?php } ?>
324 <style>
325 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
326 tr.detail { font-size:10pt; }
327 td { font-size:10pt; }
328 input { font-size:10pt; }
329 </style>
330 <script type="text/javascript">
331 function validate_file(){
332 $.ajax({
333 type: "POST",
334 url: "<?php echo $GLOBALS['webroot']?>/library/ajax/offsite_portal_ajax.php",
335 data: {
336 action: 'check_file',
338 cache: false,
339 success: function( message )
341 if(message == 'OK'){
342 document.getElementById('form_download').value = 1;
343 document.getElementById('file_error_message').innerHTML = '';
344 document.forms[0].submit();
346 else{
347 document.getElementById('form_download').value = 0;
348 document.getElementById('file_error_message').innerHTML = message;
349 return false;
354 </script>
355 </head>
357 <body class="body_top">
359 <?php if ($userMode) { ?>
360 <form method='post' name='theform' id='theform' action='edit_globals.php?mode=user' onsubmit='return top.restoreSession()'>
361 <?php } else { ?>
362 <form method='post' name='theform' id='theform' action='edit_globals.php' onsubmit='return top.restoreSession()'>
363 <?php } ?>
365 <?php if ($userMode) { ?>
366 <p><b><?php echo xlt('Edit User Settings'); ?></b>
367 <?php } else { ?>
368 <p><b><?php echo xlt('Edit Global Settings'); ?></b>
369 <?php } ?>
371 <?php // mdsupport - Optional server based searching mechanism for large number of fields on this screen. ?>
372 <span style='float: right;'>
373 <input name='srch_desc' size='20'
374 value='<?php echo (!empty($_POST['srch_desc']) ? htmlspecialchars($_POST['srch_desc']) : '') ?>' />
375 <input type='submit' name='form_search' value='<?php echo xla('Search'); ?>' />
376 </span>
378 <ul class="tabNav">
379 <?php
380 $i = 0;
381 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
382 if ( !$userMode || in_array($grpname, $USER_SPECIFIC_TABS) ) {
383 echo " <li" . ($i ? "" : " class='current'") .
384 "><a href='#'>" .
385 xlt($grpname) . "</a></li>\n";
386 ++$i;
390 </ul>
392 <div class="tabContainer">
393 <?php
394 $i = 0;
395 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
396 if ( !$userMode || in_array($grpname, $USER_SPECIFIC_TABS) ) {
397 echo " <div class='tab" . ($i ? "" : " current") .
398 "' style='height:auto;width:97%;'>\n";
400 echo " <table>";
402 if ($userMode) {
403 echo "<tr>";
404 echo "<th>&nbsp</th>";
405 echo "<th>" . htmlspecialchars( xl('User Specific Setting'), ENT_NOQUOTES) . "</th>";
406 echo "<th>" . htmlspecialchars( xl('Default Setting'), ENT_NOQUOTES) . "</th>";
407 echo "<th>&nbsp</th>";
408 echo "<th>" . htmlspecialchars( xl('Set to Default'), ENT_NOQUOTES) . "</th>";
409 echo "</tr>";
412 foreach ($grparr as $fldid => $fldarr) {
413 if ( !$userMode || in_array($fldid, $USER_SPECIFIC_GLOBALS) ) {
414 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
415 // mdsupport - Check for matches
416 $srch_cl = '';
417 if (!empty($_POST['srch_desc']) && (stristr(($fldname.$flddesc), $_POST['srch_desc']) !== FALSE)) {
418 $srch_cl = 'class="srch"';
421 // Most parameters will have a single value, but some will be arrays.
422 // Here we cater to both possibilities.
423 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
424 "gl_name = ? ORDER BY gl_index", array($fldid));
425 $glarr = array();
426 while ($glrow = sqlFetchArray($glres)) $glarr[] = $glrow;
428 // $fldvalue is meaningful only for the single-value cases.
429 $fldvalue = count($glarr) ? $glarr[0]['gl_value'] : $flddef;
431 // Collect user specific setting if mode set to user
432 $userSetting = "";
433 $settingDefault = "checked='checked'";
434 if ($userMode) {
435 $userSettingArray = sqlQuery("SELECT * FROM user_settings WHERE setting_user=? AND setting_label=?",array($_SESSION['authId'],"global:".$fldid));
436 $userSetting = $userSettingArray['setting_value'];
437 $globalValue = $fldvalue;
438 if (!empty($userSettingArray)) {
439 $fldvalue = $userSetting;
440 $settingDefault = "";
444 echo " <tr $srch_cl title='" . attr($flddesc) . "'><td valign='top'><b>" . text($fldname) . "</b></td><td valign='top'>\n";
446 if (is_array($fldtype)) {
447 echo " <select name='form_$i' id='form_$i'>\n";
448 foreach ($fldtype as $key => $value) {
449 if ($userMode) {
450 if ($globalValue == $key) $globalTitle = $value;
452 echo " <option value='" . attr($key) . "'";
454 //Casting value to string so the comparison will be always the same type and the only thing that will check is the value
455 //Tried to use === but it will fail in already existing variables
456 if ((string)$key == (string)$fldvalue) echo " selected";
457 echo ">";
458 echo text($value);
459 echo "</option>\n";
461 echo " </select>\n";
464 else if ($fldtype == 'bool') {
465 if ($userMode) {
466 if ($globalValue == 1) {
467 $globalTitle = htmlspecialchars( xl('Checked'), ENT_NOQUOTES);
469 else {
470 $globalTitle = htmlspecialchars( xl('Not Checked'), ENT_NOQUOTES);
473 echo " <input type='checkbox' name='form_$i' id='form_$i' value='1'";
474 if ($fldvalue) echo " checked";
475 echo " />\n";
478 else if ($fldtype == 'num') {
479 if ($userMode) {
480 $globalTitle = $globalValue;
482 echo " <input type='text' name='form_$i' id='form_$i' " .
483 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />\n";
486 else if ($fldtype == 'text') {
487 if ($userMode) {
488 $globalTitle = $globalValue;
490 echo " <input type='text' name='form_$i' id='form_$i' " .
491 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
493 else if ($fldtype == 'pwd') {
494 if ($userMode) {
495 $globalTitle = $globalValue;
497 echo " <input type='password' name='form_$i' " .
498 "size='50' maxlength='255' value='' />\n";
501 else if ($fldtype == 'pass') {
502 if ($userMode) {
503 $globalTitle = $globalValue;
505 echo " <input type='password' name='form_$i' " .
506 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
509 else if ($fldtype == 'lang') {
510 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
511 echo " <select name='form_$i' id='form_$i'>\n";
512 while ($row = sqlFetchArray($res)) {
513 echo " <option value='" . attr($row['lang_description']) . "'";
514 if ($row['lang_description'] == $fldvalue) echo " selected";
515 echo ">";
516 echo xlt($row['lang_description']);
517 echo "</option>\n";
519 echo " </select>\n";
522 else if ($fldtype == 'all_code_types') {
523 global $code_types;
524 echo " <select name='form_$i' id='form_$i'>\n";
525 foreach (array_keys($code_types) as $code_key ) {
526 echo " <option value='" . attr($code_key) . "'";
527 if ($code_key == $fldvalue) echo " selected";
528 echo ">";
529 echo xlt($code_types[$code_key]['label']);
530 echo "</option>\n";
532 echo " </select>\n";
535 else if ($fldtype == 'm_lang') {
536 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
537 echo " <select multiple name='form_{$i}[]' id='form_{$i}[]' size='3'>\n";
538 while ($row = sqlFetchArray($res)) {
539 echo " <option value='" . attr($row['lang_description']) . "'";
540 foreach ($glarr as $glrow) {
541 if ($glrow['gl_value'] == $row['lang_description']) {
542 echo " selected";
543 break;
546 echo ">";
547 echo xlt($row['lang_description']);
548 echo "</option>\n";
550 echo " </select>\n";
553 else if ($fldtype == 'color_code') {
554 if ($userMode) {
555 $globalTitle = $globalValue;
557 echo " <input type='text' class='color {hash:true}' name='form_$i' id='form_$i' " .
558 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />" .
559 "<input type='button' value='Default' onclick=\"document.forms[0].form_$i.color.fromString('" . attr($flddef) . "')\">\n";
562 else if ($fldtype == 'css') {
563 if ($userMode) {
564 $globalTitle = $globalValue;
566 $themedir = "$webserver_root/interface/themes";
567 $dh = opendir($themedir);
568 if ($dh) {
569 echo " <select name='form_$i' id='form_$i'>\n";
570 while (false !== ($tfname = readdir($dh))) {
571 // Only show files that contain style_ as options
572 // Skip style_blue.css since this is used for
573 // lone scripts such as setup.php
574 // Also skip style_pdf.css which is for PDFs and not screen output
575 if (!preg_match("/^style_.*\.css$/", $tfname) ||
576 $tfname == 'style_blue.css' || $tfname == 'style_pdf.css')
577 continue;
578 echo "<option value='" . attr($tfname) . "'";
579 // Drop the "style_" part and any replace any underscores with spaces
580 $styleDisplayName = str_replace("_", " ", substr($tfname, 6));
581 // Strip the ".css" and uppercase the first character
582 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
583 if ($tfname == $fldvalue) echo " selected";
584 echo ">";
585 echo text($styleDisplayName);
586 echo "</option>\n";
588 closedir($dh);
589 echo " </select>\n";
593 else if ($fldtype == 'tabs_css') {
594 if ($userMode) {
595 $globalTitle = $globalValue;
597 $themedir = "$webserver_root/interface/themes";
598 $dh = opendir($themedir);
599 if ($dh) {
600 echo " <select name='form_$i' id='form_$i'>\n";
601 while (false !== ($tfname = readdir($dh))) {
602 // Only show files that contain tabs_style_ as options
603 if (!preg_match("/^tabs_style_.*\.css$/", $tfname)) continue;
604 echo "<option value='" . attr($tfname) . "'";
605 // Drop the "tabs_style_" part and any replace any underscores with spaces
606 $styleDisplayName = str_replace("_", " ", substr($tfname, 11));
607 // Strip the ".css" and uppercase the first character
608 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
609 if ($tfname == $fldvalue) echo " selected";
610 echo ">";
611 echo text($styleDisplayName);
612 echo "</option>\n";
614 closedir($dh);
615 echo " </select>\n";
619 else if ($fldtype == 'hour') {
620 if ($userMode) {
621 $globalTitle = $globalValue;
623 echo " <select name='form_$i' id='form_$i'>\n";
624 for ($h = 0; $h < 24; ++$h) {
625 echo "<option value='$h'";
626 if ($h == $fldvalue) echo " selected";
627 echo ">";
628 if ($h == 0) echo "12 AM";
629 else if ($h < 12) echo "$h AM";
630 else if ($h == 12) echo "12 PM";
631 else echo ($h - 12) . " PM";
632 echo "</option>\n";
634 echo " </select>\n";
636 if ($userMode) {
637 echo " </td>\n";
638 echo "<td align='center' style='color:red;'>" . attr($globalTitle) . "</td>\n";
639 echo "<td>&nbsp</td>";
640 echo "<td align='center'><input type='checkbox' value='YES' name='toggle_" . $i . "' id='toggle_" . $i . "' " . attr($settingDefault) . "/></td>\n";
641 echo "<input type='hidden' id='globaldefault_" . $i . "' value='" . attr($globalValue) . "'>\n";
642 echo "</tr>\n";
644 else {
645 echo " </td></tr>\n";
647 ++$i;
649 if( trim(strtolower($fldid)) == 'portal_offsite_address_patient_link' && !empty($GLOBALS['portal_offsite_enable']) && !empty($GLOBALS['portal_offsite_providerid']) ){
650 echo "<input type='hidden' name='form_download' id='form_download'>";
651 echo "<tr><td><input onclick=\"return validate_file()\" type='button' value='".xla('Download Offsite Portal Connection Files')."' /></td><td id='file_error_message' style='color:red'></td></tr>";
654 echo " </table>\n";
655 echo " </div>\n";
659 </div>
662 <input type='submit' name='form_save' value='<?php echo xla('Save'); ?>' />
663 </p>
664 </center>
666 </form>
668 </body>
670 <script language="JavaScript">
672 $(document).ready(function(){
673 tabbify();
674 enable_modals();
676 <?php // mdsupport - Highlight search results ?>
677 $('.srch td').wrapInner("<mark></mark>");
678 $('.tab > table').find('tr.srch:first').each(function() {
679 var srch_div = $(this).closest('div').prevAll().length + 1;
680 $('.tabNav > li:nth-child('+srch_div+') a').wrapInner("<mark></mark>");
682 // Use the counter ($i) to make the form user friendly for user-specific globals use
683 <?php if ($userMode) { ?>
684 <?php for ($j = 0; $j <= $i; $j++) { ?>
685 $("#form_<?php echo $j ?>").change(function() {
686 $("#toggle_<?php echo $j ?>").attr('checked',false);
688 $("#toggle_<?php echo $j ?>").change(function() {
689 if ($('#toggle_<?php echo $j ?>').attr('checked')) {
690 var defaultGlobal = $("#globaldefault_<?php echo $j ?>").val();
691 $("#form_<?php echo $j ?>").val(defaultGlobal);
694 <?php } ?>
695 <?php } ?>
699 </script>
701 </html>