
<?php $__env->startSection('title'); ?>
	@parent
	Продукты проекта <?php echo $project->name; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
	<script src="<?php echo asset('js/products.js'); ?>"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="row">
  <div class="col-md-12">
		<h4>Продукты проекта <?php echo $project->name; ?> <small><a href="<?php echo action('ProductsController@export', array($project->id)); ?>" target="_blank">экспорт в Excel</a></small></h4>
		<div class="btn-group btn-group-search-input">
			<input id="partnerProductsSearch" type="text" class="form-control" placeholder="Поиск" autocomplete="off" autofocus>
			<span class="btn-search-clear glyphicon glyphicon-remove-circle"></span>
		</div>
		<div class="table-responsive">
			<table id="partnerProducts" class="table table-striped table-hover">
				<thead>
				<th>Название</th>
				<th>Цена</th>
				<th class="text-center">Доступно (блокировано)</th>
				<th>Действия</th>
				</thead>
				<tbody>
					<?php foreach ($project->products as $product): ?>
					<tr>
						<td>
							<span class="to-search"><?php echo $product->mark->name; ?> <?php echo $product->name; ?></span>
							<br/>
							<small><?php echo $product->year_start; ?> - <?php echo $product->year_end; ?></small>
						</td>
						<td class="td-nobr">
							<?php
								$prices = $product->getPrices();
							?>
							<?php foreach (ProductType::all() as $productType): ?>
								<?php if ((isset($prices[$productType->id]['price']) && $prices[$productType->id]['price']) || (isset($prices[$productType->id]['price_back']) && $prices[$productType->id]['price_back'])): ?>
									<?php echo $productType->name; ?> / <span class="to-humanize"><?php echo $prices[$productType->id]['price']; ?></span> <i class="fa fa-rub"></i> / <span class="to-humanize"><?php echo $prices[$productType->id]['price_back']; ?></span> <i class="fa fa-rub"></i> / <span class="to-humanize"><?php echo $prices[$productType->id]['price_opt']; ?></span> <i class="fa fa-rub"></i>, <?php echo $prices[$productType->id]['plates']; ?>/<?php echo $prices[$productType->id]['hooks']; ?>/<?php echo $prices[$productType->id]['splates']; ?><br/>
								<?php endif; ?>
							<?php endforeach; ?>
						</td>
						<?php
						  $quant = $product->getQuant();
							$noProduction = $product->no_production;
						?>
						<td class="text-center td-nobr">
							<?php if ($noProduction == 0): ?>	
								<?php foreach (ProductType::all() as $productType): ?>
									<?php if ((isset($prices[$productType->id]['price']) && $prices[$productType->id]['price']) || (isset($prices[$productType->id]['price_back']) && $prices[$productType->id]['price_back'])): ?>
									<a href="#" class="td-nobr-block"><i class="fa fa-caret-down fa-2x setQuantDown" data-action="<?php echo action('ProductsController@updateQuant', array($project->id,  $product->id, $productType->id, "down")); ?>"></i></a>
									  <span class="to-humanize td-nobr-block productQuant"><?php echo $quant[$productType->id]['quant'] - $quant[$productType->id]['quant_blocked']; ?></span>
									<a href="#" class="td-nobr-block"><i class="fa fa-caret-up fa-2x setQuantUp" data-action="<?php echo action('ProductsController@updateQuant', array($project->id,  $product->id, $productType->id, "up")); ?>"></i></a>
									<span class="to-humanize td-nobr-block">(<?php echo ($quant[$productType->id]['quant_blocked'])? $quant[$productType->id]['quant_blocked']:0; ?>)</span><br>
									<?php endif; ?>
								<?php endforeach; ?>
							<?php endif; ?>
						</td>
						<td>
							<button class="btn btn-sm btn-default btn-block" onClick="location.href ='<?php echo action('ProductsController@edit', array($project->id, $product->id)); ?>'"> &nbsp;Редактировать&nbsp; </button>
							<button class="btn btn-sm btn-default btn-block action_confirm" type="button" data-method="delete" href="<?php echo action('ProductsController@destroy', array($project->id, $product->id)); ?>"> Удалить </button>
						</td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
		</div>
		<button class="btn btn-primary" onClick="location.href ='<?php echo URL::to('projects'); ?>/<?php echo $project->id; ?>/products/create'">Добавить продукт</button>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>