Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Farirai's avatar

Facing problems trying to filter data in my table below is my blade file

When i enter a date its not responding to the search

\<html>

   <head>
       <title>Reports</title>
   
       <script>
function myFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("myInput");
  filter = input.value.toUpperCase();
  table = document.getElementById("myTable");
  tr = table.getElementsByTagcreated_at("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].getElementsByTagcreated_at("td")[0];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}
</script>


   <style>

* {
    /* Change your font family */
    font-family: sans-serif;
}

.content-table {
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 0.9em;
    min-width: 400px;
    border-radius: 5px 5px 0 0;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}

.content-table thead tr {
    background-color: #009879;
    color: #ffffff;
    text-align: left;
    font-weight: bold;
}

.content-table th,
.content-table td {
    padding: 12px 15px;
}

.content-table tbody tr {
    border-bottom: 1px solid #dddddd;
}

.content-table tbody tr:nth-of-type(even) {
    background-color: #f3f3f3;
}

.content-table tbody tr:last-of-type {
    border-bottom: 2px solid #009879;
}

.content-table tbody tr.active-row {
    font-weight: bold;
    color: #009879;
}

button {
  background-color: #009879;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  border-bottom: 2px solid #009879;
  border-radius: 5px 5px 0 0;
}

body{
   /* margin: 10%; */
   padding: 3%;
}

#myInput {
  background-image: url('/css/searchicon.png'); /* Add a search icon to input */
  background-position: 10px 12px; /* Position the search icon */
  background-repeat: no-repeat; /* Do not repeat the icon image */
  width: 79%; /* Full-width */
  font-size: 16px; /* Increase font-size */
  padding: 12px 20px 12px 40px; /* Add some padding */
  border: 1px solid #ddd; /* Add a grey border */
  margin-bottom: 12px; /* Add some space below the input */
}

   </style>

   </head>

   <body>


   <h1>My Reports</h1>

  

   <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Filter by  created_at..">
   <br>
   
   <br>
   <button onclick ="window.print()">Export to pdf</button>
   <br>
   <br>

   
   <h3>Emphaya</h3>

   
   <table class="content-table" id="myTable">
         <tr id ="header">
            <th></th>
            <th>available_for_use_month</th>
            <th>available_for_use_today</th>
             <th>expected_tomorrow</th>
             <th>expected_before_monthend</th>
             <th>created_at</th>
             <th>updated_at</th>
         </tr>

         @foreach ($emphayas as $emphaya)
         <tr id ="header">
            <td></td>
            <td>{{ $emphaya->available_for_use_month}}</td>
            <td>{{ $emphaya->available_for_use_today }}</td>
            <td>{{ $emphaya->expected_tomorrow}}</td>
            <td>{{ $emphaya->expected_before_monthend}}</td>
            <td>{{ $emphaya->created_at}}</td>
            <td>{{ $emphaya->updated_at}}</td>

         </tr>


         @endforeach
         <tr id ="header">
         <th>Total</th>
            <td>{{ \App\Models\Emphaya::sum('available_for_use_month') }}
            <td>{{ \App\Models\Emphaya::sum('available_for_use_today') }}
            <td>{{ \App\Models\Emphaya::sum('expected_tomorrow') }}
            <td>{{ \App\Models\Emphaya::sum('expected_before_monthend') }}

         </tr>
      </table>


       <h3>Cashmet</h3>
      
       <table class="content-table" id="myTable">
       <tr id ="header">
            <th></th>
            <th>available_for_use_month</th>
            <th>available_for_use_today</th>
             <th>expected_tomorrow</th>
             <th>expected_before_monthend</th>
             <th>created_at</th>
             <th>updated_at</th>
         </tr>

         @foreach ($cashmets as $cashmet)
         <tr id ="header">
            <td></td>
            <td>{{ $cashmet->available_for_use_month}}</td>
            <td>{{ $cashmet->available_for_use_today }}</td>
            <td>{{ $cashmet->expected_tomorrow}}</td>
            <td>{{ $cashmet->expected_before_monthend}}</td>
            <td>{{ $cashmet->created_at}}</td>
            <td>{{ $cashmet->updated_at}}</td>

         </tr>

         @endforeach
         <tr id ="header">
         <th>Total</th>
            <td>{{ \App\Models\Cashmet::sum('available_for_use_month') }}
            <td>{{ \App\Models\Cashmet::sum('available_for_use_today') }}
            <td>{{ \App\Models\Cashmet::sum('expected_tomorrow') }}
            <td>{{ \App\Models\Cashmet::sum('expected_before_monthend') }}

         </tr>
      </table>

      <h3>Metremit</h3>
    
      <table class="content-table" id="myTable">
      <tr id ="header">
            <th></th>
            <th>available_for_use_month</th>
            <th>available_for_use_today</th>
             <th>expected_tomorrow</th>
             <th>expected_before_monthend</th>
             <th>created_at</th>
             <th>updated_at</th>
         </tr>


         @foreach ($metremits as $metremit)
         <tr id ="header">
            <td></td>
            <td>{{ $metremit->available_for_use_month}}</td>
            <td>{{ $metremit->available_for_use_today }}</td>
            <td>{{ $metremit->expected_tomorrow}}</td>
            <td>{{ $metremit->expected_before_monthend}}</td>
            <td>{{ $metremit->created_at}}</td>
            <td>{{ $metremit->updated_at}}</td>

         </tr>


         @endforeach
         <tr id ="header">
         <th>Total</th>
            <td>{{ \App\Models\Metremit::sum('available_for_use_month') }}
            <td>{{ \App\Models\Metremit::sum('available_for_use_today') }}
            <td>{{ \App\Models\Metremit::sum('expected_tomorrow') }}
            <td>{{ \App\Models\Metremit::sum('expected_before_monthend') }}

         </tr>
      </table>



      <h3>Bluefort</h3>
     
      <table class="content-table" id="myTable">
      <tr id ="header">
            <th></th>
            <th>available_for_use_month</th>
            <th>available_for_use_today</th>
             <th>expected_tomorrow</th>
             <th>expected_before_monthend</th>
             <th>created_at</th>
             <th>updated_at</th>
         </tr>
         @foreach ($blueforts as $bluefort)
         <tr id ="header">
            <td></td>
            <td>{{ $bluefort->available_for_use_month}}</td>
            <td>{{ $bluefort->available_for_use_today }}</td>
            <td>{{ $bluefort->expected_tomorrow}}</td>
            <td>{{ $bluefort->expected_before_monthend}}</td>
            <td>{{ $bluefort->created_at}}</td>
            <td>{{ $bluefort->updated_at}}</td>

         </tr>


         @endforeach
         <tr id ="header">
         <th>Total</th>
            <td>{{ \App\Models\Bluefort::sum('available_for_use_month') }}
            <td>{{ \App\Models\Bluefort::sum('available_for_use_today') }}
            <td>{{ \App\Models\Bluefort::sum('expected_tomorrow') }}
            <td>{{ \App\Models\Bluefort::sum('expected_before_monthend') }}

         </tr>
      </table>

      <h3>Treasury</h3>
    
      <table class="content-table" id="myTable">
      <tr id ="header">
            <th></th>
            <th>available_for_use_month</th>
            <th>available_for_use_today</th>
             <th>expected_tomorrow</th>
             <th>expected_before_monthend</th>
             <th>created_at</th>
             <th>updated_at</th>
         </tr>

         @foreach ($treasuries as $treasury)
         <tr id ="header">
            <td></td>
            <td>{{ $treasury->available_for_use_month}}</td>
            <td>{{ $treasury->available_for_use_today }}</td>
            <td>{{ $treasury->expected_tomorrow}}</td>
            <td>{{ $treasury->expected_before_monthend}}</td>
            <td>{{ $treasury->created_at}}</td>
            <td>{{ $treasury->updated_at}}</td>

         </tr>


         @endforeach
         <tr id ="header">
         <th>Total</th>
            <td>{{ \App\Models\Treasury::sum('available_for_use_month') }}
            <td>{{ \App\Models\Treasury::sum('available_for_use_today') }}
            <td>{{ \App\Models\Treasury::sum('expected_tomorrow') }}
            <td>{{ \App\Models\Treasury::sum('expected_before_monthend') }}

         </tr>
      </table>


      <h3>Corporate Banking</h3>
    
      <table class="content-table" id="myTable">
      <tr id ="header">
            <th></th>
            <th>available_for_use_month</th>
            <th>available_for_use_today</th>
             <th>expected_tomorrow</th>
             <th>expected_before_monthend</th>
             <th>created_at</th>
             <th>updated_at</th>
         </tr>

         @foreach ($corporate_bankings as $corporate_banking)
         <tr id ="header">
            <td></td>
            <td>{{ $corporate_banking->available_for_use_month}}</td>
            <td>{{ $corporate_banking->available_for_use_today }}</td>
            <td>{{ $corporate_banking->expected_tomorrow}}</td>
            <td>{{ $corporate_banking->expected_before_monthend}}</td>
            <td>{{ $corporate_banking->created_at}}</td>
            <td>{{ $corporate_banking->updated_at}}</td>

         </tr>


         @endforeach
         <tr id ="header">
         <th>Total</th>
            <td>{{ \App\Models\CorporateBanking::sum('available_for_use_month') }}
            <td>{{ \App\Models\CorporateBanking::sum('available_for_use_today') }}
            <td>{{ \App\Models\CorporateBanking::sum('expected_tomorrow') }}
            <td>{{ \App\Models\CorporateBanking::sum('expected_before_monthend') }}

         </tr>
      </table>

          <br>




