Interim autoloaded library/classes via composer classmap, take 4. (#422)
[openemr.git] / interface / super / edit_globals.php
blob6ed50933ae9aa0737778fe54711d73f1d577104f
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(dirname(__FILE__)."/../../myportal/soap_service/portal_connectivity.php");
35 $userMode = (array_key_exists('mode', $_GET) && $_GET['mode'] == 'user');
37 if (!$userMode) {
38 // Check authorization.
39 $thisauth = acl_check('admin', 'super');
40 if (!$thisauth) die(xlt('Not authorized'));
43 function checkCreateCDB(){
44 $globalsres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
45 ('couchdb_host','couchdb_user','couchdb_pass','couchdb_port','couchdb_dbase','document_storage_method')");
46 $options = array();
47 while($globalsrow = sqlFetchArray($globalsres)){
48 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
50 $directory_created = false;
51 if( !empty($GLOBALS['document_storage_method']) ) {
52 // /documents/temp/ folder is required for CouchDB
53 if(!is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/')){
54 $directory_created = mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/',0777,true);
55 if(!$directory_created){
56 echo htmlspecialchars( xl("Failed to create temporary folder. CouchDB will not work."),ENT_NOQUOTES);
59 $couch = new CouchDB();
60 if(!$couch->check_connection()) {
61 echo "<script type='text/javascript'>alert('".addslashes(xl("CouchDB Connection Failed."))."');</script>";
62 return;
64 if($GLOBALS['couchdb_host'] || $GLOBALS['couchdb_port'] || $GLOBALS['couchdb_dbase']){
65 $couch->createDB($GLOBALS['couchdb_dbase']);
66 $couch->createView($GLOBALS['couchdb_dbase']);
69 return true;
72 /**
73 * Update background_services table for a specific service following globals save.
74 * @author EMR Direct
76 function updateBackgroundService($name,$active,$interval) {
77 //order important here: next_run change dependent on _old_ value of execute_interval so it comes first
78 $sql = 'UPDATE background_services SET active=?, '
79 . 'next_run = next_run + INTERVAL (? - execute_interval) MINUTE, execute_interval=? WHERE name=?';
80 return sqlStatement($sql,array($active,$interval,$interval,$name));
83 /**
84 * Make any necessary changes to background_services table when globals are saved.
85 * To prevent an unexpected service call during startup or shutdown, follow these rules:
86 * 1. Any "startup" operations should occur _before_ the updateBackgroundService() call.
87 * 2. Any "shutdown" operations should occur _after_ the updateBackgroundService() call. If these operations
88 * would cause errors in a running service call, it would be best to make the shutdown function itself
89 * a background service that is activated here, does nothing if active=1 or running=1 for the
90 * parent service, then deactivates itself by setting active=0 when it is done shutting the parent service
91 * down. This will prevent nonresponsiveness to the user by waiting for a service to finish.
92 * 3. If any "previous" values for globals are required for startup/shutdown logic, they need to be
93 * copied to a temp variable before the while($globalsrow...) loop.
94 * @author EMR Direct
96 function checkBackgroundServices(){
97 //load up any necessary globals
98 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
99 ('phimail_enable','phimail_interval')");
100 while($globalsrow = sqlFetchArray($bgservices)){
101 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
104 //Set up phimail service
105 $phimail_active = empty($GLOBALS['phimail_enable']) ? '0' : '1';
106 $phimail_interval = max(0, (int) $GLOBALS['phimail_interval']);
107 updateBackgroundService('phimail', $phimail_active, $phimail_interval);
111 <html>
113 <head>
114 <?php
116 html_header_show();
118 // If we are saving user_specific globals.
120 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && $userMode) {
121 $i = 0;
122 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
123 if (in_array($grpname, $USER_SPECIFIC_TABS)) {
124 foreach ($grparr as $fldid => $fldarr) {
125 if (in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
126 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
127 $label = "global:".$fldid;
128 $fldvalue = trim($_POST["form_$i"]);
129 setUserSetting($label,$fldvalue,$_SESSION['authId'],FALSE);
130 if ( $_POST["toggle_$i"] == "YES" ) {
131 removeUserSetting($label);
133 ++$i;
138 echo "<script type='text/javascript'>";
139 echo "if (parent.left_nav.location) {";
140 echo " parent.left_nav.location.reload();";
141 echo " parent.Title.location.reload();";
142 echo " if(self.name=='RTop'){";
143 echo " parent.RBot.location.reload();";
144 echo " }else{";
145 echo " parent.RTop.location.reload();";
146 echo " }";
147 echo "}";
148 echo "self.location.href='edit_globals.php?mode=user&unique=yes';";
149 echo "</script>";
152 if (array_key_exists('form_download', $_POST) && $_POST['form_download']) {
153 $client = portal_connection();
154 try {
155 $response = $client->getPortalConnectionFiles($credentials);
157 catch(SoapFault $e){
158 error_log('SoapFault Error');
159 error_log(var_dump(get_object_vars($e)));
161 catch(Exception $e){
162 error_log('Exception Error');
163 error_log(var_dump(get_object_vars($e)));
165 if(array_key_exists('status', $response) && $response['status'] == "1") {//WEBSERVICE RETURNED VALUE SUCCESSFULLY
166 $tmpfilename = realpath(sys_get_temp_dir())."/".date('YmdHis').".zip";
167 $fp = fopen($tmpfilename,"wb");
168 fwrite($fp,base64_decode($response['value']));
169 fclose($fp);
170 $practice_filename = $response['file_name'];//practicename.zip
171 ob_clean();
172 // Set headers
173 header("Cache-Control: public");
174 header("Content-Description: File Transfer");
175 header("Content-Disposition: attachment; filename=".$practice_filename);
176 header("Content-Type: application/zip");
177 header("Content-Transfer-Encoding: binary");
178 // Read the file from disk
179 readfile($tmpfilename);
180 unlink($tmpfilename);
181 exit;
183 else{//WEBSERVICE CALL FAILED AND RETURNED AN ERROR MESSAGE
184 ob_end_clean();
186 <script type="text/javascript">
187 alert('<?php echo xls('Offsite Portal web Service Failed').":\\n".text($response['value']);?>');
188 </script>
189 <?php
193 <html>
194 <head>
195 <?php
197 // If we are saving main globals.
199 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && !$userMode) {
200 $force_off_enable_auditlog_encryption = true;
201 // Need to force enable_auditlog_encryption off if the php mycrypt module
202 // is not installed.
203 if (extension_loaded('mcrypt')) {
204 $force_off_enable_auditlog_encryption = false;
207 // Aug 22, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
208 // Check the current status of Audit Logging
209 $auditLogStatusFieldOld = $GLOBALS['enable_auditlog'];
212 * Compare form values with old database values.
213 * Only save if values differ. Improves speed.
216 // Get all the globals from DB
217 $old_globals = sqlGetAssoc( 'SELECT gl_name, gl_index, gl_value FROM `globals` ORDER BY gl_name, gl_index',false,true );
219 $i = 0;
220 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
221 foreach ($grparr as $fldid => $fldarr) {
222 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
223 if($fldtype == 'pwd'){
224 $pass = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array($fldid) );
225 $fldvalueold = $pass['gl_value'];
228 /* Multiple choice fields - do not compare , overwrite */
229 if (!is_array($fldtype) && substr($fldtype, 0, 2) == 'm_') {
230 if (isset($_POST["form_$i"])) {
231 $fldindex = 0;
233 sqlStatement("DELETE FROM globals WHERE gl_name = ?", array( $fldid ) );
235 foreach ($_POST["form_$i"] as $fldvalue) {
236 $fldvalue = trim($fldvalue);
237 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?,?,?)', array( $fldid, $fldindex, $fldvalue ) );
238 ++$fldindex;
242 else {
243 /* check value of single field. Don't update if the database holds the same value */
244 if (isset($_POST["form_$i"])) {
245 $fldvalue = trim($_POST["form_$i"]);
247 else {
248 $fldvalue = "";
250 if($fldtype=='pwd') $fldvalue = $fldvalue ? SHA1($fldvalue) : $fldvalueold; // TODO: salted passwords?
252 // We rely on the fact that set of keys in globals.inc === set of keys in `globals` table!
255 !isset( $old_globals[$fldid]) // if the key not found in database - update database
257 ( isset($old_globals[$fldid]) && $old_globals[ $fldid ]['gl_value'] !== $fldvalue ) // if the value in database is different
259 // Need to force enable_auditlog_encryption off if the php mcrypt module
260 // is not installed.
261 if ( $force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption") ) {
262 error_log("OPENEMR ERROR: UNABLE to support auditlog encryption since the php mcrypt module is not installed",0);
263 $fldvalue=0;
265 // special treatment for some vars
266 switch ($fldid) {
267 case 'first_day_week':
268 // update PostCalendar config as well
269 sqlStatement("UPDATE openemr_module_vars SET pn_value = ? WHERE pn_name = 'pcFirstDayOfWeek'", array($fldvalue));
270 break;
272 // Replace old values
273 sqlStatement( 'DELETE FROM `globals` WHERE gl_name = ?', array( $fldid ) );
274 sqlStatement( 'INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?, ?, ? )', array( $fldid, 0, $fldvalue ) );
275 } else {
276 //error_log("No need to update $fldid");
279 ++$i;
282 checkCreateCDB();
283 checkBackgroundServices();
285 // July 1, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
286 // If Audit Logging status has changed, log it.
287 $auditLogStatusNew = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'enable_auditlog'");
288 $auditLogStatusFieldNew = $auditLogStatusNew['gl_value'];
289 if ( $auditLogStatusFieldOld != $auditLogStatusFieldNew )
291 auditSQLAuditTamper($auditLogStatusFieldNew);
293 echo "<script type='text/javascript'>";
294 echo "if (parent.left_nav.location) {";
295 echo " parent.left_nav.location.reload();";
296 echo " parent.Title.location.reload();";
297 echo " if(self.name=='RTop'){";
298 echo " parent.RBot.location.reload();";
299 echo " }else{";
300 echo " parent.RTop.location.reload();";
301 echo " }";
302 echo "}";
303 echo "self.location.href='edit_globals.php?unique=yes';";
304 echo "</script>";
308 <!-- supporting javascript code -->
309 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
310 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
311 <script type="text/javascript" src="../../library/js/common.js"></script>
312 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
313 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jscolor-1-4-5/jscolor.js"></script>
314 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
316 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
317 <?php if ($userMode) { ?>
318 <title><?php echo xlt('User Settings'); ?></title>
319 <?php } else { ?>
320 <title><?php echo xlt('Global Settings'); ?></title>
321 <?php } ?>
323 <style>
324 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
325 tr.detail { font-size:10pt; }
326 td { font-size:10pt; }
327 input { font-size:10pt; }
328 </style>
329 <script type="text/javascript">
330 function validate_file(){
331 $.ajax({
332 type: "POST",
333 url: "<?php echo $GLOBALS['webroot']?>/library/ajax/offsite_portal_ajax.php",
334 data: {
335 action: 'check_file',
337 cache: false,
338 success: function( message )
340 if(message == 'OK'){
341 document.getElementById('form_download').value = 1;
342 document.getElementById('file_error_message').innerHTML = '';
343 document.forms[0].submit();
345 else{
346 document.getElementById('form_download').value = 0;
347 document.getElementById('file_error_message').innerHTML = message;
348 return false;
353 </script>
354 </head>
356 <body class="body_top">
358 <?php if ($userMode) { ?>
359 <form method='post' name='theform' id='theform' action='edit_globals.php?mode=user' onsubmit='return top.restoreSession()'>
360 <?php } else { ?>
361 <form method='post' name='theform' id='theform' action='edit_globals.php' onsubmit='return top.restoreSession()'>
362 <?php } ?>
364 <?php if ($userMode) { ?>
365 <p><b><?php echo xlt('Edit User Settings'); ?></b>
366 <?php } else { ?>
367 <p><b><?php echo xlt('Edit Global Settings'); ?></b>
368 <?php } ?>
370 <?php // mdsupport - Optional server based searching mechanism for large number of fields on this screen. ?>
371 <span style='float: right;'>
372 <input name='srch_desc' size='20'
373 value='<?php echo (!empty($_POST['srch_desc']) ? htmlspecialchars($_POST['srch_desc']) : '') ?>' />
374 <input type='submit' name='form_search' value='<?php echo xla('Search'); ?>' />
375 </span>
377 <ul class="tabNav">
378 <?php
379 $i = 0;
380 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
381 if ( !$userMode || in_array($grpname, $USER_SPECIFIC_TABS) ) {
382 echo " <li" . ($i ? "" : " class='current'") .
383 "><a href='#'>" .
384 xlt($grpname) . "</a></li>\n";
385 ++$i;
389 </ul>
391 <div class="tabContainer">
392 <?php
393 $i = 0;
394 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
395 if ( !$userMode || in_array($grpname, $USER_SPECIFIC_TABS) ) {
396 echo " <div class='tab" . ($i ? "" : " current") .
397 "' style='height:auto;width:97%;'>\n";
399 echo " <table>";
401 if ($userMode) {
402 echo "<tr>";
403 echo "<th>&nbsp</th>";
404 echo "<th>" . htmlspecialchars( xl('User Specific Setting'), ENT_NOQUOTES) . "</th>";
405 echo "<th>" . htmlspecialchars( xl('Default Setting'), ENT_NOQUOTES) . "</th>";
406 echo "<th>&nbsp</th>";
407 echo "<th>" . htmlspecialchars( xl('Set to Default'), ENT_NOQUOTES) . "</th>";
408 echo "</tr>";
411 foreach ($grparr as $fldid => $fldarr) {
412 if ( !$userMode || in_array($fldid, $USER_SPECIFIC_GLOBALS) ) {
413 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
414 // mdsupport - Check for matches
415 $srch_cl = '';
416 if (!empty($_POST['srch_desc']) && (stristr(($fldname.$flddesc), $_POST['srch_desc']) !== FALSE)) {
417 $srch_cl = 'class="srch"';
420 // Most parameters will have a single value, but some will be arrays.
421 // Here we cater to both possibilities.
422 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
423 "gl_name = ? ORDER BY gl_index", array($fldid));
424 $glarr = array();
425 while ($glrow = sqlFetchArray($glres)) $glarr[] = $glrow;
427 // $fldvalue is meaningful only for the single-value cases.
428 $fldvalue = count($glarr) ? $glarr[0]['gl_value'] : $flddef;
430 // Collect user specific setting if mode set to user
431 $userSetting = "";
432 $settingDefault = "checked='checked'";
433 if ($userMode) {
434 $userSettingArray = sqlQuery("SELECT * FROM user_settings WHERE setting_user=? AND setting_label=?",array($_SESSION['authId'],"global:".$fldid));
435 $userSetting = $userSettingArray['setting_value'];
436 $globalValue = $fldvalue;
437 if (!empty($userSettingArray)) {
438 $fldvalue = $userSetting;
439 $settingDefault = "";
443 echo " <tr $srch_cl title='" . attr($flddesc) . "'><td valign='top'><b>" . text($fldname) . "</b></td><td valign='top'>\n";
445 if (is_array($fldtype)) {
446 echo " <select name='form_$i' id='form_$i'>\n";
447 foreach ($fldtype as $key => $value) {
448 if ($userMode) {
449 if ($globalValue == $key) $globalTitle = $value;
451 echo " <option value='" . attr($key) . "'";
453 //Casting value to string so the comparison will be always the same type and the only thing that will check is the value
454 //Tried to use === but it will fail in already existing variables
455 if ((string)$key == (string)$fldvalue) echo " selected";
456 echo ">";
457 echo text($value);
458 echo "</option>\n";
460 echo " </select>\n";
463 else if ($fldtype == 'bool') {
464 if ($userMode) {
465 if ($globalValue == 1) {
466 $globalTitle = htmlspecialchars( xl('Checked'), ENT_NOQUOTES);
468 else {
469 $globalTitle = htmlspecialchars( xl('Not Checked'), ENT_NOQUOTES);
472 echo " <input type='checkbox' name='form_$i' id='form_$i' value='1'";
473 if ($fldvalue) echo " checked";
474 echo " />\n";
477 else if ($fldtype == 'num') {
478 if ($userMode) {
479 $globalTitle = $globalValue;
481 echo " <input type='text' name='form_$i' id='form_$i' " .
482 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />\n";
485 else if ($fldtype == 'text') {
486 if ($userMode) {
487 $globalTitle = $globalValue;
489 echo " <input type='text' name='form_$i' id='form_$i' " .
490 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
492 else if ($fldtype == 'pwd') {
493 if ($userMode) {
494 $globalTitle = $globalValue;
496 echo " <input type='password' name='form_$i' " .
497 "size='50' maxlength='255' value='' />\n";
500 else if ($fldtype == 'pass') {
501 if ($userMode) {
502 $globalTitle = $globalValue;
504 echo " <input type='password' name='form_$i' " .
505 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
508 else if ($fldtype == 'lang') {
509 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
510 echo " <select name='form_$i' id='form_$i'>\n";
511 while ($row = sqlFetchArray($res)) {
512 echo " <option value='" . attr($row['lang_description']) . "'";
513 if ($row['lang_description'] == $fldvalue) echo " selected";
514 echo ">";
515 echo xlt($row['lang_description']);
516 echo "</option>\n";
518 echo " </select>\n";
521 else if ($fldtype == 'all_code_types') {
522 global $code_types;
523 echo " <select name='form_$i' id='form_$i'>\n";
524 foreach (array_keys($code_types) as $code_key ) {
525 echo " <option value='" . attr($code_key) . "'";
526 if ($code_key == $fldvalue) echo " selected";
527 echo ">";
528 echo xlt($code_types[$code_key]['label']);
529 echo "</option>\n";
531 echo " </select>\n";
534 else if ($fldtype == 'm_lang') {
535 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
536 echo " <select multiple name='form_{$i}[]' id='form_{$i}[]' size='3'>\n";
537 while ($row = sqlFetchArray($res)) {
538 echo " <option value='" . attr($row['lang_description']) . "'";
539 foreach ($glarr as $glrow) {
540 if ($glrow['gl_value'] == $row['lang_description']) {
541 echo " selected";
542 break;
545 echo ">";
546 echo xlt($row['lang_description']);
547 echo "</option>\n";
549 echo " </select>\n";
552 else if ($fldtype == 'color_code') {
553 if ($userMode) {
554 $globalTitle = $globalValue;
556 echo " <input type='text' class='color {hash:true}' name='form_$i' id='form_$i' " .
557 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />" .
558 "<input type='button' value='Default' onclick=\"document.forms[0].form_$i.color.fromString('" . attr($flddef) . "')\">\n";
561 else if ($fldtype == 'css') {
562 if ($userMode) {
563 $globalTitle = $globalValue;
565 $themedir = "$webserver_root/interface/themes";
566 $dh = opendir($themedir);
567 if ($dh) {
568 echo " <select name='form_$i' id='form_$i'>\n";
569 while (false !== ($tfname = readdir($dh))) {
570 // Only show files that contain style_ as options
571 // Skip style_blue.css since this is used for
572 // lone scripts such as setup.php
573 // Also skip style_pdf.css which is for PDFs and not screen output
574 if (!preg_match("/^style_.*\.css$/", $tfname) ||
575 $tfname == 'style_blue.css' || $tfname == 'style_pdf.css')
576 continue;
577 echo "<option value='" . attr($tfname) . "'";
578 // Drop the "style_" part and any replace any underscores with spaces
579 $styleDisplayName = str_replace("_", " ", substr($tfname, 6));
580 // Strip the ".css" and uppercase the first character
581 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
582 if ($tfname == $fldvalue) echo " selected";
583 echo ">";
584 echo text($styleDisplayName);
585 echo "</option>\n";
587 closedir($dh);
588 echo " </select>\n";
592 else if ($fldtype == 'tabs_css') {
593 if ($userMode) {
594 $globalTitle = $globalValue;
596 $themedir = "$webserver_root/interface/themes";
597 $dh = opendir($themedir);
598 if ($dh) {
599 echo " <select name='form_$i' id='form_$i'>\n";
600 while (false !== ($tfname = readdir($dh))) {
601 // Only show files that contain tabs_style_ as options
602 if (!preg_match("/^tabs_style_.*\.css$/", $tfname)) continue;
603 echo "<option value='" . attr($tfname) . "'";
604 // Drop the "tabs_style_" part and any replace any underscores with spaces
605 $styleDisplayName = str_replace("_", " ", substr($tfname, 11));
606 // Strip the ".css" and uppercase the first character
607 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
608 if ($tfname == $fldvalue) echo " selected";
609 echo ">";
610 echo text($styleDisplayName);
611 echo "</option>\n";
613 closedir($dh);
614 echo " </select>\n";
618 else if ($fldtype == 'hour') {
619 if ($userMode) {
620 $globalTitle = $globalValue;
622 echo " <select name='form_$i' id='form_$i'>\n";
623 for ($h = 0; $h < 24; ++$h) {
624 echo "<option value='$h'";
625 if ($h == $fldvalue) echo " selected";
626 echo ">";
627 if ($h == 0) echo "12 AM";
628 else if ($h < 12) echo "$h AM";
629 else if ($h == 12) echo "12 PM";
630 else echo ($h - 12) . " PM";
631 echo "</option>\n";
633 echo " </select>\n";
635 if ($userMode) {
636 echo " </td>\n";
637 echo "<td align='center' style='color:red;'>" . attr($globalTitle) . "</td>\n";
638 echo "<td>&nbsp</td>";
639 echo "<td align='center'><input type='checkbox' value='YES' name='toggle_" . $i . "' id='toggle_" . $i . "' " . attr($settingDefault) . "/></td>\n";
640 echo "<input type='hidden' id='globaldefault_" . $i . "' value='" . attr($globalValue) . "'>\n";
641 echo "</tr>\n";
643 else {
644 echo " </td></tr>\n";
646 ++$i;
648 if( trim(strtolower($fldid)) == 'portal_offsite_address_patient_link' && !empty($GLOBALS['portal_offsite_enable']) && !empty($GLOBALS['portal_offsite_providerid']) ){
649 echo "<input type='hidden' name='form_download' id='form_download'>";
650 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>";
653 echo " </table>\n";
654 echo " </div>\n";
658 </div>
661 <input type='submit' name='form_save' value='<?php echo xla('Save'); ?>' />
662 </p>
663 </center>
665 </form>
667 </body>
669 <script language="JavaScript">
671 $(document).ready(function(){
672 tabbify();
673 enable_modals();
675 <?php // mdsupport - Highlight search results ?>
676 $('.srch td').wrapInner("<mark></mark>");
677 $('.tab > table').find('tr.srch:first').each(function() {
678 var srch_div = $(this).closest('div').prevAll().length + 1;
679 $('.tabNav > li:nth-child('+srch_div+') a').wrapInner("<mark></mark>");
681 // Use the counter ($i) to make the form user friendly for user-specific globals use
682 <?php if ($userMode) { ?>
683 <?php for ($j = 0; $j <= $i; $j++) { ?>
684 $("#form_<?php echo $j ?>").change(function() {
685 $("#toggle_<?php echo $j ?>").attr('checked',false);
687 $("#toggle_<?php echo $j ?>").change(function() {
688 if ($('#toggle_<?php echo $j ?>').attr('checked')) {
689 var defaultGlobal = $("#globaldefault_<?php echo $j ?>").val();
690 $("#form_<?php echo $j ?>").val(defaultGlobal);
693 <?php } ?>
694 <?php } ?>
698 </script>
700 </html>