<%- include('block_inicio') %>
<%- include('barra_menu') %>
<div class="container">
    
  
  <!--Resto dispositivos-->
  <div class="row d-none d-sm-block">
      <br><br>
    <div class="row d-flex justify-content-center" >
      <h2>ESTAD√çSTICAS</h2>
    </div>
    <br><br>

    <div id="cont-estadistica" class=" d-flex flex-column align-items-center p-3" style="width: auto; background: rgb(189, 133, 226); border-radius: 15px;">
    </div><!--cont estadistica-->
    

  </div>

</div>
<br><br>
<%- include('block_end') %>


<style>
img{cursor:pointer;}



</style>

<script>
let contEestadistica = document.getElementById('cont-estadistica')

window.onload = ()=>{
  $.ajax({
    type:'POST',
    url:'/estadisticaspsico',
    data:{cuatrimestre:queCuatrimestreEs()}
    }).done(async function(res){
          $.each(res,function(key,val){
            $('#cont-estadistica').append(`<label class='white'>${val.name}</label>
      <div class='progress' style='height: 40px; width: 40%; margin-top:-0.9%'>
        <div class='progress-bar' role='progressbar' style='width:${val.porcentaje}' aria-valuemin='0' aria-valuemax='100'>${val.porcentaje}</div>
      </div> <br>`)
          })//end each
    }).fail(async function(err){
      toastr.error('La Operacion NO Pudo Resolverse...', 'ERROR', { timeOut: 3000 })
      await sleep(2000)
      //window.location.reload()
    })
}//end






function queCuatrimestreEs(){
  let mes = new Date()
  if((mes.getMonth() + 1) <= 7){
    return '1'
  }
  if((mes.getMonth() + 1) >= 8){
    return '2'
  }
}
</script>