<?php $__env->startSection('content'); ?>
	<div class="row">
    	<div class="col-lg-12">
    		<h1 class="page-header">Variables</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">
                            Edit Variable <?php echo e($variable->id); ?> - <?php echo e($variable->name); ?>

                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12">
                                	<form class="form-horizontal" role="form" method="POST" action="<?php echo e(url('admin/variables/edit')); ?>"
										onsubmit="document.getElementById('value').value = editor.getValue()">
										<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
										<input type="hidden" name="id" value="<?php echo e($variable->id); ?>">
										
										<?php if(old('value')): ?>
										<input type="hidden" id="value" name="value" value="<?php echo e(old('value')); ?>">
										<?php else: ?>
										<input type="hidden" id="value" name="value" value="<?php echo e(trim($variable->value)); ?>">
										<?php endif; ?>
										
										<div class="form-group">
											<label class="col-md-2 control-label" style="text-align: left;">Variable Name</label>
											<div class="col-md-4">
												
												<?php if(old('name')): ?>
												<input type="text" class="form-control" name="name" value="<?php echo e(old('name')); ?>">
												<?php else: ?>
												<input type="text" class="form-control" name="name" value="<?php echo e(trim($variable->name)); ?>">
												<?php endif; ?>
													
											</div>
											<label class="col-md-2 control-label" style="text-align: left;">Variable Type</label>
											<div class="col-md-4">
												<select class="form-control" name="type">
													<option <?php if($variable->type=='general'): ?> <?php echo e('selected'); ?> <?php endif; ?> 
														value="general">General</option>
													<option <?php if($variable->type=='price'): ?> <?php echo e('selected'); ?> <?php endif; ?> 
														value="Price">Price</option>
													<option <?php if($variable->type=='company'): ?> <?php echo e('selected'); ?> <?php endif; ?> 
														value="company">Company</option>
												</select>
											</div>
										</div>
										
										<div id="editor" class="col-md-12"></div>
				
										<div class="form-group">
											<div class="col-md-6 col-md-offset-0" style="margin: 15px 0px;">
												<button type="submit" class="btn btn-primary">
													Save
												</button>
											</div>
										</div>
									</form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div> 
            
    	<script>
        	var editor = ace.edit("editor");
        	editor.setTheme("ace/theme/eclipse");
        	editor.setShowPrintMargin(false);
        	var phpMode = ace.require("ace/mode/php").Mode;
        	editor.getSession().setMode(new phpMode());
        	editor.setValue(document.getElementById('value').value, -1);
    	</script>

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

<?php $__env->startSection('extras'); ?>
	    <style>
	    	#editor {
        		position: relative;
        		width: 100%;
        		height: 100px;
    		}

    	</style>
    	<script src="<?php echo e(asset('js/ace/ace.js')); ?>" type="text/javascript" charset="utf-8"></script>
    	<script src="<?php echo e(asset('js/ace/mode-php.js')); ?>" type="text/javascript" charset="utf-8"></script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('residential.templates.uadmin', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>