<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Pendaftaran <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">Pendaftaran</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> Daftar Pasien


            </div>
            <div class="col-md-4" align="right">
               
            </div>
        </div>
        <div class="box">
            <div class="box-body">
                <?= $this->session->flashdata('message'); ?>
                <h4 style="font-weight: bold;" class="text-primary">IDENTITAS </h4>

                <form action="<?= base_url('Pendaftaran/simpanpasien'); ?>" method="post">

                    <div class="row">
                        <div class="col-md-6">
                            <table width="100%" class="table">
                                <tr>
                                    <td width="25%">
                                        No KTP / NIK
                                    </td>
                                    <td>
                                        <input type="text" name="NIK" class="form-control" Value="<?= $getNoBpjs['peserta']['nik']; ?>" required>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Nama Depan
                                    </td>
                                    <td>
                                        <input type="text" name="FirstName" class="form-control" value="<?= $getNoBpjs['peserta']['nama']; ?>" required>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Tempat Lahir
                                    </td>
                                    <td>
                                        <input type="text" name="DOBPlace" class="form-control" required>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Kebangsaan
                                    </td>
                                    <td>
                                        <input type="text" name="Nationality" class="form-control" value="INDONESIA" required>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Agama
                                    </td>
                                    <td>
                                        <select name="Religion" class="form-control" required>
                                            <option value=""></option>
                                            <?php
                                            foreach ($religi as $agama) :
                                            ?>
                                                <option value="<?= $agama['Religion']; ?>"><?= $agama['Religion']; ?>
                                                </option>
                                            <?php
                                            endforeach;
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Pendidikan
                                    </td>
                                    <td>
                                        <select name="Education" class="form-control" required>
                                            <option value=""></option>
                                            <?php
                                            foreach ($edu as $pend) :
                                            ?>
                                                <option value="<?= $pend['ID']; ?>">
                                                    <?= $pend['EducationName']; ?>
                                                </option>
                                            <?php
                                            endforeach;
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Pasien Tipe
                                    </td>
                                    <td>
                                        <select name="PatientType" class="form-control" required>
                                            <option value=""></option>
                                            <?php
                                            foreach ($tipe as $tip) :
                                            ?>
                                                <option value="<?= $tip['TypeID']; ?>">
                                                    <?= $tip['TypeName']; ?>
                                                </option>
                                            <?php
                                            endforeach;
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Bahasa</td>
                                    <td>
                                        <select name="Bahasa" class="form-control" required>
                                            <option value="">- PILIH BAHASA -</option>
                                            <?php
                                            foreach ($bahasa as $bhs) :
                                            ?>
                                                <option value="<?= $bhs['Bahasa']; ?>"><?= $bhs['Bahasa']; ?></option>
                                            <?php
                                            endforeach;
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-md-6">
                            <table width="100%" class="table">
                                <tr>
                                    <td width="25%">
                                        Jenis Kelamin
                                    </td>
                                    <td>
                                        <select name="Sex" class="form-control" required>
                                            <option value="" disabled></option>
                                            <option value="2">Laki-laki</option>
                                            <option value="1">Perempuan</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Nama Belakang
                                    </td>
                                    <td>
                                        <input type="text" name="LastName" class="form-control" required>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Tanggal Lahir
                                    </td>
                                    <td>
                                        <input type="date" name="DOB" class="form-control" value="<?= $getNoBpjs['peserta']['tglLahir']; ?>" required>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Suku Bangsa
                                    </td>
                                    <td>
                                        <select name="SukuBangsa" class="form-control" required>
                                            <option value=""></option>
                                            <?php
                                            foreach ($suku as $dSuku) :
                                            ?>
                                                <option value="<?= $dSuku['SukuBangsa']; ?>"><?= $dSuku['SukuBangsa']; ?>
                                                </option>
                                            <?php
                                            endforeach;
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Status
                                    </td>
                                    <td>
                                        <select name="Status" class="form-control" required>
                                            <option value=""></option>
                                            <option value="SINGLE">SINGLE</option>
                                            <option value="MARRIED">MARRIED</option>
                                            <option value="WIDOW">WIDOW</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Pekerjaan
                                    </td>
                                    <td>
                                        <select name="Profession" class="form-control" required>
                                            <option value=""></option>
                                            <?php
                                            foreach ($prof as $pek) :
                                            ?>
                                                <option value="<?= $pek['Deskripsi']; ?>">
                                                    <?= $pek['Deskripsi']; ?>
                                                </option>
                                            <?php
                                            endforeach;
                                            ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Kartu BPJS / NIK Karyawan <br>
                                        <small style="color: red;">Asuransi, isi NIK</small>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" name="EmployeeID" value="<?= $getNoBpjs['peserta']['noKartu']; ?>">
                                    </td>
                                </tr>
                            </table>
                    </div>
            </div>
            <div class="box">
            <div class="box-body">
                    <h4 style="font-weight: bold;" class="text-primary">DOMISILI </h4>
                    <table class="table table-striped">
                        <tr>
                            <td width="15%">Provinsi</td>
                            <td>
                                <select name="HomeProvince" id="HomeProvince" class="form-control">
                                    <option value=""></option>
                                    <?php
                                    foreach ($provinsi as $prov) :
                                    ?>
                                        <option value="<?= $prov['PROVINCE']; ?>"><?= $prov['PROVINCE']; ?></option>
                                    <?php
                                    endforeach;
                                    ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Kota/Kabupaten</td>
                            <td>
                                <select name="HomeCity" id="HomeCity" class="form-control">

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Kecamatan</td>
                            <td>
                                <select name="Kecamatan" id="Kecamatan" class="form-control">

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Kelurahan</td>
                            <td>
                                <select name="Kelurahan" id="Kelurahan" class="form-control">

                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Alamat Domisili</td>
                            <td>
                                <textarea name="HomeAddress1" class="form-control" required></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td>Alamat KTP</td>
                            <td>
                                <textarea name="HomeAddress2" class="form-control" required></textarea>
                            </td>
                        </tr>
                    </table>
            </div></div>

            <div class="box">
            <div class="box-body">
            <h4 style="font-weight: bold;" class="text-primary">PENJAMIN </h4>
            <table class="table table-striped">
                        <tr>
                            <td width="15%">Asuransi / Penjamin</td>
                            <td>
                                <select name="CompanyCode" class="teanganData " data-live-search="true">
                                    <option value="">- Pilih -</option>
                                    <?php
                                    foreach ($asuransi as $penjamin) :
                                    ?>
                                        <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) :
                                    ?>
                                        <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" class="form-control" required>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td align="right">
                                <a href="" class="btn btn-sm btn-danger bg-red-gradient"><i class="fa fa-fw fa-undo"></i> Reset</a>
                                <button type="submit" class="btn btn-sm btn-success bg-green-gradient"> SIMPAN <i class="fa fa-save fa-fw"></i></button>
                            </td>
                        </tr>
                    </table>
                    </form> 
        </div></div>
        </div>

    </section>
