@extends('layouts.default')

@section('title')
@parent
Информация о пользователе
@stop

@section('content')
<h4>Информация о пользователе</h4>

<div class="well clearfix">
	<div class="col-md-6">
		@if ($user->first_name)
		<p><strong>Имя:</strong> {{ $user->first_name }} </p>
		@endif
		@if ($user->last_name)
		<p><strong>Фамилия:</strong> {{ $user->last_name }} </p>
		@endif
		<p><strong>E-mail:</strong> {{ $user->email }}</p>
		<p><strong>Телефон:</strong> <span class="phone-to-humanize">{{ $user->phone }}</span></p>
	</div>
	<div class="col-md-6">
		<p><em>Дата регистрации: {{ $user->created_at }}</em></p>
		<p><em>Дата обновления информации: {{ $user->updated_at }}</em></p>
		<button class="btn btn-primary" onClick="location.href ='{{ action('UserController@edit', array($user->id)) }}'">Редактировать</button>
	</div>
</div>

@if (Sentry::getUser()->hasAccess('admin'))
	<h4>Состоит в группах</h4>
	<?php $userGroups = $user->getGroups(); ?>
	<div class="well">
		<ul>
			@if (count($userGroups) >= 1)
			@foreach ($userGroups as $group)
			<li>{{ $group->getName() }}</li>
			@endforeach
			@else
			<li>Нет ни одной группы.</li>
			@endif
		</ul>
	</div>
@endif

@if(User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_AGENT))
	<h4>Информация о финансах</h4>
	<div class="well clearfix">
		<div class="col-md-6">
			<p><strong>Заработано денег:</strong> <span class="to-humanize">{{ $user->profit }}</span> <i class="fa fa-rub"></i></p>
		</div>
	</div>
@endif

@if(User::find(Sentry::getUser()->id)->hasRole(Role::ROLE_FRANCHISEES))
	<h4>Информация о финансах</h4>
	<div class="well clearfix">
		<div class="col-md-6">
			<p><strong>Заработано денег:</strong> <span class="to-humanize">{{ $user->profit }}</span> <i class="fa fa-rub"></i></p>
			<p><strong>Депозит на производство:</strong> <span class="to-humanize">{{ $user->money }}</span> <i class="fa fa-rub"></i></p>
			<p><strong>Заморожено денег:</strong> <span class="to-humanize">{{ User::find($user->id)->getFrozenMoney() }}</span> <i class="fa fa-rub"></i></p>
		</div>
	</div>

	<h4>Информация о доставке</h4>
	<div class="well clearfix">
		<div class="col-md-6">
			@if ($user->city)
			<p><strong>Город:</strong> {{ $user->city }}</p>
			@endif
			@if ($user->address)
			<p><strong>Адрес:</strong> {{ $user->address }}</p>
				@if (!$user->delivery_to)
				<p><strong>Доставка до адреса</strong></p>
				@else
				<p><strong>Доставка до транспортной компании</strong></p>
				@endif
			@endif
			@if ($user->delivery_price)
			<p><strong>Стоимость доставки:</strong> <span class="to-humanize">{{ $user->delivery_price }}</span> <i class="fa fa-rub"></i></p>
			@endif
		</div>
	</div>

	<h4>Информация о платежах</h4>
	<table class="table table-hover table-borderless">
		<thead>
			<tr>
				<th style="width:200px">Дата</th>
				<th class="text-right" style="width:100px">Сумма</th>
				<th>Комментарий</th>
			</tr>
		</thead>
		@foreach (User::find($user->id)->payments as $payment)
		<tbody>
			<tr>
				<td><span class="date-to-humanize" data-date="{{ $payment->created_at }}">{{ $payment->created_at }}</span></td>
				<td class="text-right"><span class="to-humanize">{{ $payment->amount}}</span> <i class="fa fa-rub"></i></td>
				<td>{{ $payment->comment}}</td>
			</tr>
		</tbody>
		@endforeach
	</table>
@endif

@stop
