Mark totals row as static (keep it at bottom of the table issue #131)

This commit is contained in:
jekkos
2015-09-06 13:19:32 +02:00
parent 756b675e2b
commit 2b6b3914a7
8 changed files with 4245 additions and 14 deletions

View File

@@ -54,7 +54,7 @@ function get_sales_manage_table_data_rows($sales, $controller)
}
else
{
$table_data_rows .= "<tr><td>&nbsp;</td><td>".$CI->lang->line('sales_total')."</td><td>&nbsp;</td><td>&nbsp;</td><td>".to_currency($sum_amount_tendered)."</td><td>".to_currency($sum_amount_due)."</td><td>".to_currency($sum_change_due)."</td><td colspan=\"3\"></td></tr>";
$table_data_rows .= "<tr class='static'><td>&nbsp;</td><td>".$CI->lang->line('sales_total')."</td><td>&nbsp;</td><td>&nbsp;</td><td>".to_currency($sum_amount_tendered)."</td><td>".to_currency($sum_amount_due)."</td><td>".to_currency($sum_change_due)."</td><td colspan=\"3\"></td></tr>";
}
return $table_data_rows;

View File

@@ -18,7 +18,8 @@
<script type="text/javascript" src="js/jquery.form-3.51.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.jkey-1.1.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.metadata.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.tablesorter.min.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.tablesorter-2.20.1.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.tablesorter.staticrow.js" language="javascript"></script>
<script type="text/javascript" src="js/jquery.validate-1.13.1-min.js" language="javascript"></script>
<script type="text/javascript" src="js/common.js" language="javascript"></script>
<script type="text/javascript" src="js/date.js" language="javascript"></script>

View File

@@ -154,7 +154,8 @@ function init_table_sorting()
7: { sorter: 'false'},
8: { sorter: 'invoice_number'},
9: { sorter: 'false'}
}
},
widgets: ['staticRow']
});
}
}

2121
dist/opensourcepos.js vendored
View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,76 @@
/*
*
* StaticRow widget for jQuery TableSorter 2.0
* Version 1.0
*
* Copyright (c) 2011 Nils Luxton
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
*/
$.tablesorter.addWidget({
// Give the new Widget an ID to be used in the tablesorter() call, as follows:
// $('#myElement').tablesorter({ widgets: ['zebra','staticRow'] });
id: 'staticRow',
// "Format" is run on all widgets once when the tablesorter has finished initialising,
// and then again every time a sort has finished.
format: function(table) {
// Use a property of the function to determine
// whether this is the first run of "Format"
// (i.e. is this the table's default starting position,
// or has it been sorted?)
if (typeof $(table).data('hasSorted') == 'undefined')
{
$(table).data('hasSorted', true); // This will force us into the "else" block the next time "Format" is run
// "Index" the static rows, saving their current (starting)
// position in the table inside a data() param on the
// <tr> element itself for later use.
$('tbody .static', table).each(function() {
$(this).data('tableindex', $(this).index());
});
}
else
{
// Loop the static rows, moving them to their
// original "indexed" position, and keep doing
// this until no more re-shuffling needs doing
var hasShuffled = true;
while (hasShuffled)
{
hasShuffled = false;
$('tbody .static', table).each(function() {
var targetIndex = $(this).data('tableindex');
if (targetIndex != $(this).index())
{
hasShuffled = true;
var thisRow = $(this).detach();
var numRows = $('tbody tr', table).length;
// Are we trying to be the last row?
if (targetIndex >= numRows)
{
thisRow.appendTo($('tbody', table));
}
// Are we trying to be the first row?
else if (targetIndex == 0)
{
thisRow.prependTo($('tbody', table));
}
// No, we want to be somewhere in the middle!
else
{
thisRow.insertBefore($('tbody tr:eq(' + targetIndex + ')', table));
}
}
});
}
}
}
});