$(document).ready(function () { all_other(); }); function all_other() { $('#otherList table thead td').click(function() { $('#filterF .page').val(1); if ($(this).attr('id') == 'action') return; if ($(this).attr('id') == 'invoices') return; cl = $('#otherList'); 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'; } $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'other', order: $(this).attr('id'), way: order, filter: $('#filterF').serializeArray() }, function(data) { $('#otherList table.list tbody').replaceWith(data); $('#disabler').fadeOut(); reloadOther(); }); }); $('#otherList #filterF #clear').click(function() { $('#otherList table thead td').attr('order', '').removeClass('desc').removeClass('asc'); $('#filterF').find(':input').val(''); $('#filterF #isFiltered').val('0'); cl = $('#otherList'); $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'other', filter: $('#filterF').serializeArray() }, function(data) { $('#otherList table.list tbody').replaceWith(data); $('#disabler').fadeOut(); reloadOther(); }); }); $('#otherList #filterF #filter').click(function() { $('#otherList table thead td').attr('order', '').removeClass('desc').removeClass('asc'); $('#filterF #isFiltered').val('1'); cl = $('#otherList'); $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $('#filterF input[name=page]').val(0); $.get('http://track.acshipping.com/updater.php', { id: 'other', filter: $('#filterF').serializeArray() }, function(data) { $('#otherList table.list tbody').replaceWith(data); $('#disabler').fadeOut(); reloadOther(); }); }); viewOther(); editOther(); pageOther(); newOther(); invoiceViewOther(); removeOther(); } function viewOther() { $('#otherList table tbody a.view').click(function() { id = $(this).attr('nr'); cl = $('#otherList'); $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'viewother', nr: id }, function(data) { $(data).appendTo('#otherList'); updateHeight(); $('#viewOther').fadeIn('fast'); $('#viewOther').css('top', 0).css('left', 0); $('#viewOther a.close').click(function() { $('#viewOther').fadeOut(function(){$('#viewOther').remove(); $('#disabler').fadeOut();}); }); }); }); } function editOther() { $('#otherList table tbody a.edit').click(function() { iii = '#editOtherF input[name='; id = $(this).attr('nr'); cl = $('#otherList'); $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'editother', nr: id }, function(data) { $(data).appendTo('#otherList'); updateHeight(); $('#editOther').fadeIn('fast'); $('#editOther').css('top', 0).css('left', 0); $('#editOther a.cancel').click(function() { $('#editOther').fadeOut(function(){$('#editOther').remove(); $('#disabler').fadeOut();}); }); $('#editOther a.save').click(function() { $('#editOther div.feedback').slideUp(function() {$('#editOther div.feedback').children().remove(); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=editother&nr='+id+'&save=yes&'+$('#editOtherF').serialize(), success: function(data) { if (data == "OK") { $('#editOther').fadeOut(function(){ $('#editOther').remove(); $('#disabler').fadeOut(); }); return; } if (data.substring(0, 6) == "EMPTY ") { $('
There are empty fields left.
').appendTo('#editOther div.feedback'); $('#editOther div.feedback').slideDown(); return; } if (data == "ERR") { $('
There was an error.
').appendTo('#editOther div.feedback'); $('#editOther div.feedback').slideDown(); return; } } }); }); }); }); }); } function newOther() { $('#otherList #new').click(function() { cl = $('#otherList'); $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=newother', success: function(data) { $(data).appendTo('#otherList'); updateHeight(); $('#newOther').css('top', 0).css('left', 0); $('#newOther').fadeIn('fast'); $('#newOther a.cancel').click(function() { $('#newOther').fadeOut(function(){$('#newOther').remove(); $('#disabler').fadeOut();}); }); $('#newOther a.submit').click(function() { $('#newOtherF input').css('background-color', '#FFFFFF'); $('#newOther div.feedback').slideUp(function() {$('#newOther div.feedback').children().remove(); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=newother&'+$('#newOtherF').serialize(), success: function(data) { if (data == 'OK') { $('
New Other has been successfully created. Click "Filter" to see your new boat in your search.
').appendTo($('#otherList .feedback')); $('#newOther').fadeOut(function() { $('#disabler').fadeOut(); $('#filterF .number').val($('#newOtherF .number').val()); $('#newOther').remove(); }); $('#otherList .feedback').slideDown(); } else if (data == 'NRERR') { $('
A cargo with number '+$('#newBoatF .vin').val()+' has already been registered. Please use the filter to find it.
').appendTo($('#newOther .feedback')); $('#newOther .feedback').slideDown(); } else if (data.substring(0, 6) == 'EMPTY ') { $('
Some fields are empty.
').appendTo($('#newOther .feedback')); a = data.split(" "); $.each(a, function() { $('#newOtherF input[name='+this+']').css('background-color', '#FFAAAA'); }); $('#newOther .feedback').slideDown(); } updateHeight(); } }); }); }); } }); }); } function reloadOther() { viewOther(); editOther(); pageOther(); load_select('other'); invoiceViewOther(); removeOther(); } function pageOther() { $('#otherPage .page').click(function () { $('#filterF .page').val($(this).attr('nr')); order = ''; orderby = $('#otherList table thead td[order="asc"]').attr('id'); if (orderby != null) order = 'asc'; else { orderby = $('#otherList table thead td[order="desc"]').attr('id'); if (orderby != null) order = 'desc'; } cl = $('#otherList'); $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $.get('http://track.acshipping.com/updater.php', { id: 'other', order: orderby, way: order, filter: $('#filterF').serializeArray() }, function(data) { $('#otherList table.list tbody').replaceWith(data); $('#disabler').fadeOut(); reloadOther(); }); }); } function invoiceViewOther() { $('#otherList a.viewInvoice').click(function() { cl = $('#otherList'); $('#disabler').css('top', 0).css('left', 0).width(cl.width()).height(cl.height()); $('#disabler').fadeIn('fast'); $.ajax({ type: 'GET', url: 'http://track.acshipping.com/updater.php', data: 'id=viewinvoice&nr='+$(this).attr('nr'), success: function(data) { $(data).appendTo('#otherList'); $('#viewInvoice').css('top', 0).css('left', 0); $('#viewInvoice').fadeIn('fast'); if ($('#otherList').height() < $('#viewInvoice').height()) { $('#otherList').height($('#viewInvoice').height()); } $('#viewInvoice a.closeInvoice').click(function() { $('#viewInvoice').fadeOut('fast', function() { $('#viewInvoice').remove(); $('#disabler').fadeOut(); $('#otherList').attr('style', ''); }); }); $('#viewInvoice a.upload').click(function() { addUpload(); }); } }); }); } function removeOther() { $('#otherList .remove').click(function() { nr = $(this).attr('nr'); line = $(this).parent().parent(); c = confirm('Do you really want to remove this cargo?'); if (c) { $('#otherList .feedback').slideUp('fast', function() { $('#otherList .feedback').children().remove(); $.ajax({ type: 'POST', url: 'http://track.acshipping.com/updater.php', data: 'id=removeother&nr='+nr, success: function (data) { if (data == 'OK') { $('
Cargo was removed successfully.
').appendTo('#otherList .feedback'); $('#otherList .feedback').slideDown(); line.fadeOut(); } else if (data == 'USED') { $('
Cargo cannot be removed because it is used in invoices.
').appendTo('#otherList .feedback'); $('#otherList .feedback').slideDown(); } else { $('
Unknown error occured
').appendTo('#otherList .feedback'); $('#otherList .feedback').slideDown(); } } }); }); } }); }