Added the option 'last value' for the items 'general' and 'exception' in reports. TICKET: #1819
(cherry picked from commit 0952b96b49
)
Conflicts:
pandora_console/include/javascript/pandora.js
This commit is contained in:
parent
42d90c5793
commit
30a05aa62f
|
@ -568,8 +568,25 @@ html_print_input_hidden('id_item', $idItem);
|
||||||
<td style="">
|
<td style="">
|
||||||
<?php
|
<?php
|
||||||
html_print_extended_select_for_time ('period', $period, '', '', '0', 10);
|
html_print_extended_select_for_time ('period', $period, '', '', '0', 10);
|
||||||
?></td>
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="row_last_value" style="" class="datos">
|
||||||
|
<td style="vertical-align: top;" class="datos">
|
||||||
|
<?php
|
||||||
|
echo __('Last value');
|
||||||
|
ui_print_help_tip(__('Warning: period 0 reports cannot be used to show information back in time. Information contained in this kind of reports will be always reporting the most recent information'));
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td style="">
|
||||||
|
<?php
|
||||||
|
html_print_checkbox('last_value', '1',
|
||||||
|
($period === 0), false, false, 'set_last_value_period();');
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="row_resolution" style="" class="datos">
|
<tr id="row_resolution" style="" class="datos">
|
||||||
<td style="vertical-align: top;">
|
<td style="vertical-align: top;">
|
||||||
<?php
|
<?php
|
||||||
|
@ -1424,7 +1441,8 @@ $(document).ready (function () {
|
||||||
minuteText: '<?php echo __('Minute');?>',
|
minuteText: '<?php echo __('Minute');?>',
|
||||||
secondText: '<?php echo __('Second');?>',
|
secondText: '<?php echo __('Second');?>',
|
||||||
currentText: '<?php echo __('Now');?>',
|
currentText: '<?php echo __('Now');?>',
|
||||||
closeText: '<?php echo __('Close');?>'});
|
closeText: '<?php echo __('Close');?>'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function create_custom_graph() {
|
function create_custom_graph() {
|
||||||
|
@ -1451,7 +1469,11 @@ function create_custom_graph() {
|
||||||
jQuery.ajax ({
|
jQuery.ajax ({
|
||||||
data: params1.join ("&"),
|
data: params1.join ("&"),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: action= <?php echo '"' . ui_get_full_url(false, false, false, false) . '"'; ?> + "/ajax.php",
|
url: action= <?php
|
||||||
|
echo '"' .
|
||||||
|
ui_get_full_url(false, false, false, false) .
|
||||||
|
'"';
|
||||||
|
?> + "/ajax.php",
|
||||||
async: false,
|
async: false,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
@ -1899,6 +1921,7 @@ function chooseType() {
|
||||||
$("#row_netflow_filter").hide();
|
$("#row_netflow_filter").hide();
|
||||||
$("#row_max_values").hide();
|
$("#row_max_values").hide();
|
||||||
$("#row_resolution").hide();
|
$("#row_resolution").hide();
|
||||||
|
$("#row_last_value").hide();
|
||||||
|
|
||||||
// SLA list default state
|
// SLA list default state
|
||||||
$("#sla_list").hide();
|
$("#sla_list").hide();
|
||||||
|
@ -2159,6 +2182,12 @@ function chooseType() {
|
||||||
$("#row_order_uptodown").show();
|
$("#row_order_uptodown").show();
|
||||||
$("#row_show_resume").show();
|
$("#row_show_resume").show();
|
||||||
$("#row_show_in_two_columns").show();
|
$("#row_show_in_two_columns").show();
|
||||||
|
|
||||||
|
$("#row_last_value").show();
|
||||||
|
if ($("#hidden-period").val() == 0) {
|
||||||
|
$("#row_period").hide();
|
||||||
|
$("input[name='last_value']").prop("checked", true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'group_report':
|
case 'group_report':
|
||||||
$("#row_group").show();
|
$("#row_group").show();
|
||||||
|
@ -2191,6 +2220,12 @@ function chooseType() {
|
||||||
$("#row_show_resume").show();
|
$("#row_show_resume").show();
|
||||||
$("#row_show_graph").show();
|
$("#row_show_graph").show();
|
||||||
$("#row_show_in_two_columns").show();
|
$("#row_show_in_two_columns").show();
|
||||||
|
|
||||||
|
$("#row_last_value").show();
|
||||||
|
if ($("#hidden-period").val() == 0) {
|
||||||
|
$("#row_period").hide();
|
||||||
|
$("input[name='last_value']").prop("checked", true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'agent_module':
|
case 'agent_module':
|
||||||
$("#row_description").show();
|
$("#row_description").show();
|
||||||
|
@ -2292,4 +2327,19 @@ function chooseType() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_last_value_period() {
|
||||||
|
var checked = $("input[name='last_value']").prop("checked");
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#row_period").hide();
|
||||||
|
period_set_value($("#hidden-period").attr('class'), 0);
|
||||||
|
alert("<?php
|
||||||
|
echo __('Warning: period 0 reports cannot be used to show information back in time. Information contained in this kind of reports will be always reporting the most recent information');
|
||||||
|
?>");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#row_period").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -639,7 +639,13 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
|
||||||
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline;">';
|
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline;">';
|
||||||
html_print_select ($fields, $uniq_name . '_select', $selected,"" . $script,
|
html_print_select ($fields, $uniq_name . '_select', $selected,"" . $script,
|
||||||
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
|
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
|
||||||
echo ' <a href="javascript:">'.html_print_image('images/pencil.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'), 'style' => 'width: 18px;')).'</a>';
|
echo ' <a href="javascript:">' .
|
||||||
|
html_print_image('images/pencil.png', true,
|
||||||
|
array('class' => $uniq_name . '_toggler',
|
||||||
|
'alt' => __('Custom'),
|
||||||
|
'title' => __('Custom'),
|
||||||
|
'style' => 'width: 18px;')) .
|
||||||
|
'</a>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:inline;">';
|
echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:inline;">';
|
||||||
|
@ -648,7 +654,12 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
|
||||||
html_print_input_hidden ($name, $selected, false, $uniq_name);
|
html_print_input_hidden ($name, $selected, false, $uniq_name);
|
||||||
html_print_select ($units, $uniq_name . '_units', 1, "" . $script,
|
html_print_select ($units, $uniq_name . '_units', 1, "" . $script,
|
||||||
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
|
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
|
||||||
echo ' <a href="javascript:">'.html_print_image('images/default_list.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('List'), 'title' => __('List'), 'style' => 'width: 18px;')).'</a>';
|
echo ' <a href="javascript:">' .
|
||||||
|
html_print_image('images/default_list.png', true,
|
||||||
|
array('class' => $uniq_name . '_toggler',
|
||||||
|
'alt' => __('List'),
|
||||||
|
'title' => __('List'), 'style' => 'width: 18px;')) .
|
||||||
|
'</a>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo "<script type='text/javascript'>
|
echo "<script type='text/javascript'>
|
||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
|
|
|
@ -308,16 +308,21 @@ function reporting_get_agentmodule_data_min ($id_agent_module, $period=0, $date
|
||||||
*
|
*
|
||||||
* @return float The sumatory of the module values in the interval.
|
* @return float The sumatory of the module values in the interval.
|
||||||
*/
|
*/
|
||||||
function reporting_get_agentmodule_data_sum ($id_agent_module, $period=0, $date = 0) {
|
function reporting_get_agentmodule_data_sum ($id_agent_module,
|
||||||
|
$period = 0, $date = 0) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Initialize variables
|
// Initialize variables
|
||||||
if (empty ($date)) $date = get_system_time ();
|
if (empty ($date)) $date = get_system_time ();
|
||||||
$datelimit = $date - $period;
|
$datelimit = $date - $period;
|
||||||
|
|
||||||
$search_in_history_db = db_search_in_history_db($datelimit);
|
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||||
|
|
||||||
$id_module_type = db_get_value ('id_tipo_modulo', 'tagente_modulo','id_agente_modulo', $id_agent_module);
|
$id_module_type = db_get_value ('id_tipo_modulo', 'tagente_modulo',
|
||||||
$module_name = db_get_value ('nombre', 'ttipo_modulo', 'id_tipo', $id_module_type);
|
'id_agente_modulo', $id_agent_module);
|
||||||
|
$module_name = db_get_value ('nombre', 'ttipo_modulo', 'id_tipo',
|
||||||
|
$id_module_type);
|
||||||
$module_interval = modules_get_interval ($id_agent_module);
|
$module_interval = modules_get_interval ($id_agent_module);
|
||||||
$uncompressed_module = is_module_uncompressed ($module_name);
|
$uncompressed_module = is_module_uncompressed ($module_name);
|
||||||
|
|
||||||
|
@ -330,11 +335,12 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, $period=0, $date
|
||||||
$module_inc = is_module_inc ($module_name);
|
$module_inc = is_module_inc ($module_name);
|
||||||
|
|
||||||
// Get module data
|
// Get module data
|
||||||
$interval_data = db_get_all_rows_sql ('SELECT * FROM tagente_datos
|
$interval_data = db_get_all_rows_sql('
|
||||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
SELECT * FROM tagente_datos
|
||||||
' AND utimestamp > ' . (int) $datelimit .
|
WHERE id_agente_modulo = ' . (int) $id_agent_module . '
|
||||||
' AND utimestamp < ' . (int) $date .
|
AND utimestamp > ' . (int) $datelimit . '
|
||||||
' ORDER BY utimestamp ASC', $search_in_history_db);
|
AND utimestamp < ' . (int) $date . '
|
||||||
|
ORDER BY utimestamp ASC', $search_in_history_db);
|
||||||
if ($interval_data === false) $interval_data = array ();
|
if ($interval_data === false) $interval_data = array ();
|
||||||
|
|
||||||
// Uncompressed module data
|
// Uncompressed module data
|
||||||
|
@ -5360,6 +5366,11 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$mod_name = modules_get_agentmodule_name ($row['id_agent_module']);
|
$mod_name = modules_get_agentmodule_name ($row['id_agent_module']);
|
||||||
$ag_name = modules_get_agentmodule_agent_name ($row['id_agent_module']);
|
$ag_name = modules_get_agentmodule_agent_name ($row['id_agent_module']);
|
||||||
|
|
||||||
|
if ($content['period'] == 0) {
|
||||||
|
$data_res[$key] =
|
||||||
|
modules_get_last_value($row['id_agent_module']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch ($row['operation']) {
|
switch ($row['operation']) {
|
||||||
case 'sum':
|
case 'sum':
|
||||||
$data_res[$key] =
|
$data_res[$key] =
|
||||||
|
@ -5383,6 +5394,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$row['id_agent_module'], $content['period']);
|
$row['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$unit = db_get_value('unit', 'tagente_modulo',
|
$unit = db_get_value('unit', 'tagente_modulo',
|
||||||
'id_agente_modulo',
|
'id_agente_modulo',
|
||||||
|
@ -5592,6 +5604,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$found = false;
|
$found = false;
|
||||||
if (strcmp($a, $agent_name) == 0
|
if (strcmp($a, $agent_name) == 0
|
||||||
&& strcmp($m, $module_name . ' (' . $g['operation'] . ')') == 0) {
|
&& strcmp($m, $module_name . ' (' . $g['operation'] . ')') == 0) {
|
||||||
|
|
||||||
|
if ($content['period'] == 0) {
|
||||||
|
$value_res =
|
||||||
|
modules_get_last_value($g['id_agent_module']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch ($g['operation']) {
|
switch ($g['operation']) {
|
||||||
case 'sum':
|
case 'sum':
|
||||||
$value_res = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
|
$value_res = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
@ -5607,6 +5625,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$value_res = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
|
$value_res = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($value_res === false) {
|
if ($value_res === false) {
|
||||||
$data[$i] = '--';
|
$data[$i] = '--';
|
||||||
|
@ -5666,6 +5685,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($content['period'] == 0) {
|
||||||
|
$min =
|
||||||
|
modules_get_last_value($generals[$i]['id_agent_module']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch ($generals[$i]['operation']) {
|
switch ($generals[$i]['operation']) {
|
||||||
case 'sum':
|
case 'sum':
|
||||||
$min = reporting_get_agentmodule_data_sum ($generals[$i]['id_agent_module'], $content['period'], $report["datetime"]);
|
$min = reporting_get_agentmodule_data_sum ($generals[$i]['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
@ -5681,6 +5706,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$min = reporting_get_agentmodule_data_average ($generals[$i]['id_agent_module'], $content['period']);
|
$min = reporting_get_agentmodule_data_average ($generals[$i]['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$min_name_agent_module =
|
$min_name_agent_module =
|
||||||
|
@ -5718,6 +5744,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($content['period'] == 0) {
|
||||||
|
$value =
|
||||||
|
modules_get_last_value($g['id_agent_module']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch ($g['operation']) {
|
switch ($g['operation']) {
|
||||||
case 'sum':
|
case 'sum':
|
||||||
$value = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
|
$value = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
@ -5733,6 +5765,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$value = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
|
$value = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($value !== false) {
|
if ($value !== false) {
|
||||||
if ($value > $max) {
|
if ($value > $max) {
|
||||||
|
@ -6247,17 +6280,26 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($content['period'] == 0) {
|
||||||
|
$min =
|
||||||
|
modules_get_last_value($exceptions[$i]['id_agent_module']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch ($exceptions[$i]['operation']) {
|
switch ($exceptions[$i]['operation']) {
|
||||||
case 'avg':
|
case 'avg':
|
||||||
$min = reporting_get_agentmodule_data_average($exceptions[$i]['id_agent_module'], $content['period']);
|
$min = reporting_get_agentmodule_data_average(
|
||||||
|
$exceptions[$i]['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
case 'max':
|
case 'max':
|
||||||
$min = reporting_get_agentmodule_data_max($exceptions[$i]['id_agent_module'], $content['period']);
|
$min = reporting_get_agentmodule_data_max(
|
||||||
|
$exceptions[$i]['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
case 'min':
|
case 'min':
|
||||||
$min = reporting_get_agentmodule_data_min($exceptions[$i]['id_agent_module'], $content['period']);
|
$min = reporting_get_agentmodule_data_min(
|
||||||
|
$exceptions[$i]['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
//Restore dbconnection
|
//Restore dbconnection
|
||||||
|
@ -6286,6 +6328,11 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$unit = db_get_value('unit', 'tagente_modulo',
|
$unit = db_get_value('unit', 'tagente_modulo',
|
||||||
'id_agente_modulo', $exc['id_agent_module']);
|
'id_agente_modulo', $exc['id_agent_module']);
|
||||||
|
|
||||||
|
if ($content['period'] == 0) {
|
||||||
|
$value =
|
||||||
|
modules_get_last_value($exceptions[$i]['id_agent_module']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch ($exc['operation']) {
|
switch ($exc['operation']) {
|
||||||
case 'avg':
|
case 'avg':
|
||||||
$value = reporting_get_agentmodule_data_average ($exc['id_agent_module'], $content['period']);
|
$value = reporting_get_agentmodule_data_average ($exc['id_agent_module'], $content['period']);
|
||||||
|
@ -6297,6 +6344,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$value = reporting_get_agentmodule_data_min ($exc['id_agent_module'], $content['period']);
|
$value = reporting_get_agentmodule_data_min ($exc['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($value !== false) {
|
if ($value !== false) {
|
||||||
if ($value > $max) $max = $value;
|
if ($value > $max) $max = $value;
|
||||||
|
|
|
@ -501,25 +501,27 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
|
||||||
*/
|
*/
|
||||||
function period_select_init(name) {
|
function period_select_init(name) {
|
||||||
// Manual mode is hidden by default
|
// Manual mode is hidden by default
|
||||||
$('#'+name+'_manual').hide();
|
$('#' + name + '_manual').hide();
|
||||||
$('#'+name+'_default').show();
|
$('#' + name + '_default').show();
|
||||||
|
|
||||||
// If the text input is empty, we put on it 5 minutes by default
|
// If the text input is empty, we put on it 5 minutes by default
|
||||||
if($('#text-'+name+'_text').val() == '') {
|
if ($('#text-' + name + '_text').val() == '') {
|
||||||
$('#text-'+name+'_text').val(300);
|
$('#text-' + name + '_text').val(300);
|
||||||
// Set the value in the hidden field too
|
// Set the value in the hidden field too
|
||||||
$('.'+name).val(300);
|
$('.' + name).val(300);
|
||||||
if($('#'+name+'_select option:eq(0)').val() == 0) {
|
if ($('#' + name + '_select option:eq(0)').val() == 0) {
|
||||||
$('#'+name+'_select option:eq(2)').attr('selected', 'selected');
|
$('#' + name + '_select option:eq(2)')
|
||||||
|
.attr('selected', 'selected');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#'+name+'_select option:eq(1)').attr('selected', 'selected');
|
$('#' + name + '_select option:eq(1)')
|
||||||
|
.attr('selected', 'selected');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($('#text-'+name+'_text').val() == 0) {
|
else if ($('#text-' + name + '_text').val() == 0) {
|
||||||
$('#'+name+'_units option:last').removeAttr('selected');
|
$('#' + name + '_units option:last').removeAttr('selected');
|
||||||
$('#'+name+'_manual').show();
|
$('#' + name + '_manual').show();
|
||||||
$('#'+name+'_default').hide();
|
$('#' + name + '_default').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,58 +534,67 @@ function period_select_init(name) {
|
||||||
* @param name string with the name of the select for time
|
* @param name string with the name of the select for time
|
||||||
*/
|
*/
|
||||||
function period_select_events(name) {
|
function period_select_events(name) {
|
||||||
$('.'+name+'_toggler').click(function() {
|
$('.' + name + '_toggler').click(function() {
|
||||||
toggleBoth(name);
|
toggleBoth(name);
|
||||||
$('#text-'+name+'_text').focus();
|
$('#text-' + name + '_text').focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
adjustTextUnits(name);
|
adjustTextUnits(name);
|
||||||
|
|
||||||
// When select a default period, is setted in seconds
|
// When select a default period, is setted in seconds
|
||||||
$('#'+name+'_select').change(function() {
|
$('#' + name + '_select').change(function() {
|
||||||
var value = $('#'+name+'_select').val();
|
var value = $('#' + name + '_select').val();
|
||||||
|
|
||||||
if(value == -1) {
|
if (value == -1) {
|
||||||
value = 300;
|
value = 300;
|
||||||
toggleBoth(name);
|
toggleBoth(name);
|
||||||
$('#text-'+name+'_text').focus();
|
$('#text-' + name + '_text').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.'+name).val(value);
|
$('.' + name).val(value);
|
||||||
$('#text-'+name+'_text').val(value);
|
$('#text-' + name + '_text').val(value);
|
||||||
|
|
||||||
adjustTextUnits(name);
|
adjustTextUnits(name);
|
||||||
});
|
});
|
||||||
|
|
||||||
// When select a custom units, the default period changes to 'custom' and
|
// When select a custom units, the default period changes to
|
||||||
// the time in seconds is calculated into hidden input
|
// 'custom' and the time in seconds is calculated into hidden input
|
||||||
$('#'+name+'_units').change(function() {
|
$('#' + name + '_units').change(function() {
|
||||||
selectFirst(name);
|
selectFirst(name);
|
||||||
calculateSeconds(name);
|
calculateSeconds(name);
|
||||||
});
|
});
|
||||||
|
|
||||||
// When write any character into custom input, it check to convert it to
|
// When write any character into custom input, it check to convert
|
||||||
// integer and calculate in seconds into hidden input
|
// it to integer and calculate in seconds into hidden input
|
||||||
$('#text-'+name+'_text').keyup (function () {
|
$('#text-' + name + '_text').keyup (function () {
|
||||||
var cleanValue = parseInt($('#text-'+name+'_text').val());
|
var cleanValue = parseInt($('#text-' + name + '_text').val());
|
||||||
if(isNaN(cleanValue)) {
|
if (isNaN(cleanValue)) {
|
||||||
cleanValue = '';
|
cleanValue = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#text-'+name+'_text').val(cleanValue);
|
$('#text-' + name + '_text').val(cleanValue);
|
||||||
|
|
||||||
selectFirst(name+'_select');
|
selectFirst(name + '_select');
|
||||||
calculateSeconds(name);
|
calculateSeconds(name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function period_set_value(name, value) {
|
||||||
|
$("#text-" + name + "_text").val(value);
|
||||||
|
adjustTextUnits(name);
|
||||||
|
calculateSeconds(name);
|
||||||
|
selectFirst(name + '_select');
|
||||||
|
$("#" + name + "_manual").hide();
|
||||||
|
$("#" + name + "_default").show();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Select first option of a select if is not value=0
|
* Select first option of a select if is not value=0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function selectFirst(name) {
|
function selectFirst(name) {
|
||||||
if($('#'+name+' option:eq(0)').val() == 0) {
|
if ($('#'+name+' option:eq(0)').val() == 0) {
|
||||||
$('#'+name+' option:eq(1)').attr('selected', 'selected');
|
$('#'+name+' option:eq(1)').attr('selected', 'selected');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -598,16 +609,15 @@ function selectFirst(name) {
|
||||||
* work properly when the divs are into a hiden div
|
* work properly when the divs are into a hiden div
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function toggleBoth(name) {
|
function toggleBoth(name) {
|
||||||
if($('#'+name+'_default').css('display') == 'none') {
|
if ($('#'+name+'_default').css('display') == 'none') {
|
||||||
$('#'+name+'_default').css('display','inline');
|
$('#'+name+'_default').css('display','inline');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#'+name+'_default').css('display','none');
|
$('#'+name+'_default').css('display','none');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#'+name+'_manual').css('display') == 'none') {
|
if ($('#'+name+'_manual').css('display') == 'none') {
|
||||||
$('#'+name+'_manual').css('display','inline');
|
$('#'+name+'_manual').css('display','inline');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -621,9 +631,10 @@ function toggleBoth(name) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function calculateSeconds(name) {
|
function calculateSeconds(name) {
|
||||||
var calculated = $('#text-'+name+'_text').val()*$('#'+name+'_units').val();
|
var calculated =
|
||||||
|
$('#text-' + name + '_text').val() * $('#' + name + '_units').val();
|
||||||
|
|
||||||
$('.'+name).val(calculated);
|
$('.' + name).val(calculated);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -632,11 +643,11 @@ function calculateSeconds(name) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function period_select_update(name, seconds) {
|
function period_select_update(name, seconds) {
|
||||||
$('#text-'+name+'_text').val(seconds);
|
$('#text-' + name + '_text').val(seconds);
|
||||||
adjustTextUnits(name);
|
adjustTextUnits(name);
|
||||||
calculateSeconds(name);
|
calculateSeconds(name);
|
||||||
$('#'+name+'_manual').show();
|
$('#' + name + '_manual').show();
|
||||||
$('#'+name+'_default').hide();
|
$('#' + name + '_default').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue