<?php
$abso = str_replace("\\","/", FCPATH);
$virt = str_replace("\\","/", base_url());
?>
<link rel="stylesheet" href="<?php echo base_url(); ?>dist/css/theme/common.css"/>
<link rel="stylesheet" href="<?php echo base_url(); ?>dist/css/theme/extension.css"/>
<link rel="stylesheet" href="<?php echo base_url(); ?>dist/css/theme/hover.css"/>
<link rel="stylesheet" href="<?php echo base_url(); ?>dist/css/theme/animate.css"/>
<link rel="stylesheet" href="<?php echo base_url(); ?>dist/css/theme/admin/dashboard.css"/>

<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('projectList'); ?></li>
			</ol>
	</section>
		
	<div class="content registration m-0-b">
		<div class="row section-title p-5-x p-1-y text-center">
			<div class="col">
				<h1 class="m-0-t font-weight-bold"><?php echo $this->lang->line('detail'); ?></h1>
				<p class="m-0-b"><?php echo $this->lang->line('new'); ?></p>
			</div>
		</div>
		
		<div class="row m-5-b m-2-t p-1-x">
			<div class="col-md-6">
				<form class="form-horizontal registration-form" method="post" enctype="multipart/form-data"
							action="<?php echo base_url(); ?>project/save" id="project_form">
					<input type="hidden" name="ID" id="ID" value="0" />
				
					<div class="box box-flat m-1-b">							
						<div class="box-header p-1-l p-1-r">
							<div class="flex-btn-group">
								<button type="submit" class="btn btn-block btn-success"><i class="fa fa-check"></i>&nbsp;<?php echo $this->lang->line('save'); ?></button>
								<a href="<?php echo base_url(); ?>project" class="btn btn-danger"><i class="fa fa-backward"></i>&nbsp;<?php echo $this->lang->line('back'); ?></a>
							</div>
						</div>
						
						<div class="box-body">
							<!-- MESSAGE -->
							<div class="row">
								<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>
							
							<!-- HELPER -->
							<div class="row m-2-t m-1-b p-2-x">
								<div class="col">
									<div class="helper">
										<ul>
											<li><?php echo $this->lang->line('required'); ?></li>
										</ul>
									</div>
								</div>
							</div>
							
							<!-- TITLE -->
							<div class="form-group">
								<label class="col-xs-12 required registration-form-label"><?php echo $this->lang->line('title'); ?></label>
								<div class="col-xs-12">
									<input type="text" class="form-control validate[required] registration-form-input" name="title" id="title" value="" />
								</div>
							</div>				
							
							<!-- START AND END DATE -->
							<div class="row p-0">
								<div class="col-md-6">
									<div class="form-group">
										<label class="col-xs-12 required registration-form-label"><?php echo $this->lang->line('startDT'); ?></label>
										<div class="col-xs-12">
											<input type="text" class="form-control validate[required] datepick registration-form-input" name="startDT" id="startDT" value="" style="position: relative;" />
											<div class="helper">
												<ul>
													<li><?php echo $this->lang->line('startDTHelper'); ?>.</li>
													<li><?php echo $this->lang->line('required2'); ?></li>
												</ul>
											</div>
										</div>
									</div>
								</div>
								<div class="col-md-6">
									<div class="form-group">
										<label class="col-xs-12 registration-form-label"><?php echo $this->lang->line('endDT'); ?></label>
										<div class="col-xs-12">											
											<input type="text" class="form-control datepick registration-form-input" name="endDT" id="endDT" value="" />											
											<div class="helper">
												<ul>
													<li><?php echo $this->lang->line('endDTHelper1'); ?></li>
													<li><?php echo $this->lang->line('startDTHelper2'); ?></li>
												</ul>
											</div>
										</div>
									</div>
								</div>
							</div>
							
							<!-- VENUE -->
							<div class="form-group">
								<label class="col-xs-12 registration-form-label"><?php echo $this->lang->line('venue'); ?></label>
								<div class="col-xs-12">
									<textarea class="form-control registration-form-input" rows="5" name="venue" id="venue"></textarea>
									
								</div>
							</div>
							
							<!-- BANNER IMAGE -->
							<div class="form-group">
								<label class="col-xs-12 registration-form-label"><?php echo $this->lang->line('banner'); ?></label>
								<div class="col-xs-12">
									<?php	$image = $virt."dist/img/_sys/banner.png"; ?>
									<div class="uploader">
										<input type="file" name="banner" accept="image/*" />
										<input type="hidden" name="resetBanner" value="0" />
										<img src="<?php echo $image; ?>" class="img-responsive" />
									</div>
									
									<div class="helper">
										<ul>
											<li><?php echo $this->lang->line('imgHelper'); ?></li>
											<li><?php echo $this->lang->line('imgOptSize'); ?></li>
											<li><a href="javascript:void(0);" onclick="return clearBannerImage(this);"><?php echo $this->lang->line('bannerReset'); ?></a></li>
										</ul>
									</div>
								</div>
							</div>		
							
							<!-- BACKGROUND COLOR -->
							<div class="form-group">
								<label class="col-xs-12 registration-form-label"><?php echo $this->lang->line('bgColor'); ?></label>
								<div class="col-xs-12">
									<input type="text" name="color" id="color" value="" />
									<input type="hidden" name="resetColor" value="0" />
									<div class="helper">
										<ul>
											<li><?php echo $this->lang->line('bgColorHelper'); ?></li>
											<li><a href="javascript:void(0);" onclick="return clearColor(this);"><?php echo $this->lang->line('bgColorReset'); ?></a></li>
										</ul>
									</div>
								</div>
							</div>
							
							<!-- LANGUAGE -->
							<div class="form-group">
								<label class="col-xs-12 registration-form-label"><?php echo $this->lang->line('lang'); ?></label>
								<div class="col-xs-12">									
									<div class="helper">
										<ul>
											<li><?php echo $this->lang->line('langHelper1'); ?></li>
											<li><?php echo $this->lang->line('langHelper2'); ?></li>
											<li><?php echo $this->lang->line('langHelper3'); ?></li>
										</ul>
									</div>
									
									<?php
									$languages = array('EN'=>'English','MS'=>'Bahasa Malaysia');
									foreach($languages as $code=>$name) {
										?>
										<div class="row p-0 m-0">
											<div class="col-md-4"><?php echo $name; ?> (<?php echo $code; ?>)</div>
											<div class="col-md-8">
												<div class="switch">
													<label>
														<span class="hidden-xs"></span>
														<input type="checkbox" name="language[<?php echo $code; ?>]" value="1" />
														<span class="lever"></span>
														<span class="hidden-xs"></span>
													</label>
												</div>
											</div>
										</div>
										<?php
									}
									?>
								</div>
							</div>
						
							<!-- SETTING -->
							<div class="form-group">
								<label class="col-xs-12 registration-form-label"><?php echo $this->lang->line('setting'); ?></label>
								<div class="col-xs-12">									
									<div class="helper">
										<ul>
											<li><?php echo $this->lang->line('settingHelper'); ?></li>
										</ul>
									</div>
									
									<div class="row p-0 m-0">
										<div class="col-md-4"><?php echo $this->lang->line('showRes'); ?></div>
										<div class="col-md-8">
											<div class="switch">
												<label>
													<span class="hidden-xs"><?php echo $this->lang->line('y'); ?></span>
													<input type="checkbox" name="showResultToVoter" value="1" />
													<span class="lever"></span>
													<span class="hidden-xs"><?php echo $this->lang->line('n'); ?></span>
												</label>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						
						<div class="box-footer p-1-l p-1-r">
							<div class="flex-btn-group">
								<button type="submit" class="btn btn-block btn-success"><i class="fa fa-check"></i>&nbsp;<?php echo $this->lang->line('save'); ?></button>
								<a href="<?php echo base_url(); ?>project" class="btn btn-danger"><i class="fa fa-backward"></i>&nbsp;<?php echo $this->lang->line('back'); ?></a>
							</div>
						</div>
					</div>		
				</form>
			</div>
			
			<div class="col-md-6">
			<?php $this->load->view('project/guide',NULL); ?>
			</div>
		</div>
	</div>
	
