<?php
$abso = str_replace("\\","/", FCPATH);
$virt = str_replace("\\","/", base_url());	
?>	
<div class="result-wrapper p-1" id="result_wrapper">
	<h3 class="result-title m-1-b"><?php echo $lines['vote_result']; ?></h3>
	<div class="row"><div class="col-xs-12 text-red" id="message"></div></div>
	<?php
	if($result) {
		foreach($result as $positionID=>$position) {
			$limit = $position['limit'];
			echo "<h3 class=\"m-1-t\">".$position['name']."</h3>";
			?>
			<div class="table-responsive">
				<table class="table">
					<thead>
						<tr>
							<th class="col-xs-1 text-center">#</th>
							<th class="col-xs-8 text-left"><?php echo $lines['line_candidate']; ?></th>
							<th class="col-xs-2 text-center"><?php echo $lines['vote_total']; ?></th>
							<th class="col-xs-1 text-center">&nbsp;</th>
						</tr>
					</thead>
					
					<tbody>
					<?php
					if($position['candidates']) {
						$c = 0;
						foreach($position['candidates'] as $candidateID=>$candidate) {		
							$image = $virt."dist/img/_sys/user.png";
							if($candidate['picture'] && file_exists($abso."img/candidate/".$candidate['picture'])) $image = $virt."img/candidate/".$candidate['picture'];
							?>
							<tr>
								<td class="col-xs-1 text-center"><?php echo ($c+1); ?></td>
								<td class="col-xs-8 text-left voted-item">
									<div class="voted-img"><img src="<?php echo $image; ?>" class="img-responsive-reverse" /></div>
									<div class="voted-name"><?php echo $candidate['name']; ?></div>
								</td>
								<td class="col-xs-2 text-center">
									<span><?php echo $candidate['total']; ?></span>
								</td>
								<td class="col-xs-1 text-center">
									<?php
									if ($c < $limit) {
										?><i class="fa fa-star text-green"></i><?php
									} else {
										if($candidate['total'] == $position['candidates'][$c-1]['total']) {
											?><i class="fa fa-star text-green"></i><?php
										}
									}
									?>
								</td>
							</tr>
							<?php
							$c++;
						}
					}
					?>
					</tbody>
				</table>
			</div>
			<?php
		}
	}
	?>
</div>












