<!--
=========================================================
* Soft UI Dashboard 3 - v1.1.0
=========================================================

* Product Page: https://www.creative-tim.com/product/soft-ui-dashboard
* Copyright 2024 Creative Tim (https://www.creative-tim.com)
* Licensed under MIT (https://www.creative-tim.com/license)
* Coded by Creative Tim

=========================================================

* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="apple-touch-icon" sizes="76x76" href="https://cybernovasystems.com/prueba/pago/imagenes/logocofi.jpg">
  <link rel="icon" type="image/png" href="https://cybernovasystems.com/prueba/pago/imagenes/logocofi.jpg">
  <title>
Qodifica
  </title>
  <!--     Fonts and icons     -->
  <link href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700,800" rel="stylesheet" />
  <!-- Nucleo Icons -->
  <link href="https://demos.creative-tim.com/soft-ui-dashboard/assets/css/nucleo-icons.css" rel="stylesheet" />
  <link href="https://demos.creative-tim.com/soft-ui-dashboard/assets/css/nucleo-svg.css" rel="stylesheet" />
  <!-- Font Awesome Icons -->
  <script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
  <!-- CSS Files -->
  <link id="pagestyle" href="assets/css/soft-ui-dashboard.css?v=1.1.0" rel="stylesheet" />
  <!-- Nepcha Analytics (nepcha.com) -->
  <!-- Nepcha is a easy-to-use web analytics. No cookies and fully compliant with GDPR, CCPA and PECR. -->
  <script defer data-site="YOUR_DOMAIN_HERE" src="https://api.nepcha.com/js/nepcha-analytics.js"></script>
</head>

<body class="g-sidenav-show  bg-gray-100">
  <head>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
  <style>
    
.icon-sm:not(.active) i {
    top: 2px;
    color: black;
    font-size: 0.65rem;
}
  </style>
</head>
<aside class="sidenav navbar navbar-vertical navbar-expand-xs border-0 border-radius-xl my-3 fixed-start ms-3 " id="sidenav-main">
  <div class="sidenav-header">
    <i class="fas fa-times p-3 cursor-pointer text-secondary opacity-5 position-absolute end-0 top-0 d-none d-xl-none" aria-hidden="true" id="iconSidenav"></i>
    <a class="navbar-brand m-0" href="https://qodifica.com/Qodifica/personal.php" target="_blank">
      <img src="https://cybernovasystems.com/prueba/pago/imagenes/logocofi.jpg" class="navbar-brand-img h-100" alt="main_logo">
      <span class="ms-1 font-weight-bold">Sistema de Liquidaciones</span>
    </a>
  </div>
  <hr class="horizontal dark mt-0">
  <div class="collapse navbar-collapse  w-auto " id="sidenav-collapse-main">
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link " href="https://qodifica.com/Qodifica/personal.php">
          <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
            <i class="fas fa-tachometer-alt"></i>
          </div>
          <span class="nav-link-text ms-1">Personal</span>
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link " href="https://qodifica.com/Qodifica/trabajos.php">
          <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
            <i class="fas fa-table"></i>
          </div>
          <span class="nav-link-text ms-1">Trabajos</span>
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link " href="https://qodifica.com/Qodifica/series.php">
          <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
            <i class="fas fa-credit-card"></i>
          </div>
          <span class="nav-link-text ms-1">Series</span>
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link " href="https://qodifica.com/Qodifica/lista_trabajos_liquidados.php">
          <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
            <i class="fas fa-check-circle"></i>
          </div>
          <span class="nav-link-text ms-1">Trabajos Liquidados</span>
        </a>
      </li>
       <!-- Nuevo campo de menú "Bloqueados" -->
      <li class="nav-item">
        <a class="nav-link active" href="https://qodifica.com/Qodifica/trabajos_bloqueado.php">
          <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
            <i class="fas fa-lock"></i>
          </div>
          <span class="nav-link-text ms-1">Bloqueados</span>
        </a>
      </li>
    </ul>
  </div>
</aside>

  <main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
    <!-- Navbar -->
    <nav class="navbar navbar-main navbar-expand-lg px-0 mx-4 shadow-none border-radius-xl" id="navbarBlur" navbar-scroll="true">
      <div class="container-fluid py-1 px-3">
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb bg-transparent mb-0 pb-0 pt-1 px-0 me-sm-6 me-5">
            <li class="breadcrumb-item text-sm"><a class="opacity-5 text-dark" href="javascript:;">Pagina</a></li>
            <li class="breadcrumb-item text-sm text-dark active" aria-current="page">Modulo</li>
          </ol>
          <h6 class="font-weight-bolder mb-0">Trabajos</h6>
        </nav>
        <div class="collapse navbar-collapse mt-sm-0 mt-2 me-md-0 me-sm-4" id="navbar">
          <div class="ms-md-auto pe-md-3 d-flex align-items-center">
            
          </div>
          <ul class="navbar-nav  justify-content-end">
            <li class="nav-item d-flex align-items-center">
              <a class="btn btn-outline-primary btn-sm mb-0 me-3" target="_blank" href="https://www.creative-tim.com/builder?ref=navbar-soft-ui-dashboard">Version 1</a>
            </li>
            <li class="nav-item d-flex align-items-center">
              <a href="javascript:;" class="nav-link text-body font-weight-bold px-0">
                <i class="fa fa-user me-sm-1"></i>
                <span class="d-sm-inline d-none">Sign In</span>
              </a>
            </li>
          
              </a>
            
            </li>
          </ul>
        </div>
      </div>
    </nav>
      <div class="relative flex flex-col min-w-0 mb-6 break-words bg-white dark:bg-gray-950 shadow-soft-xl dark:shadow-soft-dark-xl rounded-2xl bg-clip-border">
    <div class="flex-auto p-4">
        <div class="flex flex-wrap -mx-3">
            <div class="flex-none w-full max-w-full px-3">
                <div>
                    <p class="mb-0 font-sans font-semibold leading-normal text-sm dark:opacity-60">Selecciona tu archivo Excel</p>
                     <form id="uploadForm" enctype="multipart/form-data">
        <input type="file" name="archivo_excel" id="archivo_excel" accept=".xlsx, .xls" required>
        <button type="submit">Subir</button>
    </form>
    <div id="mensaje"></div> 
                </div>
            </div>
            <div class="w-4/12 max-w-full px-3 text-right flex-0">
                <div class="inline-block w-12 h-12 text-center rounded-lg bg-gradient-to-tl from-purple-700 to-pink-500 shadow-soft-2xl">
                    <i class="ni leading-none ni-upload text-lg relative top-3.5 text-white" aria-hidden="true"></i>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-lg-6 col-md-6 col-12">
        <div class="card">
            <span class="mask bg-primary opacity-10 border-radius-lg"></span>
            <div class="card-body p-3 position-relative">
                <div class="row">
                    <div class="col-8 text-start">
                        <div class="icon icon-shape bg-white shadow text-center border-radius-2xl">
                            <i class="fa fa-tasks text-dark text-gradient text-lg opacity-10" aria-hidden="true"></i>
                        </div>
                        <h5 class="text-white font-weight-bolder mb-0 mt-3">
                            <span id="pendientes">0</span>
                        </h5>
                        <span class="text-white text-sm">Pendientes</span>
                    </div>
                    <div class="col-4">
                        <div class="dropdown text-end mb-6">
                            <a href="javascript:;" class="cursor-pointer" id="dropdownPendientes" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fa fa-ellipsis-h text-white"></i>
                            </a>
                            <ul class="dropdown-menu px-2 py-3" aria-labelledby="dropdownPendientes">
                                <li><a class="dropdown-item border-radius-md" href="javascript:;">Acci��n</a></li>
                                <li><a class="dropdown-item border-radius-md" href="javascript:;">Otra acci��n</a></li>
                                <li><a class="dropdown-item border-radius-md" href="javascript:;">Algo m��s</a></li>
                            </ul>
                        </div>
                        <p class="text-white text-sm text-end font-weight-bolder mt-auto mb-0">+55%</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="col-lg-6 col-md-6 col-12 mt-4 mt-md-0">
        <div class="card">
            <span class="mask bg-dark opacity-10 border-radius-lg"></span>
            <div class="card-body p-3 position-relative">
                <div class="row">
                    <div class="col-8 text-start">
                        <div class="icon icon-shape bg-white shadow text-center border-radius-2xl">
                            <i class="fa fa-check-circle text-dark text-gradient text-lg opacity-10" aria-hidden="true"></i>
                        </div>
                        <h5 class="text-white font-weight-bolder mb-0 mt-3">
                            <span id="terminados">0</span>
                        </h5>
                        <span class="text-white text-sm">Liquidados</span>
                    </div>
                    <div class="col-4">
                        <div class="dropstart text-end mb-6">
                            <a href="javascript:;" class="cursor-pointer" id="dropdownTerminados" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fa fa-ellipsis-h text-white"></i>
                            </a>
                            <ul class="dropdown-menu px-2 py-3" aria-labelledby="dropdownTerminados">
                                <li><a class="dropdown-item border-radius-md" href="javascript:;">Acci��n</a></li>
                                <li><a class="dropdown-item border-radius-md" href="javascript:;">Otra acci��n</a></li>
                                <li><a class="dropdown-item border-radius-md" href="javascript:;">Algo m��s</a></li>
                            </ul>
                        </div>
                        <p class="text-white text-sm text-end font-weight-bolder mt-auto mb-0">+124%</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <!-- End Navbar -->
    <div class="container-fluid py-4">
      <div class="row">
        <div class="col-12">
          <div class="card mb-4">
            <div class="card-header pb-0">
              <h6>Bloqueados</h6>
            </div>
            <div class="card-body px-0 pt-0 pb-2">
              <div class="table-responsive p-0">
             <div>
   
</div>
<input type="text" id="buscador" placeholder="Buscar por pedido o técnico..."
  style="margin-bottom: 10px; padding: 6px; width: 100%; max-width: 300px; border: 1px solid #ccc; border-radius: 4px;">


  <table id="tablaTrabajos" class="table align-items-center mb-0">
    <thead>
      <tr>
        <th>Datos</th>
        <th></th>
        <th></th>
        <th></th>
       
        <th>Accion</th>
      
      </tr>
    </thead>
    <tbody></tbody>
  </table>
              </div>
            </div>
          </div>
        </div>
      </div>
     
   <footer class="footer pt-3">
  <div class="container-fluid">
    <div class="row align-items-center justify-content-lg-between">
      <div class="col-lg-6 mb-lg-0 mb-4">
        <div class="copyright text-center text-sm text-muted text-lg-start">
          �0�8 <script>
            document.write(new Date().getFullYear())
          </script>,
          hecho con <i class="fa fa-heart"></i> por
          <a href="https://www.cybernovasystems.com" class="font-weight-bold" target="_blank">CyberNovaSystems</a>
          para una web mejor.
        </div>
      </div>
      <div class="col-lg-6">
        <ul class="nav nav-footer justify-content-center justify-content-lg-end">
          <li class="nav-item">
            <a href="https://www.cybernovasystems.com" class="nav-link text-muted" target="_blank">CyberNovaSystems</a>
          </li>
          <li class="nav-item">
            <a href="https://www.cybernovasystems.com/acerca-de" class="nav-link text-muted" target="_blank">Sobre nosotros</a>
          </li>
          <li class="nav-item">
            <a href="https://www.cybernovasystems.com/blog" class="nav-link text-muted" target="_blank">Blog</a>
          </li>
          <li class="nav-item">
            <a href="https://www.cybernovasystems.com/terminos-y-condiciones" class="nav-link pe-0 text-muted" target="_blank">Licencia</a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</footer>

    </div>
  </main>
  <div class="fixed-plugin">
    <a class="fixed-plugin-button text-dark position-fixed px-3 py-2">
      <i class="fa fa-cog py-2"> </i>
    </a>
    <div class="card shadow-lg ">
      <div class="card-header pb-0 pt-3 ">
        <div class="float-start">
          <h5 class="mt-3 mb-0">Soft UI Configurator</h5>
          <p>See our dashboard options.</p>
        </div>
        <div class="float-end mt-4">
          <button class="btn btn-link text-dark p-0 fixed-plugin-close-button">
            <i class="fa fa-close"></i>
          </button>
        </div>
        <!-- End Toggle Button -->
      </div>
      <hr class="horizontal dark my-1">
      <div class="card-body pt-sm-3 pt-0">
        <!-- Sidebar Backgrounds -->
        <div>
          <h6 class="mb-0">Sidebar Colors</h6>
        </div>
        <a href="javascript:void(0)" class="switch-trigger background-color">
          <div class="badge-colors my-2 text-start">
            <span class="badge filter bg-primary active" data-color="primary" onclick="sidebarColor(this)"></span>
            <span class="badge filter bg-gradient-dark" data-color="dark" onclick="sidebarColor(this)"></span>
            <span class="badge filter bg-gradient-info" data-color="info" onclick="sidebarColor(this)"></span>
            <span class="badge filter bg-gradient-success" data-color="success" onclick="sidebarColor(this)"></span>
            <span class="badge filter bg-gradient-warning" data-color="warning" onclick="sidebarColor(this)"></span>
            <span class="badge filter bg-gradient-danger" data-color="danger" onclick="sidebarColor(this)"></span>
          </div>
        </a>
        <!-- Sidenav Type -->
        <div class="mt-3">
          <h6 class="mb-0">Sidenav Type</h6>
          <p class="text-sm">Choose between 2 different sidenav types.</p>
        </div>
        <div class="d-flex">
          <button class="btn btn-primary w-100 px-3 mb-2 active" data-class="bg-transparent" onclick="sidebarType(this)">Transparent</button>
          <button class="btn btn-primary w-100 px-3 mb-2 ms-2" data-class="bg-white" onclick="sidebarType(this)">White</button>
        </div>
        <p class="text-sm d-xl-none d-block mt-2">You can change the sidenav type just on desktop view.</p>
        <!-- Navbar Fixed -->
        <div class="mt-3">
          <h6 class="mb-0">Navbar Fixed</h6>
        </div>
        <div class="form-check form-switch ps-0">
          <input class="form-check-input mt-1 ms-auto" type="checkbox" id="navbarFixed" onclick="navbarFixed(this)">
        </div>
        <hr class="horizontal dark my-sm-4">
        <a class="btn bg-gradient-dark w-100" href="https://www.creative-tim.com/product/soft-ui-dashboard">Free Download</a>
        <a class="btn btn-outline-dark w-100" href="https://www.creative-tim.com/learning-lab/bootstrap/license/soft-ui-dashboard">View documentation</a>
        <div class="w-100 text-center">
          <a class="github-button" href="https://github.com/creativetimofficial/soft-ui-dashboard" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star creativetimofficial/soft-ui-dashboard on GitHub">Star</a>
          <h6 class="mt-3">Thank you for sharing!</h6>
          <a href="https://twitter.com/intent/tweet?text=Check%20Soft%20UI%20Dashboard%20made%20by%20%40CreativeTim%20%23webdesign%20%23dashboard%20%23bootstrap5&amp;url=https%3A%2F%2Fwww.creative-tim.com%2Fproduct%2Fsoft-ui-dashboard" class="btn btn-dark mb-0 me-2" target="_blank">
            <i class="fab fa-twitter me-1" aria-hidden="true"></i> Tweet
          </a>
          <a href="https://www.facebook.com/sharer/sharer.php?u=https://www.creative-tim.com/product/soft-ui-dashboard" class="btn btn-dark mb-0 me-2" target="_blank">
            <i class="fab fa-facebook-square me-1" aria-hidden="true"></i> Share
          </a>
        </div>
      </div>
    </div>
  </div>
  <!--   Core JS Files   -->
  <script src="../assets/js/core/popper.min.js"></script>
  <script src="../assets/js/core/bootstrap.min.js"></script>
  <script src="../assets/js/plugins/perfect-scrollbar.min.js"></script>
  <script src="../assets/js/plugins/smooth-scrollbar.min.js"></script>
  <script>
    var win = navigator.platform.indexOf('Win') > -1;
    if (win && document.querySelector('#sidenav-scrollbar')) {
      var options = {
        damping: '0.5'
      }
      Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
    }
  </script>
  <!-- Github buttons -->
  <script async defer src="https://buttons.github.io/buttons.js"></script>
  <!-- Control Center for Soft Dashboard: parallax effects, scripts for the example pages etc -->
  <script src="../assets/js/soft-ui-dashboard.min.js?v=1.1.0"></script>
</body>

</html>


    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">


<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Subir Trabajos</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>


<!-- Agrega estos enlaces de estilo y script para SweetAlert2 -->
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.1.8/dist/sweetalert2.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.1.8/dist/sweetalert2.min.js"></script>


</body>
</html>


  <script>
let todosLosTrabajos = [];

async function cargarTrabajosBloqueados() {
  const res = await fetch('listar_bloqueados.php');
  todosLosTrabajos = await res.json();
  mostrarTrabajos(todosLosTrabajos);
}

function mostrarTrabajos(trabajos) {
  const tbody = document.querySelector("#tablaTrabajos tbody");
  tbody.innerHTML = "";

  if (trabajos.length === 0) {
    const fila = document.createElement("tr");
    fila.innerHTML = `<td colspan="5" style="text-align: center; font-style: italic;">No hay trabajos bloqueados aún</td>`;
    tbody.appendChild(fila);
    return;
  }

  trabajos.forEach(trabajo => {
    const fila = document.createElement("tr");
    fila.innerHTML = `
      <td class="align-middle" style="text-align: left; font-size: 12px;">
        <div style="margin-bottom: 6px;">
          <p class="text-xs font-weight-bold mb-0">Cliente:</p>
          <p class="text-xs mb-0">${trabajo.cliente}</p>
        </div>
        <div>
          <p class="text-xs font-weight-bold mb-0">Pedido:</p>
          <p class="text-xs mb-0">${trabajo.codigo || '<span style="color: gray;">No disponible</span>'}</p>
        </div>
      </td>
      <td class="align-middle" style="text-align: left; font-size: 12px;">
        <div style="margin-bottom: 6px;">
          <p class="text-xs font-weight-bold mb-0">DNI:</p>
          <p class="text-xs mb-0">${trabajo.dni}</p>
        </div>
        <div>
          <p class="text-xs font-weight-bold mb-0">Dirección:</p>
          <p class="text-xs mb-0">${trabajo.direccion}</p>
        </div>
      </td>
      <td class="align-middle" style="text-align: left; font-size: 12px;">
        <div style="margin-bottom: 6px;">
          <p class="text-xs font-weight-bold mb-0">Distrito:</p>
          <p class="text-xs mb-0">${trabajo.distrito}</p>
        </div>
        <div>
          <p class="text-xs font-weight-bold mb-0">Técnico:</p>
          <p class="text-xs mb-0">${trabajo.tecnico}</p>
        </div>
      </td>
      <td class="align-middle" style="text-align: left; font-size: 12px;">
        <div style="margin-bottom: 6px;">
          <p class="text-xs font-weight-bold mb-0">Estado:</p>
          <p class="text-xs mb-0">${trabajo.estado}</p>
        </div>
        <div>
          <p class="text-xs font-weight-bold mb-0">Fecha:</p>
          <p class="text-xs mb-0">${trabajo.fecha_registro}</p>
        </div>
      </td>
      <td>
        <button class="desbloquear-btn" data-id="${trabajo.id}"
          style="padding: 5px 10px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">
          Desbloquear
        </button>
      </td>
    `;
    tbody.appendChild(fila);
  });

  // Eventos de desbloqueo
  document.querySelectorAll('.desbloquear-btn').forEach(boton => {
    boton.addEventListener('click', (event) => {
      const id = event.target.getAttribute('data-id');
      confirmarDesbloqueo(id, event.target);
    });
  });
}

// Filtro en tiempo real
document.getElementById("buscador").addEventListener("input", (e) => {
  const texto = e.target.value.toLowerCase();
  const filtrados = todosLosTrabajos.filter(t =>
    (t.codigo && t.codigo.toLowerCase().includes(texto)) ||
    (t.tecnico && t.tecnico.toLowerCase().includes(texto))
  );
  mostrarTrabajos(filtrados);
});




    // Función para mostrar confirmación antes de desbloquear
    function confirmarDesbloqueo(id, boton) {
      Swal.fire({
        title: '¿Estás seguro?',
        text: "¡El trabajo será desbloqueado y marcado como 'Pendiente'!",
        icon: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#28a745',
        cancelButtonColor: '#d33',
        confirmButtonText: 'Sí, desbloquear'
      }).then(async (result) => {
        if (result.isConfirmed) {
          desbloquearTrabajo(id, boton);  // Si confirma, desbloquear
        }
      });
    }

    // Función para desbloquear el trabajo
    async function desbloquearTrabajo(id, boton) {
      boton.disabled = true;
      const res = await fetch('desbloquear_trabajo.php', {
        method: 'POST',
        headers: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        body: `id=${id}`
      });

      const data = await res.json();

      // Mostrar mensaje con SweetAlert2
      Swal.fire({
        icon: 'success',
        title: '¡Desbloqueado!',
        text: data.mensaje,
        confirmButtonColor: '#007BFF'
      });

      cargarTrabajosBloqueados(); // Recargar tabla
    }

    // Cargar trabajos bloqueados al iniciar
    cargarTrabajosBloqueados();
  </script>
