@if(!Request::is('budget/reports*'))
  @if($user->budgetProjects->count() > 1)
	<div class="well well-sm">
		@foreach ($user->budgetProjects()->get() as $project)
			<?php $countRequests = $project->getCountRequestProject(); ?>
			<a href="/{{ Request::path() }}?projectId={{ $project->id }}" class="btn btn-sm btn-default @if ($workProject->id == $project->id) active @endif">{{ $project->name }}<b>{{ $countRequests? ' ('.$countRequests.')' : '' }}</b></a>
		@endforeach
	</div>
	@endif

	<div class="panel-heading" style="padding-bottom:0">
		@if (!Request::is('budget/archive'))
			@include('budget/operations/btns')
		@endif
		@if ($workProject->budgetUploads()->orderBy('created_at', 'DESC')->first())
		<p class="pull-right" style="line-height:1em;margin-right:15px">
			<small>
				<b>
					Последняя загрузка на<br/>
					{{ $workProject->budgetUploads()->orderBy('created_at', 'DESC')->first()->budgetAccount->name }}, <span class="date-to-humanize" data-date="{{ $workProject->budgetUploads()->orderBy('created_at', 'DESC')->first()->created_at }}">{{ $workProject->budgetUploads()->orderBy('created_at', 'DESC')->first()->created_at }}</span>
				</b>
			</small>
		</p>
		@endif
		<ul class="nav nav-tabs" style="border-bottom:0">
		@if (Auth::user()->hasAnyRole(array(Role::ROLE_BUDGET_VIEW_OPERATIONS, Role::ROLE_BUDGET, Role::ROLE_BUDGET_ACCOUNTANT)))
			<li{{ (Request::is('budget') ? ' class="active"' : '') }}><a href="{{ URL::to('budget') }}">Бюджет</a></li>
			<li{{ (Request::is('budget/operations') ? ' class="active"' : '') }}><a href="{{ URL::to('budget/operations') }}">Операции</a></li>
			<li{{ (Request::is('budget/archive') ? ' class="active"' : '') }}><a href="{{ URL::to('budget/archive') }}">Архив</a></li>
      <?php
        $budgetCloseDay = ($workProject->budget_close_day)? $workProject->budget_close_day : 1;
      ?>
			@if($user->hasRole(Role::ROLE_BUDGET) && BudgetOperation::whereProjectId($workProject->id)->whereRaw( DB::raw('DATE(date) < '.date("'Y-m-".$budgetCloseDay."'")) )->count() || ! date('d') >= $budgetCloseDay)
			<li{{ (Request::is('budget/showclosemonth') ? ' class="active"' : '') }}><a href="{{ URL::to('budget/showclosemonth') }}"><b>Закрытие месяца</b></a></li>
			@endif
		@endif
			@if (Auth::user()->hasAnyRole(array(Role::ROLE_BUDGET_OUTCOMING_REQUEST, Role::ROLE_BUDGET_CFO, Role::ROLE_BUDGET_ACCOUNTANT, Role::ROLE_BUDGET_ACC_SECRETARY)))
			<li{{ (Request::is('budget/costsrequests*') ? ' class="active"' : '') }}><a href="{{ URL::to('budget/costsrequests') }}">Заявки на расход</a></li>
			@endif
      @if (Auth::user()->hasAnyRole(array(Role::ROLE_BUDGET, Role::ROLE_BUDGET_ACCOUNTANT, Role::ROLE_BUDGET_SALARY_MANAGMENT)))
			<li {{ ((Request::is('budget/salary*')) ? 'class="active"' : '') }}>
				<a href="{{ URL::to('budget/salary') }}">Зарплата</a>
			</li>
			@endif
		</ul>
	</div>
@else
  <div class="panel-heading" style="padding-bottom:0">
		<ul class="nav nav-tabs" style="border-bottom:0">
		@if (Auth::user()->hasRole(Role::ROLE_BUDGET))
		  <li><a class="btn disabled text-bold"> По проекту: </a></li>
			<li{{ (Request::is('budget/reports/totalcosts*') && !Request::is('budget/reports/totalcosts/all') && !Request::is('budget/reports/totalcosts/archive') ? ' class="active"' : '') }}><a href="{{ URL::to('budget/reports/totalcosts') }}/{{ $workProject->id }}">Расходы по месяцам</a></li>
			<li{{ (Request::is('budget/reports/chartStat') ? ' class="active"' : '') }}><a href="{{ action('BudgetController@chartStat') }}">Графики прихода/расхода</a></li>
			<li><a class="btn disabled text-bold"> Общие: </a></li>
			<li{{ (Request::is('budget/reports/totalcosts/all') ? ' class="active"' : '') }}><a href="{{ URL::to('budget/reports/totalcosts/all') }}">Текущий месяц</a></li>
			<li{{ (Request::is('budget/reports/totalcosts/archive') ? ' class="active"' : '') }}><a href="{{ URL::to('budget/reports/totalcosts/archive') }}">Архив</a></li>
		@endif
		</ul>
	</div>
@endif
