<div class="content-wrapper">
    <?php require('./layout/headerpage.php'); ?>
    <div class="container col-12 mb-4 pb-5">
        <div class="row">
            <div class="col-12">
                <div class="col-12">
                    <div class="card  mx-3">
                        <div class="timeline-header bg-primary py-2 pl-2">
                            <b class="text-light judul"><span class="bi bi-stickies"></span> Daftar Jurnal Manual</b>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body my-4 mx-4">
                            <form action="" method="post">
                                <table id="example51" class="table table-bordered table-striped table-hover table-sm  mb-4">
                                    <thead>
                                        <tr>
                                            <th><input type="checkbox" class=" check_all"></th>
                                            <th>Edit</th>
                                            <th>Tanggal</th>
                                            <th>Jurnal</th>
                                            <th>Uraian</th>
                                            <th>Jumlah</th>


                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $crud = new crudData();
                                        $showUser = $crud->showTableOrder($tb_jurnal, 'tanggal desc');
                                        while ($data = $showUser->fetch(PDO::FETCH_OBJ)) {
                                            $link = new linkpage;
                                            $clsNeraca = new simakom_neraca;
                                            $jenis = $data->jenis . " - " . $clsNeraca->valueJurnal($data->jenis);

                                            echo "
                                                    <tr>
                                                        <td width='5px'>
                                                            <input type='checkbox' class='d-inline small chk_boxes1' name='id_jurnal[]' value='$data->id'> 
                                                        </td>
                                                        <td width='75px' align='center'>
                                                        <a " . $link->pageID($data->id, 'laporan/neraca/jurnal_edit') . " class='badge badge-primary  px-1 py-1 d-inline''> <i class='bi bi-pencil-square'></i> EDIT</a>
                                                        </td>
                                                        <td  width='120px' align='center'>" . $format->dateToIndo($data->tanggal) . "</td>
                                                        <td  width='300px' align='left'>$jenis</td>
                                                        <td>$data->uraian</td>
                                                        <td  width='120px' align='right'>" . $format->ribuan($data->jumlah) . "</td>
                                                        
                                                        </tr>";
                                        };
                                        ?>
                                    </tbody>
                                </table>
                                <div class="div d-inline">
                                    <a <?php echo $link->page('laporan/neraca/jurnal_create'); ?> class="btn btn-primary btn-xs mb-2 btn-rounded small px-2"> <i class="bi bi-person-plus"></i> TAMBAH</a>
                                    <button type="submit" name="submit" class="btn btn-primary btn-xs mb-2 btn-rounded small px-2"> <i class="bi bi-trash"></i> HAPUS</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- /.content-wrapper -->
<script type="text/javascript">
    $(function() {
        $('.check_all').click(function() {
            $('.chk_boxes1').prop('checked', this.checked);
        });
    });
</script>

<?php
if (isset($_POST['submit']) && isset($_POST['id_jurnal'])) {
    foreach ($_POST['id_jurnal'] as $id) {
        $user_admin = new crudData();
        $delete = $user_admin->deleteData($tb_jurnal, 'id', $id);
    };

    $direct = new toast();
    echo  $direct->redirect('toast', 'delete', 'laporan/neraca/jurnal_read');
};
