<?php $__env->startSection('pageTitle'); ?>
	<div class="page-head">
		<div class="container">
			<!-- BEGIN PAGE TITLE -->
			<div class="page-title">
				<h1>Rascunhos <small>gerenciamento de pedidos salvos como rascunho</small></h1>
			</div>
			<!-- END PAGE TITLE -->
		</div>
	</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumb'); ?>
	<li>
		<a href="<?php echo e(action('HomeController@index')); ?>">Tela Inicial</a>
		<i class="fa fa-circle"></i>
	</li>
	<li class="active">Rascunhos</li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
	<?php echo Form::open(['action' => 'PedidoController@removerRascunhos', 'method' => 'DELETE']); ?>

	<p class="center-block text-right">
		<?php echo Form::submit('Remover rascunhos selecionados', ['class' => 'btn btn-circle red btn-sm', 'data-loading-text' => 'Carregando...', 'data-loading']); ?>

	</p>
	<div class="table-responsive">
		<table id="tabelaRasc" class="table table-striped table-bordered table-advance table-hover">
			<thead>
			<tr>
				<th class="text-center"><?php echo Form::checkbox('checkAll', null, null, ['id' => 'checkAll']); ?></th>
				<th class="text-center">
					Status
				</th>
				<th>
					Cliente
				</th>
				<th class="text-center">
					Tabela
				</th>
				<th>
					Pagamento
				</th>
				<th>
					Ordem de compra
				</th>
				<th>
					Observação
				</th>
				<th>
					Itens
				</th>
				<th></th>
			</tr>
			</thead>
			<tbody>
			<?php $__empty_1 = true; foreach($rascunhos as $rascunho): $__empty_1 = false; ?>
				<tr>
					<td class="text-center"><?php echo Form::checkbox('rascunhos[]', $rascunho->id, null); ?></td>
					<td class="text-center">
						<?php echo ($rascunho->status == 'rascunho') ? '<span class="label label-success">Rascunho</span>' : '<span class="label label-danger">Não enviado</span>'; ?>

					</td>
					<td>
						<?php echo e($rascunho->nomeCliente); ?><br />
						<small><?php echo e($rascunho->codigoCliente); ?></small>
					</td>
					<td class="text-center">
						<?php echo e($rascunho->tabela); ?>

					</td>
					<td class="text-center">
						<?php echo isset($rascunho->condicaoPagamentoNome) ? $rascunho->condicaoPagamentoNome : '<span class="label label-info">-</span>'; ?>

					</td>
					<td>
						<?php echo isset($rascunho->ordemCompra) ? $rascunho->ordemCompra : '<span class="label label-info">-</span>'; ?>

					</td>
					<td>
						<?php echo isset($rascunho->observacao) ? $rascunho->observacao : '<span class="label label-info">-</span>'; ?>

					</td>
					<td class="text-center">
						<a href="javascript:;" class="popovers" data-container="body" data-original-title="Itens"
						   data-placement="top" data-html="true" data-trigger="hover"
						   data-content='
								<ul>
									<?php $__empty_2 = true; foreach($rascunho->itens as $item): $__empty_2 = false; ?>
										<li>
											<span class="badge badge-info">
												<?php echo e($item->quantidade); ?>

											</span>
											<?php echo e($item->nome); ?> -
								   			<strong>R$ <?php echo e(\KsiHelper::formatarDinheiro($item->preco)); ?></strong>
										</li>
									<?php endforeach; if ($__empty_2): ?>
								   <li><span class="label label-warning">Nenhum item encontrado</span></li>
							<?php endif; ?>
								   </ul>
							   '>

							<i class="icon-info"></i>
						</a>
					</td>
					<td class="text-center">
						<a href="<?php echo e(action('PedidoController@recuperarPedido', $rascunho->id)); ?>" class="btn default btn-xs blue">
							<i class="fa fa-share"></i> Continuar
						</a>
					</td>
				</tr>
			<?php endforeach; if ($__empty_1): ?>
				<tr class="active">
					<td colspan="9">
						Nenhum resultado encontrado
					</td>
				</tr>
			<?php endif; ?>
			</tbody>
		</table>
	</div>
	<?php echo Form::close(); ?>


	<?php echo e($rascunhos->render()); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('javascript'); ?>
	<script type="text/javascript">
		$("#tabelaRasc #checkAll").on('click', function () {
			if ($("#tabelaRasc #checkAll").is(':checked')) {
				$("#tabelaRasc input[type=checkbox]").each(function () {
					$(this).prop("checked", true);
					$(this).parent().addClass('checked');
				});

			} else {
				$("#tabelaRasc input[type=checkbox]").each(function () {
					$(this).prop("checked", false);
					$(this).parent().removeClass('checked');
				});
			}
		});
	</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('partials.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>