@extends('layouts.default')

@section('title')
@parent
Добавление продукта для проекта {{ $project->name }}
@stop

@section('content')
<div class="row">
	<div class="col-md-6 col-md-offset-3">
		{{ Form::open(array('action' => array('ProductsController@store', $project->id))) }}
		<h2>Добавление продукта для проекта {{ $project->name }}</h2>

		<div class="form-group {{ ($errors->has('mark')) ? 'has-error' : '' }}">
			{{ Form::label( 'mark', 'Марка:', array('class' => 'control-label') ) }}
			{{ Form::select('mark', $marks, null, array('class' => 'form-control', 'autofocus')) }}
			{{ ($errors->has('mark') ? $errors->first('mark') : '') }}
		</div>

		<div class="form-group {{ ($errors->has('name')) ? 'has-error' : '' }}">
			{{ Form::label( 'name', 'Название:', array('class' => 'control-label') ) }}
			{{ Form::text('name', null, array('class' => 'form-control')) }}
			{{ ($errors->has('name') ? $errors->first('name') : '') }}
		</div>

		<div class="row">
			<div class="col-md-6">
				<div class="form-group {{ ($errors->has('year_start')) ? 'has-error' : '' }}">
					{{ Form::label( 'year_start', 'С:', array('class' => 'control-label') ) }}
					{{ Form::select('year_start', $yearsStart, null, array('class' => 'form-control')) }}
					{{ ($errors->has('year_start') ? $errors->first('name') : '') }}
				</div>
			</div>
			<div class="col-md-6">
				<div class="form-group {{ ($errors->has('year_end')) ? 'has-error' : '' }}">
					{{ Form::label( 'year_end', 'По:', array('class' => 'control-label') ) }}
					{{ Form::select('year_end', $yearsEnd, null, array('class' => 'form-control')) }}
					{{ ($errors->has('year_end') ? $errors->first('name') : '') }}
				</div>
			</div>
	    <div class="col-md-6">
			  <label class="checkbox">
          <input type="checkbox" name="no-production"> Не отправлять в производство
        </label>
	    </div>
	  </div>

		@foreach (ProductType::all() as $productType)
		<div class="well well-sm">
			<h4>{{ $productType->name }}</h4>
			<div class="row">
				<div class="col-md-6">
					<div class="form-group {{ ($errors->has('price['.$productType->id.']')) ? 'has-error' : '' }}">
						{{ Form::label( 'price['.$productType->id.']', 'Цена при 100% предоплате:', array('class' => 'control-label') ) }}
						{{ Form::text('price['.$productType->id.']', null, array('class' => 'form-control')) }}
						{{ ($errors->has('price['.$productType->id.']') ? $errors->first('price') : '') }}
					</div>
				</div>
				<div class="col-md-6">
					<div class="form-group {{ ($errors->has('price_back['.$productType->id.']')) ? 'has-error' : '' }}">
						{{ Form::label( 'price_back['.$productType->id.']', 'Цена при наложенном платеже:', array('class' => 'control-label') ) }}
						{{ Form::text('price_back['.$productType->id.']', null, array('class' => 'form-control')) }}
						{{ ($errors->has('price_back['.$productType->id.']') ? $errors->first('price_back') : '') }}
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-6">
					<div class="form-group {{ ($errors->has('price_opt['.$productType->id.']')) ? 'has-error' : '' }}">
						{{ Form::label( 'price_opt['.$productType->id.']', 'Оптовая цена:', array('class' => 'control-label') ) }}
						{{ Form::text('price_opt['.$productType->id.']', null, array('class' => 'form-control')) }}
						{{ ($errors->has('price_opt['.$productType->id.']') ? $errors->first('price_opt') : '') }}
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-4">
					<div class="form-group {{ ($errors->has('plates['.$productType->id.']')) ? 'has-error' : '' }}">
						{{ Form::label( 'plates['.$productType->id.']', 'Пластины:', array('class' => 'control-label') ) }}
						{{ Form::text('plates['.$productType->id.']', null, array('class' => 'form-control')) }}
						{{ ($errors->has('plates['.$productType->id.']') ? $errors->first('price') : '') }}
					</div>
				</div>
				<div class="col-md-4">
					<div class="form-group {{ ($errors->has('hooks['.$productType->id.']')) ? 'has-error' : '' }}">
						{{ Form::label( 'hooks['.$productType->id.']', 'Уголки:', array('class' => 'control-label') ) }}
						{{ Form::text('hooks['.$productType->id.']', null, array('class' => 'form-control')) }}
						{{ ($errors->has('hooks['.$productType->id.']') ? $errors->first('price') : '') }}
					</div>
				</div>
				<div class="col-md-4">
					<div class="form-group {{ ($errors->has('splates['.$productType->id.']')) ? 'has-error' : '' }}">
						{{ Form::label( 'splates['.$productType->id.']', 'С-ки:', array('class' => 'control-label') ) }}
						{{ Form::text('splates['.$productType->id.']', null, array('class' => 'form-control')) }}
						{{ ($errors->has('splates['.$productType->id.']') ? $errors->first('price') : '') }}
					</div>
				</div>
			</div>
		</div>
		@endforeach

		{{ Form::submit('Добавить продукт', array('class' => 'btn btn-primary')) }}
		{{ Form::button('Отмена', array('class' => 'btn btn-default', 'onclick'=>'location="'.URL::to('projects').'/'.$project->id.'/products"')) }}

    {{ Form::close() }}
	</div>
</div>

@stop