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

    <section class="content">
        <?php
        extract($_GET);
        date_default_timezone_set("Asia/Jakarta");
        if ($countMr > 0) {
        ?>
            <div class="row">
                <div class="col-md-3">
                    <!-- Profile Image -->

                    <div class="box box-widget widget-user-2">
                        <div class="widget-user-header bg-aqua-active">
                            <div class="widget-user-image">
                                <?php
                                if ($mr['Sex'] == '2') {
                                ?>
                                    <img class="img-circle" src="<?= base_url('images/male.png'); ?>" alt="User Avatar">
                                <?php
                                } else {
                                ?>
                                    <img class="img-circle" src="<?= base_url('images/female.png'); ?>" alt="User Avatar">
                                <?php
                                }
                                ?>

                            </div>
                            <h4 class="widget-user-username"><?= $mr['FirstName'] . ' ' . $mr['LastName']; ?></h4>
                            <p class="widget-user-desc"><small><?= $mr['NIK']; ?></small>
                            </p>
                        </div>
                        <div class="box-body">
                            <ul class="list-group list-group-unbordered">
                                <li class="list-group-item">
                                    <small><span class="fa fa-fw fa-calendar"></span> <a title="TTL" class="pull-right-container"><b><?= $mr['DOB']; ?></b></a></small>
                                </li>
                                <li class="list-group-item">
                                    <b><small><span class="fa fa-fw fa-home"></span> <a title="Alamat" class="pull-right-container" id="lblnokartubapel"><?= $mr['HomeAddress1']; ?></a></small></b>
                                </li>
                                <?php
                                    if ($cekpeserta == 200) {
                                ?>
                                <li class="list-group-item">
                                    <b><small><span class="fa fa-fw fa-phone"></span> <a title="No HP" class="pull-right-container" id="lblnokartubapel"><?= $getpeserta['noHP']; ?></a></small></b>
                                </li>
                                <li class="list-group-item">
                                    <b><small><span class="fa fa-fw fa-book"></span> <a title="No KTP" class="pull-right-container" id="lblnokartubapel"><?= $getpeserta['noKTP']; ?></a></small></b>
                                </li>
                                <li class="list-group-item">
                                    <b><small><span class="fa fa-fw fa-book"></span> <a title="Active" class="pull-right-container" id="lblnokartubapel"><?= $getpeserta['ketAktif']; ?></a></small></b>
                                </li>
                                <li class="list-group-item">
                                    <b><small><span class="fa fa-fw fa-book"></span> <a title="No Kartu" class="pull-right-container" id="lblnokartubapel"><?= $getpeserta['noKartu']; ?></a></small></b>
                                </li>
                                <li class="list-group-item">
                                    <b><small><span class="fa fa-fw fa-home"></span> <a title="Faskes" class="pull-right-container" id="lblnokartubapel"><?= $getpeserta['kdProviderPst']['nmProvider']; ?></a></small></b>
                                </li>
                            </ul>
                            <?php } else { ?>

                            <?php } ?>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->

                </div>
                <!-- end kanan -->

                <div class="col-md-9">
                    <?= $this->session->flashdata('message'); ?>
                    <div class="box box-primary">
                        <form onsubmit="btnSimpan.disabled = true; return true;" class="form-horizontal" method="post" action="<?= base_url('Pendaftaran/prosesdaftar'); ?>">
                            <div class="box-header with-border">
                                <i class="fa fa-battery-half"></i>
                                <small class="pull-right">
                                    <label style="font-size:medium" id="lblnorujukan"></label>
                                </small>
                            </div>
                            <div class="box-body">

                                <table width="100%">
                                    <?php
                                    $cekPasien = $this->db->query("SELECT * FROM Cases WHERE PatientCode = '$nomr' AND [Case Status] = 'OPEN'")->num_rows();
                                    ?>
                                    <tr style="display: none;">
                                        <td><small>Status Pasien</small></td>
                                        <td>
                                            <input style="margin-bottom:5px" type="text" name="cekPasien" class="form-control" value="<?= $cekPasien; ?>">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="20%"><small>Jenis Pasien</small></td>
                                        <td>
                                            <?php
                                            if ($mr['PatientType'] == '1') {
                                            ?>
                                                <select name="jns" class="form-control" required>
                                                    <option value="pribadi" selected>Pribadi / Asuransi</option>
                                                    <option value="bpjs">BPJS</option>
                                                </select>
                                            <?php
                                            } else if ($mr['PatientType'] == '2') {
                                            ?>
                                                <select name="jns" class="form-control" required>
                                                    <option value="vip" selected>VIP</option>
                                                    <option value="bpjs">BPJS</option>

                                                </select>
                                            <?php
                                            } else {
                                            ?>
                                                <select name="jns" class="form-control" required>
                                                    <option value="pribadi" selected>Pribadi / Asuransi</option>
                                                    <option value="bpjs">BPJS</option>

                                                </select>
                                            <?php
                                            }
                                            ?>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td><small>No. MR</small></td>
                                        <td>
                                            <input type="text" name="PatientCode" class="form-control" required value="<?= $mr['PatientCode']; ?>" style="margin-top:5px">
                                            <input type="hidden" name="nokartu" class="form-control" required value="<?= $mr['EmployeeID']; ?>" style="margin-top:5px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><small>Nama Pasien</small></td>
                                        <td>
                                            <input type="text" name="Description" class="form-control" required value="<?= $mr['FirstName'] . ' ' . $mr['LastName']; ?>" style="margin-top:5px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><small>Tanggal Periksan</small></td>
                                        <td>
                                            <input type="date" name="tgl" class="form-control" required value="<?= date('Y-m-d'); ?>" style="margin-top:5px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><small>Kategori</small></td>
                                        <td>
                                            <select name="kategori" id="pelayanan" style="margin-top:5px; margin-bottom:5px" class="form-control" required>
                                                <option value=""></option>
                                                <option value="OP" selected>Rawat Jalan</option>
                                            </select>
                                        </td>
                                    </tr>

                                    <tr style="display: none;" id="room">
                                        <td>
                                            <small>Room
                                                <b>
                                                    <i>
                                                        <font color="red">Wajib isi</font>
                                                    </i>
                                                </b>
                                            </small>
                                        </td>
                                        <td>
                                            <select name="room" class="teanganData " data-live-search="true">
                                                <option value="">- Pilih Ruang -</option>
                                                <?php
                                                foreach ($room as $dRoom) :
                                                ?>
                                                    <option value="<?= $dRoom['OfficeName']; ?>">
                                                        <?= $dRoom['OfficeName']; ?> | <?= $dRoom['OfficeDescription']; ?> | <?= $dRoom['Class']; ?> | <?= $dRoom['Floor']; ?> | <?= $dRoom['Status']; ?> | <?= $dRoom['Category']; ?>
                                                    </option>
                                                <?php
                                                endforeach;
                                                ?>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div style="margin-top: 5px;"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div style="margin-top: 5px;"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><small>Penjamin</small></td>
                                        <td>
                                            <select name="company" required class="teanganData " data-live-search="true">
                                                <option value="">-- Pilih Penjamin --</option>
                                                <?php
                                                foreach ($company as $cc) :
                                                    if ($cc['CompanyCode'] == $mr['CompanyCode']) {
                                                ?>
                                                        <option selected value="<?= $cc['CompanyCode']; ?>">
                                                            <?= $cc['CompanyName']; ?>
                                                        </option>
                                                    <?php
                                                    } else {
                                                    ?>
                                                        <option value="<?= $cc['CompanyCode']; ?>">
                                                            <?= $cc['CompanyName']; ?>
                                                        </option>
                                                <?php
                                                    }
                                                endforeach;
                                                ?>

                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div style="margin-top: 5px;"></div>
                                        </td>
                                    </tr>
                                    <!-- <tr>
                                        <td><small>Perusahaan</small></td>
                                        <td>
                                            <select name="perusahaan" class="teanganData " data-live-search="true">
                                                <option value="">-- Pilih Perusahaan --</option>
                                                <?php
                                                foreach ($perusahaan as $pp) :
                                                ?>
                                                <option value="-">Tidak Ada Pilihan</option>
                                                        <option selected value="<?= $pp['KODE']; ?>">
                                                            <?= $pp['NAMA PERUSAHAAN']; ?>
                                                        </option>
                                                <?php
                                                endforeach;
                                                ?>
                                            </select>
                                        </td>
                                    </tr> -->
                                    <tr>
                                        <td colspan="2">
                                            <div style="margin-top: 5px;"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top"><small>Tujuan</small></td>
                                        <td>

                                            <table class="table table-striped">
                                                <tr>
                                                    <th>Poli</th>
                                                    <th>Dokter</th>
                                                    <td></td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <select name="tujuan[]" class="form-control" id="js-example-basic-single2" style="width: 100%;">
                                                            <option value=""></option>
                                                            <?php
                                                            foreach ($daftarPoli as $dataPoli) :
                                                            ?>
                                                                <option value="<?= $dataPoli['ActivityClass']; ?>">
                                                                    <?= $dataPoli['ActivityClass']; ?>
                                                                </option>
                                                            <?php
                                                            endforeach;
                                                            ?>
                                                        </select>

                                                        <div style="margin-top:5px; display:none;" id="dvPassport2">
                                                            <select name="tujuan[]" class="form-control" id="js-example-basic-single3" style="width: 100%;">
                                                                <option value=""></option>
                                                                <?php
                                                                foreach ($daftarPoli as $dataPoli) :
                                                                ?>
                                                                    <option value="<?= $dataPoli['ActivityClass']; ?>">
                                                                        <?= $dataPoli['ActivityClass']; ?>
                                                                    </option>
                                                                <?php
                                                                endforeach;
                                                                ?>
                                                            </select>
                                                        </div>

                                                        <div style="margin-top:5px; display:none;" id="dvPassport3">
                                                            <select name="tujuan[]" class="form-control" id="js-example-basic-single4" style="width: 100%;">
                                                                <option value=""></option>
                                                                <?php
                                                                foreach ($daftarPoli as $dataPoli) :
                                                                ?>
                                                                    <option value="<?= $dataPoli['ActivityClass']; ?>">
                                                                        <?= $dataPoli['ActivityClass']; ?>
                                                                    </option>
                                                                <?php
                                                                endforeach;
                                                                ?>
                                                            </select>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <select name="doctor[]" class="form-control" id="js-example-basic-single" style="width: 100%;">
                                                            <option value=""></option>
                                                            <?php
                                                            foreach ($doctor as $dc) :
                                                            ?>
                                                                <option value="<?= $dc['DoctorID']; ?>">
                                                                    <?= $dc['FirstName']; ?>
                                                                </option>
                                                            <?php
                                                            endforeach;
                                                            ?>
                                                        </select>

                                                        <div style="margin-top:5px;display:none;" id="dvPassportD2">
                                                            <select name="doctor[]" class="form-control" id="js-example-basic-single6" style="width: 100%;">
                                                                <option value=""></option>
                                                                <?php
                                                                foreach ($doctor as $dc) :
                                                                ?>
                                                                    <option value="<?= $dc['DoctorID']; ?>">
                                                                        <?= $dc['FirstName']; ?>
                                                                    </option>
                                                                <?php

                                                                endforeach;
                                                                ?>
                                                            </select>
                                                        </div>

                                                        <div style="margin-top:5px; display:none;" id="dvPassportD3">
                                                            <select name="doctor[]" class="form-control" id="js-example-basic-single5" style="width: 100%;">
                                                                <option value=""></option>
                                                                <?php
                                                                foreach ($doctor as $dc) :
                                                                ?>
                                                                    <option value="<?= $dc['DoctorID']; ?>">
                                                                        <?= $dc['FirstName']; ?>
                                                                    </option>
                                                                <?php
                                                                endforeach;
                                                                ?>
                                                            </select>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <label for="chkPassport2" style="cursor: pointer;">
                                                            <input type="checkbox" id="chkPassport2" onclick="ShowHideDiv(this)" name="cek_tambah[]" />
                                                            Tambah
                                                        </label>
                                                        <br>
                                                        <div id="tambah2" style="display:none">
                                                            <label for="chkPassport3" style="cursor: pointer; margin-top:5px">
                                                                <input type="checkbox" id="chkPassport3" onclick="ShowHideDiv3(this)" name="cek_tambah[]" />
                                                                Tambah
                                                            </label>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </table>


                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div style="margin-top: 5px;"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div style="margin-top: 5px;"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><small>Catatan</small></td>
                                        <td>
                                            <textarea name="catatan" class="form-control"></textarea>
                                        </td>
                                    </tr>
                                    <tr style="display: none;">
                                        <td><small>User</small></td>
                                        <td>
                                            <input type="text" value="<?= $user['nama']; ?>" name="user">
                                        </td>
                                    </tr>

                                </table>


                            </div>
                            <div class="box-footer">
                                <div class="form-group">
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                            <button id="btnSimpan" type="submit" class="btn btn-success">Submit</button>
                                        <a href="<?= base_url('kontrol/resetKontrol'); ?>" class="btn btn-danger pull-right"><i class="fa fa-undo"></i> Batal</a>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>

            </div>
        <?php
        } else {
        ?>
            <!-- Default box -->
            <div class="box">
                <div class="box-body">
                    <div class='row'>
                        <div class='col-md-6'>
                            <h3>Data Tidak Ditemukan</h3>
                        </div>
                        <div class='col-md-6 text-right'>
                            <br>
                            <a href="<?= base_url('pasien/form'); ?>" class="btn btn-success"><i class="fa fa-plus"></i> Pasien Baru</a>
                            <a href="<?= base_url('pasien/pasien'); ?>" class="btn btn-danger"><i class="fa fa-undo"></i> Batal</a>
                        </div>
                    </div>

                </div>
            </div>
        <?php
        }
        ?>

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


<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">
    function ShowHideDiv(chkPassport2) {
        var dvPassport2 = document.getElementById("dvPassport2");
        dvPassport2.style.display = chkPassport2.checked ? "block" : "none";
        var dvPassportD2 = document.getElementById("dvPassportD2");
        dvPassportD2.style.display = chkPassport2.checked ? "block" : "none";
        var tambah2 = document.getElementById("tambah2");
        tambah2.style.display = chkPassport2.checked ? "block" : "none";
    }

    function ShowHideDiv3(chkPassport3) {
        var dvPassport3 = document.getElementById("dvPassport3");
        dvPassport3.style.display = chkPassport3.checked ? "block" : "none";
        var dvPassportD3 = document.getElementById("dvPassportD3");
        dvPassportD3.style.display = chkPassport3.checked ? "block" : "none";

    }
</script>