<div class="row">

<?php

$dia = date("d");

$mes = date("m");

$ano = date("Y");

$date = $ano."-".$mes."-".$dia;

?>

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Poupanca'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>

        <div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-red">

            <div class="inner">

      

      <h4 id="poupanca">

      </h4>

              <p>Saldo Poupado </p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/fair.png">

              <i class=""></i>

            </div>

             <?php echo ($pread == 1) ? '<a href="saldopoupado_data.php?tid='.$_SESSION['tid'].'&&mid='.base64_encode("408").'" class="small-box-footer">Mais info<i class="fa fa-arrow-circle-right"></i></a>' : '<a href="#" class="small-box-footer">-------</a>'; ?>

          </div>

        </div>

<?php

}

else{

  echo '';

}

?>

        <!-- ./col -->

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Emprestimos'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>

        <div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-green">

            <div class="inner">

      

<h4 id="emprestimos">



</h4>

      <p>Emprestimos</p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/fair.png"> <i class=""></i> </div>

             <?php echo ($pread == 1) ? '<a href="listloans.php?tid='.$_SESSION['tid'].'&&mid='.base64_encode("405").'" class="small-box-footer">Mais info<i class="fa fa-arrow-circle-right"></i></a> </div>' : '<a href="#" class="small-box-footer">-------</a>'; ?>

        </div>

<?php

}

else{

  echo '';

}

?>







<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Emprestimos'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>

        <div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-green">

            <div class="inner">

			

<h4 id="saldos">

</h4>

			<p>Saldo</p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/fair.png"> <i class=""></i> </div>

             <?php echo ($pread == 1) ? '<a href="listloans.php?tid='.$_SESSION['tid'].'&&mid='.base64_encode("405").'" class="small-box-footer">Mais info<i class="fa fa-arrow-circle-right"></i></a> </div>' : '<a href="#" class="small-box-footer">-------</a>'; ?>

        </div>

<?php

}

else{

	echo '';

}

?>

        <!-- ./col -->

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Mutuarios'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>

       <div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-red">

            <div class="inner">

 			

			<h4 id="mutuarios">

			</h4>

              <p>Mutuarios</p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/school.png">

              <i class=""></i>

            </div>

            <?php echo ($pread == 1) ? '<a href="listborrowers.php?tid='.$_SESSION['tid'].'&&mid='.base64_encode("403").'" class="small-box-footer">Mais info<i class="fa fa-arrow-circle-right"></i></a>' : '<a href="#" class="small-box-footer">-------</a>'; ?>

          </div>

        </div>

<?php

}

else{

	echo '';

}

?>

		

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Funcionarios'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>

		<div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-yellow">

            <div class="inner">

 			

			<h4>

<?php

$select = mysqli_query($link, "SELECT * FROM user") or die (mysqli_error($link));

$num = mysqli_num_rows($select);

echo $num;

?>

			</h4>

              <p>Funcionarios</p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/comittee.png">

              <i class=""></i>

            </div>

            <?php echo ($pread == 1) ? '<a href="listemployee.php?tid='.$_SESSION['tid'].'&&mid='.base64_encode("409").'" class="small-box-footer">Mais infos<i class="fa fa-arrow-circle-right"></i></a>' : '<a href="#" class="small-box-footer">-------</a>'; ?>

          </div>

        </div>

<?php

}

else{

	echo '';

}

?>

		

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Configuracoes Gerais'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1')

{

?>

		<div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-green">

            <div class="inner">

 			

			<h4>

<?php

$select = mysqli_query($link, "SELECT * FROM systemset") or die (mysqli_error($link));

$num = mysqli_num_rows($select);

echo $num;

?>

			</h4>

              <p>Configuracao de Empresa</p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/setting.png">

              <i class=""></i>

            </div>

            <a href="system_set.php?tid=<?php echo $_SESSION['tid']; ?>&&mid=<?php echo base64_encode("411"); ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>

          </div>

        </div>

<?php

}

else{

	echo '';

}

?>

		



	

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Pagamentos em Atraso'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>	

		   <div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-yellow">

            <div class="inner">

 			

			<h4 id="pagaatrazo">

			</h4>

              <p>Pagamentos em Atrazo</p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/fair.png">

              <i class=""></i>

            </div>

            <a href="missedpayment.php?tid=<?php echo $_SESSION['tid']; ?>&&mid=<?php echo base64_encode("407"); ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>

          </div>

        </div>

<?php

}

else{

	echo '';

}

?>



        <!-- ./col -->

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Pagamentos'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>

        <div class="col-lg-3 col-xs-6">

          <!-- small box -->

          <div class="small-box bg-red">

            <div class="inner">

 			

			<h4 id="pagamentos">

			</h4>

              <p>Pagamentos </p>

            </div>

            <div class="icon"><img height="80" width="80" src="../img/fair.png">

              <i class=""></i>

            </div>

             <?php echo ($pread == 1) ? '<a href="listpayment.php?tid='.$_SESSION['tid'].'&&mid='.base64_encode("408").'" class="small-box-footer">Mais info<i class="fa fa-arrow-circle-right"></i></a>' : '<a href="#" class="small-box-footer">-------</a>'; ?>

          </div>

        </div>

