<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Data Pasien
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Vclaim</a></li>
            <li class="active">Dashboard</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="box">
            <div class="box-body">
                <a href="" data-toggle="modal" data-target="#baru" class="btn btn-sm btn-primary"><i class="fa fa-fw fa-plus"></i> Baru</a> 
                <a href="" class="btn btn-sm btn-success"><i class="fa fa-fw fa-search"></i> Cari</a> 
                <a href="" class="btn btn-sm btn-warning"><i class="fa fa-fw fa-print"></i> Cetak Kartu Pasien</a> 
            </div><!-- /.box-body -->
        </div><!-- /.box -->

    </section><!-- /.content -->

    <!-- Main content -->
    <section class="content" style="margin-top: -180px;">
        <!-- Default box -->
        <div class="box">
            <div class="box-body">
                <form action="<?= base_url('pasien/updateAsuransi/'.$pasien['PatientCode']); ?>" method="post">
                <h4 style="font-weight: bold;" class="text-primary">PASIEN PENJAMIN </h4>
                
                <table class="table table-striped">
                    <tr>
                        <td width="15%">Asuransi / Penjamin</td>
                        <td>
                            <select name="CompanyCode" class="teanganData " data-live-search="true" required>
                                <option value="">- Pilih -</option>
                                <?php 
                                foreach($asuransi as $penjamin):
                                    if($pasien['CompanyCode'] == $penjamin['CompanyCode']){
                                        ?>
                                        <option selected value="<?= $penjamin['CompanyCode'];?>"><?= $penjamin['CompanyName'];?></option>
                                        <?php 

                                    }else{
                                        ?>
                                        <option value="<?= $penjamin['CompanyCode'];?>"><?= $penjamin['CompanyName'];?></option>
                                        <?php 

                                    }
                                endforeach;
                                ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td width="15%">Perusahaan</td>
                        <td>
                            <select id="perusahaan" name="perusahaan" class="teanganData " data-live-search="true">
                                <option value="">- Pilih -</option>
                                <?php 
                                foreach($perusahaan as $per):
                                    if($pasien['NAMA PERUSAHAAN'] == $per['NAMA PERUSAHAAN']){
                                        ?>
                                        <option selected value="<?= $per['NAMA PERUSAHAAN'];?>"><?= $per['NAMA PERUSAHAAN'];?></option>
                                        <?php 
                                    }else{
                                        ?>
                                        <option value="<?= $per['NAMA PERUSAHAAN'];?>"><?= $per['NAMA PERUSAHAAN'];?></option>
                                        <?php 
                                    }
                                endforeach;
                                ?>
                            </select>
                            <select name="kode" id="kode" hidden></select>
                        </td>
                    </tr>
                    <tr>
                        <td>No.HP / WhatsApp Aktif</td>
                        <td>
                            <input type="number" name="CellPhone" value="<?= $pasien['CellPhone'];?>" class="form-control" required>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td align="right">
                            
                            <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-save fa-fw"></i> UPDATE </button>
                        </td>
                    </tr>
                    
                </table>
                </form>
            </div><!-- /.box-body -->
            <div class="box-footer">
                <?= date('d F Y'); ?>
            </div><!-- /.box-footer-->
        </div><!-- /.box -->

    </section><!-- /.content -->
</div><!-- /.content-wrapper -->

<!-- Modal -->
<div class="modal fade" id="baru" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
    aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-pencil"></i> PASIEN BARU</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">

                <form action="<?= base_url('pasien/formNik'); ?>" method="get">
                    <input type="text" placeholder="NIK..." class="form-control" required name="nik">
                    <button style="width: 100%; border-radius: 0px;" type="submit" class="btn btn-sm btn-success">Daftar By NIK Bridging</button>
                </form>

                <div style="margin-top: 5px; text-align:right">
                    <a href="">Daftar Biasa</a>
                </div>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-1.4.1.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
    $('#perusahaan').change(function() {
        var _perusahaan = document.getElementById("perusahaan").value;
        // alert(_provinsi);
        $.ajax({
            url: "<?= base_url('pasien/perusahaanKode'); ?>",
            method: "POST",
            data: {
                nperusahaan: _perusahaan
            },
            async: true,
            dataType: 'json',
            success: function(data) {

                var html = '';
                var i;
                for (i = 0; i < data.length; i++) {
                    html += '<option value="' + data[i].KODE + '">' + data[i].KODE +
                        '</option>';
                }
                $('#kode').html(html);
            }
        });
        return false;
    });

});
</script>