$(document).ready(function () { all_users(); }); function all_users() { $('#usersList table thead td').click(function() { $('#userFilterF .page').val(1); if ($(this).attr('id') == 'action') return; if ($(this).attr('id') == 'isadmin') return; if ($(this).attr('id') == 'isoperator') return; cl = $('#usersList'); order = $(this).attr('order'); if (order == 'asc') { $(this).parent().children().attr('order', '').removeClass('desc').removeClass('asc'); $(this).attr('order', 'desc').addClass('desc'); order = 'desc'; } else { $(this).parent().children().attr('order', '').removeClass('desc').removeClass('asc'); $(this).attr('order', 'asc').addClass('asc'); order = 'asc'; } $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'users', order: $(this).attr('id'), way: order, filter: $('#userFilterF').serializeArray() }, function(data) { $('#usersList table.list tbody').replaceWith(data); $('#usersDisabler').fadeOut(); reloadUser(); }); }); $('#usersList #userFilterF #clear').click(function() { $('#usersList table thead td').attr('order', '').removeClass('desc').removeClass('asc'); $('#userFilterF').find(':input').val(''); $('#userFilterF #isFiltered').val('0'); cl = $('#usersList'); $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'users', filter: $('#userFilterF').serializeArray() }, function(data) { $('#usersList table.list tbody').replaceWith(data); $('#usersDisabler').fadeOut(); reloadUser(); }); updateHeight(); }); $('#usersList #userFilterF #filter').click(function() { $('#usersList table thead td').attr('order', '').removeClass('desc').removeClass('asc'); $('#userFilterF #isFiltered').val('1'); cl = $('#usersList'); $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $('#filterF input[name=page]').val(0); $.get('http://track.acshipping.com/updater.php', { id: 'users', filter: $('#userFilterF').serializeArray() }, function(data) { $('#usersList table.list tbody').replaceWith(data); $('#usersDisabler').fadeOut(); reloadUser(); }); updateHeight(); }); newUser(); editUser(); editUserPass(); change_perm(); select_user(); pageUser(); } function reloadUser() { editUser(); editUserPass(); change_perm(); select_user(); pageUser(); } function pageUser() { $('#usersPage .page').click(function () { $('#userFilterF .page').val($(this).attr('nr')); order = ''; orderby = $('#usersList table thead td[order="asc"]').attr('id'); if (orderby != null) order = 'asc'; else { orderby = $('#usersList table thead td[order="desc"]').attr('id'); if (orderby != null) order = 'desc'; } cl = $('#usersList'); $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'users', order: orderby, way: order, filter: $('#userFilterF').serializeArray() }, function(data) { $('#usersList table.list tbody').replaceWith(data); $('#usersDisabler').fadeOut(); reloadUser(); }); }); } function newUser() { $('#usersList #new').click(function() { cl = $('#usersList'); $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=newuser', success: function(data) { $(data).appendTo('#usersList'); $('#newUser').css('top', 0).css('left', 0); $('#newUser').fadeIn('fast'); $('#newUser a.cancel').click(function() { $('#newUser').fadeOut(function(){$('#newUser').remove(); $('#usersDisabler').fadeOut();}); }); $('#newUser a.submit').click(function() { $('#newUserF input').css('background-color', '#FFFFFF'); $('#newUser div.feedback').slideUp(function() {$('#newUser div.feedback').children().remove(); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=newuser&'+$('#newUserF').serialize(), success: function(data) { if (data == 'OK') { $('
New User has been successfully created. Click "Filter" to see your new car in your search.
').appendTo($('#usersList .feedback')); $('#newUser').fadeOut(function() { $('#usersDisabler').fadeOut(); $('#userFilterF .login').val($('#newUserF .login').val()); $('#newUser').remove(); }); $('#usersList .feedback').slideDown(); } else if (data == 'LOGINERR') { $('
A user with username '+$('#newUserF .login').val()+' has already been registered. Please use the filter to find it.
').appendTo($('#newUser .feedback')); $('#newUser .feedback').slideDown(); } else if (data.substring(0, 6) == 'EMPTY ') { $('
Some fields are empty.
').appendTo($('#newUser .feedback')); a = data.split(" "); $.each(a, function() { $('#newUserF input[name='+this+']').css('background-color', '#FFAAAA'); }); $('#newUser .feedback').slideDown(); } } }); }); }); } }); }); } function editUser() { $('#usersList table tbody a.edit').click(function() { id = $(this).attr('nr'); cl = $('#usersList'); $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'edituser', nr: id }, function(data) { $(data).appendTo('#usersList'); $('#editUser').fadeIn('fast'); $('#editUser').css('top', 0).css('left', 0); $('#editUser a.cancel').click(function() { $('#editUser').fadeOut(function(){$('#editUser').remove(); $('#usersDisabler').fadeOut();}); }); $('#editUser a.save').click(function() { $('#editUser div.feedback').slideUp(function() {$('#editUser div.feedback').children().remove(); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=edituser&nr='+id+'&save=yes&'+$('#editUserF').serialize(), success: function(data) { if (data == "OK") { $('
Information successfully saved. Redo your search to see the changes.
').appendTo($('#usersList .feedback')); $('#editUser').fadeOut(function(){ $('#editUser').remove(); $('#usersDisabler').fadeOut(); }); $('#usersList .feedback').slideDown(); return; } if (data.substring(0, 6) == "EMPTY ") { $('
There are empty fields left.
').appendTo('#editUser div.feedback'); $('#editUser div.feedback').slideDown(); return; } if (data == "ERR") { $('
There was an error.
').appendTo('#editUser div.feedback'); $('#editUser div.feedback').slideDown(); return; } } }); }); }); }); }); } function editUserPass() { $('#usersList table tbody a.change').click(function() { id = $(this).attr('nr'); cl = $('#usersList'); $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'changepass', nr: id }, function(data) { $(data).appendTo('#usersList'); $('#editUserPass').fadeIn('fast'); $('#editUserPass').css('top', 0).css('left', 0).css('position', 'absolute').css('z-index', 1050); $('#editUserPass a.cancel').click(function() { $('#editUserPass').fadeOut(function(){$('#editUserPass').remove(); $('#usersDisabler').fadeOut();}); }); $('#editUserPass a.save').click(function() { $('#editUserPass div.feedback').slideUp(function() {$('#editUserPass div.feedback').children().remove(); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=changepass&nr='+id+'&save=yes&'+$('#editUserPassF').serialize(), success: function(data) { if (data == "OK") { $('
Password successfully changed.
').appendTo($('#usersList .feedback')); $('#editUserPass').fadeOut(function(){ $('#editUserPass').remove(); $('#usersDisabler').fadeOut(); }); $('#usersList .feedback').slideDown(); return; } if (data.substring(0, 6) == "EMPTY ") { $('
There are empty fields left.
').appendTo('#editUserPass div.feedback'); $('#editUserPass div.feedback').slideDown(); return; } if (data == "ERR") { $('
There was an error.
').appendTo('#editUserPass div.feedback'); $('#editUserPass div.feedback').slideDown(); return; } } }); }); }); }); }); } function change_perm() { $('#usersList .perm').click(function() { id = $(this).attr('nr'); cl = $('#usersList'); $('#usersDisabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#usersDisabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'userperm', nr: id }, function(data) { $(data).appendTo('#usersList'); $('#permList').fadeIn('fast'); $('#permList').css('top', 0).css('left', 0); $('#permList a.cancel').click(function() { $('#permList').fadeOut(function(){$('#permList').remove(); $('#usersDisabler').fadeOut();}); }); $('#permList a.save').click(function() { $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=userperm&nr='+id+'&save=yes&'+$('#permF').serialize(), success: function(data) { if (data == "OK") { $('
Permissions successfully changed.
').appendTo($('#usersList .feedback')); $('#permList').fadeOut(function(){ $('#permList').remove(); $('#usersDisabler').fadeOut(); }); $('#usersList .feedback').slideDown(); return; } } }); }); }); }); } function select_user() { $('#usersList .select').click(function() { nr = $(this).attr('nr'); name = $(this).html(); $('#editCustomer #username').html(name); $('#editCustomer .saveuser').attr('nr', nr); $('#editCustomer .saveuser').fadeIn(); $('#usersList').fadeOut('fast', function() { $('#usersList').remove(); $('#editCustomerDisabler').fadeOut(); }); }); }