<h3>Grand_Total</h3>
        
      <table class="content-table">
      <tr id ="header">
          
            <th>available_for_use_month</th>
            <th>available_for_use_today</th>
             <th>expected_tomorrow</th>
             <th>expected_before_monthend</th>
             
         </tr>

         @foreach ($sum as $sumt)
       <tr id ="header">
    
      <td>{{ $sumt->available_for_use_month}}</td>
      <td>{{ $sumt->available_for_use_today }}</td>
      <td>{{ $sumt->expected_tomorrow}}</td>
      <td>{{ $sumt->expected_before_monthend}}</td>
    

   </tr>


         @endforeach
         <tr id ="header">
        
      

         </tr>
      </table>

      
      <h3>Deposits</h3>
      <table class="content-table">
          <tr id ="header">

            <th></th>
            <th>name</th>
            <th>tenure</th>
            <th>available</th>
            <th>expected_in_7_days</th>
            <th>created_at</th>
             <th>updated_at</th>
         </tr>


        @foreach($deposits as $deposit)

        <tr id ="header">
            <td></td>
            <td>{{ $deposit->name }}</td>
            <td>{{ $deposit->tenure }}</td>
            <td>{{ $deposit->available}}</td>
            <td>{{ $deposit->expected_in_7_days}}</td>
            <td>{{ $deposit->created_at}}</td>
            <td>{{ $deposit->updated_at}}</td>

         </tr>
         @endforeach
         <tr id ="header">
         <th>Total</th>
            <td>{{ \App\Models\Deposits::sum('name') }}
             <td>{{ \App\Models\Deposits::sum('tenure') }}
            <td>{{ \App\Models\Deposits::sum('available') }}
            <td>{{ \App\Models\Deposits::sum('expected_in_7_days') }}
         </tr>
      </table>
 





   </body>
</html>


0 likes
2 replies

Please or to participate in this conversation.