	<footer class="main-footer">
		<div class="pull-right hidden-xs">
			<b>Copyright@<?php echo date('Y') ?></b>. Badan Bank Tanah
		</div>
		Aplikasi Informasi dan Status Perolehan Tanah <strong>[INSTAPRO]</strong> 
	</footer>
</div>

<script src="<?php echo base_url(); ?>assets/bower_components/jquery/dist/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/jquery-ui/jquery-ui.min.js"></script>
<script>
	$.widget.bridge('uibutton', $.ui.button);
</script>
<script src="<?php echo base_url(); ?>assets/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/raphael/raphael.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/morris.js/morris.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<script src="<?php echo base_url(); ?>assets/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="<?php echo base_url(); ?>assets/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/moment/min/moment.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url(); ?>assets/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/fastclick/lib/fastclick.js"></script>

<script src="<?php echo base_url(); ?>assets/bower_components/datatables.net/js/jquery.dataTables.js"></script>
<script src="<?php echo base_url(); ?>assets/bower_components/datatables.net-bs/js/dataTables.bootstrap.js"></script>

<script src="<?php echo base_url(); ?>assets/dist/js/adminlte.min.js"></script>
<script src="<?php echo base_url(); ?>assets/dist/js/pages/dashboard.js"></script>
<script src="<?php echo base_url(); ?>assets/dist/js/demo.js"></script>
<script src="<?php echo base_url() ?>assets/bower_components/ckeditor/ckeditor.js"></script>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<!-- js untuk select2  -->
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>

<script type="text/javascript">
	<?php
	$x="";
	$y="";
	$data = $this->db->query("SELECT * from project")->result();
	foreach ($data as $d) {
		$id = $d->project_id;
		?>



		var ctx = document.getElementById("grafik_<?php  echo $d->project_id?>").getContext('2d');
		var myChart = new Chart(ctx, {
			type: 'bar',
			data: {
				labels:[
				<?php 
				$idKat = "";				
				$dat = $this->db->query("SELECT * FROM transaksi where transaksi_project='$id' group by transaksi_kategori")->result();
				foreach ($dat as $dd) {
					
					echo $dd->transaksi_kategori.",";
					$idKat = $dd->transaksi_kategori;
				}
				?>
				],
				//labels: ["10-20", "21-30", "31-60"],
				datasets: [
				{
					label: "RENCANA",
					backgroundColor: "pink",
					borderColor: "red",
					borderWidth: 1,
					data: [
					<?php								
					$dax = $this->db->query("SELECT * FROM transaksi where transaksi_project='$id' group by transaksi_kategori")->result();
					foreach($dax as $dx){
						$id_kat= $dx->transaksi_kategori;
						$rencana = $this->db->query("SELECT sum(transaksi_rencana_jumlah) as total from transaksi where transaksi_project='$id' and transaksi_kategori='$id_kat'")->result();
						foreach ($rencana as $r) {	
							$x = $r->total;						
							echo $r->total.",";
						}
					}					
					?>
					]
				},
				{
					label: "REALISASI",
					backgroundColor: "lightblue",
					borderColor: "blue",
					borderWidth: 1,
					data: [
					<?php									
					$dax = $this->db->query("SELECT * FROM realisasi where realisasi_project='$id' group by realisasi_kategori")->result();
					foreach($dax as $dx){
						$id_kat= $dx->realisasi_kategori;
						$realisasi = $this->db->query("SELECT sum(realisasi_jumlah_harga) as total from realisasi where realisasi_project='$id' and realisasi_kategori='$id_kat'")->result();
						foreach ($realisasi as $rel) {	
							$y = $rel->total;						
							echo $rel->total.",";
						}
					}					
					?>
					]

					//data: [245000]
				},
				{
					label: "SISA",
					backgroundColor: "lightgreen",
					borderColor: "green",
					borderWidth: 1,
					data: [
					<?php 
					$dax = $this->db->query("SELECT * FROM transaksi where transaksi_project='$id' group by transaksi_kategori")->result();
					foreach($dax as $dx){
						$id_kat= $dx->transaksi_kategori;
						$rencana = $this->db->query("SELECT sum(transaksi_rencana_jumlah) as total from transaksi where transaksi_project='$id' and transaksi_kategori='$id_kat'")->row();						
						$realisasi= $this->db->query("SELECT sum(realisasi_jumlah_harga) as total from realisasi where realisasi_project='$id' and realisasi_kategori='$id_kat'")->row();

						$x = $rencana->total;
						$y = $realisasi->total;
						$hasil = abs($x-$y);
						echo $hasil.",";
						
					}

					?>
					]
				},
				],

			}, 
		});

		// code...

		<?php
	}
	?>
	



