@extends('admin.layout')

@section('content')

    <?php
    if (!isset($data)) $data = array();
    if (!$data && session("data")) {
        $data = session("data");
    }
    if (!$data && session('_old_input')) {
        $data = session("_old_input");
    }
    ?>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>产品分类</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        @if(role('Furniture/Goods/Category/index'))
                            <div class="row">
                                <div class="col-sm-3 pull-right">
                                    <a href="{{ U('Furniture/Goods/Category/index')}}"
                                       class="btn btn-sm btn-primary pull-right">返回列表</a>
                                </div>
                            </div>
                        @endif

                        <div class="row">
                            <div class="col-lg-10">
                                <form name="form_product" id="form-validation" action=""
                                      class="form-horizontal form-validation" accept-charset="UTF-8" method="post">


                                    <div class="form-group">

                                        <label class="control-label col-sm-3">父类</label>

                                        <div class="col-sm-9">
                                            <select class="form-control m-b" name="data[pid]">
                                                <option value="0">--顶级--</option>
                                                @foreach($cate as $c)
                                                    <option value="{{$c->id}}"
                                                            @if(isset($data['pid']) && $data['pid'] == $c->id) selected @endif>{{$c->name}}</option>
                                                    @if($c->sub)
                                                        @foreach($c->sub as $s)
                                                            <option value="{{$s->id}}"
                                                                    @if(isset($data['pid']) && $data['pid'] == $s->id) selected @endif>
                                                                &nbsp&nbsp&nbsp&nbsp|---{{$s->name}} </option>
                                                        @endforeach
                                                    @endif
                                                @endforeach
                                            </select>
                                        </div>

                                    </div>
                                    <div class="form-group">

                                        <label class="control-label col-sm-3">分类名称</label>

                                        <div class="col-sm-9">
                                            <input id="data_name" name="data[name]" class="form-control"
                                                   value="{{ $data['name'] or ''}}" required="" aria-required="true"
                                                   placeholder="">
                                        </div>

                                    </div>
                                    <div class="form-group">

                                        <label class="control-label col-sm-3">排序，越大越靠前</label>

                                        <div class="col-sm-9">
                                            <input id="data_sort" name="data[sort]" class="form-control"
                                                   value="{{ $data['sort'] or ''}}" required="" aria-required="true"
                                                   placeholder="">
                                        </div>

                                    </div>
                                    <div class="form-group">

                                        <label class="control-label col-sm-3">状态</label>

                                        <div class="col-sm-9">
                                            <label class="radio-inline">
                                                <input type="radio" name="data[status]" value="1"
                                                       @if(isset($data['status']) && $data['status'] == '1')checked="checked" @endif/>启用
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="data[open_status]" value="0"
                                                       @if(isset($data['status']) && $data['status'] == '0')checked="checked" @endif/>不启用
                                            </label>
                                        </div>

                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-sm-3">&nbsp;</label>
                                        <div class="col-sm-9">
                                            <input type="hidden" name="_referer"
                                                   value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
                                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
                                            <input type="submit" class="btn btn-success" style="margin-right:20px;">
                                            <input type="reset" class="btn btn-default">
                                        </div>
                                    </div>

                                </form>
                            </div>
                            <!-- /.col-lg-10 -->
                        </div>
                        <!-- /.row -->
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection