@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/costs?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 width="35%">Шаблоны</th>
						<th class="text-right">Планируемая сумма расходов за месяц</th>
						<th>Действия</th>
					</tr>
				</thead>
				<tbody>
					@foreach ($budgetCosts as $budgetCost) 
					<tr>
						<td>
							<p>
								<b>{{ $budgetCost->name }}</b>
								<br/>
								{{  $budgetCost->getManagedName() }}
							</p>
						</td>
						<td>
							<p>
								<b>{{ ($budgetCost->budgetCostGroup)? $budgetCost->budgetCostGroup->name:'-' }}</b>								
							</p>
						</td>
						<td>
							<p>
								{{ nl2br($budgetCost->template) }}
							</p>
						</td>
						<td class="text-right">
							<p>
								<b><span class="to-humanize">{{ $budgetCost->planAmount }}</span> <i class="fa fa-rub"></i></b>
							</p>
						</td>
						<td>
							<?php 
								if ($budgetCost->project_id) {
									$hidden = '';
								}else{
									$hidden = ' hidden';
								}; ?> 
							<button class="btn btn-sm btn-default{{ $hidden }}" onClick="location.href ='{{ action('BudgetCostsController@edit', $budgetCost->id) }}'">Редактировать</button>
							<button class="btn btn-sm btn-default action-confirm ladda-button{{ $hidden }}" data-style="zoom-out" type="button" data-method="post" data-confirm-text="Вы уверены что хотите удалить статью расходов?" data-action="{{ action('BudgetCostsController@destroy', $budgetCost->id) }}">Удалить</button>
						</td>
					</tr>
					@endforeach
				</tbody>
			</table>
		</div>

		<button class="btn btn-primary" onClick="location.href ='{{ action('BudgetCostsController@create') }}'">Добавить статью расходов</button>
	</div>
</div>
@stop
