@extends('dashboard::master')
{{--
    Autor: Giovanni López O.
    @gmlo_89
--}}
@section('head')
	
@stop

@section('content')
	<header>
		<h1 class="module-title"><span class="glyphicon glyphicon-folder-open"></span>{{ $title }}</h1>
    </header>
    {{ Alert::render() }}
    <div class="row btn-bar">
    	<div class="btn-group pull-left">
			<a href="{{ url('admin/categories') }}" class="btn btn-default">{{ trans('dashboard::label.go_back') }}</a>
		</div>
		<button tyle="button" data-click="submit" data-target="#frmPrincipal" class="btn btn-info pull-right">{{ trans('dashboard::label.save') }}</button>
    </div>
   
    {{ Form::model($category, $formOptions) }}
    	<div class="panel panel-default">
			<div class="panel-heading"><span class="glyphicon glyphicon-th-list"></span> {{ trans('categories::label.module_name') }}</div>
			<div class="panel-body">
				<div class="form-group">
					<label for="inputTitle" class="col-sm-2 control-label">{{ trans('categories::label.title') }}</label>
					<div class="col-sm-10">
						{{ Form::text('title', null, 
									array(
										"class" 		=> "form-control required",
										"id" 			=> "inputTitle",
										"placeholder"	=> trans('categories::label.title')
								)) }}
					</div>
				</div>

				<div class="form-group">
					<label class="col-sm-2 control-label" for="exampleIntroImage">{{ trans('categories::label.image') }}</label>
					<div class="col-sm-10">
						@if(!empty($category->image))
							<div class="row">
								<div class="col-md-3">
									<img class="img-responsive" src="{{ $category->image }}">
								</div>
								<div class="col-md-9">
									<div class="checkbox">
										<label>
											<input name="change-intro-image" type="checkbox"> {{ trans('categories::label.change_image') }}
										</label>
									</div>
									<a class="fancybox" href="{{ $category->image }}"> <span class="glyphicon glyphicon-zoom-in"></span> {{ trans('categories::label.show_image') }}</a>
								</div>
							</div>
						@endif
						{{ Form::file('image') }}
					</div>
				</div>
				
			    		
				<div class="form-group">
					<label class="col-sm-2 control-label" for="inputCategoryParent">{{ trans('categories::label.category_parent') }}</label>
					<div class="col-sm-10">
						{{ Form::select('category_parent', $categories, null, 
							array(
								"class" => 	"form-control",
								"id" 	=>	"inputCategoryParent"
							)) 
						}}
					</div>
				</div>
				@if($category->exists)
	    			<div class="form-group">
	    				<div class="col-sm-10 col-sm-offset-2">
	    					<button type="button" id="btnDeleteArticle" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> {{ trans('categories::label.delete_category') }}</button>
	    				</div>
		    		</div>
	    		@endif
			</div>
		</div>
	</form>
@stop

@section('scripts')
	{{ JavaScript::makeVar('msg_confirm_delete', trans('categories::message.confirm_delete_category')) }}
	<script>
		// Para eliminar un usuario se muestra un cuadro de dialogo
		$('#btnDeleteArticle').click(function(event) {
			bootbox.confirm(inncore.msg_confirm_delete, function(result) {
				if(result)
				{
					$("#frmPrincipal input, #frmPrincipal textarea, #frmPrincipal select").rules("remove");
					$("#frmPrincipal input[name='_method']").val("DELETE");
					$("#frmPrincipal").submit();
				}
			});
		});
		
		$('#frmPrincipal').validate();
	
		
		$(document).ready(function() {
		    
		});
	</script>

@stop