@extends('layouts.app')

@section('title',"Compras")

@section('content')
	@foreach ($compra as $c)
		<div class="card">
			<div class="card-body">
				<div class="container-fluid">
					<div class="row">
						<div class="col-12 text-right">
							<form action="{{ url('compras') }}" method="POST">
								@csrf
								<input type="hidden" name="action" value="pdf">
								<input type="hidden" name="id" value="{{ $c->id }}">
								<button class="btn btn-warning"><i class="icon-file-pdf"></i> Generar PDF</button>
							</form>
						</div>
					</div><br/>
					<div class="row" >
						<div class="col-9" >
							<h4>{{ $c->nombre }}</h4>
							<b>Emision:</b> {{ $c->fec_emision}}
						</div>
						<div class="col-3 text-right" style="border: 1px solid black; border-radius: 5px;">
							<div class="fact-right"><b>RUC:</b> {{ $c->ruc }}</div>
							<div class="fact-right"><h3>Factura</h3></div>
						</div>
					</div>
				</div>
				<hr>
				<div class="row">
					<div class="col-6">
						
					</div>
					<div class="col-6 text-right">
						<b>Divisa: </b> {{ $c->divisas->divisa }}
					</div>
				</div>
				<table class="table  table-bordered">
					<thead>
						<th>Codigo</th>
						<th>Descripcion</th>
						<th>Cantidad</th>
						<th>Precio</th>
						<th>Cuenta</th>
						<th>Dolares</th>
					</thead>
					<tbody>
	            		@php
	            			$cont = 0;
	            			$cont_cuenta = 0;
	            			$cont_dolares = 0;
						@endphp
						@foreach ($c->Compras_lineas as $l)
							@php
		            			$cont += $l->precio;
		            			$cont_cuenta += $l->cuenta;
		            			$cont_dolares += $l->dolares;
							@endphp
							<tr>
								<td>{{ $l->codigo }}</td>
								<td>{{ $l->concepto }}</td>
								<td>{{ $l->cantidad }}</td>
								<td>{{ $l->precio }}</td>
								<td>{{ $l->cuenta }}</td>
								<td>{{ $l->dolares }}</td>
							</tr>
						@endforeach
						<tr><td colspan="3"></td><td><b>Total:	{{$cont}}</b></td><td><b>Total:	{{$cont_cuenta}}</b></td><td><b>Total:	{{$cont_dolares}}</b></td></tr>
					</tbody>
				</table>
			</div>
		</div>
	@endforeach
@endsection