From ef3a0e7133117bacfcb1abcfec4c74d95a4b05fc Mon Sep 17 00:00:00 2001 From: rakcsle Date: Thu, 17 Oct 2024 19:04:50 -0700 Subject: [PATCH] Calendario de Viajes cronograma cambio a Amchart4 --- Transportes/RepContratosCalendario.aspx | 2192 +++++++++++--------- Transportes/RepContratosCalendario.aspx.vb | 151 +- 2 files changed, 1333 insertions(+), 1010 deletions(-) diff --git a/Transportes/RepContratosCalendario.aspx b/Transportes/RepContratosCalendario.aspx index 4245b8d34..4a8940191 100644 --- a/Transportes/RepContratosCalendario.aspx +++ b/Transportes/RepContratosCalendario.aspx @@ -51,7 +51,7 @@ - + .gantt_parent_task { + background-color: #ffcccc !important; /* Color para las tareas principales */ + } - + .gantt_child_task { + background-color: #cce5ff !important; /* Color para las sub-tareas */ + } + --%> + + <%----%> @@ -409,7 +407,7 @@ -
+
Formato:   @@ -484,11 +482,31 @@ + +
-
-
+
+
+ + +
+
+
+
+
+ +
+
-
+ + + +
+
+
+ + + @@ -731,1026 +749,1206 @@ - - - + <%-- + --%> + <%----%> <%----%> - - --%> + + + + <%-- + + --%> + + + + + + + + + + + + + + + + + + + var PrimeraCargaCalendario = true; + var currentUpdateEvent; + var addStartDate; + var addEndDate; + var globalAllDay; + var view = null; + var date = null; + + function InitCalendar() { + $(document).ready(function () { + let mes = parseInt($('#<%=HidCurrentMonth.ClientID%>').val()); + let anio = parseInt($('#<%=HidCurrentYear.ClientID%>').val()); + + Calendario(mes, anio); + + }); + } + + function selectDate(start, end, allDay) { + } + + function updateEvent(event, element, esCalendario = true) { + + $('#<%=TxtCantidadPasajeros.ClientID%>').val(event.CantidadPasajeros); + $('#<%=TxtFolio.ClientID%>').val(event.NumeroContrato); + $('#<%=TxtObservaciones.ClientID%>').val(event.Observaciones); + $('#<%=TxtDescripcion.ClientID%>').val(event.description); + $('#<%=TxtUbicacion.ClientID%>').val(event.NombreAcercamiento); + + if (esCalendario) { + $('#<%=TxtFechaSalida.ClientID%>').val(formatearFechaISO(event.start._i)); + } else { + $('#<%=TxtFechaSalida.ClientID%>').val(formatearFechaISO(event.start)); + } + $('#<%=TxtFechaRegreso.ClientID%>').val(formatearFechaISO(event.FechaFinal)); + $('#<%=DdlClientes.ClientID%>').val(event.CveCliente); + + $('#<%=DdlChofer.ClientID%>').val(event.CvePersonal); + + if (event.CvePersonal2 > 0) { + $('#<%=chkSegundoChofer.ClientID%>').prop('checked', true); + setTimeout(function () { $('#<%=DdlChofer2.ClientID%>').val(event.CvePersonal2).change(); }, 500);; + ; + } else { + $('#<%=chkSegundoChofer.ClientID%>').prop('checked', false); + $('#<%=DdlChofer2.ClientID%>').val(-1); + } + + $('#<%=DdlEstatusContrato.ClientID%>').val(event.CveEventoEstatus); + $('#<%=TxtDolares.ClientID%>').val(event.Dolares); + $('#<%=TxtPesos.ClientID%>').val(event.Pesos); + $('#<%=TxtMoneda.ClientID%>').val(event.Moneda); + + + + $('#<%=TxtAnticipo.ClientID%>').val(event.Anticipo); + $('#<%=HdnCveContrato.ClientID%>').val(event.id); + $('#<%=DdlTipoAF.ClientID%>').val(event.CveTipoAF); + $('#<%=DdlSubProyectoModal.ClientID%>').val(event.CveSubProyecto); + + $('#<%= HidCveTipoAF.ClientID%>').val($('#<%=TxtAnticipo.ClientID%>').val()); + + <%--$('#<%=BtnDdlTipoAF.ClientID%>').click();--%> + <%--$('#<%=DdlAF.ClientID%>').val(event.CveActivoFijo);--%> + + $('#HidNumChoferes').val(event.NumChoferes); + + $('#HidRemisionSerieFolio').val(event.RemisionSerieFolio); + $('#HidCveVentaRemision').val(event.CveVentaRemision); + $('#HidRemisionSaldo').val(event.RemisionSaldo); + $('#HdnNumContrato').val(event.NumeroContrato); + + if (event.CveActivoFijo > 0) { + $('#HidCveAF').val(event.CveActivoFijo); + } else { + $('#HidCveAF').val('-1'); + } + + + if (event.NombreComercial !== null) { + $('#HidModClienteNombre').val(''); + } else { + $('#HidModClienteNombre').val(event.NombreComercial); + } + + $('#HidModCveCliente').val(event.CveCliente); + + $('#<%=HdnCveContrato.ClientID%>').click(); + + } + + function formatearFechaISO(fechaISO) { + let fecha = new Date(fechaISO); + + // Formatear la fecha en DD/MM/YYYY + let dia = fecha.getDate().toString().padStart(2, '0'); + let mes = (fecha.getMonth() + 1).toString().padStart(2, '0'); // getMonth() devuelve mes de 0-11 + let año = fecha.getFullYear(); + + // Formatear la hora en formato 24 horas + let horas = fecha.getHours().toString().padStart(2, '0'); + let minutos = fecha.getMinutes().toString().padStart(2, '0'); + let segundos = fecha.getSeconds().toString().padStart(2, '0'); + + // Combinar la fecha y la hora + return `${dia}/${mes}/${año} ${horas}:${minutos}:${segundos}`; + } + + + //function formatearFechaISO(fechaISO) { + // let fecha = new Date(fechaISO); + + // // Formatear la fecha en DD/MM/YYYY + // let dia = fecha.getDate().toString().padStart(2, '0'); + // let mes = (fecha.getMonth() + 1).toString().padStart(2, '0'); // getMonth() devuelve mes de 0-11 + // let año = fecha.getFullYear(); + + // // Formatear la hora en formato 12 horas con AM/PM + // let horas = fecha.getHours(); + // let minutos = fecha.getMinutes().toString().padStart(2, '0'); + // let periodo = 'a. m.'; + // if (horas >= 12) { + // periodo = 'p. m.'; + // horas = horas > 12 ? horas - 12 : horas; // Convertir hora de formato 24 a 12 horas + // } + // if (horas === 0) horas = 12; // Medianoche se muestra como 12 a.m. + // horas = horas.toString().padStart(2, '0'); + + // // Combinar la fecha y la hora + // return `${dia}/${mes}/${año} ${horas}:${minutos}:00 ${periodo}`; + //} + + function RadionButtonSelectedValueSet(name, SelectdValue) { + $('input[name="' + name + '"][value="' + SelectdValue + '"]').prop('checked', true); + } + + function updateEventOnDropResize(event, allDay) { + var eventToUpdate = { + id: event.id, + start: event.start + }; + + if (event.end === null) { + eventToUpdate.end = eventToUpdate.start; + } + else { + eventToUpdate.end = event.end; + } + var endDate; + if (!event.allDay) { + endDate = new Date(eventToUpdate.end + 60 * 60000); + endDate = endDate.toJSON(); + } + else { + endDate = eventToUpdate.end.toJSON(); + } + + eventToUpdate.start = eventToUpdate.start.toJSON(); + eventToUpdate.end = eventToUpdate.end.toJSON(); //endDate; + eventToUpdate.allDay = event.allDay; + + PageMethods.ActualizaEvento(eventToUpdate, UpdateTimeSuccess); + } + + function eventDropped(event, dayDelta, minuteDelta, allDay, revertFunc) { + if ($(this).data("qtip")) $(this).qtip("destroy"); + updateEventOnDropResize(event); + } + + function eventResized(event, dayDelta, minuteDelta, revertFunc) { + if ($(this).data("qtip")) $(this).qtip("destroy"); + + updateEventOnDropResize(event); + } + + function Calendario(mes = -1, anio = -1) { + + let fechaActual = new Date(); + if (mes === -1) { + mes = fechaActual.getMonth() + 1; + } + if (anio === -1) { + anio = fechaActual.getFullYear(); + } + + + let mesFormateado = ('0' + mes).slice(-2); + let fechaInicio = `${anio}-${mesFormateado}-01`; + + var date = new Date(); + var d = date.getDate(); + var m = date.getMonth(); + var y = date.getFullYear(); + var h = {}; + + //alert(fechaInicio); + if ($('#calendar').width() <= 400) { + $('#calendar').addClass("mobile"); + h = { + left: 'title, prev, next', + center: '', + right: 'today,month,agendaWeek,agendaDay' + }; + } else { + $('#calendar').removeClass("mobile"); + + h = { + left: 'title', + center: '', + right: 'prev,next,today,month,agendaWeek,agendaDay' + }; + } + + $('#calendar').fullCalendar('destroy'); + $('#calendar').fullCalendar({ + defaultDate: fechaInicio, + header: h, + monthNames: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"], + monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'], + dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'], + dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'], + buttonText: { + today: 'Hoy', + week: 'Semana', + month: 'Mes', + day: 'Día' + }, + eventClick: updateEvent, + selectable: true, + selectHelper: true, + select: selectDate, + editable: true, + minTime: "00:00:00", + maxTime: "24:00:00", + eventOverlap: false, // No permitir la superposición de eventos + slotEventOverlap: false, // No permitir la superposición en vistas de agenda + eventRender: function (event, element) { + element.css({ + 'margin-bottom': '2px', + 'margin-left': '2px', + 'white-space': 'normal', // Permitir el ajuste de texto + 'height': 'auto', // Ajustar la altura automáticamente + 'overflow': 'hidden' // Ocultar cualquier desbordamiento + }); + element.find('.fc-title').css({ + 'white-space': 'normal', // Asegurar que el texto se ajuste + 'line-height': '1.2em' // Ajustar la altura de línea para mejor legibilidad + }); + + var firstFourChars = event.title.substring(0, 4); + var restOfTitle = event.title.substring(4); + + // Aplica el HTML personalizado al elemento del título del evento + //element.find('.fc-title').html('' + firstFourChars + '' + restOfTitle); + }, + events: { + url: '/Ashx/CargaEventos.ashx', + type: 'GET', + data: { + U: ' <%= UsuarioActual.CveUsuario %>', + E: '<%= UsuarioActual.CveEmpresa %>', + tipoVista: '<%= RBTipoVista.Text %>', + METODO: 'contrato_transportes', + CveUsuarioPara: $('#DdlTecnico').val(), + CveSubProyecto: $('#DdlSubProyecto').val(), + CveCliente: $('#C_DdlCliente_Value').val(), + CveContratoEstatus: $('#DdlEstatusConsulta').val(), + CveTipoActivoFijo: $('#DdlTipoUnidad').val(), + CvePersonal: $('#DdlChoferFiltro').val() + } + }, + eventDrop: eventDropped, + eventResize: eventResized, + viewRender: function (view, element) { + + let pointDate = view.intervalStart; + let currentMonth = pointDate.month() + 1; + let currentYear = pointDate.year(); + + $('#<%=DdlTipoAF.ClientID%>').val(currentMonth); + $('#<%=DdlSubProyectoModal.ClientID%>').val(currentYear); + } + + }); + } + + function obtenerFechaInicio(mes = -1, anio = -1) { + let fechaActual = new Date(); + + if (mes === -1) { + mes = fechaActual.getMonth() + 1; // getMonth() es base 0, así que se suma 1 + } + if (anio === -1) { + anio = fechaActual.getFullYear(); + } + + + let mesFormateado = ('0' + mes).slice(-2); + + + let fechaInicio = `${anio}-${mesFormateado}-01`; + + return fechaInicio; + } + + + function TabAltaClicked(sender, e) { + + setTimeout(function () { + InitCalendar(); + + }, 10); + + } + + + //Gant + let RCveEvento =<%= RCveEvento %>; + function NuevoEvento(CveEvento) { + $('.txtCveEvento').val(CveEvento); + $('.BtnopenmodalClickGant').click(); + } + function zoom_tasks(node) { + switch (node.value) { + case "week": + gantt.config.scale_unit = "day"; + gantt.config.date_scale = "%d %M"; + + gantt.config.scale_height = 60; + gantt.config.min_column_width = 30; + gantt.config.subscales = [ + { unit: "hour", step: 1, date: "%H" } + ]; + show_scale_options("hour"); + break; + case "trplweek": + gantt.config.min_column_width = 70; + gantt.config.scale_unit = "day"; + gantt.config.date_scale = "%d %M"; + gantt.config.subscales = []; + gantt.config.scale_height = 35; + show_scale_options("day"); + break; + case "month": + gantt.config.min_column_width = 70; + gantt.config.scale_unit = "week"; + gantt.config.date_scale = "Week #%W"; + gantt.config.subscales = [ + { unit: "day", step: 1, date: "%D" } + ]; + show_scale_options(); + gantt.config.scale_height = 60; + break; + case "year": + gantt.config.min_column_width = 70; + gantt.config.scale_unit = "month"; + gantt.config.date_scale = "%M"; + gantt.config.scale_height = 60; + show_scale_options(); + gantt.config.subscales = [ + { unit: "week", step: 1, date: "#%W" } + ]; + break; + case "yearyear": + gantt.config.min_column_width = 70; + gantt.config.scale_unit = "month"; + gantt.config.date_scale = "%y %M"; + gantt.config.scale_height = 60; + show_scale_options(); + gantt.config.subscales = [ + { unit: "month", step: 1, date: "#%M" } + ]; + break; + } + set_scale_units(); + gantt.render(); + } + function show_scale_options(mode) { + var hourConf = document.getElementById("filter_hours"), + dayConf = document.getElementById("filter_days"); + if (mode == 'day') { + hourConf.style.display = "none"; + dayConf.style.display = ""; + dayConf.getElementsByTagName("input")[0].checked = true; + } else if (mode == "hour") { + hourConf.style.display = ""; + dayConf.style.display = "none"; + hourConf.getElementsByTagName("input")[0].checked = true; + } else { + hourConf.style.display = "none"; + dayConf.style.display = "none"; + } + } + function set_scale_units(mode) { + if (mode && mode.getAttribute) { + mode = mode.getAttribute("value"); + } + + switch (mode) { + case "work_hours": + gantt.config.subscales = [ + { unit: "hour", step: 1, date: "%H" } + ]; + gantt.ignore_time = function (date) { + if (date.getHours() < 9 || date.getHours() > 16) { + return true; + } else { + return false; + } + }; + + break; + case "full_day": + gantt.config.subscales = [ + { unit: "hour", step: 3, date: "%H" } + ]; + gantt.ignore_time = null; + break; + case "work_week": + gantt.ignore_time = function (date) { + if (date.getDay() == 0 || date.getDay() == 6) { + return true; + } else { + return false; + } + }; + + break; + default: + gantt.ignore_time = null; + break; + } + gantt.render(); + } + + var datosGant = []; + function loadGant() { + gantt.config.date_format = "%Y-%m-%d %H:%i"; + gantt.config.order_branch = true; + gantt.config.order_branch_free = true; + gantt.config.open_tree_initially = true; + gantt.config.show_tasks_outside_timescale = true; + gantt.config.drag_move = false; // Desactiva mover tareas + gantt.config.drag_resize = false; // Desactiva redimensionar tareas + gantt.config.drag_progress = false; // Desactiva mover la barra de progreso + + gantt.i18n.setLocale("es"); + gantt.init("gantt_here"); + + + + gantt.config.columns = [ + //{ name: "text", label: "Contrato ", width: "*", min_width: 150, tree: true, resize: true, template: function (obj) { return "" + obj.text + " " } }, + { name: "codigoaf", label: "Unidad", max_width: 50, align: "left" }, + //{ name: "start_date", label: "Inicio", min_width: 90, align: "center" }, + //{ name: "end_date", label: "Fin", min_width: 90, align: "center" } + + //{ name: "progress", label: "Avance", align: "center", template: function (obj) { return "" + (obj.progress * 100).toFixed(2) + " %" } }, + //{ name: "duration", label: "Duración", align: "center" }, + //{ name: "new", label: "", align: "center", template: function (obj) { return " " } } + /*{name:"staff", label:"Holder(s)", template:function(obj){return obj.holder+"("+obj.progress+")"} },*/ + //{ name: "add", label: "" } + ]; + + gantt.parse({ + data: datosGant + }); + + + + + // Agregar evento para hover y mostrar tooltip + gantt.attachEvent("onMouseMove", function (id, e) { + if (id) { + var task = gantt.getTask(id); + + // Mostrar el tooltip burbuja + var tooltip = document.getElementById("gantt_tooltip"); + if (!tooltip) { + tooltip = document.createElement("div"); + tooltip.id = "gantt_tooltip"; + tooltip.style.position = "absolute"; + tooltip.style.backgroundColor = "#fff"; + tooltip.style.border = "1px solid #ccc"; + tooltip.style.padding = "5px"; + tooltip.style.borderRadius = "5px"; + tooltip.style.boxShadow = "0 2px 5px rgba(0,0,0,0.2)"; + tooltip.style.zIndex = "1000"; + document.body.appendChild(tooltip); + } + + tooltip.innerHTML = "UNIDAD: " + task.unidad + "
CONTRATO: " + task.text + + "
DURACIÓN: " + task.duracion; + + // Posicionar el tooltip cerca del cursor + tooltip.style.left = (e.pageX + 15) + "px"; // Desplazado un poco a la derecha del cursor + tooltip.style.top = (e.pageY + 15) + "px"; // Desplazado un poco abajo del cursor + tooltip.style.display = "block"; + } else { + var tooltip = document.getElementById("gantt_tooltip"); + if (tooltip) { + tooltip.style.display = "none"; + } + } + }); + + gantt.attachEvent("onTaskDblClick", function (id, e) { + // Cancelar el comportamiento predeterminado + return false; + }); + + + gantt.attachEvent("onBeforeTaskMove", function (id, parent, tindex) { + console.log(tindex) + var task = gantt.getTask(id); + if (task.parent != parent) + return false; + return true; + }); + + gantt.attachEvent("onRowDragEnd", function (id, target, tindex) { + console.log(tindex) + debugger; + drag_id = null; + gantt.render(); + }); + + gantt.attachEvent("onTaskLoading", function (task) { + if (task.hidden) { + task.$rendered = false; // Evitar que la tarea se renderice + } + return true; + }); + + + + } + + + // loadGant(); + +
diff --git a/Transportes/RepContratosCalendario.aspx.vb b/Transportes/RepContratosCalendario.aspx.vb index e4a0913b0..ae548d7bc 100644 --- a/Transportes/RepContratosCalendario.aspx.vb +++ b/Transportes/RepContratosCalendario.aspx.vb @@ -73,7 +73,8 @@ Partial Class RepContratosCalendario CveChofer:=DdlChoferFiltro.SelectedValue.ToEntero) Then DtAvance = ObjContratos.DtResultados.Copy() CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero) - CargaDiagramadeGant(DdlTipoVista.SelectedValue.ToEntero) + 'CargaDiagramadeGant(DdlTipoVista.SelectedValue.ToEntero) + 'CargaScheduler(DdlTipoVista.SelectedValue.ToEntero) End If GvContratos.DataSource = DtAvance DdlEstatusContrato.Enabled = UsuarioActual.TienePermisoProceso(173) @@ -89,9 +90,112 @@ Partial Class RepContratosCalendario Public Shared Function GetLastDayOfMonth(ByVal dateTime As DateTime) As DateTime Return New DateTime(dateTime.Year, dateTime.Month, DateTime.DaysInMonth(dateTime.Year, dateTime.Month)) End Function + + Private Sub CargaScheduler(Optional TipoVista As Integer = -1) + ' var data = [ + '{ + 'Id: 1, + 'Subject: 'Board Meeting', + 'Description: 'Meeting to discuss business goal of 2021.', + 'StartTime: New Date(2021, 7, 1, 9, 0), + 'EndTime: New Date(2021, 7, 2, 11, 0), + 'RoomId: 1 + '}] + + + '[ { text 'Room A', id: 1, color: '#98AFC7' },] + + Dim StrFiltro As String = "" + If DdlTipoUnidad.SelectedValue.ToEntero > 0 Then StrFiltro = " AND CveTipoActivoFijo = " & DdlTipoUnidad.SelectedValue + Dim DtUnidades As DataTable = GlobalDTActivoFijos(UsuarioActual.CveEmpresa).FiltraParametros("Codigo <> '' AND MedidaVehicular IN (2,3) " & StrFiltro, Orderby:=" TipoActivoFijo ASC, CodigoNumeroOrden ASC", DistinctColumns:={"Codigo", "CveActivoFijo"}) + + Dim jsonData As New JArray() + Dim jsonCategorias As New JArray() + + Dim strAF As New StringBuilder + Dim strData As New StringBuilder + Dim strAFData As New StringBuilder + + strData.AppendLine("[") + For Each Row As DataRow In DtAvance.FiltraParametros("CodigoAF <> '' AND TipoEstatus <> 3").Rows + + Dim FI As Date = Row("FechaInicial").ToString.ToDate + Dim FF As Date = Row("FechaFinal").ToString.ToDate + + Dim obj As New JObject( + New JProperty("Id", Row("CveContrato").ToString), + New JProperty("Subject", $"{Row("CodigoAF").ToString}"), + New JProperty("Description", $"{Row("NombreAF")}"), + New JProperty("StartTime", $"new Date({FI.Year},{FI.Month - 1},{FI.Day},{FI.Hour},{FI.Minute})"), + New JProperty("EndTime", $"new Date({FF.Year},{FF.Month - 1},{FF.Day},{FF.Hour},{FF.Minute})"), + New JProperty("IsBlock", "true"), + New JProperty("RoomId", Row("CveAF").ToString) + ) + jsonData.Add(obj) + + + strData.AppendLine("{") + strData.AppendLine($"Id: {Row("CveContrato").ToString},") + strData.AppendLine($"Subject: {$"'{Row("NumeroContrato").ToString}"}',") + strData.AppendLine($"StartTime: new Date({FI.Year},{FI.Month - 1},{FI.Day},{FI.Hour},{FI.Minute}),") + strData.AppendLine($"EndTime: new Date({FF.Year},{FF.Month - 1},{FF.Day},{FI.Hour},{FF.Minute}),") + strData.AppendLine($"RoomId: {Row("CveAF").ToString}") + strData.AppendLine("},") + + + strAF.AppendFormat("{0},", Row("CveAF")) + + Next + strData.AppendLine("{}]") + + If TipoVista = 1 Then 'solo con viajes + DtUnidades = DtUnidades.FiltraParametros($"CveActivoFijo IN ({strAF.ToString})") + End If + + + Dim random = New Random() + strAFData.AppendLine("[") + For Each Row As DataRow In DtUnidades.Rows + Dim obj As New JObject( + New JProperty("text", Row("Codigo").ToString), + New JProperty("id", Row("CveActivoFijo").ToString), + New JProperty("color", String.Format("#{0:X6}", random.Next(16777216))) + ) + jsonCategorias.Add(obj) + + strAFData.AppendLine("{") + strAFData.AppendLine($"text: '{Row("Codigo").ToString}',") + strAFData.AppendLine($"id: {Row("CveActivoFijo").ToString},") + strAFData.AppendLine($"color: '{String.Format("#{0:X6}", random.Next(16777216))}'") + strAFData.AppendLine("},") + + Next + strAFData.AppendLine("{}]") + + 'RegistraScript($"cargaScheduler({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});", "A1") + 'RegistraScript($"cargaScheduler({strData.ToString().TrimEnd(","c) },{strAFData.ToString().TrimEnd(","c) },{TipoVista}, {$"new Date({txtFechaI.ToDate.ToString("yyyy, MM, dd, hh, MM")})"}, {$"new Date({txtFechaF.ToDate.ToString("yyyy, MM, dd, hh, MM")})"});", "A1") + + Dim FechaInicio As Date = txtFechaI.Text.ToDate + Dim FechaFin As Date = txtFechaF.Text.ToDate + + 'strData.Append($",new Date({FechaInicio.Year},{FechaInicio.Month - 1},{FechaInicio.Day})") + 'strData.Append($",new Date({FechaFin.Year},{FechaFin.Month - 1},{FechaFin.Day})") + + 'RegistraScript($"cargaScheduler({strData.ToString().TrimEnd(","c) },{strAFData.ToString().TrimEnd(","c) },{TipoVista}, {$" new Date({FechaInicio.Year},{FechaInicio.Month - 1},{FechaInicio.Day})"}, {$"new Date({FechaFin.Year},{FechaFin.Month - 1},{FechaFin.Day})"});", "A1") + RegistraScript($"cargaScheduler({strData.ToString().TrimEnd(","c) },{strAFData.ToString().TrimEnd(","c) },{TipoVista}, {$" new Date({FechaInicio.Year},{FechaInicio.Month - 1},{FechaInicio.Day})"}, {$"new Date(2024,09,5)"});", "A1") + + UPScheduler.Update() + + End Sub Private Sub CargaCronograma(Optional TipoVista As Integer = -1) If DtAvance IsNot Nothing Then + + Dim strData As New StringBuilder + Dim strAFData As New StringBuilder + + + 'Dim separator As String = "" 'Dim str As New StringBuilder() 'str.AppendLine("datosGant=[") @@ -112,6 +216,7 @@ Partial Class RepContratosCalendario Dim strAF As New StringBuilder 'se quitan los estatus cancelados Dim randomNumber As New Random + strData.AppendLine("[") For Each Row As DataRow In DtAvance.FiltraParametros("CodigoAF <> '' AND TipoEstatus <> 3").Rows Dim obj As New JObject( @@ -127,6 +232,23 @@ Partial Class RepContratosCalendario New JProperty("fechaFinalViaje", Row("FechaFinal").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")) ) jsonData.Add(obj) + + Dim FI As Date = Row("FechaInicial").ToString.ToDate + Dim FF As Date = Row("FechaFinal").ToString.ToDate + + strData.AppendLine("{") + strData.AppendLine($"category: '{Row("CodigoAF").ToString}',") + strData.AppendLine($"fromDate: '{FI.ToString("yyyy-MM-dd HH:mm:ss")}',") + strData.AppendLine($"toDate: '{FF.ToString("yyyy-MM-dd HH:mm:ss")}',") + 'strData.AppendLine($"columnSettings: {{fill: '{String.Format("#{0:X6}", random.Next(16777216))}'}},") + strData.AppendLine($"unidad: '{Row("NombreAF").ToString}',") + strData.AppendLine($"color: am4core.color('" & String.Format("#{0:X6}", random.Next(16777216)) & "'),") + strData.AppendLine($"cveContrato: {Row("CveContrato").ToString.ToEntero},") + strData.AppendLine($"contrato: '{Row("NumeroContrato").ToString}',") + strData.AppendLine($"fechaFinalViaje: '{FF.ToString("yyyy-MM-dd HH:mm:ss")}'") + strData.AppendLine("},") + + strAF.AppendFormat("{0},", Row("CveAF")) 'uniad contrato y duracion @@ -139,29 +261,29 @@ Partial Class RepContratosCalendario 'separator = "," Next + strData.AppendLine("{}]") If TipoVista = 1 Then 'solo con viajes DtUnidades = DtUnidades.FiltraParametros($"CveActivoFijo IN ({strAF.ToString})") End If 'CATEGORIAS 'AGREGAR TODAS LAS UNIDADES + strAFData.AppendLine("[") For Each Row As DataRow In DtUnidades.Rows Dim obj As New JObject( New JProperty("category", Row("Codigo")) ) jsonCategorias.Add(obj) + + strAFData.AppendLine("{") + strAFData.AppendLine($"category: '{Row("Codigo").ToString}',") + strAFData.AppendLine("},") + Next - Dim FechaI = txtFechaI.Text.ToDateTime() - Dim FechaF = txtFechaF.Text.ToDateTime() + strAFData.AppendLine("{}]") - 'Dim ScriptZoomx = $"zoomAxis({FechaI.Year},{FechaI.Month - 1},{FechaI.Day},{FechaF.Year},{FechaF.Month - 1},{FechaF.Day});" - 'Dim ScriptZoomy = $"zoomAxisy(0,{If(jsonCategorias.Count > 9, 9, jsonCategorias.Count - 1)});" - 'RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});{ScriptZoomx};{ScriptZoomy};", "A1") - 'RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});", "A1") - - - 'str.AppendLine("];loadGant();") - 'RegistraScript(str.ToString()) + 'RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});", $"{random.Next(16777216)}") + RegistraScript($"cargaDiagramaGrantAMC4({strData.ToString().Replace(",{}", "")},{strAFData.ToString().Replace(",{}", "")},{TipoVista});", $"{random.Next(16777216)}") UPPGantt.Update() UPGat.Update() @@ -722,8 +844,9 @@ Partial Class RepContratosCalendario End Sub Protected Sub RBTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs) InicializaCalendar() - CargaCronograma() - CargaDiagramadeGant() + 'CargaCronograma() + 'CargaDiagramadeGant() + CargaScheduler(DdlTipoVista.SelectedValue.ToEntero) End Sub Protected Sub DdlTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs) @@ -747,4 +870,6 @@ Partial Class RepContratosCalendario Protected Sub DdlTipoVistaCalendario_SelectedIndexChanged(sender As Object, e As EventArgs) CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero) End Sub + + End Class