Daftar dan Belajar Sekarang!

Sum mysql by current month

foto dvnwrkrsn
3 Kontribusi 0 Coto
1 minggu yang lalu
Halo, Saya ingin tau bagaimana caranya agar meSUM data pada masing2 tanggal, Semisalnya saya ingin SUM pda tanggal 1 dan tabel jumlah pasien saja dan sisanya di tanggal lain datanya 0. Mohon bantuannya. Ini Koding Viewnya
<head>
    <style>
    table, th, td {
        border: 1px solid black;
    }

    th, td {
        padding: 15px;
    }
    </style>
</head>
<div class="content-wrapper" lang="id">
    <section class="content-header">
        <h1>Surveilans</h1>
    </section>

    <section class="content">
        <form action="" method="get" id="">
            <div class="box box-solid">
                <div class="box-body">
                    <div class="row">
                        <div class="col-md-12">
                            <fieldset style="font-family:tahoma; font-size:12px">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label">Periode</label>
                                        <input type="date" class="form-control datepicker" name="date" id="valTgl">
                                        <br>
                                        <input type="button" value="Tampil" id="submitTgl">
                                    </div>
                                </div>
                            </fieldset>
                            <center>
                                <h2>HASIL SURVEILANS HAIS - <?= get_detail_tgl(date('Y-m'))?></h2>
                            </center>
                            <table>
                                <thead>
                                    <th scope="col">No</th>
                                        <th scope="col">Indikator</th>
                                        <?php
                                            $x = 1;
                                            $start  = date('Y-m-01');
                                            $end    = date('Y-m-t');
                                            $s      = strtotime($start);
                                            $e      = strtotime($end);
                                            $ss     = $s-86430;
                                            while($ss <= $e) {
                                                echo "<th align='center' colspan='2'>$x</th>"; ?>
                                        <?php 
                                        $ss+=86430;
                                        $x+=1; } ?>
                                        <th>Total</th>
                                </thead>
                                <tbody>
                                <?php foreach($detail->result_array() as $data){?>
                                    <tr>
                                        <td>1</td>
                                        <td>Jumlah Pasien Baru</td>
                                        <td><a href="" data-target="#mutu-modal-1" data-toggle="modal"></a></td>
                                    </tr>
                                    <tr>
                                        <td>2</td>
                                        <td>Jumlah Pasien Baru Terpasang Infus</td>
                                    </tr>
                                    <tr>
                                        <td>3</td>
                                        <td>Jumlah Pasien Baru Terpasang DC</td>
                                    </tr>
                                    <tr>
                                        <td>4</td>
                                        <td>Jumlah Terpasang CVL</td>
                                    </tr>
                                    <tr>
                                        <td>5</td>
                                        <td>Jumlah Pasien Baru Terpasang Ventilator</td>
                                    </tr>
                                    <tr>
                                        <td>6</td>
                                        <td>Jumlah Pasien Baru Tirah Baring</td>
                                    </tr>
                                    <tr>
                                        <td>7</td>
                                        <td>Jumlah Pasien Dengan Central Line/Hari</td>
                                    </tr>
                                    <tr>
                                        <td>8</td>
                                        <td>Jumlah Pasien Terpasang Vena Line/Hari</td>
                                    </tr>
                                    <tr>
                                        <td>9</td>
                                        <td>Jumlah Pasien Terpasang Kateter Urin/Hari</td>
                                    </tr>
                                    <tr>
                                        <td>10</td>
                                        <td>Jumlah Pasien Terpasang Ventilator/Hari</td>
                                    </tr>
                                    <tr>
                                        <td>11</td>
                                        <td>Jumlah Pasien Operasi</td>
                                    </tr>
                                    <tr>
                                        <td>12</td>
                                        <td>Jumlah Pasien Tirah Baring/Hari</td>
                                    </tr>
                                    <tr>
                                        <td>13</td>
                                        <td>IADP(Infeksi Aliran Darah Primer)</td>
                                    </tr>
                                    <tr>
                                        <td>14</td>
                                        <td>ISK(Infeksi Saluran Kemih)</td>
                                    </tr>
                                    <tr>
                                        <td>15</td>
                                        <td>HAP(Hospital Acquired Pneumonia)</td>
                                    </tr>
                                    <tr>
                                        <td>16</td>
                                        <td>VAP(Ventilator Asociated Pneumonia)</td>
                                    </tr>
                                    <tr>
                                        <td>17</td>
                                        <td>IDO(Infeksi Daerah Operasi)</td>
                                    </tr>
                                    <tr>
                                        <td>18</td>
                                        <td>Plebitis</td>
                                    </tr>
                                    <tr>
                                        <td>19</td>
                                        <td>Dekubitis</td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </section>
</div>


<!-- Modal -->
<div class="modal fade" id="mutu-modal-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN BARU</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_pasien_baru">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" id="jumlah_pasien_baru" name="jumlah_pasien_baru">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
            </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-2" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN BARU TERPASANG INFUS</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_baru_infus">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" id="jumlah_baru_infus" name="jumlah_baru_infus">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-3" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN BARU TERPASANG DC</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_baru_dc">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_baru_dc">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-4" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH TERPASANG CVL</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_cvl">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_cvl">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-5" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN BARU TERPASANG VENTILATOR</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_baru_ventilator">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_baru_ventilator">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-6" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN BARU TIRAH BARING</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_baru_tirah_baring">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_baru_tirah_baring">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-7" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN DENGAN CENTRAL LINE/HARI</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_central_hari">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_central_hari">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-8" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN TERPASANG VENA LINE /HARI</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_vena_hari">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_vena_hari">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-9" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN TERPASANG KATETER URIN/HARI</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_kateter_urin">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_kateter_urin">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-10" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN TERPASANG VENTILATOR /HARI</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_ventilator_hari">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_ventilator_hari">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-11" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN OPERASI</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_pasien_operasi">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_pasien_operasi">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-12" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">JUMLAH PASIEN TIRAH BARING /HARI</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_tirah_baring_hari">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_tirah_baring_hari">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-13" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">IADP (Infeksi Aliran Darah Primer)</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_iadp">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_iadp">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-14" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">ISK (Infeksi Saluran Kemih)</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_isk">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_isk">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-15" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">HAP (Hospital Aquired Pneumonia)</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_hap">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_hap">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="mutu-modal-16" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">VAP (Ventilator Asociated Pneumonia)</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_vap">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_vap">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="mutu-modal-17" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">IDO (Infeksi Daerah Operasi)</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_ido">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_ido">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="mutu-modal-18" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">PLEBITIS</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_plebitis">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_plebitis">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
            </form>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="mutu-modal-19" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="modal-title">DEKUBITUS</h5>
            </div>
            <form method="post" enctype="multipart/form-data" action="<?= base_url(); ?>ppi/ppi_hais/tambah_dekubitis">
                <div class="modal-body">
                    <p>Masukkan Nilai : </p>
                    <input type="text" name="jumlah_dekubitis">
                    <input type="hidden" name="tanggal" value="<?php echo date('Y-m-d')?>">
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                </div>
            </form>
            </div>
        </div>
    </div>
</div>
Ini Modelnya
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class M_ppi_hais extends CI_Model {

    public function __construct(){
        parent::__construct();
    }

    public function get_indikator()
    {
        $sql = "SELECT * FROM t_surveilan";

        return $this->db->query($sql); 
    }

    public function get_detail_surveilan()
    {
        $sql = "SELECT * FROM t_surveilan_detail";

        return $this->db->query($sql);
    }

    public function save_pasien_baru($jumlah_pasien_baru,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_pasien_baru,tanggal,id_indikator) value(?,?,1)";

        $this->db->query($sql, array($jumlah_pasien_baru,$tanggal));
    }

    public function save_infus_baru($jumlah_baru_infus,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_baru_infus,tanggal,id_indikator) values('$jumlah_baru_infus','$tanggal',2)";

        $this->db->query($sql);
    }

    public function save_baru_dc($jumlah_baru_dc,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_baru_dc,tanggal,id_indikator) values('$jumlah_baru_dc','$tanggal',3)";

        $this->db->query($sql);
    }

    public function save_cvl($jumlah_cvl,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_cvl,tanggal,id_indikator) values('$jumlah_cvl','$tanggal',4)";

        $this->db->query($sql);
    }

    public function save_baru_ventilator($jumlah_baru_ventilator,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_baru_ventilator,tanggal,id_indikator) values('$jumlah_baru_ventilator','$tanggal',5)";

        $this->db->query($sql);
    }

    public function save_baru_tirah_baring($jumlah_baru_tirah_baring,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_baru_tirah_baring,tanggal,id_indikator) values('$jumlah_baru_tirah_baring','$tanggal',6)";

        $this->db->query($sql);
    }

    public function save_central_hari($jumlah_central_hari,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_central_hari,tanggal,id_indikator) values('$jumlah_central_hari','$tanggal',7)";

        $this->db->query($sql);
    }

    public function save_vena_hari($jumlah_vena_hari,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_vena_hari,tanggal,id_indikator) values('$jumlah_vena_hari','$tanggal',8)";

        $this->db->query($sql);
    }

    public function save_kateter_urin($jumlah_kateter_urin,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_kateter_urin,tanggal,id_indikator) values('$jumlah_kateter_urin','$tanggal',9)";

        $this->db->query($sql);
    }

    public function save_ventilator_hari($jumlah_ventilator_hari,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_ventilator_hari,tanggal,id_indikator) values('$jumlah_ventilator_hari','$tanggal',10)";

        $this->db->query($sql);
    }

    public function save_pasien_operasi($jumlah_pasien_operasi,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_pasien_operasi,tanggal,id_indikator) values('$jumlah_pasien_operasi','$tanggal',11)";

        $this->db->query($sql);
    }

    public function save_tirah_baring_hari($jumlah_tirah_baring_hari,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_tirah_baring_hari,tanggal,id_indikator) values('$jumlah_tirah_baring_hari','$tanggal',12)";

        $this->db->query($sql);
    }

    public function save_iadp($jumlah_iadp,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_iadp,tanggal,id_indikator) values('$jumlah_iadp','$tanggal',13)";

        $this->db->query($sql);
    }

    public function save_isk($jumlah_isk,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_isk,tanggal,id_indikator) values('$jumlah_isk','$tanggal',14)";

        $this->db->query($sql);
    }

    public function save_hap($jumlah_hap,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_hap,tanggal,id_indikator) values('$jumlah_hap','$tanggal',15)";

        $this->db->query($sql);
    }

    public function save_vap($jumlah_vap,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_vap,tanggal,id_indikator) values('$jumlah_vap','$tanggal',16)";

        $this->db->query($sql);
    }

    public function save_ido($jumlah_ido,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_ido,tanggal,id_indikator) values('$jumlah_ido','$tanggal',17)";

        $this->db->query($sql);
    }

    public function save_plebitis($jumlah_plebitis,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_plebitis,tanggal,id_indikator) values('$jumlah_plebitis','$tanggal',18)";

        $this->db->query($sql);
    }

    public function save_dekubitis($jumlah_dekubitis,$tanggal)
    {
        $sql = "INSERT INTO t_surveilan_detail(jumlah_dekubitis,tanggal,id_indikator) values('$jumlah_dekubitis','$tanggal',19)";

        $this->db->query($sql);
    }

}
ini Controllernya
<?php 
defined('BASEPATH') OR exit('No direct script access allowed');

