Merge pull request #2 from Huda11Baig/filter_by_year

added filter by year
This commit is contained in:
Huda11Baig 2022-11-13 12:10:01 +03:00 committed by GitHub
commit 235477676e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,6 +66,29 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<script>
function myFunction() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value;
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
<div id="bill-form" class="modal fade show" role="dialog"> <div id="bill-form" class="modal fade show" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@ -103,6 +126,7 @@
</div> </div>
{% if bills.total > 0 %} {% if bills.total > 0 %}
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Filter by year">
<h3>Active Bills</h3> <h3>Active Bills</h3>
<table id="bill_table" class="col table table-striped table-hover table-responsive-sm"> <table id="bill_table" class="col table table-striped table-hover table-responsive-sm">
<thead> <thead>
@ -113,7 +137,7 @@
</th><th>{{ _("How much?") }} </th><th>{{ _("How much?") }}
</th><th>{{ _("Actions") }}</th></tr> </th><th>{{ _("Actions") }}</th></tr>
</thead> </thead>
<tbody> <tbody id="myTable">
{% for (weights, bill) in bills.items %} {% for (weights, bill) in bills.items %}
{% if bill.archive == false %} {% if bill.archive == false %}
<tr owers="{{bill.owers|join(',','id')}}" payer="{{bill.payer.id}}"> <tr owers="{{bill.owers|join(',','id')}}" payer="{{bill.payer.id}}">
@ -178,3 +202,6 @@
</div></div> </div></div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}