<?php 
$q_instansi	= $this->db->query("SELECT * FROM identitas LIMIT 1")->row();
if ($jumlahpihaktemp != 0 ){ $tombol = '<a href="'.base_url().'hitung_panjar/mulai_hitung"><button type="button" class="btn btn-warning pull-right">Cetak</button></a>';}else { $tombol = 'Silahkan Tambah Pihak Lagi..!';}
$namasatker = $q_instansi->nama_satker;
?>
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>.:: <?php echo $q_instansi->nama_website; ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
	<style type="text/css">
	@font-face {
	  font-family: 'Cabin';
	  font-style: normal;
	  font-weight: 400;
	  src: local('Cabin Regular'), local('Cabin-Regular'), url(<?php echo base_url(); ?>asset/font/satu.woff) format('woff');
	}
	@font-face {
	  font-family: 'Cabin';
	  font-style: normal;
	  font-weight: 700;
	  src: local('Cabin Bold'), local('Cabin-Bold'), url(<?php echo base_url(); ?>asset/font/dua.woff) format('woff');
	}
	@font-face {
	  font-family: 'Lobster';
	  font-style: normal;
	  font-weight: 400;
	  src: local('Lobster'), url(<?php echo base_url(); ?>asset/font/tiga.woff) format('woff');
	}	
	
	</style>
    <link rel="stylesheet" href="<?php echo base_url(); ?>asset/css/bootstrap.css" media="screen">
   
    <script src="<?php echo base_url(); ?>asset/js/jquery.min.js"></script>
    <script src="<?php echo base_url(); ?>asset/js/bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>asset/js/bootswatch.js"></script>
    <script src="<?php echo base_url(); ?>asset/js/jquery.chained.js"></script>
	<!-- bootstrap autocomplet -->
		<script type="text/javascript" src="<?php echo base_url();?>asset/js/jquery.autocomplete.js"></script>
		<link href="<?php echo base_url();?>asset/js/jquery.autocomplete.css" rel="stylesheet" />
	<!-- batas bootstrap autocomplet -->
  <body style="">
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <span class="navbar-brand"><strong style="font-family: verdana; margin-left: 310px; text-align: center"><?php echo $q_instansi->nama_website; ?></strong></span>
          <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        
      </div>
    </div>
    <div class="container">
	
	<br><br>

	<div class="container-fluid" style="margin-top: 30px">
	<div class="col-lg-6">
			<div style="width: 400px; margin: 0 auto">
				<div class="row-fluid">
					<div style="width: 400px; margin: 0 auto">
						<div class="well well-sm">
							<img src="<?php echo base_url(); ?>upload/<?php echo $q_instansi->logo; ?>" class="thumbnail span3" style="display: inline; float: left; margin-right: 20px; width: 80px; height: 80px">
							<h3 style="margin: 5px 0 0.4em 0; font-size: 21px; color: #000; font-weight: bold"><?php echo $q_instansi->nama_website; ?></h3>
							<div style="color: #000; font-size: 13px" class="clearfix"><?php echo $q_instansi->alamat; ?></div>
						 </div>
					</div>
					
					<div class="well" style="width: 400px; margin: 20px auto; border: solid 1px #d9d9d9; padding: 30px 20px; border-radius: 8px">
						<legend><a href="<?php echo base_URL()?>dashboard" style="width: 350px; margin: 10px auto; border: solid 1px #d9d9d9; padding: 10px 10px; border-radius: 2px" class="btn btn-success btn-sm" title="Mulai Hitung Panjar"><i class="icon-edit icon-white"> </i> Dashboard /  Kembali</a></legend>
						<?php
					if ($namasatker == $this->config->item('csrf_lisensi'))
							{ echo $tombol;}
							 else
							 { 
						 	echo "<i style='color:blue;font-size:30px;font-family:calibri ;'>
								Kode Satker tidak ditemukan, hubungi sms/wa : 081245208017 </i> ";
								}
					?>
						<legend><marquee> Mulai Hitung Panjar ...!!!</marquee></legend>
						<legend><?php echo "<b>TOTAL BIAYA : Rp. ".number_format($totalbiaya, 0, ',', '.')."</legend>"; 
							$terbilang = terbilang($totalbiaya);
							echo "</b><i>Terbilang : ".$terbilang." rupiah.</i>";
												
						 
						 ?>
						 
