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

class Rep_tunggakan_kls extends CI_Controller {
	
	var $gparam = array();
	
	public function __construct() {
        parent::__construct();
		$this->gparam['controller'] = $this->router->fetch_class();
		$this->load->model('rep_tunggakan_kls_model', 'rep_sis');
		$this->gparam['privilage'] = getPrivilage($this->gparam['controller']);
		$this->gparam['restrict'] = 'You Cannot Access This Menu';
    }
	
	
	public function index()	{
		
		if ($this->gparam['privilage']->privilage_view == 'Y') {
		
			$gridopt = $this->input->get(array('psize', 'pnumber'));
			header('Content-Type: text/html');
			$act = base_url()."index.php/".$this->gparam['controller']."/load_data";
			
			$excell_download = '<a class="btn btn-success" id="save_excell" href="#" >
								<i class="fa fa-lg fa-fw fa-download"></i>Excell
							  </a>';		

			
			$get_smk = $this->rep_sis->getDataSMK();
			$nama_smk='	<select name="smk" class="chosen-select" style="width:195px;" onchange="getJurusan(this.value);cekKelas(0,0);getRuang();" >
									<option value="">--Semua Sekolah--</option>';
					
			foreach ($get_smk as $v_smk) {
				$nama_smk .='<option value="'.$v_smk['id'].'">'.$v_smk['name'].'</option>';
			}
			$nama_smk .='</select> ';
			
			$mappingJur = '<div id="id-MappingJur">
					<label class="select">
						<select name="id_mapping_jur" class="chosen-select" style="width:195px;" id="id_mapping_jur" onchange="cekKelas(0,0);getRuang();">
							<option value="">--Semua Jurusan--</option>																
						</select> <i></i> 
					</label></div>';
					$kelas='<div id="id-MappingKls"><label class="select">
									<select name="kelas" style="width:195px;" class="chosen-select" onchange="getRuang(this.value);" >
									<option value="">--Semua Kelas--</option></select> <i></i> 
								</label></div>';
								
			$ruang='<div id="id-MappingRuang"><label class="select">
									<select name="ruang" style="width:195px;" class="chosen-select">
									<option value="">--Semua Ruang Kelas--</option></select> <i></i> 
								</label></div>';
			
			
			// pnumber, psize
			$data = array(
					'controller'  	=> $this->gparam['controller'],
					'psize'			=> (empty($gridopt['psize'])?10:$gridopt['psize']),
					'pnumber'  		=> (empty($gridopt['pnumber'])?1:$gridopt['pnumber']),
					'excell' 		=> $excell_download,
					'nama_smk' 		=> $nama_smk,
					'ruang'	=> $ruang,
					'mappingJur'	=> $mappingJur,
					'kelas'	=> $kelas,
					'action'		=> $act
			);
			
			$this->load->view('rep_tunggakan_kls_view',$data);
		} else {
			echo $this->gparam['restrict'];
		}
	}
	
	
	function load_data() {
	
		/* $periode = $this->input->post("periode");
		$until = $this->input->post("until");
	    $get_id_siswa = $this->rep_sis->get_id_siswa($peride,$until);
		 */
		$bulan = array("July","August","September","October","November","December","January","February","March","April","May","June");
		$now = new \DateTime('now');
	   	$month = $now->format('m');
	   	$year = $now->format('Y');
		
		$curr_bulan = $month - 6;
		if($curr_bulan <= 0){
			$curr_bulan = $month + 6;
		}
		
		$periode = $this->input->post("periode");	
		$smk = $this->input->post("smk");
		$jur = $this->input->post("id_mapping_jur");
		$kelas = $this->input->post("kelas");
		$ruang = $this->input->post("ruang");
		if((empty($smk))||($smk=='')){
			$get_id_siswa = $this->rep_sis->get_id_siswa('', '', '', '');
			$header = $this->rep_sis->get_header('');
			$header_count = $this->rep_sis->get_count_header('');
		}else if((empty($jur))||($jur=='')){
			$get_id_siswa = $this->rep_sis->get_id_siswa($smk, '', '', '');
			$header = $this->rep_sis->get_header($smk);
			$header_count = $this->rep_sis->get_count_header($smk);
		}else if((empty($kelas))||($kelas=='')){
			$get_id_siswa = $this->rep_sis->get_id_siswa($smk, $jur, '', '');
			$header = $this->rep_sis->get_header($smk);
			$header_count = $this->rep_sis->get_count_header($smk);
		}else if((empty($ruang))||($ruang=='')){
			$get_id_siswa = $this->rep_sis->get_id_siswa($smk, $jur, $kelas, '');
			$header = $this->rep_sis->get_header($smk);
			$header_count = $this->rep_sis->get_count_header($smk);
		}else{
			$get_id_siswa = $this->rep_sis->get_id_siswa($smk, $jur, $kelas, $ruang);
			$header = $this->rep_sis->get_header($smk);
			$header_count = $this->rep_sis->get_count_header($smk);
		}
		
		
		
		/*Header*/
		$html = '<table class="table table-bordered" border="1" id="activity_table"><thead><tr>';
		$html .='<th rowspan="2" style="text-align:center;">No.</th>';
		$html .='<th rowspan="2" style="text-align:center;">Nama</th>';
		$html .='<th rowspan="2" style="text-align:center;">Sekolah</th>';
		$html .='<th rowspan="2" style="text-align:center;">Kelas</th>';
		$html .='<th rowspan="2" style="text-align:center;">NIS</th>';
		$html .='<th rowspan="2" style="text-align:center;">Total SPP</th>';
		$header_cicilan = $this->rep_sis->get_header_cicilan();
		$header_cicilan_count = $this->rep_sis->get_cicilan_count_header();
		$html .='<th rowspan="2" style="text-align:center;">DSP</th>';
		
		
		foreach ($header_count as $value_header_c) {
			$nama_smk=$this->rep_sis->getSMK($value_header_c['id_smk']);
			
			$html .='<th colspan="'.$value_header_c['jenis_pem'].'" style="text-align:center;">'.$nama_smk->name.'</th>';
		}
		
		$html .='<th rowspan="2" style="text-align:center;" >Jumlah</th>';
		$html .= '</tr></thead>';
		
		$html .= '<thead><tr>';
		/*foreach ($header_cicilan as $header_cicilan_r) {
			$html .='<th style="text-align:center;">'.$header_cicilan_r['daftarlist'].'</th>';
		}*/
		//$html .='<th style="text-align:center;">DSP</th>';
		
		$total_biaya_siswa;
		$temp_bs=0;
		foreach ($header as $value_header) {
			$total_biaya_siswa[$temp_bs]=0;
			$temp_bs=$temp_bs+1;
			$html .='<th style="text-align:center;">'.$value_header['jenispembayaran'].'</th>';
		}
		
		$html .= '</tr></thead>';
		
		$html .= '<tbody>';
		/*Close Header*/
		
		
		$total_all = 0;
		$total_spp = 0;
		/*$total_cicil=array($header_cicilan_count->jum_cicilan);
		
		for($inz_c=0;$inz_c<$header_cicilan_count->jum_cicilan;$inz_c++){
			$total_cicil[$inz_c]=0;
		}*/
		
		$total_cicil=0;
		$i_no=1;
		foreach ($get_id_siswa as $v_siswa) {
			
			$spp = 0;
			$trans = 0;
			/*Get Detail Siswa*/
			$html .='<tr><td>'.$i_no++.'</td>';	
			$html .='<td>'.$this->rep_sis->get_detail($v_siswa['id_siswa']).'</td>';	
			$html .='<td>'.$this->rep_sis->get_ruang_kelas($v_siswa['id_siswa']).'</td>';
			$html .='<td>'.$this->rep_sis->get_kelas($v_siswa['id_siswa']).'</td>';		
			$html .='<td>'.$v_siswa['nis'].'</td>';				
			/******************/
			
			/*Get Detail SPP Siswa*/
			$spp = $this->rep_sis->get_total_spp($v_siswa['id_siswa']);	
			$spp_rep = $this->rep_sis->get_spp_rep($v_siswa['id_siswa']);	
			
			$count_spp_rep=0;
			$thn_ajaran=$this->rep_sis->get_tahun_ajaran();
			foreach ($spp_rep as $v_spp_rep) {
				if($v_spp_rep['tahun_ajaran']==$thn_ajaran){
					for($i=1;$i<=$curr_bulan;$i++){
						if($i==1){
							if((empty($v_spp_rep['July']))||($v_spp_rep['July']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==2){
							if((empty($v_spp_rep['August']))||($v_spp_rep['August']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==3){
							if((empty($v_spp_rep['September']))||($v_spp_rep['September']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==4){
							if((empty($v_spp_rep['October']))||($v_spp_rep['October']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==5){
							if((empty($v_spp_rep['November']))||($v_spp_rep['November']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==6){
							if((empty($v_spp_rep['December']))||($v_spp_rep['December']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==7){
							if((empty($v_spp_rep['January']))||($v_spp_rep['January']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==8){
							if((empty($spp_rep['February']))||($spp_rep['February']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==9){
							if((empty($v_spp_rep['March']))||($v_spp_rep['March']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==10){
							if((empty($v_spp_rep['April']))||($v_spp_rep['April']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==11){
							if((empty($v_spp_rep['May']))||($v_spp_rep['May']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==12){
							if((empty($v_spp_rep['June']))||($v_spp_rep['June']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}
					}
				}else{
					for($i=1;$i<=12;$i++){
						if($i==1){
							if((empty($v_spp_rep['July']))||($v_spp_rep['July']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==2){
							if((empty($v_spp_rep['August']))||($v_spp_rep['August']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==3){
							if((empty($v_spp_rep['September']))||($v_spp_rep['September']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==4){
							if((empty($v_spp_rep['October']))||($v_spp_rep['October']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==5){
							if((empty($v_spp_rep['November']))||($v_spp_rep['November']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==6){
							if((empty($v_spp_rep['December']))||($v_spp_rep['December']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==7){
							if((empty($v_spp_rep['January']))||($v_spp_rep['January']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==8){
							if((empty($v_spp_rep['February']))||($v_spp_rep['February']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==9){
							if((empty($v_spp_rep['March']))||($v_spp_rep['March']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==10){
							if((empty($v_spp_rep['April']))||($v_spp_rep['April']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==11){
							if((empty($v_spp_rep['May']))||($v_spp_rep['May']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}else if($i==12){
							if((empty($v_spp_rep['June']))||($v_spp_rep['June']=='')){
								$count_spp_rep=$count_spp_rep+$v_spp_rep['biaya'];
							}
						}
					}	
				}
			}
			
			$total_spp=$total_spp+$count_spp_rep;
			
			if($count_spp_rep==0||empty($count_spp_rep)){
				$html .='<td style="text-align:right;">LUNAS</td>';
			}else{		
				$html .='<td style="text-align:right;">Rp. '.number_format($count_spp_rep,2,",",".").'</td>';
			}
			
			/*****************/
			
			/*Get Detail Cicilan Siswa*/
			$total_cicilan=0;
			$temp_tc=0;
			//foreach ($header_cicilan as $header_cicilan_r) {
				$cicilan = $this->rep_sis->get_total_cicilan($v_siswa['id_siswa']);	
				$bayar_cicilan = $this->rep_sis->get_total_bayar_cicilan($v_siswa['id_siswa']);	
				$total_bayar_cicilan=$bayar_cicilan-$cicilan;
				
				if($total_bayar_cicilan<=0){
					$html .='<td style="text-align:right;"> LUNAS </td>';
				}else{		
					$html .='<td style="text-align:right;">Rp. '.number_format($total_bayar_cicilan,2,",",".").'</td>';
				}
				$total_cicilan=$total_cicilan+$total_bayar_cicilan;
				$total_cicil=$total_cicil+$total_cicilan;
				$temp_tc=$temp_tc+1;
			//}
			
				
			/*Get Detail Transaksi*/
			$val_gtrans=0;
			$sign_gtrans=0;
			$temp_inc_b=0;
			foreach ($header as $vheader) {
				$gtrans 	= $this->rep_sis->get_total_trans($v_siswa['id_siswa'],$vheader['id']);
				$gtotal_maps = $this->rep_sis->get_total_map_biaya_siswa($v_siswa['id_siswa'],$vheader['id'], $v_siswa['id_smk'], $v_siswa['kelas']);
				$gtotal_maps_smk = $this->rep_sis->get_total_map_biaya_siswa_smk($v_siswa['id_siswa'],$vheader['jenispembayaran'], $v_siswa['id_smk'], $v_siswa['kelas']);
				$total_gtran=0;
				$coba=0;
				if(empty($gtrans)||$gtrans==NULL){
					//$coba=15;	
					if(empty($gtotal_maps)){
						$val_gtrans=0;
					}else{
						$total_gtran=0;
						$val_gtrans=0;
						$temp_t3=0;
						foreach ($gtotal_maps as $gtotal_map) {
							if(($v_siswa['kelas'])==($gtotal_map['kelas'])){
								if($gtotal_map['tahun_ajaran']==$thn_ajaran){
									$temp_t3=1;
									if(($gtotal_map['periode'])<=($curr_bulan)){
										$val_gtrans=($gtotal_map['total']);
									}else{
										$val_gtrans=0;
									}
								}else{
									$val_gtrans=($gtotal_map['total']);
								}
							}else if(($v_siswa['kelas'])>($gtotal_map['kelas'])){
								$val_gtrans=$gtotal_map['total'];
								
							}else{
								$val_gtrans=0;
							}
							$total_gtran=$total_gtran+$val_gtrans;
						}
					}
				}else{
					if(empty($gtotal_maps)){
						$val_gtrans=0;
					}else{
						$total_gtran=0;
						$val_gtrans=0;
						$temp_t3=0;
						foreach ($gtotal_maps as $gtotal_map) {
							$temp_t2=0;
							//foreach ($gtrans as $gtran) {
								if(($gtotal_map['id'])==($gtrans->id_list_biaya)){
									$temp_t2=1;
									$val_gtrans=0;
									
									if(($v_siswa['kelas'])==($gtotal_map['kelas'])){
										if($gtotal_map['tahun_ajaran']==$thn_ajaran){
											$temp_t3=1;
											if(($gtotal_map['periode'])<=($curr_bulan)){
												$val_gtrans=($gtotal_map['total']);
											}else{
												$val_gtrans=0;
											}
										}else{
											$val_gtrans=($gtotal_map['total']);
										}
									}else if(($v_siswa['kelas'])>($gtotal_map['kelas'])){
										$val_gtrans=($gtotal_map['total']);
									}else{
										$val_gtrans=0;
									}
									
								}
							//}
							if($temp_t2==0){
								if(($v_siswa['kelas'])==($gtotal_map['kelas'])){
									if($gtotal_map['tahun_ajaran']==$thn_ajaran){
										$temp_t3=1;
										if(($gtotal_map['periode'])<=($curr_bulan)){
											$val_gtrans=($gtotal_map['total']);
										}else{
											$val_gtrans=0;
										}
									}else{
										$val_gtrans=($gtotal_map['total']);
									}
								}else if(($v_siswa['kelas'])>($gtotal_map['kelas'])){
									$val_gtrans=($gtotal_map['total']);
								}else{
									$val_gtrans=0;
								}
							}
							$total_gtran=$total_gtran+$val_gtrans;
						}
					}
				}
				
				
				/*
				foreach ($gtrans as $gtran) {
					$coba=1000;
					$temp_t1=0;
					
					
					
					
					foreach ($gtotal_maps as $gtotal_map) {
						
						if(($gtotal_map['id'])==($gtran['id_list_biaya'])){
							
							if(($gtran['total'])||(empty($gtran['total']))||($gtran['total']==NULL)){
								if(($v_siswa['kelas'])>=($gtotal_map['kelas'])){
									if($temp_t1==0){
										$val_gtrans=($gtotal_map['total'])-($gtran['total']);
										$sign_gtrans=1;
										$temp_t1=$temp_t1+1;
									}else{
										if(($gtotal_map['periode'])<=($curr_bulan)){
											$val_gtrans=($gtotal_map['total'])-($gtran['total']);
											$sign_gtrans=1;
										}else{
											if(($v_siswa['kelas'])>($gtotal_map['kelas'])){
												$val_gtrans=($gtotal_map['total'])-($gtran['total']);
												$sign_gtrans=1;
											}else{
												$val_gtrans=0;
												$sign_gtrans=-1;
											}
										}
										
									}
									
								}else{
									$val_gtrans=0;
									$sign_gtrans=-1;
								}
							}else{
								$val_gtrans=($gtotal_map['total'])-($gtran['total']);
								if($val_gtrans<=0){
									$val_gtrans=0;
									$sign_gtrans=0;
								}else{
									$val_gtrans=$val_gtrans;
									$sign_gtrans=1;
								}
							}
						}
					}
				$total_gtran=$total_gtran+$val_gtrans;
				}
				*/
					if(($vheader['id_smk'])==($v_siswa['id_smk'])){
						$temp_t=$total_gtran - $gtrans->total;
						if($temp_t<=0){
							$temp_t=0;
						}else{
							$temp_t=$temp_t;
						}
						$trans = $trans + $temp_t; 
						$total_biaya_siswa[$temp_inc_b]=$total_biaya_siswa[$temp_inc_b]+$temp_t;
						//if(($sign_gtrans==0)||(empty($sign_gtrans))){
							//$html .='<td style="text-align:right;">LUNAS</td>';
						//}else if($sign_gtrans==-1){
							//$html .='<td style="text-align:right;">BAT</td>';
						//}else{
							//$html .='<td style="text-align:right; background-color:yellow;">Rp. '.number_format($total_gtran,2,",",".").'</td>';
							$html .='<td style="text-align:right;">Rp. '.number_format($temp_t,2,",",".").'</td>';
						//}
					}else{
						$trans = $trans;
						//$html .='<td style="text-align:right;">Rp. - </td>';
						$html .='<td style="text-align:right;">-</td>';
						$total_biaya_siswa[$temp_inc_b]=$total_biaya_siswa[$temp_inc_b]+0;
					}
				
				$temp_inc_b=$temp_inc_b+1;
			}			
			/*******************/
			
			/* Get Total Transaction */
			$jml = $count_spp_rep + $trans + $total_cicilan;
			$total_all = $total_all + $jml;			
			$html .='<td style="text-align:right;"><b>Rp. '.number_format($jml,2,",",".").'</b></td></tr>';
			/********************/
			
		}
		$html .= '<tr><td style="text-align:center; font-weight: bold;" colspan="5" >JUMLAH</td>';
		$html .= '<td style="text-align:right;">Rp. '.number_format($total_spp,2,",",".").'</td>';
		//for($tc=0; $tc < $header_cicilan_count->jum_cicilan ; $tc++){
			$html .= '<td style="text-align:right;">Rp. '.number_format($total_cicil,2,",",".").'</td>';
		//}
		
		for($ts=0; $ts < sizeof($header) ; $ts++){
			$html .= '<td style="text-align:right;">Rp. '.number_format($total_biaya_siswa[$ts],2,",",".").'</td>';
		}
		$html .='<td style="text-align:right;"><b>Rp. '.number_format($total_all,2,",",".").'</b></td></tr>';
		
		/*
		$html .= '<tr><td style="text-align:center; font-weight: bold;" colspan="3" >JUMLAH</td>';
		
		$spp_harian = $this->rep_sis->total_spp_harian($periode);
		$html .= '<td style="text-align:right;">Rp. '.number_format($total_spp,2,",",".").'</td>';
		
		
		
		$smk = $this->input->post("smk");
		
		foreach ($header as $vheader) {
				if((empty($smk))||($smk=='')){
					$otal_daily = $this->rep_sis->get_total_trans_harian($vheader['jenispembayaran'],$periode,'');
					//if($vheader['id_smk']==$otal_daily->id_smk){
					$html .='<td style="text-align:right;"><b>Rp. '.number_format($otal_daily->total,2,",",".").'</b></td>';
					//}else{
					//	$html .='<td style="text-align:right;"><b>Rp. test </b></td>';
					//}
						
				}else{
					$otal_daily = $this->rep_sis->get_total_trans_harian($vheader['jenispembayaran'],$periode,$smk);
					//if($vheader['id_smk']==$otal_daily->id_smk){
						$html .='<td style="text-align:right;"><b>Rp. '.number_format($otal_daily->total,2,",",".").'</b></td>';
					//}else{
					//	$html .='<td style="text-align:right;"><b>Rp. - </b></td>';
					//}
				}
				
		}
		*/
		/**********************/
		
		/*Summary Closing*/
		//$html .='<td style="text-align:right;"><b>Rp. '.number_format($total_all,2,",",".").'</b></td></tr>';
		/*****************/
		$html .= '</tbody>';
		$html .= '</table>';
		//$html = "Peiode -- ".$periode;
		$html .= '<script>
					var name = "DailyTrans.xls";
					$("#save_excell").on("click", function () {
						var uri = $("#activity_table").btechco_excelexport({
						containerid: "activity_table"
						, datatype: $datatype.Table
						, returnUri: true
						});
				$(this).attr("download", name).attr("href", uri).attr("target", "_blank");
			});
		</script>';
		echo $html;
	}
	
	
	function getJurusan() {
		$id_smk = $this->input->post("smk");
		$options = $this->rep_sis->getJurusan($id_smk);
	
		$html = '<label class="select">
						<select name="id_mapping_jur" style="width:195px;" class="chosen-select" id="id_mapping_jur" onchange="cekKelas('.$id_smk.',this.value);getRuang();">
							<option value="">--Semua Jurusan--</option>																
						'.$options.'
						</select> <i></i> 
					</label>';
		$html .='<script>
					$(function() {
						$(".chosen-select").chosen();
					})
				</script>';	
		echo $html;			
	}
	
	function cekKelas() {
		$id_jur = $this->input->post("id_jur");
		$id_smk = $this->input->post("id_smk");
		$options = $this->rep_sis->cekKelas($id_smk);
		$html='<label class="select">
									<select name="kelas" style="width:195px;" class="chosen-select"  onchange="getRuang(this.value,'.$id_jur.');" >
									<option value="">--Semua Kelas--</option>'.$options.'</select> <i></i> 
								</label>';
		$html .='<script>
					$(function() {
						$(".chosen-select").chosen();
					})
				</script>';	
								
		echo $html;			
	}
	
	function getRuang(){
		$kelas = $this->input->post("kelas");
		$id_mapping_jur = $this->input->post("id_mapping_jur");
		
		$options = $this->rep_sis->getRuang($kelas, $id_mapping_jur);
	
		$html = '<label class="select">
						<select name="ruang"  class="chosen-select" id="id_mapping_ruang">
							<option value="">--Semua Ruang Kelas--</option>																
						'.$options.'
						</select> <i></i> 
					</label>';
		$html .='<script>
					$(function() {
						$(".chosen-select").chosen();
					})
				</script>';	
				
		echo $html;			
	}
	
	function convert_bln($month){
		$curr_bulan = $month - 6;
		if($curr_bulan <= 0){
			$curr_bulan = $month + 6;
		}
		return $curr_bulan;
	}
}
