{% extends "base.html" %}

{% load static %}

{% load crispy_forms_tags %}

{% block content %}


      <!-- End Navbar -->
      <div class="content">
        <div class="container-fluid">
          <div class="row">

            

            {% if user.is_authenticated %}
            <a href="{% url 'index' %}" class="btn btn-info float-right" >Principal</a>
            <a href="{% url 'crear_ordservicio' %}" class="btn btn-info float-right" >Ingresar Orden de Servicio</a>
            <a href="{% url 'crear_servrealizado' %}" class="btn btn-info float-right" >Ingresar Servicio a una Orden</a>
            <a href="{% url 'crear_accesorios' %}" class="btn btn-info float-right" >Ingresar Accesorios a una Orden</a> 
            
          </div>
          <div class="row">  
            <form method="POST" target="_blank"  action="{% url 'consultaequipo' %}" class="mt-3" autocomplete="off">
              {% csrf_token %}
              <div class="input-group mb-3">
                  <div class="input-group-prepend">
                      <button type="submit" class="btn btn-success">Consultar</button>
                  </div>
                  <div class="input-group-prepend">
                    <input name="n_control2" id="n_control2" type="number" class="form-control" value="{{ datos.n_control }}"> 
                  </div>
              </div>
            </form>
            {% endif %}

            <div class="col-md-12">
              <div class="card">
                <div class="card-header card-header-primary">
                  <h4 class="card-title ">Orden de Servicio</h4>
                  <p class="card-category"></p>
                </div>
              </div>

                
                  <form method="POST" action="" class="mt-3" autocomplete="off" >
                    {% csrf_token %}
                    <div class="col-12">
                      <div class="row">
                        
                        <div class="card col-6">
                          <div class="card-header card-header-primary">
                            <h4 class="card-title ">Datos de Identificacion</h4>
                          </div>
                        
                          <div class="card-body">
                          <p>Folio</p>
                          <input name="folio" type="text" placeholder="{{ folio }}" class="form-control" value="{{ folio }}" readonly> <br>
                          <p>No. de Reporte</p>
                          <input name="n_reporte"       type="text" class="form-control" value="{{ controlb }}" readonly> <br>
                          <p>No. de Control</p>
                          <input name="orden_n_control" id="n_control1" type="text" class="form-control" value="{{ datos.n_control }}" oninput="verificar()"> <br>
                          <p>Turno</p>
                          <input name="turno" type="text" class="form-control" value="{{ hora }}" readonly> <br>
                          <p>REPORTA</p>
                          <input name="reporta" type="text" class="form-control" value="{{ quien_reporta }}" readonly> <br>
                          <p>Asignado IB</p>
                          <input name="ib1" type="hidden" class="form-control" value="{{ reporta_ib }}" readonly> <br>
                          <input name="ib1-1" type="text" class="form-control" value="{{ reporta_ib_1 }}" readonly> <br>
                          <input name="ib2" type="hidden" class="form-control" value=""> <br>
                          
                          
                          </div>
                          
                        </div>
                        <div class="card col-6">
                          <div class="card-header card-header-primary">
                            <h4 class="card-title ">Descripcion del Servicio</h4>
                          </div>
                          
                          <div class="card-body">
                            {{ form2|crispy }}
                            <p><strong>Falla Detectada</strong></p>
                            <input name="falla_detectada" type="text" class="form-control" value="" > <br>

                            <p><strong>Servicio Realizado</strong></p>
                            <table border="1">
                              <thead class="text-primary" >
                              <tr>
                                <th>Fecha</th>
                                <th>IB</th>
                                <th>DESCRIPCIÓN</th>
                              </tr>
                              </thead>
                              <tbody>
                                {% for datosse in datosseg %}
                                  <tr>
                                    <td> {{ datosse.fecha }}</td>
                                    <td> {{ datosse.ib }}</td>
                                    <td> {{ datosse.descripcion }}</td>
                                  </tr>
                                {% endfor %}
                              </tbody>
                            </table>

                          </div>
                        
                        </div>

                        <div class="card col-6">
                          <div class="card-header card-header-primary">
                            <h4 class="card-title ">Accesorios/Refacciones/Consumibles</h4>
                          </div>
                          
                          <div class="card-body">
                            <table border="1">
                              <thead class="text-primary" >
                              <tr>
                                <th>Cantidad</th>
                                <th>N. Parte</th>
                                <th>Descripción</th>
                              </tr>
                              </thead>
                              <tbody>
                            {% for datosac in datosacc %}
                              <tr>
                                <td>{{ datosac.cantidad }}</td>
                                <td>{{ datosac.n_parte }}</td>
                                <td>{{ datosac.descripcion }}</td>
                              </tr>
                              <br>
                            {% endfor %}
                          </tbody>
                        </table>

                          </div>
                        
                        </div>


                                                


                        <div class="card col-6">
                          <div class="card-header card-header-primary">
                            <h4 class="card-title ">Consumibles en General</h4>
                          </div>
                          <div class="card-body">
                            {{ form3|crispy }}
                          </div>
                        </div>

                        <div class="card col-6">
                          <div class="card-header card-header-primary">
                            <h4 class="card-title ">Estado del Servicio </h4>
                          </div>
                          <div class="card-body">
                            {{ form4|crispy }}
                          </div>
                        </div>

                        <div class="card col-6">
                          <div class="card-header card-header-primary">
                            <h4 class="card-title ">Servicio Externo</h4>
                          </div>
                          <div class="card-body">
                            {{ form5|crispy }}
                          </div>
                        </div>

                        <div class="card col-6">
                          <div class="card-header card-header-primary">
                            <h4 class="card-title ">Ingenieros </h4>
                          </div>
                          <div class="card-body">
                            {{ form6|crispy }}
                          </div>
                        </div>
                      </div>



                    <button type="submit" class="btn btn-success">Guardar</button>
                  </form>
                
              
            </div>


                      
            
            
            
          </div>
        </div>
      </div>

      {% endblock content %}


{% block javascript %}

<script>try {function verificar() {
  var myBox1 = document.getElementById('n_control1').value; 
  var result = document.getElementById('n_control2'); 
  var myResult = myBox1;
  result.value = myResult;
  }
} catch (error) { throw error; }

</script>


{% endblock javascript %}
      