<?php $__env->startSection('content'); ?>
	<div class="row">
    	<div class="col-lg-12">
    		<h1 class="page-header">Channels</h1>
    	</div>
    </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                    
                    	<?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; ?>
						
						<div class="panel-heading">
                            Add Channel
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12">
				                    <form id="theForm" class="form-horizontal" role="form" method="POST" action="<?php echo e(url('admin/channels/add')); ?>">
										<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
										
										<div class="form-group">
											<label class="col-md-2 control-label">Network</label>
											<div class="col-md-2">
												<select  class="form-control" name="network">
													<option value="">Select One</option>
													<?php foreach($networks as $network): ?>
													<option value="<?php echo e($network->id); ?>" 
													<?php if(old('network') == $network->id): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>
														<?php echo e($network->name); ?>

													</option>
													<?php endforeach; ?>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">Headends</label>
											<?php foreach($headends as &$headend): ?>
											
											<div class="col-md-2" style="">
												<input type="checkbox" id="headend<?php echo e($headend->id); ?>" name="headend[<?php echo e($headend->id); ?>]" value="<?php echo e($headend->id); ?>" 
												<?php if(is_array(old('headend')) && array_key_exists($headend->id, old('headend')) && old('headend')[$headend->id] == $headend->id): ?>
												checked
												<?php $headend->checked = true; ?>
												<?php else: ?>
												<?php $headend->checked = false; ?>
												<?php endif; ?>
												onchange="headendChange(<?php echo e($headend->id); ?>)"
												>
												<label class="control-label"><?php echo e($headend->name); ?></label>
											</div>
											
											<?php endforeach; ?>
											
										</div>
										<br>
										<?php foreach($headends as $headend): ?>
										<div class="form-group" id="container<?php echo e($headend->id); ?>"
										<?php if(!$headend->checked): ?>
										style="display: none;"
										<?php endif; ?>
										>
											<label class="col-md-2 control-label"><?php echo e($headend->name); ?></label>
											<label class="col-md-1 control-label">SD</label>
											<div class="col-md-1">
												<input type="text" class="form-control" id="sd<?php echo e($headend->id); ?>" name="sd[<?php echo e($headend->id); ?>]" value="<?php echo e(old('sd')[$headend->id]); ?>">	
											</div>
											<label class="col-md-1 control-label">HD</label>
											<div class="col-md-1">
												<input type="text" class="form-control" id="hd<?php echo e($headend->id); ?>" name="hd[<?php echo e($headend->id); ?>]" value="<?php echo e(old('hd')[$headend->id]); ?>">	
											</div>
											<label class="col-md-1 control-label">DTV</label>
											<div class="col-md-1">
												<input type="text" class="form-control" id="dtv<?php echo e($headend->id); ?>" name="dtv[<?php echo e($headend->id); ?>]" value="<?php echo e(old('dtv')[$headend->id]); ?>">	
											</div>
											<label class="col-md-1 control-label">Package</label>
											<div class="col-md-2">
												<select  class="form-control" id="package<?php echo e($headend->id); ?>" name="package[<?php echo e($headend->id); ?>]">
													<option value="">Select One</option>
													<option value="broadcast_basic" 
													<?php if(old('package')[$headend->id] == 'broadcast_basic'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Broadcast Basic</option>
													<option value="expanded_basic"
													<?php if(old('package')[$headend->id] == 'expanded_basic'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Expanded Basic</option>
													<option value="digital_advantage"
													<?php if(old('package')[$headend->id] == 'digital_advantage'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Digital Advantage</option>
													<option value="digital_music"
													<?php if(old('package')[$headend->id] == 'digital_music'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Digital Music</option>
													<option value="hbo"
													<?php if(old('package')[$headend->id] == 'hbo'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>HBO</option>
													<option value="cinemax"
													<?php if(old('package')[$headend->id] == 'cinemax'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Cinemax</option>
													<option value="showtime"
													<?php if(old('package')[$headend->id] == 'showtime'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Showtime</option>
													<option value="starz_encore"
													<?php if(old('package')[$headend->id] == 'starz_encore'): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Starz/Encore</option>
												</select>
											</div>
										</div>
										<?php endforeach; ?>

										<div class="form-group">
											<div class="col-md-8 col-md-offset-2">
												<button type="submit" class="btn btn-primary">
													Add Channel
												</button>
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
<?php $__env->stopSection(); ?>

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




		function headendChange(id)
		{
			var container = document.getElementById('container' + id);
			var checkbox = document.getElementById('headend' + id);

			if(checkbox.checked == true)
			{
				container.style.display = '';
			}
			else
			{
				container.style.display = 'none';
				document.getElementById('sd'+id).value = "";
				document.getElementById('hd'+id).value = "";
				document.getElementById('dtv'+id).value = "";
				document.getElementById('package'+id).value = "";
			}
		}

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

<?php $__env->startSection('extras'); ?>
	<script>
	
	</script>
<?php $__env->stopSection(); ?>


			

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