<?php
date_default_timezone_set("Asia/Jakarta");
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Pasien
            <small>Klinik</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Anamnesa</a></li>
            <li class="active">Pasien</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">

        <!-- SELECT2 EXAMPLE -->
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title"></h3>
                <div class="box-tools pull-right">
                    <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                    <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
                </div>
            </div><!-- /.box-header -->
            <div class="box-body">
                <small>
                    <table id="example1" class="table table-bordered table-hover table-striped">
                        <thead>
                            <tr>
                                <th>No.</th>
                                <th>Case ID</th>
                                <th>Nama</th>
                                <th>Penjamin</th>
                                <th>Status Pasien</th>
                                <th>Opsi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $no = 1;
                            foreach ($pasien as $data) :
                                $case = $data['Case ID'];
                            ?>
                            <tr>
                                <td><?= $no++; ?>.</td>
                                <td><?= $data['Case ID']; ?></td>
                                <td><?= $data['Description']; ?></td>
                                <td><?= $data['CompanyName']; ?></td>
                                <td><?= $data['Case Status']; ?></td>
                                <td>
                                    <?php 
                                    if($user['dept'] == 1){
                                        ?>
                                        
                                        <?php 
                                    }else if($user['dept'] == 2){
                                        ?>
                                        
                                        <?php 
                                    }else if($user['dept'] == 3){
                                        ?>
                                        <a href="" data-toggle="modal" data-target="#tes<?=$case; ?>" style="width: 100%" class="btn btn-sm btn-success"><i class="fa fa-fw fa-edit"></i> Anamnesa</a>
                                        <?php
                                    }
                                    ?>
                                </td>
                            </tr>
                            <?php
                            
                            endforeach;
                            ?>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th>No.</th>
                                <th>Case ID</th>
                                <th>Nama</th>
                                <th>Penjamin</th>
                                <th>Status Pasien</th>
                                <th>Opsi</th>
                            </tr>
                        </tfoot>
                    </table>
                </small>
            </div><!-- /.box-body -->
            <div class="box-footer">
                <small>Daftar Pasien <?= date('d F Y'); ?> - @Klinik <?= date('Y'); ?></small>
            </div>
        </div><!-- /.box -->

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

<!-- Modal -->
<?php 
foreach($pasien as $m):
?>
<div class="modal fade" id="tes<?= $m['Case ID']; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <form action="<?= base_url('anamnesa/prosesAnamnesa'); ?>" method="post">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Anamnesa</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <small>
        <b>Nama :</b> <?= $m['Description'];?> <br>
        <table class="table table-striped" style="margin-top: 10px;">
            <tr>
                <td colspan="4">
                Case ID 
                <input type="text" name="CaseID" class="form-control" value="<?= $m['Case ID']; ?>" readonly>
                </td>
            </tr>
            <tr>
                <td>Poli Tujuan</td>
                <td>
                    <select name="Unit" class="form-control" required>
                        <option value="">- Pilih -</option>
                        <?php
                        foreach($poli as $klinik):
                            ?>
                            <option value="<?= $klinik['Jenis']; ?>"><?= $klinik['Jenis']; ?></option>
                            <?php 
                        endforeach;
                        ?>
                    </select>
                </td>
                <td>Dokter Tujuan</td>
                <td>
                    <select name="DoctorID" class="teanganData" data-live-search="true" required>
                        <option value="">- Pilih -</option>
                        <?php
                        foreach($dokter as $dok):
                            ?>
                            <option value="<?= $dok['DoctorID']; ?>"><?= $dok['DoctorID']; ?>-<?= $dok['FirstName']; ?>, <?= $dok['LastName']; ?></option>
                            <?php 
                        endforeach;
                        ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Berat Badan *cm</td>
                <td><input type="text" name="BeratBadan" class="form-control"></td>
                <td>Tinggi Badan *kg</td>
                <td><input type="text" name="TinggiBadan" class="form-control"></td>
            </tr>
            <tr>
                <td>RespRate</td>
                <td><input type="text" name="respRate" class="form-control"></td>
                <td>HeartRate</td>
                <td><input type="text" name="heartRate" class="form-control"></td>
                
            </tr>
            <tr>
                <td>Tensi</td>
                <td><input type="text" name="Tensi" class="form-control"></td>
                <td>Suhu</td>
                <td><input type="text" name="Suhu" class="form-control"></td>
            </tr>
            <tr>
                <td>Diastole</td>
                <td><input type="text" name="Diastole" class="form-control"></td>
                <td>Keluhan</td>
                <td>
                    <textarea name="Keluhan" class="form-control"></textarea>
                </td>
                </td>
            </tr>
        </table>
        </small>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary" >Simpan</button>
      </div>
    </div>
    </form>
  </div>
</div>
<?php 
endforeach;
?>