<table border=2>
<tr>
<td align="center" bgcolor="#c7f7bf" width="3%" >No</td>
<td align="center" bgcolor="#c7f7bf" width="70%" >Komponen Biaya</td>
<td align="center" bgcolor="#c7f7bf" width="20%" >Jumlah</td>

</tr>

<?php

$warna ="#fcfdfd";
$warnabukanmaterai ="#f9f8f8";
if (empty($komponen)) {
		echo "<tr><td colspan='3' align='center' bgcolor='#f58484'>Data Tidak diTemukan</td></tr>";
	}else{
	$con = 1;
	foreach ($komponen as $row) {
		//$mahasiswa = $row->mahasiswa_id;
		$nama_komponen = $row->nama_komponen;
		$biaya_k = number_format($row->jumlah, 0, ',', '.');
		
	echo "<tr>";
			echo '<td bgcolor='.$warna.'>'.$con.'</td>';
			echo '<td bgcolor='.$warna.'> '.$nama_komponen.'</td>';
			echo '<td bgcolor='.$warna.'> Rp. '.$biaya_k.'</td>';
		echo "</tr>";
		    				$con++;
		    			}
	}



?>

</table>
<table border=2>
<tr>
<td align="center" bgcolor="#c7f7bf" width="3%" >No</td>
<td align="center" bgcolor="#c7f7bf" width="70%" >Komponen Biaya POS</td>
<td align="center" bgcolor="#c7f7bf" width="20%" >Jumlah</td>

</tr>

<?php
$warna ="#fcfdfd";
$warnabukanmaterai ="#f9f8f8";
if (empty($databiayapos)) {
		echo "<tr><td colspan='3' align='center' bgcolor='#f58484'>Data N i h i l</td></tr>";
	}else{
	$con = 1;
	foreach ($databiayapos as $rowpos) {
		$sebutan_pihakpos = $rowpos->pemohon_termohon;
		$jumlah_radiuspos = $rowpos->jumlah_panggilan;
		$biaya_radiuspos = number_format($rowpos->biaya, 0, ',', '.');
		$namapos = $rowpos->nama_pihak;
		$jumlahpos = number_format($rowpos->jumlah_panggilan_x_biaya, 0, ',', '.');
	echo "<tr>";
			echo '<td  bgcolor='.$warna.'>'.$con.'</td>';
			echo '<td  bgcolor='.$warna.'> Biaya Kirim POS '.$sebutan_pihakpos.' [ <b>'.$namapos.'</b> ] '.$jumlah_radiuspos.' x '.$biaya_radiuspos.'</td>';
			echo '<td  bgcolor='.$warna.'> Rp. '.$jumlahpos.'</td>';
		echo "</tr>";
		    				$con++;
		    			}
	}



?>

</table>
<table border=2>
<tr>
<td align="center" bgcolor="#c7f7bf" width="3%" >No</td>
<td align="center" bgcolor="#c7f7bf" width="70%" >Detail Radius Biaya</td>
<td align="center" bgcolor="#c7f7bf" width="20%" >Jumlah</td>

</tr>

<?php

$warna ="#fcfdfd";
$warnabukanmaterai ="#f9f8f8";
if (empty($databiaya)) {
		echo "<tr><td colspan='3' align='center' bgcolor='#f58484'>Data Tidak diTemukan</td></tr>";
	}else{
	$con = 1;
	foreach ($databiaya as $row) {
		//$mahasiswa = $row->mahasiswa_id;
		$sebutan_pihak = $row->pemohon_termohon;
		$jumlah_radius = $row->jumlah_panggilan;
		$biaya_radius = number_format($row->biaya, 0, ',', '.');
		$nama = $row->nama_pihak;
		$jumlah = number_format($row->jumlah_panggilan_x_biaya, 0, ',', '.');
		
	echo "<tr>";
			echo '<td  bgcolor='.$warna.'>'.$con.'</td>';
			echo '<td  bgcolor='.$warna.'> Radius '.$sebutan_pihak.' [ <b>'.$nama.'</b> ] '.$jumlah_radius.' x '.$biaya_radius.'</td>';
			echo '<td  bgcolor='.$warna.'> Rp. '.$jumlah.'</td>';
		echo "</tr>";
		    				$con++;
		    			}
	}

foreach ($countdatabiayapos as $rowbayarpos) {
	$totalkomponenpos = $rowbayarpos->totalpos;
}
foreach ($countkomponen as $rowbayar) {
	$totalkomponen = $rowbayar->total;
}
foreach ($countdatabiaya as $rowradius) {
	$totalradius = $rowradius->totalradius;
}
$jumlah_all = $totalkomponen + $totalradius + $totalkomponenpos;
$total = number_format($jumlah_all, 0, ',', '.');
$terbilang = terbilang($jumlah_all);

