<div class="panel-heading" id="refrenceStatusBtns" data-status-type="{{ $input['statusType'] }}" style="padding-bottom:0">
	<ul class="nav nav-tabs" style="border-bottom:0">
		@if (User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_AGENT) && !Sentry::getUser()->hasAccess('admin'))
		<li style="margin:10px 15px">Необработанные заявки ({{ Lead::whereAgentId(Sentry::getUser()->id)->count() }})</li>
		<li @if ($input['statusType'] == 'work') class="active" @endif><a id="refrence_btn_work" data-status-type="work" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">В работе ({{ Partner::my(array('statusType' => 'work'))->checkStatus(array('statusType' => 'work'))->count() }})</span></a></li>
		<li @if ($input['statusType'] == 'reject') class="active" @endif><a id="refrence_btn_work" data-status-type="reject" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Отказ ({{ Partner::my(array('statusType' => 'reject'))->checkStatus(array('statusType' => 'reject'))->count() }})</span></a></li>
		<li @if ($input['statusType'] == 'agreedagent') class="active" @endif><a id="refrence_btn_work" data-status-type="agreedagent" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Оформленные ({{ Partner::my(array('statusType' => 'agreedagentinwork'))->checkStatus(array('statusType' => 'agreedagentinwork'))->count() }})</span></a></li>
		@endif
		@if (User::find(Sentry::getUser()->id)->hasAnyRole(array(Role::ROLE_CRM, Role::ROLE_FRANCHISEES)))
		<li @if ($input['statusType'] == 'work') class="active" @endif><a id="refrence_btn_work" data-status-type="work" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">В работе ({{ Partner::my(array('statusType' => 'work'))->checkStatus(array('statusType' => 'work'))->count() }})</span></a></li>
		<li @if ($input['statusType'] == 'noanswer') class="active" @endif><a id="refrence_btn_work" data-status-type="noanswer" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Недозвон ({{ Partner::my(array('statusType' => 'noanswer'))->checkStatus(array('statusType' => 'noanswer'))->count() }})</span></a></li>
		<li @if ($input['statusType'] == 'reject') class="active" @endif><a id="refrence_btn_work" data-status-type="reject" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Отказ ({{ Partner::my(array('statusType' => 'reject'))->checkStatus(array('statusType' => 'reject'))->count() }})</span></a></li>
		@endif
		@if (User::find(Sentry::getUser()->id)->hasAnyRole(array(Role::ROLE_CRM, Role::ROLE_LOGISTICS)))
		<li @if ($input['statusType'] == 'paywaiting') class="active" @endif><a id="refrence_btn_work" data-status-type="paywaiting" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Ожидают оплаты ({{ Partner::my(array('statusType' => 'paywaiting'))->checkStatus(array('statusType' => 'paywaiting'))->count() }})</span></a></li>
		@endif
		@if (User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_FRANCHISEES) && !Sentry::getUser()->hasAccess('admin'))
		<!--<li @if ($input['statusType'] == 'checkpatterns') class="active" @endif><a id="refrence_btn_work" data-status-type="checkpatterns" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Проверка лекал ({{ Partner::my(array('statusType' => 'checkpatterns'))->checkStatus(array('statusType' => 'checkpatterns'))->count() }})</span></a></li>-->
		<li @if ($input['statusType'] == 'agreedfranchisees') class="active" @endif><a id="refrence_btn_work" data-status-type="agreedfranchisees" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Оформленные ({{ Partner::my(array('statusType' => 'agreedfranchiseesinwork'))->checkStatus(array('statusType' => 'agreedfranchiseesinwork'))->count() }})</span></a></li>
		@endif
		@if (User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_LOGISTICS))
		<!--<li @if ($input['statusType'] == 'checkpatterns') class="active" @endif><a id="refrence_btn_work" data-status-type="checkpatterns" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Проверка лекал ({{ Partner::my(array('statusType' => 'checkpatterns'))->checkStatus(array('statusType' => 'checkpatterns'))->count() }})</span></a></li>-->
		<li @if ($input['statusType'] == 'agreed') class="active" @endif><a id="refrence_btn_work" data-status-type="agreed" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Оформленные ({{ Partner::my(array('statusType' => 'agreedinwork'))->checkStatus(array('statusType' => 'agreedinwork'))->count() }})</span></a></li>
		<li @if ($input['statusType'] == 'agreedfranchisees') class="active" @endif><a id="refrence_btn_work" data-status-type="agreedfranchisees" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Оформленные франчайзи ({{ Partner::my(array('statusType' => 'agreedfranchiseesinwork'))->checkStatus(array('statusType' => 'agreedfranchiseesinwork'))->count() }})</span></a></li>
		@endif
		@if (User::find(Sentry::getUser()->id)->hasAnyRole(array(Role::ROLE_CRM, Role::ROLE_LOGISTICS)))
		<li @if ($input['statusType'] == 'production') class="active" @endif><a id="refrence_btn_work" data-status-type="production" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Производство ({{ Partner::my(array('statusType' => 'production'))->checkStatus(array('statusType' => 'production'))->count() }})</span></a></li>
		<li @if ($input['statusType'] == 'packing') class="active" @endif><a id="refrence_btn_work" data-status-type="packing" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Упаковка ({{ Partner::my(array('statusType' => 'packing'))->checkStatus(array('statusType' => 'packing'))->count() }})</span></a></li>
		<li @if ($input['statusType'] == 'change') class="active" @endif><a id="refrence_btn_work" data-status-type="change" href="#" class="ladda-button" data-style="zoom-out"><span class="ladda-label">Обмен ({{ Partner::my(array('statusType' => 'change'))->checkStatus(array('statusType' => 'change'))->count() }})</span></a></li>
		@endif
	</ul>
