<div class="row">
	<div class="card w-100">
		<div class="card-footer">
			<h4>
				<i class="fa fa-rocket"></i>
				Programar viaje
			</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(1)">
						<i class="fa fa-plus"></i>
						Nueva programacion de viaje
					</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">Usuario (Vehiculo)</th>
						<th class="text-left">Fecha</th>
						<th class="text-left">Cliente</th>
						<th class="text-center">Ruta origen</th>
						<th class="text-center">Ruta destino</th>
						<th class="text-center">Origen Creacion</th>
						<th class="text-center">Estado</th>
						<th class="text-center">Guia Trans</th>
					</thead>
					<tbody>
						<tr ng:repeat="progviaj in progviaje | filter: search">
							<td class="">
								
								<div class="btn-group btn-group-justified xs">
									<button class="btn btn-danger" ng:click="delete(progviaj)" ng:if="progviaj.estado == 0">
										<i class="fa fa-trash"></i>
									</button>
									
									<div class="dropdown" ng:if="progviaj.btn_guia == 0">
										<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
											
										  </button>
										  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
											<a class="dropdown-item" ng:click="openModal(2,progviaj)" style="font-size: 20px;">
												<i class="fa fa-search"></i>
												Consultar
											</a>
											<a class="dropdown-item" ng:click="" style="font-size: 20px;">
												<i class="fas fa-fw fa-mail-bulk"></i>
												Nuevo Manifiesto
											</a>
										  </div>
									</div>

									<!--
									<button class="btn btn-secondary ml-1" ng:click="openModal(2,progviaj)" ng:if="progviaj.btn_guia == 0">
										<i class="fa fa-file"></i>
									</button>

									
								
									-->
									<!--
									
									<button class="btn btn-secondary ml-1" ng:click="openModal(3,progviaj)" >
										<i class="fa fa-coins"></i>
									</button>

									<button class="btn btn-primary ml-1" ng:click="goToGuia(progviaj)" >
										<i class="fa fa-eye"></i>
									</button>
									-->
								</div>

								
							</td>
							
							<td class="text-left" ng:bind="progviaj.tausuario.username + '-' + 	progviaj.tausuario.pnombre"></td>

							<td class="text-left" ng:bind="progviaj.fecha"></td>
							<td class="text-left" ng:bind="progviaj.cliente.cliente"></td>
							<td class="text-left" ng:bind="progviaj.rutao.descripcion"></td>
							<td class="text-left" ng:bind="progviaj.rutad.descripcion"></td>
							<td class="text-left" ng:bind="progviaj.user_crea"></td>
						
							<td class="text-center">
								<span class="badge badge-secondary" ng:show="progviaj.estado == 0">Programado</span>
								<span class="badge badge-warning" ng:show="progviaj.estado ==  1">Iniciado</span>
								<span class="badge badge-success" ng:show="progviaj.estado ==  2">Finalizado</span>
								
							</td>
							<td class="text-center">
								<span class="badge badge-secondary" ng:show="progviaj.btn_guia == 0">No</span>
								<span class="badge badge-success" ng:show="progviaj.btn_guia ==  1">Si</span>
							</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="form-group">
							<label for="">Usuario (Vehiculo)</label>
							<select class="form-control" id="cbx_veh" ng:options="tausuario.id_usuario as tausuario.username + '-' + 	tausuario.pnombre for tausuario in tausuarios" ng:model="modal.model.id_usuario">
								<option value="">Seleccionar</option>
							</select>
							<small ng:show="modal.fails.id_vehiculo" ng:repeat="fail in modal.fails.id_vehiculo" ng:bind="fail" class="text-danger"></small>
						</div>
						
						
						<div class="form-group">
							<label for="">Fecha </label>
							<input type="date" id="fecha_progvi" class="form-control" 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 class="form-group">
							<label for="">Cliente</label>
							<select class="form-control" id="cbx_chof" ng:options="cliente.id_cliente as cliente.cliente for cliente in clientes" ng:model="modal.model.id_cliente" required>
								<option value="">Seleccionar</option>
							</select>
						</div>
						
						<div class="form-group">
							<label for="">Ruta Origen</label>
							<select class="form-control" ng:options="ru_o.id_ruta as ru_o.descripcion for ru_o in ruta_o" ng:model="modal.model.ruta_origen" required>
								<option value="">Seleccionar</option>
							</select>
						</div>
						
	        			<div class="form-group">
							<label for="">Ruta Destino</label>
							<select class="form-control" ng:options="ru_d.id_ruta as ru_d.descripcion for ru_d in ruta_d" ng:model="modal.model.ruta_destino" required>
								<option value="">Seleccionar</option>
							</select>
						</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 bd-example-modal-lg" id="modal_ingreso" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
	<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="saveingreso()" id="form_editingreso" name="form_editingreso">
	        		<fieldset>
					

						<div class="row">
						
							<div class="col-xs-6 col-md-7">
								<div class="form-group">
									<label for="">Detalle</label>	
									<input type="text" class="form-control"  id="gasto_detalle" name="gasto_detalle" ng:model="modal.model.gasto_detalle" required>
									<small ng:show="modal.fails.gasto_detalle" ng:repeat="fail in modal.fails.gasto_detalle" ng:bind="fail" class="text-danger"></small>
								</div>
							</div>

							<div class="col-xs-6 col-md-2">
								<div class="form-group">
									<label for="">Moneda</label>	
									<select class="form-control"  ng:model="modal.model.gasto_moneda" required>
										<option value="">Seleccione</option>
										<option value="US $">US $</option>
										<option value="S/.">S/.</option>
									</select>
								</div>
							</div>

							<div class="col-xs-6 col-md-2">
								<div class="form-group">
									<label for="">Monto</label>	
									<input type="number" step="0.01" placeholder=".00" class="form-control border-important" ng:model="modal.model.gasto_monto" required>
									<small ng:show="modal.fails.gasto_monto" ng:repeat="fail in modal.fails.gasto_monto" ng:bind="fail" class="text-danger d-block"></small>
								</div>
							</div>

							<div class="col-xs-1 col-md-1">
								<label for="" style="color: white;">R</label>
								<button class="btn btn-primary" type="submit" ng:disabled="modal.spinner">
									<any ng:show="!modal.spinner">
										<i class="fa fa-save"></i>
									</any>
									<any ng:show="modal.spinner">
										<i class="fa fa-spin fa-spinner"></i>
									</any>
								</button>
								
							</div>

						</div>	
	        		</fieldset>

					<hr class="mt-2 mb-3"/>


					<div class="table-responsive table-responsive-vertical">
						<table class="table">
							<thead>
								<th class="text-center">Detalle</th>
								<th class="text-left">Moneda</th>
								<th class="text-left">Monto</th>
								<th class="text-center">Eliminar</th>
							</thead>
							<tbody>
								<tr ng:repeat="progviaj in progviajedet | filter: search">
									
									<td class="text-left" ng:bind="progviaj.fecha"></td>
									<td class="text-left" ng:bind="progviaj.cliente.cliente"></td>
									<td class="text-left" ng:bind="progviaj.rutao.descripcion"></td>

									<td class="">
										
										<div class="btn-group btn-group-justified xs">
											<button class="btn btn-danger" type="button" ng:click="deleteDetalle(progviaj)" ng:if="progviaj.estado == 0">
												<i class="fa fa-trash"></i>
											</button>
											
											
										</div>
		
										
									</td>
									
								
								</tr>
							</tbody>
						</table>
					</div>


	        	</form>
		    </div>

		    <div class="modal-footer">
	        	
	      	</div>
	    </div>
	</div>
</div>


<div class="modal fade bd-example-modal-lg" id="modal_genguia" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
	<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="saveguia()" id="form_genguia" name="form_genguia">
	        		<fieldset>

						

	        		</fieldset>
	        	</form>
		    </div>
		    <div class="modal-footer">
	        	<button type="submit" class="btn btn-info btn-block" form="form_genguia" ng:disabled="modal.spinner">
	        		<any ng:show="!modal.spinner">Enviar Guia Sunat</any>
	        		<any ng:show="modal.spinner">
	        			<i class="fa fa-spin fa-spinner"></i>
	        			Guardando
	        		</any>
	        	</button>
	      	</div>
	    </div>
	</div>
</div>