@extends('frontend.layouts.app')

@section('title', app_name() . ' | ' . __('labels.frontend.auth.register_box_title'))

@section('content')
<form method="post" action="{{url('quotation-request')}}" onsubmit="return validateSp()">
	{{csrf_field()}}
	<div class="wrapper">
		<div class="header header-top">
			<a href="{{url('/')}}" class="header-menu"><i class="fa fa-arrow-left"></i></a>
			<h2 class="page-title">Service Provider</h2>
			 
		</div><!-- header -->
		<div class="main-content">
		<div class="container-fluid">
			<div class="category-block">
				<?php //echo "<pre>"; print_r($serviceslist); echo "</pre>";?>
				@if($serviceslist)
					@foreach($serviceslist as $val)
					<div class="service-list">				
					<div class="service-list-pic">
						<!-- <input type="hidden" name="spemails[]" value="{{$val->email}}"> -->
						<input type="hidden" name="cities" id="cities" value="{{$val->city_id ? $val->city_id : 0}}">
						<input type="hidden" name="services" id="services" value="{{$val->service_id ? $val->service_id : 0}}">
						<input type="checkbox" name="splist[]" class="custom-control-input splist-check" id="customCheck{{$val->id}}" value="{{$val->user_id ? $val->user_id : $val->id}}" >				
						<label class="service-pic">

							@if($val->avatar_location)
							<img src="{{url('storage/'.$val->avatar_location)}}" alt="">
							@else
							<img src="{{url('img/no-image.jpg')}}" alt="">
							@endif
						</label>
					</div>
					<div class="service-list-details">
						<a href="{{url('/service-provider-single/'.urlencode( base64_encode( $val->user_id ? $val->user_id : $val->id ) ).'/'.($val->city_id ? $val->city_id : 0).'/'.( $val->service_id ? $val->service_id : $val->service_id )  )}}"><h3>{{ $val->first_name . " " . $val->last_name }}</h3></a>
						<p class="rating-block">{{number_format($val->rating, 1)}} <i class="fa fa-star"></i></p>
					</div>
				</div><!-- service-list -->
					@endforeach
				@endif
			</div><!-- category-block -->
		</div><!-- container-fluid -->
		</div><!-- main-content -->
		<div class="footer">
			@if(Auth::user())
				<input type="submit" class="block-btn" id="quote-request" value="Request For Quotation">
			@else
				<a href="{{url('/login')}}" class="block-btn" >Request For Quotation</a>
			@endif
			
			<!-- <a href="javascript:void(0)" class="block-btn" id="quote-request">Request For Quotation</a> -->
		</div><!-- footer -->
	</div><!-- wrapper -->
</form>
<script type="text/javascript">
	var user_type = 0;
	<?php if(auth()->user()) { ?>
		user_type = "{{auth()->user()->user_type}}";
	<?php } ?>
	function validateSp(){
		if(!$('.splist-check').is(':checked')){
		 	alert("Please select at least one Service Provider.");
		 	return false;
	   	}
	   	if(user_type != 2) {
	   		alert("Please login as customer to submit quotation.");
		 	return false;
	   	}
	}	
</script>
@endsection
