<?php $r="../";
require_once($r."inc/funciones.php");
validNotSession($r);
$spe=$_SESSION['perfil'];
if($spe!=$pad && $spe!=$psu){ echo '<div class="alert alert-danger  alert-dismissible text-center"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><h6>NO TIENES PERMISO PARA ESTA SECCION</h6></div>';exit();}
$mysqli = connectDB($r);
$row1 = $mysqli->query("SELECT * FROM z_gastos");
?>
<!DOCTYPE html>
<html lang="en">
  <?php include $r."inc/head.php"; ?>
<body class="fixed-nav sidenav-toggled sticky-footer bg-dark" id="page-top">
  <div class="container">
    <div id="mensaje" style="position:fixed;width:90%;padding-left:10%;top:20px;left:0px;margin:0 auto;z-index:9999;"></div>
  </div>
  <?php include $r."inc/nav.php"; ?>
  
  <div class="content-wrapper">
    <div class="container-fluid">
      <div class="card mb-3">
        <div class="card-header">
          <i class="fa fa-table"></i> <?  ?></div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
              <thead>
                <tr>
                  <th>fecha</th>
                  <th>tipo</th>
                  <th>tipo</th>
                  <th>tipo</th>
                  <th>nota</th>
                  <th>cantidad</th>
                  <th></th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>fecha</th>
                  <th>tipo</th>
                  <th>tipo</th>
                  <th>tipo</th>
                  <th>nota</th>
                  <th>cantidad</th>
                  <th></th>
                </tr>
              </tfoot>
              <tbody>
                    <?php while($row2 = $row1->fetch_assoc()) { ?>
                      <tr>
                        <td><?php echo $row2["fecha"] ?></td>
                        <td><?php $usuario = suser($row2["iduser"]); echo $usuario['nombre']; ?></td>
                        <td><?php $idcategoria=$row2["categoria"]; $row3 = $mysqli->query("SELECT * FROM z_cinversiones WHERE id='$idcategoria'");$row4 = $row3->fetch_assoc();echo $row4['nombre']?></td>
                        <td><?php $idtipo=$row2["tipo"]; $row5 = $mysqli->query("SELECT * FROM z_tinversiones WHERE id='$idtipo'");$row6 = $row5->fetch_assoc();echo $row6['nombre']?></td>
                        <td><?php echo $row2["nota"] ?></td>
                        <td class="h6 text-danger text-right">$ <? echo $row2["cantidad"] ?> COP</td>
                        <td width="25px"><a onClick="return popitup('<?php echo $row2["archivo"] ?>')"  href="<?php echo $row2["archivo"] ?>"><i class="fa fa-file"></i></a></td>
                    
                        </tr>
                    <?php
                    }
                    ?>
              <tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
  <?php include $r."inc/foot.php"; ?>
</body>
<script>
$('#dataTable').DataTable( {
        "order": [[ 4, "desc" ]]
    } );
</script>
<script>
    function popitup(url){
	    newwindow=window.open(url,'name','height=600,width=600'); 
	    if (window.focus) {newwindow.print();}
	    return false; 
    }
</script>
</html>    