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