diff --git a/application/controllers/system/Filters.php b/application/controllers/system/Filters.php index a2b35a662..100809c4f 100644 --- a/application/controllers/system/Filters.php +++ b/application/controllers/system/Filters.php @@ -392,4 +392,21 @@ class Filters extends VileSci_Controller $this->output->set_content_type('application/json')->set_output(json_encode($json)); } + + /** + * + */ + public function rowNumber() + { + $json = new stdClass(); + + $dataset = $_SESSION[self::SESSION_NAME]['dataset']; + + if (is_array($dataset)) + { + $json->rowNumber = count($dataset); + } + + $this->output->set_content_type('application/json')->set_output(json_encode($json)); + } } diff --git a/include/js/infocenter/infocenterPersonDataset.js b/include/js/infocenter/infocenterPersonDataset.js index f4d80a370..a6b00dde5 100644 --- a/include/js/infocenter/infocenterPersonDataset.js +++ b/include/js/infocenter/infocenterPersonDataset.js @@ -11,29 +11,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - */ -/** - * javascript file for infocenter overview page - */ -$(document).ready( - function() - { - //bootstrap table - $("#tableDataset").addClass('table table-bordered table-responsive'); +*/ - // Checks if the table contains data (rows) - if ($('#tableDataset').find('tbody:empty').length == 0 - && $('#tableDataset').find('tr:empty').length == 0) - { - $("#tableDataset").tablesorter( - { - widgets: ["zebra", "filter"] - }); - } - appendTableActionsHtml(); - setTableActions(); - } -); +/** + * Javascript file for infocenter overview page + */ +$(document).ready(function() { + + appendTableActionsHtml(); + // setTableActions(); + +}); /** * adds person table additional actions html (above and beneath it) @@ -44,7 +32,7 @@ function appendTableActionsHtml() var url = currurl.replace(/infocenter\/InfoCenter(.*)/, "Messages/write"); var formHtml = '
'; - $("#filterForm").before(formHtml); + $("#datasetActionsTop").before(formHtml); var selectAllHtml = '' + @@ -56,16 +44,36 @@ function appendTableActionsHtml() '' + ' Nachricht senden'; - var personcount = $("#tableDataset tbody tr").length; - var persontext = personcount === 1 ? "Person" : "Personen"; - var countHtml = $("#tableDataset tbody tr").length +" "+persontext; + var personcount = 0; + + $.ajax({ + url: window.location.pathname.replace('infocenter/InfoCenter', 'Filters/rowNumber'), + method: "GET" + }) + .done(function(data, textStatus, jqXHR) { + + if (data != null) + { + if (data.rowNumber != null) + { + personcount = data.rowNumber; + + var persontext = personcount === 1 ? "Person" : "Personen"; + var countHtml = personcount + " " + persontext; + + $("#datasetActionsTop, #datasetActionsBottom").append( + "
" + selectAllHtml + "  " + messageHtml + "
"+ + "
" + countHtml + "
"+ + "
" + ); + $("#datasetActionsBottom").append("

"); + } + + setTableActions(); + } + + }).fail(function(jqXHR, textStatus, errorThrown) {}); - $("#datasetActionsTop, #datasetActionsBottom").append( - "
"+selectAllHtml+"  "+ messageHtml+"
"+ - "
"+countHtml+"
"+ - "
" - ); - $("#datasetActionsBottom").append("

"); } /** @@ -74,7 +82,7 @@ function appendTableActionsHtml() function setTableActions() { $(".sendMsgsLink").click(function() { - var idsel = $("#tableDataset input:checked[name=PersonId\\[\\]]"); + var idsel = $("#filterTableDataset input:checked[name=PersonId\\[\\]]"); if(idsel.length > 0) { var form = $("#sendMsgsForm"); @@ -91,15 +99,15 @@ function setTableActions() $(".selectAll").click(function() { //select only trs if not filtered by tablesorter - var trs = $("#tableDataset tbody tr").not(".filtered"); + var trs = $("#filterTableDataset tbody tr").not(".filtered"); trs.find("input[name=PersonId\\[\\]]").prop("checked", true); } ); $(".unselectAll").click(function() { - var trs = $("#tableDataset tbody tr").not(".filtered"); + var trs = $("#filterTableDataset tbody tr").not(".filtered"); trs.find("input[name=PersonId\\[\\]]").prop("checked", false); } ); -} \ No newline at end of file +}