

<div class="content-wrapper">
	<section class="content-header">
		<h1 style="font-family:roboto">
			<b><?php echo $this->lang->line('voter'); ?></b>
		</h1>
		<ol class="breadcrumb">
			<li style="color:#0C0"><a href="#"><i class="fa fa-home"></i> <?php echo $this->lang->line('home'); ?></a></li>
			<li style="color:#0C0"><a href="#"><?php echo $this->lang->line('project'); ?></a></li>
			<li class="active" style="color:#0C0"><?php echo $this->lang->line('project_list'); ?></li>
		</ol>
	</section>

	<div class="content project m-0-b">
		<div class="row m-0-b m-1-t p-0-y p-3-x p-xs-1-x">
			<div class="col-md-8">
				<h3>
					<p>
					<?php echo $this->lang->line('selDesc'); ?>
					<?php
					if($current) {
						?><br /><a href="<?php echo base_url(); ?>project/detail/<?php echo $current['ID']; ?>"><?php echo $current['title']; ?></a><?php
					} else {
						echo "-";
					}
					?>
					</p>
				</h3>
				<div class="helper helper-xl text-bold">
					<ul>
						<li><?php echo $this->lang->line('clickOSelect'); ?></li>
						<li><?php echo $this->lang->line('clickOnProject'); ?></li>
					</ul>
				</div>
			</div>
		
			<div class="col-md-4">
				<strong>Legend</strong>
				<div class="legend">
					<span class="project-info-item" data-toggle="tooltip" title="Voters">
						<span class="project-info-icon"><i class="fa fa-users"></i></span>
						<span class="project-info-sts"><?php echo $this->lang->line('numVoters'); ?></span>
					</span>
					<span class="project-info-item" data-toggle="tooltip" title="Paid?">
						<span class="project-info-icon"><i class="fa fa-dollar"></i></span>
						<span class="project-info-sts"><?php echo $this->lang->line('isPaid'); ?></span>
					</span>
					<span class="project-info-item" data-toggle="tooltip" title="Started?">
						<span class="project-info-icon"><i class="fa fa-rocket"></i></span>
						<span class="project-info-sts"><?php echo $this->lang->line('isStarted'); ?></span>
					</span>
					<span class="project-info-item" data-toggle="tooltip" title="Delete?">
						<span class="project-info-icon delete"><i class="fa fa-trash"></i></span>
						<span class="project-info-sts"><?php echo $this->lang->line('delProject'); ?></span>
					</span>
				</div>
			</div>
		</div>
		
		<div class="row m-5-b m-0-t p-0-y p-3-x p-xs-1-x project-list">
			<div class="section-title p-5-l p-5-r p-1-t p-0-b text-center">
				<h1 class="m-0-t font-weight-bold"><?php echo $this->lang->line('myProjects'); ?></h1>
				<p class="m-0-b"><?php echo $this->lang->line('myProjectList'); ?></p>
			</div>
			
			<div class="row m-1-b m-1-t p-0-y p-3-x p-xs-1-x text-center">
				<div class="m-1-y">
					<a href="<?php echo base_url(); ?>project/add" class="btn btn-primary"><i class="fa fa-plus"></i>&nbsp;<?php echo $this->lang->line('add'); ?></a>
					<a href="<?php echo base_url(); ?>dashboard" class="btn btn-danger"><i class="fa fa-backward"></i>&nbsp;<?php echo $this->lang->line('back'); ?></a>
				</div>
				<div class="helper"><?php echo $this->lang->line('addHelper'); ?></div>
			</div>
			
			<div class="row m-1-b m-1-t p-0-y p-3-x p-xs-1-x">
				<div class="col message <?php echo $respond['type'] ? strtolower($respond['type']) : NULL; ?> text-center" id="message">
				<?php echo ($respond['message']) ? $respond['message'] : ((strtolower($respond['type']) == 'success') ? 'Success' : NULL); ?>
				</div>
			</div>
			
		
			<?php
			if($projects) {
				foreach($projects as $project) {
					$stopped = ($project['stopped']) ? TRUE : FALSE;
					$started = (strtotime($project['startDT']) <= strtotime('now')) ? TRUE : FALSE;
					$ended = ($project['endDT']) ? ((strtotime($project['endDT']) <= strtotime('now')) ? TRUE : FALSE) : FALSE;
					?>
					<div class="project-item col-md-4 m-xs-1-b m-3-b <?php echo ($current['ID'] == $project['ID']) ? "current" : NULL; ?>">
						<button type="button" onclick="return selectProject(<?php echo $project['ID']; ?>,this);" class="project-select" data-toggle="tooltip" title="Select Project">
							<i class="fa fa-<?php echo ($current['ID'] == $project['ID']) ? "check" : "circle-o"; ?>"></i>
							<span>&nbsp;<?php echo ($current['ID'] == $project['ID']) ? $this->lang->line('selected') : $this->lang->line('select'); ?></span>
						</button>
						
						<?php
						if($started) {
							?>
							<button type="button" class="project-timeframe <?php echo ($ended || $stopped) ? $this->lang->line('end') : $this->lang->line('start'); ?>"
									data-toggle="tooltip" title="Project <?php echo ($ended || $stopped) ? $this->lang->line('end') : $this->lang->line('start'); ?>">
								<i class="fa fa-<?php echo ($ended || $stopped) ? "bell-slash-o" : "rocket"; ?>"></i>
								<span>&nbsp;Project <?php echo ($ended || $stopped) ? $this->lang->line('end') : $this->lang->line('start'); ?></span>
							</button>
							<?php
						}
						?>
						
						<div class="project-wrap">
							<div class="project-title">
								<a href="<?php echo base_url(); ?>project/detail/<?php echo $project['ID']; ?>">
									<?php echo $project['title']; ?>&nbsp;&nbsp;<i class="fa fa-sign-in"></i>
								</a>
							</div>
							<div class="project-info row p-0">
								<!-- VOTERS -->
								<span class="project-info-item col-xs-4 text-center" data-toggle="tooltip" title="Voters">
									<a class="project-info-icon" href="<?php echo base_url(); ?>voter"><i class="fa fa-users"></i></a>
									<span class="project-info-sts"><?php echo ($project['voters']); ?></span>
								</span>
								<!-- PAID -->
								<span class="project-info-item col-xs-4 text-center" data-toggle="tooltip" title="Paid?">
									<a class="project-info-icon" href="<?php echo base_url(); ?>checkout"><i class="fa fa-dollar"></i></a>
									<span class="project-info-sts"><?php echo ($project['paid']) ? "<i class=\"fa fa-check text-green\"></i>" : "<i class=\"fa fa-times text-red\"></i>"; ?></span>
								</span>
								<!-- DELETE -->
								<span class="project-info-item col-xs-4 text-center" data-toggle="tooltip" title="Delete?">
									<a class="project-info-icon delete <?php echo $project['voters'] ? "disabled" : ($started?"disabled":NULL); ?>"
											onclick="return deleteProject(this);"
											href="<?php echo base_url(); ?>project/delete/<?php echo $project['ID']; ?>">
										<i class="fa fa-trash"></i>
									</a>
								</span>
							</div>
						</div>
					</div>
					<?php
				}
			}
			?>
		</div>
	</div>
