<?php $__env->startSection('styles'); ?>
	<link rel="stylesheet" href="<?php echo e(asset('/css/sweetalert.css')); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('banner'); ?>
	<?php echo $__env->make('sections.banner-sm', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('contents'); ?>
	<section id="standard-content" class="event-details">
		<div class="container">

			<p id="breadcrumb">
			    <a href="<?php echo e(url('/events')); ?>">Events</a>
			    <?php echo e($event->event_title); ?>

			</p>

			<div class="container-wrapper">

				<?php if( $errors->count() > 0 ): ?>
				     <div class="alert alert-danger">
				     	<p>The following errors have occurred:</p>

				      	<ul>
				        	<?php foreach( $errors->all() as $message ): ?>
				          		<li><?php echo e($message); ?></li>
				        	<?php endforeach; ?>
				      	</ul>
				     </div>
			    <?php endif; ?>
					    
				<?php echo Form::open(['id' => 'PayForm']); ?>

				<div class="col-md-4">
					<div class="event-contents well">
						<h1 class="amount">Total : &dollar; <span class="amount_val"><?php echo e($event->price); ?></span></h1>
						<h2><?php echo e($event->event_title); ?></h2>
						<ul class="detail-list">
							<li><i class="fa fa-map-marker"></i> <?php echo e($event->location); ?></li>
							<li><i class="fa fa-calendar"></i> <?php echo e(date("d-m-Y g:a", strtotime($event->event_date))); ?></li>
							<li><i class="fa fa-eye"></i> <?php echo e($event->views); ?></li>
							<li><i class="fa fa-heart"></i> <?php echo e($event->favs); ?></li>
						</ul>
					</div>

					
					<div class="well">
						<h3>Number of Tickets</h3>
						<div class="col-md-12">
							<div class="form-group">
								<label class="control-label">General Admission</label>
								<select class="form-control" name="general">
									<?php for($i=1; $i < 21; $i++): ?>
										<option value="<?php echo e($i); ?>"><?php echo e($i); ?></option>
									<?php endfor; ?>
								</select>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group">
								<label class="control-label">Student</label>
								<select class="form-control" name="general">
									<?php for($i=1; $i < 21; $i++): ?>
										<option value="<?php echo e($i); ?>"><?php echo e($i); ?></option>
									<?php endfor; ?>
								</select>
							</div>
						</div>
						<div class="col-md-12">
							<label>Family</label>
							<div class="clearfix"></div>
							<div class="col-md-6">
								<div class="form-group">
									<label class="control-label">Adult</label>
									<select class="form-control" name="adult">
										<?php for($i=1; $i < 21; $i++): ?>
											<option value="<?php echo e($i); ?>"><?php echo e($i); ?></option>
										<?php endfor; ?>
									</select>
								</div>
							</div>
							<div class="col-md-6">
								<div class="form-group">
									<label class="control-label">Child</label>
									<select class="form-control" name="child">
										<?php for($i=0; $i < 21; $i++): ?>
											<option value="<?php echo e($i); ?>"><?php echo e($i); ?></option>
										<?php endfor; ?>
									</select>
								</div>
							</div>
						</div>
						<div class="clearfix"></div>
					</div>
						
						
				</div>
				<div class="col-md-8">
					<div class="col-md-6">

						<?php if(!Auth::user()): ?>
							<div class="well text-center">
								<a href="<?php echo e(url('/auth/login')); ?>" class="btn btn-default">Login</a>
								<br/>or<br/>
								<span>Manually enter your details below</span>
							</div>
						<?php endif; ?>

							<div class="well">
								<h3 class="heading">Personal Details</h3>
								<div class="form-group">
									<label class="control-label">Firstname</label>
									<input name="firstname" type="text" class="form-control cinput" value="<?php if(Auth::user()): ?> <?php echo e(ucfirst(Auth::user()->firstname)); ?> <?php else: ?><?php echo e(session('firstname')); ?><?php endif; ?>">
								</div>
								<div class="form-group">
									<label class="control-label">Lastname</label>
									<input name="lastname" type="text" class="form-control cinput" value="<?php if(Auth::user()): ?> <?php echo e(ucfirst(Auth::user()->lastname)); ?> <?php else: ?><?php echo e(session('lastname')); ?><?php endif; ?>">
								</div>
								<div class="form-group">
									<label class="control-label">Phone</label>
									<input name="mobile" type="text" class="form-control" value="<?php if(Auth::user()): ?> <?php echo e(ucfirst(Auth::user()->phone)); ?> <?php else: ?><?php echo e(session('mobile')); ?><?php endif; ?>">
								</div>
								<div class="form-group">
									<label class="control-label">Email</label>
									<input name="email" type="text" class="form-control cinput" value="<?php if(Auth::user()): ?><?php echo e(ucfirst(Auth::user()->email)); ?> <?php else: ?><?php echo e(session('email')); ?><?php endif; ?>">
								</div>
								<div class="form-group">
									<label class="control-label">Address</label>
									<textarea class="form-control" name="address" rows="5"><?php if(Auth::user()): ?><?php echo Auth::user()->address; ?><?php else: ?><?php echo e(session('address')); ?><?php endif; ?></textarea>
								</div>
							</div>
					</div>
					<div class="col-md-6">
						<div class="well">
							<h3 class="heading">Payment Details</h3>
							<div class="form-group">
								<div class="card-lists">
									<ul class="cards">
										<li data-type="paypal"><img src="<?php echo e(asset('/images/paypal.png')); ?>"></li>
										<li data-type="mastercard"><img src="<?php echo e(asset('/images/mastercard.png')); ?>"></li>
										<li data-type="visa"><img src="<?php echo e(asset('/images/visa.png')); ?>"></li>
									</ul>
								</div>
							</div>
							<div id="card-details" <?php if(session('cardtype') == ''): ?> hidden <?php endif; ?>>
								<h3 class="heading">Card Details</h3>
								<div class="form-group">
									<label class="control-label">Name on Card</label>
									<input name="name_on_card" type="text" class="form-control nameoncard cinput" value="<?php echo e(session('nameoncard')); ?>">
								</div>
								<div class="form-group">
									<label class="control-label">Card Number</label>
									<input name="card_number" type="text" class="form-control cardnumber cinput" id="card_number" value="<?php echo e(session('cardnumber')); ?>">
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label">Expiry Date</label>
											<input name="expiry_date" type="text" class="form-control expirydate cinput" id="expiry_date" value="<?php echo e(session('expirydate')); ?>">
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label">CCV</label>
											<input name="ccv" type="text" class="form-control ccv cinput" id="ccv" value="<?php echo e(session('ccv')); ?>">
										</div>
									</div>
								</div>
								<div class="clearfix"></div>
							</div>
						</div>
						
						<div class="alert alert-danger error" hidden>
							<em>Select paymenet details above</em>
						</div>
						<button type="submit" class="btn btn-primary btn-block" id="proceedBtn">Proceed</button>
					</div>
					
				</div>
				
				<input name="card_type" value="<?php echo e(session('cardtype')); ?>" type="hidden">
				<input name="intent" value="book-an-event" type="hidden">
				<input name="eventid" value="<?php echo e($event->id); ?>" type="hidden">
				<input name="total" value="<?php echo e(money_format('%i', $event->price)); ?>" type="hidden">

				<?php echo Form::close(); ?>

				<div class="clearfix"></div>
			</div>
		</div>
	</section>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
	<script type="text/javascript" src="<?php echo e(asset('/js/sweetalert.min.js')); ?>"></script>
	<script type="text/javascript" src="<?php echo e(asset('/js/jquery.mask.js')); ?>"></script>

	<?php echo $__env->make('sweet::alert', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

	<script type="text/javascript">
		$(function(){
			var $card 		= $('.cards li'),
				$cardbox 	= $('#card-details'),
				$cardnumber = $('#card_number'),
				$expirydate = $('#expiry_date'),
				$ccv 		= $('#ccv'),
				$proceedbtn = $('#proceedBtn'),
				$cardtype 	= $('input[name=card_type]'),
				$empty 		= '',
				$errorbox 	= $('.error');

			// user chooses type of payment
			$card.click(function(){
				var t = $(this).data('type');

				if (t == 'paypal') {
					swal({ 
						title: "Paying via Paypal",   
						text: "You will be redirected to Paypal for the final payment.",   
						type: "warning",   
						showCancelButton: true,   
						confirmButtonColor: "#DD6B55",   
						confirmButtonText: "Yes, proceed",   
						closeOnConfirm: true 
					}, function(isConfirm){  
						if(isConfirm) {
							window.open("http://paypal.com");
						} else {
							$cardtype.val('');
						}
						
					});
				} else {
					$cardbox.show();
				}

				$cardtype.val(t);
				$errorbox.hide();
			});

			//masks
			$cardnumber.mask('0000-0000-0000-0000');
			$expirydate.mask('00/00');
			$ccv.mask('000');

			// user pressed proceed
			$proceedbtn.click(function(e){
				e.preventDefault();

				if($cardtype.val() == $empty) {
					$errorbox.show();
				} else {
					var $emptytotal = 0;

					$('.cinput').each(function(){
						var $entry = $(this).val();

						if($entry == $empty) {
							$emptytotal ++;
							$(this).parent('.form-group').addClass('has-error has-feedback');
						} else {
							$(this).parent('.form-group').removeClass('has-error');
						}
					});

					if ($emptytotal == 0) $('#PayForm').submit();
				}
			});

		});
	</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('masters.base', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>