quick minor path updates (#1968)
[openemr.git] / interface / super / edit_globals.php
blob7ca646d07bd9da2a44705b3b159a786ed59bb44f
1 <?php
2 /**
3 * Script for the globals editor.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2010 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2016-2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("../../custom/code_types.inc.php");
17 require_once("$srcdir/acl.inc");
18 require_once("$srcdir/globals.inc.php");
19 require_once("$srcdir/user.inc");
20 require_once("$srcdir/log.inc");
21 require_once(dirname(__FILE__)."/../../myportal/soap_service/portal_connectivity.php");
23 use OpenEMR\Core\Header;
25 $userMode = (array_key_exists('mode', $_GET) && $_GET['mode'] == 'user');
27 if (!$userMode) {
28 // Check authorization.
29 $thisauth = acl_check('admin', 'super');
30 if (!$thisauth) {
31 die(xlt('Not authorized'));
35 function checkCreateCDB()
37 $globalsres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
38 ('couchdb_host','couchdb_user','couchdb_pass','couchdb_port','couchdb_dbase','document_storage_method')");
39 $options = array();
40 while ($globalsrow = sqlFetchArray($globalsres)) {
41 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
44 $directory_created = false;
45 if (!empty($GLOBALS['document_storage_method'])) {
46 // /documents/temp/ folder is required for CouchDB
47 if (!is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/')) {
48 $directory_created = mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/', 0777, true);
49 if (!$directory_created) {
50 echo xlt("Failed to create temporary folder. CouchDB will not work.");
54 $couch = new CouchDB();
55 if (!$couch->check_connection()) {
56 echo "<script type='text/javascript'>alert('".addslashes(xl("CouchDB Connection Failed."))."');</script>";
57 return false;
60 if ($GLOBALS['couchdb_host'] || $GLOBALS['couchdb_port'] || $GLOBALS['couchdb_dbase']) {
61 $couch->createDB($GLOBALS['couchdb_dbase']);
62 $couch->createView($GLOBALS['couchdb_dbase']);
66 return true;
69 /**
70 * Update background_services table for a specific service following globals save.
71 * @author EMR Direct
73 function updateBackgroundService($name, $active, $interval)
75 //order important here: next_run change dependent on _old_ value of execute_interval so it comes first
76 $sql = 'UPDATE background_services SET active=?, '
77 . 'next_run = next_run + INTERVAL (? - execute_interval) MINUTE, execute_interval=? WHERE name=?';
78 return sqlStatement($sql, array($active,$interval,$interval,$name));
81 /**
82 * Make any necessary changes to background_services table when globals are saved.
83 * To prevent an unexpected service call during startup or shutdown, follow these rules:
84 * 1. Any "startup" operations should occur _before_ the updateBackgroundService() call.
85 * 2. Any "shutdown" operations should occur _after_ the updateBackgroundService() call. If these operations
86 * would cause errors in a running service call, it would be best to make the shutdown function itself is
87 * a background service that is activated here, does nothing if active=1 or running=1 for the
88 * parent service. Then it deactivates itself by setting active=0 when it is done shutting the parent service
89 * down. This will prevent non-responsiveness to the user by waiting for a service to finish.
90 * 3. If any "previous" values for globals are required for startup/shutdown logic, they need to be
91 * copied to a temp variable before the while($globalsrow...) loop.
92 * @author EMR Direct
94 function checkBackgroundServices()
96 //load up any necessary globals
97 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
98 ('phimail_enable','phimail_interval')");
99 while ($globalsrow = sqlFetchArray($bgservices)) {
100 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
103 //Set up phimail service
104 $phimail_active = empty($GLOBALS['phimail_enable']) ? '0' : '1';
105 $phimail_interval = max(0, (int) $GLOBALS['phimail_interval']);
106 updateBackgroundService('phimail', $phimail_active, $phimail_interval);
110 <html>
112 <head>
113 <?php
115 // If we are saving user_specific globals.
117 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && $userMode) {
118 //verify csrf
119 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
120 csrfNotVerified();
123 $i = 0;
124 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
125 if (in_array($grpname, $USER_SPECIFIC_TABS)) {
126 foreach ($grparr as $fldid => $fldarr) {
127 if (in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
128 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
129 $label = "global:".$fldid;
130 $fldvalue = trim($_POST["form_$i"]);
131 setUserSetting($label, $fldvalue, $_SESSION['authId'], false);
132 if ($_POST["toggle_$i"] == "YES") {
133 removeUserSetting($label);
136 ++$i;
142 echo "<script type='text/javascript'>";
143 echo "if (parent.left_nav.location) {";
144 echo " parent.left_nav.location.reload();";
145 echo " parent.Title.location.reload();";
146 echo " if(self.name=='RTop'){";
147 echo " parent.RBot.location.reload();";
148 echo " }else{";
149 echo " parent.RTop.location.reload();";
150 echo " }";
151 echo "}";
152 echo "self.location.href='edit_globals.php?mode=user&unique=yes';";
153 echo "</script>";
156 if (array_key_exists('form_download', $_POST) && $_POST['form_download']) {
157 //verify csrf
158 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
159 csrfNotVerified();
162 $client = portal_connection();
163 try {
164 $response = $client->getPortalConnectionFiles($credentials);
165 } catch (SoapFault $e) {
166 error_log('SoapFault Error');
167 error_log(var_dump(get_object_vars($e)));
168 } catch (Exception $e) {
169 error_log('Exception Error');
170 error_log(var_dump(get_object_vars($e)));
173 if (array_key_exists('status', $response) && $response['status'] == "1") {//WEBSERVICE RETURNED VALUE SUCCESSFULLY
174 $tmpfilename = realpath(sys_get_temp_dir())."/".date('YmdHis').".zip";
175 $fp = fopen($tmpfilename, "wb");
176 fwrite($fp, base64_decode($response['value']));
177 fclose($fp);
178 $practice_filename = $response['file_name'];//practicename.zip
179 ob_clean();
180 // Set headers
181 header("Cache-Control: public");
182 header("Content-Description: File Transfer");
183 header("Content-Disposition: attachment; filename=".$practice_filename);
184 header("Content-Type: application/zip");
185 header("Content-Transfer-Encoding: binary");
186 // Read the file from disk
187 readfile($tmpfilename);
188 unlink($tmpfilename);
189 exit;
190 } else {//WEBSERVICE CALL FAILED AND RETURNED AN ERROR MESSAGE
191 ob_end_clean();
193 <script type="text/javascript">
194 alert('<?php echo xls('Offsite Portal web Service Failed').":\\n".text($response['value']);?>');
195 </script>
196 <?php
201 <?php
203 // If we are saving main globals.
205 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && !$userMode) {
206 //verify csrf
207 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
208 csrfNotVerified();
211 $force_off_enable_auditlog_encryption = true;
212 // Need to force enable_auditlog_encryption off if the php openssl module
213 // is not installed or the AES-256-CBC cipher is not available.
214 if (extension_loaded('openssl') && in_array('AES-256-CBC', openssl_get_cipher_methods())) {
215 $force_off_enable_auditlog_encryption = false;
218 // Aug 22, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
219 // Check the current status of Audit Logging
220 $auditLogStatusFieldOld = $GLOBALS['enable_auditlog'];
223 * Compare form values with old database values.
224 * Only save if values differ. Improves speed.
227 // Get all the globals from DB
228 $old_globals = sqlGetAssoc('SELECT gl_name, gl_index, gl_value FROM `globals` ORDER BY gl_name, gl_index', false, true);
230 $i = 0;
231 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
232 foreach ($grparr as $fldid => $fldarr) {
233 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
234 if ($fldtype == 'pwd') {
235 $pass = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array($fldid));
236 $fldvalueold = $pass['gl_value'];
239 /* Multiple choice fields - do not compare , overwrite */
240 if (!is_array($fldtype) && substr($fldtype, 0, 2) == 'm_') {
241 if (isset($_POST["form_$i"])) {
242 $fldindex = 0;
244 sqlStatement("DELETE FROM globals WHERE gl_name = ?", array( $fldid ));
246 foreach ($_POST["form_$i"] as $fldvalue) {
247 $fldvalue = trim($fldvalue);
248 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?,?,?)', array( $fldid, $fldindex, $fldvalue ));
249 ++$fldindex;
252 } else {
253 /* check value of single field. Don't update if the database holds the same value */
254 if (isset($_POST["form_$i"])) {
255 $fldvalue = trim($_POST["form_$i"]);
256 } else {
257 $fldvalue = "";
260 if ($fldtype=='pwd') {
261 $fldvalue = $fldvalue ? SHA1($fldvalue) : $fldvalueold; // TODO: salted passwords?
264 // We rely on the fact that set of keys in globals.inc === set of keys in `globals` table!
266 if (!isset($old_globals[$fldid]) // if the key not found in database - update database
268 ( isset($old_globals[$fldid]) && $old_globals[ $fldid ]['gl_value'] !== $fldvalue ) // if the value in database is different
270 // Need to force enable_auditlog_encryption off if the php openssl module
271 // is not installed or the AES-256-CBC cipher is not available.
272 if ($force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption")) {
273 error_log("OPENEMR ERROR: UNABLE to support auditlog encryption since the php openssl module is not installed or the AES-256-CBC cipher is not available", 0);
274 $fldvalue=0;
276 if (!$force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption") && ($fldvalue==1)) {
277 // Run below function to set up the encryption key
278 aes256PrepKey();
281 // special treatment for some vars
282 switch ($fldid) {
283 case 'first_day_week':
284 // update PostCalendar config as well
285 sqlStatement("UPDATE openemr_module_vars SET pn_value = ? WHERE pn_name = 'pcFirstDayOfWeek'", array($fldvalue));
286 break;
289 // Replace old values
290 sqlStatement('DELETE FROM `globals` WHERE gl_name = ?', array( $fldid ));
291 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?, ?, ? )', array( $fldid, 0, $fldvalue ));
292 } else {
293 //error_log("No need to update $fldid");
297 ++$i;
301 checkCreateCDB();
302 checkBackgroundServices();
304 // July 1, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
305 // If Audit Logging status has changed, log it.
306 $auditLogStatusNew = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'enable_auditlog'");
307 $auditLogStatusFieldNew = $auditLogStatusNew['gl_value'];
308 if ($auditLogStatusFieldOld != $auditLogStatusFieldNew) {
309 auditSQLAuditTamper($auditLogStatusFieldNew);
312 echo "<script type='text/javascript'>";
313 echo "if (parent.left_nav.location) {";
314 echo " parent.left_nav.location.reload();";
315 echo " parent.Title.location.reload();";
316 echo " if(self.name=='RTop'){";
317 echo " parent.RBot.location.reload();";
318 echo " }else{";
319 echo " parent.RTop.location.reload();";
320 echo " }";
321 echo "}";
322 echo "self.location.href='edit_globals.php?unique=yes';";
323 echo "</script>";
327 <?php if ($userMode) { ?>
328 <title><?php echo xlt('User Settings'); ?></title>
329 <?php } else { ?>
330 <title><?php echo xlt('Global Settings'); ?></title>
331 <?php } ?>
333 <?php Header::setupHeader(['common','jscolor']); ?>
335 <script type="text/javascript">
336 function validate_file(){
337 $.ajax({
338 type: "POST",
339 url: "<?php echo $GLOBALS['webroot']?>/library/ajax/offsite_portal_ajax.php",
340 data: {
341 csrf_token_form: '<?php echo attr(collectCsrfToken()); ?>',
342 action: 'check_file'
344 cache: false,
345 success: function( message )
347 if(message == 'OK'){
348 document.getElementById('form_download').value = 1;
349 document.getElementById('file_error_message').innerHTML = '';
350 document.forms[0].submit();
352 else{
353 document.getElementById('form_download').value = 0;
354 document.getElementById('file_error_message').innerHTML = message;
355 return false;
360 </script>
361 </head>
363 <?php if ($userMode) { ?>
364 <body class="body_top" style="min-width: 700px;">
365 <?php } else { ?>
366 <div class="body_top">
367 <?php } ?>
369 <?php if ($userMode) { ?>
370 <form method='post' name='theform' id='theform' class='form-horizontal' action='edit_globals.php?mode=user' onsubmit='return top.restoreSession()'>
371 <?php } else { ?>
372 <form method='post' name='theform' id='theform' class='form-horizontal' action='edit_globals.php' onsubmit='return top.restoreSession()'>
373 <?php } ?>
374 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
376 <div class="container">
377 <div class="row">
378 <div class="col-xs-12">
379 <div class="form-group">
380 <?php if ($userMode) { ?>
381 <h3><?php echo xlt('Edit User Settings'); ?></h3>
382 <?php } else { ?>
383 <h3><?php echo xlt('Edit Global Settings'); ?></h3>
384 <?php } ?>
385 </div>
386 </div>
387 </div>
388 <div class="row">
389 <div class="col-xs-12">
390 <div class="form-group">
391 <button type='submit' class='btn btn-default btn-save' name='form_save' value='<?php echo xla('Save'); ?>'><?php echo xlt('Save'); ?></button>
392 <div class="form-inline pull-right">
393 <?php // mdsupport - Optional server based searching mechanism for large number of fields on this screen. ?>
394 <button type='submit' class='btn btn-default btn-search' id='globals_form_search' name='form_search'><?php echo xlt('Search'); ?></button>
395 <input name='srch_desc' class='form-control' type='text' value='<?php echo (!empty($_POST['srch_desc']) ? attr($_POST['srch_desc']) : '') ?>' />
396 </div>
397 </div>
398 </div>
399 </div>
400 </div>
402 <ul class="tabNav">
403 <?php
404 $i = 0;
405 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
406 if (!$userMode || in_array($grpname, $USER_SPECIFIC_TABS)) {
407 echo " <li" . ($i ? "" : " class='current'") .
408 "><a href='#'>" .
409 xlt($grpname) . "</a></li>\n";
410 ++$i;
414 </ul>
416 <div class="tabContainer">
417 <?php
418 $i = 0;
419 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
420 if (!$userMode || in_array($grpname, $USER_SPECIFIC_TABS)) {
421 echo " <div class='tab" . ($i ? "" : " current") .
422 "' style='height:auto;width:97%;'>\n";
424 echo "<div class='container'>";
426 if ($userMode) {
427 echo "<div class='row'>";
428 echo "<div class='col-xs-5'>&nbsp</div>";
429 echo "<div class='col-xs-4'><b>" . xlt('User Specific Setting') . "</b></div>";
430 echo "<div class='col-xs-2'><b>" . xlt('Default Setting') . "</b></div>";
431 echo "<div class='col-xs-1'><b>" . xlt('Default') . "</b></div>";
432 echo "</div>";
435 foreach ($grparr as $fldid => $fldarr) {
436 if (!$userMode || in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
437 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
438 // mdsupport - Check for matches
439 $srch_cl = '';
440 if (!empty($_POST['srch_desc']) && (stristr(($fldname.$flddesc), $_POST['srch_desc']) !== false)) {
441 $srch_cl = ' srch';
444 // Most parameters will have a single value, but some will be arrays.
445 // Here we cater to both possibilities.
446 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
447 "gl_name = ? ORDER BY gl_index", array($fldid));
448 $glarr = array();
449 while ($glrow = sqlFetchArray($glres)) {
450 $glarr[] = $glrow;
453 // $fldvalue is meaningful only for the single-value cases.
454 $fldvalue = count($glarr) ? $glarr[0]['gl_value'] : $flddef;
456 // Collect user specific setting if mode set to user
457 $userSetting = "";
458 $settingDefault = "checked='checked'";
459 if ($userMode) {
460 $userSettingArray = sqlQuery("SELECT * FROM user_settings WHERE setting_user=? AND setting_label=?", array($_SESSION['authId'],"global:".$fldid));
461 $userSetting = $userSettingArray['setting_value'];
462 $globalValue = $fldvalue;
463 if (!empty($userSettingArray)) {
464 $fldvalue = $userSetting;
465 $settingDefault = "";
469 if ($userMode) {
470 echo " <div class='row" . $srch_cl . "' title='" . attr($flddesc) . "'><div class='col-xs-5 control-label'><b>" . text($fldname) . "</b></div><div class='col-xs-4'>\n";
471 } else {
472 echo " <div class='row" . $srch_cl . "' title='" . attr($flddesc) . "'><div class='col-sm-5 control-label'><b>" . text($fldname) . "</b></div><div class='col-sm-6'>\n";
475 if (is_array($fldtype)) {
476 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
477 foreach ($fldtype as $key => $value) {
478 if ($userMode) {
479 if ($globalValue == $key) {
480 $globalTitle = $value;
484 echo " <option value='" . attr($key) . "'";
486 //Casting value to string so the comparison will be always the same type and the only thing that will check is the value
487 //Tried to use === but it will fail in already existing variables
488 if ((string)$key == (string)$fldvalue) {
489 echo " selected";
492 echo ">";
493 echo text($value);
494 echo "</option>\n";
497 echo " </select>\n";
498 } else if ($fldtype == 'bool') {
499 if ($userMode) {
500 if ($globalValue == 1) {
501 $globalTitle = xlt('Checked');
502 } else {
503 $globalTitle = xlt('Not Checked');
507 echo " <input type='checkbox' class='checkbox' name='form_$i' id='form_$i' value='1'";
508 if ($fldvalue) {
509 echo " checked";
512 echo " />\n";
513 } else if ($fldtype == 'num') {
514 if ($userMode) {
515 $globalTitle = $globalValue;
518 echo " <input type='text' class='form-control' name='form_$i' id='form_$i' " .
519 "maxlength='15' value='" . attr($fldvalue) . "' />\n";
520 } else if ($fldtype == 'text') {
521 if ($userMode) {
522 $globalTitle = $globalValue;
525 echo " <input type='text' class='form-control' name='form_$i' id='form_$i' " .
526 "maxlength='255' value='" . attr($fldvalue) . "' />\n";
527 } else if ($fldtype == 'pwd') {
528 if ($userMode) {
529 $globalTitle = $globalValue;
532 echo " <input type='password' class='form-control' name='form_$i' " .
533 "maxlength='255' value='' />\n";
534 } else if ($fldtype == 'pass') {
535 if ($userMode) {
536 $globalTitle = $globalValue;
539 echo " <input type='password' class='form-control' name='form_$i' " .
540 "maxlength='255' value='" . attr($fldvalue) . "' />\n";
541 } else if ($fldtype == 'lang') {
542 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
543 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
544 while ($row = sqlFetchArray($res)) {
545 echo " <option value='" . attr($row['lang_description']) . "'";
546 if ($row['lang_description'] == $fldvalue) {
547 echo " selected";
550 echo ">";
551 echo xlt($row['lang_description']);
552 echo "</option>\n";
555 echo " </select>\n";
556 } else if ($fldtype == 'all_code_types') {
557 global $code_types;
558 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
559 foreach (array_keys($code_types) as $code_key) {
560 echo " <option value='" . attr($code_key) . "'";
561 if ($code_key == $fldvalue) {
562 echo " selected";
565 echo ">";
566 echo xlt($code_types[$code_key]['label']);
567 echo "</option>\n";
570 echo " </select>\n";
571 } else if ($fldtype == 'm_lang') {
572 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
573 echo " <select multiple class='form-control' name='form_{$i}[]' id='form_{$i}[]' size='3'>\n";
574 while ($row = sqlFetchArray($res)) {
575 echo " <option value='" . attr($row['lang_description']) . "'";
576 foreach ($glarr as $glrow) {
577 if ($glrow['gl_value'] == $row['lang_description']) {
578 echo " selected";
579 break;
583 echo ">";
584 echo xlt($row['lang_description']);
585 echo "</option>\n";
588 echo " </select>\n";
589 } else if ($fldtype == 'color_code') {
590 if ($userMode) {
591 $globalTitle = $globalValue;
594 echo " <input type='text' class='form-control jscolor {hash:true}' name='form_$i' id='form_$i' " .
595 "maxlength='15' value='" . attr($fldvalue) . "' />" .
596 "<input type='button' value='" . xla('Default'). "' onclick=\"document.forms[0].form_$i.jscolor.fromString('" . attr($flddef) . "')\">\n";
597 } else if ($fldtype == 'default_visit_category') {
598 $sql = "SELECT pc_catid, pc_catname, pc_cattype
599 FROM openemr_postcalendar_categories
600 WHERE pc_active = 1 ORDER BY pc_seq";
601 $result = sqlStatement($sql);
602 echo "<select class='form-control' name='form_{$i}' id='form_{$i}'>\n";
603 echo "<option value='_blank'>" . xlt('None') . "</option>";
604 while ($row = sqlFetchArray($result)) {
605 $catId = $row['pc_catid'];
606 $name = $row['pc_catname'];
607 if ($catId < 9 && $catId != "5") {
608 continue;
611 if ($row['pc_cattype'] == 3 && !$GLOBALS['enable_group_therapy']) {
612 continue;
615 $optionStr = '<option value="%pc_catid%"%selected%>%pc_catname%</option>';
616 $optionStr = str_replace("%pc_catid%", attr($catId), $optionStr);
617 $optionStr = str_replace("%pc_catname%", text(xl_appt_category($name)), $optionStr);
618 $selected = ($fldvalue == $catId) ? " selected" : "";
619 $optionStr = str_replace("%selected%", $selected, $optionStr);
620 echo $optionStr;
623 echo "</select>";
624 } else if ($fldtype == 'css' || $fldtype == 'tabs_css') {
625 if ($userMode) {
626 $globalTitle = $globalValue;
628 $themedir = "$webserver_root/public/themes";
629 $dh = opendir($themedir);
630 if ($dh) {
631 // Collect styles
632 $styleArray = array();
633 while (false !== ($tfname = readdir($dh))) {
634 // Only show files that contain tabs_style_ or style_ as options
635 if ($fldtype == 'tabs_css') {
636 $patternStyle = 'tabs_style_';
637 } else { // $fldtype == 'css'
638 $patternStyle = 'style_';
640 if ($tfname == 'style_blue.css' ||
641 $tfname == 'style_pdf.css' ||
642 !preg_match("/^" . $patternStyle . ".*\.css$/", $tfname)) {
643 continue;
646 if ($fldtype == 'tabs_css') {
647 // Drop the "tabs_style_" part and any replace any underscores with spaces
648 $styleDisplayName = str_replace("_", " ", substr($tfname, 11));
649 } else { // $fldtype == 'css'
650 // Drop the "style_" part and any replace any underscores with spaces
651 $styleDisplayName = str_replace("_", " ", substr($tfname, 6));
653 // Strip the ".css" and uppercase the first character
654 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
656 $styleArray[$tfname] = $styleDisplayName;
658 // Alphabetize styles
659 asort($styleArray);
660 // Generate style selector
661 echo "<select class='form-control' name='form_$i' id='form_$i'>\n";
662 foreach ($styleArray as $styleKey => $styleValue) {
663 echo "<option value='" . attr($styleKey) . "'";
664 if ($styleKey == $fldvalue) {
665 echo " selected";
667 echo ">";
668 echo text($styleValue);
669 echo "</option>\n";
671 echo "</select>\n";
673 closedir($dh);
674 } else if ($fldtype == 'hour') {
675 if ($userMode) {
676 $globalTitle = $globalValue;
679 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
680 for ($h = 0; $h < 24; ++$h) {
681 echo "<option value='$h'";
682 if ($h == $fldvalue) {
683 echo " selected";
686 echo ">";
687 if ($h == 0) {
688 echo "12 AM";
689 } else if ($h < 12) {
690 echo "$h AM";
691 } else if ($h == 12) {
692 echo "12 PM";
693 } else {
694 echo ($h - 12) . " PM";
697 echo "</option>\n";
700 echo " </select>\n";
703 if ($userMode) {
704 echo " </div>\n";
705 echo "<div class='col-xs-2' style='color:red;'>" . attr($globalTitle) . "</div>\n";
706 echo "<div class='col-xs-1'><input type='checkbox' value='YES' name='toggle_" . $i . "' id='toggle_" . $i . "' " . attr($settingDefault) . "/></div>\n";
707 echo "<input type='hidden' id='globaldefault_" . $i . "' value='" . attr($globalValue) . "'>\n";
708 echo "</div>\n";
709 } else {
710 echo " </div></div>\n";
713 ++$i;
716 if (trim(strtolower($fldid)) == 'portal_offsite_address_patient_link' && !empty($GLOBALS['portal_offsite_enable']) && !empty($GLOBALS['portal_offsite_providerid'])) {
717 echo "<div class='row'>";
718 echo "<div class='col-xs-12'>";
719 echo "<input type='hidden' name='form_download' id='form_download'>";
720 echo "<button onclick=\"return validate_file()\" type='button'>" . xla('Download Offsite Portal Connection Files') . "</button>";
721 echo "<div id='file_error_message' class='alert alert-error'></div>";
722 echo "</div>";
723 echo "</div>";
727 echo " </div>\n";
728 echo " </div>\n";
732 </div>
734 </form>
736 </div>
737 </body>
739 <script language="JavaScript">
741 $(document).ready(function(){
742 tabbify();
744 <?php // mdsupport - Highlight search results ?>
745 $('.srch div').wrapInner("<mark></mark>");
746 $('.tab .row.srch :first-child').closest('.tab').each(function() {
747 $('.tabNav li:nth-child('+($(this).index()+1)+') a').wrapInner("<mark></mark>");
749 // Use the counter ($i) to make the form user friendly for user-specific globals use
750 <?php if ($userMode) { ?>
751 <?php for ($j = 0; $j <= $i; $j++) { ?>
752 $("#form_<?php echo $j ?>").change(function() {
753 $("#toggle_<?php echo $j ?>").prop('checked',false);
755 $("#toggle_<?php echo $j ?>").change(function() {
756 if ($('#toggle_<?php echo $j ?>').prop('checked')) {
757 var defaultGlobal = $("#globaldefault_<?php echo $j ?>").val();
758 $("#form_<?php echo $j ?>").val(defaultGlobal);
761 <?php } ?>
762 <?php } ?>
766 </script>
768 </html>