{% extends '@NoahtechSistemasInterjama/Default/base.html.twig' %}
{% block title %}Interjama | Chofer{% endblock %}
{% block stylesheets %}
<link href="{{asset('app/node_modules/select2/dist/css/select2.min.css')}}" rel="stylesheet">
<link href="{{asset('app/node_modules/@ttskch/select2-bootstrap4-theme/dist/select2-bootstrap4.min.css')}}" rel="stylesheet">
<link rel="stylesheet" href="{{asset('app/node_modules/intl-tel-input/build/css/intlTelInput.css')}}">
{% endblock %}
{% block body %}
<br><br>
<section class="row justify-content-center">
<div class="col-md-12" data-ng-controller="ChoferController" data-ng-init="init({{ data|json_encode() }})" style="padding:30px; border:1px solid #ccc;-webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px;">
<br>
<div class="">
<h2 class="title_interior">Chofer</h2>
</div>
<br>
<div class="form-check">
<input class="form-check-input" type="radio" data-ng-model="situacion.chofer" value="registrado" data-ng-change="changeSituacionChofer();">
<label class="form-check-label" for="flexRadioDefault1">
Ya soy chofer registrado
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" data-ng-model="situacion.chofer" value="nuevo" data-ng-change="changeSituacionChofer();">
<label class="form-check-label" for="flexRadioDefault2">
No soy chofer registrado
</label>
</div>
<br>
<div class="alert alert-primary" role="alert" data-ng-if="situacion.chofer == 'registrado'">
<strong>Ingrese el tipo y número de documento para continuar con la precarga.</strong>
</div>
<div class="alert alert-primary" role="alert" data-ng-if="situacion.chofer == 'nuevo'">
<strong>Ingrese todos los datos para poder registrase como chofer.</strong>
</div>
<div class="form-group row">
<div class="col"><hr></div>
</div>
<br>
<!-- En caso de que sea registrado -->
<form id="formSearchChofer" class="">
<div class="form-group row">
<label for="tipo" class="col-sm-2 col-form-label">Tipo</label>
<div class="col-sm-3">
<select class="form-control" name="tipo" id="tipo" data-ng-model="tipo.seleccionado">
<option value="" selected disabled>Seleccione...</option>
<option value="dni">D.N.I.</option>
<option value="ci">C.I.</option>
<option value="pasaporte">Pasaporte</option>
<option value="rut">RUT</option>
</select>
</div>
<label for="numero" class="col-sm-2 col-form-label">Número</label>
<div class="col-sm-3">
<input type="text" name="numero" class="form-control" id="numero" data-ng-model="chofer.numero" placeholder="Ingrese número">
</div>
</div>
<div class="form-group row">
<div class="col-sm-10"></div>
<div class="col-sm-2" data-ng-if="chofer.id == null && situacion.chofer == 'registrado'" style="text-align: right;">
<button type="button" class="btn btn-primary" id="btnSearchChofer" data-ng-click="searchChofer();">Buscar</button>
</div>
</div>
<div class="form-group row">
<label for="nombre" class="col-sm-2 col-form-label">Nombre</label>
<div class="col-sm-3">
<input type="text" name="nombre" class="form-control" id="nombre" data-ng-model="chofer.nombre" placeholder="Ingrese nombre" data-ng-disabled="chofer.id == null && situacion.chofer == 'registrado'">
</div>
<label for="apellido" class="col-sm-2 col-form-label">Apellido</label>
<div class="col-sm-3">
<input type="text" name="apellido" class="form-control" id="apellido" data-ng-model="chofer.apellido" placeholder="Ingrese apellido" data-ng-disabled="chofer.id == null && situacion.chofer == 'registrado'">
</div>
</div>
<div class="form-group row">
<label for="telefono" class="col-sm-2 col-form-label">Teléfono</label>
<div class="col-sm-3">
<input type="text" name="telefono" class="form-control" id="telefono" data-ng-model="chofer.telefono" disabled>
<span class="error" id="telefonoError">Número de teléfono invalido.</span>
</div>
<label for="empresa" class="col-sm-2 col-form-label">Empresa</label>
<div class="col-sm-3">
<select class="form-control" name="empresa" id="empresa" data-ng-model="empresas.seleccionada" multiple="multiple" data-ng-options="empresa.id as empresa.razon_social for empresa in aEmpresas" data-ng-disabled="chofer.id == null && situacion.chofer == 'registrado'">
</select>
</div>
</div>
<div class="form-group">
<div class="col"><hr></div>
</div>
<div class="form-group row">
<div class="col-sm-2">
<a href="{{path('public_inicio')}}" class="btnMsec" >Volver</a>
</div>
<div class="col-md-6"></div>
<div class="col-md-4">
<button id="botonRegistrarChofer" data-ng-if="chofer.id == null && situacion.chofer == 'nuevo'" type="button" data-ng-click="registrarChofer()" class="btnM colorBase">Registrar</button>
<button id="editarChofer" data-ng-if="gestionarPrecargas" type="button" class="btnM btn-primary" data-ng-click="editarChofer();">Editar datos</a>
<button id="gestionarPrecargas" data-ng-if="gestionarPrecargas" type="button" class="btnM colorBase" data-ng-click="redirectPrecargas(chofer.id);">Precargas</button>
</div>
</div>
</form>
</div>
<br/>
</section>
{% endblock %}
{% block javascripts %}
<script type="text/javascript" src="{{asset('app/js/controllers/choferController.js')}}"></script>
<script type="text/javascript" src="{{asset('app/js/services/choferService.js')}}"></script>
<script type="text/javascript" src="{{asset('app/node_modules/select2/dist/js/select2.min.js')}}"></script>
<script type="text/javascript" src="{{asset('app/node_modules/select2/dist/js/i18n/es.js')}}"></script>
<script type="text/javascript" src="{{asset('app/node_modules/intl-tel-input/build/js/intlTelInput.min.js')}}"></script>
{% endblock %}