</script>

<script type="text/javascript">
	<?php
	$x="";
	$y="";
	$data = $this->db->query("SELECT * from project")->result();
	foreach ($data as $d) {
		$id = $d->project_id;
		?>

		var ctx = document.getElementById("grafik_<?php  echo $d->project_id?>").getContext('2d');
		var myChart = new Chart(ctx, {
			type: 'bar',
			data: {
				labels:[
				<?php 
				$idKat = "";				
				$dat = $this->db->query("SELECT * FROM transaksi where transaksi_project='$id' group by transaksi_kategori")->result();
				foreach ($dat as $dd) {
					
					echo $dd->transaksi_kategori.",";
					$idKat = $dd->transaksi_kategori;
				}
				?>
				],
				//labels: ["10-20", "21-30", "31-60"],
				datasets: [
				{
					label: "RENCANA",
					backgroundColor: "pink",
					borderColor: "red",
					borderWidth: 1,
					data: [
					<?php								
					$dax = $this->db->query("SELECT * FROM transaksi where transaksi_project='$id' group by transaksi_kategori")->result();
					foreach($dax as $dx){
						$id_kat= $dx->transaksi_kategori;
						$rencana = $this->db->query("SELECT sum(transaksi_rencana_jumlah) as total from transaksi where transaksi_project='$id' and transaksi_kategori='$id_kat'")->result();
						foreach ($rencana as $r) {	
							$x = $r->total;						
							echo $r->total.",";
						}
					}					
					?>
					]
				}
				],

			}, 
		});

		// code...





		<?php
	}
	?>



</script>


<script type="text/javascript">
	var ctx = document.getElementById("grafik_index").getContext('2d');
	var myChart = new Chart(ctx, {
		type: 'pie',
		data: {
			labels:[
			"RENCANA", "REALISASI", "SISA"
			],				
			datasets: [{
				label: 'HARGA SATUAN RP',
				data: [
				<?php
				$rencana = $this->db->query("select sum(transaksi_rencana_harga) as rencana_satuan from transaksi")->row();
				$realisasi = $this->db->query("select sum(realisasi_harga_satuan) as realisasi_harga from realisasi")->row();
				$x = $rencana->rencana_satuan;
				$y = $realisasi->realisasi_harga;
				$hasil = abs($x-$y);

				echo $rencana->rencana_satuan.",".$realisasi->realisasi_harga.",".$hasil;
				 ?>
				

				],
				backgroundColor: [
				'rgba(255, 99, 132, 0.2)',
				'rgba(54, 162, 235, 0.2)',
				'rgba(255, 206, 86, 0.2)'
				],
				borderColor: [
				'rgba(255, 99, 132, 1)',
				'rgba(54, 162, 235, 1)',
				'rgba(255, 206, 86, 1)'
				],
				borderWidth: 1
			}]




		}, 
	});


	var ctx = document.getElementById("grafik_").getContext('2d');
	var myChart = new Chart(ctx, {
		type: 'pie',
		data: {
			labels:[
			"RENCANA", "REALISASI", "SISA"
			],				
			datasets: [{
				label: 'JUMLAH HARGA RP',
				data: [
				<?php
				$rencanax = $this->db->query("select sum(transaksi_rencana_jumlah) as rencana_jumlah from transaksi")->row();
				$realisasiy = $this->db->query("select sum(realisasi_jumlah_harga) as realisasi_jumlah from realisasi")->row();
				$xx = $rencanax->rencana_jumlah;
				$yy = $realisasiy->realisasi_jumlah;
				$hasilxy = abs($xx-$yy);

				echo $rencanax->rencana_jumlah.",".$realisasiy->realisasi_jumlah.",".$hasilxy;
				 ?>
				

				],
				backgroundColor: [
				'rgba(255, 99, 132, 0.2)',
				'rgba(54, 162, 235, 0.2)',
				'rgba(255, 206, 86, 0.2)'
				],
				borderColor: [
				'rgba(255, 99, 132, 1)',
				'rgba(54, 162, 235, 1)',
				'rgba(255, 206, 86, 1)'
				],
				borderWidth: 1
			}]




		}, 
	});