</div>

<script>
$(function() {
	$('form#project_form').off('submit').on('submit',function() {
		if ($(this).validationEngine('validate')) {
			var proceed = true;
			
			var title = $.trim(	$('#title').val()	);
			if(title == "") { proceed =  false; $('#title').validationEngine('showPrompt', 'Please enter project title', 'load','bottomRight',1); }
			if(!proceed) return false;
			
			var startDT = $.trim(	$('#startDT').val()	);
			if(startDT == "") { proceed =  false; $('#startDT').validationEngine('showPrompt', 'Please enter project start date', 'load','bottomRight',1); }
			if(!proceed) return false;
			
			openLoader();
			return true;
		} else {
			return false;
		}
	});
	
	$('.uploader input[type="file"]').off('change').on('change', function() {
		var $img = $(this).siblings('img').eq(0);
		var input = this;
		
		if (input.files && input.files[0]) {
			$img.attr('src', '');
			var reader = new FileReader();			
			reader.onload = function (e) {
				$img.attr('src', e.target.result);
			}			
			reader.readAsDataURL(input.files[0]);
		}	
		$(this).siblings('input[type="hidden"]').val('0');
	});
	
	$('.datepick').datetimepicker({ format: 'DD-MM-YYYY hh:mm a' });
	$("#color").spectrum({ preferredFormat: "hex", color: "#d4d8dc" });
});

function clearBannerImage(me) {
	var $u = $(me).parents('.form-group').eq(0).find('.uploader').eq(0);	
	var $i = $u.find('img').eq(0);
	var def = '<?php echo base_url(); ?>dist/img/_sys/banner.png';
	
	if(	$.trim(	$i.attr('src')	) == def ) return;
	
	if(confirm('Are you sure to reset the project banner image?')) {
		$i.attr('src',def);
		$i.siblings('input[type="hidden"]').val('1');
	}
}

function clearColor() {
	if(confirm('Are you sure to reset the project background color?')) {
		$("#color").spectrum("set", '#d4d8dc');
	}
}

</script>




























