@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/debtpartners?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>
					</tr>
				</thead>
				<tbody>
					@foreach ($budgetDebtPartners as $budgetDebtPartner)
					<tr>
						<td>
							<p>
                              <b class="{{ $budgetDebtPartner->debet_project_id }}">{{ isset($budgetDebtPartner->debet_project_id)? $budgetDebtPartner->deb_project['name'] : $budgetDebtPartner->name }}</b>
								@if ($budgetDebtPartner->cost)
								<small>
									<br/>Расходы списываются как <b>{{ $budgetDebtPartner->cost->name }}</b>
								</small>
								@endif
							</p>
						</td>
						<td>
							@if(!isset($budgetDebtPartner->deb_project['id']))
							<button class="btn btn-sm btn-default" onClick="location.href ='{{ action('BudgetDebtPartnersController@edit', $budgetDebtPartner->id) }}'">Редактировать</button>
							@endif
							<button class="btn btn-sm btn-default action_confirm" type="button" data-method="delete" data-confirm-text="Вы уверены, что хотите удалить контрагента?" href="{{ action('BudgetDebtPartnersController@destroy', $budgetDebtPartner->id) }}">Удалить</button>
						</td>
					</tr>
					@endforeach
				</tbody>
			</table>
		</div>

		<button class="btn btn-primary" onClick="location.href ='{{ action('BudgetDebtPartnersController@create') }}'">Добавить контрагента</button>
	</div>
</div>

<div id="confirmModal" class="modal fade" role="dialog" style="display: none;" aria-hidden="true">
  <div class="modal-dialog">					
    <div class="modal-content">						
      <div class="modal-header">							
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>							
        <h3 id="confirmModalCaption">Подтвердите удаление</h3>						
      </div>						
      <div class="modal-body">							
        <p id="confirmModalText"></p>						
      </div>						
      <div class="modal-footer">							
        <button class="btn btn-primary" id="confirmModalBtnOk">Да</button>							
        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Нет</button>						
      </div>					
    </div>				
  </div>			
</div>
@stop
