<div class="row">
	<div class="card w-100">
		<div class="card-footer">
			<h4>
				<i class="fas fa-shopping-cart"></i>
				Registro Compras
			</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(3)">
						<i class="fa fa-plus"></i>
						Agregar compra(Auto)
					</button>

					<button class="btn btn-primary" ng:click="openModal(1)">
						<i class="fa fa-plus"></i>
						Agregar compra(Manual)
					</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">Codigo Registro</th>
						<th class="text-left">Fecha Emision</th>
						<th class="text-left">Tipo documento</th>
						<th class="text-left">Serie</th>
						<th class="text-center">Numero</th>
						<th class="text-center">RUC</th>
						<th class="text-center">Razon Social</th>
						<th class="text-center">Moneda</th>
						<th class="text-center">Base Imponible</th>
						<th class="text-center">IGV</th>
						<th class="text-center">Total</th>
					</thead>
					<tbody>
						<tr ng:repeat="compra in compras | filter: search">
							<td class="text-center">
								<button class="btn btn-danger" ng:click="delete(compra)" ng:if="!compra.deleted_at">
									<i class="fa fa-trash"></i>
								</button>	
							</td>
							<td class="text-left" ng:bind="compra.id"></td>
							<td class="text-left" ng:bind="compra.fecha | date: 'dd/MM/yyyy'"></td>
							<td class="text-left" ng:bind="compra.tipodoccompra.tipo_abr"></td>
							<td class="text-left" ng:bind="compra.serie"></td>
							<td class="text-left" ng:bind="compra.numero"></td>
							<td class="text-left" ng:bind="compra.ruc"></td>
							<td class="text-left" ng:bind="compra.razonsocial"></td>
							
							
							<td class="text-left">
								<span ng:show="compra.moneda == 'PEN'" ng:if="compra.moneda">Soles</span>
								<span ng:show="compra.moneda == 'USD'" ng:if="compra.moneda">Dolares</span>
							</td>

							<td class="text-left" ng:bind="compra.baseimponible"></td>
							<td class="text-left" ng:bind="compra.igv"></td>
							<td class="text-left" ng:bind="compra.total"></td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>

