<?php $__env->startSection('content'); ?>

	<div class="row">
    	<div class="col-lg-12">
    		<h1 class="page-header">Events</h1>
    	</div>
    </div>
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
						<div class="panel-heading">
                            Add Event
                        </div>

				<div class="panel-body">
					<?php if(session('status')): ?>
					<div class="alert alert-success">
						<?php echo e(session('status')); ?>

					</div>
					<?php endif; ?>
					<?php if(count($errors) > 0): ?>
						<div class="alert alert-danger">
							<strong>Whoops!</strong> There were some problems with your input.<br><br>
							<ul>
								<?php foreach($errors->all() as $error): ?>
									<li><?php echo e($error); ?></li>
								<?php endforeach; ?>
							</ul>
						</div>
					<?php endif; ?>

					<form class="form-horizontal" role="form" method="POST" action="<?php echo e(url('admin/event/add')); ?>">
						<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">

						<div class="form-group">
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('main')">
								<select class="form-control" id="main" name="main" onchange="checkCat(1)">
									<option value=""></option>
									<?php foreach($mains as $main): ?>
										<option value="<?php echo e($main->id); ?>" 
										<?php if(old('main') == $main->id): ?> 
										<?php echo e('selected'); ?> 
										<?php endif; ?>
										><?php echo e($main->name); ?></option>
									<?php endforeach; ?>
										<option value="31" 
										<?php if(old('main') == 31): ?> 
										<?php echo e('selected'); ?> 
										<?php endif; ?>
										>Internal</option>
										<option value="43" 
										<?php if(old('main') == 43): ?> 
										<?php echo e('selected'); ?> 
										<?php endif; ?>
										>Hidden</option>
								</select>
								<span id="main-label" 
									class="label-text"
								>Category &nbsp;<i id="secondary_plus" class="fa fa-plus" onclick="showSecondary()" 
								style="
								<?php if(old('secondary')): ?>
									display:none;
								<?php endif; ?>
								cursor: pointer;"
								></i></span>
							</div>
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('sub')" id="sub_container">
								<select class="form-control" id="sub" name="sub">
									<option value=""></option>
									<?php foreach(\App\Event_Category::where('type', '=', 'sub')->orderBy('name', 'asc')->get() as $category): ?>
									<option value="<?php echo e($category->id); ?>"
									<?php if(old('sub') == $category->id): ?> 
									<?php echo e('selected'); ?> 
									<?php endif; ?>
									><?php echo e($category->name); ?></option>
									<?php endforeach; ?>
								</select>
								<span id="sub-label" 

								class="label-text"

								>Sub-Category</span>
							</div>
						</div>
						<div class="form-group" id="secondary_container"
						<?php if(!old('secondary')): ?>
						style="display:none;"
						<?php endif; ?>
						>
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('secondary')">
								<select class="form-control" id="secondary" name="secondary">
									<option value=""></option>
									<?php foreach($mains as $main): ?>
										<option value="<?php echo e($main->id); ?>" 
										<?php if(old('secondary') == $main->id): ?> 
										<?php echo e('selected'); ?> 
										<?php endif; ?>
										><?php echo e($main->name); ?></option>
									<?php endforeach; ?>
								</select>
								<span id="secondary-label" 
									class="label-text"
								>Secondary</span>
							</div>
							<div class="col-sm-12 col-md-6 moreMargin">
							
							</div>
						</div>
						<div class="form-group" id="schools" style="display: none;">
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('school1')">
								<select class="form-control" id="school1" name="school1">
									<option value=""></option>
									<?php foreach(\App\Event_Category::where('type', '=', 'school')->orderBy('name', 'asc')->get() as $category): ?>
									<option value="<?php echo e($category->id); ?>"
									<?php if(old('school1') == $category->id): ?> 
									<?php echo e('selected'); ?> 
									<?php endif; ?>
									><?php echo e($category->name); ?></option>
									<?php endforeach; ?>
								</select>
								<span id="school1-label" 
	
								class="label-text"

								>School 1</span>
							</div>
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('school2')">
								<select class="form-control" id="school2" name="school2">
									<option value=""></option>
									<?php foreach(\App\Event_Category::where('type', '=', 'school')->orderBy('name', 'asc')->get() as $category): ?>
									<option value="<?php echo e($category->id); ?>"
									<?php if(old('school2') == $category->id): ?> 
									<?php echo e('selected'); ?> 
									<?php endif; ?>
									><?php echo e($category->name); ?></option>
									<?php endforeach; ?>
								</select>
								<span id="school2-label" 

								class="label-text"

								>School 2</span>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('title')">
								<input type="text" class="form-control" id="title" name="title" value="<?php echo e(old('title')); ?>" title="Title">
								<span id="title-label" class="label-text">Title</span>	
							</div>
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('description')">
								<textarea class="form-control" id="description" name="description" class="form-control" rows="2" placeholder="Description"><?php echo e(old('description')); ?></textarea>
								<?php if(old('description')): ?>
									<span id="description-labelx" class="hasValue">Description</span>
								<?php endif; ?>
							</div>
						</div>
						<div class="form-group" id="show_container" style="display: none;">
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('show')">
								<select class="form-control" id="show" name="show">
									<option value=""></option>
									<?php foreach(\App\Event_Category::where('type', '=', 'show')->orderBy('name', 'asc')->get() as $category): ?>
									<option value="<?php echo e($category->id); ?>"
									<?php if(old('show') == $category->id): ?> 
									<?php echo e('selected'); ?> 
									<?php endif; ?>
									><?php echo e($category->name); ?></option>
									<?php endforeach; ?>
								</select>
								<span id="show-label" 

								class="label-text"

								>Show</span>
							</div>
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('episode')">
								<input type="text" class="form-control" id="episode" name="episode" value="<?php echo e(old('episode')); ?>" title="Episode">
								<span id="episode-label" class="label-text">Episode</span>	
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12 col-md-3 moreMargin" onclick="inputFocus('event_date')" id="dateContainer">
								<input type="text" class="form-control date start" id="event_date" name="event_date" value="<?php echo e(old('event_date')); ?>" title="Event Date">
								<span id="event_date-label" class="label-text">Event Date</span>	
							</div>
							<div class="col-sm-12 col-md-3 moreMargin" onclick="inputFocus('stream_time')" id="streamT">
								<input type="text" class="form-control time start" id="stream_time" name="stream_time" value="<?php echo e(old('stream_time')); ?>" title="Stream Time">
								<span id="stream_time-label" class="label-text">Stream Time</span>	
							</div>
							<div id="eventT">
								<div class="col-sm-12 col-md-3 moreMargin" onclick="inputFocus('event_time')">
									<input type="text" class="form-control time start" id="event_time" name="event_time" value="<?php echo e(old('event_time')); ?>" title="Event Time" onchange="updateEndLabel()">
									<span id="event_time-label" class="label-text">Event Time</span>	
								</div>
								<div class="col-sm-12 col-md-3 moreMargin" onclick="inputFocus('end_time')">
									<input type="text" class="form-control time end" id="end_time" name="end_time" value="<?php echo e(old('end_time')); ?>" title="End Time">
									<span id="end_time-label" class="label-text">End Time</span>	
								</div>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('stream_name')">
								<input type="text" class="form-control" id="stream_name" name="stream_name" value="<?php echo e(old('stream_name')); ?>" title="Stream Name" onchange="updateURL()">
								<span id="stream_name-label" class="label-text">Stream Name</span>
							</div>
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('stream_url')">
								<input type="text" class="form-control" id="stream_url" name="stream_url" value="<?php echo e(old('stream_url')); ?>" title="Stream URL" onclick="this.setSelectionRange(0, this.value.length)">
								<span id="stream_url-label" class="label-text">Stream URL</span>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('banner')">
								<input type="text" class="form-control" id="banner" name="banner" value="<?php echo e(old('banner')); ?>" title="Graphic">
								<span id="banner-label" class="label-text">Banner Graphic</span>	
							</div>
							<div class="col-sm-12 col-md-6 moreMargin" onclick="inputFocus('file')">
								<input type="text" class="form-control" id="file" name="file" value="<?php echo e(old('file')); ?>" title="Filename">
								<span id="file-label" class="label-text">Filename</span>	
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12 col-md-3 moreMargin">
								<input type="checkbox" name="display_date" value="1" 
								<?php if(old('display_date')): ?>
								<?php echo e('checked'); ?> 
								<?php endif; ?>
								> &nbsp;Display Date
							</div>
							<div class="col-sm-12 col-md-3 moreMargin">
								<input type="checkbox" name="live_tv" value="1" 
								<?php if(old('live_tv')): ?> 
								<?php echo e('checked'); ?> 
								<?php endif; ?>
								> &nbsp;Live TV
							</div>

							<div class="col-sm-12 col-md-3 moreMargin">							
								<input type="checkbox" name="status" value="1" 
								<?php if(old('status')): ?> 
								<?php echo e('checked'); ?> 
								<?php endif; ?>
								> &nbsp;Active
							</div>
							<div class="col-sm-12 col-md-3 moreMargin">
								<input type="submit" class="btn btn-primary" style="float: right;" value="Save">
							</div>

						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('extras'); ?>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.2/css/bootstrap-datepicker3.min.css">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.min.css">
	    	<style>
			input:focus+.label-text, input:not([value=""])+.label-text, select+.label-text
			    		{
			    font-weight: normal;
			    padding: 0;
			    padding-left: 20px;
			    -webkit-transform: translateY(-2rem) scale(.7);
			    transform: translateY(-2rem) scale(.7);
			}
			input+.label-text, select+.label-text, .hasValue{
			    font-size: 1.5rem;
			    font-weight: 400;
			    position: absolute;
			    top: 0;
			    left: 0;
			    display: block;
	
			    padding-left: 20px;
			    padding-top: 5px;
			    padding-bottom: 5px;
			    opacity: .8;
			    transition: all .3s ease-out,opacity 150ms ease .3s;
			    -webkit-transform: translateY(0) scale(1);
			    transform: translateY(0) scale(1);
			    -webkit-transform-origin: left top;
			    transform-origin: left top;
			}
			span {
			    font-size: 1rem;
			    font-weight: 600;
			    display: block;
			    padding-top: .25rem;
			    padding-bottom: .25rem;
			    margin-left: 1rem;
			    color: #317aba;
			}
			.hasValue
			{
			    font-weight: normal;
			    padding: 0;
			    padding-left: 20px;
			    -webkit-transform: translateY(-2rem) scale(.7);
			    transform: translateY(-2rem) scale(.7);
			}
			
	
			@media (max-width: 959px)
			{
				.moreMargin {
				    margin-top: 1.5em;
				}
			}
	
			@media (min-width: 960px)
			{
				.moreMargin {
				    margin-top: 1em;
				}
			}
		
		</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('bottom'); ?>
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/datepair.js/0.4.14/jquery.datepair.min.js"></script>
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.2/js/bootstrap-datepicker.min.js"></script>
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.min.js"></script>
    	<script>
    		$('.form-control').each(function() {
    		   var elem = $(this);

    		   // Save current value of element
    		   elem.data('oldVal', elem.val());

    		   // Look for changes in the value
    		   elem.bind("propertychange change click keyup input paste", function(event){
    		      // If value has changed...
    		      if (elem.data('oldVal') != elem.val()) {
    		       // Updated stored value
    		       elem.data('oldVal', elem.val());
    		       var elem2 = $('#'+elem.attr('id')+"-label");
    		       elem2.addClass('hasValue');
    		       elem2.removeClass('label-text');
    		       if(elem.val() == "")
    		       {
    			       
    		    	   elem2.addClass('label-text');
    			       elem2.removeClass('hasValue');
    		       }
    		     }
    		   });
    		 });

    		function inputFocus(id)
    		{
    			document.getElementById(id).focus();
    		}
    	</script>
	<script>
		$('#eventT .time').timepicker({
		        'showDuration': true,
		        'timeFormat': 'H:i:s',
		        'step': 5,
		        'disableTextInput': true,
		        'disableTouchKeyboard': true,
		        'scrollDefault': 'now'
		        
		    });
	
		    $('#dateContainer .date').datepicker({
		        'format': 'yyyy-m-d',
		        'autoclose': true,
		    });
	
		 	$('#streamT .time').timepicker({
		 		'showDuration': true,
		        'timeFormat': 'H:i:s',
		        'step': 5,
		        'disableTextInput': true,
		        'disableTouchKeyboard': true,
		        'scrollDefault': 'now'
		    });

		 	var eventTEl = document.getElementById('eventT');
		    var datepair = new Datepair(eventTEl);

			function showSecondary()
			{
				document.getElementById('secondary_container').style.display = '';
				document.getElementById('secondary_plus').style.display = 'none';
			} 
		    
		    function updateURL()
			{
				var stream_name = document.getElementById('stream_name').value;
				var stream_url = document.getElementById('stream_url');
				var stream_url_label = document.getElementById('stream_url-label');
				
				stream_url.value = 'https://5beb169e8a234.streamlock.net:443/live/' + stream_name + '/playlist.m3u8';
				stream_url_label.className = "hasValue";		
			}

			function updateEndLabel()
			{
				document.getElementById('end_time-label').className = "hasValue";
			}

			function showSchools()
			{
				if(document.getElementById('main').value == 1)
				{
					document.getElementById('schools').style.display = '';
				}
				else
				{
					document.getElementById('schools').style.display = 'none';
					clearSelected(document.getElementById('school1'));
					clearSelected(document.getElementById('school2'));
					document.getElementById('school1-label').className = 'label-text';
					document.getElementById('school2-label').className = 'label-text';
				}
			}

			function updateURL()
			{
				var stream_name = document.getElementById('stream_name').value;
				var stream_url = document.getElementById('stream_url');
				var sendURL_container = document.getElementById('sendURL_container');
				var sendURL = document.getElementById('sendURL');

				stream_url.value = 'https://5beb169e8a234.streamlock.net:443/live/' + stream_name + '/playlist.m3u8';
				document.getElementById('stream_url-label').className = 'hasValue';
			}

			function checkCat(cid)
			{
				var value;
				var school1c = document.getElementById('schools');
				var subc = document.getElementById('sub_container');
				var showc = document.getElementById('show_container');
				var school1 = document.getElementById('school1');
				var school2 = document.getElementById('school2');
				var sub = document.getElementById('sub');
				var show = document.getElementById('show');
				var episode = document.getElementById('episode');
				switch(cid)
				{
					case 1:
						value = document.getElementById('main').value;
						if(value == 1)
						{
							school1c.style.display = "";
							subc.style.display = "";
							showc.style.display = "none";
							episode.value = "";

							clearSelected(show);
							
						}
						if(value == 2)
						{
							subc.style.display = "";
							school1c.style.display = "none";
							showc.style.display = "none";
							episode.value = "";
							clearSelected(school2);
							clearSelected(school1);
							clearSelected(show);

						}
						if(value == 3)
						{
							subc.style.display = "";
							school1c.style.display = "none";
							showc.style.display = "none";
							episode.value = "";
							clearSelected(school2);
							clearSelected(school1);
							clearSelected(show);

						}
						if(value == 4)
						{
							showc.style.display = "";
							subc.style.display = "none";
							school1c.style.display = "none";
							clearSelected(school2);
							clearSelected(sub);
							clearSelected(school1);

							
							
						}
						if(value == 31)
						{
							subc.style.display = "none";
							school1c.style.display = "none";
							showc.style.display = "none";
							episode.value = "";
							clearSelected(school2);
							clearSelected(school1);
							clearSelected(show);
							clearSelected(sub);
						}
						if(value == 43)
						{
							subc.style.display = "none";
							school1c.style.display = "none";
							showc.style.display = "none";
							episode.value = "";
							clearSelected(school2);
							clearSelected(school1);
							clearSelected(show);
							clearSelected(sub);
						}
						break;
					case 2:

						break;
					case 3:
						
						break;
					case 4:
						document.getElementById('schools').style.display = "";
						document.getElementById('sub_container').style.display = "";
						document.getElementById('show_container').style.display = "none";	
						break;
					case 5:
						document.getElementById('schools').style.display = "";
						document.getElementById('sub_container').style.display = "";
						document.getElementById('show_container').style.display = "none";	
						break;
				
				}
			}

			function clearSelected(dropdown)
			{
				var elements = dropdown.options;
				for(var i = 0; i < elements.length; i++)
					{
				      elements[i].selected = false;
					}
			}

			checkCat(1);
	 </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('residential.templates.uadmin', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>