@extends('layouts.default')

@section('title')
@parent
  Заявки на расход :: Бюджет для "{{ $workProject->name }}"
@stop

@section('breadcrumbs')
	{{ Breadcrumbs::render('budget.costsrequests', $workProject) }}
@stop

@section('css')
  <link rel="stylesheet" href="{{asset('css/jquery.fileupload.css')}}">
	<link rel="stylesheet" href="{{ asset('css/bootstrap-validator.min.css') }}">
@stop

@section('js')
  <script src="{{asset('js/jquery.fileupload.js')}}"></script>
	<script src="{{asset('js/jquery.iframe-transport.js')}}"></script>
	<script src="{{ asset('js/plugin/x-editable/x-editable.min.js') }}"></script>
	<script src="{{ asset('js/plugin/bootstrapvalidator/bootstrapValidator.min.js') }}"></script>
	<script src="{{ asset('js/kmk-support.js') }}"></script>
	<script src="{{ asset('js/costsRequests.js') }}"></script>
@stop

@section('content')
<div class="row">
	<?php 
		$projectAmount = $workProject->getCurrentBudgetMonthPlan(); // бюджет проекта
		$userType = '';
		$signRequest = 0;
		if( Auth::user()->hasRole(Role::ROLE_BUDGET_OUTCOMING_REQUEST) ){
			$userType = 1;
		}else if( Auth::user()->hasRole(Role::ROLE_BUDGET_CFO) ){
			$userType = 2;
		}else if( Auth::user()->hasAnyRole(array(Role::ROLE_BUDGET_ACCOUNTANT, Role::ROLE_BUDGET_ACC_SECRETARY)) ){
			$userType = 3;
		}
		
		if( Auth::user()->hasRole(Role::ROLE_BUDGET_SIGN_COST_REQUEST) ){
			$signRequest = 1;
		}
		$statusType = Session::get('statusType');
		Session::put('userType', $userType);
		Session::put('signRequest', $signRequest);
	?>
  <div class="col-md-12 col-lg-12 col-sm-12">
		<div class="panel panel-default">
			@include('budget/menu')
			<div class="panel-body">
			  @include('budget/costsrequests/btns')
				<!--<form class="form-inline pull-right" role="form">
					<div class="form-group">
						<input id="startDate" name="startDate" class="form-control input-sm" value="{{-- $startDate --}}"/>
					</div>
					<div class="form-group">
						<input id="endDate" name="endDate" class="form-control input-sm" value="{{-- $endDate --}}"/>
					</div>
				</form>-->
				<div class="clearfix"></div>
				<div class="table-responsive">
					<table class="table table-condensed table-hover">
						<thead>
							<tr>
								<th>#</th>
                <th>@if( Auth::user()->isAdmin() ) <!--datetype = создано/подписано/одобрено/отказано/оплачено--> <a href="{{ action('BudgetCostsRequestsController@costsRequestsSearch')}}?type=all&content=&datetype=создано&beginDate={{ date('d.m.Y') }}&endDate={{ date('d.m.Y') }}"> Дата </a> @else Дата @endif</th>
								<th>Статья расходов</th>
								@if( ($userType != 3 || ($statusType == 'my' && $userType == 3)) && $statusType != 'paid')
								  <th class="text-center">Бюджет</th>
								@elseif( $statusType == 'paid' || $userType == 3 )
								<th class="text-right" title="Номер платежного поручения при безналичной оплате">№ п/п</th>
								@endif
								<th>Файлы</th>
								<th class="text-right">Сумма</th>
								<th class="table-comment">Комментарий</th>
							</tr>
						</thead>
						<tbody id='budgetCostsRequestContainer'>
							@foreach($costsRequests as $costsRequest)
							  @include('budget/costsrequests/operation')
							@endforeach
						</tbody> 
					</table>
				</div>
				<dl class="dl-horizontal">
					<dt>Заявок на сумму: </dt>
					<!--<button class="btn-success" id="testBtnOlo"> удалить </button>-->
					<dd><span id="totalRequestsSum" class="to-humanize"> </span> <i class="fa fa-rub"></i></dd>
					<dt>Кол-во: </dt>
					<dd><span id="totalRequestsCount" class="to-humanize"> </span></dd>
				</dl>
			</div>
		</div>
	</div>
</div>

	@section('modals')
		@include('budget/costsrequests/modal')
	@stop
@stop