<file_sep>-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jul 13, 2022 at 05:25 PM
-- Server version: 10.4.21-MariaDB
-- PHP Version: 7.4.29

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `antrian`
--

-- --------------------------------------------------------

--
-- Table structure for table `antrian`
--

CREATE TABLE `antrian` (
  `id` int(11) NOT NULL,
  `tanggal` varchar(50) DEFAULT NULL,
  `status` varchar(50) NOT NULL,
  `waktu_panggil` varchar(50) DEFAULT current_timestamp(),
  `waktu_selesai` varchar(50) DEFAULT NULL,
  `pelayanan_id` int(11) NOT NULL,
  `loket_id` int(11) NOT NULL,
  `antrian_last` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT;

--
-- Dumping data for table `antrian`
--

INSERT INTO `antrian` (`id`, `tanggal`, `status`, `waktu_panggil`, `waktu_selesai`, `pelayanan_id`, `loket_id`, `antrian_last`) VALUES
(1, '22-07-06 08:16:25', 'selesai', NULL, NULL, 4, 1, NULL),
(2, '22-07-06 08:28:44', 'selesai', NULL, NULL, 4, 1, NULL),
(3, '22-07-06 08:28:45', 'selesai', NULL, NULL, 4, 1, NULL),
(4, '22-07-06 08:28:45', 'selesai', NULL, NULL, 4, 1, NULL),
(5, '22-07-06 08:28:46', 'selesai', NULL, NULL, 4, 1, NULL),
(6, '22-07-06 08:28:47', 'selesai', NULL, NULL, 4, 1, NULL),
(7, '22-07-06 08:28:48', 'selesai', NULL, NULL, 5, 1, NULL),
(8, '22-07-06 08:28:50', 'selesai', NULL, NULL, 5, 1, NULL),
(9, '22-07-06 08:28:50', 'selesai', NULL, NULL, 5, 1, NULL),
(10, '22-07-06 08:28:52', 'selesai', NULL, NULL, 6, 1, NULL),
(11, '22-07-06 08:28:54', 'selesai', NULL, NULL, 6, 1, NULL),
(12, '22-07-06 08:28:56', 'selesai', NULL, NULL, 7, 1, NULL),
(13, '22-07-06 08:28:57', 'selesai', NULL, NULL, 7, 1, NULL),
(14, '22-07-06 09:15:24', 'selesai', NULL, NULL, 4, 1, NULL),
(15, '22-07-06 10:29:15', 'selesai', NULL, NULL, 7, 1, NULL),
(16, '22-07-06 10:29:44', 'selesai', NULL, NULL, 7, 1, NULL),
(17, '22-07-06 10:30:19', 'selesai', NULL, NULL, 4, 1, NULL),
(18, '22-07-06 10:31:28', 'selesai', NULL, NULL, 4, 1, NULL),
(19, '22-07-06 10:31:29', 'selesai', NULL, NULL, 4, 1, NULL),
(20, '22-07-06 10:31:30', 'selesai', NULL, NULL, 4, 1, NULL),
(21, '22-07-06 10:58:00', 'selesai', NULL, NULL, 6, 1, NULL),
(22, '22-07-06 10:58:01', 'selesai', NULL, NULL, 6, 1, NULL),
(23, '22-07-06 10:58:02', 'selesai', NULL, NULL, 6, 1, NULL),
(24, '22-07-06 10:58:04', 'selesai', NULL, NULL, 7, 1, NULL),
(25, '22-07-06 11:00:53', 'selesai', NULL, NULL, 4, 1, NULL),
(26, '22-07-06 11:02:22', 'selesai', NULL, NULL, 4, 1, NULL),
(27, '22-07-06 11:02:40', 'selesai', NULL, NULL, 4, 1, NULL),
(28, '22-07-06 11:03:17', 'selesai', NULL, NULL, 4, 1, NULL),
(29, '22-07-06 11:03:27', 'selesai', NULL, NULL, 4, 1, NULL),
(30, '22-07-06 11:03:32', 'selesai', NULL, NULL, 5, 1, NULL),
(31, '22-07-06 11:31:40', 'selesai', NULL, NULL, 4, 1, NULL),
(32, '22-07-06 11:32:59', 'selesai', NULL, NULL, 5, 1, NULL),
(33, '22-07-06 21:54:52', 'selesai', NULL, NULL, 4, 1, NULL),
(34, '22-07-06 21:57:11', 'selesai', NULL, NULL, 5, 1, NULL),
(35, '22-07-06 21:57:15', 'selesai', NULL, NULL, 6, 1, NULL),
(36, '22-07-06 21:57:18', 'berlansung', NULL, NULL, 7, 1, NULL),
(37, '22-07-06 21:57:27', 'selesai', NULL, NULL, 4, 1, NULL),
(38, '22-07-06 21:57:30', 'selesai', NULL, NULL, 4, 1, NULL),
(39, '22-07-06 21:57:33', 'selesai', NULL, NULL, 4, 1, NULL),
(40, '22-07-06 22:26:02', 'selesai', NULL, NULL, 4, 1, NULL),
(41, '22-07-06 22:38:01', 'selesai', NULL, NULL, 4, 1, NULL),
(42, '22-07-07 02:18:42', 'selesai', NULL, NULL, 4, 1, NULL),
(43, '22-07-07 02:18:45', 'selesai', NULL, NULL, 4, 1, NULL),
(44, '22-07-07 02:19:22', 'selesai', NULL, NULL, 4, 1, NULL),
(45, '22-07-07 02:19:25', 'selesai', NULL, NULL, 4, 1, NULL),
(46, '22-07-07 02:19:27', 'selesai', NULL, NULL, 4, 1, NULL),
(47, '22-07-07 02:19:30', 'selesai', NULL, NULL, 4, 1, NULL),
(48, '22-07-07 02:22:47', 'selesai', NULL, NULL, 4, 1, NULL),
(49, '22-07-07 02:23:18', 'selesai', NULL, NULL, 4, 1, NULL),
(50, '22-07-07 04:23:08', 'selesai', NULL, NULL, 4, 1, NULL),
(51, '22-07-07 04:23:08', 'selesai', NULL, NULL, 4, 1, NULL),
(52, '22-07-07 05:25:43', 'selesai', NULL, NULL, 4, 1, NULL),
(53, '22-07-07 05:25:43', 'selesai', NULL, NULL, 4, 1, NULL),
(54, '22-07-07 05:39:27', 'selesai', NULL, NULL, 4, 1, NULL),
(55, '22-07-07 05:39:27', 'selesai', NULL, NULL, 4, 1, NULL),
(56, '22-07-07 05:44:05', 'berlansung', NULL, NULL, 5, 1, NULL),
(57, '22-07-07 05:44:05', 'mengantri', NULL, NULL, 5, 1, NULL),
(58, '22-07-07 05:46:43', 'mengantri', NULL, NULL, 5, 1, NULL),
(59, '22-07-07 05:46:43', 'mengantri', NULL, NULL, 5, 1, NULL),
(60, '22-07-07 08:07:04', 'selesai', NULL, NULL, 4, 1, NULL),
(61, '22-07-07 08:07:04', 'selesai', NULL, NULL, 4, 1, NULL),
(62, '22-07-08 01:49:22', 'selesai', NULL, NULL, 4, 1, NULL),
(63, '22-07-08 01:49:22', 'selesai', NULL, NULL, 4, 1, NULL),
(64, '22-07-08 07:33:06', 'selesai', NULL, NULL, 4, 1, NULL),
(65, '22-07-08 07:33:06', 'selesai', NULL, NULL, 4, 1, NULL),
(66, '22-07-08 07:49:14', 'selesai', NULL, NULL, 4, 1, NULL),
(67, '22-07-08 07:49:14', 'selesai', NULL, NULL, 4, 1, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `loket`
--

CREATE TABLE `loket` (
  `id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `keterangan` tinytext NOT NULL,
  `pelayanan_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `loket`
--

INSERT INTO `loket` (`id`, `nama`, `keterangan`, `pelayanan_id`) VALUES
(2, 'Loket 1', 'Pelayanan Customer Services', 0),
(3, 'Loket 2', 'Pelayanan Pengaduan', 5),
(4, 'Loket 3', 'Pelayanan Permohonan Baru', 6),
(5, 'Loket 4', 'Pelayanan Perpanjangan', 0);

-- --------------------------------------------------------

--
-- Table structure for table `pelayanan`
--

CREATE TABLE `pelayanan` (
  `id` int(11) UNSIGNED NOT NULL,
  `nama` varchar(100) NOT NULL,
  `kode` varchar(100) NOT NULL,
  `keterangan` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `pelayanan`
--

INSERT INTO `pelayanan` (`id`, `nama`, `kode`, `keterangan`) VALUES
(4, 'Customer Services', 'A', 'Layanan konsumen'),
(5, 'Pengaduan', 'B', 'Layanan pengaduan'),
(6, 'Permohonan Baru', 'C', 'Layanan permohonan baru'),
(7, 'Perpanjangan', 'D', 'Layanan Perpanjangan');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `antrian`
--
ALTER TABLE `antrian`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `loket`
--
ALTER TABLE `loket`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pelayanan`
--
ALTER TABLE `pelayanan`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `antrian`
--
ALTER TABLE `antrian`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=68;

--
-- AUTO_INCREMENT for table `loket`
--
ALTER TABLE `loket`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `pelayanan`
--
ALTER TABLE `pelayanan`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<file_sep><?= $this->extend('/layouts/tempelate-admin'); ?>
<?= $this->section('content'); ?>
<div class="container">
  <?php
  if (!empty(session()->getFlashdata('success'))) { ?>
    <div class="alert alert-success">
      <?php echo session()->getFlashdata('success'); ?> </div>
  <?php } ?> <?php if (!empty(session()->getFlashdata('info'))) { ?>
    <div class="alert alert-info"> <?php echo session()->getFlashdata('info'); ?>
    </div> <?php } ?>
  <?php if (!empty(session()->getFlashdata('warning'))) { ?>
    <div class="alert alert-warning"> <?php echo session()->getFlashdata('warning'); ?>
    </div>
  <?php } ?>
  <?php if (!empty(session()->getFlashdata('danger'))) { ?>
    <div class="alert alert-danger"> <?php echo session()->getFlashdata('danger'); ?>
    </div>
  <?php } ?>
</div>
<div class="container">
  <a href="
        <?php echo base_url();?>/pelayanan/create" class="btn btn-success float-right mb-3">Tambah Pelayanan </a>
  <h4>Pelayanan</h4>
  <div class="table-responsive">
    <table class="table table-bordered">
      <thead>
        <th>No</th>
        <th>Name</th>
        <th>Kode</th>
        <th>Keterangan</th>
        <th>Aksi</th>
      </thead>
      <tbody>
        <?php foreach ($pelayanan as $key => $data) { ?>
          <tr>
            <td> <?php echo $key + 1; ?> </td>
            <td> <?php echo $data['nama']; ?> </td>
            <td> <?php echo $data['kode']; ?> </td>
            <td> <?php echo $data['keterangan']; ?> </td>
            <td>
              <div class="btn-group">
                <a href="<?php echo base_url('pelayanan/edit/' . $data['id']); ?>" class="btn btn-warning btn-sm">
                  <i class="fas fa-edit"></i>
                </a> &emsp; <a href="<?php echo base_url('pelayanan/delete/' . $data['id']); ?>" class="btn btn-danger btn-sm" onclick="return confirm('Apakah Anda yakin ingin menghapus pelayanan <?php echo $data['nama']; ?> ini?')">
                  <i class="fas fa-trash-alt"></i>
                </a>
              </div>
            </td>
          </tr>
        <?php } ?>
      </tbody>
    </table>
  </div>
</div>
<?= $this->endSection(); ?><file_sep>
//check localstorage
if(localStorage.getItem('preferredTheme') == 'dark') {
    setDarkMode(true)
}

function setDarkMode(isDark) {
    var darkBtn = document.getElementById('darkBtn')
    var lightBtn = document.getElementById('lightBtn')

    if(isDark) {
        lightBtn.style.display = "block"
        darkBtn.style.display = "none"
        localStorage.setItem('preferredTheme', 'dark');
    } else {
        lightBtn.style.display = "none"
        darkBtn.style.display = "block"
        localStorage.removeItem('preferredTheme');
    }

    document.body.classList.toggle("darkmode");
}<file_sep><?php namespace App\Models;
 
use CodeIgniter\Model;
 
class LoketModel extends Model
{
    protected $table = "loket";
 
    public function getLoket($id = false)
    {
        if($id === false){
            return $this->table('loket')
                        ->get()
                        ->getResultArray();
        } else {
            return $this->table('loket')
                        ->where('id', $id)
                        ->get()
                        ->getRowArray();
        }   
    } 

    public function insert_loket($data)
    {
        return $this->db->table($this->table)->insert($data);
    } 

    public function update_loket($data, $id)
    {
    return $this->db->table($this->table)->update($data, ['id' => $id]);
    } 

   public function delete_loket($id)
    {
    return $this->db->table($this->table)->delete(['id' => $id]);
    } 
}<file_sep><?php foreach ($antrian4 as $key => $data4) {
  $aa = $data4["id"];
} ?>
<?php foreach ($antrian5 as $key => $data5) {
  $bb = $data5["id"];
} ?>
<?php foreach ($antrian6 as $key => $data6) {
  $cc = $data6["id"];
} ?>
<?php foreach ($antrian7 as $key => $data7) {
  $dd = $data7["id"];
} ?>
<?= $this->extend('layouts/tempelate'); ?>
<?= $this->section('content'); ?>
<!-- Begin Page Content -->
<div class="container">
  <div class="card-body">
    <div class="row">
      <!-- Page Heading -->
      <div class="col-12"> Dashboard Antrian </div>

      <div class="antrian">
        <h5>Panggilan Antrian</h5>
        <p> A <?php echo $aa; ?> </p>
        <h5>Loket 1</h5>
      </div>
      <div class="antrian-layar">
        <p id="time"></p>
        </body>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script type="text/javascript">
          var timestamp = '<?= time(); ?>';

          function updateTime() {
            $('#time').html(Date(timestamp));
            timestamp++;
          }
          $(function() {
            setInterval(updateTime, 1000);
          });
        </script>
        <tr>
          <marquee behavior="" direction="">
            <td>
              <h2>Antrian saat ini : Loket 1 : A <?php echo $aa; ?>, Loket 2 : B <?php echo $bb; ?>, Loket 3 : C <?php echo $cc; ?>, Loket 4 : D <?php echo $dd; ?> </h2>
            </td>
          </marquee>
          <td><img width="200" src="https://c.tenor.com/kvXMS__Bkd8AAAAC/hello-hi.gif" alt=""></td>
        </tr>

      </div>

      <br>
      <!-- <div class="antrian"><h5><NAME></h5><p>A03</p><h5>Loket 1</h5></div> -->
      <br>
      <div class="loket">
        <p>A <?php echo $aa; ?> </p>
        <h5>Loket 1</h5>
      </div>
      <div class="loket">
        <p>B <?php echo $bb; ?> </p>
        <h5>Loket 2</h5>
      </div>
      <div class="loket">
        <p>C <?php echo $cc; ?> </p>
        <h5>Loket 3</h5>
      </div>
      <div class="loket">
        <p>D <?php echo $dd; ?> </p>
        <h5>Loket 4</h5>
      </div>
    </div>

  </div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<?= $this->endSection(); ?><file_sep><?php foreach ($antrianlast as $key => $data40) {
  echo $data40["id"];
}
<file_sep><!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- My Style -->
  <link href="<?php echo base_url('assets/css/style.css'); ?> " rel="stylesheet">

  <!-- BOOTSTRAP /-->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="<KEY>" crossorigin="anonymous">

  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />

  <script src="https://kit.fontawesome.com/a076d05399.js"></script>

  <title><?= $title; ?> - Sistem Antrian</title>
</head>

<body>

  <nav class="navbar navbar-expand-lg navbar-light bg-light mb-5">
    <div class="container">
      <a class="navbar-brand" href="#">
        <i class="fa-solid fa-clock"></i>
      </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
        <div class="navbar-nav">
          <a class="nav-link" href="<?php base_url(); ?>antrian">Ambil antrian</a>
          <a class="nav-link" href="<?php base_url(); ?>antrianno">Layar antrian</a>
          <a class="nav-link" href="<?php base_url(); ?>loketpanggil">Loket Panggil</a>
          <a class="nav-link" href="<?php base_url(); ?>loket">Loket</a>
          <a class="nav-link" href="<?php base_url(); ?>pelayanan">Pelayanan</a>
        </div>
      </div>
    </div>
  </nav>

  <?= $this->renderSection('content'); ?>

  <footer class="footer mt-5 py-3 text-center">
    <div class="container">
    <span>
        <p><i class="fa-solid fa-smile"></i> TERIMAKASIH <i class="fa-solid fa-smile"></i></p>
        <i class="fa-solid fa-heart"></i> LYDIA DIFFANI <i class="fa-solid fa-heart"></i></p>
        <p>&copy; <script>
            document.write(new Date().getFullYear());
          </script>
        </p>
    </span>
    </div>
  </footer>
  <script src="assets/js/main.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="<KEY>" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" integrity="<KEY>" crossorigin="anonymous"></script>
</body>

</html><file_sep><?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\AntrianModel;

class Antrianno extends Controller
{

    public function __construct()
    {

        // Mendeklarasikan class AntrianModel menggunakan $this->antrian
        $this->antrian = new AntrianModel();
    }

    public function index()
    {
        $data = [
            'title' => 'Layar Antrian'
        ];
        $data['antrian4'] = $this->antrian->getAntrianno(4);
        $data['antrian5'] = $this->antrian->getAntrianno(5);
        $data['antrian6'] = $this->antrian->getAntrianno(6);
        $data['antrian7'] = $this->antrian->getAntrianno(7);
        $data['antrianlast'] = $this->antrian->getAntrianlast(7);

        echo view('pages/antrianno/index', $data);
    }


    public function edite()
    {
        $data = [
            'title' => 'Edit'
        ];
        $data['antrian4'] = $this->antrian->getAntrianno(4);
        $data['antrian5'] = $this->antrian->getAntrianno(5);
        $data['antrian6'] = $this->antrian->getAntrianno(6);
        $data['antrian7'] = $this->antrian->getAntrianno(1);
        echo view('antrian/edit2', $data);
    }

    public function cek()
    {
        $data = [
            'title' => 'Cek'
        ];
        $data['antrianlast'] = $this->antrian->getAntrianlast(7);
        echo view('antrian/cek', $data);
    }
}
<file_sep><?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\AntrianModel;

class Antrian extends Controller
{

    public function __construct()
    {

        // Mendeklarasikan class AntrianModel menggunakan $this->antrian
        $this->antrian = new AntrianModel();
    }

    public function index()
    {
        $data = [
            'title' => 'Ambil Antrian'
        ];
        return view('pages/antrian/index', $data);
    }


    public function edite()
    {

        $data['antrian'] = $this->antrian->getAntrian();
        echo view('pages/antrian/edit2', $data);
    }



    public function a()
    {
        // Mengambil value dari form dengan method POST

        $oke =  date('y-m-d H:i:s');

        // Membuat array collection yang disiapkan untuk insert ke tablehttps://codeigniter.com/user_guide/database/index.html

        $data = [
            'tanggal' =>  $oke,
            'status' => 'mengantri',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '4',
            'loket_id' => '1'
        ];

        $dataaa = [
            'tanggal' =>  $oke,
            'status' => 'berlansung',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '4',
            'loket_id' => '1'
        ];
        $dataa['antrianstatus'] = $this->antrian->getAntrianstatus('4');
        if ($dataa['antrianstatus'] != null) {
            $simpan = $this->antrian->insert_antrian($data);
        } else {
            $simpan = $this->antrian->insert_antrian($dataaa);
        }




        // Jika simpan berhasil, maka ...
        if ($simpan) {
            // Deklarasikan session flashdata dengan tipe success
            session()->setFlashdata('success', 'Anda telah melakukan pengambilan no antrian, no antrian anda adalah $last_id');
            $data['antrian'] = $this->antrian->getAntrian();
            echo view('pages/antrian/antrian', $data);
        }
    }


    public function b()
    {
        // Mengambil value dari form dengan method POST

        $oke =  date('y-m-d H:i:s');

        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'tanggal' =>  $oke,
            'status' => 'mengantri',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '5',
            'loket_id' => '1'
        ];

        $dataaa = [
            'tanggal' =>  $oke,
            'status' => 'berlansung',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '5',
            'loket_id' => '1'
        ];


        $dataa['antrianstatus'] = $this->antrian->getAntrianstatus('5');
        if ($dataa['antrianstatus'] != null) {
            $simpan = $this->antrian->insert_antrian($data);
        } else {
            $simpan = $this->antrian->insert_antrian($dataaa);
        }


        // Jika simpan berhasil, maka ...
        if ($simpan) {
            // Deklarasikan session flashdata dengan tipe success
            session()->setFlashdata('success', 'Anda telah melakukan pengambilan no antrian, no antrian anda adalah $last_id');
            $data['antrian'] = $this->antrian->getAntrian();
            echo view('pages/antrian/antrian', $data);
        }
    }


    public function c()
    {
        // Mengambil value dari form dengan method POST

        $oke =  date('y-m-d H:i:s');

        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'tanggal' =>  $oke,
            'status' => 'mengantri',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '6',
            'loket_id' => '1'
        ];

        $dataaa = [
            'tanggal' =>  $oke,
            'status' => 'berlansung',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '6',
            'loket_id' => '1'
        ];



        $dataa['antrianstatus'] = $this->antrian->getAntrianstatus('6');
        if ($dataa['antrianstatus'] != null) {
            $simpan = $this->antrian->insert_antrian($data);
        } else {
            $simpan = $this->antrian->insert_antrian($dataaa);
        }

        // Jika simpan berhasil, maka ...
        if ($simpan) {
            // Deklarasikan session flashdata dengan tipe success
            session()->setFlashdata('success', 'Anda telah melakukan pengambilan no antrian, no antrian anda adalah $last_id');
            $data['antrian'] = $this->antrian->getAntrian();
            echo view('pages/antrian/antrian', $data);
        }
    }


    public function d()
    {
        // Mengambil value dari form dengan method POST

        $oke =  date('y-m-d H:i:s');

        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'tanggal' =>  $oke,
            'status' => 'mengantri',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '7',
            'loket_id' => '1'
        ];
        $dataaa = [
            'tanggal' =>  $oke,
            'status' => 'berlansung',
            'waktu_panggil' => null,
            'waktu_selesai' => null,
            'pelayanan_id' => '7',
            'loket_id' => '1'
        ];


        $dataa['antrianstatus'] = $this->antrian->getAntrianstatus('7');
        if ($dataa['antrianstatus'] != null) {
            $simpan = $this->antrian->insert_antrian($data);
        } else {
            $simpan = $this->antrian->insert_antrian($dataaa);
        }


        // Jika simpan berhasil, maka ...
        if ($simpan) {
            // Deklarasikan session flashdata dengan tipe success
            session()->setFlashdata('success', 'Anda telah melakukan pengambilan no antrian, no antrian anda adalah $last_id');
            $data['antrian'] = $this->antrian->getAntrian();
            echo view('pages/antrian/antrian', $data);
        }
    }
}
<file_sep><?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\LoketModel;
use App\Models\PelayananModel;

class Loket extends Controller
{

    public function __construct()
    {

        // Mendeklarasikan class LoketModel menggunakan $this->loket
        $this->loket = new LoketModel();
        $this->pelayanan = new PelayananModel();
    }

    public function index()
    {
        $data = [
            'title' => 'Loket'
        ];
        $data['loket'] = $this->loket->getLoket();
        echo view('admin/loket/index', $data);
    }
    public function edit($id)
    {
        $data = [
            'title' => 'Edit Loket'
        ];
        // Memanggil function getLoket($id) dengan parameter $id di dalam LoketModel dan menampungnya di variabel array loket
        $data['loket'] = $this->loket->getLoket($id);
        $data['pelayanan'] = $this->pelayanan->getPelayanan();
        // Mengirim data ke dalam view
        return view('admin/loket/edit', $data);
    }

    public function create()
    {
        $data = [
            'title' => 'Tambah Loket'
        ];
        $data['pelayanan'] = $this->pelayanan->getPelayanan();
        return view('admin/loket/create', $data);
    }

    public function delete($id)
    {
        // Memanggil function delete() dengan parameter $id di dalam LoketModel dan menampungnya di variabel hapus
        $hapus = $this->loket->delete_loket($id);

        // Jika berhasil melakukan hapus
        if ($hapus) {
            // Deklarasikan session flashdata dengan tipe warning
            session()->setFlashdata('danger', 'Hapus Loket berhasil!');
            // Redirect
            return redirect()->to(base_url('loket'));
        }
    }

    public function update($id)
    {
        // Mengambil value dari form dengan method POST
        $name = $this->request->getPost('nama');
        $code = $this->request->getPost('pelayanan_id');
        $desc = $this->request->getPost('keterangan');

        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'nama' => $name,
            'keterangan' => $desc,
            'pelayanan_id' => $code
        ];

        /* 
    Membuat variabel ubah yang isinya merupakan memanggil function 
    update_loket dan membawa parameter data beserta id
    */
        $ubah = $this->loket->update_loket($data, $id);

        // Jika berhasil melakukan ubah
        if ($ubah) {
            // Deklarasikan session flashdata dengan tipe info
            session()->setFlashdata('warning', 'Updated loket berhasil!');
            // Redirect ke halaman loket
            return redirect()->to(base_url('loket'));
        }
    }


    public function store()
    {
        // Mengambil value dari form dengan method POST
        $name = $this->request->getPost('nama');
        $desc = $this->request->getPost('keterangan');
        $code = $this->request->getPost('pelayanan_id');


        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'nama' => $name,
            'keterangan' => $desc,
            'pelayanan_id' => $code
        ];

        /* 
    Membuat variabel simpan yang isinya merupakan memanggil function 
    insert_loket dan membawa parameter data 
    */
        $simpan = $this->loket->insert_loket($data);

        // Jika simpan berhasil, maka ...
        if ($simpan) {
            // Deklarasikan session flashdata dengan tipe success
            session()->setFlashdata('success', 'Tambah Loket berhasil!');
            // Redirect halaman ke loket
            return redirect()->to(base_url('loket'));
        }
    }


    function action()
    {
        $data['loket'] = $this->loket->getLoket();
        echo json_encode($data);
    }
}
<file_sep><?= $this->extend('/layouts/tempelate'); ?>
<?= $this->section('content'); ?>
<div class="container">
  <main>
    <section class="mb-4">
      <div class="container">
        <div class="hero-inner">
          <div class="hero-copy">
            <div class="card text-center bg-light">
              <div class="card-body bg-warning">
                <h1 style="text-align: center;">Menu Antrian</h1>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
    <div class="container">
      <div class="row row-cols-1 row-cols-md-2">
        <?php foreach ($pelayanan->getResultArray() as $row) : ?>
          <div class="col mb-4">
            <div class="card bg-primary mb-3">
              <a style="color:white; text-decoration:none; text-align:center;" href="
              <?php echo base_url(); ?>/antrian/<?= $row['kode']; ?>/<?= $row['id']; ?>">
                <div class="card-body" style="text-align: center; font-weight: bold;"></div>
                <div class="card-body">
                  <h1 class="card-title"><?= $row['nama']; ?></h1>
                </div>
                <div class="card-body" style="text-align: center; font-weight: bold;"></div>
              </a>
            </div>
          </div>
        <?php endforeach; ?>

      </div>
    </div>
  </main>
  <?= $this->endSection(); ?><file_sep><?= $this->extend('/layouts/tempelate'); ?>

<?= $this->section('content'); ?>
<div class="container">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQn2fooM3tyt2t_WmQ3r42h4JMHxZWCLT2NDw&usqp=CAU" height="180px"
align="right" border="5">

    <h1>SELAMAT DATANG DI COFFEE SHOP!</h1>
    <p>Silahkan mengambil antrian</p>

</div>
<?= $this->endSection(); ?><file_sep><?php namespace App\Models;
 
use CodeIgniter\Model;
 
class PelayananModel extends Model
{
    protected $table = "pelayanan";
    protected $primaryKey = 'id';
    protected $allowedFields = ['id','nama', 'kode', 'keterangan'];

    // Menampilkan data

    public function getAll($id = false)
    {
        if ($id === false) {
        return $this->paginate(10, 'pelayanan');
        }

        return $this->where([
        'id' => $id
        ])->first();
    }
    public function getPelayanan($id = false)
    {
        if($id === false){
            return $this->table('pelayanan')
                        ->get()
                        ->getResultArray();
        } else {
            return $this->table('pelayanan')
                        ->where('id', $id)
                        ->get()
                        ->getRowArray();
        }   
    } 

    public function insert_pelayanan($data)
    {
        return $this->db->table($this->table)->insert($data);
    } 

    public function update_pelayanan($data, $id)
    {
    return $this->db->table($this->table)->update($data, ['id' => $id]);
    } 

   public function delete_pelayanan($id)
    {
    return $this->db->table($this->table)->delete(['id' => $id]);
    } 
}<file_sep><?php

namespace App\Models;

use CodeIgniter\Model;

class TampilpelayananModel extends Model
{
    protected $table = 'pelayanan';
    public function __construct()
    {
        $this->db = db_connect();
        $this->builder = $this->db->table($this->table);
    }
    public function getAllData($id = null)
    {
        if ($id == null) {
            return $this->builder->get();
        } else {
            $this->builder->where('id', $id);
            return $this->builder->get()->getRowArray();
        }
    }
}
<file_sep><?= $this->extend('/layouts/tempelate-antrian'); ?>
<?= $this->section('content'); ?>
<div class="container">
  <div class="body-wrap boxed-container">
    <?php foreach ($antrian as $key => $data) {
      $a = $data["id"];
    } ?>
    <main>
      <section class="hero">
        <div class="container">
          <div class="hero-inner">
            <div class="hero-copy">
              <br>
              <div class="container">
                <div class="card text-center">
                  <div class="card-header bg-primary"> NOMOR ANTRIAN </div>
                  <div class="card-body">
                    <h1 class="hero-paragraph is-revealing">
                      <?php
                      $request = \Config\Services::request();
                      $s = $request->uri->getSegment(3);
                      if ($s == "4") {
                        echo "A" .
                          $a;
                      } elseif ($s == "5") {
                        echo "B" .
                          $a;
                      } elseif ($s == "6") {
                        echo "C" .
                          $a;
                      } elseif ($s == "7") {
                        echo "D" .
                          $a;
                      }
                      ?> </h1>
                    <h3>Akan tercetak otomatis . . . </h3>
                  </div>
                </div>
              </div>
              <p class="hero-cta is-revealing">
                <a class="button button-primary button-shadow" href="#">.</a>
              </p>
            </div>
            <div class="container mt-5 mb-5 text-center"></div>
            <!-- <div class="container">
            <?php if (!empty(session()->getFlashdata("success"))) { ?><div class="alert alert-success">
            <?php echo session()->getFlashdata("success"); ?></div>
            <?php } ?>
            <?php if (!empty(session()->getFlashdata("info"))) { ?><div class="alert alert-info">
            <?php echo session()->getFlashdata("info"); ?></div>
            <?php } ?>
            <?php if (!empty(session()->getFlashdata("warning"))) { ?><div class="alert alert-warning">
            <?php echo session()->getFlashdata("warning"); ?></div>
            <?php } ?></div> -->
          </div>
        </div>
      </section>
    </main>
  </div>
  <script src="<?php echo base_url("dist/js/main.min.js"); ?>">
  </script>
</div> <?= $this->endSection(); ?><file_sep><?php namespace App\Models;
 
use CodeIgniter\Model;
 
class AntrianModel extends Model
{
    protected $table = "antrian";
 
    public function getAntrian($id = false)
    {
        if($id === false){
            $request = \Config\Services::request();
            $loktt = $request->uri->getSegment(3);
            return $this->table('antrian')
                        ->where('pelayanan_id', $loktt)
                        ->selectMax('id')
                        ->limit(1)
                        ->get()
                        ->getResultArray();

        } else {
            return $this->table('antrian')
                        ->where('antrian_loket_id', $id)
                        ->where('pelayanan_id', $id)
                        ->get()
                        ->getRowArray();
        }   
    }
     public function getAntrianstatus($id = false)
    {
        if($id === false){
            return $this->table('antrian')
                        ->where('status', 'berlansung')
                        ->get()
                        ->getResultArray();

        } else {
            return $this->table('antrian')
                        ->where('status', 'berlansung')
                        ->where('pelayanan_id', $id)
                        ->get()
                        ->getRowArray();
        }   
    } 

      public function getAntrianno($id = false)
    {
        if($id != 0){
          
            return $this->table('antrian')
                        ->where('pelayanan_id', $id)
                        ->where('status', 'berlansung')
                        ->selectMin('id')
                        ->limit(1)
                        ->get()
                        ->getResultArray();

        } else {
            return $this->table('antrian')
                        ->where('antrian_loket_id', $id)
                        ->where('pelayanan_id', $id)
                        ->get()
                        ->getRowArray();
        }   
    } 



    public function getAntrianlast($id = false)
    {
        if($id != 0){
          
            return $this->table('antrian')
                        ->where('status', 'berlansung')
                        ->selectMax('id')
                        ->limit(1)
                        ->get()
                        ->getResultArray();

        } else {
            return $this->table('antrian')
                        ->where('antrian_loket_id', $id)
                        ->where('pelayanan_id', $id)
                        ->get()
                        ->getRowArray();
        }   
    } 

    public function insert_antrian($data)
    {
        return $this->db->table($this->table)->insert($data);
    } 

    public function update_antrian($data, $id)
    {
    return $this->db->table($this->table)->update($data, ['id' => $id]);
    } 

   public function delete_antrian($id)
    {
    return $this->db->table($this->table)->delete(['id' => $id]);
    } 

    public function update_antrian_data($data, $id)
    {
        $request = \Config\Services::request();
        $rr = $request->uri->getSegment(3);
   $this->db->table($this->table)->update($data, ['id' => $id]);
   return $this->db->query("UPDATE antrian SET status = 'berlansung' WHERE id = ( SELECT MIN(id) AS min FROM antrian WHERE pelayanan_id = (select pelayanan_id from antrian where id = '" .$id." ') and status = 'mengantri'   )");
    } 
}<file_sep><?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\AntrianModel;

class Loketpanggil extends Controller
{

    public function __construct()
    {

        $this->antrian = new AntrianModel();
    }

    public function index()
    {
        $data = [
            'title' => 'Loket panggil'
        ];
        $data['antrian4'] = $this->antrian->getAntrianno(4);
        $data['antrian5'] = $this->antrian->getAntrianno(5);
        $data['antrian6'] = $this->antrian->getAntrianno(6);
        $data['antrian7'] = $this->antrian->getAntrianno(7);
        $data['antrianlast'] = $this->antrian->getAntrianlast(7);
        echo view('admin/loketpanggil/index', $data);
    }
    public function dua()
    {
        $data = [
            'title' => 'Loket panggil 2'
        ];
        $data['antrian4'] = $this->antrian->getAntrianno(4);
        $data['antrian5'] = $this->antrian->getAntrianno(5);
        $data['antrian6'] = $this->antrian->getAntrianno(6);
        $data['antrian7'] = $this->antrian->getAntrianno(7);
        $data['antrianlast'] = $this->antrian->getAntrianlast(7);
        echo view('admin/loketpanggil/dua', $data);
    }
    public function tiga()
    {
        $data = [
            'title' => 'Loket panggil 3'
        ];
        $data['antrian4'] = $this->antrian->getAntrianno(4);
        $data['antrian5'] = $this->antrian->getAntrianno(5);
        $data['antrian6'] = $this->antrian->getAntrianno(6);
        $data['antrian7'] = $this->antrian->getAntrianno(7);
        $data['antrianlast'] = $this->antrian->getAntrianlast(7);
        echo view('admin/loketpanggil/tiga', $data);
    }
    public function empat()
    {
        $data = [
            'title' => 'Loket panggil 4'
        ];
        $data['antrian4'] = $this->antrian->getAntrianno(4);
        $data['antrian5'] = $this->antrian->getAntrianno(5);
        $data['antrian6'] = $this->antrian->getAntrianno(6);
        $data['antrian7'] = $this->antrian->getAntrianno(7);
        $data['antrianlast'] = $this->antrian->getAntrianlast(7);
        echo view('admin/loketpanggil/empat', $data);
    }

    public function edit($id)
    {

        $desc = 'selesai';

        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'status' => $desc
        ];

        /* 
    Membuat variabel ubah yang isinya merupakan memanggil function 
    update_loket dan membawa parameter data beserta id
    */
        $ubah = $this->antrian->update_antrian_data($data, $id);

        // Jika berhasil melakukan ubah
        if ($ubah) {
            // Deklarasikan session flashdata dengan tipe info
            session()->setFlashdata('info', 'Nomor antrian ' . $id . ' Selesai!');
            // Redirect ke halaman antrian
            return redirect()->to(base_url('loketpanggil'));
        }
    }
}
<file_sep><?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\TampilpelayananModel;

class Tpelayanan extends Controller
{

    public function __construct()
    {

        // Mendeklarasikan class ProductModel menggunakan $this->pelayanan
        $this->pelayanan = new TampilpelayananModel();
    }

    public function antrianindex()
    {
        $data = [
            'title' => 'Ambil Antrian'
        ];
        $data['pelayanan'] = $this->pelayanan->getAllData();
        echo view('pages/antrian/index', $data);
    }
}
<file_sep>Repository ini dibuat untuk memenuhi tugas Pemrograman Web
| Nama      | <NAME>  |
| ----------- | ----------- |
| NIM     | 312010498       |
| Kelas   | TI.20.A.1        |
# UAS <NAME> (Genap)
<b>Link</b>

- [Dokumentasi](https://youtu.be/FBTE4BXdMFc)

- [Demo program](http://antriansistemlydia.epizy.com/)


<p>Untuk melakukan Program ini harus instalasi Codeigniter 4 dapat dilakukan dengan dua cara, yaitu cara manual dan menggunakan <b>composer</b>. Pada praktikum ini kita menggunakan cara composer.</p>

![](/XAMPP.PNG)

<P>Setelah itu buka ``XAMPP``</P>
klik shell, kemudian ketik:

```php
cd C:\xampp\htdocs\UAS
```

Setelah itu ketik:

```php
shell php spark serve
```

<p>Kemudian ketik:</p> 

```php
http://localhost:8080
```

Saya membuat webhosting dari ( https://app.infinityfree.net/ )

Untuk Upload data ke webhosting saya menggunakan filezilla Client

![](/filezilla.PNG)
<file_sep><?= $this->extend('/layouts/tempelate-admin'); ?>

<?= $this->section('content'); ?>
<div class="container">
    <h4>Edit Loket</h4>
    <hr>
    <form action="<?php echo base_url('loket/update/' . $loket['id']); ?>" method="post">

        <div class="form-group">
            <label for="">Nama Loket</label>
            <input type="text" name="nama" value="<?php echo $loket['nama']; ?>" class="form-control" placeholder="Nama Loket">
        </div>
        <div class="form-group">
            <label for="">Jenis Loket</label>
            <select name="id" class="form-control" placeholder="Jenis Pelayanan">>
                <?php
                foreach ($pelayanan as $key => $data) { ?>
                    <option value="<?php echo $data['id']; ?>">
                        <?php echo $data['nama']; ?> </option>
                <?php } ?>
            </select>

        </div>
        <div class="form-group">
            <label for="">Keterangan Loket</label>
            <input type="text" name="keterangan" value="<?php echo $loket['keterangan']; ?>" class="form-control" placeholder="Nama description">
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-primary">Update</button>
        </div>
    </form>
</div>
<?= $this->endSection(); ?><file_sep><?php
foreach ($antrian4 as $key => $data) { ?>
    <tr>
        <td><?php echo $key + 1; ?></td>
        <td><?php echo $data["id"]; ?></td>
        <td><?php echo $data["loket_id"]; ?></td>

    </tr>
<?php } ?>

<?php foreach ($antrian5 as $key => $data) { ?>
    <tr>
        <td><?php echo $key + 1; ?></td>
        <td><?php echo $data["id"]; ?></td>
        <td><?php echo $data["loket_id"]; ?></td>

    </tr>
<?php } ?><file_sep><?= $this->extend('/layouts/tempelate-admin'); ?>

<?= $this->section('content'); ?>
<div class="container">
    <h4>Tambah Loket</h4>
    <hr>
    <form action="<?php echo base_url('loket/store'); ?>" method="post">

        <div class="form-group">
            <label for="">Nama Loket</label>
            <input type="text" name="nama" class="form-control" placeholder="Nama Keterangan">
        </div>
        <div class="form-group">
            <label for="">Jenis Layanan</label>
            <select name="pelayanan_id" class="form-control" placeholder="Jenis Pelayanan">>
                <?php
                foreach ($pelayanan as $key => $data) { ?>
                    <option value="<?php echo $data['id']; ?>">
                        <?php echo $data['nama']; ?> </option>
                <?php } ?>
            </select>

        </div>
        <div class="form-group">
            <label for="">Keterangan Loket</label>
            <input type="text" name="keterangan" class="form-control" placeholder="Keterangan Loket">
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-primary">Simpan</button>
        </div>
    </form>
</div>

<?= $this->endSection(); ?><file_sep><?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\PelayananModel;

class Pelayanan extends Controller
{

    public function __construct()
    {

        // Mendeklarasikan class PelayananModel menggunakan $this->pelayanan
        $this->pelayanan = new PelayananModel();
    }

    public function index()
    {
        $data = [
            'title' => '<NAME>'
        ];
        $data['pelayanan'] = $this->pelayanan->getPelayanan();
        echo view('admin/pelayanan/index', $data);
    }

    public function edit($id)
    {
        $data = [
            'title' => 'Edit Pelayanan'
        ];
        // Memanggil function getPelayanan($id) dengan parameter $id di dalam PelayananModel dan menampungnya di variabel array pelayanan
        $data['pelayanan'] = $this->pelayanan->getPelayanan($id);
        // Mengirim data ke dalam view
        return view('admin/pelayanan/edit', $data);
    }

    public function create()
    {
        $data = [
            'title' => 'Tambah Pelayanan'
        ];
        return view('admin/pelayanan/create', $data);
    }

    public function delete($id)
    {
        // Memanggil function delete_pelayanan() dengan parameter $id di dalam PelayananModel dan menampungnya di variabel hapus
        $hapus = $this->pelayanan->delete_pelayanan($id);

        // Jika berhasil melakukan hapus
        if ($hapus) {
            // Deklarasikan session flashdata
            session()->setFlashdata('danger', 'Deleted pelayanan berhasil!');
            // Redirect ke halaman Pelayanan
            return redirect()->to(base_url('pelayanan'));
        }
    }
    public function update($id)
    {
        // Mengambil value dari form dengan method POST
        $name = $this->request->getPost('nama');
        $code = $this->request->getPost('kode');
        $desc = $this->request->getPost('keterangan');

        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'nama' => $name,
            'kode' => $code,
            'keterangan' => $desc
        ];

        /* 
    Membuat variabel ubah yang isinya merupakan memanggil function 
    update_pelayanan dan membawa parameter data beserta id
    */
        $ubah = $this->pelayanan->update_pelayanan($data, $id);

        // Jika berhasil melakukan ubah
        if ($ubah) {
            // Deklarasikan session flashdata
            session()->setFlashdata('warning', 'Updated pelayanan berhasil!');
            // Redirect ke halaman pelayanan
            return redirect()->to(base_url('pelayanan'));
        }
    }


    public function store()
    {
        // Mengambil value dari form dengan method POST
        $name = $this->request->getPost('nama');
        $code = $this->request->getPost('kode');
        $desc = $this->request->getPost('keterangan');


        // Membuat array collection yang disiapkan untuk insert ke table
        $data = [
            'nama' => $name,
            'kode' => $code,
            'keterangan' => $desc
        ];

        /* 
    Membuat variabel simpan yang isinya merupakan memanggil function 
    insert_pelayanan dan membawa parameter data 
    */
        $simpan = $this->pelayanan->insert_pelayanan($data);

        // Jika simpan berhasil, maka ...
        if ($simpan) {
            // Deklarasikan session flashdata dengan tipe success
            session()->setFlashdata('success', 'Created pelayanan successfully');
            // Redirect halaman ke pelayanan
            return redirect()->to(base_url('pelayanan'));
        }
    }
}
<file_sep><?php foreach ($antrian4 as $key => $data4) {
    $aa = $data4["id"];
} ?>
<?php foreach ($antrian5 as $key => $data5) {
    $bb = $data5["id"];
} ?>
<?php foreach ($antrian6 as $key => $data6) {
    $cc = $data6["id"];
} ?>
<?php foreach ($antrian7 as $key => $data7) {
    $dd = $data7["id"];
} ?>


<?= $this->extend('/layouts/tempelate-admin'); ?>

<?= $this->section('content'); ?>

<!-- Begin Page Content -->
<div class="container pb-5">

    <?php if (!empty(session()->getFlashdata("success"))) { ?>

        <div class="alert alert-success">
            <?php echo session()->getFlashdata("success"); ?>
        </div>

    <?php } ?>
    <?php if (!empty(session()->getFlashdata("info"))) { ?>

        <div class="alert alert-info">
            <?php echo session()->getFlashdata("info"); ?>
        </div>

    <?php } ?>

    <?php if (!empty(session()->getFlashdata("warning"))) { ?>

        <div class="alert alert-warning">
            <?php echo session()->getFlashdata("warning"); ?>
        </div>

    <?php } ?>

    <!-- Begin Page Content -->
    <div id="loket2">

        <!-- Page Heading -->
        <div class="col-12">
            Pelayanan Loket 2 (Pengaduan)
        </div>

        <div class="card">
            <div class="">
                <div class="container">
                    <div class="row">
                        <div class="col-dilayani">
                            <div class="dilayani">
                                <h5>Sedang Dilayani</h5>
                                <p>B<?php echo $bb; ?></p>
                            </div>
                            <?php if (is_numeric($bb)) {
                                echo "<a href='" .
                                    base_url("loketpanggil/edit/" . $bb) .
                                    "' class='btn btn-lg col-11 btn-warning'>Selesai</a>";
                            } else {
                                echo "<a class='btn btn-lg col-11 btn-danger'>Tidak ada antrian</a>";
                            } ?>
                        </div>
                        <div class="daftar">
                            <h4>Daftar Antrian Selanjutnya</h4>
                            <table class="table" border="1" cellspacing="0">
                                <thead>
                                    <tr>
                                        <th>No Antrian</th>
                                        <th>Panggil</th>
                                        <th>Keterangan</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>B<?php echo $bb; ?></td>
                                        <td>
                                            <?php if (is_numeric($bb)) {
                                                echo "<a href='' class='btn btn-sm col-11 btn-success'>Panggil</a>";
                                            } else {
                                                echo "<a class='btn btn-sm col-11 btn-danger'>kosong</a>";
                                            } ?>
                                        </td>
                                        <td>Ada</td>
                                    </tr>

                                </tbody>
                            </table>

                        </div>

                    </div>
                </div>
            </div>
        </div>


    </div>
    <!-- /.container-fluid -->



    <!-- End of Main Content -->
    <?= $this->endSection(); ?>