<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            LHP <label style="font-weight: normal; font-size:15px" id="timer"></label>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Sis-RS</a></li>
            <li class="active">ICD</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row" style="margin-bottom: 10px;">
            <div class="col-md-8">
                <i class="fa fa-fw fa-calendar"></i> <b>LHP</b>


            </div>
            <div class="col-md-4" align="right">
                <form action="<?= base_url('DashboardLaporan/carilhp'); ?>" method="get">
                    <table>
                        <tr>
                            <td><input type="date" class="form-control" name="tgl1" id="tgl1" value="<?= date('Y-m-d'); ?>"></td>
                            <td><input type="date" class="form-control" name="tgl2" id="tgl2" value="<?= date('Y-m-d'); ?>"></td>
                            <td><button style="border-radius: 0px;" type="submit" class="btn btn-sm btn-primary">Cari</button></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="box">
            <div class="box-body">
                <?= $this->session->flashdata('message'); ?>
                <div class="table-responsive">
                        <table id="example1" class="table table-bordered dataTable dtr-inline">
                    <thead>
                        <tr>
                            <th>Nama Pasien</th>
                            <th>Case ID</th>
                            <th>Penjamin</th>
                            <th>Kas</th>
                            <th>Piutang</th>
                            <th>Adm</th>
                            <th>P.Umum</th>
                            <th>Tindakan</th>
                            <th>Lab</th>
                            <th>Fisio</th>
                            <th>P.Gigi</th>
                            <th>Farmasi</th>
                            <th>Inhalasi</th>
                            <th>Message</th>
                            <th>Bidan</th>
                            <th>Alkes</th>
                            <th>Lain-Lain</th>
                            <th>Total</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        $grandTotal = 0; 
                        $payment = 0; 
                        $total1 = 0; 
                        $total2 = 0; 
                        $adm = 0; 
                        $umum = 0; 
                        $tindakan = 0; 
                        $laboratory = 0; 
                        $polyGigi = 0; 
                        $farmasi = 0; 
                        foreach($lhp as $l) : ?>
                        <tr>
                            <td><?= $l['Description']; ?></td>
                            <td><?= $l['Case ID']; ?></td>
                            <td><?= $l['CompanyName']; ?></td>
                            <td><?= number_format($l['PAYMENT'],0); ?></td>
                            <td><?= number_format($l['Total'],0); ?></td>
                            <td><?= number_format($l['ADM'],0); ?></td>
                            <td><?= number_format($l['UMUM'],0); ?></td>
                            <td><?= number_format($l['TINDAKAN'],0); ?></td>
                            <td><?= number_format($l['LABORATORY'],0); ?></td>
                            <td>-</td>
                            <td><?= number_format($l['POLI_GIGI'],0); ?></td>
                            <td><?= number_format($l['FARMASI'],0); ?></td>
                            <td>-</td>
                            <td>-</td>
                            <td>-</td>
                            <td>-</td>
                            <td>-</td>
                            <td><?php 
                            $total = $l['ADM'] + $l['UMUM']+ $l['TINDAKAN']+ $l['LABORATORY']+ $l['POLI_GIGI']+ $l['FARMASI']; 
                            echo number_format($total,0); 

                            $total2 += $total;

                            $grandTotal += $total;
                            $payment += $l['PAYMENT'];
                            $total1 += $l['Total'];
                            $adm += $l['ADM'];
                            $umum += $l['UMUM'];
                            $tindakan += $l['TINDAKAN'];
                            $laboratory += $l['LABORATORY'];
                            $polyGigi += $l['POLI_GIGI'];
                            $farmasi += $l['FARMASI'];
                            ?></td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                    <tfoot>
                        <tr>
                            <th>Total</th>
                            <th></th>
                            <th></th>
                            <th><?= number_format($payment,0); ?></th>
                            <th><?= number_format($total,0); ?></th>
                            <th><?= number_format($adm,0); ?></th>
                            <th><?= number_format($umum,0); ?></th>
                            <th><?= number_format($tindakan,0); ?></th>
                            <th><?= number_format($laboratory,0); ?></th>
                            <th></th>
                            <th><?= number_format($polyGigi,0); ?></th>
                            <th><?= number_format($farmasi,0); ?></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th><?= number_format($total2,0); ?></th>
                        </tr>
                    </tfoot>
                </table>
                <h3 style="display:none;">Total : <?php echo number_format($grandTotal,0); ?></h3>
            </div>
        </div>
    </section>
</div>