<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12" align="justify">
            <h2 class="page-header">Hasil E-Voting</h2>
			<div class="col-lg-12">
				<p><h4>E-Voting Musyda PDPM Kabupaten Pekalongan</h4>
				<hr>
				<div class="row">

					<div class="col-lg-3" align="center">
						<h1><?php echo $jmlformatur; ?></h1>
						<div class='label label-primary'>Calon Formatur</div>
					</div>

					<!--<div class="col-lg-4" align="center">
						<h1><?php echo $sementara; ?></h1>
						<div class='label label-primary'>Pemilih Sementara</div>
					</div> -->
					<!--<div class="col-lg-3" align="center">
						<h1><?php echo $tetap; ?></h1>
						<div class='label label-primary'>Pemilih Tetap</div>
					</div>-->
					<div class="col-lg-3" align="center">
						<h1><?php echo $sah; ?></h1>
						<div class='label label-primary'>Suara Masuk</div>
					</div>
				<!--<div class="col-lg-3" align="center">
						<h1><?php echo $belumpilih; ?></h1>
						<div class='label label-primary'>Belum Memilih</div>
					</div>-->
					
					
				</div>
				
			</div>
</div>
           
           
           </div>
     <hr>
				<table id="examples" class="table table-striped responsive-utilities">
                <thead>
                    <tr class="headings">
						<th class="col-lg-1">No Urut Calon</th>
                        <th class="col-lg-4">Nama Calon Formatur</th>
                        <th class="col-lg-1">Jumlah Suara</th>
                        <th class="col-lg-5">Persentase</th>
						<th class="col-lg-2">Keterangan </th>
                    </tr>
                </thead>

                <tbody>
					
					
					<?php foreach($formatur->result_array() as $a) { ?>
					
						<?php
							$pi = 0;
						?>
					
							<?php foreach($hitung->result_array() as $p) { ?>
								<?php
									$pilih = $p['pilih'];
									$dd = explode(" ", $pilih);
									for($i=0;$i<count($dd);$i++)
									 { 
										if($dd[$i]==$a['id']) {
											$pi=$pi+1;
										}
									 } 
								?>
							<?php } ?>
						<?php
							$nama = $a['nama'];
							$hasilp[$nama] = $pi;	
						?>
					
					
				<?php }
						arsort($hasilp);
						$x=0;
						foreach($hasilp as $nama=>$x_value){
							//echo $nama;
							if($x<=8){ // samakan dengan Jumlah dipilih  dikurangi-1
								$hasilpa[$nama] = "<div class='label label-primary'>Masuk Formatur</div>";
							} else {
								$hasilpa[$nama] = "<div class='label label-danger'>Tidak Masuk Formatur</div>";
							}
							$x++;
						}
					
				?>

                   <?php foreach($formatur->result_array() as $f) { ?>
						<?php
							$pi = 0;
							$total = $hitung->num_rows();
						?>
						<tr class="even pointer">
							
							
							<?php foreach($hitung->result_array() as $p) { ?>
								<?php
									$pilih = $p['pilih'];
									$dd = explode(" ", $pilih);
									for($i=0;$i<count($dd);$i++)
									 { 
										if($dd[$i]==$f['id']) {
											$pi=$pi+1;
										}
									 } 
								?>
							
							<?php } 
								if($pi!=0){
									$persen = (100/$total)*$pi;
								} else {
									$persen = "0";
								}
							?>
							
							<td class=" "><strong><?php echo $f['id'];?> </strong>  </td>
							<td class=" "> <img style="width: 10%; height: 10%" align="left" class="circle"  src="<?php echo base_url(); ?>dist/img/<?php echo $f['foto'] ?>" alt="icon"  ><strong> &nbsp; &nbsp;&nbsp; <?php echo $f['nama']; ?>  </strong></td>
							<td class=" " align="center"><strong><?php echo $pi; ?></strong></td>
							
							<td class=" ">
								<div class="col-lg-12">
									<div class="progress progress-striped active" style="margin-top:0px; margin-bottom:0px;">
										<div class="progress-bar" style="width:<?php echo $persen; ?>%" ></div>
									</div>
									
								</div>
								<br/>
								<p style="margin-top:-30px; margin-bottom:0px; margin-left:15px"><small><?php echo $persen; ?> %</small></p>
							</td>
							<td><?php $nama = $f['nama'];
							echo $hasilpa[$nama]; ?></td>
						</tr>
					<?php } ?> 
                </tbody>
            </table>
				
				
								
				
			</div>
			
        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->
</div>
<!-- /#page-wrapper -->

<script src="<?php echo base_url(); ?>dist/js/jquery.dataTables.js"></script>
        
        <script>
        $(document).ready(function() {
            $('#examples').dataTable();
        } );

        </script>