</script>


<script type="text/javascript">
	$(document).ready(function(){

		$('#provinsi').change(function(){ 
			var id=$(this).val();
			$.ajax({

				type: 'POST',
				url:'<?php echo base_url('master/get_kota');?>',
				data:'id='+id,
				success: function(response) { 
					$('#kota').html(response); 
				}				
			});
			return false;
		}); 

	});
</script>

<script>
	function changeKota(idPerolehan) {
		var provEle = 'provinsi'+idPerolehan;
		var kotaEle = 'kota'+idPerolehan;
		var idProvinsi = document.getElementById(provEle).value;

		// alert(idPerolehan);
		// alert(idProvinsi);
		
		$.ajax({

			type: 'POST',
			url:'<?php echo base_url('master/get_kota');?>',
			data:'id='+idProvinsi,
			success: function(response) { 
				$('#kota'+idPerolehan).html(response); 
				//document.getElementById(kotaEle).html(response);
			}				
		});
		$.ajax({

			type: 'POST',
			url:'<?php echo base_url('master/reset_selection');?>',
			data:'id='+idProvinsi,
			success: function(response) { 
				$('#kecamatan'+idPerolehan).html(response);
				$('#kelurahan'+idPerolehan).html(response); 
				//document.getElementById(kotaEle).html(response);
			}				
		});
		return false;
	}
</script>

<script>
	function changeKecamatan(idPerolehan) {
		var kotaEle = 'kota'+idPerolehan;
		var kecEle = 'kecamatan'+idPerolehan;
		var idKota = document.getElementById(kotaEle).value;

		// alert(idPerolehan);
		// alert(idKota);
		
		$.ajax({

			type: 'POST',
			url:'<?php echo base_url('master/get_kecamatan');?>',
			data:'id='+idKota,
			success: function(response) { 
				$('#kecamatan'+idPerolehan).html(response); 
				//document.getElementById(kotaEle).html(response);
			}				
		});
		$.ajax({

			type: 'POST',
			url:'<?php echo base_url('master/reset_selection');?>',
			data:'id='+idKota,
			success: function(response) { 
				$('#kelurahan'+idPerolehan).html(response); 
				//document.getElementById(kotaEle).html(response);
			}				
		});
		return false;
	}
</script>

<script>
	function changeKelurahan(idPerolehan) {
		var kecEle = 'kecamatan'+idPerolehan;
		var kelEle = 'kelurahan'+idPerolehan;
		var idKec = document.getElementById(kecEle).value;

		// alert(idPerolehan);
		// alert(idProvinsi);
		
		$.ajax({

			type: 'POST',
			url:'<?php echo base_url('master/get_kelurahan');?>',
			data:'id='+idKec,
			success: function(response) { 
				$('#kelurahan'+idPerolehan).html(response); 
				//document.getElementById(kotaEle).html(response);
			}				
		});
		return false;
	}
</script>

<script>
	function changeKegiatan(idPerolehan) {
		var statEle = 'status_perolehan'+idPerolehan;
		var kegEle = 'kegiatan_perolehan'+idPerolehan;
		var idStatus = document.getElementById(statEle).value;

		// alert(idPerolehan);
		// alert(idStatus);
		
		$.ajax({

			type: 'POST',
			url:'<?php echo base_url('master/get_kegiatan_perolehan');?>',
			data:'id='+idStatus,
			success: function(response) { 
				$('#kegiatan_perolehan'+idPerolehan).html(response); 
				//document.getElementById(kotaEle).html(response);
			}				
		});
		return false;
	}
</script>

<script>
	function changeKegiatanProgres(idProgres) {
		var statEle = 'status_perolehan_progres'+idProgres;
		var kegEle = 'kegiatan_perolehan_progres'+idProgres;
		var idStatus = document.getElementById(statEle).value;

		// alert(idPerolehan);
		// alert(idStatus);
		
		$.ajax({

			type: 'POST',
			url:'<?php echo base_url('master/get_kegiatan_perolehan');?>',
			data:'id='+idStatus,
			success: function(response) { 
				$('#kegiatan_perolehan_progres'+idProgres).html(response); 
				//document.getElementById(kotaEle).html(response);
			}				
		});
		return false;
	}
