@extends('admin.layout.master')

@section('content')

<div class="app-content  my-3 my-md-5">
	<div class="side-app">
		<div class="page-header">
			<h4 class="page-title">Circle Management Lists</h4>
			<ol class="breadcrumb">
				<li class="breadcrumb-item"><a href="{{route('admin.userList')}}">Circle Management</a></li>
				<li class="breadcrumb-item active" aria-current="page">Circle Management Lists</li>
			</ol>

		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="card">
					@if(Session::has('success'))

						<div class="alert alert-primary">
							<p>{{ Session::get('success') }}</p>
						</div>

					@endif

					@if(Session::has('errors'))

						<div class="alert alert-danger">
							<p>{{ Session::get('errors') }}</p>
						</div>

					@endif
					
					<div class="card-header">
						<div class="col-xl-10 col-lg-10 col-md-10">
							<h3 class="card-title">Circle Management List</h3>
						</div>
						<div class="col-xl-2 col-lg-2 col-md-2">
							<a href="{{route('circle.circleAdd')}}"><button type='button' class="btn btn-primary">Add New Circle</button></a>
						</div>
					</div>


					<div class="card-body">
					  <div class="table-responsive">
						<table id="tables" class="table card-table table-vcenter text-nowrap">
							<thead>
								<tr>
									<th style="display: none;">#</th>
									<th>Circle <br>Code</th>
									<th>Target <br>Achive</th>
									<th>Round <br>Set</th>
									<th>Periodecaly <br>Of Round</th>
									<th>Engaged <br>Users</th>
									<th>No Of <br>Round</th>
									<th>Current <br>Round</th>
									<th>Start <br>Date</th>
									<th>Status</th>
									<th></th>
								</tr>
							</thead>
							<tbody>
							
							@foreach($circle as $key=>$val)
								<tr>
									<td style="display: none;">{{$key+1}}</td>
									<td style="text-align: center;"><a href="{{route('circle.circle_detail', base64_encode($val->id))}}">{{$val->circle_code}}</a></td>
									<td style="text-align: center;">{{$val->target_achive}}</td>
									<td style="text-align: center;">{{$val->round_set}}</td>
									<td style="text-align: center;">{{$val->p_round}}</td>
									<td style="text-align: center;">
										@foreach($val->getUsers as $key=>$value)
											<a href="{{route('circle.circle_of_user_details', base64_encode($value->mobile_number))}}">{{ucfirst($value->username)}}</a>
											<br>
										@endforeach
									</td>
									<td style="text-align: center;">{{$val->estimate_round}}</td>
									<td style="text-align: center;">@if($val->completed_round == $val->estimate_round){{$val->estimate_round}} @else{{($val->completed_round + 1)}}@endif</td>
									<td style="text-align: center;">{{$val->start_date}}</td>
									<td style="text-align: center;">
										
											@if($val->status == 0)
												<p style="color: #FFA500">Waiting</p>
											@elseif($val->status == 1)
												<p style="color: #008000">On-Going</p>
											@elseif($val->status == 2)
												<p style="color: #0000FF">Block</p>
											@elseif($val->status == 3)
												<p style="color: #FF0000">Suspend</p>
											@elseif($val->status == 4)
												<p style="color: #732626">Rejected</p>
											@elseif($val->status == 6)
												<p style="color: #732626">Settled</p>
											@else
												<p style="color: #464646">Completed</p>
											@endif
									</td>	
									<td style="text-align: center;">
										<!-- <a class="btn btn-primary btn-sm text-white" data-toggle="tooltip" data-original-title="Details" href="{{route('circle.circle_detail', base64_encode($val->id))}}"><i class="fa fa-eye"></i></a> -->
										@if($val->usercount == 0)
											@if($val->status==0 || $val->status==1 && $val->estimate_round!=$val->completed_round)
												<a class="icon" href="javascript:void(0)"></a>
												<a href="{{route('circle.user_blockrequest', base64_encode($val->id))}}" data-toggle="tooltip" data-original-title="For Block" class="btn btn-warning btn-sm text-white" onclick="return confirm('Are You Sure To Block This Circle?')"><i class="fa fa-lock"></i></a>
											@endif
											
											@if($val->estimate_round!=$val->completed_round && $val->status != 3)
												<a class="icon" href="javascript:void(0)"></a>
												<a href="{{route('circle.user_request', base64_encode($val->id))}}" data-toggle="tooltip" data-original-title="For Suspend" class="btn btn-secondary btn-sm text-white" onclick="return confirm('Are You Sure To Suspend This Circle?')"><i class="fa fa-ban"></i></a>
											@endif

											<a class="btn btn-dark btn-sm text-white" data-toggle="tooltip" data-original-title="Withdraw Details" href="{{route('circle.circle_withdraw_detail', base64_encode($val->id))}}"><i class="fa fa-money"></i></a>
										@else

											<a class="btn btn-danger btn-sm text-white" data-toggle="tooltip" data-original-title="Rejection Details" href="{{route('circle.circle_reject_detail', base64_encode($val->id))}}"><i class="fa fa-info"></i></a>
										@endif
										
									</td>
								</tr>
							@endforeach							
							</tbody>
						</table>
						
					  </div>
					</div>
					
				</div>
			</div>
		</div>
	</div>
</div>

@endsection
@section('scripts')
<script type="text/javascript">
	$(document).ready(function() {
    		$('#tables').DataTable();
	});	
</script>
@endsection
