@extends('layouts.default')

@section('title')
	@parent
	Редактировать задачу
@stop

@section('content')
	<div class="row">
		<div class="col-md-6 col-md-offset-3">
			{{ Form::open(array('action' =>  array('UsertasksController@update', $usertask->id), 'method' => 'put')) }}
			<h2>Редактировать задачу</h2>

			<div class="form-group {{ ($errors->has('name')) ? 'has-error' : '' }}">
				{{ Form::label( 'name', 'Название:', array('class' => 'control-label') ) }}
				{{ Form::text('name', $usertask->name, array('class' => 'form-control', 'placeholder' => 'Название', 'autofocus')) }}
				{{ ($errors->has('name') ? $errors->first('name') : '') }}
			</div>

			<div class="form-group {{ ($errors->has('fine')) ? 'has-error' : '' }}">
				{{ Form::label( 'fine', 'Штраф за невыполнение:', array('class' => 'control-label') ) }}
				{{ Form::text('fine', $usertask->fine, array('class' => 'form-control', 'placeholder' => 'Штраф за невыполнение')) }}
				{{ ($errors->has('fine') ? $errors->first('fine') : '') }}
			</div>

			{{ Form::label('Исполнители') }}
			<div class="form-group">
				@foreach ($users as $user)
				<label class="checkbox-inline">
					<input type="checkbox" name="users[{{ $user->id }}]" value='1'
					{{ (in_array($user->id, $usertaskUsers) ? 'checked="checked"' : '') }} > {{ $user->first_name }} {{ $user->last_name }}
				</label>
				<br/>
				@endforeach
			</div>

			{{ Form::hidden('id', $usertask->id) }}
			{{ Form::submit('Сохранить изменения', array('class' => 'btn btn-primary')) }}
			{{ Form::button('Отмена', array('class' => 'btn btn-default', 'onclick'=>'location="'.URL::to('usertasks').'"')) }}

			{{ Form::close() }}
		</div>
	</div>
@stop