Created
March 11, 2021 14:54
-
-
Save jerry-maheswara-github/3075717dae60289aff925248f0410b94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Misi extends CI_Controller { | |
public function index() | |
{ | |
$data = $this->db->query(' | |
SELECT M.*, T.*, S.*, P.* | |
FROM M_MISI as M | |
INNER JOIN M_TUJUAN T ON T.misi_id = M.misi_id | |
INNER JOIN M_SASARAN S ON S.tujuan_id = T.tujuan_id | |
INNER JOIN M_PROGRAM P ON P.sasaran_id = S.sasaran_id | |
')->result(); | |
$misi_name = ''; | |
$tujuan_name = ''; | |
$sasaran_name = ''; | |
$program_name = ''; | |
$arr_m = array(); | |
$arr_t = array(); | |
$arr_s = array(); | |
$arr_p = array(); | |
$mapping = array(); | |
foreach ($data as $dkey => $dvalue) { | |
if ($dvalue->misi_name !== $misi_name) { | |
$mapping[$dkey][] = array('name'=>$dvalue->misi_name); | |
} | |
if ($dvalue->tujuan_name !== $tujuan_name) { | |
$mapping[$dkey][] = array('name' => $dvalue->tujuan_name); | |
} | |
if ($dvalue->sasaran_name !== $sasaran_name) { | |
$mapping[$dkey][] = array('name' => $dvalue->sasaran_name); | |
} | |
if ($dvalue->program_name !== $program_name) { | |
$mapping[$dkey][] = array('name' => $dvalue->program_name); | |
} | |
$misi_name = $dvalue->misi_name; | |
$tujuan_name = $dvalue->tujuan_name; | |
$sasaran_name = $dvalue->sasaran_name; | |
$program_name = $dvalue->program_name; | |
array_push($arr_m, $dvalue->misi_name); | |
array_push($arr_t, $dvalue->tujuan_name); | |
array_push($arr_s, $dvalue->sasaran_name); | |
array_push($arr_p, $dvalue->program_name); | |
} | |
$rowspan = array_merge( | |
array_count_values($arr_m), | |
array_count_values($arr_t), | |
array_count_values($arr_s), | |
array_count_values($arr_p) | |
); | |
foreach ($mapping as $ma_key => $ma_value) { | |
foreach ($ma_value as $mv_key => $mv_value) { | |
$mapping[$ma_key][$mv_key]['rowspan'] = $rowspan[$mv_value['name']]; | |
} | |
} | |
$this->data['data_misi'] = $mapping; | |
$this->load->view('misi', $this->data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment