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

	<div class="row">
    	<div class="col-lg-12">
    		<h1 class="page-header">Sponsor</h1>
    	</div>
    </div>
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
						<div class="panel-heading">
                            Edit Sponsor: <?php echo e($sponsor->name); ?>

                        </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/sponsor/edit')); ?>">
						<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
						<input type="hidden" name="sponsorID" value="<?php echo e($sponsor->id); ?>">
						
						<div class="form-group">
							<div class="col-sm-12 col-md-9  moreMargin" onclick="inputFocus('name')">
								<input type="text" class="form-control" id="name" name="name" value="<?php echo e(old('name') ? old('name') : $sponsor->name); ?>" title="Name">
								<span id="name-label" class="label-text">Name</span>	
							</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>
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
	                    
                        <div class="panel-heading">
                            <?php echo e($sponsor->name); ?> Ads <a href="<?php echo e(url('uadmin/sponsors/add_ad/'.$sponsor->id)); ?>" target="_blank"> <i class="fa fa-plus fa-fw" style="float: right;"></i> </a>
                        </div>
                        <!-- /.panel-heading -->
                        <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; ?>
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>File</th>
                                            <th>Status</th>
                                            <th>Type</th>
                                            <th>Category 1</th>
                                            <th>Category 2</th>
                                            <th>URL</th>
                                            <th>Created</th>
                                            <th>Expiration</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php $count = 0; ?>
                                    <?php foreach($ads as $ad): ?>
                                    <?php $count++; ?>
                                    <?php if($count % 2 == 1): ?>
                                        <tr class="odd" title="<?php echo e($ad->url); ?>">
                                    <?php else: ?>
                                    	<tr class="even" title="<?php echo e($ad->url); ?>">
                                    <?php endif; ?>
                                            <td><?php echo e($ad->file); ?></td>
                                            <td><?php echo e($ad->status ? 'Active' : 'Inactive'); ?></td>
                                            <td><?php echo e($ad->type); ?></td>
                                            <td><?php echo e($ad->category ? \App\Event_category::find($ad->category)->name : ($ad->category2 ? '' : 'Global')); ?>

                                            <td><?php echo e($ad->category2 ? \App\Event_category::find($ad->category2)->name : ''); ?>

                                            <td><?php echo e($ad->url); ?></td>
                                            <td><?php echo e($ad->created_at); ?></td>
                                            <td><?php echo e($ad->expiration); ?>

                                            <td style="text-align: center;">
                                            <?php if($ad->status): ?>
                                           		<form style="display: inline;" role="form" method="POST" action="<?php echo e(url('admin/sponsor/ad/deactivate')); ?>" 
													onsubmit="return confirm('Are you sure you want to deactivate ad?')">
													<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
													<input type="hidden" name="adID" value="<?php echo e($ad->id); ?>">
													<button type="submit" style="border: none; background-color: transparent; padding: 0;" title="Deactivate">
                                            			<i class="fa fa-toggle-on fa-fw" style="text-align: right;"></i>
                                            		</button>
                                            	</form>
                                            <?php else: ?>
                                            	<form style="display: inline;" role="form" method="POST" action="<?php echo e(url('admin/sponsor/ad/activate')); ?>" 
													onsubmit="return confirm('Are you sure you want to activate ad?')">
													<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
													<input type="hidden" name="adID" value="<?php echo e($ad->id); ?>">
													<button type="submit" style="border: none; background-color: transparent; padding: 0;" title="Activate">
                                            			<i class="fa fa-toggle-off fa-fw" style="text-align: right;"></i>
                                            		</button>
                                            	</form>
                                            <?php endif; ?>
                                            </td>
                                        </tr>
                                  	<?php endforeach; ?>
                                       </tbody>
                                	</table>
                                </div>
                             </div>
                         </div>
		</div>
	</div>

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

<?php $__env->startSection('extras'); ?>
<!-- DataTables CSS -->
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/t/bs/pdfmake-0.1.18,dt-1.10.11,b-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2/datatables.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'); ?>
    	
    	    <!-- DataTables JavaScript -->
    <script type="text/javascript" src="https://cdn.datatables.net/t/bs/pdfmake-0.1.18,dt-1.10.11,b-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2/datatables.min.js"></script>
    
    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
    $(document).ready(function() {
        $('#dataTables-example').dataTable( {
					"pageLength": 25,
					"order": [ 0, 'asc' ]
        } );   
    });
    if ( typeof $.fn.dataTable == "function" && typeof $.fn.dataTableExt.fnVersionCheck == "function" && $.fn.dataTableExt.fnVersionCheck('1.9.2')/*older versions should work too*/ )
    {
        $.fn.dataTableExt.oApi.clearSearch = function ( oSettings )
        {
     
            var table = this;
             
            //any browser, must include your own file
            //var clearSearch = $('<img src="/images/delete.png" style="vertical-align:text-bottom;cursor:pointer;" alt="Delete" title="Delete"/>');
             
            //no image file needed, css embedding must be supported by browser
            var clearSearch = $('<i class="fa fa-times-circle-o fa-fw" style="vertical-align:text-bottom;cursor:pointer;color: gray;"></i>');
            $(clearSearch).click( function ()
                    {
                          table.fnFilter('');
                    });
            $(oSettings.nTableWrapper).find('div.dataTables_filter').append(clearSearch);
            $(oSettings.nTableWrapper).find('div.dataTables_filter label').css('margin-right', '-16px');//16px the image width
            $(oSettings.nTableWrapper).find('div.dataTables_filter input').css('padding-right', '16px');
        }
     
        //auto-execute, no code needs to be added
        $.fn.dataTable.models.oSettings['aoInitComplete'].push( {
            "fn": $.fn.dataTableExt.oApi.clearSearch,
            "sName": 'whatever'
        } );
    }
    </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>

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