cara melihat data

tampilan web :

https://imgur.com/UTUNzVJ

1. apa yang perlu ditambahkan dalam syntax, saat saya ingin melihat data tanpa memilih opsi pilih opd dan pilih kelompok?

2. dan melihat data tanpa memilih opsi pilih opd atau pilih kelompok?

jadi misal saat saya ingin melihat data salah satu opd memilih opsi kelompok, data tetap terlihat dan saat saya ingin melih data salah satu kelompok tanpa memilih opsi opd, data tetap terlihat?

controller

	function index() {
		$d['title'] = "Input Detil Pilah Gender";
		$d['bredkum'] = bredkum(array("data"=>$d['title']), "data");
		$d['p'] = "index";
		$this->load->view('template', $d);
	}

	function input_per_skpd($tahun=0) {
        $tahun  = "";
        $opd    = isset($p['opd'])?$p['opd']:'';
        $kelomp = isset($p['kelompok'])?$p['kelompok']:'';

		$d['p_tahun'] = array();

		for ($i = ((date('Y')) - 5); $i <= ((date('Y') + 1)); $i++) {
			$d['p_tahun'][$i] = $i;
		}

        $get_nama_kelompok  = $this->db->query("select id_kelompok,nama
                                                from data_pilah_gender_kelompok")->result_array();
        $get_opd            = $this->db->query("SELECT id, nama FROM `skpd`")->result_array();

        $d['p_opd']     = $get_opd;
        $d['p_kelompok']= $get_nama_kelompok;

	$d['tahun']     = $tahun;
        $d['opd']       = $opd;
        $d['kelompok']  = $kelomp;
        $d['nilai']     = array();

		$d['title'] = "Input Detil Pilah Gender";
		$d['bredkum'] = bredkum(array("data_pilah_gender"=>$d['title']), "data");
		$d['url'] = $this->url;
		$d['menu_aktif'] = 3;
		$d['p'] = "input_per_opd";
		$this->load->view('template', $d);
	}

	function input_per_skpd_ok() {
		if ($this->input->method() != 'post') {
            		if(count($this->input->get())==3) {
                		$g = $this->input->get();
                		$tahun  = $g['tahun'];
                		$opd    = $g['opd'];
                		$kelomp = $g['kelompok'];
            		} else {
                		redirect($this->url."/input_per_skpd");
            		}
				//redirect($this->url."/input_per_skpd");
		} else {
            		$p = $this->input->post();
            		$tahun  = $p['tahun'];
            		$opd    = $p['opd'];
            		$kelomp = $p['kelompok'];

            		redirect($this->url."/input_per_skpd_ok?tahun=$tahun&opd=$opd&kelompok=$kelomp");
        	}

		$p_tahun = array();

		for ($i = ((date('Y')) - 3); $i <= ((date('Y') + 1)); $i++) {
			$p_tahun[$i] = $i;
		}
		$tampung = array();

        	$get_nama_elemen    = $this->db->query("SELECT * FROM `data_pilah_gender` WHERE `id_skpd`='$opd' AND `id_kelompok`='$kelomp'")->result_array();
        	$get_nama_kelompok  = $this->db->query("select id_kelompok,nama
                                                from data_pilah_gender_kelompok")->result_array();
        	$get_opd            = $this->db->query("SELECT id, nama FROM `skpd`")->result_array();

        	$strings = "SELECT
	a.id, a.id_elemen, d.`id` AS id_skpd, c.`id_kelompok` AS id_kelompok, a.tahun, a.isi_l, a.isi_p, b.nama_elemen, d.`nama` AS nama_skpd, c.`nama` AS nama_kelompok
                    FROM data_pilah_gender_detil a
                    LEFT JOIN data_pilah_gender b ON a.id_elemen = b.id
                    LEFT JOIN `data_pilah_gender_kelompok` AS c ON b.`id_kelompok`=c.`id_kelompok`
                    LEFT JOIN `skpd` AS d ON b.`id_skpd`=d.`id`
                    WHERE a.tahun IN ('$tahun') AND b.`id_skpd`='$opd' AND b.`id_kelompok`='$kelomp' ";

        	$get_data = $this->db->query($strings)->result_array();

        	$tampung            = array();
        foreach((array)$get_nama_elemen as $gne) {
            $tampung[$gne['id']] = array("detail" => "", "l" => "", "p" => "", "elemen" => $gne['id'],"elemen_nama"=>$gne['nama_elemen'], "opd" => "$opd", "kelompok" => "$kelomp");

            foreach ((array)$get_data as $gd) {
                if ($gd['id_elemen'] == $gne['id']) {
                    $tampung[$gne['id']]['detail'] = $gd['id'];
                    $tampung[$gne['id']]['l'] = $gd['isi_l'];
                    $tampung[$gne['id']]['p'] = $gd['isi_p'];
                }
            }

            if ($tampung[$gne['id']]['detail'] == '') {
                $stringi = "INSERT INTO `data_pilah_gender_detil` ( `id_elemen`,`tahun`,`isi_l`,`isi_p`,`update_at` )
                            VALUES ( '{$gne['id']}','$tahun','','',NOW())";
                $this->db->query($stringi);
            }
        }

        	/* --------------------
		$get_nama_elemen = $this->db->query("select id, nama_elemen
											from data_pilah_gender")->result_array();

		$tampung['data'] = array();
		if (!empty($get_nama_elemen)) {
			foreach ($get_nama_elemen as $e) {
				$idx = $e['id'];
				$tampung['nama_elemen'][$idx] = $e['nama_elemen'];
			}
		}

		$strq = "select
						a.id, a.id_elemen, a.tahun, a.isi_l, a.isi_p, b.nama_elemen
						from data_pilah_gender_detil a
						left join data_pilah_gender b on a.id_elemen = b.id
						where a.tahun in (".$tahun_gabung.")";

		$get_data = $this->db->query($strq)->result_array();

		if (!empty($get_data)) {
			foreach ($get_data as $d) {
				$idx = $d['id_elemen']."-".$d['tahun'];
				$tampung['data'][$idx."_l"] = $d['isi_l'];
				$tampung['data'][$idx."_p"] = $d['isi_p'];
			}
		}
        	-------*/

		$d['p_tahun']   = $p_tahun;
        	$d['p_opd']     = $get_opd;
        	$d['p_kelompok']= $get_nama_kelompok;

		$d['tahun'] = $tahun;
        	$d['opd']   = $opd;
        	$d['kelompok']  = $kelomp;
        	$d['nilai']     = $tampung;

		$d['title'] = "Input Detil Pilah Gender";
		$d['bredkum'] = bredkum(array("data"=>$d['title']), "data");
		$d['url'] = $this->url;
		$d['menu_aktif'] = 3;
		$d['p'] = "input_per_opd";

		$this->load->view('template', $d);

	}

view

<div class="main-panel">
  <div class="content">
    <div class="page-inner">
      <div class="page-header">
        <h4 class="page-title"><?=$title;?></h4>
        <?=$bredkum;?>
      </div>

      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header">
              <h4 class="card-title">Aksi</h4>
            </div>
            <div class="card-body">
                <form action="<?=site_url($url."/input_per_skpd_ok")?>" method="post" class="">
            	<div class="row">
                    <div class="col-md-12">
                        <div class="form-group">
                            <label>Tahun</label><br>
                            <?=form_dropdown('tahun',$p_tahun,$tahun,'class="form-control" id="tahun" required');?>
                        </div>
                        <div class="form-group">
                            <label>OPD</label>
                            <select class="form-control" name="opd">
                                <option value="">Pilih OPD...</option>
                                <?php
                                $k_opd      = array();
                                foreach($p_opd as $pd) {
                                    $k_opd[$pd['id']]   = $pd['nama'];
                                    $selected       = "";
                                    if($pd['id']==$opd) {
                                        $selected   = "selected";
                                    }
                                    echo '<option value="'.$pd['id'].'" '.$selected.'>'.$pd['nama'].'</option>';
                                }
                                ?>
                            </select>

                        </div>
                        <div class="form-group">
                            <label>Kelompok Data</label>
                            <select class="form-control" name="kelompok">
                                <option value="">Pilih Kelompok...</option>
                                <?php
                                $k_kel      = array();
                                foreach($p_kelompok as $klp) {
                                    $k_kel[$klp['id_kelompok']]     = $klp['nama'];
                                    $selected       = "";
                                    if($klp['id_kelompok']==$kelompok) {
                                        $selected   = "selected";
                                    }
                                    echo '<option value="'.$klp['id_kelompok'].'" '.$selected.'>'.$klp['nama'].'</option>';
                                }
                                ?>
                            </select>

                        </div>
                    </div>
                    <div class="col-md-12">
                        <button class="btn btn-info" id="btn_view"><i class="fa fa-search"></i> View</button>
                        <a href="#" onclick="return eksport_excel();" class="btn btn-success"><i class="fa fa-download"></i> Download Format</a>
                        <a href="<?=site_url('data_pilah_gender_detil/import_excel');?>" class="btn btn-warning"><i class="fa fa-upload"></i> Upload Format</a>
                    </div>

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

      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header">
              <h4 class="card-title"><?=$title;?></h4>
            </div>
            <div class="card-body">
            	<form method="post" action="<?=site_url($url."/save_per_opd?tahun=$tahun&opd=$opd&kelompok=$kelompok");?>">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th width="40%" rowspan="2">Elemen</th>
                                <th width="15%" rowspan="2">OPD</th>
                                <th width="15%" rowspan="2">Kelompok Data</th>
                                <?php
                                $jml_tahun = 1;
                                $size = (30 / $jml_tahun);
                                    ?>
                                <th width="<?=$size;?>%" colspan="2"><?=$tahun?></th>
                            </tr>
                            <tr>
                                <th>L</th>
                                <th>P</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                                $num=1;
                                foreach ((array)$nilai as $e=>$f) {
                                    echo '<tr>
                                        <td>'.$f['elemen_nama'].'</td>
                                    ';
                                    ?>
                                        <td><?= $k_opd[$f['opd']] ?></td>
                                    <td><?= $k_kel[$f['kelompok']] ?></td>
                                    <td><input type="number" step="any" class="form-control" name="isi-<?=$f['elemen']?>-l" value="<?=$f['l']?>" /></td>
                                    <td><input type="number" step="any" class="form-control" name="isi-<?=$f['elemen']?>-p" value="<?=$f['p']?>" /></td>
                                    <?php
                                    echo '</tr>';

                                    //<td>'.form_number("jumlah_".$e['id_elemen']."_".$tahun,$e['isi'],'class="form-control input-sm" required step="any"').'</td>
                                }
                                if(!empty($nilai)) {

                            ?>
                            <tr>
                                <td colspan="<?=(($jml_tahun*2)+1);?>">
                                    <button type="submit" class="btn btn-info">Simpan</button>
                                </td>
                            </tr>
                            <?php
                                }
                            ?>
                        </tbody>
                    </table>
                </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
	//$('#tahun').select2();
	$('#id_skpd').fastselect();

	$("#btn_view").on("click", function() {
		var id_skpd = $("#id_skpd").val();
		var tahun = $("#tahun").val();

		if (id_skpd == "") {
			alert('Silakan pilih OPD');
			return false;
		} else if (tahun == null) {
			alert('Silakan isikan tahun');
			return false;
		} else if (tahun.length > 5) {
			alert('Tahun dipilih maksimal 5..')
			return false;
		} else {
			window.open(base_url+'data_indikator_makro_detil/input_per_skpd/'+id_skpd+'/'+tahun, '_self');
		}
	});

	function eksport_excel() {
		var tahun = $("#tahun").val();
		var gabung = tahun.join("-");
		window.open(base_url+'excel/eksport_data_detil_pilah_gender?tahun='+gabung);
		return false;
	}
</script>

Terimakasih

avatar aziima27
@aziima27

20 Kontribusi 11 Poin

Dipost 1 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban