Merge branch 'ent-3799-bug-en-configuracion-ehorus' into 'develop'

Ent 3799 bug en configuracion ehorus

See merge request artica/pandorafms!2421

Former-commit-id: cf20d4985c6de38e1eab8bdd23ddb32708cc57ba
This commit is contained in:
Daniel Rodriguez 2019-05-14 17:38:55 +02:00
commit be20163073
2 changed files with 17 additions and 15 deletions

View File

@ -139,47 +139,49 @@ if ($config['ehorus_enabled'] && !$custom_field_exists) {
ui_print_error_message($error_message); ui_print_error_message($error_message);
} }
echo "<form method='post'>";
// Form enable. // Form enable.
echo '<form id="form_enable" method="post">'; echo '<div id="form_enable">';
html_print_input_hidden('update_config', 1); html_print_input_hidden('update_config', 1);
html_print_table($table_enable); html_print_table($table_enable);
echo '</form>'; echo '</div>';
// Form remote. // Form remote.
if ($config['ehorus_enabled']) { echo '<div id="form_remote">';
echo '<form id="form_remote" method="post">';
echo '<fieldset>'; echo '<fieldset>';
echo '<legend>'.__('eHorus API').'</legend>'; echo '<legend>'.__('eHorus API').'</legend>';
html_print_input_hidden('update_config', 1); html_print_input_hidden('update_config', 1);
html_print_table($table_remote); html_print_table($table_remote);
echo '</fieldset>';
echo '</div>';
echo '<div class="action-buttons" style="width: '.$table_remote->width.'">'; echo '<div class="action-buttons" style="width: '.$table_remote->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"'); html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>'; echo '</div>';
echo '</fieldset>';
echo '</form>'; echo '</form>';
}
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false); if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
$('form#form_remote').hide(); $('#form_remote').hide();
$('form#form_enable').css('margin-bottom','20px'); }
$('#form_enable').css('margin-bottom','20px');
var showFields = function () { var showFields = function () {
$('form#form_remote').show(); $('#form_remote').show();
} }
var hideFields = function () { var hideFields = function () {
$('form#form_remote').hide(); $('#form_remote').hide();
} }
var handleEnable = function (event) { var handleEnable = function (event) {
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked'); var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
if (event.target.value == '1' && is_checked) { if (event.target.value == '1' && is_checked) {
showFields(); showFields();
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false); $('input:checkbox[name="ehorus_enabled"]').attr('checked', true);
} }
else { else {
hideFields(); hideFields();
$('input:checkbox[name="ehorus_enabled"]').attr('checked', true); $('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
}; };
} }
$('input:checkbox[name="ehorus_enabled"]').change(handleEnable); $('input:checkbox[name="ehorus_enabled"]').change(handleEnable);

View File

@ -1349,7 +1349,7 @@ function config_update_config()
break; break;
case 'ehorus': case 'ehorus':
if (!config_update_value('ehorus_enabled', (int) get_parameter('ehorus_enabled', $config['ehorus_enabled']))) { if (!config_update_value('ehorus_enabled', (int) get_parameter('ehorus_enabled', 0))) {
$error_update[] = __('Enable eHorus'); $error_update[] = __('Enable eHorus');
} }