<?php $__env->startSection('content'); ?>
	<div class="row">
    	<div class="col-lg-12">
    		<h1 class="page-header">Documents</h1>
    	</div>
    </div>
    <div class="row">
            <div class="col-lg-12">
                <?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 panel-default">
						<div class="panel-heading">
                            <?php echo e(ucfirst($action)); ?> Franchise
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12">
				                    <form id="theForm" class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="<?php echo e(url('admin/franchises/'.$action)); ?>">
										<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
										<?php if($action == 'edit'): ?>
											<input type="hidden" name="franchiseID" value="<?php echo e($franchise->id); ?>">
										<?php endif; ?>
										<div class="form-group">
											
											<div class="col-sm-12 col-md-2 morePadding morePadding2" onclick="inputFocus('type')">
												<select class="form-control" id="type" name="type"  title="Type">
													<!--  <option id="type_option"></option>  -->
													
													<option value="catv"
													<?php if(old('type') == 'catv' || (isset($franchise) && $franchise->type == 'catv')): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>CATV</option>
													<option value="voice_data"
													<?php if(old('type') == 'voice_data' || (isset($franchise) && $franchise->type == 'voice_data')): ?> 
														<?php echo e('selected'); ?> 
													<?php endif; ?>
													>Voice & Data</option>
													
													
													
												</select>
												<span id="type-label" 
												
												class="xlabel-text hasValue"
												
												>Type</span>	
											</div>
											
											<div class="col-sm-12 col-md-4 morePadding morePadding2" onclick="inputFocus('description')">
												<input type="text" class="form-control" id="description" name="description" value="<?php echo e(old('description') ? old('description') : (isset($franchise) ? $franchise->description : '')); ?>" title="Description">
												<span id="description-label" class="label-text">Description</span>	
											</div>
											
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('contact')">
												<input type="text" class="form-control" id="contact" name="contact" value="<?php echo e(old('contact') ? old('contact') : (isset($franchise) ? $franchise->contact : '')); ?>" title="Contact Person">
												<span id="contact-label" class="label-text">Contact</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('phone')">
												<input type="text" class="form-control" id="phone" name="phone" value="<?php echo e(old('phone') ? old('phone') : (isset($franchise) ? $franchise->phone : '')); ?>" title="Contact Phone">
												<span id="phone-label" class="label-text">Phone</span>	
											</div>

										</div>
										<div class="form-group">
											<div class="col-sm-12 col-md-6 morePadding morePadding2" onclick="inputFocus('address')">
												<input type="text" class="form-control" id="address" name="address" value="<?php echo e(old('address') ? old('address') : (isset($franchise) ? $franchise->address : '')); ?>" title="Address">
												<span id="address-label" class="label-text">Address</span>	
											</div>
											
											<div class="col-sm-12 col-md-2 morePadding morePadding2" onclick="inputFocus('city')">
												<select class="form-control" id="city" name="city"  title="City">
													<option id="city_option" value="">Select One</option>
													
													<?php foreach(\App\City::all()->sortBy('name') as $city): ?>
													
														<option value="<?php echo e($city->id); ?>"
														<?php if(old('city') == $city->id || (isset($franchise) && $franchise->city_id == $city->id)): ?> 
															<?php echo e('selected'); ?> 
														<?php endif; ?>
														><?php echo e($city->name); ?></option>
													
													<?php endforeach; ?>
													
												</select>
												<span id="city-label" 
												
												class="xlabel-text hasValue"
												
												>City</span>	
											</div>
											
											<div class="col-sm-12 col-md-2 morePadding morePadding2" onclick="inputFocus('state')">
												<input type="text" class="form-control" id="state" name="state" value="<?php echo e(old('state') ? old('state') : (isset($franchise) ? $franchise->state : 'Utah')); ?>" title="State">
												<span id="state-label" class="label-text">State</span>	
											</div>
											
											<div class="col-sm-12 col-md-2 morePadding morePadding2" onclick="inputFocus('zip')">
												<input type="text" class="form-control" id="zip" name="zip" value="<?php echo e(old('zip') ? old('zip') : (isset($franchise) ? $franchise->zip : '')); ?>" title="Zip Code">
												<span id="zip-label" class="label-text">Zip Code</span>	
											</div>
										</div>
										<div class="form-group">
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('franchise_fee')">
												<input type="number" class="form-control" id="franchise_fee" name="franchise_fee" step=".01" value="<?php echo e(old('franchise_fee') ? old('franchise_fee') : (isset($franchise) ? $franchise->franchise_fee : '')); ?>" title="Franchise Fee">
												<span id="franchise_fee-label" class="label-text">Franchise Fee</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('application_fee')">
												<input type="number" class="form-control" id="application_fee" name="application_fee" step=".01" value="<?php echo e(old('application_fee') ? old('application_fee') : (isset($franchise) ? $franchise->application_fee : '')); ?>" title="Application Fee">
												<span id="application_fee-label" class="label-text">Application Fee</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('term')">
												<input type="number" class="form-control" id="term" name="term" step="1" value="<?php echo e(old('term') ? old('term') : (isset($franchise) ? $franchise->term : '')); ?>" title="Term">
												<span id="term-label" class="label-text">Term</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('expiration')">
												<input type="text" class="form-control" id="expiration" name="expiration"  value="<?php echo e(old('expiration') ? old('expiration') : (isset($franchise) && $franchise->expiration != "0000-00-00 00:00:00" ? explode(' ',$franchise->expiration)[0] : '')); ?>" title="Expiration">
												<span id="expiration-label" class="label-text">Expiration</span>	
											</div>
										</div>
										<!-- 
										<div class="form-group">
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('commercial_general_liability')">
												<input type="number" class="form-control" id="commercial_general_liability" name="commercial_general_liability" step=".01" value="<?php echo e(old('commercial_general_liability') ? old('commercial_general_liability') : (isset($franchise) ? $franchise->commercial_general_liability : '')); ?>" title="Commercial General Liability Amount">
												<span id="commercial_general_liability-label" class="label-text">Commercial General Liability</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('automobile_liability')">
												<input type="number" class="form-control" id="automobile_liability" name="automobile_liability" step=".01" value="<?php echo e(old('automobile_liability') ? old('automobile_liability') : (isset($franchise) ? $franchise->automobile_liability : '')); ?>" title="Automobile Liability Insurance">
												<span id="automobile_liability-label" class="label-text">Automobile Liability</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('workers_comp')">
												<input type="number" class="form-control" id="workers_comp" name="workers_comp" step=".01" value="<?php echo e(old('workers_comp') ? old('workers_comp') : (isset($franchise) ? $franchise->workers_comp : '')); ?>" title="Workers Comp and Employers Liability Amount">
												<span id="workers_comp-label" class="label-text">Workers' Comp</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('bond')">
												<input type="number" class="form-control" id="bond" name="bond" step=".01" value="<?php echo e(old('bond') ? old('bond') : (isset($franchise) ? $franchise->bond : '')); ?>" title="Bond Amount">
												<span id="bond-label" class="label-text">Bond</span>	
											</div>
										</div>
										 -->
										<div class="form-group">
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('signed_by')">
												<input type="text" class="form-control" id="signed_by" name="signed_by" value="<?php echo e(old('signed_by') ? old('signed_by') : (isset($franchise) ? $franchise->signed_by : '')); ?>" title="Signed By">
												<span id="signed_by-label" class="label-text">Signed By</span>	
											</div>
											<div class="col-sm-12 col-md-3 morePadding morePadding2" onclick="inputFocus('signed_date')">
												<input type="text" class="form-control" id="signed_date" name="signed_date" value="<?php echo e(old('signed_date') ? old('signed_date') : (isset($franchise) ? date('Y-m-d', strtotime($franchise->signed_date)) : '')); ?>" title="Date Signed">
												<span id="signed_date-label" class="label-text">Date Signed</span>	
											</div>
										</div>
										<div class="form-group">
											<div class="col-sm-12 col-md-6 morePadding morePadding2">
												<textarea class="form-control" name="notes" id="notes" rows="2" placeholder="Notes"><?php echo e(old('notes') ? old('notes') : (isset($franchise) ? $franchise->notes : '')); ?></textarea>
											</div>
											<div class="col-sm-12 col-md-6 morePadding">
												<button type="submit" class="btn btn-primary" style="float: right;">
													Save
												</button>
											</div>
										</div>
										
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		<?php if($action == 'edit'): ?>
		
			<?php if(isset($documents) && count($documents) > 0): ?>
				<div class="row">
					<div class="col-lg-12">
						<div class="panel panel-default">
							<div class="panel-heading">
	                            Documents
	                        </div>
	                        <div class="panel-body">
	                            <div class="row">
	                                <div class="col-lg-12">
				                         <div class="dataTable_wrapper">
			                                <table class="table table-striped table-bordered table-hover" id="dataTables-example2">
			                                    <thead>
			                                        <tr>
			                                            <th>File</th>
			                                            <th>Uploaded By</th>
			                                            <th>Uploaded At</th>
			                                        </tr>
			                                    </thead>
			                                    <tbody>
			                                    <?php $count = 0; ?>
			                                    <?php foreach($documents as $document): ?>
			                                    <?php $count++; ?>
			                                    <?php if($count % 2 == 1): ?>
			                                        <tr class="odd">
			                                    <?php else: ?>
			                                    	<tr class="even">
			                                    <?php endif; ?>
			                                            <td><a href="<?php echo e(url('uadmin/franchises/attachment/'.$document->id)); ?>" target="_blank"><?php echo e(str_replace(' ','_',$document->filename)); ?></a></td>
			                                            <td><?php echo e($document->created_by); ?></td>
			                                            <td><?php echo e($document->created_at); ?></td>
		
			                                        </tr>
			                                  	<?php endforeach; ?>
			                                       </tbody>
			                                	</table>
			                                </div>
	                                </div>
	                            </div>
	                        </div>
	                    </div>
					</div>
				</div>
			<?php endif; ?>
			
			<div class="row">
	            <div class="col-lg-12">
	                <?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 panel-default">
						<div class="panel-heading">
                            Add Document
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12">
				                    <form id="theForm" class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="<?php echo e(url('admin/franchises/add_document')); ?>">
										<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
										<input type="hidden" name="franchiseID" value="<?php echo e($franchise->id); ?>">

										<div class="form-group">
											<div class="col-sm-12 col-md-4 morePadding morePadding2" onclick="inputFocus('attachment')">
												<input type="file" class="form-control" id="attachment" name="attachment" value="<?php echo e(old('attachment')); ?>"  title="File" style="border: none;">
												<span id="attachment-label" class="xlabel-text hasValue">File</span>	
											</div>
											<div class="col-sm-12 col-md-8 morePadding">
												<button type="submit" class="btn btn-primary" style="float: right;">
													Upload
												</button>
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
						
			
		<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('extras'); ?>
	<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)
		{
			.morePadding {
			    margin-top: 1.5em;
			}
		}

		@media (min-width: 960px)
		{
			.morePadding {
			    margin-top: 1em;
			}
		}
		
	</style>
	 <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>
    	a:hover{
    		text-decoration: none;
    	}
    	.odd .subBack {
    		background-color: #f0fcff;
    	}
    	.even .subBack {
    		background-color: #ecf7fa;
    	}
    	.floatLeft
    	{
    		float: left;
    	}

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

<?php $__env->startSection('bottom'); ?>
<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 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() {
    var table1 =    $('#dataTables-example2').dataTable( {
					"pageLength": 10,
					"order": [ 2, 'asc' ],
					"stateSave" : false,
					"scrollX" : window.innerWidth < 800 ? true : false,

					
        } );  


    });

    

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