<?php
include("header.php");
setlocale(LC_MONETARY, 'es_MX');
$sql = "SELECT * FROM ie_detalle,ie_concepto WHERE `ie_det_con_id` = ie_con_id order by ie_det_con_id desc";
$resultado = mysqli_query($mysqli, $sql);
?>

<div class="content-wrapper">
    <!-- START PAGE CONTENT-->
    <div class="page-heading">
        <h1 class="page-title">Ingresos y Egresos</h1>
        <ol class="breadcrumb">
            <li class="breadcrumb-item">
                <button onclick="location.href='ie_nie.php?tie=Ingreso'" type="button" class="btn btn-primary">Ingresos</button>
                <button onclick="location.href='ie_nie.php?tie=Egreso'" type="button" class="btn btn-primary">Egresos</button>
                <button onclick="location.href='iibalance.php?ti=6&fi=<?echo date('Y-m-d');?>&ff=<?echo date('Y-m-d');?>'" type="button" class="btn btn-primary">Informe</button>
            </li>
            <li class="breadcrumb-item"></li>
        </ol>
    </div>
    <div class="page-content fade-in-up">
        <div class="ibox">
            <div class="ibox-head">
                <div class="ibox-title">Listado</div>
            </div>
            <div class="ibox-body">
                <table class="table table-striped table-bordered table-hover" id="dataTableIE" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th> ID </th>
                            <th> CONCEPTO </th>
                            <th> FECHA </th>
                            <th> DESCRIPCION </th>
                            <th> INGRESO</th>
                            <th> EGRESO</th>
                            <th> </th>
                            <th> </th>

                        </tr>
                    </thead>
                    <tbody>
                        <?php $NUM = 0;
                        while ($row = mysqli_fetch_array($resultado)) {
                            $NUM = $NUM + 1 ?>
                            <tr>
                                <td><?php echo $row['ie_det_id']; ?></td>
                                <td><?php echo $row['ie_con_descripcion']; ?></td>
                                <?
                                $fechaie = date_create($row['ie_det_fecha']);
                                $fechaie = date_format($fechaie, "d/m/Y");?>
                                <td><?php echo $fechaie; ?></td>
                                <td><?php echo $row['ie_det_descripcion']; ?></td>
                                <td><?php if ($row['ie_con_tipo']=='Ingreso') echo money_format('%.2n', $row['ie_det_importe']); else echo '$ -----------'; ?></td>
                                <td><?php if ($row['ie_con_tipo']=='Egreso') echo money_format('%.2n', $row['ie_det_importe']); else echo '$ -----------'; ?></td>

                                <td> </td>
                                <td> <a href="#" data-href="ie_nie.php?id=<?php echo $row['ie_det_id'] . '&borrar=1&tie='; ?>" data-toggle="modal" data-target="#confirm-delete">
                                        <div class="icon-item"><i class="fa fa-trash"></i></div>
                                    </a> </td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
        <?php
        include('footer.php');
        //<a href="ie_nie.php?id=<?php echo $row['ie_det_id']; ?>&edt=1&tie=<?echo $row['ie_con_tipo'];?>"><div class="icon-item"><i class="fa fa-edit"></i></div></a> 
        ?>