<!-- Main content -->
<section class="content" style="zoom : 85%;">
  <div class="container-fluid">
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-header">
            <div class="row">
              <div class="col-sm-6">
                <h3 class="card-title">Proses Tiket Gangguan</h3>
              </div>
              <div class="col-sm-6">
              </div>
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
            <table id="example1" class="table table-bordered table-striped">
              <thead class="bg-success">
              <tr>
                <th>No</th>
                <th>Time</th>
                <th>Nama Server</th>
                <th>Jenis</th>
                <th>Keterangan</th>
                <th>Lokasi</th>
                <th>Koordinat</th>
                <th>URL Tracking</th>
                <th>Action</th>
              </tr>
              </thead>
              <tbody>
              <?php
                $no = 1;
                $aserver = mysqli_query($con,"SELECT * FROM v_tiket_gangguan WHERE status = '5' $SqlDataId ORDER BY telah_proses_time DESC");
                while ($server = mysqli_fetch_assoc($aserver)) {
                  if ($server['jenis_tiket'] == 'Pelanggan') {
                    $ket = '<a href="?'.encrypt_url('user_detail|'.$server['id_pelanggan']).'"><b>'.$server['nama_pelanggan'].'</b></a><br>'.$server['permasalahan'];
                  } else {
                    $ket = $server['permasalahan'];
                  }
              ?>
              <tr>
                <td style="max-width: 30px;"><?php echo $no; ?></td>
                <td style="max-width: 75px;"><?php echo $server['start_time']; ?></td>
                <td><?php echo $server['nama_server']; ?></td>
                <td><?php echo $server['jenis_tiket']; ?></td>
                <td style="max-width: 150px;"><?php echo $ket; ?></td>
                <td style="max-width: 150px;"><?php echo $server['lokasi']; ?></td>
                <td style="max-width: 150px;"><a href="https://www.google.com/maps/search/?api=1&query=<?php echo $server['latitude'].', '.$server['longitude']; ?>" target="_blank"><?php echo $server['latitude'].', '.$server['longitude']; ?></a></td>
                <td style="max-width: 150px;"><a href="<?= 'https://manjapro.net/tracking/' . $server['tiket_id']; ?>" target="_blank"><?= 'https://manjapro.net/tracking/' . $server['tiket_id']; ?></a></td>
                <td>
                  <?php 
                  if($server['status'] == '2' OR $server['status'] == '3') { 
                    echo '<a href="?'.encrypt_url('tiket_update_proses|'.$server['id']).'" type="button" class="btn btn-primary btn-sm ml-1">Update Proses</a>'; }
                  elseif($server['status'] == '4') {
                    echo '<a href="?'.encrypt_url('tiket_update_proses|'.$server['id']).'" type="button" class="btn btn-secondary btn-sm ml-1">Verifikasi</a>'; }
                  elseif($server['status'] == '5') {
                    echo '<a href="?'.encrypt_url('tiket_update_proses|'.$server['id']).'" type="button" class="btn btn-success btn-sm ml-1">Detail</a>'; }
                  ?>
                </td>
              </tr>
            <?php
              if (isset($_POST['proses'.$server['id']])) {
                $stmt = $pdo->prepare("UPDATE tiket_gangguan SET id_penyelesai_tiket = :idpenyet, status = '2' WHERE id = :idtik");
                $stmt->bindParam(':idpenyet', $UserId, PDO::PARAM_INT);
                $stmt->bindParam(':idtik', $server['id'], PDO::PARAM_INT);
                $stmt->execute();
                sweetAlert("Tiket akan di proses", "success");
              }
              if (isset($_POST['hapus'.$server['id']])) {
                $iddata = $server['id'];
                deleteAlert("tiket_gangguan", $iddata);
              }
            $no++; } ?>
              </tbody>
            </table>
          </div>
          <!-- /.card-body -->
        </div>
        <!-- /.card -->
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </div>
  <!-- /.container-fluid -->
</section>
<!-- /.content -->