</script>

<script>
	//show hide logo menu
	$(document).ready( function () {
		var x = document.getElementById("main_logo");
		var y = document.getElementById("second_logo");
		var z = document.getElementById("user_img");
		x.style.display = "block";
		y.style.display = "none";
		z.style.display = "block";

		$("#hamburger_button").click(function(){
			if (y.style.display === "none") {
				y.style.display = "block";
				x.style.display = "none";
				z.style.display = "none";
			} else {
				y.style.display = "none";
				x.style.display = "block";
				z.style.display = "block";
			}
		});
	} );
</script>

<script>
	//show hide tgl_akhir input field
	$(document).ready( function () {
		<?php
			$perolehan_l = $this->db->query("SELECT * FROM perolehan")->result();

			foreach($perolehan_l as $perolehan_r){
				echo 
				'
				 var tgla'.$perolehan_r->perolehan_id.' = document.getElementById("tgl_akhir'.$perolehan_r->perolehan_id.'");
				 tgla'.$perolehan_r->perolehan_id.'.style.display = "none";
				';
			}
		?>
	});

	function changeKondisi(idPerolehan) {
		var kondisi = 'kondisi'+idPerolehan;
		var valKond = document.getElementById(kondisi).value;

		// alert(idPerolehan);
		// alert(valKond);
			
		if (valKond == 'selesai') {
			document.getElementById("tgl_akhir"+idPerolehan).style.display = "block";
			$("#tgl_akhir"+idPerolehan).attr('required', '');
		}else{
			document.getElementById("tgl_akhir"+idPerolehan).style.display = "none";
		}	
	}
</script>

<script>
	$(function () {
		CKEDITOR.replace('editor')
	});

	$(document).ready( function () {
		$('#table-datatable').DataTable();
		//$('#perolehan-datatable').DataTable();
	});
</script>

<script>
	$(document).ready( function () {
		$('#perolehan-datatable').DataTable({
			"searching": false,
			"info": false,
			"bLengthChange": false,
			"sDom": '<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"text-center"ip>>>'
		});
		$('#provinsi-datatable').DataTable({
			"searching": false,
			"info": false,
			"bLengthChange": false,
			"sDom": '<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"text-center"ip>>>'
		});
		$('#kota-datatable').DataTable({
			"searching": false,
			"info": false,
			"bLengthChange": false,
			"sDom": '<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"text-center"ip>>>'
		});
		$('#progres-datatable').DataTable({
			"searching": false,
			"info": false,
			"bLengthChange": false,
			"sDom": '<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"text-center"ip>>>'
		});
	});
</script>

