
<!-- MAIN CONTENT WRAPPER -->

	<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
		<link href="assets/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<link href="assets/css/main.css" rel="stylesheet" type="text/css">
		<link href="assets/css/my-custom-styles.css" rel="stylesheet" type="text/css">
<!-- main -->
<div class="col-lg-12">
	<ul class="breadcrumb">
		<li><i class="fa fa-home"></i><a href="/home">Home</a></li>
		<!--<li><a href="#">Forms</a></li>-->
		<li class="active">Designation</li>
	</ul>
</div>
<div class="content">
	<div class="main-content">
		<div class="row">
			
			<div class="col-md-4">
				<!-- ADVANCED VALIDATION -->
				<div class="widget">
					<div class="widget-header">
					<h3><i class="fa fa-check-circle"></i>Ward</h3></div>
					<div class="widget-content">
						<form id="frmmain" name="frmmain" data-parsley-validate novalidate>
							<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
						         
							<div class="alert  alert-info " >
								<ul><li class="fa fa-cog  fa-1x fa-fw"></li>Kindly enter Ward..</ul>
							</div>						
							<div class="alert alert-success print-success-msg" style="display:none">
								<ul></ul>
							</div>	
							<div class="alert alert-danger print-error-msg" style="display:none">
								<ul></ul>
							</div>
							
							<div class="form-group">
								<label for="text-input1">Ward*</label>
								<input type="text" name="ward" id="ward" class="form-control" >
								<input type="hidden" name="pk" id="pk" class="form-control" >
								<small class="text-danger" id="errusertype"></small>
							</div>
							<div class="form-group">
								<label>Note</label>
								<textarea class="form-control" name="note" id="note" rows="5" cols="30" ></textarea>
								<small class="text-danger" id="errdescription" ></small>
							</div>
							<div class="form-group">
								<label for="multiselect1">Status*</label>
								<br/>
                                <select name="status" id="status" class="form-control input-lg" required>
                                    <option value="Active">Active</option>
                                    <option value="Inactive">Inactive</option>
								</select>
								<small class="text-danger" id="errstatus"></small>
							</div>
							<br/>
							<button type="submit" id="submit" name="submit" class="btn btn-primary userType">Submit</button>
						</form>
					</div>
				</div>
				<!-- END ADVANCED VALIDATION -->
			</div>
			
			<div class="col-md-8">
				
				
					
				<!-- BASIC VALIDATION -->
				<div class="widget widget-table">
					<div class="widget-header">
						<h3><i class="fa fa-table"></i> View Ward</h3> 
					</div>
					<div class="widget-content">
						<table id="datatable-data-export" class="table table-sorting table-striped table-hover table-bordered datatable">
							<thead>
								<tr>
									<th>Ward</th>
									<th>Note</th>
									<th>Status</th>
									<th>Action</th>
								</tr>
							</thead>
							<tbody>
							<?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
							
								<tr>
						<td><?php echo e($value-> ward_name); ?></td>
						<td><?php echo e($value-> ward_note); ?></td>
						<td><?php echo e($value-> ward_status); ?></td>
							<td><button class= "btn btn-default" onclick="editname(<?php echo e($value->ward_id); ?>)" >  Edit </button>&nbsp;<button class= "btn btn-default" onclick="delrec(<?php echo e($value->ward_id); ?>)" > Delete</button></td>		
								</tr>
							<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
							</tbody>
						</table>
						
					</div>
				</div>
				<!-- END BASIC VALIDATION -->
			</div>
			
		</div>
	</div>
