adding default billing encounter view and minor fix for edit_globals (#1025)
[openemr.git] / interface / super / edit_globals.php
blob8ba22037a0e4938a7eddb5f3290280fcd9a6b3ea
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.g.miller@gmail.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.g.miller@gmail.com>
22 * @link http://www.open-emr.org
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) {
41 die(xlt('Not authorized'));
45 function checkCreateCDB()
47 $globalsres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
48 ('couchdb_host','couchdb_user','couchdb_pass','couchdb_port','couchdb_dbase','document_storage_method')");
49 $options = array();
50 while ($globalsrow = sqlFetchArray($globalsres)) {
51 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
54 $directory_created = false;
55 if (!empty($GLOBALS['document_storage_method'])) {
56 // /documents/temp/ folder is required for CouchDB
57 if (!is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/')) {
58 $directory_created = mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/', 0777, true);
59 if (!$directory_created) {
60 echo htmlspecialchars(xl("Failed to create temporary folder. CouchDB will not work."), ENT_NOQUOTES);
64 $couch = new CouchDB();
65 if (!$couch->check_connection()) {
66 echo "<script type='text/javascript'>alert('".addslashes(xl("CouchDB Connection Failed."))."');</script>";
67 return false;
70 if ($GLOBALS['couchdb_host'] || $GLOBALS['couchdb_port'] || $GLOBALS['couchdb_dbase']) {
71 $couch->createDB($GLOBALS['couchdb_dbase']);
72 $couch->createView($GLOBALS['couchdb_dbase']);
76 return true;
79 /**
80 * Update background_services table for a specific service following globals save.
81 * @author EMR Direct
83 function updateBackgroundService($name, $active, $interval)
85 //order important here: next_run change dependent on _old_ value of execute_interval so it comes first
86 $sql = 'UPDATE background_services SET active=?, '
87 . 'next_run = next_run + INTERVAL (? - execute_interval) MINUTE, execute_interval=? WHERE name=?';
88 return sqlStatement($sql, array($active,$interval,$interval,$name));
91 /**
92 * Make any necessary changes to background_services table when globals are saved.
93 * To prevent an unexpected service call during startup or shutdown, follow these rules:
94 * 1. Any "startup" operations should occur _before_ the updateBackgroundService() call.
95 * 2. Any "shutdown" operations should occur _after_ the updateBackgroundService() call. If these operations
96 * would cause errors in a running service call, it would be best to make the shutdown function itself is
97 * a background service that is activated here, does nothing if active=1 or running=1 for the
98 * parent service. Then it deactivates itself by setting active=0 when it is done shutting the parent service
99 * down. This will prevent non-responsiveness to the user by waiting for a service to finish.
100 * 3. If any "previous" values for globals are required for startup/shutdown logic, they need to be
101 * copied to a temp variable before the while($globalsrow...) loop.
102 * @author EMR Direct
104 function checkBackgroundServices()
106 //load up any necessary globals
107 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
108 ('phimail_enable','phimail_interval')");
109 while ($globalsrow = sqlFetchArray($bgservices)) {
110 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
113 //Set up phimail service
114 $phimail_active = empty($GLOBALS['phimail_enable']) ? '0' : '1';
115 $phimail_interval = max(0, (int) $GLOBALS['phimail_interval']);
116 updateBackgroundService('phimail', $phimail_active, $phimail_interval);
118 function handleAltServices($this_serviceid, $gln = '', $sinterval = 1)
120 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name = '$gln'");
121 while ($globalsrow = sqlFetchArray($bgservices)) {
122 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
125 $bs_active = empty($GLOBALS[$gln]) ? '0' : '1';
126 $bs_interval = max(0, (int) $sinterval);
127 updateBackgroundService($this_serviceid, $bs_active, $bs_interval);
128 if (!$bs_active && $this_serviceid == 'ccdaservice') {
129 require_once(dirname(__FILE__)."/../../ccdaservice/ssmanager.php");
131 service_shutdown(0);
136 <html>
138 <head>
139 <?php
141 html_header_show();
143 // If we are saving user_specific globals.
145 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && $userMode) {
146 $i = 0;
147 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
148 if (in_array($grpname, $USER_SPECIFIC_TABS)) {
149 foreach ($grparr as $fldid => $fldarr) {
150 if (in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
151 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
152 $label = "global:".$fldid;
153 $fldvalue = trim($_POST["form_$i"]);
154 setUserSetting($label, $fldvalue, $_SESSION['authId'], false);
155 if ($_POST["toggle_$i"] == "YES") {
156 removeUserSetting($label);
159 ++$i;
165 echo "<script type='text/javascript'>";
166 echo "if (parent.left_nav.location) {";
167 echo " parent.left_nav.location.reload();";
168 echo " parent.Title.location.reload();";
169 echo " if(self.name=='RTop'){";
170 echo " parent.RBot.location.reload();";
171 echo " }else{";
172 echo " parent.RTop.location.reload();";
173 echo " }";
174 echo "}";
175 echo "self.location.href='edit_globals.php?mode=user&unique=yes';";
176 echo "</script>";
179 if (array_key_exists('form_download', $_POST) && $_POST['form_download']) {
180 $client = portal_connection();
181 try {
182 $response = $client->getPortalConnectionFiles($credentials);
183 } catch (SoapFault $e) {
184 error_log('SoapFault Error');
185 error_log(var_dump(get_object_vars($e)));
186 } catch (Exception $e) {
187 error_log('Exception Error');
188 error_log(var_dump(get_object_vars($e)));
191 if (array_key_exists('status', $response) && $response['status'] == "1") {//WEBSERVICE RETURNED VALUE SUCCESSFULLY
192 $tmpfilename = realpath(sys_get_temp_dir())."/".date('YmdHis').".zip";
193 $fp = fopen($tmpfilename, "wb");
194 fwrite($fp, base64_decode($response['value']));
195 fclose($fp);
196 $practice_filename = $response['file_name'];//practicename.zip
197 ob_clean();
198 // Set headers
199 header("Cache-Control: public");
200 header("Content-Description: File Transfer");
201 header("Content-Disposition: attachment; filename=".$practice_filename);
202 header("Content-Type: application/zip");
203 header("Content-Transfer-Encoding: binary");
204 // Read the file from disk
205 readfile($tmpfilename);
206 unlink($tmpfilename);
207 exit;
208 } else {//WEBSERVICE CALL FAILED AND RETURNED AN ERROR MESSAGE
209 ob_end_clean();
211 <script type="text/javascript">
212 alert('<?php echo xls('Offsite Portal web Service Failed').":\\n".text($response['value']);?>');
213 </script>
214 <?php
218 <html>
219 <head>
220 <?php
222 // If we are saving main globals.
224 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && !$userMode) {
225 $force_off_enable_auditlog_encryption = true;
226 // Need to force enable_auditlog_encryption off if the php mycrypt module
227 // is not installed.
228 if (extension_loaded('mcrypt')) {
229 $force_off_enable_auditlog_encryption = false;
232 // Aug 22, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
233 // Check the current status of Audit Logging
234 $auditLogStatusFieldOld = $GLOBALS['enable_auditlog'];
237 * Compare form values with old database values.
238 * Only save if values differ. Improves speed.
241 // Get all the globals from DB
242 $old_globals = sqlGetAssoc('SELECT gl_name, gl_index, gl_value FROM `globals` ORDER BY gl_name, gl_index', false, true);
244 $i = 0;
245 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
246 foreach ($grparr as $fldid => $fldarr) {
247 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
248 if ($fldtype == 'pwd') {
249 $pass = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array($fldid));
250 $fldvalueold = $pass['gl_value'];
253 /* Multiple choice fields - do not compare , overwrite */
254 if (!is_array($fldtype) && substr($fldtype, 0, 2) == 'm_') {
255 if (isset($_POST["form_$i"])) {
256 $fldindex = 0;
258 sqlStatement("DELETE FROM globals WHERE gl_name = ?", array( $fldid ));
260 foreach ($_POST["form_$i"] as $fldvalue) {
261 $fldvalue = trim($fldvalue);
262 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?,?,?)', array( $fldid, $fldindex, $fldvalue ));
263 ++$fldindex;
266 } else {
267 /* check value of single field. Don't update if the database holds the same value */
268 if (isset($_POST["form_$i"])) {
269 $fldvalue = trim($_POST["form_$i"]);
270 } else {
271 $fldvalue = "";
274 if ($fldtype=='pwd') {
275 $fldvalue = $fldvalue ? SHA1($fldvalue) : $fldvalueold; // TODO: salted passwords?
278 // We rely on the fact that set of keys in globals.inc === set of keys in `globals` table!
280 if (!isset($old_globals[$fldid]) // if the key not found in database - update database
282 ( isset($old_globals[$fldid]) && $old_globals[ $fldid ]['gl_value'] !== $fldvalue ) // if the value in database is different
284 // Need to force enable_auditlog_encryption off if the php mcrypt module
285 // is not installed.
286 if ($force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption")) {
287 error_log("OPENEMR ERROR: UNABLE to support auditlog encryption since the php mcrypt module is not installed", 0);
288 $fldvalue=0;
291 // special treatment for some vars
292 switch ($fldid) {
293 case 'first_day_week':
294 // update PostCalendar config as well
295 sqlStatement("UPDATE openemr_module_vars SET pn_value = ? WHERE pn_name = 'pcFirstDayOfWeek'", array($fldvalue));
296 break;
299 // Replace old values
300 sqlStatement('DELETE FROM `globals` WHERE gl_name = ?', array( $fldid ));
301 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?, ?, ? )', array( $fldid, 0, $fldvalue ));
302 } else {
303 //error_log("No need to update $fldid");
307 ++$i;
311 checkCreateCDB();
312 checkBackgroundServices();
313 handleAltServices('ccdaservice', 'ccda_alt_service_enable', 1);
315 // July 1, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
316 // If Audit Logging status has changed, log it.
317 $auditLogStatusNew = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'enable_auditlog'");
318 $auditLogStatusFieldNew = $auditLogStatusNew['gl_value'];
319 if ($auditLogStatusFieldOld != $auditLogStatusFieldNew) {
320 auditSQLAuditTamper($auditLogStatusFieldNew);
323 echo "<script type='text/javascript'>";
324 echo "if (parent.left_nav.location) {";
325 echo " parent.left_nav.location.reload();";
326 echo " parent.Title.location.reload();";
327 echo " if(self.name=='RTop'){";
328 echo " parent.RBot.location.reload();";
329 echo " }else{";
330 echo " parent.RTop.location.reload();";
331 echo " }";
332 echo "}";
333 echo "self.location.href='edit_globals.php?unique=yes';";
334 echo "</script>";
338 <!-- supporting javascript code -->
339 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
340 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
341 <script type="text/javascript" src="../../library/js/common.js"></script>
342 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
343 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jscolor-1-4-5/jscolor.js"></script>
344 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
346 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
347 <?php if ($userMode) { ?>
348 <title><?php echo xlt('User Settings'); ?></title>
349 <?php } else { ?>
350 <title><?php echo xlt('Global Settings'); ?></title>
351 <?php } ?>
353 <style>
354 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
355 tr.detail { font-size:10pt; }
356 td { font-size:10pt; }
357 input { font-size:10pt; }
358 </style>
359 <script type="text/javascript">
360 function validate_file(){
361 $.ajax({
362 type: "POST",
363 url: "<?php echo $GLOBALS['webroot']?>/library/ajax/offsite_portal_ajax.php",
364 data: {
365 action: 'check_file',
367 cache: false,
368 success: function( message )
370 if(message == 'OK'){
371 document.getElementById('form_download').value = 1;
372 document.getElementById('file_error_message').innerHTML = '';
373 document.forms[0].submit();
375 else{
376 document.getElementById('form_download').value = 0;
377 document.getElementById('file_error_message').innerHTML = message;
378 return false;
383 </script>
384 </head>
386 <body class="body_top">
388 <?php if ($userMode) { ?>
389 <form method='post' name='theform' id='theform' action='edit_globals.php?mode=user' onsubmit='return top.restoreSession()'>
390 <?php } else { ?>
391 <form method='post' name='theform' id='theform' action='edit_globals.php' onsubmit='return top.restoreSession()'>
392 <?php } ?>
394 <?php if ($userMode) { ?>
395 <p><b><?php echo xlt('Edit User Settings'); ?></b>
396 <?php } else { ?>
397 <p><b><?php echo xlt('Edit Global Settings'); ?></b>
398 <?php } ?>
400 <?php // mdsupport - Optional server based searching mechanism for large number of fields on this screen. ?>
401 <span style='float: right;'>
402 <input name='srch_desc' size='20'
403 value='<?php echo (!empty($_POST['srch_desc']) ? htmlspecialchars($_POST['srch_desc']) : '') ?>' />
404 <input type='submit' name='form_search' value='<?php echo xla('Search'); ?>' />
405 </span>
407 <ul class="tabNav">
408 <?php
409 $i = 0;
410 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
411 if (!$userMode || in_array($grpname, $USER_SPECIFIC_TABS)) {
412 echo " <li" . ($i ? "" : " class='current'") .
413 "><a href='#'>" .
414 xlt($grpname) . "</a></li>\n";
415 ++$i;
419 </ul>
421 <div class="tabContainer">
422 <?php
423 $i = 0;
424 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
425 if (!$userMode || in_array($grpname, $USER_SPECIFIC_TABS)) {
426 echo " <div class='tab" . ($i ? "" : " current") .
427 "' style='height:auto;width:97%;'>\n";
429 echo " <table>";
431 if ($userMode) {
432 echo "<tr>";
433 echo "<th>&nbsp</th>";
434 echo "<th>" . htmlspecialchars(xl('User Specific Setting'), ENT_NOQUOTES) . "</th>";
435 echo "<th>" . htmlspecialchars(xl('Default Setting'), ENT_NOQUOTES) . "</th>";
436 echo "<th>&nbsp</th>";
437 echo "<th>" . htmlspecialchars(xl('Set to Default'), ENT_NOQUOTES) . "</th>";
438 echo "</tr>";
441 foreach ($grparr as $fldid => $fldarr) {
442 if (!$userMode || in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
443 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
444 // mdsupport - Check for matches
445 $srch_cl = '';
446 if (!empty($_POST['srch_desc']) && (stristr(($fldname.$flddesc), $_POST['srch_desc']) !== false)) {
447 $srch_cl = 'class="srch"';
450 // Most parameters will have a single value, but some will be arrays.
451 // Here we cater to both possibilities.
452 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
453 "gl_name = ? ORDER BY gl_index", array($fldid));
454 $glarr = array();
455 while ($glrow = sqlFetchArray($glres)) {
456 $glarr[] = $glrow;
459 // $fldvalue is meaningful only for the single-value cases.
460 $fldvalue = count($glarr) ? $glarr[0]['gl_value'] : $flddef;
462 // Collect user specific setting if mode set to user
463 $userSetting = "";
464 $settingDefault = "checked='checked'";
465 if ($userMode) {
466 $userSettingArray = sqlQuery("SELECT * FROM user_settings WHERE setting_user=? AND setting_label=?", array($_SESSION['authId'],"global:".$fldid));
467 $userSetting = $userSettingArray['setting_value'];
468 $globalValue = $fldvalue;
469 if (!empty($userSettingArray)) {
470 $fldvalue = $userSetting;
471 $settingDefault = "";
475 echo " <tr $srch_cl title='" . attr($flddesc) . "'><td valign='top'><b>" . text($fldname) . "</b></td><td valign='top'>\n";
477 if (is_array($fldtype)) {
478 echo " <select name='form_$i' id='form_$i'>\n";
479 foreach ($fldtype as $key => $value) {
480 if ($userMode) {
481 if ($globalValue == $key) {
482 $globalTitle = $value;
486 echo " <option value='" . attr($key) . "'";
488 //Casting value to string so the comparison will be always the same type and the only thing that will check is the value
489 //Tried to use === but it will fail in already existing variables
490 if ((string)$key == (string)$fldvalue) {
491 echo " selected";
494 echo ">";
495 echo text($value);
496 echo "</option>\n";
499 echo " </select>\n";
500 } else if ($fldtype == 'bool') {
501 if ($userMode) {
502 if ($globalValue == 1) {
503 $globalTitle = htmlspecialchars(xl('Checked'), ENT_NOQUOTES);
504 } else {
505 $globalTitle = htmlspecialchars(xl('Not Checked'), ENT_NOQUOTES);
509 echo " <input type='checkbox' name='form_$i' id='form_$i' value='1'";
510 if ($fldvalue) {
511 echo " checked";
514 echo " />\n";
515 } else if ($fldtype == 'num') {
516 if ($userMode) {
517 $globalTitle = $globalValue;
520 echo " <input type='text' name='form_$i' id='form_$i' " .
521 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />\n";
522 } else if ($fldtype == 'text') {
523 if ($userMode) {
524 $globalTitle = $globalValue;
527 echo " <input type='text' name='form_$i' id='form_$i' " .
528 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
529 } else if ($fldtype == 'pwd') {
530 if ($userMode) {
531 $globalTitle = $globalValue;
534 echo " <input type='password' name='form_$i' " .
535 "size='50' maxlength='255' value='' />\n";
536 } else if ($fldtype == 'pass') {
537 if ($userMode) {
538 $globalTitle = $globalValue;
541 echo " <input type='password' name='form_$i' " .
542 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
543 } else if ($fldtype == 'lang') {
544 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
545 echo " <select name='form_$i' id='form_$i'>\n";
546 while ($row = sqlFetchArray($res)) {
547 echo " <option value='" . attr($row['lang_description']) . "'";
548 if ($row['lang_description'] == $fldvalue) {
549 echo " selected";
552 echo ">";
553 echo xlt($row['lang_description']);
554 echo "</option>\n";
557 echo " </select>\n";
558 } else if ($fldtype == 'all_code_types') {
559 global $code_types;
560 echo " <select name='form_$i' id='form_$i'>\n";
561 foreach (array_keys($code_types) as $code_key) {
562 echo " <option value='" . attr($code_key) . "'";
563 if ($code_key == $fldvalue) {
564 echo " selected";
567 echo ">";
568 echo xlt($code_types[$code_key]['label']);
569 echo "</option>\n";
572 echo " </select>\n";
573 } else if ($fldtype == 'm_lang') {
574 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
575 echo " <select multiple name='form_{$i}[]' id='form_{$i}[]' size='3'>\n";
576 while ($row = sqlFetchArray($res)) {
577 echo " <option value='" . attr($row['lang_description']) . "'";
578 foreach ($glarr as $glrow) {
579 if ($glrow['gl_value'] == $row['lang_description']) {
580 echo " selected";
581 break;
585 echo ">";
586 echo xlt($row['lang_description']);
587 echo "</option>\n";
590 echo " </select>\n";
591 } else if ($fldtype == 'color_code') {
592 if ($userMode) {
593 $globalTitle = $globalValue;
596 echo " <input type='text' class='color {hash:true}' name='form_$i' id='form_$i' " .
597 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />" .
598 "<input type='button' value='" . xla('Default'). "' onclick=\"document.forms[0].form_$i.color.fromString('" . attr($flddef) . "')\">\n";
599 } else if ($fldtype == 'default_visit_category') {
600 $sql = "SELECT pc_catid, pc_catname, pc_cattype
601 FROM openemr_postcalendar_categories
602 WHERE pc_active = 1 ORDER BY pc_seq";
603 $result = sqlStatement($sql);
604 echo "<select name=\"form_{$i}\" id=\"form_{$i}\">\n";
605 echo "<option value='_blank'>" . xlt('None') . "</option>";
606 while ($row = sqlFetchArray($result)) {
607 $catId = $row['pc_catid'];
608 $name = $row['pc_catname'];
609 if ($catId < 9 && $catId != "5") {
610 continue;
613 if ($row['pc_cattype'] == 3 && !$GLOBALS['enable_group_therapy']) {
614 continue;
617 $optionStr = '<option value="%pc_catid%"%selected%>%pc_catname%</option>';
618 $optionStr = str_replace("%pc_catid%", attr($catId), $optionStr);
619 $optionStr = str_replace("%pc_catname%", text(xl_appt_category($name)), $optionStr);
620 $selected = ($fldvalue == $catId) ? " selected" : "";
621 $optionStr = str_replace("%selected%", $selected, $optionStr);
622 echo $optionStr;
625 echo "</select>";
626 } else if ($fldtype == 'css') {
627 if ($userMode) {
628 $globalTitle = $globalValue;
631 $themedir = "$webserver_root/interface/themes";
632 $dh = opendir($themedir);
633 if ($dh) {
634 echo " <select name='form_$i' id='form_$i'>\n";
635 while (false !== ($tfname = readdir($dh))) {
636 // Only show files that contain style_ as options
637 // Skip style_blue.css since this is used for
638 // lone scripts such as setup.php
639 // Also skip style_pdf.css which is for PDFs and not screen output
640 if (!preg_match("/^style_.*\.css$/", $tfname) ||
641 $tfname == 'style_blue.css' || $tfname == 'style_pdf.css') {
642 continue;
645 echo "<option value='" . attr($tfname) . "'";
646 // Drop the "style_" part and any replace any underscores with spaces
647 $styleDisplayName = str_replace("_", " ", substr($tfname, 6));
648 // Strip the ".css" and uppercase the first character
649 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
650 if ($tfname == $fldvalue) {
651 echo " selected";
654 echo ">";
655 echo text($styleDisplayName);
656 echo "</option>\n";
659 closedir($dh);
660 echo " </select>\n";
662 } else if ($fldtype == 'tabs_css') {
663 if ($userMode) {
664 $globalTitle = $globalValue;
667 $themedir = "$webserver_root/interface/themes";
668 $dh = opendir($themedir);
669 if ($dh) {
670 echo " <select name='form_$i' id='form_$i'>\n";
671 while (false !== ($tfname = readdir($dh))) {
672 // Only show files that contain tabs_style_ as options
673 if (!preg_match("/^tabs_style_.*\.css$/", $tfname)) {
674 continue;
677 echo "<option value='" . attr($tfname) . "'";
678 // Drop the "tabs_style_" part and any replace any underscores with spaces
679 $styleDisplayName = str_replace("_", " ", substr($tfname, 11));
680 // Strip the ".css" and uppercase the first character
681 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
682 if ($tfname == $fldvalue) {
683 echo " selected";
686 echo ">";
687 echo text($styleDisplayName);
688 echo "</option>\n";
691 closedir($dh);
692 echo " </select>\n";
694 } else if ($fldtype == 'hour') {
695 if ($userMode) {
696 $globalTitle = $globalValue;
699 echo " <select name='form_$i' id='form_$i'>\n";
700 for ($h = 0; $h < 24; ++$h) {
701 echo "<option value='$h'";
702 if ($h == $fldvalue) {
703 echo " selected";
706 echo ">";
707 if ($h == 0) {
708 echo "12 AM";
709 } else if ($h < 12) {
710 echo "$h AM";
711 } else if ($h == 12) {
712 echo "12 PM";
713 } else {
714 echo ($h - 12) . " PM";
717 echo "</option>\n";
720 echo " </select>\n";
723 if ($userMode) {
724 echo " </td>\n";
725 echo "<td align='center' style='color:red;'>" . attr($globalTitle) . "</td>\n";
726 echo "<td>&nbsp</td>";
727 echo "<td align='center'><input type='checkbox' value='YES' name='toggle_" . $i . "' id='toggle_" . $i . "' " . attr($settingDefault) . "/></td>\n";
728 echo "<input type='hidden' id='globaldefault_" . $i . "' value='" . attr($globalValue) . "'>\n";
729 echo "</tr>\n";
730 } else {
731 echo " </td></tr>\n";
734 ++$i;
737 if (trim(strtolower($fldid)) == 'portal_offsite_address_patient_link' && !empty($GLOBALS['portal_offsite_enable']) && !empty($GLOBALS['portal_offsite_providerid'])) {
738 echo "<input type='hidden' name='form_download' id='form_download'>";
739 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>";
743 echo " </table>\n";
744 echo " </div>\n";
748 </div>
751 <input type='submit' name='form_save' value='<?php echo xla('Save'); ?>' />
752 </p>
753 </center>
755 </form>
757 </body>
759 <script language="JavaScript">
761 $(document).ready(function(){
762 tabbify();
763 enable_modals();
765 <?php // mdsupport - Highlight search results ?>
766 $('.srch td').wrapInner("<mark></mark>");
767 $('.tab > table').find('tr.srch:first').each(function() {
768 var srch_div = $(this).closest('div').prevAll().length + 1;
769 $('.tabNav > li:nth-child('+srch_div+') a').wrapInner("<mark></mark>");
771 // Use the counter ($i) to make the form user friendly for user-specific globals use
772 <?php if ($userMode) { ?>
773 <?php for ($j = 0; $j <= $i; $j++) { ?>
774 $("#form_<?php echo $j ?>").change(function() {
775 $("#toggle_<?php echo $j ?>").attr('checked',false);
777 $("#toggle_<?php echo $j ?>").change(function() {
778 if ($('#toggle_<?php echo $j ?>').attr('checked')) {
779 var defaultGlobal = $("#globaldefault_<?php echo $j ?>").val();
780 $("#form_<?php echo $j ?>").val(defaultGlobal);
783 <?php } ?>
784 <?php } ?>
788 </script>
790 </html>