3 * Script for the globals editor.
5 * Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
6 * Copyright (C) 2016 Brady Miller <brady@sparmy.com>
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
20 * @author Rod Roark <rod@sunsetsystems.com>
21 * @author Brady Miller <brady@sparmy.com>
22 * @link http://www.open-emr.org
25 $fake_register_globals=false;
26 $sanitize_all_escapes=true;
28 require_once("../globals.php");
29 require_once("../../custom/code_types.inc.php");
30 require_once("$srcdir/acl.inc");
31 require_once("$srcdir/globals.inc.php");
32 require_once("$srcdir/user.inc");
33 require_once("$srcdir/classes/CouchDB.class.php");
34 require_once(dirname(__FILE__
)."/../../myportal/soap_service/portal_connectivity.php");
36 $userMode = (array_key_exists('mode', $_GET) && $_GET['mode'] == 'user');
39 // Check authorization.
40 $thisauth = acl_check('admin', 'super');
41 if (!$thisauth) die(xlt('Not authorized'));
44 function checkCreateCDB(){
45 $globalsres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
46 ('couchdb_host','couchdb_user','couchdb_pass','couchdb_port','couchdb_dbase','document_storage_method')");
48 while($globalsrow = sqlFetchArray($globalsres)){
49 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
51 $directory_created = false;
52 if( !empty($GLOBALS['document_storage_method']) ) {
53 // /documents/temp/ folder is required for CouchDB
54 if(!is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/')){
55 $directory_created = mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/temp/',0777,true);
56 if(!$directory_created){
57 echo htmlspecialchars( xl("Failed to create temporary folder. CouchDB will not work."),ENT_NOQUOTES
);
60 $couch = new CouchDB();
61 if(!$couch->check_connection()) {
62 echo "<script type='text/javascript'>alert('".addslashes(xl("CouchDB Connection Failed."))."');</script>";
65 if($GLOBALS['couchdb_host'] ||
$GLOBALS['couchdb_port'] ||
$GLOBALS['couchdb_dbase']){
66 $couch->createDB($GLOBALS['couchdb_dbase']);
67 $couch->createView($GLOBALS['couchdb_dbase']);
74 * Update background_services table for a specific service following globals save.
77 function updateBackgroundService($name,$active,$interval) {
78 //order important here: next_run change dependent on _old_ value of execute_interval so it comes first
79 $sql = 'UPDATE background_services SET active=?, '
80 . 'next_run = next_run + INTERVAL (? - execute_interval) MINUTE, execute_interval=? WHERE name=?';
81 return sqlStatement($sql,array($active,$interval,$interval,$name));
85 * Make any necessary changes to background_services table when globals are saved.
86 * To prevent an unexpected service call during startup or shutdown, follow these rules:
87 * 1. Any "startup" operations should occur _before_ the updateBackgroundService() call.
88 * 2. Any "shutdown" operations should occur _after_ the updateBackgroundService() call. If these operations
89 * would cause errors in a running service call, it would be best to make the shutdown function itself
90 * a background service that is activated here, does nothing if active=1 or running=1 for the
91 * parent service, then deactivates itself by setting active=0 when it is done shutting the parent service
92 * down. This will prevent nonresponsiveness to the user by waiting for a service to finish.
93 * 3. If any "previous" values for globals are required for startup/shutdown logic, they need to be
94 * copied to a temp variable before the while($globalsrow...) loop.
97 function checkBackgroundServices(){
98 //load up any necessary globals
99 $bgservices = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals WHERE gl_name IN
100 ('phimail_enable','phimail_interval')");
101 while($globalsrow = sqlFetchArray($bgservices)){
102 $GLOBALS[$globalsrow['gl_name']] = $globalsrow['gl_value'];
105 //Set up phimail service
106 $phimail_active = empty($GLOBALS['phimail_enable']) ?
'0' : '1';
107 $phimail_interval = max(0, (int) $GLOBALS['phimail_interval']);
108 updateBackgroundService('phimail', $phimail_active, $phimail_interval);
119 // If we are saving user_specific globals.
121 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && $userMode) {
123 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
124 if (in_array($grpname, $USER_SPECIFIC_TABS)) {
125 foreach ($grparr as $fldid => $fldarr) {
126 if (in_array($fldid, $USER_SPECIFIC_GLOBALS)) {
127 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
128 $label = "global:".$fldid;
129 $fldvalue = trim($_POST["form_$i"]);
130 setUserSetting($label,$fldvalue,$_SESSION['authId'],FALSE);
131 if ( $_POST["toggle_$i"] == "YES" ) {
132 removeUserSetting($label);
139 echo "<script type='text/javascript'>";
140 echo "if (parent.left_nav.location) {";
141 echo " parent.left_nav.location.reload();";
142 echo " parent.Title.location.reload();";
143 echo " if(self.name=='RTop'){";
144 echo " parent.RBot.location.reload();";
146 echo " parent.RTop.location.reload();";
149 echo "self.location.href='edit_globals.php?mode=user&unique=yes';";
153 if (array_key_exists('form_download', $_POST) && $_POST['form_download']) {
154 $client = portal_connection();
156 $response = $client->getPortalConnectionFiles($credentials);
159 error_log('SoapFault Error');
160 error_log(var_dump(get_object_vars($e)));
163 error_log('Exception Error');
164 error_log(var_dump(get_object_vars($e)));
166 if(array_key_exists('status', $response) && $response['status'] == "1") {//WEBSERVICE RETURNED VALUE SUCCESSFULLY
167 $tmpfilename = realpath(sys_get_temp_dir())."/".date('YmdHis').".zip";
168 $fp = fopen($tmpfilename,"wb");
169 fwrite($fp,base64_decode($response['value']));
171 $practice_filename = $response['file_name'];//practicename.zip
174 header("Cache-Control: public");
175 header("Content-Description: File Transfer");
176 header("Content-Disposition: attachment; filename=".$practice_filename);
177 header("Content-Type: application/zip");
178 header("Content-Transfer-Encoding: binary");
179 // Read the file from disk
180 readfile($tmpfilename);
181 unlink($tmpfilename);
184 else{//WEBSERVICE CALL FAILED AND RETURNED AN ERROR MESSAGE
187 <script type
="text/javascript">
188 alert('<?php echo xls('Offsite Portal web Service Failed
').":\\n".text($response['value
']);?>');
198 // If we are saving main globals.
200 if (array_key_exists('form_save', $_POST) && $_POST['form_save'] && !$userMode) {
201 $force_off_enable_auditlog_encryption = true;
202 // Need to force enable_auditlog_encryption off if the php mycrypt module
204 if (extension_loaded('mcrypt')) {
205 $force_off_enable_auditlog_encryption = false;
208 // Aug 22, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
209 // Check the current status of Audit Logging
210 $auditLogStatusFieldOld = $GLOBALS['enable_auditlog'];
213 * Compare form values with old database values.
214 * Only save if values differ. Improves speed.
217 // Get all the globals from DB
218 $old_globals = sqlGetAssoc( 'SELECT gl_name, gl_index, gl_value FROM `globals` ORDER BY gl_name, gl_index',false,true );
221 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
222 foreach ($grparr as $fldid => $fldarr) {
223 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
224 if($fldtype == 'pwd'){
225 $pass = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array($fldid) );
226 $fldvalueold = $pass['gl_value'];
229 /* Multiple choice fields - do not compare , overwrite */
230 if (!is_array($fldtype) && substr($fldtype, 0, 2) == 'm_') {
231 if (isset($_POST["form_$i"])) {
234 sqlStatement("DELETE FROM globals WHERE gl_name = ?", array( $fldid ) );
236 foreach ($_POST["form_$i"] as $fldvalue) {
237 $fldvalue = trim($fldvalue);
238 sqlStatement('INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?,?,?)', array( $fldid, $fldindex, $fldvalue ) );
244 /* check value of single field. Don't update if the database holds the same value */
245 if (isset($_POST["form_$i"])) {
246 $fldvalue = trim($_POST["form_$i"]);
251 if($fldtype=='pwd') $fldvalue = $fldvalue ?
SHA1($fldvalue) : $fldvalueold; // TODO: salted passwords?
253 // We rely on the fact that set of keys in globals.inc === set of keys in `globals` table!
256 !isset( $old_globals[$fldid]) // if the key not found in database - update database
258 ( isset($old_globals[$fldid]) && $old_globals[ $fldid ]['gl_value'] !== $fldvalue ) // if the value in database is different
260 // Need to force enable_auditlog_encryption off if the php mcrypt module
262 if ( $force_off_enable_auditlog_encryption && ($fldid == "enable_auditlog_encryption") ) {
263 error_log("OPENEMR ERROR: UNABLE to support auditlog encryption since the php mcrypt module is not installed",0);
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));
273 // Replace old values
274 sqlStatement( 'DELETE FROM `globals` WHERE gl_name = ?', array( $fldid ) );
275 sqlStatement( 'INSERT INTO `globals` ( gl_name, gl_index, gl_value ) VALUES ( ?, ?, ? )', array( $fldid, 0, $fldvalue ) );
277 //error_log("No need to update $fldid");
284 checkBackgroundServices();
286 // July 1, 2014: Ensoftek: For Auditable events and tamper-resistance (MU2)
287 // If Audit Logging status has changed, log it.
288 $auditLogStatusNew = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'enable_auditlog'");
289 $auditLogStatusFieldNew = $auditLogStatusNew['gl_value'];
290 if ( $auditLogStatusFieldOld != $auditLogStatusFieldNew )
292 auditSQLAuditTamper($auditLogStatusFieldNew);
294 echo "<script type='text/javascript'>";
295 echo "if (parent.left_nav.location) {";
296 echo " parent.left_nav.location.reload();";
297 echo " parent.Title.location.reload();";
298 echo " if(self.name=='RTop'){";
299 echo " parent.RBot.location.reload();";
301 echo " parent.RTop.location.reload();";
304 echo "self.location.href='edit_globals.php?unique=yes';";
309 <!-- supporting javascript code
-->
310 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
311 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
312 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
313 <script type
="text/javascript" src
="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
314 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jscolor-1-4-5/jscolor.js"></script
>
315 <link rel
="stylesheet" type
="text/css" href
="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
317 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
318 <?php
if ($userMode) { ?
>
319 <title
><?php
echo xlt('User Settings'); ?
></title
>
321 <title
><?php
echo xlt('Global Settings'); ?
></title
>
325 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
326 tr
.detail
{ font
-size
:10pt
; }
327 td
{ font
-size
:10pt
; }
328 input
{ font
-size
:10pt
; }
330 <script type
="text/javascript">
331 function validate_file(){
334 url
: "<?php echo $GLOBALS['webroot']?>/library/ajax/offsite_portal_ajax.php",
336 action
: 'check_file',
339 success
: function( message
)
342 document
.getElementById('form_download').value
= 1;
343 document
.getElementById('file_error_message').innerHTML
= '';
344 document
.forms
[0].submit();
347 document
.getElementById('form_download').value
= 0;
348 document
.getElementById('file_error_message').innerHTML
= message
;
357 <body
class="body_top">
359 <?php
if ($userMode) { ?
>
360 <form method
='post' name
='theform' id
='theform' action
='edit_globals.php?mode=user' onsubmit
='return top.restoreSession()'>
362 <form method
='post' name
='theform' id
='theform' action
='edit_globals.php' onsubmit
='return top.restoreSession()'>
365 <?php
if ($userMode) { ?
>
366 <p
><b
><?php
echo xlt('Edit User Settings'); ?
></b
>
368 <p
><b
><?php
echo xlt('Edit Global Settings'); ?
></b
>
371 <?php
// mdsupport - Optional server based searching mechanism for large number of fields on this screen. ?>
372 <span style
='float: right;'>
373 <input name
='srch_desc' size
='20'
374 value
='<?php echo (!empty($_POST['srch_desc
']) ? htmlspecialchars($_POST['srch_desc
']) : '') ?>' />
375 <input type
='submit' name
='form_search' value
='<?php echo xla('Search
'); ?>' />
381 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
382 if ( !$userMode ||
in_array($grpname, $USER_SPECIFIC_TABS) ) {
383 echo " <li" . ($i ?
"" : " class='current'") .
385 xlt($grpname) . "</a></li>\n";
392 <div
class="tabContainer">
395 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
396 if ( !$userMode ||
in_array($grpname, $USER_SPECIFIC_TABS) ) {
397 echo " <div class='tab" . ($i ?
"" : " current") .
398 "' style='height:auto;width:97%;'>\n";
404 echo "<th> </th>";
405 echo "<th>" . htmlspecialchars( xl('User Specific Setting'), ENT_NOQUOTES
) . "</th>";
406 echo "<th>" . htmlspecialchars( xl('Default Setting'), ENT_NOQUOTES
) . "</th>";
407 echo "<th> </th>";
408 echo "<th>" . htmlspecialchars( xl('Set to Default'), ENT_NOQUOTES
) . "</th>";
412 foreach ($grparr as $fldid => $fldarr) {
413 if ( !$userMode ||
in_array($fldid, $USER_SPECIFIC_GLOBALS) ) {
414 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
415 // mdsupport - Check for matches
417 if (!empty($_POST['srch_desc']) && (stristr(($fldname.$flddesc), $_POST['srch_desc']) !== FALSE)) {
418 $srch_cl = 'class="srch"';
421 // Most parameters will have a single value, but some will be arrays.
422 // Here we cater to both possibilities.
423 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
424 "gl_name = ? ORDER BY gl_index", array($fldid));
426 while ($glrow = sqlFetchArray($glres)) $glarr[] = $glrow;
428 // $fldvalue is meaningful only for the single-value cases.
429 $fldvalue = count($glarr) ?
$glarr[0]['gl_value'] : $flddef;
431 // Collect user specific setting if mode set to user
433 $settingDefault = "checked='checked'";
435 $userSettingArray = sqlQuery("SELECT * FROM user_settings WHERE setting_user=? AND setting_label=?",array($_SESSION['authId'],"global:".$fldid));
436 $userSetting = $userSettingArray['setting_value'];
437 $globalValue = $fldvalue;
438 if (!empty($userSettingArray)) {
439 $fldvalue = $userSetting;
440 $settingDefault = "";
444 echo " <tr $srch_cl title='" . attr($flddesc) . "'><td valign='top'><b>" . text($fldname) . "</b></td><td valign='top'>\n";
446 if (is_array($fldtype)) {
447 echo " <select name='form_$i' id='form_$i'>\n";
448 foreach ($fldtype as $key => $value) {
450 if ($globalValue == $key) $globalTitle = $value;
452 echo " <option value='" . attr($key) . "'";
454 //Casting value to string so the comparison will be always the same type and the only thing that will check is the value
455 //Tried to use === but it will fail in already existing variables
456 if ((string)$key == (string)$fldvalue) echo " selected";
464 else if ($fldtype == 'bool') {
466 if ($globalValue == 1) {
467 $globalTitle = htmlspecialchars( xl('Checked'), ENT_NOQUOTES
);
470 $globalTitle = htmlspecialchars( xl('Not Checked'), ENT_NOQUOTES
);
473 echo " <input type='checkbox' name='form_$i' id='form_$i' value='1'";
474 if ($fldvalue) echo " checked";
478 else if ($fldtype == 'num') {
480 $globalTitle = $globalValue;
482 echo " <input type='text' name='form_$i' id='form_$i' " .
483 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />\n";
486 else if ($fldtype == 'text') {
488 $globalTitle = $globalValue;
490 echo " <input type='text' name='form_$i' id='form_$i' " .
491 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
493 else if ($fldtype == 'pwd') {
495 $globalTitle = $globalValue;
497 echo " <input type='password' name='form_$i' " .
498 "size='50' maxlength='255' value='' />\n";
501 else if ($fldtype == 'pass') {
503 $globalTitle = $globalValue;
505 echo " <input type='password' name='form_$i' " .
506 "size='50' maxlength='255' value='" . attr($fldvalue) . "' />\n";
509 else if ($fldtype == 'lang') {
510 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
511 echo " <select name='form_$i' id='form_$i'>\n";
512 while ($row = sqlFetchArray($res)) {
513 echo " <option value='" . attr($row['lang_description']) . "'";
514 if ($row['lang_description'] == $fldvalue) echo " selected";
516 echo xlt($row['lang_description']);
522 else if ($fldtype == 'all_code_types') {
524 echo " <select name='form_$i' id='form_$i'>\n";
525 foreach (array_keys($code_types) as $code_key ) {
526 echo " <option value='" . attr($code_key) . "'";
527 if ($code_key == $fldvalue) echo " selected";
529 echo xlt($code_types[$code_key]['label']);
535 else if ($fldtype == 'm_lang') {
536 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
537 echo " <select multiple name='form_{$i}[]' id='form_{$i}[]' size='3'>\n";
538 while ($row = sqlFetchArray($res)) {
539 echo " <option value='" . attr($row['lang_description']) . "'";
540 foreach ($glarr as $glrow) {
541 if ($glrow['gl_value'] == $row['lang_description']) {
547 echo xlt($row['lang_description']);
553 else if ($fldtype == 'color_code') {
555 $globalTitle = $globalValue;
557 echo " <input type='text' class='color {hash:true}' name='form_$i' id='form_$i' " .
558 "size='6' maxlength='15' value='" . attr($fldvalue) . "' />" .
559 "<input type='button' value='Default' onclick=\"document.forms[0].form_$i.color.fromString('" . attr($flddef) . "')\">\n";
562 else if ($fldtype == 'css') {
564 $globalTitle = $globalValue;
566 $themedir = "$webserver_root/interface/themes";
567 $dh = opendir($themedir);
569 echo " <select name='form_$i' id='form_$i'>\n";
570 while (false !== ($tfname = readdir($dh))) {
571 // Only show files that contain style_ as options
572 // Skip style_blue.css since this is used for
573 // lone scripts such as setup.php
574 // Also skip style_pdf.css which is for PDFs and not screen output
575 if (!preg_match("/^style_.*\.css$/", $tfname) ||
576 $tfname == 'style_blue.css' ||
$tfname == 'style_pdf.css')
578 echo "<option value='" . attr($tfname) . "'";
579 // Drop the "style_" part and any replace any underscores with spaces
580 $styleDisplayName = str_replace("_", " ", substr($tfname, 6));
581 // Strip the ".css" and uppercase the first character
582 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
583 if ($tfname == $fldvalue) echo " selected";
585 echo text($styleDisplayName);
593 else if ($fldtype == 'tabs_css') {
595 $globalTitle = $globalValue;
597 $themedir = "$webserver_root/interface/themes";
598 $dh = opendir($themedir);
600 echo " <select name='form_$i' id='form_$i'>\n";
601 while (false !== ($tfname = readdir($dh))) {
602 // Only show files that contain tabs_style_ as options
603 if (!preg_match("/^tabs_style_.*\.css$/", $tfname)) continue;
604 echo "<option value='" . attr($tfname) . "'";
605 // Drop the "tabs_style_" part and any replace any underscores with spaces
606 $styleDisplayName = str_replace("_", " ", substr($tfname, 11));
607 // Strip the ".css" and uppercase the first character
608 $styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName));
609 if ($tfname == $fldvalue) echo " selected";
611 echo text($styleDisplayName);
619 else if ($fldtype == 'hour') {
621 $globalTitle = $globalValue;
623 echo " <select name='form_$i' id='form_$i'>\n";
624 for ($h = 0; $h < 24; ++
$h) {
625 echo "<option value='$h'";
626 if ($h == $fldvalue) echo " selected";
628 if ($h == 0) echo "12 AM";
629 else if ($h < 12) echo "$h AM";
630 else if ($h == 12) echo "12 PM";
631 else echo ($h - 12) . " PM";
638 echo "<td align='center' style='color:red;'>" . attr($globalTitle) . "</td>\n";
639 echo "<td> </td>";
640 echo "<td align='center'><input type='checkbox' value='YES' name='toggle_" . $i . "' id='toggle_" . $i . "' " . attr($settingDefault) . "/></td>\n";
641 echo "<input type='hidden' id='globaldefault_" . $i . "' value='" . attr($globalValue) . "'>\n";
645 echo " </td></tr>\n";
649 if( trim(strtolower($fldid)) == 'portal_offsite_address_patient_link' && !empty($GLOBALS['portal_offsite_enable']) && !empty($GLOBALS['portal_offsite_providerid']) ){
650 echo "<input type='hidden' name='form_download' id='form_download'>";
651 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>";
662 <input type
='submit' name
='form_save' value
='<?php echo xla('Save
'); ?>' />
670 <script language
="JavaScript">
672 $
(document
).ready(function(){
676 <?php
// mdsupport - Highlight search results ?>
677 $
('.srch td').wrapInner("<mark></mark>");
678 $
('.tab > table').find('tr.srch:first').each(function() {
679 var srch_div
= $
(this
).closest('div').prevAll().length +
1;
680 $
('.tabNav > li:nth-child('+srch_div+
') a').wrapInner("<mark></mark>");
682 // Use the counter ($i) to make the form user friendly for user-specific globals use
683 <?php
if ($userMode) { ?
>
684 <?php
for ($j = 0; $j <= $i; $j++
) { ?
>
685 $
("#form_<?php echo $j ?>").change(function() {
686 $
("#toggle_<?php echo $j ?>").attr('checked',false);
688 $
("#toggle_<?php echo $j ?>").change(function() {
689 if ($
('#toggle_<?php echo $j ?>').attr('checked')) {
690 var defaultGlobal
= $
("#globaldefault_<?php echo $j ?>").val();
691 $
("#form_<?php echo $j ?>").val(defaultGlobal
);