</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() {
        // PROVINSI
        $('#HomeProvince').change(function() {
            var _provinsi = document.getElementById("HomeProvince").value;
            // alert(_provinsi);
            $.ajax({
                url: "<?= base_url('Pendaftaran/homecity'); ?>",
                method: "POST",
                data: {
                    nprovinsi: _provinsi
                },
                async: true,
                dataType: 'json',
                success: function(data) {

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

        // KABUPATEN - KECAMATAN
        $('#HomeCity').change(function() {
            var _kabupaten = document.getElementById("HomeCity").value;
            // alert(_kabupaten);
            $.ajax({
                url: "<?= base_url('Pendaftaran/kecamatan'); ?>",
                method: "POST",
                data: {
                    nkabupaten: _kabupaten
                },
                async: true,
                dataType: 'json',
                success: function(data) {

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

                }
            });

            return false;
        });

        $('#Kecamatan').change(function() {
            var _kecamatan = document.getElementById("Kecamatan").value;
            var _kabupaten = document.getElementById("HomeCity").value;
            // alert(_kabupaten + ' | ' + _kecamatan);
            $.ajax({
                url: "<?= base_url('Pendaftaran/kelurahan'); ?>",
                method: "POST",
                data: {
                    nkecamatan: _kecamatan,
                    nkabupaten: _kabupaten
                },
                async: true,
                dataType: 'json',
                success: function(data) {

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

                }
            });

            return false;
        });

        $('#Kelurahan').change(function() {
            $("#domisili1").show();
            $("#domisili2").show();
        });

    });
</script>