</div>
<!-- /main -->
<script src="assets/js/jquery/jquery-2.1.0.min.js"></script>
	<script src="assets/js/bootstrap/bootstrap.js"></script>
	<script src="assets/js/plugins/modernizr/modernizr.js"></script>    
	<script src="assets/js/plugins/bootstrap-tour/bootstrap-tour.custom.js"></script>
	<script src="assets/js/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script>
	<script src="assets/js/king-common.js"></script>
	<script src="assets/js/plugins/stat/jquery.easypiechart.min.js"></script>
	<script src="assets/js/plugins/raphael/raphael-2.1.0.min.js"></script>
	<script src="assets/js/plugins/stat/flot/jquery.flot.min.js"></script>
	<script src="assets/js/plugins/stat/flot/jquery.flot.resize.min.js"></script>
	<script src="assets/js/plugins/stat/flot/jquery.flot.time.min.js"></script>
	<script src="assets/js/plugins/stat/flot/jquery.flot.pie.min.js"></script>
	<script src="assets/js/plugins/stat/flot/jquery.flot.tooltip.min.js"></script>
	<script src="assets/js/plugins/jquery-sparkline/jquery.sparkline.min.js"></script>
	<script src="assets/js/plugins/datatable/jquery.dataTables.min.js"></script>
	<script src="assets/js/plugins/datatable/dataTables.bootstrap.js"></script>
	<script src="assets/js/plugins/jquery-mapael/jquery.mapael.js"></script>
	<script src="assets/js/plugins/raphael/maps/usa_states.js"></script>
	<script src="assets/js/king-chart-stat.js"></script>
	<script src="assets/js/king-table.js"></script>
	<script src="assets/js/king-components.js"></script>
    
	<script src="assets/js/plugins/bootstrap-multiselect/bootstrap-multiselect.js"></script>
	<script src="assets/js/plugins/parsley-validation/parsley.min.js"></script>  
<script type="application/javascript">


	
	$('.userType').click(function(e)
	{
	   e.preventDefault();
		$.ajax({
			url: 'wardinsert',
			type: 'POST',
			data:$('#frmmain').serialize(),
			success: function(data) 
			{
			   $('#sideMenu').load('viewward');	
			   	alert("Success");
				$("input[name='ward']").val('');	
				$("[name='note']").val('');
				$("[name='status']").val('Active');
			}
			
		});
	});
	/*i=0;
	
	$(document).on('submit', '#frmmain', function()
	{
		$(".alert-info").find("ul").html('<li class="fa fa-cog fa-spin fa-1x fa-fw"></li>Processing...');
		
		var _token = $("input[name='_token']").val();
		var usertype = $("input[name='usertype']").val();
		var description = $("#description").val();
		var status = $("#status").val();
		
		document.getElementById("errusertype").innerHTML = "";
		
		if(usertype == "")
		{
			document.getElementById("errusertype").innerHTML = "User type should not be empty...";
			$(".alert-info").find("ul").html('<li class="fa fa-cog fa-1x fa-fw"></li>Kindly check the error...');
		}
		else
		{
			if(i==0)
			{ 
				i++;
				//alert(i);
				$.ajax({
					url: "/utype",
					type:'POST',
					data: {_token:_token, usertype:usertype, description:description, status:status},
					success: function(data) {											
						if(data.status == 1)
						{
							printSuccessMsg(data.message);
							$('#sideMenu').load('usertype');
						}
						else
						{
							printErrorMsg(data.message)
						}
					}
				});					   
			}							
		}							
		
		function printErrorMsg (msg) {
			$(".alert-info").css('display','none');
			$(".print-success-msg").css('display','none');
			$(".print-error-msg").find("ul").html('');
			$(".print-error-msg").css('display','block');
			$(".print-error-msg").find("ul").append('<li class="fa fa-times-circle fa-1x fa-fw"></li>'+msg);
		}
		
		function printSuccessMsg (msg) {
			$(".alert-info").css('display','none');
			$(".print-error-msg").css('display','none');
			$(".print-success-msg").find("ul").html('');
			$(".print-success-msg").css('display','block');
			$(".print-success-msg").find("ul").append('<li class="fa fa-check  fa-1x fa-fw"></li>'+msg);
			//Code to redirect page
			//var url = "/dashboard";
			//$(location).attr('href',url);
		}
		return false;
	});*/
	function editname(id)
	{
		$.ajax({
			type: "GET",
			url:"/editward",
			dataType: "json",
			data: {
				'_token': $('input[name=_token]').val(),
				'id': id
			},
			success: function (data) {
				$.each(data,function(i,obj)
				{
					$('#pk').val(obj.ward_id);
					$('#ward').val(obj.ward_name);
					$('#note').val(obj.ward_note);
					$('#status').val(obj.ward_status);
					// $('#btnadd').val("UPDATE"); 
				});  
			}
		});
	}
	function delrec(id)
	{
		k = 0;
		if(confirm("Are u Sure U Want To Delete?")==1)
		{
			k++;
			$.ajax({
				type: "GET",
				url:"/delward",
				data:'&id='+id,
				success: function (sdata)
				{
					alert("Success");
					$('#sideMenu').load('viewward');	
				}
			});
		}
		
	}
	
</script>					  