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

Ent 3799 bug en configuracion ehorus

See merge request artica/pandorafms!2403

Former-commit-id: 183212d8ad2e9cab574800000ac71576d7ae75ae
This commit is contained in:
Daniel Rodriguez 2019-05-13 14:54:25 +02:00
commit ecacf2d3f5
2 changed files with 16 additions and 14 deletions

View File

@ -52,8 +52,9 @@ $table_enable->style['name'] = 'font-weight: bold';
// Enable eHorus.
$row = [];
$row['name'] = __('Enable eHorus');
$row['name'] = ('Enable eHorus');
$row['control'] = html_print_checkbox_switch('ehorus_enabled', 1, $config['ehorus_enabled'], true);
$row['button'] = html_print_submit_button(('Update'), 'update_button', false, 'class="sub upd"', true);
$table_enable->data['ehorus_enabled'] = $row;
// Remote config table.
@ -139,15 +140,15 @@ if ($config['ehorus_enabled'] && !$custom_field_exists) {
ui_print_error_message($error_message);
}
echo "<form method='post'>";
// Form enable.
echo '<form id="form_enable" method="post">';
echo '<div id="form_enable">';
html_print_input_hidden('update_config', 1);
html_print_table($table_enable);
echo '</form>';
echo '</div>';
// Form remote.
if ($config['ehorus_enabled']) {
echo '<form id="form_remote" method="post">';
echo '<div id="form_remote">';
echo '<fieldset>';
echo '<legend>'.__('eHorus API').'</legend>';
html_print_input_hidden('update_config', 1);
@ -156,30 +157,31 @@ if ($config['ehorus_enabled']) {
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
echo '</div>';
echo '</fieldset>';
echo '</div>';
echo '</form>';
}
?>
<script type="text/javascript">
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
$('form#form_remote').hide();
$('form#form_enable').css('margin-bottom','20px');
if(!$('input:checkbox[name="ehorus_enabled"]').is(':checked')){
$('#form_remote').hide();
}
$('#form_enable').css('margin-bottom','20px');
var showFields = function () {
$('form#form_remote').show();
$('#form_remote').show();
}
var hideFields = function () {
$('form#form_remote').hide();
$('#form_remote').hide();
}
var handleEnable = function (event) {
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
if (event.target.value == '1' && is_checked) {
showFields();
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
$('input:checkbox[name="ehorus_enabled"]').attr('checked', true);
}
else {
hideFields();
$('input:checkbox[name="ehorus_enabled"]').attr('checked', true);
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
};
}
$('input:checkbox[name="ehorus_enabled"]').change(handleEnable);

View File

@ -1349,7 +1349,7 @@ function config_update_config()
break;
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');
}