Cara buat suatu data yang tampilan bg-colornya otomatis berubah saat statusnya berubah?

<?php

class Home_model extends CI_model{
    //Menampilkan Semua Data
    public function getAllProject()
    {
        return $this->db->get('project')->result_array();
    }

    //Progress Function
    public function getProgress()
    {
        $query = $this->db->query("SELECT progress AS kemajuan FROM project GROUP BY progress ORDER BY progress ASC");

        return $query->result();
    }

    //Year Function
    public function getTahun()
    {
        $query = $this->db->query("SELECT tahun_pembuatan AS tahun FROM project GROUP BY tahun_pembuatan ORDER BY tahun_pembuatan ASC");

        return $query->result();
    }

    function filterByTahun($year)
    {
        return $this->db->get_where('project', ['tahun_pembuatan' => $year])->result();    }
}
<?php

class Home extends CI_Controller{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('Home_model');
    }

    public function index()
    {
        $var = array (

        );
        $data['judul']      = 'Halaman Informasi';
        $data['tahun']      = $this->Home_model->getTahun();
        $data['project']    = $this->Home_model->getAllProject();
        $data['kemajuan']   = $this->Home_model->getProgress();

        $this->load->view('templates/header', $data);
        $this->load->view('home/index', $data); /*Saya ingin mencari file bernama "home.php" yang berada pada folder view*/
        $this->load->view('templates/footer');
    }

    public function filter($year)
    {
        $data['judul']      = 'Halaman Informasi';
        $data['tahun']      = $this->Home_model->getTahun();
        $data['dataFilter'] = $this->Home_model->filterByTahun($year);
        $data['allProject'] = $this->Home_model->getAllProject();

        $this->load->view('templates/header', $data);
        $this->load->view('home/filter', $data);
        $this->load->view('templates/footer');
    }
}
<div class="container mt-5 pt-3">
    <ul class="list-group">
        <?php foreach($project as $data): ?>
            <?php if($data->Antri == "$kemajuan") { ?>
                <li class="list-group-item bg-danger">
                    <h3 class="text-center"><?= $data['nama_project']; ?></h3>
                    <div class="text-center">
                        <button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#keterangan">Keterangan</button>
                    </div>
                </li>
            <?php } elseif($data->kemajuan == "Proses") { ?>
                <li class="list-group-item bg-warning">
                    <h3 class="text-center"><?= $data['nama_project']; ?></h3>
                    <div class="text-center">
                        <button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#keterangan">Keterangan</button>
                    </div>
                </li>
            <?php } elseif($data->kemajuan == "Pengujian") { ?>
                <li class="list-group-item bg-info">
                    <h3 class="text-center"><?= $data['nama_project']; ?></h3>
                    <div class="text-center">
                        <button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#keterangan">Keterangan</button>
                    </div>
                </li>
            <?php } elseif($data->kemajuan == "Pengembangan") { ?>
                <li class="list-group-item bg-primary">
                    <h3 class="text-center"><?= $data['nama_project']; ?></h3>
                    <div class="text-center">
                        <button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#keterangan">Keterangan</button>
                    </div>
                </li>
            <?php } elseif($data->kemajuan == "Selesai") { ?>
                <li class="list-group-item bg-successs">
                    <h3 class="text-center"><?= $data['nama_project']; ?></h3>
                    <div class="text-center">
                        <button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#keterangan">Keterangan</button>
                    </div>
                </li>
            <?php } else { ?>
                <li class="list-group-item">
                    <h3 class="text-center"><?= $data['nama_project']; ?></h3>
                    <div class="text-center">
                        <button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#keterangan">Keterangan</button>
                    </div>
                </li>
            <?php } ?>
        <?php endforeach; ?>
    </ul>
</div>
avatar ulquiorraschiffer
@ulquiorraschiffer

1 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban