@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('Album/Product/index'))
				    <div class="row">
    					<div class="col-sm-3 pull-right">
    					   <a href="{{ U('Album/Product/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">
                     <input id="data_store_id" 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">
                       <select name="data[cat_id]" id="data_cat_id" class="form-control"  required="" aria-required="true">
                           @if(isset($cat))
                               @foreach($cat as $key=>$val)
                                       <option value="{{$val->id}}"  @if($val['id'] == (isset($data['cat_id'])? $data['cat_id']:''))selected @endif>{{$val->name}}</option>
                               @endforeach
                           @endif
                       </select>
                   </div>

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

                                    <label class="control-label col-sm-3">默认价格</label>

                                    <div class="col-sm-9">
                                        <input id="data_store_id" name="data[price_default]" type="number" class="form-control" value="{{ $data['price_default'] or ''}}" required="" aria-required="true"  placeholder="">
                                    </div>
                                </div>
                                <div class="form-group">
                                    
                 <label class="control-label col-sm-3">尺寸图片(1920*1080)</label>
                    <div class="col-sm-9">
                        {{--{!!  widget('Tools.ImgUpload')->single2('/upload/attr','attr',"attr",  isset($data['attr'])? $data['attr'] : '',array("sizex"=>1920,"sizey"=>1080)) !!}--}}
                        {!!  widget('Tools.ImgUpload')->multi2('/upload/specifications_img','specifications_img',"data[specifications_img]",  isset($data['specifications_img'])? $data['specifications_img'] : '',array("sizex"=>1920,"sizey"=>1080)) !!}
                    </div>
                </div>

                <div class="form-group">

                    <label class="control-label col-sm-3">安装图片(1920*1080)</label>
                    <div class="col-sm-9">
                        {!!  widget('Tools.ImgUpload')->multi2('/upload/install_img','install_img',"data[install_img]",  isset($data['install_img'])? $data['install_img'] : '',array("sizex"=>1920,"sizey"=>1080)) !!}
                    </div>
                </div>
                <div class="form-group">
                                    
                 <label class="control-label col-sm-3">风格</label>
                    <div class="col-sm-9">
                        <select name="data[style]" id="data_style" class="form-control"  required="" aria-required="true">
                            @if(isset($style))
                                @foreach($style as $key=>$val)
                                    <option value="{{$val->id}}"  @if($val['id'] == (isset($data['style'])? $data['style']:''))selected @endif>{{$val->name}}</option>
                                @endforeach
                            @endif
                        </select>
                    </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">封面图片(1920*1080)</label>
                    <div class="col-sm-9">
                        {{--{!!  widget('Tools.ImgUpload')->single2('/upload/cover_pic','cover_pic',"cover_pic",  isset($data['cover_pic'])? $data['cover_pic'] : '',array("sizex"=>662,"sizey"=>510)) !!}--}}
                        {!!  widget('Tools.ImgUpload')->single2('/upload/cover_pic','cover_pic',"cover_pic",  isset($data['cover_pic'])? $data['cover_pic'] : '',array("sizex"=>1920,"sizey"=>1080)) !!}
                    </div>
                </div>
                                <div class="form-group">
                                    <label class="control-label col-sm-3">搭配图片(1920*1080)</label>
                                    <div class="col-sm-9">
                                        {!!  widget('Tools.ImgUpload')->single2('/upload/detail_pic','detail_pic',"detail_pic",  isset($data['detail_pic'])? $data['detail_pic'] : '',array("sizex"=>1920,"sizey"=>1080)) !!}
                                    </div>
                                </div>
                <div class="form-group">
                 <label class="control-label col-sm-3">是否促销</label>
                                    
                   <div class="col-sm-9">
                       @if(dict()->get('global','bool') != null)
                           @foreach(dict()->get('global','bool') as $key=>$val)
                               <label class="radio-inline">
                                   <input type="radio" name="data[hot_cake]" value="{{$key}}" @if(isset($data['hot_cake']) && $data['hot_cake'] == $key)checked="checked" @endif/>{{$val}}
                               </label>
                           @endforeach
                       @else
                           <label class="radio-inline">
                               <input type="radio" name="data[hot_cake]">
                           </label>
                       @endif
                    </div>
                                
                </div>    
                <div class="form-group">
                                    
                 <label class="control-label col-sm-3">最新上市</label>
                                    
                   <div class="col-sm-9">
                       @if(dict()->get('global','bool') != null)
                           @foreach(dict()->get('global','bool') as $key=>$val)
                               <label class="radio-inline">
                                   <input type="radio" name="data[news]" value="{{$key}}" @if(isset($data['news']) && $data['news'] == $key)checked="checked" @endif/>{{$val}}
                               </label>
                           @endforeach
                       @else
                           <label class="radio-inline">
                               <input type="radio" name="data[news]">
                           </label>
                       @endif
                    </div>
                                
                </div>    
                <div class="form-group">
                 <label class="control-label col-sm-3">产品详情</label>
                   <div class="col-sm-9">
                  {{--     //{!! ueditor('') !!}--}}
                       {!!  widget('Tools.ImgUpload')->multi2('/upload/detail','detail',"data[detail]",  isset($data['detail'])? $data['detail'] : '') !!}
                    </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>
<script>
    function check(){
        //alert($('#data_cat_id').val());
        if($('#data_cat_id').val() == '' || $('#data_cat_id').val() == null){

            return false;
        }
    }

</script>
@endsection