globals convert to responsive bootstrap, step 1
[openemr.git] / interface / super / edit_globals.php
blob65be1baa9c10d08a5213ffe3c5d3c4bcaeb5cd97
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(dirname(__FILE__)."/../../myportal/soap_service/portal_connectivity.php");
21 use OpenEMR\Core\Header;
23 $userMode = (array_key_exists('mode', $_GET) && $_GET['mode'] == 'user');
25 if (!$userMode) {
26 // Check authorization.
27 $thisauth = acl_check('admin', 'super');
28 if (!$thisauth) {
29 die(xlt('Not authorized'));
33 function checkCreateCDB()
35 $globalsres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
36 ('couchdb_host','couchdb_user','couchdb_pass','couchdb_port','couchdb_dbase','document_storage_method')");
37 $options = array();
38 while ($globalsrow = sqlFetchArray($globalsres)) {
39 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
42 $directory_created = false;
43 if (!empty($GLOBALS['document_storage_method'])) {
44 // /documents/temp/ folder is required for CouchDB
45 if (!is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/')) {
46 $directory_created = mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/', 0777, true);
47 if (!$directory_created) {
48 echo xlt("Failed to create temporary folder. CouchDB will not work.");
52 $couch = new CouchDB();
53 if (!$couch->check_connection()) {
54 echo "<script type='text/javascript'>alert('".addslashes(xl("CouchDB Connection Failed."))."');</script>";
55 return false;
58 if ($GLOBALS['couchdb_host'] || $GLOBALS['couchdb_port'] || $GLOBALS['couchdb_dbase']) {
59 $couch->createDB($GLOBALS['couchdb_dbase']);
60 $couch->createView($GLOBALS['couchdb_dbase']);
64 return true;
67 /**
68 * Update background_services table for a specific service following globals save.
69 * @author EMR Direct
71 function updateBackgroundService($name, $active, $interval)
73 //order important here: next_run change dependent on _old_ value of execute_interval so it comes first
74 $sql = 'UPDATE background_services SET active=?, '
75 . 'next_run = next_run + INTERVAL (? - execute_interval) MINUTE, execute_interval=? WHERE name=?';
76 return sqlStatement($sql, array($active,$interval,$interval,$name));
79 /**
80 * Make any necessary changes to background_services table when globals are saved.
81 * To prevent an unexpected service call during startup or shutdown, follow these rules:
82 * 1. Any "startup" operations should occur _before_ the updateBackgroundService() call.
83 * 2. Any "shutdown" operations should occur _after_ the updateBackgroundService() call. If these operations
84 * would cause errors in a running service call, it would be best to make the shutdown function itself is
85 * a background service that is activated here, does nothing if active=1 or running=1 for the
86 * parent service. Then it deactivates itself by setting active=0 when it is done shutting the parent service
87 * down. This will prevent non-responsiveness to the user by waiting for a service to finish.
88 * 3. If any "previous" values for globals are required for startup/shutdown logic, they need to be
89 * copied to a temp variable before the while($globalsrow...) loop.
90 * @author EMR Direct
92 function checkBackgroundServices()
94 //load up any necessary globals
95 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
96 ('phimail_enable','phimail_interval')");
97 while ($globalsrow = sqlFetchArray($bgservices)) {
98 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
101 //Set up phimail service
102 $phimail_active = empty($GLOBALS['phimail_enable']) ? '0' : '1';
103 $phimail_interval = max(0, (int) $GLOBALS['phimail_interval']);
104 updateBackgroundService('phimail', $phimail_active, $phimail_interval);
106 function handleAltServices($this_serviceid, $gln = '', $sinterval = 1)
108 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name = ?", array($gln));
109 while ($globalsrow = sqlFetchArray($bgservices)) {
110 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
113 $bs_active = empty($GLOBALS[$gln]) ? '0' : '1';
114 $bs_interval = max(0, (int) $sinterval);
115 updateBackgroundService($this_serviceid, $bs_active, $bs_interval);
116 if (!$bs_active && $this_serviceid == 'ccdaservice') {
117 require_once(dirname(__FILE__)."/../../ccdaservice/ssmanager.php");
119 service_shutdown(0);
124 <html>
126 <head>
127 <?php
129 // If we are saving user_specific globals.
131 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && $userMode) {
132 $i = 0;
133 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
134 if (in_array($grpname, $USER_SPECIFIC_TABS)) {
135 foreach ($grparr as $fldid => $fldarr) {
136 if (in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
137 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
138 $label = "global:".$fldid;
139 $fldvalue = trim($_POST["form_$i"]);
140 setUserSetting($label, $fldvalue, $_SESSION['authId'], false);
141 if ($_POST["toggle_$i"] == "YES") {
142 removeUserSetting($label);
145 ++$i;
151 echo "<script type='text/javascript'>";
152 echo "if (parent.left_nav.location) {";
153 echo " parent.left_nav.location.reload();";
154 echo " parent.Title.location.reload();";
155 echo " if(self.name=='RTop'){";
156 echo " parent.RBot.location.reload();";
157 echo " }else{";
158 echo " parent.RTop.location.reload();";
159 echo " }";
160 echo "}";
161 echo "self.location.href='edit_globals.php?mode=user&unique=yes';";
162 echo "</script>";
165 if (array_key_exists('form_download', $_POST) && $_POST['form_download']) {
166 $client = portal_connection();
167 try {
168 $response = $client->getPortalConnectionFiles($credentials);
169 } catch (SoapFault $e) {
170 error_log('SoapFault Error');
171 error_log(var_dump(get_object_vars($e)));
172 } catch (Exception $e) {
173 error_log('Exception Error');
174 error_log(var_dump(get_object_vars($e)));
177 if (array_key_exists('status', $response) && $response['status'] == "1") {//WEBSERVICE RETURNED VALUE SUCCESSFULLY
178 $tmpfilename = realpath(sys_get_temp_dir())."/".date('YmdHis').".zip";
179 $fp = fopen($tmpfilename, "wb");
180 fwrite($fp, base64_decode($response['value']));
181 fclose($fp);
182 $practice_filename = $response['file_name'];//practicename.zip
183 ob_clean();
184 // Set headers
185 header("Cache-Control: public");
186 header("Content-Description: File Transfer");
187 header("Content-Disposition: attachment; filename=".$practice_filename);
188 header("Content-Type: application/zip");
189 header("Content-Transfer-Encoding: binary");
190 // Read the file from disk
191 readfile($tmpfilename);
192 unlink($tmpfilename);
193 exit;
194 } else {//WEBSERVICE CALL FAILED AND RETURNED AN ERROR MESSAGE
195 ob_end_clean();
197 <script type="text/javascript">
198 alert('<?php echo xls('Offsite Portal web Service Failed').":\\n".text($response['value']);?>');
199 </script>
200 <?php
205 <?php
207 // If we are saving main globals.
209 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && !$userMode) {
210 $force_off_enable_auditlog_encryption = true;
211 // Need to force enable_auditlog_encryption off if the php mycrypt module
212 // is not installed.
213 if (extension_loaded('mcrypt')) {
214 $force_off_enable_auditlog_encryption = false;
217 // Aug 22, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
218 // Check the current status of Audit Logging
219 $auditLogStatusFieldOld = $GLOBALS['enable_auditlog'];
222 * Compare form values with old database values.
223 * Only save if values differ. Improves speed.
226 // Get all the globals from DB
227 $old_globals = sqlGetAssoc('SELECT gl_name, gl_index, gl_value FROM `globals` ORDER BY gl_name, gl_index', false, true);
229 $i = 0;
230 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
231 foreach ($grparr as $fldid => $fldarr) {
232 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
233 if ($fldtype == 'pwd') {
234 $pass = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array($fldid));
235 $fldvalueold = $pass['gl_value'];
238 /* Multiple choice fields - do not compare , overwrite */
239 if (!is_array($fldtype) && substr($fldtype, 0, 2) == 'm_') {
240 if (isset($_POST["form_$i"])) {
241 $fldindex = 0;
243 sqlStatement("DELETE FROM globals WHERE gl_name = ?", array( $fldid ));
245 foreach ($_POST["form_$i"] as $fldvalue) {
246 $fldvalue = trim($fldvalue);
247 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?,?,?)', array( $fldid, $fldindex, $fldvalue ));
248 ++$fldindex;
251 } else {
252 /* check value of single field. Don't update if the database holds the same value */
253 if (isset($_POST["form_$i"])) {
254 $fldvalue = trim($_POST["form_$i"]);
255 } else {
256 $fldvalue = "";
259 if ($fldtype=='pwd') {
260 $fldvalue = $fldvalue ? SHA1($fldvalue) : $fldvalueold; // TODO: salted passwords?
263 // We rely on the fact that set of keys in globals.inc === set of keys in `globals` table!
265 if (!isset($old_globals[$fldid]) // if the key not found in database - update database
267 ( isset($old_globals[$fldid]) && $old_globals[ $fldid ]['gl_value'] !== $fldvalue ) // if the value in database is different
269 // Need to force enable_auditlog_encryption off if the php mcrypt module
270 // is not installed.
271 if ($force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption")) {
272 error_log("OPENEMR ERROR: UNABLE to support auditlog encryption since the php mcrypt module is not installed", 0);
273 $fldvalue=0;
276 // special treatment for some vars
277 switch ($fldid) {
278 case 'first_day_week':
279 // update PostCalendar config as well
280 sqlStatement("UPDATE openemr_module_vars SET pn_value = ? WHERE pn_name = 'pcFirstDayOfWeek'", array($fldvalue));
281 break;
284 // Replace old values
285 sqlStatement('DELETE FROM `globals` WHERE gl_name = ?', array( $fldid ));
286 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?, ?, ? )', array( $fldid, 0, $fldvalue ));
287 } else {
288 //error_log("No need to update $fldid");
292 ++$i;
296 checkCreateCDB();
297 checkBackgroundServices();
298 handleAltServices('ccdaservice', 'ccda_alt_service_enable', 1);
300 // July 1, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
301 // If Audit Logging status has changed, log it.
302 $auditLogStatusNew = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'enable_auditlog'");
303 $auditLogStatusFieldNew = $auditLogStatusNew['gl_value'];
304 if ($auditLogStatusFieldOld != $auditLogStatusFieldNew) {
305 auditSQLAuditTamper($auditLogStatusFieldNew);
308 echo "<script type='text/javascript'>";
309 echo "if (parent.left_nav.location) {";
310 echo " parent.left_nav.location.reload();";
311 echo " parent.Title.location.reload();";
312 echo " if(self.name=='RTop'){";
313 echo " parent.RBot.location.reload();";
314 echo " }else{";
315 echo " parent.RTop.location.reload();";
316 echo " }";
317 echo "}";
318 echo "self.location.href='edit_globals.php?unique=yes';";
319 echo "</script>";
323 <?php if ($userMode) { ?>
324 <title><?php echo xlt('User Settings'); ?></title>
325 <?php } else { ?>
326 <title><?php echo xlt('Global Settings'); ?></title>
327 <?php } ?>
329 <?php Header::setupHeader(['common','jscolor']); ?>
331 <script type="text/javascript">
332 function validate_file(){
333 $.ajax({
334 type: "POST",
335 url: "<?php echo $GLOBALS['webroot']?>/library/ajax/offsite_portal_ajax.php",
336 data: {
337 action: 'check_file'
339 cache: false,
340 success: function( message )
342 if(message == 'OK'){
343 document.getElementById('form_download').value = 1;
344 document.getElementById('file_error_message').innerHTML = '';
345 document.forms[0].submit();
347 else{
348 document.getElementById('form_download').value = 0;
349 document.getElementById('file_error_message').innerHTML = message;
350 return false;
355 </script>
356 </head>
358 <?php if ($userMode) { ?>
359 <body class="body_top" style="min-width: 700px;">
360 <?php } else { ?>
361 <div class="body_top">
362 <?php } ?>
364 <?php if ($userMode) { ?>
365 <form method='post' name='theform' id='theform' class='form-horizontal' action='edit_globals.php?mode=user' onsubmit='return top.restoreSession()'>
366 <?php } else { ?>
367 <form method='post' name='theform' id='theform' class='form-horizontal' action='edit_globals.php' onsubmit='return top.restoreSession()'>
368 <?php } ?>
370 <div class="container">
371 <div class="row">
372 <div class="col-xs-12">
373 <div class="form-group">
374 <?php if ($userMode) { ?>
375 <h3><?php echo xlt('Edit User Settings'); ?></h3>
376 <?php } else { ?>
377 <h3><?php echo xlt('Edit Global Settings'); ?></h3>
378 <?php } ?>
379 </div>
380 </div>
381 </div>
382 <div class="row">
383 <div class="col-xs-12">
384 <div class="form-group">
385 <button type='submit' class='btn btn-default btn-save' name='form_save' value='<?php echo xla('Save'); ?>'><?php echo xlt('Save'); ?></button>
386 <div class="form-inline pull-right">
387 <?php // mdsupport - Optional server based searching mechanism for large number of fields on this screen. ?>
388 <button type='submit' class='btn btn-default btn-search' id='globals_form_search' name='form_search'><?php echo xlt('Search'); ?></button>
389 <input name='srch_desc' class='form-control' type='text' value='<?php echo (!empty($_POST['srch_desc']) ? attr($_POST['srch_desc']) : '') ?>' />
390 </div>
391 </div>
392 </div>
393 </div>
394 </div>
396 <ul class="tabNav">
397 <?php
398 $i = 0;
399 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
400 if (!$userMode || in_array($grpname, $USER_SPECIFIC_TABS)) {
401 echo " <li" . ($i ? "" : " class='current'") .
402 "><a href='#'>" .
403 xlt($grpname) . "</a></li>\n";
404 ++$i;
408 </ul>
410 <div class="tabContainer">
411 <?php
412 $i = 0;
413 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
414 if (!$userMode || in_array($grpname, $USER_SPECIFIC_TABS)) {
415 echo " <div class='tab" . ($i ? "" : " current") .
416 "' style='height:auto;width:97%;'>\n";
418 echo "<div class='container'>";
420 if ($userMode) {
421 echo "<div class='row'>";
422 echo "<div class='col-xs-5'>&nbsp</div>";
423 echo "<div class='col-xs-4'><b>" . xlt('User Specific Setting') . "</b></div>";
424 echo "<div class='col-xs-2'><b>" . xlt('Default Setting') . "</b></div>";
425 echo "<div class='col-xs-1'><b>" . xlt('Default') . "</b></div>";
426 echo "</div>";
429 foreach ($grparr as $fldid => $fldarr) {
430 if (!$userMode || in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
431 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
432 // mdsupport - Check for matches
433 $srch_cl = '';
434 if (!empty($_POST['srch_desc']) && (stristr(($fldname.$flddesc), $_POST['srch_desc']) !== false)) {
435 $srch_cl = ' srch';
438 // Most parameters will have a single value, but some will be arrays.
439 // Here we cater to both possibilities.
440 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
441 "gl_name = ? ORDER BY gl_index", array($fldid));
442 $glarr = array();
443 while ($glrow = sqlFetchArray($glres)) {
444 $glarr[] = $glrow;
447 // $fldvalue is meaningful only for the single-value cases.
448 $fldvalue = count($glarr) ? $glarr[0]['gl_value'] : $flddef;
450 // Collect user specific setting if mode set to user
451 $userSetting = "";
452 $settingDefault = "checked='checked'";
453 if ($userMode) {
454 $userSettingArray = sqlQuery("SELECT * FROM user_settings WHERE setting_user=? AND setting_label=?", array($_SESSION['authId'],"global:".$fldid));
455 $userSetting = $userSettingArray['setting_value'];
456 $globalValue = $fldvalue;
457 if (!empty($userSettingArray)) {
458 $fldvalue = $userSetting;
459 $settingDefault = "";
463 if ($userMode) {
464 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";
465 } else {
466 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";
469 if (is_array($fldtype)) {
470 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
471 foreach ($fldtype as $key => $value) {
472 if ($userMode) {
473 if ($globalValue == $key) {
474 $globalTitle = $value;
478 echo " <option value='" . attr($key) . "'";
480 //Casting value to string so the comparison will be always the same type and the only thing that will check is the value
481 //Tried to use === but it will fail in already existing variables
482 if ((string)$key == (string)$fldvalue) {
483 echo " selected";
486 echo ">";
487 echo text($value);
488 echo "</option>\n";
491 echo " </select>\n";
492 } else if ($fldtype == 'bool') {
493 if ($userMode) {
494 if ($globalValue == 1) {
495 $globalTitle = xlt('Checked');
496 } else {
497 $globalTitle = xlt('Not Checked');
501 echo " <input type='checkbox' class='checkbox' name='form_$i' id='form_$i' value='1'";
502 if ($fldvalue) {
503 echo " checked";
506 echo " />\n";
507 } else if ($fldtype == 'num') {
508 if ($userMode) {
509 $globalTitle = $globalValue;
512 echo " <input type='text' class='form-control' name='form_$i' id='form_$i' " .
513 "maxlength='15' value='" . attr($fldvalue) . "' />\n";
514 } else if ($fldtype == 'text') {
515 if ($userMode) {
516 $globalTitle = $globalValue;
519 echo " <input type='text' class='form-control' name='form_$i' id='form_$i' " .
520 "maxlength='255' value='" . attr($fldvalue) . "' />\n";
521 } else if ($fldtype == 'pwd') {
522 if ($userMode) {
523 $globalTitle = $globalValue;
526 echo " <input type='password' class='form-control' name='form_$i' " .
527 "maxlength='255' value='' />\n";
528 } else if ($fldtype == 'pass') {
529 if ($userMode) {
530 $globalTitle = $globalValue;
533 echo " <input type='password' class='form-control' name='form_$i' " .
534 "maxlength='255' value='" . attr($fldvalue) . "' />\n";
535 } else if ($fldtype == 'lang') {
536 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
537 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
538 while ($row = sqlFetchArray($res)) {
539 echo " <option value='" . attr($row['lang_description']) . "'";
540 if ($row['lang_description'] == $fldvalue) {
541 echo " selected";
544 echo ">";
545 echo xlt($row['lang_description']);
546 echo "</option>\n";
549 echo " </select>\n";
550 } else if ($fldtype == 'all_code_types') {
551 global $code_types;
552 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
553 foreach (array_keys($code_types) as $code_key) {
554 echo " <option value='" . attr($code_key) . "'";
555 if ($code_key == $fldvalue) {
556 echo " selected";
559 echo ">";
560 echo xlt($code_types[$code_key]['label']);
561 echo "</option>\n";
564 echo " </select>\n";
565 } else if ($fldtype == 'm_lang') {
566 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
567 echo " <select multiple class='form-control' name='form_{$i}[]' id='form_{$i}[]' size='3'>\n";
568 while ($row = sqlFetchArray($res)) {
569 echo " <option value='" . attr($row['lang_description']) . "'";
570 foreach ($glarr as $glrow) {
571 if ($glrow['gl_value'] == $row['lang_description']) {
572 echo " selected";
573 break;
577 echo ">";
578 echo xlt($row['lang_description']);
579 echo "</option>\n";
582 echo " </select>\n";
583 } else if ($fldtype == 'color_code') {
584 if ($userMode) {
585 $globalTitle = $globalValue;
588 echo " <input type='text' class='form-control jscolor {hash:true}' name='form_$i' id='form_$i' " .
589 "maxlength='15' value='" . attr($fldvalue) . "' />" .
590 "<input type='button' value='" . xla('Default'). "' onclick=\"document.forms[0].form_$i.color.fromString('" . attr($flddef) . "')\">\n";
591 } else if ($fldtype == 'default_visit_category') {
592 $sql = "SELECT pc_catid, pc_catname, pc_cattype
593 FROM openemr_postcalendar_categories
594 WHERE pc_active = 1 ORDER BY pc_seq";
595 $result = sqlStatement($sql);
596 echo "<select class='form-control' name='form_{$i}' id='form_{$i}'>\n";
597 echo "<option value='_blank'>" . xlt('None') . "</option>";
598 while ($row = sqlFetchArray($result)) {
599 $catId = $row['pc_catid'];
600 $name = $row['pc_catname'];
601 if ($catId < 9 && $catId != "5") {
602 continue;
605 if ($row['pc_cattype'] == 3 && !$GLOBALS['enable_group_therapy']) {
606 continue;
609 $optionStr = '<option value="%pc_catid%"%selected%>%pc_catname%</option>';
610 $optionStr = str_replace("%pc_catid%", attr($catId), $optionStr);
611 $optionStr = str_replace("%pc_catname%", text(xl_appt_category($name)), $optionStr);
612 $selected = ($fldvalue == $catId) ? " selected" : "";
613 $optionStr = str_replace("%selected%", $selected, $optionStr);
614 echo $optionStr;
617 echo "</select>";
618 } else if ($fldtype == 'css' || $fldtype == 'tabs_css') {
619 if ($userMode) {
620 $globalTitle = $globalValue;
622 $themedir = "$webserver_root/interface/themes";
623 $dh = opendir($themedir);
624 if ($dh) {
625 // Collect styles
626 $styleArray = array();
627 while (false !== ($tfname = readdir($dh))) {
628 // Only show files that contain tabs_style_ or style_ as options
629 if ($fldtype == 'tabs_css') {
630 $patternStyle = 'tabs_style_';
631 } else { // $fldtype == 'css'
632 $patternStyle = 'style_';
634 if ($tfname == 'style_blue.css' ||
635 $tfname == 'style_pdf.css' ||
636 !preg_match("/^" . $patternStyle . ".*\.css$/", $tfname)) {
637 continue;
640 if ($fldtype == 'tabs_css') {
641 // Drop the "tabs_style_" part and any replace any underscores with spaces
642 $styleDisplayName = str_replace("_", " ", substr($tfname, 11));
643 } else { // $fldtype == 'css'
644 // Drop the "style_" part and any replace any underscores with spaces
645 $styleDisplayName = str_replace("_", " ", substr($tfname, 6));
647 // Strip the ".css" and uppercase the first character
648 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
650 $styleArray[$tfname] = $styleDisplayName;
652 // Alphabetize styles
653 asort($styleArray);
654 // Generate style selector
655 echo "<select class='form-control' name='form_$i' id='form_$i'>\n";
656 foreach ($styleArray as $styleKey => $styleValue) {
657 echo "<option value='" . attr($styleKey) . "'";
658 if ($styleKey == $fldvalue) {
659 echo " selected";
661 echo ">";
662 echo text($styleValue);
663 echo "</option>\n";
665 echo "</select>\n";
667 closedir($dh);
668 } else if ($fldtype == 'hour') {
669 if ($userMode) {
670 $globalTitle = $globalValue;
673 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
674 for ($h = 0; $h < 24; ++$h) {
675 echo "<option value='$h'";
676 if ($h == $fldvalue) {
677 echo " selected";
680 echo ">";
681 if ($h == 0) {
682 echo "12 AM";
683 } else if ($h < 12) {
684 echo "$h AM";
685 } else if ($h == 12) {
686 echo "12 PM";
687 } else {
688 echo ($h - 12) . " PM";
691 echo "</option>\n";
694 echo " </select>\n";
697 if ($userMode) {
698 echo " </div>\n";
699 echo "<div class='col-xs-2' style='color:red;'>" . attr($globalTitle) . "</div>\n";
700 echo "<div class='col-xs-1'><input type='checkbox' value='YES' name='toggle_" . $i . "' id='toggle_" . $i . "' " . attr($settingDefault) . "/></div>\n";
701 echo "<input type='hidden' id='globaldefault_" . $i . "' value='" . attr($globalValue) . "'>\n";
702 echo "</div>\n";
703 } else {
704 echo " </div></div>\n";
707 ++$i;
710 if (trim(strtolower($fldid)) == 'portal_offsite_address_patient_link' && !empty($GLOBALS['portal_offsite_enable']) && !empty($GLOBALS['portal_offsite_providerid'])) {
711 echo "<div class='row'>";
712 echo "<div class='col-xs-12'>";
713 echo "<input type='hidden' name='form_download' id='form_download'>";
714 echo "<button onclick=\"return validate_file()\" type='button'>" . xla('Download Offsite Portal Connection Files') . "</button>";
715 echo "<div id='file_error_message' class='alert alert-error'></div>";
716 echo "</div>";
717 echo "</div>";
721 echo " </div>\n";
722 echo " </div>\n";
726 </div>
728 </form>
730 </div>
731 </body>
733 <script language="JavaScript">
735 $(document).ready(function(){
736 tabbify();
738 <?php // mdsupport - Highlight search results ?>
739 $('.srch div').wrapInner("<mark></mark>");
740 $('.tab > .container').find('div.srch:first').each(function() {
741 var srch_div = $(this).closest('div').prevAll().length + 1;
742 $('.tabNav > li:nth-child('+srch_div+') a').wrapInner("<mark></mark>");
744 // Use the counter ($i) to make the form user friendly for user-specific globals use
745 <?php if ($userMode) { ?>
746 <?php for ($j = 0; $j <= $i; $j++) { ?>
747 $("#form_<?php echo $j ?>").change(function() {
748 $("#toggle_<?php echo $j ?>").prop('checked',false);
750 $("#toggle_<?php echo $j ?>").change(function() {
751 if ($('#toggle_<?php echo $j ?>').prop('checked')) {
752 var defaultGlobal = $("#globaldefault_<?php echo $j ?>").val();
753 $("#form_<?php echo $j ?>").val(defaultGlobal);
756 <?php } ?>
757 <?php } ?>
761 </script>
763 </html>