File "infoRegistro-20260419142950.js"

Full Path: C:/wamp64/www/INVENTALMACEN/js/infoRegistro-20260419142950.js
File size: 4.46 KB
MIME-type: text/plain
Charset: utf-8

$('#formInfoRegistro').submit(function (e) {
  e.preventDefault();
  var dcto = $.trim($('#dcto').val());
  var fecha = $.trim($('#fecha').val());
  var cliente = $.trim($('#cliente').val());
  var ubicacion = $.trim($('#ubicacion').val());
  var planilla = $.trim($('#planilla').val());

  $.ajax({
    url: '../controller/infoRegistro.php',
    type: 'POST',
    datatype: 'json',
    data: {
      dcto: dcto,
      fecha: fecha,
      cliente: cliente,
      ubicacion: ubicacion,
      planilla: planilla,
    },
    success: function (data) {
      if (data == 'null') {
        Swal.fire({
          icon: 'error',
          title: 'Usuario y/o contraseña incorrecta',
        });
      } else {
        Swal.fire({
          icon: 'success',
          title: '!Conexion Exitosa¡',
          confirmButtonColor: '#3085d6',
          confirmButtonText: 'Ingresar',
        }).then((result) => {
          if (result.value) {
            window.location.href = '../views/registro.php';
          }
        });
      }
    },
  });
});

//----------------------------------------------------------------------------------------------------------
$('#formControlPesoProm').submit(function (e) {
  e.preventDefault();

  var listLinea = $.trim($('#listLinea').val());
  var listItem = $.trim($('#listItem').val());
  var tpRegistro = $.trim($('#tpRegistro').val());
 // var inpPeso = $.trim($('#inpPeso').val());
  var inpUnidad = $.trim($('#inpUnidad').val());
  var inpLote = $.trim($('#inpLote').val());
  //var inpPesoProm = $.trim($('#inpPesoProm').val());
  //var listTara = $.trim($('#listTara').val());
  //var inpTara = $.trim($('#inpTara').val());
  //var inpBase = $.trim($('#inpBase').val());
  //var checSkin = $('#checSkin').is(':checked') ? 'on' : '';
  //var checMap = $('#checMap').is(':checked') ? 'on' : '';

  $.ajax({
    url: '../controller/controlPesoProm.php',
    type: 'POST',
    datatype: 'json',
    data: {
      listLinea: listLinea,
      listItem: listItem,
      tpRegistro: tpRegistro,
      //inpPeso: inpPeso,
      inpUnidad: inpUnidad,
      inpLote: inpLote,
      //inpPesoProm: inpPesoProm,
     // listTara: listTara,
      //inpTara: inpTara,
      //inpBase: inpBase,
      //checSkin: checSkin,
      //checMap: checMap,
    },
    success: function (data) {
      let respuesta = {};
      try {
        respuesta = JSON.parse(data);
      } catch (e) {
        console.error('Respuesta no es JSON:', data);
        Swal.fire({
          icon: 'error',
          title: 'Error de respuesta del servidor',
          text: 'Por favor verifique los datos.',
        });
        return;
      }

      if (!respuesta || typeof respuesta.estado === 'undefined') {
        // Para datos "null" o sin estructura válida
        Swal.fire({
          icon: 'error',
          title: 'Ha ocurrido un error en el registro',
          text: '¿Desea continuar bajo autorización?',
          showCancelButton: true,
          confirmButtonColor: '#dc3545',
          confirmButtonText: 'Autorizar',
          cancelButtonText: 'Verificar',
        }).then((result) => {
          if (result.value) {
            $('#modalLoginForm').modal('show');
          }
        });
        return;
      }

      // Registro exitoso
      if (respuesta.estado === 'ok') {
        Swal.fire({
          icon: 'success',
          title: '¡Registro realizado exitosamente!',
          confirmButtonColor: '#3085d6',
          confirmButtonText: 'Aceptar',
        });
        $('#inpLote, #inpUnidad').val('');
      }

      // Error SQL
      else if (respuesta.estado === 'error_sql') {
        Swal.fire({
          icon: 'error',
          title: 'Error SQL',
          text: respuesta.mensaje,
        });
      }

      // Peso fuera de rango con opción a continuar
    /*  else if (respuesta.estado === 'error_peso_promedio') {
        Swal.fire({
          icon: 'warning',
          title: 'Peso promedio fuera de rango',
          html: `Valor calculado: <b>${respuesta.valorProm}</b><br>Debe estar entre <b>${respuesta.rangoMin}</b> y <b>${respuesta.rangoMax}</b>`,
          showCancelButton: true,
          confirmButtonColor: '#dc3545',
          confirmButtonText: 'Autorizar',
          cancelButtonText: 'Verificar',
        }).then((result) => {
          if (result.value) {
            $('#modalLoginForm').modal('show');
          }
        });
      }*/
    },
  });
});