<?php

}

else{

	echo '';

}

?>

        <!-- ./col -->	





		

	 <section class="content">

      <div class="row">

		</div>

		

		

		

		<!--  Event codes starts here-->

	

		 

	        <div class="box box-info">

<?php

$check = mysqli_query($link, "SELECT * FROM emp_permission WHERE tid = '".$_SESSION['tid']."' AND module_name = 'Emprestimos'") or die ("Error" . mysqli_error($link));

$get_check = mysqli_fetch_array($check);

$pcreate = $get_check['pcreate'];

$pread = $get_check['pread'];

if($pcreate == '1' || $pread == '1')

{

?>

            <div class="box-body">
              

			   <div class="alert alert-info" align="center" class="style2" style="color: #B30B00">Alertas de Pagamentos</div>

             

			   <div class="alerta">
           <table id="example1" class="table table-bordered table-striped">
              <thead>
                <tr>
                  <th>ID</th>
                  <th>Conta</th>
                  <th>Descricao</th>
                  <th>Valor</th>
                  <th>Saldo</th>
                  <th>Cliente</th>
                  <th>Agente</th>
                  <th>Aprovado por</th>
                  <th>Data de Aprov</th>
                  <th>Dia de Pagamento</th>
                </tr>
              </thead>
              <tbody class="control">
                
              </tbody>
           </table>
         </div>	
         <div>
           <form method="POST" action="">
              <input type="hidden" name="valor" value="0">
              <button name="save" type="submit" class="btn btn-danger btn-flat"><i class="fa fa-stop">&nbsp;Parar notificacao</i></button>
           </form>
         </div>              

			</div>

<?php

}

else{

	echo '';

}

?>			

       

</div>	

</div>	

<script type="text/javascript">
  $(function() {
      function popularEmprestimos() {
        $.ajax({
            url: 'ajax/popularEmprestimos.php',
            type: 'GET',
            success: function(data) {
              $("#emprestimos").html(data);
            },
            error: function() {
              $("#emprestimos").html("Erro ao popular o total de emprestimos!");
            }
        });
      }
      setInterval(popularEmprestimos, 1000);

      function popularSaldos() {
        $.ajax({
            url: 'ajax/popularSaldos.php',
            type: 'GET',
            success: function(data) {
              $("#saldos").html(data);
            },
            error: function() {
              $("#saldos").html("Erro ao popular o total de saldos!");
            }
        });
      }
      setInterval(popularSaldos, 1000);

      function popularMutuarios() {
        $.ajax({
            url: 'ajax/popularMutuarios.php',
            type: 'GET',
            success: function(data) {
              $("#mutuarios").html(data);
            },
            error: function() {
              $("#mutuarios").html("Erro ao popular o total de mutuarios!");
            }
        });
      }
      setInterval(popularMutuarios, 1000);


      function popularPagamentosAtrazo() {
        $.ajax({
            url: 'ajax/popularPagamentosAtrazo.php',
            type: 'GET',
            success: function(data) {
              $("#pagaatrazo").html(data);
            },
            error: function() {
              $("#pagaatrazo").html("Erro ao popular o total de pagamentos em atraso!");
            }
        });
      }
      setInterval(popularPagamentosAtrazo, 1000);


      function popularPagamentos() {
        $.ajax({
            url: 'ajax/popularPagamentos.php',
            type: 'GET',
            success: function(data) {
              $("#pagamentos").html(data);
            },
            error: function() {
              $("#pagamentos").html("Erro ao popular o total de pagamentos!");
            }
        });
      }
      setInterval(popularPagamentos, 1000);

      function popularPoupancas() {
        $.ajax({
            url: 'ajax/popularPoupancas.php',
            type: 'GET',
            success: function(data) {
              $("#poupanca").html(data);
            },
            error: function() {
              $("#poupanca").html("Erro ao popular o total de poupanca!");
            }
        });
      }
      setInterval(popularPoupancas, 1000);

      function controladorPagamentos() {
        $.ajax({
            url: 'ajax/controladorPagamentos.php',
            type: 'GET',
            success: function(data) {
              $(".control").html(data);
            },
            error: function() {
              $(".control").html("Erro ao popular os pagamentos em atraso!");
            }
        });
      }
      setInterval(controladorPagamentos, 1000);

      function notify() {
        $.ajax({
            url: 'ajax/notify.php',
            type: 'GET',
            success: function(data) {
                $(".box-body").prepend(data);
            },
            error: function() {
              $(".noty").html("Erro ao notificar!");
            }
        });
      }
      notify();
  });
</script>
<?php  
if (isset($_POST['save'])) {
  $valor = $_POST['valor'];
  $check = mysqli_query($link, "UPDATE notify SET notify = '$valor'") or die ("Error" . mysqli_error($link));
}
?>
<!-- Desenvolvido por Milagre Lazaro Nicodemos-->