3 * Script for the globals editor.
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');
28 // Check authorization.
29 $thisauth = acl_check('admin', 'super');
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')");
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>";
60 if ($GLOBALS['couchdb_host'] ||
$GLOBALS['couchdb_port'] ||
$GLOBALS['couchdb_dbase']) {
61 $couch->createDB($GLOBALS['couchdb_dbase']);
62 $couch->createView($GLOBALS['couchdb_dbase']);
70 * Update background_services table for a specific service following globals save.
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));
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.
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);
115 // If we are saving user_specific globals.
117 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && $userMode) {
119 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
120 if (in_array($grpname, $USER_SPECIFIC_TABS)) {
121 foreach ($grparr as $fldid => $fldarr) {
122 if (in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
123 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
124 $label = "global:".$fldid;
125 $fldvalue = trim($_POST["form_$i"]);
126 setUserSetting($label, $fldvalue, $_SESSION['authId'], false);
127 if ($_POST["toggle_$i"] == "YES") {
128 removeUserSetting($label);
137 echo "<script type='text/javascript'>";
138 echo "if (parent.left_nav.location) {";
139 echo " parent.left_nav.location.reload();";
140 echo " parent.Title.location.reload();";
141 echo " if(self.name=='RTop'){";
142 echo " parent.RBot.location.reload();";
144 echo " parent.RTop.location.reload();";
147 echo "self.location.href='edit_globals.php?mode=user&unique=yes';";
151 if (array_key_exists('form_download', $_POST) && $_POST['form_download']) {
152 $client = portal_connection();
154 $response = $client->getPortalConnectionFiles($credentials);
155 } catch (SoapFault
$e) {
156 error_log('SoapFault Error');
157 error_log(var_dump(get_object_vars($e)));
158 } catch (Exception
$e) {
159 error_log('Exception Error');
160 error_log(var_dump(get_object_vars($e)));
163 if (array_key_exists('status', $response) && $response['status'] == "1") {//WEBSERVICE RETURNED VALUE SUCCESSFULLY
164 $tmpfilename = realpath(sys_get_temp_dir())."/".date('YmdHis').".zip";
165 $fp = fopen($tmpfilename, "wb");
166 fwrite($fp, base64_decode($response['value']));
168 $practice_filename = $response['file_name'];//practicename.zip
171 header("Cache-Control: public");
172 header("Content-Description: File Transfer");
173 header("Content-Disposition: attachment; filename=".$practice_filename);
174 header("Content-Type: application/zip");
175 header("Content-Transfer-Encoding: binary");
176 // Read the file from disk
177 readfile($tmpfilename);
178 unlink($tmpfilename);
180 } else {//WEBSERVICE CALL FAILED AND RETURNED AN ERROR MESSAGE
183 <script type
="text/javascript">
184 alert('<?php echo xls('Offsite Portal web Service Failed
').":\\n".text($response['value
']);?>');
193 // If we are saving main globals.
195 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && !$userMode) {
196 $force_off_enable_auditlog_encryption = true;
197 // Need to force enable_auditlog_encryption off if the php openssl module
198 // is not installed or the AES-256-CBC cipher is not available.
199 if (extension_loaded('openssl') && in_array('AES-256-CBC', openssl_get_cipher_methods())) {
200 $force_off_enable_auditlog_encryption = false;
203 // Aug 22, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
204 // Check the current status of Audit Logging
205 $auditLogStatusFieldOld = $GLOBALS['enable_auditlog'];
208 * Compare form values with old database values.
209 * Only save if values differ. Improves speed.
212 // Get all the globals from DB
213 $old_globals = sqlGetAssoc('SELECT gl_name, gl_index, gl_value FROM `globals` ORDER BY gl_name, gl_index', false, true);
216 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
217 foreach ($grparr as $fldid => $fldarr) {
218 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
219 if ($fldtype == 'pwd') {
220 $pass = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array($fldid));
221 $fldvalueold = $pass['gl_value'];
224 /* Multiple choice fields - do not compare , overwrite */
225 if (!is_array($fldtype) && substr($fldtype, 0, 2) == 'm_') {
226 if (isset($_POST["form_$i"])) {
229 sqlStatement("DELETE FROM globals WHERE gl_name = ?", array( $fldid ));
231 foreach ($_POST["form_$i"] as $fldvalue) {
232 $fldvalue = trim($fldvalue);
233 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?,?,?)', array( $fldid, $fldindex, $fldvalue ));
238 /* check value of single field. Don't update if the database holds the same value */
239 if (isset($_POST["form_$i"])) {
240 $fldvalue = trim($_POST["form_$i"]);
245 if ($fldtype=='pwd') {
246 $fldvalue = $fldvalue ?
SHA1($fldvalue) : $fldvalueold; // TODO: salted passwords?
249 // We rely on the fact that set of keys in globals.inc === set of keys in `globals` table!
251 if (!isset($old_globals[$fldid]) // if the key not found in database - update database
253 ( isset($old_globals[$fldid]) && $old_globals[ $fldid ]['gl_value'] !== $fldvalue ) // if the value in database is different
255 // Need to force enable_auditlog_encryption off if the php openssl module
256 // is not installed or the AES-256-CBC cipher is not available.
257 if ($force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption")) {
258 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);
261 if (!$force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption") && ($fldvalue==1)) {
262 // Run below function to set up the encryption key
266 // special treatment for some vars
268 case 'first_day_week':
269 // update PostCalendar config as well
270 sqlStatement("UPDATE openemr_module_vars SET pn_value = ? WHERE pn_name = 'pcFirstDayOfWeek'", array($fldvalue));
274 // Replace old values
275 sqlStatement('DELETE FROM `globals` WHERE gl_name = ?', array( $fldid ));
276 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?, ?, ? )', array( $fldid, 0, $fldvalue ));
278 //error_log("No need to update $fldid");
287 checkBackgroundServices();
289 // July 1, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
290 // If Audit Logging status has changed, log it.
291 $auditLogStatusNew = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'enable_auditlog'");
292 $auditLogStatusFieldNew = $auditLogStatusNew['gl_value'];
293 if ($auditLogStatusFieldOld != $auditLogStatusFieldNew) {
294 auditSQLAuditTamper($auditLogStatusFieldNew);
297 echo "<script type='text/javascript'>";
298 echo "if (parent.left_nav.location) {";
299 echo " parent.left_nav.location.reload();";
300 echo " parent.Title.location.reload();";
301 echo " if(self.name=='RTop'){";
302 echo " parent.RBot.location.reload();";
304 echo " parent.RTop.location.reload();";
307 echo "self.location.href='edit_globals.php?unique=yes';";
312 <?php
if ($userMode) { ?
>
313 <title
><?php
echo xlt('User Settings'); ?
></title
>
315 <title
><?php
echo xlt('Global Settings'); ?
></title
>
318 <?php Header
::setupHeader(['common','jscolor']); ?
>
320 <script type
="text/javascript">
321 function validate_file(){
324 url
: "<?php echo $GLOBALS['webroot']?>/library/ajax/offsite_portal_ajax.php",
329 success
: function( message
)
332 document
.getElementById('form_download').value
= 1;
333 document
.getElementById('file_error_message').innerHTML
= '';
334 document
.forms
[0].submit();
337 document
.getElementById('form_download').value
= 0;
338 document
.getElementById('file_error_message').innerHTML
= message
;
347 <?php
if ($userMode) { ?
>
348 <body
class="body_top" style
="min-width: 700px;">
350 <div
class="body_top">
353 <?php
if ($userMode) { ?
>
354 <form method
='post' name
='theform' id
='theform' class='form-horizontal' action
='edit_globals.php?mode=user' onsubmit
='return top.restoreSession()'>
356 <form method
='post' name
='theform' id
='theform' class='form-horizontal' action
='edit_globals.php' onsubmit
='return top.restoreSession()'>
359 <div
class="container">
361 <div
class="col-xs-12">
362 <div
class="form-group">
363 <?php
if ($userMode) { ?
>
364 <h3
><?php
echo xlt('Edit User Settings'); ?
></h3
>
366 <h3
><?php
echo xlt('Edit Global Settings'); ?
></h3
>
372 <div
class="col-xs-12">
373 <div
class="form-group">
374 <button type
='submit' class='btn btn-default btn-save' name
='form_save' value
='<?php echo xla('Save
'); ?>'><?php
echo xlt('Save'); ?
></button
>
375 <div
class="form-inline pull-right">
376 <?php
// mdsupport - Optional server based searching mechanism for large number of fields on this screen. ?>
377 <button type
='submit' class='btn btn-default btn-search' id
='globals_form_search' name
='form_search'><?php
echo xlt('Search'); ?
></button
>
378 <input name
='srch_desc' class='form-control' type
='text' value
='<?php echo (!empty($_POST['srch_desc
']) ? attr($_POST['srch_desc
']) : '') ?>' />
388 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
389 if (!$userMode ||
in_array($grpname, $USER_SPECIFIC_TABS)) {
390 echo " <li" . ($i ?
"" : " class='current'") .
392 xlt($grpname) . "</a></li>\n";
399 <div
class="tabContainer">
402 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
403 if (!$userMode ||
in_array($grpname, $USER_SPECIFIC_TABS)) {
404 echo " <div class='tab" . ($i ?
"" : " current") .
405 "' style='height:auto;width:97%;'>\n";
407 echo "<div class='container'>";
410 echo "<div class='row'>";
411 echo "<div class='col-xs-5'> </div>";
412 echo "<div class='col-xs-4'><b>" . xlt('User Specific Setting') . "</b></div>";
413 echo "<div class='col-xs-2'><b>" . xlt('Default Setting') . "</b></div>";
414 echo "<div class='col-xs-1'><b>" . xlt('Default') . "</b></div>";
418 foreach ($grparr as $fldid => $fldarr) {
419 if (!$userMode ||
in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
420 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
421 // mdsupport - Check for matches
423 if (!empty($_POST['srch_desc']) && (stristr(($fldname.$flddesc), $_POST['srch_desc']) !== false)) {
427 // Most parameters will have a single value, but some will be arrays.
428 // Here we cater to both possibilities.
429 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
430 "gl_name = ? ORDER BY gl_index", array($fldid));
432 while ($glrow = sqlFetchArray($glres)) {
436 // $fldvalue is meaningful only for the single-value cases.
437 $fldvalue = count($glarr) ?
$glarr[0]['gl_value'] : $flddef;
439 // Collect user specific setting if mode set to user
441 $settingDefault = "checked='checked'";
443 $userSettingArray = sqlQuery("SELECT * FROM user_settings WHERE setting_user=? AND setting_label=?", array($_SESSION['authId'],"global:".$fldid));
444 $userSetting = $userSettingArray['setting_value'];
445 $globalValue = $fldvalue;
446 if (!empty($userSettingArray)) {
447 $fldvalue = $userSetting;
448 $settingDefault = "";
453 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";
455 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";
458 if (is_array($fldtype)) {
459 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
460 foreach ($fldtype as $key => $value) {
462 if ($globalValue == $key) {
463 $globalTitle = $value;
467 echo " <option value='" . attr($key) . "'";
469 //Casting value to string so the comparison will be always the same type and the only thing that will check is the value
470 //Tried to use === but it will fail in already existing variables
471 if ((string)$key == (string)$fldvalue) {
481 } else if ($fldtype == 'bool') {
483 if ($globalValue == 1) {
484 $globalTitle = xlt('Checked');
486 $globalTitle = xlt('Not Checked');
490 echo " <input type='checkbox' class='checkbox' name='form_$i' id='form_$i' value='1'";
496 } else if ($fldtype == 'num') {
498 $globalTitle = $globalValue;
501 echo " <input type='text' class='form-control' name='form_$i' id='form_$i' " .
502 "maxlength='15' value='" . attr($fldvalue) . "' />\n";
503 } else if ($fldtype == 'text') {
505 $globalTitle = $globalValue;
508 echo " <input type='text' class='form-control' name='form_$i' id='form_$i' " .
509 "maxlength='255' value='" . attr($fldvalue) . "' />\n";
510 } else if ($fldtype == 'pwd') {
512 $globalTitle = $globalValue;
515 echo " <input type='password' class='form-control' name='form_$i' " .
516 "maxlength='255' value='' />\n";
517 } else if ($fldtype == 'pass') {
519 $globalTitle = $globalValue;
522 echo " <input type='password' class='form-control' name='form_$i' " .
523 "maxlength='255' value='" . attr($fldvalue) . "' />\n";
524 } else if ($fldtype == 'lang') {
525 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
526 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
527 while ($row = sqlFetchArray($res)) {
528 echo " <option value='" . attr($row['lang_description']) . "'";
529 if ($row['lang_description'] == $fldvalue) {
534 echo xlt($row['lang_description']);
539 } else if ($fldtype == 'all_code_types') {
541 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
542 foreach (array_keys($code_types) as $code_key) {
543 echo " <option value='" . attr($code_key) . "'";
544 if ($code_key == $fldvalue) {
549 echo xlt($code_types[$code_key]['label']);
554 } else if ($fldtype == 'm_lang') {
555 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
556 echo " <select multiple class='form-control' name='form_{$i}[]' id='form_{$i}[]' size='3'>\n";
557 while ($row = sqlFetchArray($res)) {
558 echo " <option value='" . attr($row['lang_description']) . "'";
559 foreach ($glarr as $glrow) {
560 if ($glrow['gl_value'] == $row['lang_description']) {
567 echo xlt($row['lang_description']);
572 } else if ($fldtype == 'color_code') {
574 $globalTitle = $globalValue;
577 echo " <input type='text' class='form-control jscolor {hash:true}' name='form_$i' id='form_$i' " .
578 "maxlength='15' value='" . attr($fldvalue) . "' />" .
579 "<input type='button' value='" . xla('Default'). "' onclick=\"document.forms[0].form_$i.jscolor.fromString('" . attr($flddef) . "')\">\n";
580 } else if ($fldtype == 'default_visit_category') {
581 $sql = "SELECT pc_catid, pc_catname, pc_cattype
582 FROM openemr_postcalendar_categories
583 WHERE pc_active = 1 ORDER BY pc_seq";
584 $result = sqlStatement($sql);
585 echo "<select class='form-control' name='form_{$i}' id='form_{$i}'>\n";
586 echo "<option value='_blank'>" . xlt('None') . "</option>";
587 while ($row = sqlFetchArray($result)) {
588 $catId = $row['pc_catid'];
589 $name = $row['pc_catname'];
590 if ($catId < 9 && $catId != "5") {
594 if ($row['pc_cattype'] == 3 && !$GLOBALS['enable_group_therapy']) {
598 $optionStr = '<option value="%pc_catid%"%selected%>%pc_catname%</option>';
599 $optionStr = str_replace("%pc_catid%", attr($catId), $optionStr);
600 $optionStr = str_replace("%pc_catname%", text(xl_appt_category($name)), $optionStr);
601 $selected = ($fldvalue == $catId) ?
" selected" : "";
602 $optionStr = str_replace("%selected%", $selected, $optionStr);
607 } else if ($fldtype == 'css' ||
$fldtype == 'tabs_css') {
609 $globalTitle = $globalValue;
611 $themedir = "$webserver_root/interface/themes";
612 $dh = opendir($themedir);
615 $styleArray = array();
616 while (false !== ($tfname = readdir($dh))) {
617 // Only show files that contain tabs_style_ or style_ as options
618 if ($fldtype == 'tabs_css') {
619 $patternStyle = 'tabs_style_';
620 } else { // $fldtype == 'css'
621 $patternStyle = 'style_';
623 if ($tfname == 'style_blue.css' ||
624 $tfname == 'style_pdf.css' ||
625 !preg_match("/^" . $patternStyle . ".*\.css$/", $tfname)) {
629 if ($fldtype == 'tabs_css') {
630 // Drop the "tabs_style_" part and any replace any underscores with spaces
631 $styleDisplayName = str_replace("_", " ", substr($tfname, 11));
632 } else { // $fldtype == 'css'
633 // Drop the "style_" part and any replace any underscores with spaces
634 $styleDisplayName = str_replace("_", " ", substr($tfname, 6));
636 // Strip the ".css" and uppercase the first character
637 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
639 $styleArray[$tfname] = $styleDisplayName;
641 // Alphabetize styles
643 // Generate style selector
644 echo "<select class='form-control' name='form_$i' id='form_$i'>\n";
645 foreach ($styleArray as $styleKey => $styleValue) {
646 echo "<option value='" . attr($styleKey) . "'";
647 if ($styleKey == $fldvalue) {
651 echo text($styleValue);
657 } else if ($fldtype == 'hour') {
659 $globalTitle = $globalValue;
662 echo " <select class='form-control' name='form_$i' id='form_$i'>\n";
663 for ($h = 0; $h < 24; ++
$h) {
664 echo "<option value='$h'";
665 if ($h == $fldvalue) {
672 } else if ($h < 12) {
674 } else if ($h == 12) {
677 echo ($h - 12) . " PM";
688 echo "<div class='col-xs-2' style='color:red;'>" . attr($globalTitle) . "</div>\n";
689 echo "<div class='col-xs-1'><input type='checkbox' value='YES' name='toggle_" . $i . "' id='toggle_" . $i . "' " . attr($settingDefault) . "/></div>\n";
690 echo "<input type='hidden' id='globaldefault_" . $i . "' value='" . attr($globalValue) . "'>\n";
693 echo " </div></div>\n";
699 if (trim(strtolower($fldid)) == 'portal_offsite_address_patient_link' && !empty($GLOBALS['portal_offsite_enable']) && !empty($GLOBALS['portal_offsite_providerid'])) {
700 echo "<div class='row'>";
701 echo "<div class='col-xs-12'>";
702 echo "<input type='hidden' name='form_download' id='form_download'>";
703 echo "<button onclick=\"return validate_file()\" type='button'>" . xla('Download Offsite Portal Connection Files') . "</button>";
704 echo "<div id='file_error_message' class='alert alert-error'></div>";
722 <script language
="JavaScript">
724 $
(document
).ready(function(){
727 <?php
// mdsupport - Highlight search results ?>
728 $
('.srch div').wrapInner("<mark></mark>");
729 $
('.tab .row.srch :first-child').closest('.tab').each(function() {
730 $
('.tabNav li:nth-child('+
($
(this
).index()+
1)+
') a').wrapInner("<mark></mark>");
732 // Use the counter ($i) to make the form user friendly for user-specific globals use
733 <?php
if ($userMode) { ?
>
734 <?php
for ($j = 0; $j <= $i; $j++
) { ?
>
735 $
("#form_<?php echo $j ?>").change(function() {
736 $
("#toggle_<?php echo $j ?>").prop('checked',false);
738 $
("#toggle_<?php echo $j ?>").change(function() {
739 if ($
('#toggle_<?php echo $j ?>').prop('checked')) {
740 var defaultGlobal
= $
("#globaldefault_<?php echo $j ?>").val();
741 $
("#form_<?php echo $j ?>").val(defaultGlobal
);