</div>
	
<!-- CONFIRMATION SELECT PROJECT MODAL -->		
<div class="modal fade" id="confirm_select_modal" role="dialog">
	<div class="modal-dialog modal-lg">			
		<div class="modal-content">
			<div class="modal-header" >
				<button type="button" class="modal-close" data-dismiss="modal"><span></span><span></span></button>
				<h3 class="modal-title text-center"><?php echo $this->lang->line('pickConfirm'); ?></h3>
			</div>
			
			<div class="modal-body">
				<input type="hidden" id="select_project_id" value="" />
				<h4 class="m-1-y text-center"><?php echo $this->lang->line('pickConfirmHelper1'); ?></h4>
				<h5 class="m-1-y text-center"><?php echo $this->lang->line('pickConfirmHelper2'); ?></h5>
				<div class="row">
					<div class="col-md-offset-4 col-md-4">
						<div class="flex-btn-group">
							<button class="btn btn-success" onclick="return confirmSelectProject(this);"><i class="fa fa-check"></i>&nbsp;<?php echo $this->lang->line('y'); ?></button>
							<button class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i>&nbsp;<?php echo $this->lang->line('n'); ?></button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
$(function() {
	
});

function deleteProject(me) {
	if(	$(me).hasClass('disabled') ) return false;
	return confirm('<?php echo $this->lang->line('delConfirm'); ?>');
}

function selectProject(p, me) {
	if(!Number(p)) return false;	
	closeLoader();
	
	if(	$(me).parent().hasClass('current') ) return false;
	
	$('#select_project_id').val(p);	
	$('#confirm_select_modal').modal('show');
}

function confirmSelectProject(me) {
	openLoader();
	$('#confirm_select_modal').modal('hide');
	
	var id = Number($('#select_project_id').val());	
	if(!id) return false;
	
	$('#select_project_id').val('');	
	window.location.href = '<?php echo base_url(); ?>project/select/'+id;
}

</script>




