<div class="modal fade" id="modal_edit" 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="save()" id="form_edit" name="form_edit">
	        		<fieldset>
						<div class="row">
							<div class="col-xs-12 col-md-5">
								<div class="form-group">
									<label for="">Tipo de Documento</label>
									<select class="form-control" id="cbx_tipdoc" ng:options="Tipodoccomp.id as Tipodoccomp.tipo_des for Tipodoccomp in Tipodoccompra" ng:model="modal.model.id_tipo">
										<option value="">Seleccionar</option>
									</select>
									<small ng:show="modal.fails.id_tipo" ng:repeat="fail in modal.fails.id_tipo" ng:bind="fail" class="text-danger"></small>
								</div>
							</div>
							<div class="col-xs-8 col-md-2"></div>
							<div class="col-xs-12 col-md-5">
								<div class="form-group">
									<label for="">Fecha emisión </label>
									<input type="date" class="form-control border-success" ng:model="modal.model.fecha" required>  
									<small ng:show="modal.model.fecha" ng:repeat="fail in modal.model.fecha" ng:bind="fail" class="text-danger"></small>
								</div>	
							</div>
						</div>

						<div class="row">
							<div class="col-xs-8 col-md-3">
								<div class="form-group">
									<label for="">Serie</label>	
									<input type="text" class="form-control" name="serie" ng:model="modal.model.serie" required>
									<small ng:show="modal.fails.serie" ng:repeat="fail in modal.fails.serie" ng:bind="fail" class="text-danger"></small>
								</div>
							</div>
							<div class="col-xs-8 col-md-4">
								<div class="form-group">
									<label for="">Numero</label>	
									<input type="text" class="form-control" name="numero" ng:model="modal.model.numero" required>
									<small ng:show="modal.fails.numero" ng:repeat="fail in modal.fails.numero" ng:bind="fail" class="text-danger"></small>
								</div>
							</div>	
							<div class="col-xs-8 col-md-5">
								<div class="form-group">
									<label for="">RUC</label>	
									<input type="text" class="form-control" name="ruc" ng:model="modal.model.ruc" required>
									<small ng:show="modal.fails.ruc" ng:repeat="fail in modal.fails.ruc" ng:bind="fail" class="text-danger"></small>
								</div>
							</div>	
						</div>

						<div class="form-group">
	        				<label for="">Razon Social</label>	
	        				<input type="text" class="form-control" name="razonsocial" ng:model="modal.model.razonsocial" required>
	        				<small ng:show="modal.fails.razonsocial" ng:repeat="fail in modal.fails.razonsocial" ng:bind="fail" class="text-danger"></small>
	        			</div>

						<div class="row">
							
								
							<div class="col-xs-8 col-md-2">
								<label for="">Moneda</label>
							</div>
						
						
							<div class="col-xs-8 col-md-4">
								<select class="form-control" id="cbx_moneda"  ng:model="modal.model.moneda">
									<option value="">Seleccionar</option>
									<option value="PEN">Soles</option>
									<option value="USD">Dolares</option>
								</select>
								<small ng:show="modal.fails.moneda" ng:repeat="fail in modal.fails.moneda" ng:bind="fail" class="text-danger"></small>
							</div>

						</div>
						<br>
						<div class="row">
							<div class="col-xs-8 col-md-4">
								<div class="form-group">
									<label for="">Base</label>	
									<input type="number" step="0.01" placeholder=".00" class="form-control border-important" ng:model="modal.model.baseimponible">
								</div>
							</div>	
							<div class="col-xs-8 col-md-4">
								<div class="form-group">
									<label for="">IGV</label>	
									<input type="number" step="0.01" placeholder=".00" class="form-control border-important" ng:model="modal.model.igv">
								</div>
							</div>	
							<div class="col-xs-8 col-md-4">
								<div class="form-group">
									<label for="">Total</label>	
									<input type="number" step="0.01" placeholder=".00" class="form-control border-important" ng:model="modal.model.total">
								</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">Guardar Datos</any>
	        		<any ng:show="modal.spinner">
	        			<i class="fa fa-spin fa-spinner"></i>
	        			Guardando
	        		</any>
	        	</button>
	      	</div>
	    </div>
	</div>
</div>


<div class="modal fade" id="modal_addauto" 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="savetwo()" id="form_addauto" name="form_addauto">
	        		<fieldset>

						<div class="row">
							<div class="col-xs-12 col-md-5">
								<div class="form-group">
									<label for="">Tipo de Documento</label>
									<label for="">FACTURA</label>
								</div>
							</div>
							<div class="col-xs-8 col-md-1"></div>
							<div class="col-xs-12 col-md-5">
								<div class="form-group">
									<label for="">RUC</label>	
									<input type="text" class="form-control" name="ruc" ng:model="modal.model.ruc" required>
	        						<small ng:show="modal.fails.ruc" ng:repeat="fail in modal.fails.ruc" ng:bind="fail" class="text-danger"></small>
								</div>	
							</div>
						</div>

						<div class="row">
							<div class="col-xs-12 col-md-5">
								<div class="form-group">
									<label for="">Serie</label>	
									<input type="text" class="form-control" name="serie" ng:model="modal.model.serie" required>
	        						<small ng:show="modal.fails.serie" ng:repeat="fail in modal.fails.serie" ng:bind="fail" class="text-danger"></small>
								</div>	
							</div>
							<div class="col-xs-8 col-md-1">	</div>
							<div class="col-xs-12 col-md-5">
								<div class="form-group">
									<label for="">Numero Documento</label>	
									<input type="text" class="form-control" name="numero" ng:model="modal.model.numero" required>
	        						<small ng:show="modal.fails.numero" ng:repeat="fail in modal.fails.numero" ng:bind="fail" class="text-danger"></small>
								</div>	
							</div>
						</div>
					
	        		</fieldset>
	        	</form>
		    </div>
		    <div class="modal-footer">
	        	<button type="submit" class="btn btn-info btn-block" form="form_addauto" ng:disabled="modal.spinner">
	        		<any ng:show="!modal.spinner">Buscar Documento</any>
	        		<any ng:show="modal.spinner">
	        			<i class="fa fa-spin fa-spinner"></i>
	        			Buscando
	        		</any>
	        	</button>
	      	</div>
	    </div>
	</div>
</div>