@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('ProjectsController@update', $project->id), 'method' => 'put')) }}
		<h2>Редактировать информацию о проекте</h2>

		<div class="form-group {{ ($errors->has('name')) ? 'has-error' : '' }}">
			{{ Form::label( 'name', 'Название:', array('class' => 'control-label') ) }}
			{{ Form::text('name', $project->name, array('class' => 'form-control', 'placeholder' => 'Название', 'autofocus')) }}
			{{ ($errors->has('name') ? $errors->first('name') : '') }}
		</div>

		<div class="form-group {{ ($errors->has('cache_on_delivery')) ? 'has-error' : '' }}">
			{{ Form::label( 'cache_on_delivery', 'Наценка на заказ за наложенный платеж:', array('class' => 'control-label') ) }}
			{{ Form::text('cache_on_delivery', $project->cache_on_delivery, array('class' => 'form-control', 'placeholder' => 'Наценка на заказ за наложенный платеж', 'autofocus')) }}
			{{ ($errors->has('cache_on_delivery') ? $errors->first('cache_on_delivery') : '') }}
		</div>

		<div class="form-group {{ ($errors->has('cost_post_delivery')) ? 'has-error' : '' }}">
			{{ Form::label( 'cost_post_delivery', 'Стоимость доставки почтой:', array('class' => 'control-label') ) }}
			{{ Form::text('cost_post_delivery', $project->cost_post_delivery, array('class' => 'form-control', 'placeholder' => 'Наценка на заказ за наложенный платеж', 'autofocus')) }}
			{{ ($errors->has('cost_post_delivery') ? $errors->first('cost_post_delivery') : '') }}
		</div>

		{{ Form::label('Тип проекта') }}
		<div class="form-group">
			<label class="radio-inline">
				{{ Form::radio('type', Project::TYPE_SHOP, (!$project->type || $project->type == Project::TYPE_SHOP) ? 1 : 0) }} Интернет магазин
			</label>
			<br/>
			<label class="radio-inline">
				{{ Form::radio('type', Project::TYPE_HR, ($project->type == Project::TYPE_HR) ? 1 : 0) }} Отдел кадров
			</label>
		</div>

		<div class="form-group">
			<label class="checkbox-inline">
				{{ Form::checkbox('usecrm', 1, $project->usecrm ? 1 : 0) }} использовать CRM систему
			</label>
			<br/>
			<div class="form-group">
        <label class="checkbox-inline">
          {{ Form::checkbox('usebudget', 1, $project->usebudget ? 1 : 0) }} вести бюджет
        </label>
        <br/>
        Дата закрытия месяца в бюджете (операции закрываются не вкл. это число):
        <br/>
        <label class="radio-inline">
          {{ Form::radio('budget_close_day', 1, ( $project->budget_close_day == 1 || $project->budget_close_day == 0 ) ? 1 : 0) }} 1
        </label>
        <label class="radio-inline">
          {{ Form::radio('budget_close_day', 6, $project->budget_close_day == 6 ? 1 : 0) }} 6
        </label>
      </div>
			<label class="checkbox-inline">
				{{ Form::checkbox('usecheckcalls', 1, $project->usecheckcalls ? 1 : 0) }} контролировать звонки
			</label>
			<br/>
			<label class="checkbox-inline">
				{{ Form::checkbox('usepayroll', 1, $project->usepayroll ? 1 : 0) }} расчитывать зарплату
			</label>
		</div>

		{{ Form::label('Участники проекта') }}
		<div class="form-group">
			@foreach ($users as $user)
			<label class="checkbox-inline">
				<input type="checkbox" name="projectUsers[{{ $user->id }}]" value='1'
				{{ (in_array($user->id, $projectUsers) ? 'checked="checked"' : '') }} > {{ $user->first_name }} {{ $user->last_name }}
			</label>
			<br/>
			@endforeach
		</div>

		{{--
		@foreach ($fines as $fine)
		<div class="form-group">
			{{ Form::label('Штраф за ' . $fine->name) }}
			{{ Form::text('projectFines['.$fine->id.']', isset($projectFines[$fine->id])?$projectFines[$fine->id]['value']:0, array('class' => 'form-control')) }}
		</div>
		@endforeach
		--}}

		{{ Form::hidden('id', $project->id) }}
		{{ Form::submit('Сохранить изменения', array('class' => 'btn btn-primary')) }}
		{{ Form::button('Отмена', array('class' => 'btn btn-default', 'onclick'=>'location="'.URL::to('projects').'"')) }}

    {{ Form::close() }}
	</div>
</div>

@stop