<div class="row">
	<div class="card w-100">
		<div class="card-footer">
			<h4>
				<i class="fa fa-mobile"></i>
				Usuarios App
			</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>
						Agregar usuario
					</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">Vehiculo (Usuario)</th>
						<th class="text-left">Chofer</th>
						<th class="text-left">Remolque</th>
						<th class="text-center">Estado</th>
					</thead>
					<tbody>
						<tr ng:repeat="usuario in usuarios_app | filter: search">
							<td class="text-center">
								<button class="btn btn-warning" ng:click="openModal(2,usuario)" ng:if="!usuario.deleted_at">
									<i class="fa fa-edit"></i>
								</button>

								<button class="btn btn-danger" ng:click="delete(usuario)" ng:if="!usuario.deleted_at">
									<i class="fa fa-trash"></i>
								</button>
								<small class="text-center" ng:if="usuario.deleted_at">Usuario eliminado</small>
							</td>
							
							<td class="text-left" ng:bind="usuario.vehiculo.placa"></td>
							<td class="text-left" ng:bind="usuario.chofer.nombres"></td>
							<td class="text-left" ng:bind="usuario.remolque.placa"></td>
							<td class="text-center">
								<span class="badge badge-success" ng:show="usuario.enabled">ACTIVO</span>
								<span class="badge badge-danger" ng:show="!usuario.enabled">INACTIVO</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="">Vehiculo</label>
							<select class="form-control" id="cbx_veh" ng:options="vehiculo.id as vehiculo.placa for vehiculo in vehiculos" ng:model="modal.model.id_vehiculo">
								<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="">Chofer</label>
							<select class="form-control" id="cbx_chof" ng:options="chofer.id as chofer.nombres for chofer in choferes" ng:model="modal.model.id_chofer" required>
								<option value="">Seleccionar</option>
							</select>
						</div>
						
						<div class="form-group">
							<label for="">Remolque</label>
							<select class="form-control" id="cbx_remolq" ng:options="remolque.id as remolque.placa for remolque in remolques" ng:model="modal.model.id_remolque">
								<option value="">Seleccionar</option>
							</select>
						</div>
						
	        			<div class="form-group">
	        				<label for="">Contraseña</label>	
	        				<input type="text" class="form-control" name="password" ng:model="modal.model.password" required>
	        				<small ng:show="modal.fails.password" ng:repeat="fail in modal.fails.password" ng:bind="fail" class="text-danger"></small>
	        			</div>
						
						<div class="custom-control custom-checkbox mr-sm-2" ng:if="modal.edit">
					        <input type="checkbox" class="custom-control-input" id="customControlAutosizing" ng:model="modal.model.enabled">
					        <label class="custom-control-label" for="customControlAutosizing">Usuario Activo</label>
					   	</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>