@extends('layouts.default')

@section('title')
@parent
Продукты проекта {{ $project->name }}
@stop

@section('content')
<div class="row">
  <div class="col-md-12">
		<h4>Продукты проекта {{ $project->name }}</h4>
		<div class="table-responsive">
			<table class="table table-striped table-hover">
				<thead>
				<th>Артикул</th>
				<th>Название</th>
				<th>Вес</th>
				<th>Цена</th>
				<th>Действия</th>
				</thead>
				<tbody>
					@foreach ($project->products()->orderBy('name', 'ASC')->get() as $product)
						<tr>
							<td>
								{{ $product->article }}
							</td>
							<td>
								<b>{{ $product->name }}</b><br/>
								@if($product->supplier)
								<small>{{ $product->supplier->name }}</small><br/>
								@endif
								Вес: <span class="to-humanize">{{ $product->weight }}</span> грамм<br/>
							</td>
							<td>
								<span class="to-humanize">{{ $product->weight }}</span> грамм<br/>
							</td>
							<td>
								<dl class="dl-horizontal">
									<dt>Закупочная цена:</dt><dd><span class="to-humanize">{{ $product->price_purchase }}</span> <i class="fa fa-rub"></i></dd>
									<dt>100% предоплата:</dt><dd><span class="to-humanize">{{ $product->price }}</span> <i class="fa fa-rub"></i></dd>
									<dt>Наложенный платеж:</dt><dd><span class="to-humanize">{{ $product->price_back }}</span> <i class="fa fa-rub"></i></dd>
								</dl>
							</td>
							<td>
								<button class="btn btn-sm btn-default" onClick="location.href ='{{ action('ProductsController@edit', array($project->id, $product->id)) }}'">Редактировать</button>
								<button class="btn btn-sm btn-default action_confirm" type="button" data-method="delete" href="{{ action('ProductsController@destroy', array($project->id, $product->id)) }}">Удалить</button>
							</td>
						</tr>
						@if($product->action_name1 && $product->action_price1)
						<tr>
							<td></td>
							<td><b>{{ $product->action_name1 }}</b></td>
							<td></td>
							<td>
								<dl class="dl-horizontal">
									<dt>Цена по акции:</dt><dd><span class="to-humanize">{{ $product->action_price1 }}</span> <i class="fa fa-rub"></i></dd>
								</dl>
							</td>
						</tr>
						@endif
						@if($product->action_name2 && $product->action_price2)
						<tr>
							<td></td>
							<td><b>{{ $product->action_name2 }}</b></td>
							<td></td>
							<td>
								<dl class="dl-horizontal">
									<dt>Цена по акции:</dt><dd><span class="to-humanize">{{ $product->action_price2 }}</span> <i class="fa fa-rub"></i></dd>
								</dl>
							</td>
						</tr>
						@endif
						@if($product->action_name3 && $product->action_price3)
						<tr>
							<td></td>
							<td><b>{{ $product->action_name3 }}</b></td>
							<td></td>
							<td>
								<dl class="dl-horizontal">
									<dt>Цена по акции:</dt><dd><span class="to-humanize">{{ $product->action_price3 }}</span> <i class="fa fa-rub"></i></dd>
								</dl>
							</td>
						</tr>
						@endif
					@endforeach
				</tbody>
			</table>
		</div>
		<button class="btn btn-primary" onClick="location.href ='{{ URL::to('projects') }}/{{ $project->id }}/products/create'">Добавить продукт</button>
	</div>
</div>
@stop
