{% extends "layout/baseadmin.html.twig" %}
{% block content %}
<div class="row">
<div class="col-lg-7">
   <div class="widget">
      <div class="widget-body">
         <p>List of Universities</p>
         <br>
         <div>
            <table class="table">
               <thead>
                  <tr>
                     <th>Institution Name</th>
                     <th>Wallet</th>
                     <th>Withdraw Request</th>
                  </tr>
               </thead>
               <tbody>
                  {% for inst in withdraw %}
                  <tr>
                     <td>{{ inst.institution.institutionName }}</td>
                     <td>{{ inst.amount}} AED</td>
                     <td>{{ inst.statut ? 'Yes' : 'No' }}
                        {% if inst.statut == 1 %}
                        <i class="fa fa-check" style="font-size:24px;color:green"></i>
                        {% else %} 
                        <a href="{{ path('withdrawEdit',{'id': inst.institution.id,'idW':inst.id }) }}"><i class="fa fa-times" style="font-size:24px;color:red"></i></a>
                        {% endif %}
                     </td>
                  </tr>
                  {% else %} 
                  <tr>
                     <td colspan="12">no records found</td>
                  </tr>
                  {% endfor %}
            </table>
         </div>
      </div>
   </div>
</div>
<div class="col-md-5">
<div class="widget">
   <div class="widget-body">
      <p>Current Wallet State</p>
      <h2>{{ data.total }} AED</h2>
      <p>Earnings</p>
      <h3>
      {{ data.earnings }} AED</h2>
      <div class="input-group-append">
         <button  class="btn btn-outline-secondary"><a href="{{ path('updateWallet',{'id': 1 }) }}">Update Wallet</a></button>
      </div>
      <form method="post" action={{ path('amounts',{'id': 1 }) }} enctype="multipart/form-data">
      <p>Withdrawal Rates</p>
      <label for="email">Minimum Withdraw (AED):</label>
      <div class="input-group mb-3">
         <input type="number" class="form-control" name="minimum" value="{{ data.minimum }}" aria-describedby="basic-addon1" style="width: 64%;">
         <div class="input-group-append">
            <button class="btn btn-outline-secondary" type="submit" onclick="{{ path('amounts',{'id': 1 }) }}">Apply</button>
         </div>
      </div>
      <label for="email">Cut Pourcentage from each course (%):</label>
      <div class="input-group mb-3">
         <input type="number" class="form-control" name="pourcentage" value="{{ data.pourcentage }}" max="90" aria-describedby="basic-addon2" style="width: 60%;">         
         <div class="input-group-append">
            <button class="btn btn-outline-secondary" type="submit" onclick="{{ path('amounts',{'id': 1 }) }}">Apply</button>         
         </div>
      </div>
      </form>  
   </div>
</div>
</div>
<div class="row">
<div class="col-lg-7">
   <div class="widget">
<div class="widget-body">
         <p>List of New Institution Not Active</p>
         <br>
         <div>
            <table class="table">
               <thead>
                  <tr>
                     <th>Institution Name</th>
                     <th>State</th>
                  </tr>
               </thead>
               <tbody>
                  {% for inst in notActive %}
                  <tr>
                     <td>{{ inst.institutionName }}</td>
                     <td>{{ inst.islogin ? 'Deactivate' : 'Activate' }}
                        {% if inst.islogin == 0 %}
                        
                        <a href="/activeInst/{{ inst.user.id }}/1"><i class="fa fa-check" style="font-size:24px;color:green"></i></a>
                       
                        
      
                        {% endif %}
                     </td>
                  </tr>
                  {% else %} 
                  <tr>
                     <td colspan="12">no records found</td>
                  </tr>
                  {% endfor %}
            </table>
         </div>
      </div>
     </div>
    
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
   $(document).ready(function() {
       $('#product-list').DataTable();
   } );
</script>
<script>
   $(document).ready(function(){
       $("#verif").click(function(){
           var cle=$("#cle").val();
           var content=false;
           $.ajax({
               url:"/cleverif/"+cle,
               method:"GET", //First change type to method here
               success:function(response) {
                   if(response.resultat=='update')
                   {
                       $("#dateadd").html(response.date)
                       $('.error').addClass('hidden');
                       $('.success').removeClass('hidden');
                       $('.allredy').addClass('hidden');
                       content=true;
                   }
                   else if(response.resultat=='true')
                   {
                       $("#dateadd").html(response.date)
                       $('.error').addClass('hidden');
                       $('.success').addClass('hidden');
                       $('.allredy').removeClass('hidden');
                       content=true;
                   }
                   else {
                       $('.error').removeClass('hidden');
                       $('.success').addClass('hidden');
                       $('.allredy').addClass('hidden');
                   }
   
                   $('#popmod').modal('show');
   
                   // $("#content").html(response);
               },
               error:function(){
                   alert("error de connexion");
               }
           });
   
       });
   
   });
   
</script>
{% endblock %}