@extends('layouts.default')

@section('title')
@parent
Редактировать группу продукта
@stop

@section('content')
<div class="row">
	<div class="col-md-8 col-md-offset-2">
		{{ Form::open(array('action' => array('ProductsGroupController@update', $project->id, $productGroup->id), 'method' => 'put')) }}
		<h2>Редактировать группу продукта
    {{ Form::hidden('id', $productGroup->id) }}
		{{ Form::submit('Сохранить изменения', array('class' => 'btn btn-primary')) }}
		{{ Form::button('Отмена', array('class' => 'btn btn-default', 'onclick'=>'location="'.URL::to('projects').'/'.$project->id.'/products/group"')) }}
		</h2>
		
		<div class="form-group {{ ($errors->has('name')) ? 'has-error' : '' }}">
			{{ Form::label( 'name', 'Название:', array('class' => 'control-label') ) }}
			{{ Form::text('name', $productGroup->name, array('class' => 'form-control', 'autofocus')) }}
			{{ ($errors->has('name') ? $errors->first('name') : '') }}
		</div>

		{{ Form::label('Продукты в группе:') }}
		<div class="form-group">
			@foreach ($currProducts as $currProduct)
			<label class="checkbox-inline">
				<input type="checkbox" name="curr-product[{{ $currProduct->id }}]" value='1' checked="checked"> {{ $currProduct->mark }} {{ $currProduct->model }}, {{ $currProduct->productType }}
			</label>
			<br/>
			@endforeach
		</div>
		
		<label for="Остальные продукты:">Остальные продукты:</label>
		{{--<br>
		<button class="btn btn-danger ladda-button active" data-product-type-id="0"> Все </button>
		<div class="btn-group">
			@foreach ($productTypes as $productType)
			  <button class="btn btn-primary ladda-button" data-product-type-id="{{ $productType->id }}">{{ $productType->name }}</button>
			@endforeach
		</div>--}}
		{{ Form::open() }}

		<div class="form-group">
			@foreach ($anotherProducts as $anotherProduct)
			<div class="qwerty-{{ $anotherProduct->productTypeId }}">
				<label class="checkbox-inline">
					<input type="checkbox" name="another-product[{{ $anotherProduct->id }}]" class="product-type-id-{{ $anotherProduct->productTypeId }}" value='1'> 
					<span>{{ $anotherProduct->mark }} {{ $anotherProduct->model }}, {{ $anotherProduct->productType }}</span> <span class="badge">{{ $anotherProduct->productGroupName }}</span>
				</label>
			  <br/>
			</div>
			@endforeach
		</div>

    {{ Form::close() }}
	</div>
</div>
@stop

@section('js')
	<script src="{{ asset('js/products.js') }}"></script>
@stop