{# Plantilla de Twig #}
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('plugins/toastr/toastr.min.css') }}">
{% endblock %}
<!-- Modal with form -->
<!-- div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" -->
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content p-4">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><b>Solicitudes programadas</b> <b><span class="text-success">{% if info is defined %} {{ info.tipoEquipo }} {% endif %}</span></b><small>Mantenimiento {% if info is defined %} {{ info.tipoMantenimiento }} {% endif %}</small></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Usuario</th>
<th>Equipo</th>
</tr>
</thead>
<tbody>
<tr>
{% if solicitud[0] is defined %}
<td>{{solicitud[0].u_nombre}} {{solicitud[0].u_papellido}} {{solicitud[0].u_sapellido}}</td>
<td>Marbete: <b>{{solicitud[0].marbete}}</b></br>Descripción: <b>{{solicitud[0].descripcion}}</b></br>Marca: <b>{{solicitud[0].marca}}</b></br>Modelo: <b>{{solicitud[0].modelo}}</b></br>Ubicación: <b>{{solicitud[0].n_ubicacion}}</b></br>Unidad Administrativa: <b>{{solicitud[0].n_unidad}}</b></td>
{% endif %}
</tr>
</tbody>
</table>
</div>
<div class="table-responsive">
<form id="form-editar-solicitud">
<table class="table table-hover">
<thead>
<tr>
<th>Id. Solicitud</th>
<th>Fecha de registro</th>
<th>Fecha de atención</th>
<th>Acción a realizar</th>
<th>Tipo de mantenimiento</th>
<th>Estatus</th>
<th>Accion</th>
</tr>
</thead>
<tbody>
{% for s in solicitud %}
<tr id="modal-table-{{ s.id_sol }}">
<th>{{ s.id_sol }}</th>
<td class="fregistro">
{% if s.fregistro != "" %}
{{ s.fregistro|format_datetime('medium', 'none', locale='es') }}
{% endif %}
</td>
<td>
{% if s.fatencion != "" %}
{{ s.fatencion|format_datetime('medium', 'none', locale='es') }}
{% endif %}
</td>
<td class="falla">{{ s.falla }}</td>
<td>
{% if s.tipo_mantenimiento == "MP" %}
Preventivo
{% endif %}
{% if s.tipo_mantenimiento == "MC" %}
Correctivo
{% endif %}
</td>
<td>
{% if s.estatus == 1 %}
<div class="badge bg-gradient-warning text-white" style="width: 6rem;">Pendiente</div>
{% elseif s.estatus == 2 %}
<div class="badge bg-gradient-danger" style="width: 6rem;">En proceso</div>
{% elseif s.estatus == 3 %}
<div class="badge bg-gradient-primary" style="width: 6rem;">Atendido</div>
{% elseif s.estatus == 4 %}
<div class="badge bg-gradient-success" style="width: 6rem;">Evaluado</div>
{% endif %}
</td>
<td>
{% if s.fregistro > date('-15days') %}
{# do something #}
{% if s is defined %}
{% if info.tipo_mantenimiento == 'Preventivo' %}
<a class="text-success" data-toggle="collapse" data-target="#collapseExample-{{ s.id_sol }}" role="button" aria-expanded="false" aria-controls="collapseExample-{{s.id_sol}}">
<i class="fa fa-calendar" data-toggle="tooltip" title="Reprogramar mantenimiento"></i>
</a>
{% endif %}
{% if info.tipo_mantenimiento == 'Correctivo' %}
<a href="{{ path('prog_correctivo_evaluacion', {'idSol': s.id_sol}) }}">
<i class="fa fa-check-circle text-primary" data-toggle="tooltip" title="Evaluar mantenimiento"></i>
</a>
{% endif %}
{% endif %}
{% endif %}
</td>
</tr>
<tr class="collapse" id="collapseExample-{{ s.id_sol }}">
<th colspan="6">
<label for="">Acción a realizar</label>
<input type="textarea" class="form-control" name="{{ s.id_sol }}-falla" value="{{ s.falla }}" required />
<label for="">Fecha de atención</label>
<input type="date" class="form-control" name="{{ s.id_sol }}-fregistro" value="{{ s.fatencion|date('Y-m-d') }}" required />
</th>
<th>
<button type="button" class="btn btn-primary pull-right" id="actualizar-solicitud-{{ s.id_sol }}" onclick="solicitudReprogramar('{{ path('prog_preventivo_reprogramar', {'id': s.id_sol}) }}', {{ s.id_sol }})">Actualizar</button>
</th>
</tr>
{% else %}
<tr>
<th class="text-center" colspan="7">No existen registros de servicios programados</th>
</tr>
{% endfor %}
</tbody>
</table>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
<!-- /div -->
{% block javascripts %}
<script src="{{ asset('plugins/toastr/toastr.min.js') }}"></script>
<script type="text/javascript">
function solicitudReprogramar(url, id){
let send = $("#actualizar-solicitud-" + id);
let formData = new FormData(document.getElementById("form-editar-solicitud"));
$.ajax({
type: "POST",
url: url,
data: formData, // Adjuntar los campos del formulario enviado.
dataType: "html",
cache: false,
contentType: false,
processData: false,
beforeSend: function () {
send.text(""); // Para input de tipo button
send.append("<i class='fa fa-spinner fa-spin' style='font-size:16px'></i>");
send.prop("disabled", true);
},
success: function (data) {
let datos = jQuery.parseJSON(data);
console.log(datos.mensaje);
$(document).Toasts('create', {
autohide: true,
delay: 5000,
class: 'bg-success',
title: 'Edición de programación',
subtitle: 'Éxito',
body: datos.mensaje
});
let row = $('#modal-table-' + datos.idsol);
row.find('.falla').html('<p class="text-primary"><b>' + datos.falla + '</b></p>');
/*row.find('.fregistro').html('<p class="text-primary"><b>' + datos.fregistro + '</b></p>');*/
},
error: function (data, text, error) {
},
complete: function () {
setTimeout(function(){
send.text("Actualizar"); // Para input de tipo button
send.append("<i></i>");
send.prop("disabled", false);
}, 5000);
}
});
return false; // Evitar ejecutar el submit del formulario.
}
</script>
{% endblock %}