| Server IP : 172.67.201.108 / Your IP : 216.73.217.134 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/hotel-dev/public_html/js/ |
Upload File : |
/* ***************** LCS DB GRID FUNCTIONS ******************** */
$.fn.scrollStopped = function(callback) {
var that = this, $this = $(that);
$this.scroll(function(ev) {
clearTimeout($this.data('scrollTimeout'));
$this.data('scrollTimeout', setTimeout(callback.bind(that), 250, ev));
});
};
var ar_lcs_db_load = [];
var ar_lcs_db_loaded = [];
var lcs_db_keep_alive_interval;
var lcs_db_resizing = false;
var lcs_db_resize_col_class;
var lcs_db_resize_orig_width;
var lcs_db_resize_new_width;
var lcs_db_resize_mouse_x_start;
var lcs_db_resize_mouse_x_end;
var lcs_currentMousePos = { x: -1, y: -1 };
var lcs_db_resize_grid_id;
var lcs_db_multi_filter = [];
$(document).mousemove(function(event) {
lcs_currentMousePos.x = event.pageX;
lcs_currentMousePos.y = event.pageY;
});
function lcs_scrolled_into_view(elem, parent_elem) {
var $elem = $(elem);
var $window = $(parent_elem);
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top;
var elemBottom = elemTop + $elem.height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
function lcs_scrolled_past_view(elem, parent_elem) {
var $elem = $(elem);
var $window = $(parent_elem);
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top;
var elemBottom = elemTop + $elem.height();
return (elemTop >= docViewTop);
}
function lcs_db_scrollbar_width() {
var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth();
$outer.remove();
return 100 - widthWithScroll;
}
function lcs_db_cell_spacing() {
var $p = $('<div class="lcs_dbg_cell_spacer"></div>').hide().appendTo("body");
var spacer_width = parseInt($p.css("width"));
$p.remove();
return spacer_width;
}
function lcs_db_adjust_sapcer_height(div) {
var h = $('#' + div + ' .lcs_dbg_row').first().height();
$('.lcs_dbg_cell_spacer').height(h);
}
function lcs_db_toggle_filter(div, call, func, ix_form, sort_col, sort_order, search_str, parm1, parm2, parm3, filter_cols, multi_filter, filter_index) {
//alert('toggle');
var ar_filter_cols = filter_cols.split(',');
if (ar_filter_cols[filter_index - 1] == 1) {
ar_filter_cols[filter_index - 1] = 0;
} else {
ar_filter_cols[filter_index - 1] = 1;
}
filter_cols = ar_filter_cols.join(',');
lcs_db_load(div, call, func, ix_form, sort_col, sort_order, search_str, parm1, parm2, parm3, filter_cols, multi_filter);
}
function lcs_db_multi_filter_open(popup_div_id) {
//alert('toggle');
$('#' + popup_div_id).show();
}
function lcs_db_multi_filter_close(popup_div_id) {
$('#' + popup_div_id).hide();
}
function lcs_db_multi_filter_clear(popup_div_id) {
$('#' + popup_div_id + ' input:checkbox').removeAttr('checked');
}
function lcs_db_multi_filter_apply(key, popup_div_id, div, call, func, ix_form, sort_col, sort_order, search_str, parm1, parm2, parm3, filter_cols, filter_index) {
//alert('toggle');
/*
var ar_filter_cols = filter_cols.split(',');
if (ar_filter_cols[filter_index - 1] == 1) {
ar_filter_cols[filter_index - 1] = 0;
} else {
ar_filter_cols[filter_index - 1] = 1;
}
filter_cols = ar_filter_cols.join(',');
*/
if (typeof lcs_db_multi_filter[div] === 'undefined') {
lcs_db_multi_filter[div] = [];
}
lcs_db_multi_filter[div][key] = [];
$('#' + popup_div_id + ' input:checkbox:checked').each(function(){
lcs_db_multi_filter[div][key].push($(this).val());
});
lcs_db_multi_filter_close(popup_div_id);
lcs_db_load(div, call, func, ix_form, sort_col, sort_order, search_str, parm1, parm2, parm3, filter_cols, lcs_db_multi_filter[div]);
}
function lcs_db_load(div, call, func, ix_form, sort_col, sort_order, search_str, parm1, parm2, parm3, filter_cols, multi_filter=[]) {
//console.log('lcs_db_resizing: ' + lcs_db_resizing);
if (lcs_db_resizing) {
return;
}
sort_col = sort_col || 0;
sort_order = sort_order || 0;
search_str = search_str || '';
filter_cols = filter_cols || '';
if (typeof window[div + '_uid'] === 'undefined') {
window[div + '_uid'] = '0';
}
$.ajax({
url: "ajax.php?div=" + div + "&call=" + call + "&func=" + func + "&ix_form=" + encodeURIComponent(ix_form) + "&scrollbar_width=" + lcs_db_scrollbar_width() +
"&spacer_width=" + lcs_db_cell_spacing() + "&sort_col=" + sort_col + "&sort_order=" + sort_order + "&search_str=" + search_str +
"&parm1=" + encodeURIComponent(parm1) + "&parm2=" + encodeURIComponent(parm2) + "&parm3=" + encodeURIComponent(parm3) + "&filter_cols=" + filter_cols + "&old_uid=" + window[div + '_uid'] + "&multi_filter=" + encodeURIComponent(JSON.stringify(multi_filter)),
cache: false,
dataType: "json",
headers: {
"Accept": "application/json"
},
success: function(json) {
//alert('html characters: ' + json.html.length);
$('#' + div + '_total_count').text(json.row_count);
$('#' + div + '_extra_data').text(json.extra_data);
window[div + '_xls_sql'] = json.xls_sql;
$('#' + div).html(json.html);
/*
$('.resizable').resizable({
handles: "n, e, s, w"
});
*/
//lcs_db_adjust_sapcer_height(div);
//alert(json.xls_sql);
//alert(json.xls_sql);
//alert(json.html);
//alert(window[div + '_uid']);
//alert(window[div + '_load_method']);
if (window[div + '_load_method'] == 'lazy2' || window[div + '_load_method'] == 'lazy3') {
window[div + '_scroll_top'] = $('#lcs_dbg_data_' + window[div + '_uid']).scrollTop();
if (window[div + '_load_method'] == 'lazy2') {
lcs_db_lazy_load2(window[div + '_uid'], div);
} else if (window[div + '_load_method'] == 'lazy3') {
clearInterval(lcs_db_keep_alive_interval);
lcs_db_lazy_load3(window[div + '_uid'], div);
lcs_db_keep_alive_interval = setInterval(lcs_db_keep_alive, 60000, window[div + '_uid'], div);
}
$('#lcs_dbg_data_wrapper_' + window[div + '_uid']).scrollStopped(function () {
if ($('#lcs_dbg_data_wrapper_' + window[div + '_uid']).scrollTop() > ($('#lcs_dbg_data_wrapper_' + window[div + '_uid'])[0].scrollHeight - $('#lcs_dbg_data_wrapper_' + window[div + '_uid']).height() * 2) ) {
window[div + '_scroll_top'] = $('#lcs_dbg_data_wrapper_' + window[div + '_uid']).scrollTop();
$('.lcs_appear').each(function() {
if (window[div + '_load_method'] == 'lazy2') {
lcs_db_lazy_load2(window[div + '_uid'], div);
} else if (window[div + '_load_method'] == 'lazy3') {
lcs_db_lazy_load3(window[div + '_uid'], div, true);
}
$(this).removeClass('lcs_appear');
});
}
});
}
}
,error: function (request, status, error) { alert(status + ", " + error + " Response: " + request.responseText); }
});
}
function lcs_db_scroll(uid, div) {
//alert($('#lcs_dbg_header_' + uid).scrollLeft());
$('#lcs_dbg_header_' + uid).scrollLeft($('#lcs_dbg_data_' + uid).scrollLeft());
}
function lcs_db_search() {
$('#' + table_id + '_strSearch').on( 'keyup', function () {
if (this.value > ' ') {
$('#' + table_id + '_strSearch').removeClass('search');
$('#' + table_id + '_strSearch').addClass('search_cancel');
$('#' + table_id + '_search_box a').show();
} else {
$('#' + table_id + '_strSearch').removeClass('search_cancel');
$('#' + table_id + '_strSearch').addClass('search');
$('#' + table_id + '_search_box a').hide();
}
} );
}
function lcs_db_lazy_load1(i, imax, uid, div) {
if (i > imax) {
return;
}
$("#lcs_dbg_data_" + uid).append(window[div + '_ar_blocks'][i]);
i = i + 1;
setTimeout(function() { lcs_db_lazy_load1(i, imax, uid, div) }, 200);
}
function lcs_db_lazy_load2(uid, div) {
if (window[div + '_current_block'] > window[div + '_block_count']) {
return;
}
$('div#lcs_db_loading').show();
$("#lcs_dbg_data_" + uid).append(window[div + '_ar_blocks'][window[div + '_current_block']]);
window[div + '_current_block'] = window[div + '_current_block'] + 1;
$('div#lcs_db_loading').hide();
}
function lcs_db_lazy_load3(uid, div, load_async) {
if (window[div + '_current_block'] > window[div + '_block_count']) {
return;
}
$('div#lcs_db_loading').show();
$.ajax({
url: "ajax.php?call=lcs_db_grid_ajax&func=load_block&uid=" + uid + "&block=" + window[div + '_current_block'],
cache: false,
async: load_async,
dataType: "json",
headers: {
"Accept": "application/json"
},
success: function(json) {
//alert(json.html);
$("#lcs_dbg_data_" + uid).append(json.html);
window[div + '_current_block'] = window[div + '_current_block'] + 1;
$('div#lcs_db_loading').hide();
}
,error: function (request, status, error) {
$('div#lcs_db_loading').hide();
alert(status + ", " + error + " Response: " + request.responseText);
}
});
}
function lcs_db_keep_alive(uid, div) {
//console.log('lcs_db_keep_alive');
$.ajax({
url: "ajax.php?call=lcs_db_grid_ajax&func=keep_alive&uid=" + uid + "&bypass_session_timeout=true",
cache: false,
dataType: "text",
success: function(text) {
//$('#' + div + '_diag').text(text);
}
,error: function (request, status, error) { alert(status + ", " + error + " Response: " + request.responseText); }
});
}
function lcs_db_col_resize_star(col_class, elem, grid_id) {
//console.log('start ' + col_class + ' grid: ' + grid_id);
lcs_db_resizing = true;
lcs_db_resize_orig_width = parseInt($(elem).parent().css('width'));
//console.log('orig width ' + lcs_db_resize_orig_width);
lcs_db_resize_mouse_x_start = lcs_currentMousePos.x;
lcs_db_resize_col_class = col_class;
lcs_db_resize_grid_id = grid_id;
$('#lcs_dbg_resizer_guide_' + lcs_db_resize_grid_id).css('left', (lcs_currentMousePos.x - 1) + 'px');
$('#lcs_dbg_resizer_guide_' + grid_id).show();
$('*').addClass('lcs_resize_cursor');
$('body').mouseup(function() {
if (lcs_db_resizing) {
lcs_db_col_resize_stop();
}
});
$('body').mousemove(function() {
if (lcs_db_resizing) {
lcs_db_col_resize_move();
}
});
}
function lcs_db_col_resize_stop() {
//console.log('stop');
//$('.' + lcs_db_resize_col_class).css('width', '75px');
$('#lcs_dbg_resizer_guide_' + lcs_db_resize_grid_id).hide();
$('*').removeClass('lcs_resize_cursor');
lcs_db_resize_mouse_x_end = lcs_currentMousePos.x;
var mouse_travel = lcs_db_resize_mouse_x_end - lcs_db_resize_mouse_x_start;
lcs_db_resize_new_width = lcs_db_resize_orig_width + mouse_travel;
if (lcs_db_resize_new_width < 25) {
lcs_db_resize_new_width = 25;
}
if (lcs_db_resize_new_width > 1000) {
lcs_db_resize_new_width = 1000;
}
$('head').append('<style type="text/css">div.' + lcs_db_resize_col_class + '{width:' + lcs_db_resize_new_width + 'px;}</style>');
setTimeout(function() {
lcs_db_resize_col_class = '';
lcs_db_resizing = false;
}, 500);
}
function lcs_db_col_resize_move() {
//console.log('moving');
$('#lcs_dbg_resizer_guide_' + lcs_db_resize_grid_id).css('left', (lcs_currentMousePos.x - 1) + 'px');
}
$(document).ready(function() {
/*
console.log('DB Grid document ready');
$('.resizable').resizable({
handles: "n, e, s, w"
});
*/
});