127 lines
No EOL
4.6 KiB
JavaScript
127 lines
No EOL
4.6 KiB
JavaScript
var tableResultadoBusquedaCotizacion;
|
|
|
|
jQuery(document).ready(function ()
|
|
{
|
|
tableResultadoBusquedaCotizacion = $('#tableResultadoBusquedaCotizacion').DataTable();
|
|
tableResultadoBusquedaCotizacion.clear().draw();
|
|
var hiddenTaskStatus = $("#hiddenTaskStatus").val();
|
|
var hiddenIncident = $("#hiddenIncident").val();
|
|
var hiddenStep = $("#hiddenStep").val();
|
|
var hiddensol_co_cotizacion = $("#hiddensol_co_cotizacion").val();
|
|
|
|
if ((hiddenTaskStatus == "3" && hiddenStep == "AU_Cotiza") || (hiddenIncident != "0" && hiddenIncident != "")) {
|
|
$("#btnBuscarCotizaciones").hide();
|
|
$("#btnNuevaCotizacion").hide();
|
|
|
|
$("#divMotivosDevolucion").attr("style", "display:block");
|
|
|
|
TabBuscar_Onload(hiddensol_co_cotizacion);
|
|
|
|
//**************************************
|
|
//Obtiene los motivos de devolución
|
|
//**************************************
|
|
initializeFormMotivos(9, true, "DESTINATION");
|
|
|
|
//**************************************
|
|
//Si hay motivos de una vez los muestra
|
|
//**************************************
|
|
if (_HasMotivosDevolucion == true)
|
|
$('#modalMotivos').modal('show');
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.TabBuscar_Onload = function (id) {
|
|
var uri = 'api/CotizacionAPI/BusquedaCotizacion?idCotizacion=' + id;
|
|
|
|
$.getJSON(server + uri).done(function (data) {
|
|
if (data != null) {
|
|
if (data.CodigoRespuesta == "EXITOSO") {
|
|
tableResultadoBusquedaCotizacion.clear().draw();
|
|
|
|
$.each(data.Cotizaciones, function (key, item)
|
|
{
|
|
var option = $("#ucBtnBusqueda").html();
|
|
option = option.replace("[$sol_co_cotizacion]", item.IdCotizacion);
|
|
option = option.replace("[$sol_co_solicitud]", item.IdSolicitud);
|
|
option = option.replace("[$sol_co_cotizacion]", item.IdCotizacion);
|
|
|
|
|
|
var date = item.FechaCotizacion.split("T")[0];
|
|
var day = date.split("-")[2];
|
|
var month = date.split("-")[1];
|
|
var year = date.split("-")[0];
|
|
var fecha = day + "/" + month + "/" + year
|
|
|
|
|
|
//var date = new Date(item.FechaCotizacion);
|
|
//var day = date.getDate();
|
|
//var month = date.getMonth();
|
|
//var year = date.getFullYear();
|
|
//var fecha = day + "/" + (month + 1) + "/" + year
|
|
|
|
var ValorAutomovil = ToMoney(item.ValorAutomovil);
|
|
try {
|
|
tableResultadoBusquedaCotizacion.row.add([item.IdCotizacion, item.Solicitante.toLocaleUpperCase(), item.Identificacion, item.Vehiculo, ValorAutomovil, fecha, option]).draw();
|
|
}
|
|
catch (ex) {
|
|
toastr.error(ex);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
};
|
|
|
|
|
|
|
|
|
|
this.EliminarCotizacion = function (IdCotizacion) {
|
|
try
|
|
{
|
|
if (!confirm("Eliminar?"))
|
|
return;
|
|
|
|
var uri = format("api/CotizacionAPI/EliminarCotizacion/?IdCotizacion={0}", IdCotizacion);
|
|
|
|
$.getJSON(server + uri).done(function (data) {
|
|
if (data != null && data.CodigoRespuesta == "EXITOSO") {
|
|
toastr.success("Información eliminada", Message_Success);
|
|
TabBuscar_Onload();
|
|
}
|
|
else if (data.CodigoRespuesta == "ADVERTENCIA") {
|
|
toastr.warning(data.DescripcionRespuesta, Message_Warning);
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
ENDREQUEST();
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
}).then(function (value) {
|
|
|
|
ENDREQUEST();
|
|
});
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al intentar invocar el metodo de eliminación de cotizaciones. Vuelva a intentarlo mas tarde.", Message_Error);
|
|
}
|
|
|
|
};
|
|
|
|
|
|
$("#btnMotivosDevolucion").click(function () {
|
|
initializeFormMotivos(9, true, "DESTINATION");
|
|
$('#modalMotivos').modal('show');
|
|
}); |