<?php require_once('topo.php');?>
<?php require_once('lateral.php');?>
<?php
//VERIFICAÇÃO DO PROGRAMA E NÍVEL PERMISÃO
$idprograma_pagina = 56;
//VERIFICA A AÇÃO DO USUÁRIO

$SelecionaProgramaUsuario = Seleciona("usuarios_programas", "WHERE idusuario='".$_SESSION['usuarioID']."' AND idprograma='$idprograma_pagina'", "LIMIT 0,1");
while($progama_usuario = mysql_fetch_array($SelecionaProgramaUsuario)){
$AcaoUsuario = $progama_usuario['acao'];
}

//AÇÕES
// Visualizar
// Inserir
// Completa

//MASTER ACESSO
if($_SESSION['master'] == 1){
   $AcaoUsuario = "Completa"; 
}

//FIM VERIFICAÇÃO PROGRAMA
?>
          
      <!-- Right side column. Contains the navbar and content of the page -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Reembolsos
            <small>listagem de reembolsos cadastrados</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Reembolsos</a></li>
            <li class="active">Listagem</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12"><!-- /.box -->

              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Listagem de Reembolsos</h3>
                    <?php
                    //VERIFICAR USUARIO PROGRAMA
                    if($AcaoUsuario == "Inserir" or $AcaoUsuario == "Editar" or $AcaoUsuario == "Completa"){ 						
                    ?>                  
                  <button type="button" class="btn btn-primary" style=" float:right;" onclick="location.href='manutencao_reembolsos.php';"><i class="fa fa-plus-circle" aria-hidden="true"></i> Novo Reembolso</button>
                  <?php }?>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th style="cursor:pointer">Código</th>
                        <th style="cursor:pointer">Tipo</th>                     
                        <th style="cursor:pointer">Obra</th>
                        <th style="cursor:pointer">Valor</th>
                        <th style="cursor:pointer">Data</th>
                        <th style="cursor:pointer">Status</th>
                        <th style="cursor:pointer">Solicitante</th>                        
                        <th style="cursor:pointer"></th>                        
                      </tr>
                    </thead>
                    <tbody>
                    <?php

					if($_SESSION['master'] != ""){				
					$Seleciona = Seleciona("reembolsos_financeiro", "", "ORDER BY idreembolso DESC");
					}else{
					$Seleciona = Seleciona("reembolsos_financeiro", "WHERE idusuario_cadastro='".$_SESSION['usuarioID']."'  OR idusuario='".$_SESSION['usuarioID']."'", "ORDER BY idreembolso DESC");
					}
					while($linha = mysql_fetch_array($Seleciona)){
					?>
                      <tr style="cursor:pointer" onclick="location.href='manutencao_reembolsos.php?idreembolso=<?php echo $linha['idreembolso'];?>';">
                        <td><?php echo $linha['idreembolso'];?></td>
                        <td><?php echo $linha['tipo'];?></td>
                        <td>><?php echo RetornaCampoGeral("obras", $linha['idobra'], "idobra", "codmax");?></td>                        
                        <td><?php echo "R$ " . number_format($linha['valor'], 2, ',', '.');?></td>
                        <td><?php echo InverteDataNovoSeparador($linha['data'], "-", "/");?></td>
                        <td><?php echo $linha['status'];?></td>
                        <td><?php echo LoginUsuario($linha['idusuario']);?></td>                        
                        <td><button type='button' class='btn btn-success'><i class="fa fa-search" aria-hidden="true"></i></button></td>
                      </tr>
                      <?php }?>
                    </tbody>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
<?php require_once('rodape.php');?>