?>

</table>

					</div><!--/span-->
					
				</div><!--/row-->
			</div>
	</div>
	<div class="col-lg-4">
			<div style="width: 600px; margin: 0 auto">
				<div class="row-fluid">
					<div style="width: 600px; margin: 0 auto">
						<div class="well well-sm">
							<form action="<?php echo base_URL(); ?>hitung_panjar/simpan_pihak2" method="post">
							<legend><?php echo "Jenis Perkara ".$jenisperkara;?></legend>
							<?php echo $this->session->flashdata("k");?>
								<legend>Ketik Nama Lengkap Anda ?</legend>
								<?php 
								 echo "<div class='col-md-12'>
                  <table class='table table-condensed table-bordered'>
                  <tbody>
				    <input type='hidden' class='autocompletekomdanas' id='id' name='id'/>
					<input type='hidden' name='idkewenangan' value='$id_kewenangan'>
					
                    <tr><th scope='row'>Nama Lengkap </th>     <td><input type='text' class='form-control' name='nama_pihak' style='width: 100%' required></td></tr>
					<tr><th scope='row'>Jenis Pihak</th>           <td><input type='radio' name='e' value='1' checked> Pemohon/Penggugat &nbsp; <input type='radio' name='e' value='2' > Termohon/Tergugat</td></tr>
				  </table>";
					?>
								
				<legend>Ketik Kelurahan/Desa Anda Tinggal ?</legend>
				<?php 
				 echo "<div class='col-md-12'>
                  <table class='table table-condensed table-bordered'>
                  <tbody>
				    
                    <tr><th scope='row'>Kelurahan</th>     <td><input type='kelurahan' class='autocompletekomdanas nama form-control' id='autocomplete' name='kel'></td></tr>
                    <tr><th scope='row'>Kecamatan</th>    <td><input type='text' class='autocompletekomdanas form-control'  id='kec' name='kec'></td></tr>
					<tr><th scope='row'>Kab /Kota</th>    <td><input type='text' class='autocompletekomdanas form-control'  id='kabkota' name='kabkota'></td></tr>
					<tr><th scope='row'>Satuan Kerja</th>    <td><input type='text' class='autocompletekomdanas form-control'  id='satker_name' name='satker_name'></td></tr>
					<tr><th scope='row'>Radius</th>    <td><input type='text' class='autocompletekomdanas form-control'  id='nilai' name='nilai'></td></tr>
					<tr><th scope='row'></th> <td> <button type='submit' name='submit' class='btn btn-info'>Tambah Pihak</button>
						
					</td></tr>
					 </table>";
					?>
					</form>
						 </div>
					</div>
					
					
				</div><!--/row-->
			</div>
	</div>     

    </div><!--/.fluid-container-->
	
	
	  
    </div>
  
</body></html>
<script type="text/javascript">
	var site = "<?php echo site_url();?>";
        $(function(){
            $('.autocompletekelurahan').autocomplete({
                // serviceUrl berisi URL ke controller/fungsi yang menangani request kita
                serviceUrl: site+'/autocomplete/search',
                // fungsi ini akan dijalankan ketika user memilih salah satu hasil request
                onSelect: function (suggestion) {
                    $('#id_radius').val(''+suggestion.id_radius); 
                    $('#id_kec').val(''+suggestion.id_kec); 
					$('#id_kel').val(''+suggestion.id_kel);
					$('#nama_kec').val(''+suggestion.nama_kec);
					
                }
            });
        });
		$(function(){
            $('.autocompletekomdanas').autocomplete({
                // serviceUrl berisi URL ke controller/fungsi yang menangani request kita
                serviceUrl: site+'/autocomplete/json_komdanas',
                // fungsi ini akan dijalankan ketika user memilih salah satu hasil request
                onSelect: function (suggestion) {
                    $('#id').val(''+suggestion.id); 
                    $('#prop_name').val(''+suggestion.prop_name); 
					$('#kec').val(''+suggestion.kec);
					$('#satker_name').val(''+suggestion.satker_name);
					$('#kabkota').val(''+suggestion.kabkota);
					$('#nilai').val(''+suggestion.nilai);
					
                }
            });
        });
	</script>
