@extends('layouts.default')

@section('title')
	@parent
	Контрагенты :: Бюджет для "{{ $workProject->name }}"
@stop

@section('content')
<div class="row">
  <div class="col-md-12">
		@if($user->budgetProjects->count() > 1)
		<div class="well well-sm">
			@foreach ($user->budgetProjects()->get() as $project)
			<a href="/budget/partners?projectId={{ $project->id }}" class="btn btn-sm btn-default @if ($workProject->id == $project->id) active @endif">{{ $project->name }}</a>
			@endforeach
		</div>
		@endif

		<h4>Контрагенты для "{{ $workProject->name }}"</h4>
		<div class="table-responsive">
			<table class="table table-striped table-hover">
				<thead>
					<tr>
						<th>Название</th>
						<th>Город</th>
						<th>Р/С</th>
						<th>Действия</th>
					</tr>
				</thead>
				<tbody>
					@foreach ($budgetPartners as $budgetPartner)
					<tr>
						<td>
							<p>
								<b>{{ $budgetPartner->name }}</b>
								@if ($budgetPartner->cost)
								<small>
									<br/>Расходы списываются как <b>{{ $budgetPartner->cost->name }}</b>
								</small>
								@endif
							</p>
						</td>
						<td>
							<p>
								{{ $budgetPartner->city }}
							</p>
						</td>
						<td>
							<p>
								{{ $budgetPartner->current_account }}
							</p>
						</td>
						<td>
							<button class="btn btn-sm btn-default" onClick="location.href ='{{ action('BudgetPartnersController@edit', $budgetPartner->id) }}'">Редактировать</button>
							<button class="btn btn-sm btn-default action_confirm" type="button" data-method="delete" data-confirm-text="Вы уверены что хотите удалить место хранения?" href="{{ action('BudgetPartnersController@destroy', $budgetPartner->id) }}">Удалить</button>
						</td>
					</tr>
					@endforeach
				</tbody>
			</table>
		</div>

		<button class="btn btn-primary" onClick="location.href ='{{ action('BudgetPartnersController@create') }}'">Добавить контрагента</button>
	</div>
</div>
@stop
