This commit is contained in:
2024-10-18 11:36:49 -07:00
2 changed files with 1343 additions and 1010 deletions

View File

@@ -51,7 +51,7 @@
</style>
<style>
<%-- <style>
.btn.newsubpro {
margin-left: 3px;
padding: 2px 4px;
@@ -90,24 +90,22 @@
}
#gantt_here {
width: 100%; /* El ancho será el 100% del contenedor padre */
height: 400px; /* Puedes ajustar esta altura según necesites */
border: 1px solid #ccc; /* Opcional: Un borde para visualizar mejor el área del Gantt */
box-sizing: border-box; /* Asegura que el padding y el borde no afecten el tamaño total */
}
.gantt_parent_task {
background-color: #ffcccc !important; /* Color para las tareas principales */
}
}
.gantt_child_task {
.gantt_child_task {
background-color: #cce5ff !important; /* Color para las sub-tareas */
}
</style>
}
</style>--%>
<link rel="stylesheet" href="/Transportes/Gant/dhtmlxgantt.css" type="text/css">
<%--<link rel="stylesheet" href="/Transportes/Gant/dhtmlxgantt.css" type="text/css">--%>
</asp:Content>
@@ -409,7 +407,7 @@
<asp:UpdatePanel ID="UPGat" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div >
<div style="display:none!important">
<div class="gantt-samples-banner_controls_bar controls_bar" style="display:none!important">
<strong>Formato: &nbsp; </strong>
@@ -484,11 +482,31 @@
</ContentTemplate>
</asp:UpdatePanel>
<div class="row">
<div class="col-md-12">
<div id="chartdiv"></div>
<div id="chart-container" style="width: 100%; height: 600px;max-height:601px!important">
<div id="chart-header" style="width: 100%; height: 50px;"></div>
<div style="width: 100%; height: 550px; overflow-y: auto; max-height:800px!important">
<div id="chart-body" style="width: 100%; height: 550px; overflow-y: auto;"></div>
</div>
</div>
</div>
</div>
<asp:UpdatePanel ID="UPScheduler" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<div id="Gantt55"></div>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</ajax:TabPanel>
</ajax:TabContainer>
@@ -731,15 +749,36 @@
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="JS" runat="Server">
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/xy.js"></script>
<script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
<%--<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/xy.js"></script>--%>
<%--<script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>--%>
<%--<script src="/Metronic/assets/global/plugins/dhtmlxgantt/dhtmlxgantt.js"></script>--%>
<script src="/Transportes/Gant/dhtmlxgantt.js"></script>
<%--<script src="/Transportes/Gant/dhtmlxgantt.js"></script>--%>
<!-- Essential JS 2 all material theme -->
<%--<link href="Gant/material.css" rel="stylesheet" type="text/css"/>
<!-- Essential JS 2 all script -->
<script src="Gant/ej2.min.js" type="text/javascript"></script>--%>
<!-- Librería principal de amCharts 4 -->
<script src="https://cdn.amcharts.com/lib/4/core.js"></script>
<!-- Módulo de gráficos de XYChart -->
<script src="https://cdn.amcharts.com/lib/4/charts.js"></script>
<!-- Tema animado de amCharts 4 -->
<script src="https://cdn.amcharts.com/lib/4/themes/animated.js"></script>
<!-- Paquete de idioma español -->
<script src="https://cdn.amcharts.com/lib/4/lang/es_ES.js"></script>
<script>
// Create root element
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
var root = am5.Root.new("chartdiv");
//var root = am5.Root.new("chartdiv");
var am5locales_es_ES = {
"Jan": "Enero",
@@ -771,6 +810,197 @@
let dateAxis;
let yAxis;
var chartHeader;
var chartBody;
function cargaDiagramaGrantAMC4(data, categorias, TipoVista) {
// Si ya hay gráficos, eliminarlos para crear nuevos
if (chartHeader) {
chartHeader.dispose();
}
if (chartBody) {
chartBody.dispose();
}
// Obtener valores de las cajas de texto o fechas
let fechaI = document.getElementById('<%= txtFechaI.ClientID %>').value;
let fechaF = document.getElementById('<%= txtFechaF.ClientID %>').value;
// Convertir valores a objetos Date
let minDate = new Date(fechaI.split("/").reverse().join("-"));
let maxDate = new Date(fechaF.split("/").reverse().join("-"));
maxDate.setHours(23, 59, 59, 999);
// Crear instancia del gráfico del encabezado
chartHeader = am4core.create("chart-header", am4charts.XYChart);
// Establecer el formato de fecha de entrada
chartHeader.dateFormatter.inputDateFormat = "yyyy-MM-dd HH:mm:ss";
// Establecer el idioma a español
chartHeader.language.locale = am4lang_es_ES; // Asegúrate de incluir el archivo de idioma en tu HTML
// Aplicar temas
am4core.useTheme(am4themes_animated);
// Configuración general del gráfico del encabezado
chartHeader.paddingLeft = 0;
chartHeader.paddingTop = 0; // Cambiado a 0
chartHeader.mouseWheelBehavior = "none"; // Deshabilita el zoom con la rueda del mouse
// Crear eje X (DateAxis) para el encabezado
var xAxisHeader = chartHeader.xAxes.push(new am4charts.DateAxis());
xAxisHeader.baseInterval = { timeUnit: "hour", count: 1 };
xAxisHeader.min = minDate.getTime();
xAxisHeader.max = maxDate.getTime();
xAxisHeader.renderer.opposite = false; // Cambiado a false
xAxisHeader.renderer.minGridDistance = 50; // Ajusta según sea necesario para evitar superposición
xAxisHeader.renderer.minorGridEnabled = true;
xAxisHeader.markUnitChange = false;
// Asegurar que todas las etiquetas se muestren
xAxisHeader.renderer.labels.template.forceShow = true;
xAxisHeader.renderer.labels.template.location = 0.5;
xAxisHeader.renderer.labels.template.fontSize = 14;
xAxisHeader.renderer.labels.template.fontWeight = "bold";
// Formatear las etiquetas de fecha
xAxisHeader.dateFormatter.dateFormat = "dd/MM";
xAxisHeader.periodChangeDateFormats.setKey("day", "dd/MM");
// Crear eje Y (ValueAxis) para el encabezado (dummy)
var yAxisHeader = chartHeader.yAxes.push(new am4charts.ValueAxis());
yAxisHeader.renderer.labels.template.disabled = true;
yAxisHeader.renderer.grid.template.disabled = true;
// Asignar datos al gráfico del encabezado
// Creamos datos dummy con fechas mínimas y máximas
chartHeader.data = [
{ date: minDate, value: 0 },
{ date: maxDate, value: 0 }
];
// Añadir una serie dummy para que el eje X se renderice correctamente
var seriesHeader = chartHeader.series.push(new am4charts.LineSeries());
seriesHeader.dataFields.dateX = "date";
seriesHeader.dataFields.valueY = "value";
seriesHeader.strokeOpacity = 0; // Hacemos la línea invisible
seriesHeader.fillOpacity = 0;
// Crear instancia del gráfico principal (cuerpo)
chartBody = am4core.create("chart-body", am4charts.XYChart);
// Establecer el formato de fecha de entrada
chartBody.dateFormatter.inputDateFormat = "yyyy-MM-dd HH:mm:ss";
// Establecer el idioma a español
chartBody.language.locale = am4lang_es_ES; // Asegúrate de incluir el archivo de idioma en tu HTML
// Aplicar temas
am4core.useTheme(am4themes_animated);
// Configuración general del gráfico principal
chartBody.paddingLeft = 0;
chartBody.paddingTop = 0;
chartBody.mouseWheelBehavior = "none"; // Deshabilita el zoom con la rueda del mouse
// Configurar el cursor para permitir interacción solo en el eje X
chartBody.cursor = new am4charts.XYCursor();
chartBody.cursor.behavior = "zoomX"; // O "panX" si solo deseas desplazamiento horizontal
chartBody.cursor.lineY.disabled = true; // Deshabilita la línea vertical del cursor
// Definir cellSize para el tamaño fijo de cada categoría en el eje Y
var cellSize = 45;
// Crear eje Y (CategoryAxis) para el gráfico principal
var yAxisBody = chartBody.yAxes.push(new am4charts.CategoryAxis());
yAxisBody.dataFields.category = "category";
yAxisBody.renderer.inversed = false;
yAxisBody.renderer.minGridDistance = 1; // Ajusta según sea necesario
yAxisBody.renderer.labels.template.fontSize = 12;
yAxisBody.renderer.labels.template.visible = true;
yAxisBody.start = 0;
yAxisBody.end = 1;
yAxisBody.strictMinMax = true;
yAxisBody.keepSelection = true; // Mantener la selección actual del eje Y
yAxisBody.data = categorias;
// Crear eje X (DateAxis) para el gráfico principal
var xAxisBody = chartBody.xAxes.push(new am4charts.DateAxis());
xAxisBody.baseInterval = { timeUnit: "hour", count: 1 };
xAxisBody.min = minDate.getTime();
xAxisBody.max = maxDate.getTime();
xAxisBody.renderer.opposite = false; // Cambiado a false
xAxisBody.renderer.minGridDistance = 50; // Ajusta según sea necesario para evitar superposición
xAxisBody.renderer.minorGridEnabled = true;
xAxisBody.markUnitChange = false;
// Deshabilitar las etiquetas y grids del eje X en el gráfico principal
xAxisBody.renderer.labels.template.disabled = true;
xAxisBody.renderer.grid.template.disabled = true;
// Añadir la serie al gráfico principal
var seriesBody = chartBody.series.push(new am4charts.ColumnSeries());
seriesBody.dataFields.openDateX = "fromDate";
seriesBody.dataFields.dateX = "toDate";
seriesBody.dataFields.categoryY = "category";
seriesBody.columns.template.tooltipText = "UNIDAD: {category}-{unidad}\nCONTRATO: {contrato}\nDURACIÓN: {fromDate} - {toDate}";
seriesBody.columns.template.strokeOpacity = 0;
// Asignar colores a las columnas basado en el campo 'color' de los datos
seriesBody.columns.template.propertyFields.fill = "color";
seriesBody.columns.template.propertyFields.stroke = "color";
var labelBullet = seriesBody.bullets.push(new am4charts.LabelBullet());
labelBullet.label.text = "{contrato}";
labelBullet.locationX = 0.5;
labelBullet.label.horizontalCenter = "middle";
labelBullet.label.verticalCenter = "middle";
labelBullet.label.fill = am4core.color("#fff");
labelBullet.label.fontSize = 12;
labelBullet.label.truncate = true;
labelBullet.label.maxWidth = 100;
labelBullet.label.wrap = true;
// Asignar datos al gráfico principal
chartBody.data = data;
// Sincronizar los ejes X de ambos gráficos
xAxisBody.events.on("selectionextremeschanged", function () {
xAxisHeader.zoomToDates(new Date(xAxisBody.minZoomed), new Date(xAxisBody.maxZoomed));
});
xAxisHeader.events.on("selectionextremeschanged", function () {
xAxisBody.zoomToDates(new Date(xAxisHeader.minZoomed), new Date(xAxisHeader.maxZoomed));
});
// Añadir barras de scroll si es necesario
chartBody.scrollbarX = new am4core.Scrollbar();
//chartBody.scrollbarY = new am4core.Scrollbar();
// Ajustar la altura del gráfico en función de los datos
seriesBody.events.on("datavalidated", function () {
var xAxisHeight = xAxisBody.pixelHeight;
var chartHeight = categorias.length * cellSize + xAxisHeight + chartBody.paddingTop + chartBody.paddingBottom;
// Establece la altura calculada en el contenedor del gráfico
document.getElementById('chart-body').style.height = chartHeight + "px";
// Asegurar que el eje Y no esté con zoom
yAxisBody.zoom({ start: 0, end: 1 });
});
// Animaciones al cargar
seriesBody.appear();
chartBody.appear(1000, 100);
}
function cargaDiagramaGrant(data, categorias, TipoVista) {
am5.ready(function () {
@@ -785,9 +1015,9 @@
root.locale = am5locales_es_ES;
// Establecer temas
root.setThemes([
am5themes_Animated.new(root)
]);
//root.setThemes([
// am5themes_Animated.new(root)
//]);
// Crear gráfico
let chart = root.container.children.push(am5xy.XYChart.new(root, {
@@ -799,10 +1029,6 @@
paddingLeft: 0
}));
// Deshabilitar el enmascaramiento en el plotContainer
//chart.plotContainer.set("mask", null); // quita rendimiento
// Agregar leyenda
let legend = chart.children.push(am5.Legend.new(root, {
centerX: am5.p50,
@@ -814,11 +1040,6 @@
// Definir cellSize para el tamaño fijo de cada categoría en el eje Y
let cellSize = 45;
//if (TipoVista == 1) {
// cellSize = 60;
//}
// Crear eje Y (CategoryAxis)
chart.paddingTop = 40;
yAxis = chart.yAxes.push(
@@ -826,16 +1047,16 @@
categoryField: "category",
renderer: am5xy.AxisRendererY.new(root, {
inversed: false,
minGridDistance: cellSize, // Asigna el tamaño fijo a cada unidad
//minGridDistance: cellSize, // Asigna el tamaño fijo a cada unidad
minorGridEnabled: true,
neverHide: true,
forceHidden: false,
oversizedBehavior: "none",
//oversizedBehavior: "none", // Elimina o ajusta oversizedBehavior
location: 0.5,
fontSize: 12, // Ajusta el tamaño de fuente si es necesario
visible: true, // Asegura que las etiquetas sean visibles
minPosition: 0.001,
maxPosition: 0.999,
//minPosition: 0.001,
//maxPosition: 0.999,
minGridDistance: 1, // Reduced from cellSize to 1
}),
tooltip: am5.Tooltip.new(root, {
@@ -845,38 +1066,13 @@
})
);
//yAxis.renderer.grid.template.disabled = !showgrid;
//yAxis.paddingLeft = 10;
//yAxis.paddingRight = 10;
//yAxis.layout = "absolute";
// Set up axis title
//yAxis.title.text = "Unidades";
//yAxis.title.rotation = 0;
//yAxis.title.align = "center";
//yAxis.title.valign = "top";
yAxis.set('strictMinMax', true);
yAxis.set('maxDeviation', 0);
//yAxis.set('maxDeviation', 0);
yAxis.set('start', 0);
yAxis.set('end', 1);
yAxis.data.setAll(categorias);
// Asegurar que las etiquetas del eje Y siempre se muestren
//yAxis.get("renderer").labels.template.setAll({
// forceHidden: false,
// oversizedBehavior: "none",
// location: 0.5,
// fontSize: 12, // Ajusta el tamaño de fuente si es necesario
// visible: true, // Asegura que las etiquetas sean visibles
// minPosition: 0.001,
// maxPosition: 0.999
//});
// Configurar el eje Y para evitar zoom automático
// Obtener valores de las cajas de texto
let fechaI = document.getElementById('<%= txtFechaI.ClientID %>').value;
let fechaF = document.getElementById('<%= txtFechaF.ClientID %>').value;
@@ -952,36 +1148,23 @@
series.data.setAll(data);
//// Scrollbar X
//var scrollbarX = am5.Scrollbar.new(root, {
// orientation: "horizontal"
//});
// Scrollbar X
var scrollbarX = am5.Scrollbar.new(root, {
orientation: "horizontal"
});
//chart.set("scrollbarX", scrollbarX);
//chart.bottomAxesContainer.children.push(scrollbarX);
chart.set("scrollbarX", scrollbarX);
chart.bottomAxesContainer.children.push(scrollbarX);
// Scrollbar Y
//let scrollbarY = am5.Scrollbar.new(root, {
// orientation: "vertical"
//});
//chart.set("scrollbarY", scrollbarY);
//chart.rightAxesContainer.children.push(scrollbarY);
// MOSTRAR MODAL DE CONTRATO AL HACER CLICK
series.columns.template.events.on("click", e => {
let cveContrato = e.target.dataItem.dataContext.cveContrato;
$('#<%=HdnCveContrato.ClientID%>').val(cveContrato);
let url = '/Ashx/CargaEventos.ashx?METODO=contrato_transportes';
let parametros = '&cveContrato=' + cveContrato + '&U=' + '<%= UsuarioActual.CveUsuario %>' + '&E=' + '<%= UsuarioActual.CveEmpresa %>' + '&tipoVista=' + '<%= RBTipoVista.Text %>' + '&CveUsuarioPara:' + $('#DdlTecnico').val() + '&CveSubProyecto:' + $('#DdlSubProyecto').val();
fetch(url + parametros).then(response => response.json()).then(json => {
updateEvent(json[0], null, false);
}).catch(err => console.log('Solicitud fallida', err));
let scrollbarY = am5.Scrollbar.new(root, {
orientation: "vertical"
});
chart.set("scrollbarY", scrollbarY);
chart.rightAxesContainer.children.push(scrollbarY);
series.events.on("datavalidated", function (ev) {
@@ -996,10 +1179,34 @@
yAxis.zoom(0, 1);
});
//series.events.on("datavalidated", function (ev) {
// series.dataItems.forEach(function (dataItem) {
// // Accede a los datos específicos de cada punto de la serie
// let category = dataItem.get("categoryY");
// let fromDate = dataItem.get("openValueX");
// let toDate = dataItem.get("valueX");
// // Mostrar los datos específicos en la consola o realizar acciones con ellos
// console.log("Categoría:", category);
// console.log("Fecha de inicio:", fromDate);
// console.log("Fecha de fin:", toDate);
// // Puedes también mostrar un tooltip personalizado o modificar visualmente cada columna
// //dataItem.get("graphics").tooltipText = `UNIDAD: ${category}\nCONTRATO: {contrato} \nDURACIÓN: ${fromDate} - ${toDate}`;
// });
//});
// Animaciones al cargar
chart.svgContainer.measure();
series.appear();
chart.invalidateRawData();
chart.appear(1000, 100);
//series.show().then(function (ev) {
// alert("Series is now fully visible");
//})
//console.log(series);
}); // end am5.ready()
}
@@ -1262,14 +1469,14 @@
$('#<%=TxtPesos.ClientID%>').val(event.Pesos);
$('#<%=TxtMoneda.ClientID%>').val(event.Moneda);
//document.getElementById('<%= TxtMoneda.ClientID %>').value = 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($('#<%=DdlTipoAF.ClientID%>').val());
$('#<%= HidCveTipoAF.ClientID%>').val($('#<%=TxtAnticipo.ClientID%>').val());
<%--$('#<%=BtnDdlTipoAF.ClientID%>').click();--%>
<%--$('#<%=DdlAF.ClientID%>').val(event.CveActivoFijo);--%>
@@ -1296,6 +1503,8 @@
$('#HidModCveCliente').val(event.CveCliente);
$('#<%=HdnCveContrato.ClientID%>').click();
$('#<%=BtnModal.ClientID%>').click();
}
@@ -1488,8 +1697,8 @@
let currentMonth = pointDate.month() + 1;
let currentYear = pointDate.year();
$('#<%=HidCurrentMonth.ClientID%>').val(currentMonth);
$('#<%=HidCurrentYear.ClientID%>').val(currentYear);
$('#<%=DdlTipoAF.ClientID%>').val(currentMonth);
$('#<%=DdlSubProyectoModal.ClientID%>').val(currentYear);
}
});
@@ -1748,9 +1957,8 @@
}
loadGant();
</script>
// loadGant();
</script>
</asp:Content>

View File

@@ -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