<!-- <script>
    $(document).ready(function () {

      //Get a reference to the new datatable
      var table = $('#perolehan-datatable').DataTable();

      //Take the category filter drop down and append it to the datatables_filter div. 
      //You can use this same idea to move the filter anywhere withing the datatable that you want.
      $("#perolehan-datatable_filter.dataTables_filter").append($("#provinsiFilter"));
      
      //Get the column index for the Category column to be used in the method below ($.fn.dataTable.ext.search.push)
      //This tells datatables what column to filter on when a user selects a value from the dropdown.
      //It's important that the text used here (Category) is the same for used in the header of the column to filter
      var provinsiIndex = 0;
      $("#perolehan-datatable th").each(function (i) {
        if ($($(this)).html() == "Provinsi") {
			provinsiIndex = i; return false;
        }
      });

      //Use the built in datatables API to filter the existing rows by the Category column
      $.fn.dataTable.ext.search.push(
        function (settings, data, dataIndex) {
          var selectedItem = $('#provinsiFilter').val()
          var provinsi = data[provinsiIndex];
          if (selectedItem === "" || provinsi.includes(selectedItem)) {
            return true;
          }
          return false;
        }
      );

      //Set the change event for the Category Filter dropdown to redraw the datatable each time
      //a user selects a new filter.
      $("#provinsiFilter").change(function (e) {
        table.draw();
      });

      table.draw();
    });
  </script> -->

  	<script>
		$("#provinsi0").select2();
		$("#kota0").select2();
		$("#kecamatan0").select2();
		$("#kelurahan0").select2();
		$("#dasar_perolehan").select2();
		$("#status_perolehan").select2();
	</script>

	<?php
		$perolehan_list = $this->db->query("SELECT * FROM perolehan")->result();

		foreach($perolehan_list as $perolehan_row){
			echo 
			'<script>
				$("#provinsi'.$perolehan_row->perolehan_id.'").select2();
				$("#kota'.$perolehan_row->perolehan_id.'").select2();
				$("#kecamatan'.$perolehan_row->perolehan_id.'").select2();
				$("#kelurahan'.$perolehan_row->perolehan_id.'").select2();
				$("#dasar_perolehan'.$perolehan_row->perolehan_id.'").select2();
				$("#status_perolehan'.$perolehan_row->perolehan_id.'").select2();
				$("#kegiatan_perolehan'.$perolehan_row->perolehan_id.'").select2();
				$("#upd_progres'.$perolehan_row->perolehan_id.'").select2();
			</script>';
		}

		$progres_list = $this->db->query("SELECT * FROM perolehan_progres")->result();

		foreach($progres_list as $progres_row){
			echo 
			'<script>
				$("#status_perolehan_progres'.$progres_row->progres_id.'").select2();
				$("#kegiatan_perolehan_progres'.$progres_row->progres_id.'").select2();
			</script>';
		}
	?>

	<!-- Tab progres perolehan -->
	<script>
		function openCity(evt, cityName) {
			var i, tabcontent, tablinks;
			tabcontent = document.getElementsByClassName("tabcontent");
			for (i = 0; i < tabcontent.length; i++) {
				tabcontent[i].style.display = "none";
			}
			tablinks = document.getElementsByClassName("tablinks");
			for (i = 0; i < tablinks.length; i++) {
				tablinks[i].className = tablinks[i].className.replace(" active", "");
			}
			document.getElementById(cityName).style.display = "block";
			evt.currentTarget.className += " active";
		}

		// Get the element with id="defaultOpen" and click on it
		document.getElementById("defaultOpen").click();
	</script>

	<script>
		//RKAT PIE CHART
		var rkat = document.getElementById("pie_rkat").getContext('2d');
		var myRkat = new Chart(rkat, {
			type: 'pie',
			data: {
				labels:[
				"RKAT", "NON RKAT"
				],				
				datasets: [{
					label: 'PEROLEHAN',
					data: [
					<?php
					$rkat = $this->db->query("SELECT COUNT(perolehan_id) as rkat FROM perolehan WHERE is_rkat = true")->row()->rkat;
					$non_rkat = $this->db->query("SELECT COUNT(perolehan_id) as rkat FROM perolehan WHERE is_rkat = false")->row()->rkat;

					echo $rkat.",".$non_rkat;
					?>
					

					],
					backgroundColor: [
					//'rgba(255, 99, 132, 0.2)',
					'rgba(54, 162, 235, 0.2)',
					'rgba(255, 206, 86, 0.2)'
					],
					borderColor: [
					//'rgba(255, 99, 132, 1)',
					'rgba(54, 162, 235, 1)',
					'rgba(255, 206, 86, 1)'
					],
					borderWidth: 1
				}]




			}, 
		});
	</script>

	<script>
		//DASAR PEROLEHAN CHART
		var dasar = document.getElementById("bar_dasar").getContext('2d');
		var myDasar = new Chart(dasar, {
			type: 'bar',
			data: {
				labels:[
							<?php $data_dasar = $this->db->query("SELECT * FROM master_dasar_perolehan ORDER BY dasar_perolehan_desc")->result();
								  foreach ($data_dasar as $dl) {
																echo '"'.$dl->dasar_perolehan_desc.'",';
															   }
							?>
						],
				//labels: ["Bekas Hak", "Bekas Kawasan Hutan","Pelepasan Hak","Perubahan Tata Ruang","Tanah Negara Bebas","Tanah Terindikasi Terlantar","Tanah Terlantar"],
				datasets: [
				{
					label: "PEROLEHAN",
					backgroundColor: "pink",
					borderColor: "pink",
					borderWidth: 1,
					data: [//1,2,3,4,5,6,7
					<?php				
						foreach ($data_dasar as $di){
							$isi = $this->db->query("SELECT COUNT(perolehan_id) as isi FROM perolehan WHERE perolehan_dasar = '$di->dasar_perolehan_desc'")->row()->isi;
							echo $isi.",";
						}		
					?>
					]
				}
				],

			}, 
		});
	</script>

</body>
</html>