class Ppi_hais extends RSUD_Controller {

    public function __construct() {
        parent::__construct();

        $this->load->model(array(
            'ppi/m_ppi_hais',
        ));

    }

    public function index()
    {
        $data = array(
            "indikator" => $this->m_ppi_hais->get_indikator(),
            "detail"    => $this->m_ppi_hais->get_detail_surveilan()

        );

        $this->load->view('template/header', array('title_window' => "Dashboard PPI - SIMRS"));
        $this->load->view('template/menu');
        $this->load->view('ppi/ppi_hais', $data);
        $this->load->view('template/footer');

    }

    public function tambah_pasien_baru()
    {
        $jumlah_pasien_baru             = $this->input->post('jumlah_pasien_baru');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_pasien_baru($jumlah_pasien_baru,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_baru_infus()
    {
        $jumlah_baru_infus              = $this->input->post('jumlah_baru_infus');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_infus_baru($jumlah_baru_infus,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_baru_dc()
    {
        $jumlah_baru_dc              = $this->input->post('jumlah_baru_dc');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_baru_dc($jumlah_baru_dc,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_cvl()
    {
        $jumlah_cvl             = $this->input->post('jumlah_cvl');
        $tanggal                = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_cvl($jumlah_cvl,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_baru_ventilator()
    {
        $jumlah_baru_ventilator             = $this->input->post('jumlah_baru_ventilator');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_baru_ventilator($jumlah_baru_ventilator,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_baru_tirah_baring()
    {
        $jumlah_baru_tirah_baring              = $this->input->post('jumlah_baru_tirah_baring');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_baru_tirah_baring($jumlah_baru_tirah_baring,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_central_hari()
    {
        $jumlah_central_hari              = $this->input->post('jumlah_central_hari');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_central_hari($jumlah_central_hari,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_vena_hari()
    {
        $jumlah_vena_hari             = $this->input->post('jumlah_vena_hari');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_vena_hari($jumlah_vena_hari,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_kateter_urin()
    {
        $jumlah_kateter_urin              = $this->input->post('jumlah_kateter_urin');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_kateter_urin($jumlah_kateter_urin,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_ventilator_hari()
    {
        $jumlah_ventilator_hari              = $this->input->post('jumlah_ventilator_hari');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_ventilator_hari($jumlah_ventilator_hari,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_pasien_operasi()
    {
        $jumlah_pasien_operasi              = $this->input->post('jumlah_pasien_operasi');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_pasien_operasi($jumlah_pasien_operasi,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_tirah_baring_hari()
    {
        $jumlah_tirah_baring_hari              = $this->input->post('jumlah_tirah_baring_hari');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_tirah_baring_hari($jumlah_tirah_baring_hari,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_iadp()
    {
        $jumlah_iadp              = $this->input->post('jumlah_iadp');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_iadp($jumlah_iadp,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_isk()
    {
        $jumlah_isk              = $this->input->post('jumlah_isk');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_isk($jumlah_isk,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_hap()
    {
        $jumlah_hap              = $this->input->post('jumlah_hap');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_hap($jumlah_hap,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_vap()
    {
        $jumlah_vap              = $this->input->post('jumlah_vap');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_vap($jumlah_vap,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_ido()
    {
        $jumlah_ido              = $this->input->post('jumlah_ido');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_ido($jumlah_ido,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_plebitis()
    {
        $jumlah_plebitis              = $this->input->post('jumlah_plebitis');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_plebitis($jumlah_plebitis,$tanggal);

        redirect('ppi/ppi_hais');
    }

    public function tambah_dekubitis()
    {
        $jumlah_dekubitis              = $this->input->post('jumlah_dekubitis');
        $tanggal                        = $this->input->post('tanggal');
        
        
        $this->m_ppi_hais->save_dekubitis($jumlah_dekubitis,$tanggal);

        redirect('ppi/ppi_hais');
    }
}
Terima kasih sebelumnya

Jawaban
foto raendyelvicar
5 Kontribusi 0 Coto
1 minggu yang lalu
Antara pake fungsi SUM() atau COUNT() mungkin bang, count untuk ngitung seberapa banyak barisnya, kalo sum untuk ngitung jumlah "nilai" dari tiap barisnya berdasarkan tanggal. Querynya mungkin kurang lebih begini SELECT SUM(nama_kolom) FROM t_surveilan_detail GROUP BY tanggal; contoh: SELECT SUM(jumlah_pasien_baru) FROM t_surveilan_detail GROUP BY tanggal; implementasi di codingannya ane kurang paham CMIIW


Login untuk diksusi di forum sekolah koding