<?PHP 
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');
$com_id=$_GET['com_id'];
?>

<table class="table table-bordered table-hover table-striped">
<thead>
    <tr>
        <th>FECHA</th>
        <th>VALOR</th>
        <th>MEDIO DE PAGO</th>
        <th style="width:15px"></th>
        <th style="width:15px"></th>
    </tr>
    </thead>
    <?PHP 
    $sql=mysqli_query($con, "SELECT * from  compra_abonos where compras_com_id='$com_id' ");
    while ($row=mysqli_fetch_array($sql))
    {
        $coab_id=$row["coab_id"];
        $coab_abono=$row["coab_abono"];
        $coab_fecha=$row["coab_fecha"];
        $medio_pago=$row["medio_pago"];
        $mov_id=$row["mov_id"];
    ?>
    <tr>
        <td><?php echo $coab_fecha ?></td>
        <td ><p align="right"><?php echo number_format($coab_abono,0); ?></p></td>
        <td><?php echo $medio_pago ?></td>
        <td>
            <?php
            $files = glob("../img/factura-abono/$com_id/$coab_id.jpg");
            if(count($files) > 0) 
            { 
                foreach($files as $file) 
                { 
            ?>

            <?php $nu=rand(1,1000); $nu; ?>
            <a href="img/factura-abono/<?php echo $com_id ?>/<?php echo $coab_id.'.jpg?' .$nu .''; ?>" class="ui-lightbox">
                <center>
                    <div class="contenedor"> 
                        <img  class="marca" src="img/factura-abono/<?php echo $com_id ?>/<?php echo $coab_id.'.jpg?' .$nu .''; ?>" alt=""/>
                    </div>
                </center>
            </a>
       
            <?php } } else { ?>
        
            <a href="img/factura-abono/sin_imagen/sin_imagen.jpg" class="ui-lightbox">
                <center><div class="contenedor"><img class="marca" src="img/factura-abono/sin_imagen/sin_imagen.jpg" alt=""/></div></center>
            </a>
            <?php } ?>
        </td>
        <td>
        <?php
        if($mov_id==null)
        {
            $sql1=mysqli_query($con, "SELECT * from  compras where com_id='$com_id' ");
            $row1=mysqli_fetch_array($sql1);
            $com_estado=$row1["com_estado"];
            if ($com_estado=='Sin pagar') { ?>
                <a href="#" class='btn btn-xs btn-danger' title='Eliminar Abono' onclick="eliminar_abono('<?php echo  $coab_id;?>');" ><i class="btn-icon-only icon-remove"></i></a> 
        <?php } } ?>
        </td>
    </tr>
<?php   }  ?>
</table>