

<?php $__env->startSection('breadcrumb'); ?>
	<li>
		<a href="<?php echo e(action('HomeController@index')); ?>">Tela Inicial</a>
		<i class="fa fa-circle"></i>
	</li>
	<li>
		<a href="<?php echo e(action('PedidoController@index')); ?>">Pedidos de venda</a>
		<i class="fa fa-circle"></i>
	</li>
	<li>
		<a href="<?php echo e(action('PedidoController@selecionarEmpresa')); ?>">1. Seleção de empresa</a>
		<i class="fa fa-circle"></i>
	</li>
	<li>
		<a href="<?php echo e(action('PedidoController@primeiroPasso')); ?>">2. Seleção do cliente</a>
		<i class="fa fa-circle"></i>
	</li>
	<li class="active">3. Seleção dos produtos</li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

	<!-- BEGIN PORTLET -->
	<div class="portlet light bordered">
		<div class="portlet-title">
			<div class="caption font-blue-chambray">
				<i class="icon-book-open font-blue-chambray"></i>
				<span class="caption-subject bold uppercase"> 2. Seleção dos produtos</span>
				<span class="caption-helper">| Empresa: <?php echo $empresa['ZL_NOME']; ?></span>
				<span class="caption-helper">| Cliente: <?php echo $cliente->A1_NREDUZ; ?></span>
			</div>
			<div class="actions">
				<?php echo link_to_action('PedidoController@selecionarCliente', 'Voltar', null, ['class' => 'btn btn-sm btn-info']); ?>

				<?php echo link_to_action('PedidoController@salvarRascunho', 'Salvar como rascunho', null, ['class' => 'btn btn-sm btn-primary uppercase']); ?>

				<?php echo link_to_action('PedidoController@conferirPedido', 'Prosseguir', null, ['class' => 'btn btn-sm btn-success uppercase']); ?>

			</div>
		</div>

		<?php /* ======= 2 - SELECAO DO PRODUTO ======= */ ?>
		<div class="portlet-body form">
			<!-- BEGIN PRODUTO -->
			<div class="row">
				<div class="col-md-3">
					<h4 class="form-section">
						<div class="row">
							<div class="col-md-4 margin-top-5">
								Grupos
							</div>
							<div class="col-md-8">
								<?php if($cliente->DA0_PRFIXO == 'S'): ?>
									<?php echo Form::select('modalidadeVendaPadrao', ['Preço' => 'Cheio'],
									($modalidade) ? $modalidade : 'Preço', ['id' => 'modalidadeVendaPadrao', 'class' => 'form-control input-sm']); ?>

								<?php else: ?>
									<?php echo Form::select('modalidadeVendaPadrao', ['Preço' => 'Cheio', '5% desconto' => '5% desconto', '10% desconto' => '10% desconto'],
									($modalidade) ? $modalidade : 'Preço', ['id' => 'modalidadeVendaPadrao', 'class' => 'form-control input-sm']); ?>

								<?php endif; ?>
							</div>
						</div>
					</h4>
					<div class="row">
						<?php $__empty_1 = true; foreach($grupos as $grupo): $__empty_1 = false; ?>
							<div class="col-sm-2 col-md-6">
								<a href="<?php echo e(action('PedidoController@buscaProduto', [$grupo->ZO_GRUPO])); ?>" data-target="#produtosModal" data-toggle="modal"
								   class="thumbnail tooltips grupoProdutos"
								   data-container="body" data-placement="top" data-original-title="<?php echo e(ucfirst(strtolower($grupo->ZO_DESCRI))); ?>">
									<img src="<?php echo e(asset("images/grupos/$grupo->ZO_IMAGEM")); ?>" alt="101%x57" style="height: 57px; width: 100%; display: block;" data-src="holder.js/101%x57">
								</a>
							</div>
						<?php endforeach; if ($__empty_1): ?>
							<div class="col-md-12">
								<span class="label label-danger">Nenhum grupo encontrado. </span>
							</div>
						<?php endif; ?>
					</div>
				</div>



				<!-- BEGIN FORM-->
				<?php echo Form::open(['action' => 'PedidoController@removerProdutos', 'method' => 'DELETE']); ?>

				<div class="col-md-9">
					<h4 class="form-section">
						<div class="row">
							<div class="col-md-6">
								Produtos selecionados
							</div>
							<div class="col-md-6 text-right">
								<?php echo Form::submit('Remover produtos selecionados', ['class' => 'btn btn-circle red btn-sm', 'data-loading-text' => 'Carregando...', 'data-loading']); ?>

								<a href="#" data-target="#editarProdutosModal" data-toggle="modal" class="btn btn-circle blue btn-sm">
									Editar produtos
								</a>
							</div>
						</div>
					</h4>
					<div class="form-group">
						<div class="table-scrollable">
							<table id="tabelaProd" class="table table-bordered table-striped table-advance">
								<thead>
								<tr>
									<th class="text-center"><?php echo Form::checkbox('checkAll', null, null, ['id' => 'checkAll']); ?></th>
									<th>
										Produto
									</th>
									<th>
										78967493
									</th>
									<th>
										Nome
									</th>
									<th>
										Qtd.
									</th>
									<th>
										Preço
									</th>
									<th>
										Impostos
									</th>
									<th>
										Total
									</th>
								</tr>
								</thead>
								<tbody id="produtosContainer">
								<?php if($produtos): ?>
									<?php $count = 0; ?>
									<?php foreach($produtos as $produto): ?>
										<tr>
											<td class="text-center"><?php echo Form::checkbox('produtos[]', $count, null, ['id' => 'check']); ?></td>
											<td>
												<?php echo e($produto['id']); ?>

											</td>
											<td class="text-center">
												<?php echo e(substr($produto['codigo'], 8)); ?>

											</td>
											<td>
												<?php echo e($produto['nome']); ?>

											</td>
											<td class="text-center">
												<?php echo e($produto['quantidade']); ?>

											</td>
											<td>
												R$ <?php echo e(KsiHelper::formatarDinheiro($produto['preco'])); ?>

											</td>
											<td>
												<?php if($produto['ipi']): ?>
													<p><span class="label label-warning">+ R$ <?php echo e(KsiHelper::formatarDinheiro($produto['ipi'])); ?> IPI</span></p>
												<?php endif; ?>
												<?php if($produto['icms']): ?>
													<p><span class="label label-warning">+ R$ <?php echo e(KsiHelper::formatarDinheiro($produto['icms'])); ?> ST</span></p>
												<?php endif; ?>
											</td>
											<td>
												R$ <?php echo e(KsiHelper::formatarDinheiro(($produto['preco'] * $produto['quantidade']))); ?>

											</td>
										</tr>
										<?php $count++; ?>
									<?php endforeach; ?>
								<?php else: ?>
									<tr class="active">
										<td colspan="8">
											Nenhum produto selecionado
										</td>
									</tr>
								<?php endif; ?>
								</tbody>
							</table>
						</div>
						<!-- /table-scrollable -->
						<div class="row">
							<div class="col-xs-12 invoice-block text-right">
								<ul class="list-unstyled amounts">
									<li>
										<strong>Subtotal:</strong> R$ <?php echo e(KsiHelper::formatarDinheiro($somaPreco)); ?>

									</li>
									<li>
										<strong>IPI:</strong> R$ <?php echo e(KsiHelper::formatarDinheiro($somaIpi)); ?>

									</li>
									<li>
										<strong>ICMS ST:</strong> R$ <?php echo e(KsiHelper::formatarDinheiro($somaIcms)); ?>

									</li>
									<li>
										<strong>Total:</strong> R$ <?php echo e(KsiHelper::formatarDinheiro($somaPreco + $somaIpi + $somaIcms)); ?>

									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
				<?php echo Form::close(); ?>

				<!-- END FORM-->
			</div>
			<!-- END PRODUTO -->
		</div>
	</div>
	<!-- END PORTLET -->

	<?php /* ======= PRODUTOS MODAL ======= */ ?>
	<div class="modal fade" id="produtosModal" role="basic" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-body">
					<img src="<?php echo e(asset('img/loading-spinner-grey.gif')); ?>" alt="" class="loading">
					<span>
						&nbsp;&nbsp;Carregando...
					</span>
				</div>

			</div>
		</div>
	</div>
	<!-- /.modal -->

	<?php /* ======= EDITAR PRODUTOS MODAL ======= */ ?>
	<div class="modal fade" id="editarProdutosModal" role="basic" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<?php echo Form::open(['action' => ['PedidoController@alterarProdutos']]); ?>

				<?php echo Form::hidden('modalidade', null, ['id' => 'modalidade']); ?>

				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
					<h4 class="modal-title">
						<strong>Alterar produtos</strong>
						<?php if($produtos): ?>
							<small>|</small>
							<?php echo Form::submit('Alterar produtos', ['id' => 'adicionarProduto', 'class' => 'btn btn-circle green btn-sm', 'data-loading-text' => 'Carregando...', 'data-loading']); ?>

						<?php endif; ?>
					</h4>
				</div>
				<div class="modal-body">
					<table class="table table-bordered table-striped table-advance">
						<thead>
						<tr>
							<th>
								Grupo
							</th>
							<th>
								78967493
							</th>
							<th>
								Nome
							</th>
							<th>
								Qtd.
							</th>
							<th>
								Preço
							</th>
							<th>
								Total
							</th>
						</tr>
						</thead>
						<tbody id="produtosContainer">
						<?php if($produtos): ?>
							<?php $count = 0; ?>
							<?php foreach($produtos as $produto): ?>
								<tr>
									<td>
										<?php echo e($produto['grupo']); ?>

									</td>
									<td class="text-center">
										<?php echo e(substr($produto['codigo'], 8)); ?>

									</td>
									<td>
										<?php echo e($produto['nome']); ?>

									</td>
									<td class="text-center">

										<div class="stepper">
											<div class="input-group" style="width: 110px;">
												<div class="spinner-buttons input-group-btn">
													<button type="button" class="btn btn-sm spinner-down red">
														<i class="fa fa-minus"></i>
													</button>
												</div>
												<?php echo Form::text('produtoQtd[]', $produto['quantidade'], ['class' => 'form-control input-sm number spinner-input text-center', 'placeholder' => '0', 'step' => '1']); ?>

												<div class="spinner-buttons input-group-btn">
													<button type="button" class="btn btn-sm spinner-up blue">
														<i class="fa fa-plus"></i>
													</button>
												</div>
											</div>
										</div>
									</td>
									<td>
										R$ <?php echo e(KsiHelper::formatarDinheiro($produto['preco'])); ?>

									</td>
									<td>
										R$ <?php echo e(KsiHelper::formatarDinheiro(($produto['preco'] * $produto['quantidade']))); ?>

									</td>
								</tr>
								<?php $count++; ?>
							<?php endforeach; ?>
						<?php else: ?>
							<tr class="active">
								<td colspan="6">
									Nenhum produto selecionado
								</td>
							</tr>
						<?php endif; ?>
						</tbody>
					</table>
				</div>
				<?php echo Form::close(); ?>

			</div>
		</div>
	</div>
	<!-- /.modal -->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('javascript'); ?>
	<script type="text/javascript" src="<?php echo e(asset('output/plugins/spinner.min.js')); ?>"></script>
	<script type="text/javascript">
		$('.grupoProdutos').on('click', function()
		{
			$('#produtosModal').html('<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-body"><img src="<?php echo e(asset('img/loading-spinner-grey.gif')); ?>" alt="" class="loading"><span>&nbsp;&nbsp;Carregando...</span></div></div></div>');
		});

		$("#tabelaProd #checkAll").on('click', function () {
			if ($("#tabelaProd #checkAll").is(':checked')) {
				$("#tabelaProd input[type=checkbox]").each(function () {
					$(this).prop("checked", true);
					$(this).parent().addClass('checked');
				});

			} else {
				$("#tabelaProd input[type=checkbox]").each(function () {
					$(this).prop("checked", false);
					$(this).parent().removeClass('checked');
				});
			}
		});

		$('.stepper').spinner();
	</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('partials.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>