</div>
<div class="panel-body">
	@if (isset($input))
		<div id="partnersFiltr">
			<div>
				@if ($input['statusType'] == 'reject')
					<button class="btn btn-default btn-sm @if (!$input['status'] && !$input['rejectId']) active @endif ladda-button" data-style="zoom-out" data-filter-name="status" data-filter-value="">Все</button>
					<button class="btn btn-default btn-sm @if ($input['status'] == Partner::STATUS_DELIVERING_FAIL) active @endif ladda-button" data-style="zoom-out" data-filter-name="status" data-filter-value="{{ Partner::STATUS_DELIVERING_FAIL }}">Отказался забирать</button>
					<button class="btn btn-default btn-sm @if ($input['status'] == Partner::STATUS_WAIT_CLIENT_PAY_FAIL) active @endif ladda-button" data-style="zoom-out" data-filter-name="status" data-filter-value="{{ Partner::STATUS_WAIT_CLIENT_PAY_FAIL }}">Отказался платить предоплату</button>
					@foreach ($user->projects as $project)
						@foreach ($project->rejects as $reject)
							<button class="btn btn-default btn-sm @if ($input['rejectId'] == $reject->id) active @endif ladda-button" data-style="zoom-out" data-filter-name="rejectId" data-filter-value="{{ $reject->id }}">{{ $reject->name }}</button>
						@endforeach
					@endforeach
				@endif
				@if ($input['statusType'] == 'paywaiting')
					@if (User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_CRM))
						<button class="btn btn-default btn-sm @if (!$input['status']) active @endif ladda-button" data-style="zoom-out" data-filter-name="status" data-filter-value="">Все</button>
						<button class="btn btn-default btn-sm @if ($input['status'] == Partner::STATUS_WAIT_CLIENT_PAY_CONFIRM) active @endif ladda-button" data-style="zoom-out" data-filter-name="status" data-filter-value="{{ Partner::STATUS_WAIT_CLIENT_PAY_CONFIRM }}">Клиент говорит что оплатил ({{ Partner::my(array('statusType' => 'paywaiting', 'status' => Partner::STATUS_WAIT_CLIENT_PAY_CONFIRM))->checkStatus(array('statusType' => 'paywaiting', 'status' => Partner::STATUS_WAIT_CLIENT_PAY_CONFIRM))->count() }})</button>
						<button class="btn btn-default btn-sm @if ($input['status'] == Partner::STATUS_WAIT_CLIENT_PAY) active @endif ladda-button" data-style="zoom-out" data-filter-name="status" data-filter-value="{{ Partner::STATUS_WAIT_CLIENT_PAY }}">Ожидают предоплаты ({{ Partner::my(array('statusType' => 'paywaiting', 'status' => Partner::STATUS_WAIT_CLIENT_PAY))->checkStatus(array('statusType' => 'paywaiting', 'status' => Partner::STATUS_WAIT_CLIENT_PAY))->count() }})</button>
					@endif
					@if (User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_LOGISTICS))
						<button class="btn btn-default btn-sm @if ($input['status'] == Partner::STATUS_WAIT_TRANSPORT_COMPANY_PAY) active @endif ladda-button" data-style="zoom-out" data-filter-name="status" data-filter-value="{{ Partner::STATUS_WAIT_TRANSPORT_COMPANY_PAY }}">Ожидают деньги от транспортной ({{ Partner::my(array('statusType' => 'paywaiting', 'status' => Partner::STATUS_WAIT_TRANSPORT_COMPANY_PAY))->checkStatus(array('statusType' => 'paywaiting', 'status' => Partner::STATUS_WAIT_TRANSPORT_COMPANY_PAY))->count() }})</button>
					@endif
				@endif
				@if ($input['statusType'] == 'agreed' && User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_LOGISTICS))
					<button class="btn btn-default btn-sm @if ($input['type'] == 'registration') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="registration">Оформление документов ({{ Partner::my(array('statusType' => 'agreed', 'type' => 'registration'))->checkStatus(array('statusType' => 'agreed', 'type' => 'registration'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'waitdelivery') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="waitdelivery">Ожидание доставки ({{ Partner::my(array('statusType' => 'agreed', 'type' => 'waitdelivery'))->checkStatus(array('statusType' => 'agreed', 'type' => 'waitdelivery'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'waitsend') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="waitsend">Ожидание отправки ({{ Partner::my(array('statusType' => 'agreed', 'type' => 'waitsend'))->checkStatus(array('statusType' => 'agreed', 'type' => 'waitsend'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'delivery') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="delivery">Доставка ({{ Partner::my(array('statusType' => 'agreed', 'type' => 'delivery'))->checkStatus(array('statusType' => 'agreed', 'type' => 'delivery'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'success') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="success">Доставлено ({{ Partner::my(array('statusType' => 'agreed', 'type' => 'success'))->checkStatus(array('statusType' => 'agreed', 'type' => 'success'))->count() }})</button>
				@endif
				@if ($input['statusType'] == 'agreedfranchisees' && User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_LOGISTICS))
					<button class="btn btn-default btn-sm @if ($input['type'] == 'sizing') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="sizing">Снятие размера ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'sizing'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'sizing'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($needDepositQuant = Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'depositadd'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'depositadd'))->count()) btn-danger @endif  @if ($input['type'] == 'depositadd') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="depositadd">Пополнить депозит ({{ $needDepositQuant }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'production') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="production">Производство ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'production'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'production'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'registration') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="registration">Оформление документов ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'registration'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'registration', 'all_count' => true))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'waitdelivery') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="waitdelivery">Ожидание доставки ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'waitdelivery'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'waitdelivery'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'waitsend') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="waitsend">Ожидание отправки ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'waitsend'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'waitsend'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'delivery') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="delivery">Доставка ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'delivery'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'delivery'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'success') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="success">Доставлено ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'success'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'success'))->count() }})</button>
				@endif
				@if ($input['statusType'] == 'agreedfranchisees' && User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_FRANCHISEES) && !Sentry::getUser()->hasAccess('admin'))
					<button class="btn btn-default btn-sm @if ($input['type'] == 'sizing') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="sizing">Снятие размера ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'sizing'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'sizing'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($needDepositQuant = Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'depositadd'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'depositadd'))->count()) btn-danger @endif  @if ($input['type'] == 'depositadd') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="depositadd">Пополнить депозит ({{ $needDepositQuant }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'production') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="production">Производство ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'production'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'production'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'commondelivery') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="commondelivery">Доставка ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'commondelivery'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'commondelivery'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'waitclient') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="waitclient">Ожидание клиента ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'waitclient'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'waitclient'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'waitpay') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="waitpay">Ожидание оплаты от транспортной ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'waitpay'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'waitpay'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'success') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="success">Доставлено ({{ Partner::my(array('statusType' => 'agreedfranchisees', 'type' => 'success'))->checkStatus(array('statusType' => 'agreedfranchisees', 'type' => 'success'))->count() }})</button>
				@endif
				@if ($input['statusType'] == 'agreedagent' && User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_AGENT) && !Sentry::getUser()->hasAccess('admin'))
					<button class="btn btn-default btn-sm @if ($input['type'] == 'delivery') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="delivery">Доставка ({{ Partner::my(array('statusType' => 'agreedagent', 'type' => 'delivery'))->checkStatus(array('statusType' => 'agreedagent', 'type' => 'delivery'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'waitpay') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="waitpay">Ожидание оплаты ({{ Partner::my(array('statusType' => 'agreedagent', 'type' => 'waitpay'))->checkStatus(array('statusType' => 'agreedagent', 'type' => 'waitpay'))->count() }})</button>
					<button class="btn btn-default btn-sm @if ($input['type'] == 'success') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="success">Доставлено ({{ Partner::my(array('statusType' => 'agreedagent', 'type' => 'success'))->checkStatus(array('statusType' => 'agreedagent', 'type' => 'success'))->count() }})</button>
				@endif
				@if ($input['statusType'] == 'production' && User::find(Sentry::getUser()->id)->hasAnyRole(array(Role::ROLE_CRM, Role::ROLE_LOGISTICS)))
					<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'sizing') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="sizing">Снятие размеров ({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'sizing'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'sizing'))->count() }})</button>
					<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'wait') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="wait">Ожидают в очереди ({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'wait'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'wait'))->count() }})</button>
					<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'process') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="process">Производятся ({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'process'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'process'))->count() }})</button>
				@endif
				@if ($input['statusType'] == 'packing' && User::find(Sentry::getUser()->id)->hasAnyRole(array(Role::ROLE_CRM, Role::ROLE_LOGISTICS, Role::ROLE_PACKING)))
					<!--<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'success') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="success">Ожидают упаковки ({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'success'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'success'))->count() }})</button>-->
					<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'wait') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="wait">Ожидают упаковки({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'wait'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'wait'))->count() }})</button>
					<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'process') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="process"> Упаковываются({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'process'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'process'))->count() }})</button>
				@endif
				@if ($input['statusType'] == 'change' && User::find(Sentry::getUser()->id)->hasAnyRole(array(Role::ROLE_CRM, Role::ROLE_LOGISTICS)))
					<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'wait') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="wait">Ожидает обмена({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'wait'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'wait'))->count() }})</button>
					<button class="btn btn-default btn-sm @if (isset($input['type']) && $input['type'] == 'success') active @endif ladda-button" data-style="zoom-out" data-filter-name="type" data-filter-value="success"> Обмен подтвержден({{ Partner::my(array('statusType' => $input['statusType'], 'type' => 'success'))->checkStatus(array('statusType' => $input['statusType'], 'type' => 'success'))->count() }})</button>
				@endif
			</div>
			@if ($input['statusType'] == 'agreed' && User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_LOGISTICS))
				@if ($dates)
					<br/>
					<div>
						@foreach ($dates as $key=>$value)
							<button class="btn btn-default btn-sm @if (isset($input['date']) && $input['date'] == $key) active @endif ladda-button" data-style="zoom-out" data-filter-name="date" data-filter-value="{{ $key }}">{{ $value }} ({{ Partner::my(array('statusType' => $input['statusType'], 'type' => $input['type']))->checkStatus(array('statusType' => $input['statusType'], 'type' => $input['type']))->whereRaw(DB::raw("DATE(datetime_of_agree)='".$key."'"))->count() }})</button>
						@endforeach
					</div>
				@endif
			@endif
			@if ($input['statusType'] == 'agreedfranchisees' && $input['type'] == 'registration' && User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_LOGISTICS))
				@if ($franchiseesList)
					<br/>
					<div>
						Отправка до франчайзи:
						@foreach ($franchiseesList as $franchisees)
							<button class="btn btn-default btn-sm @if (isset($input['user_id']) && $input['user_id'] == $franchisees['id']) active @endif ladda-button" data-style="zoom-out" data-filter-name="user_id" data-filter-value="{{ $franchisees['id'] }}">{{ $franchisees['first_name'] }} {{ $franchisees['last_name'] }} ({{ Partner::my(array('statusType' => $input['statusType'], 'type' => $input['type'], 'user_id' => $franchisees['id']))->checkStatus(array('statusType' => $input['statusType'], 'type' => $input['type'], 'user_id' => $franchisees['id']))->count() }})</button>
						@endforeach
					</div>
				@endif
			@endif
		</div>
	@endif

	@if (isset($input) && ($input['statusType'] == 'agreed' || $input['statusType'] == 'agreedfranchisees') && $input['type'] == 'waitdelivery' && $partners->count())
		{{ Form::open(array('action' => array('PartnerController@sendChecked'), 'id' => 'deliveryCheckedFrom')) }}
	@endif
	@if (isset($input) && ($input['statusType'] == 'agreed' || $input['statusType'] == 'agreedfranchisees') && $input['type'] == 'waitsend' && $partners->count())
		{{ Form::open(array('action' => array('PartnerController@sendChecked'), 'id' => 'sendCheckedFrom')) }}
	@endif
	<table class="table table-striped table-hover">
		<thead>
			<th>Клиент</th>
			<th>Информация</th>
			<th style="width:300px">Комментарий</th>
			<th class="lead-actions">Действия</th>
		</thead>
		<tbody>
			@if (isset($input) && $input['statusType'] == 'agreed' && $input['type'] == 'registration')
		    <a class="btn btn-large btn-info pull-right" href="{{ action('ShipmentsController@downloadPostExport') }}">Скачать файл для почты</a>
	    @endif
			@foreach ($partners as $partner)
				@if (!isset($partner->hide) || !$partner->hide)
				<tr @if ($input['statusType'] == 'work') class="{{ $partner->getStatusClass() }}" @endif>
					<td>
						<p id="refrence_info_{{ $partner->id }}">
							<b>№{{ $partner->id }}</b><br/>
							@if(User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_LOGISTICS) && $partner->user->hasRole(Role::ROLE_FRANCHISEES) && $partner->pickup)
								Имя: {{ $partner->user->last_name }} {{ $partner->user->first_name }}<br/>
							@else
								Имя: {{ $partner->name }}<br/><br/>
							@endif
							@if($partner->user->hasRole(Role::ROLE_FRANCHISEES) && $partner->pickup)
								Доставка до франчайзи<br/>
								@if($partner->user->delivery_to)
								Доставка до транспортной компании
								@endif
								Город: {{ $partner->user->city }}<br/>
								Адрес: {{ $partner->user->address }}<br/>
								Стоимость доставки: <span class="to-humanize">{{ $partner->user->delivery_price }}</span> <i class="fa fa-rub"></i>
							@else
								@if($partner->city) Город: {{ $partner->city }}<br/> @endif
								@if($partner->address) Адрес: {{ $partner->address }}<br/> @endif
							@endif
							{{--
							Телефон: <span class="phone-to-humanize">{{ $partner->phone }}</span><br/>
							E-mail: {{ $partner->email }}<br/>
							--}}
						</p>
						@if ($partner->lead && $partner->lead->getDataArray())
						<p>
							<?php
								$data = $partner->lead->getDataArray();
							?>
							@if(isset($data['transaction_id']))
								<b>Lead-R : {{ $data['transaction_id'] }},</b>
							@endif
						</p>
						@endif
						@if ($partner->lead)
						<b>{{ $partner->lead->referrer_host }}</b>
						@endif
						<p id="partner_info_{{ $partner->id }}_comment">@if($partner->comment) Примечание: {{ nl2br($partner->comment) }} @endif</p>
					</td>
					<td class="project-name">
						<p>
							@if ($partner->status >= 10)
							<big>{{ $partner->getTransportTypeName() }}</big><br/>
							@endif
							@if ($partner->getStatusName())
								<big>{{ $partner->getStatusName() }}</big><br/>
							@endif
							@if ($partner->datetime_of_agree && $partner->status != Partner::STATUS_WAIT_CLIENT_PAY)
								<b>Оформлен <span class="date-to-humanize" data-date="{{ $partner->datetime_of_agree }}">{{ $partner->datetime_of_agree }}</span></b><br/>
							@endif
							@if ($partner->isStatusToWork())
								<b>Связаться <span id="nextDateTime_{{ $partner->id }}" class="date-to-humanize" data-date="{{ $partner->salenextdatetime }}">{{ $partner->salenextdatetime }}</span></b><br/>
							@endif
							@if ($partner->status == Partner::STATUS_WAIT_CLIENT_PAY_CONFIRM)
								Говорит что оплатил <span class="to-humanize">{{ $partner->paidsum }}</span> <i class="fa fa-rub"></i><br/>
							@endif
							@if ($user->projects->count() > 1)
								{{ $partner->project->name }}<br/>
							@endif
							@if ($partner->lead && $partner->status == Partner::STATUS_WORK)
							Заявка на {{ $partner->lead->entrypoint }}<br/>
							@endif
							@if ($partner->status == Partner::STATUS_REJECT && $partner->reject)
								{{ $partner->reject->name }}
							@endif
						</p>
						@include('partner/order')
					</td>
					<td>
						<div id="refrence_info_{{ $partner->id }}_comment" class="comment">
							@foreach ($partner->getComments(2) as $comment)
							<p class="date"><span class="date-to-humanize" data-date="{{ $comment->created_at }}">{{ $comment->created_at }}</span> <span>({{ $comment->sender->first_name }} {{ $comment->sender->last_name }})</span></p>
							<p>{{ nl2br($comment->comment) }}</p>
							@endforeach
						</div>
						{{--
						<div id="statusGroup_{{ $partner->id }}" class="btn-group btn-group-vertical crm-btns">
							@include('crm.btns')
						</div>
						--}}
					</td>
					<td>
						<div class="btn-group btn-group-vertical crm-btns" id="refrence_controls_{{ $partner->id }}">
							@if ($partner->statusIsAllow(Partner::ALLOW_OPEN_PARTNER))
							<a class="btn btn-sm btn-danger btn-setdatetime" href="{{ action('PartnerController@index', array($partner->id)) }}"><span class="glyphicon glyphicon-calendar"></span> Открыть</a>
							@endif
							<button class="btn btn-sm btn-info btn-partner-comments" type="button" data-action="{{ action('CrmController@getPartnerComments', array($partner->id)) }}"><span class="glyphicon glyphicon-comment"></span> Комментарии</button>
							@if (isset($input) && ($input['statusType'] == 'agreed' || $input['statusType'] == 'agreedfranchisees') && ($input['type'] == 'waitdelivery' || $input['type'] == 'waitsend' || $input['type'] == 'production'))
							<label class="checkbox">
								<input type="checkbox" name="partners[{{ $partner->id }}]" onchange="updateSbmtBtn();" /> отправлен
							</label>
							@endif
						</div>
					</td>
				</tr>
				@endif
			@endforeach
		</tbody>
	</table>
	@if (isset($input) && ($input['statusType'] == 'agreed' || $input['statusType'] == 'agreedfranchisees') && $input['type'] == 'waitdelivery' && $partners->count())
	<button id="deliveryCheckedSbmtBtn" type="submit" class="btn btn-primary pull-right ladda-button" data-style="zoom-out" data-action="{{ action('PartnerController@deliveryChecked') }}" data-form-id="deliveryCheckedFrom"><span class="ladda-label">Товар отправлен в транспортные компании всем отмеченным клиентам <span class="quant">(0)</span></span></button>
		{{ Form::close() }}
	@endif
	@if (isset($input) && $input['statusType'] == 'agreed')
		<div>
			<span class="btn btn-success fileinput-button ladda-button" data-style="zoom-out">
				<span class="ladda-label">
					<i class="glyphicon glyphicon-plus"></i>
					<span>Загрузить файл с почты</span>
					<input id="fileupload" type="file" name="file" multiple accept=".txt" />
				</span>
			</span>
			<br><br>
			<div id="uploadResultMessage" class="alert hide"></div>
			<div id="uploadStat" class="alert alert-danger hide"></div>
			<div id="progress" class="hide">
				<br/><br/>
				<div class="progress">
					<div class="progress-bar progress-bar-success"></div>
				</div>
			</div>
		</div>
	@endif
	@if (isset($input) && ($input['statusType'] == 'agreed' || $input['statusType'] == 'agreedfranchisees') && $input['type'] == 'waitsend' && $partners->count())
		<button id="sendCheckedSbmtBtn" type="submit" class="btn btn-primary pull-right ladda-button" data-style="zoom-out" data-action="{{ action('PartnerController@sendChecked') }}" data-form-id="sendCheckedFrom"><span class="ladda-label">Товар отправлен отправлен всем отмеченным клиентам <span class="quant">(0)</span></span></button>
		{{ Form::close() }}
	@endif
	{{ $partners->setBaseUrl('crm') }}
	{{ $partners->appends($input)->links() }}
</div>
