<div class="row">
	<div class="card w-100">
		<div class="card-footer">
			<h4>
				<i class="fa fa-folder"></i>
				Gestion Guia transportista - Asociar factura
			</h4>
		</div>
		<div class="card-body" ng:show="spinner">
			<h4 class="text-center">
				<i class="fa fa-spin fa-spinner"></i>
				Cargando
			</h4>
		</div>
		<div class="card-body" ng:show="!spinner">
			<div class="row">
				<div class="col-xs-12 col-sm-6">
					<button class="btn btn-primary" ng:click="openModal(2)">
						<i class="fa fa-retweet"></i>
						Sincronizar con SUNAT
					</button>
				</div>
				<div class="col-xs-12 col-sm-6">
					<input type="text" class="form-control" placeholder="Buscar" ng:model="search">
				</div>
			</div>
			<br>
			<div class="table-responsive table-responsive-vertical">
				<table class="table">
					<thead>
						<th class="text-center">ACCIONES</th>
						<th class="text-left">FECHA</th>
						<th class="text-left">N° GUIA</th>
						<th class="text-left">REMITENTE</th>
						<th class="text-left">RUTA</th>
						<th class="text-center">PLACA</th>
						<th class="text-center">CONDUCTOR</th>
						<th class="text-center">PESO</th>
						<th class="text-center">DOCUMENTO</th>
					</thead>
					<tbody>
						<tr ng:repeat="guia in guiatrans | filter: search">

							<td class="text-center">

								<button class="btn btn-success" ng:click="openModal(1,guia)">
									<i class="fa fa-cogs"></i>
								</button>

							</td>


							<td class="text-left" ng:bind="guia.fecha_traslado | date: 'dd/MM/yyyy'"></td>
							<td class="text-left" ng:bind="guia.serie_guiatrans + '-' + guia.nro_guiatrans"></td>
							<td class="text-left" ng:bind="guia.remitente_rz"></td>
							<td class="text-left" ng:bind="guia.partida_dist + '-' +guia.llegada_dist"></td>
							<td class="text-left" ng:bind="guia.vehiculoprin_placa"></td>
							<td class="text-left" ng:bind="guia.conductor_nombre"></td>
							<td class="text-left" ng:bind="guia.unidad_peso + '-' +guia.peso"></td>

							<td class="text-center">

								<button ng:click="dowloadfile(guia)" ng:if="guia.file_attached">
									<i class="fa fa-download"></i>
								</button>

							</td>


						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>

<div class="modal fade bd-example-modal-lg" id="modal_edit" tabindex="-1" role="dialog">
	<div class="modal-dialog modal-lg" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" ng:bind="modal.title"></h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-body">
				<form ng:submit="save()" id="form_edit" name="form_edit">
					<fieldset>
						<div class="form-group">
							<label>DATOS DE GUIA</label>
							<table>
								<tr>
									<td> N° Guia</td>
									<td class="text-center">:</td>
									<td class="text-left"
										ng:bind="modal.model.serie_guiatrans + '-' + modal.model.nro_guiatrans"></td>
									<td class="text-center">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</td>
									<td>Fecha emision </td>
									<td class="text-center">:</td>
									<td class="text-left" ng:bind="modal.model.fecha_traslado | date: 'dd/MM/yyyy'">
									</td>


								</tr>

								<tr>
									<td>Remitente </td>
									<td class="text-center">:</td>
									<td class="text-left" ng:bind="modal.model.remitente_rz"></td>
									<td class="text-center">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</td>
									<td>Ruta</td>
									<td class="text-center">:</td>
									<td class="text-left"
										ng:bind="modal.model.partida_dist + '-' +modal.model.llegada_dist"></td>
								</tr>

								<tr>
									<td>Placa</td>
									<td class="text-center">:</td>
									<td class="text-left" ng:bind="modal.model.vehiculoprin_placa"></td>
									<td class="text-center">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</td>
									<td>Conductor</td>
									<td class="text-center">:</td>
									<td class="text-left" ng:bind="modal.model.conductor_nombre"></td>
								</tr>

							</table>
						</div>
						<br>
						<div class="form-group">

							<label for="">DOCUMENTO A ASOCIAR</label>

							<ul class="nav nav-tabs">
								<li class="nav-item" ng:click="modal.tab = 1">
									<a class="nav-link" ng:class="{active: modal.tab == 1}">Seleccionar factura</a>
								</li>
								<li class="nav-item" ng:click="modal.tab = 2">
									<a class="nav-link" ng:class="{active: modal.tab == 2}">Buscar factura</a>
								</li>
							</ul>

							<div class="card">
								<div ng:if="modal.tab == 1" class="card-body">
									<h4 class=" text-center" ng:show="modal.spinnertwo">
										<i class="fa fa-spinner fa-spin"></i>
										<any ng:bind="modal.spinner_text"></any>
									</h4>

									<div ng:show="!modal.spinnertwo">
										<select class="selectpicker form-control" data-live-search="true"
											ng:options='venta.id as (venta.serie + "-" + venta.numero+ " " +venta.razonsocial+" S/."+venta.total) for venta in ventas'
											ng:model="modal.model.id_venta">
											<option value="">Seleccionar</option>
										</select>
										<small ng:show="modal.fails.id_venta" ng:repeat="fail in modal.fails.id_venta"
											ng:bind="fail" class="text-danger"></small>
									</div>
								</div>
								<div ng:if="modal.tab == 2" class="card-body">
									<div class="col-md-12 row">
										<div class="col-md-6">
											<input type="text" class="form-control" ng:model="modal.model.venta_filtro">
										</div>
										<div class="col-md-6">
											<button class="btn btn-primary" ng:click="findVenta()" type="button">
												<i class="fa fa-search"></i>
											</button>
										</div>
									</div>
									<div ng:if="modal.venta_encontrada" class="col-md-12">
										<label for="">
											{{ modal.venta_encontrada.serie + "-" + modal.venta_encontrada.numero+ " "
											+modal.venta_encontrada.razonsocial+" S/."+modal.venta_encontrada.total }}
										</label>
									</div>
								</div>
							</div>

						</div>


					</fieldset>
				</form>
			</div>
			<div class="modal-footer">
				<button type="submit" class="btn btn-info btn-block" form="form_edit" ng:disabled="modal.spinner">
					<any ng:show="!modal.spinner">Asociar Documento</any>
					<any ng:show="modal.spinner">
						<i class="fa fa-spin fa-spinner"></i>
						Asociando
					</any>
				</button>
			</div>
		</div>
	</div>
</div>




<div class="modal fade" id="modal_editsinsunat" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" ng:bind="modal.title"></h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-body">
				<form ng:submit="savesinsunat()" id="form_editsinsunat" name="form_editsinsunat">
					<fieldset>

						<label for=""></label>
						<button type="submit" class="btn btn-info btn-block" form="form_editsinsunat"
							ng:disabled="modal.spinner">
							<any ng:show="!modal.spinner">SINCRONIZAR CON SUNAT</any>
							<any ng:show="modal.spinner">
								<i class="fa fa-spin fa-spinner"></i>
								SINCRONIZANDO... [No cerrar ventana]
							</any>
						</button>

					</fieldset>
				</form>
			</div>



		</div>
	</div>

</div>