781 lines
45 KiB
Plaintext
781 lines
45 KiB
Plaintext
<%@ WebHandler Language="VB" Class="CargaEventos" %>
|
|
Option Explicit Off
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState
|
|
|
|
Public Property events As List(Of CalendarEvent)
|
|
|
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
|
context.Response.ContentType = "text/plain"
|
|
|
|
Dim CveUsuario As Integer = -1
|
|
Dim CveEmpresa As Integer = -1
|
|
Dim FI As Date
|
|
Dim FF As Date
|
|
If UsuarioActual(context) Is Nothing Then Exit Sub
|
|
|
|
If context.Request("METODO") IsNot Nothing Then
|
|
|
|
Select Case context.Request("METODO")
|
|
Case "servicio_domicilio"
|
|
|
|
If context.Request("U").ToEntero > 0 Then
|
|
|
|
CveUsuario = context.Request("U").ToEntero
|
|
CveEmpresa = context.Request("E").ToEntero
|
|
|
|
Dim CveSubProyecto As Integer = If(context.Request("CveSubProyecto") IsNot Nothing, context.Request("CveSubProyecto").ToEntero, -1)
|
|
Dim CveUsuarioPara As Integer = If(context.Request("CveUsuarioPara") IsNot Nothing, context.Request("CveUsuarioPara").ToEntero, -1)
|
|
|
|
|
|
FI = context.Request("start").ToDate
|
|
FF = context.Request("end").ToDate
|
|
|
|
If Not GetEventos(CveUsuario, CveEmpresa, FI, FF, CveOS:=-2, CveUsuarioPara:=CveUsuarioPara, CveSubProyecto:=CveSubProyecto, context:=context) Then
|
|
'Convierte el objeto de Eventos en JSON
|
|
'Dim oSerializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
|
|
Dim sJSON As String = Newtonsoft.Json.JsonConvert.SerializeObject(events)
|
|
|
|
context.Response.Write(sJSON)
|
|
End If
|
|
End If
|
|
|
|
Exit Select
|
|
Case "servicio_medicos"
|
|
|
|
If context.Request("U").ToEntero > 0 Then
|
|
|
|
CveUsuario = context.Request("U").ToEntero
|
|
CveEmpresa = context.Request("E").ToEntero
|
|
|
|
Dim CveSubProyecto As Integer = If(context.Request("CveSubProyecto") IsNot Nothing, context.Request("CveSubProyecto").ToEntero, -1)
|
|
Dim CveUsuarioPara As Integer = If(context.Request("CveUsuarioPara") IsNot Nothing, context.Request("CveUsuarioPara").ToEntero, -1)
|
|
Dim FechaI As Date = context.Request("start").ToDate
|
|
Dim FechaF As Date = context.Request("end").ToDate
|
|
Dim Cvecliente As Integer = -1 'DdlClienteSucursalCliente()
|
|
Dim CveClienteSucursal As Integer = -1 ' DdlClienteSucursalSucursal()
|
|
Dim CveVendedor As Integer = If(context.Request("CveVendedor") IsNot Nothing, context.Request("CveVendedor").ToEntero, -1)
|
|
Dim CveEstatus As Integer = -1
|
|
Dim ObjOS As New ClsOS
|
|
|
|
If ObjOS.GetRepOrdenesServicioMedicasRep(FechaI, FechaF, Cvecliente, CveVendedor, CveEstatus, CveUsuarioPara, -1, CveEmpresa,
|
|
CveMedico:=-1, CveProcedimiento:=-1, CveEspecialidad:=-1,
|
|
CveClienteSucursal:=CveClienteSucursal, CveUsuario:=CveUsuario) Then
|
|
|
|
If ObjOS.DtResultados IsNot Nothing AndAlso ObjOS.DtResultados.Rows.Count > 0 Then
|
|
events = New List(Of CalendarEvent)
|
|
For Each dr As DataRow In ObjOS.DtResultados.Rows
|
|
Dim cevent As CalendarEvent = New CalendarEvent()
|
|
cevent.id = dr("CveOS").ToString.ToEntero
|
|
cevent.title = $" {dr("Tecnico")}-{dr("NombreCliente")}"
|
|
cevent.description = $" {dr("Tecnico")} -{dr("NombreCliente")} OS# <a href ='/OS/OrdenesServicio.aspx?CveOS={dr("CveOS")}'>{dr("Folio")}</a>"
|
|
cevent.start = String.Format("{0:s}", dr("FechaCita").ToString.ToDateTime)
|
|
cevent.end = String.Format("{0:s}", dr("FechaCita").ToString.ToDateTime.AddHours(1))
|
|
cevent.CveOS = dr("CveOS").ToString.ToEntero
|
|
cevent.allDay = False
|
|
If dr("EstatusOSGral").ToString.Contiene("Levantamiento") Then
|
|
cevent.backgroundColor = "#3598dc"
|
|
ElseIf dr("EstatusOSGral").ToString.Contiene("Surtido") Then
|
|
cevent.backgroundColor = "#002699"
|
|
ElseIf dr("EstatusOSGral").ToString.Contiene("Asignado") Then
|
|
cevent.backgroundColor = "#8E44AD"
|
|
ElseIf dr("EstatusOSGral").ToString.Contiene("Finalizado") Then
|
|
cevent.backgroundColor = "#26C281"
|
|
ElseIf dr("EstatusOSGral").ToString.Contiene("Facturado") Then
|
|
cevent.backgroundColor = "#4B77BE"
|
|
ElseIf dr("EstatusOSGral").ToString.Contiene("Cobrado") Then
|
|
cevent.backgroundColor = "#29b4b6"
|
|
ElseIf dr("EstatusOSGral").ToString.Contiene("Cancelado") Then
|
|
cevent.backgroundColor = "#e43a45"
|
|
End If
|
|
events.Add(cevent)
|
|
Next
|
|
|
|
context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(events))
|
|
End If
|
|
End If
|
|
ObjOS.Dispose()
|
|
|
|
End If
|
|
Exit Select
|
|
Case "contrato_transportes"
|
|
|
|
If context.Request("U").ToEntero > 0 Then
|
|
|
|
CveUsuario = context.Request("U").ToEntero
|
|
CveEmpresa = context.Request("E").ToEntero
|
|
|
|
FI = context.Request("start").ToDate
|
|
FF = context.Request("end").ToDate
|
|
|
|
If Not GetContratos(context:=context) Then
|
|
'Convierte el objeto de Eventos en JSON
|
|
'Dim oSerializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
|
|
|
|
|
|
'Dim settings As New Newtonsoft.Json.JsonSerializerSettings With {
|
|
' .NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
|
|
' .Formatting = Newtonsoft.Json.Formatting.None
|
|
' }
|
|
'Dim sJSON As String = Newtonsoft.Json.JsonConvert.SerializeObject(events, settings)
|
|
'context.Response.Write(sJSON)
|
|
|
|
Dim serializer As New Newtonsoft.Json.JsonSerializer()
|
|
Using writer As New IO.StringWriter()
|
|
serializer.Serialize(writer, events)
|
|
context.Response.Write(writer.ToString())
|
|
End Using
|
|
|
|
|
|
End If
|
|
End If
|
|
Exit Select
|
|
Case Else
|
|
Exit Select
|
|
End Select
|
|
|
|
Else
|
|
If context.Request("U").ToEntero > 0 Then
|
|
CveUsuario = context.Request("U").ToEntero
|
|
CveEmpresa = context.Request("E").ToEntero
|
|
FI = context.Request("start").ToDate
|
|
|
|
FF = context.Request("end").ToDate
|
|
If Not GetEventos(CveUsuario, CveEmpresa, FI, FF, context:=context) Then
|
|
'Convierte el objeto de Eventos en JSON
|
|
'Dim oSerializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
|
|
Dim sJSON As String = Newtonsoft.Json.JsonConvert.SerializeObject(events)
|
|
|
|
context.Response.Write(sJSON)
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
|
Get
|
|
Return False
|
|
End Get
|
|
End Property
|
|
|
|
|
|
Private Function GetEventos(CveUsuario As Integer, CveEmpresa As Integer, pFI As Date, pFF As Date, Optional CveOS As Integer = -1, Optional CveUsuarioPara As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional context As HttpContext = Nothing) As Boolean
|
|
|
|
Dim ErrorEventos As Boolean = False
|
|
Dim CveEmpresaCRM As Integer = 0
|
|
Dim DT_SubProyectos As New System.Data.DataTable
|
|
DT_SubProyectos.Columns.Add("CveSubProyecto", GetType(Integer))
|
|
DT_SubProyectos.Columns.Add("backgroundColor")
|
|
Dim DT_EstatusOS As New DataTable
|
|
DT_EstatusOS.Columns.Add("", GetType(Integer))
|
|
Dim ObjEventos As New ClsOIEventos
|
|
|
|
'son 26
|
|
Dim Colores() As String = {"#006699", "#0099cc", "#0066cc", "#0033cc", "#0000ff", "#3333ff", "#3333ff", "#6600ff", "#9933ff", "#cc00ff", "#cc00cc", "#cc0099", "#cc3399", "#cc6699", "#cc0066", "#009933", "#00cc00", "#00cc66", "#009999", "#669900", "#99cc00", "#cccc00", "#cc9900", "#ff9900", "#006666", "#669999"}
|
|
|
|
If CveOS = -2 Then
|
|
|
|
Dim objSub As New ClsSubProyectos
|
|
Dim DtTempSubproyectos As New DataTable
|
|
|
|
If objSub.GetSubProyectos(CveEmpresa) Then
|
|
DtTempSubproyectos = objSub.DtResultados.FiltraParametros("", "CveSubProyecto")
|
|
End If
|
|
|
|
objSub.Dispose()
|
|
|
|
Dim ColorIndex As Integer = 0
|
|
|
|
If DtTempSubproyectos.Rows.Count > 0 Then
|
|
For Each drow As DataRow In DtTempSubproyectos.Rows
|
|
|
|
Dim Subrow As DataRow = DT_SubProyectos.NewRow
|
|
Subrow("CveSubProyecto") = drow("CveSubProyecto").ToString.ToEntero
|
|
Subrow("backgroundColor") = Colores(ColorIndex)
|
|
|
|
DT_SubProyectos.Rows.Add(Subrow)
|
|
|
|
ColorIndex = ColorIndex + 1
|
|
If ColorIndex >= 25 Then
|
|
ColorIndex = 0
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
|
|
Dim EsCoordinador As Boolean = False
|
|
Dim usuarioActual_ As Usuario = UsuarioActual(context)
|
|
If context IsNot Nothing AndAlso CveOS = -2 Then
|
|
If usuarioActual_.TienePermisoProceso(348) Then
|
|
EsCoordinador = True
|
|
End If
|
|
End If
|
|
|
|
If ObjEventos.GetEventos(-1, -1, -1, "-1", "-1", -1, CveUsuario, CveUsuarioPara, -1, -1, -1, "-1", -1, -1, -1, -1, CveOS, -1, -1, -1, -1, -1, CveUsuario, CveUsuario, CveUsuario, CveEmpresa, pFI, pFF, CveSubProyecto:=CveSubProyecto, EsCoordinador:=EsCoordinador) Then
|
|
|
|
If ObjEventos.DtResultados.Rows.Count > 0 Then
|
|
events = New List(Of CalendarEvent)
|
|
|
|
Try
|
|
For Each dr As DataRow In ObjEventos.DtResultados.Rows
|
|
|
|
If dr("CveEventoEstatus").ToString.ToEntero <> 5 Then
|
|
|
|
Dim cevent As CalendarEvent = New CalendarEvent()
|
|
cevent.id = dr("CveEvento").ToString.ToEntero
|
|
cevent.title = dr("Asunto").ToString
|
|
cevent.description = dr("Descripcion").ToString
|
|
cevent.start = String.Format("{0:s}", dr("FechaInicio").ToString.ToDateTime)
|
|
cevent.end = String.Format("{0:s}", dr("FechaFin").ToString.ToDateTime)
|
|
cevent.allDay = False
|
|
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
|
|
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
|
|
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
|
|
cevent.backgroundColor = dr("BackGroundColor").ToString
|
|
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
|
|
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
|
|
cevent.diassemana = dr("DiasSemana").ToString
|
|
cevent.dia = dr("Dia").ToString.ToEntero
|
|
cevent.mes = dr("Mes").ToString.ToEntero
|
|
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
|
|
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
|
|
cevent.Prospecto = dr("Prospecto").ToString
|
|
cevent.CveTipoEvento = dr("Prospecto").ToString.ToEntero
|
|
cevent.EmpresaCRM = dr("EmpresaCRM").ToString
|
|
cevent.SubProyecto = dr("SubProyecto").ToString
|
|
cevent.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
|
|
cevent.Direccion = dr("Direccion").ToString
|
|
|
|
cevent.CveEmpresaCRM = dr("CveEmpresaCRM").ToString
|
|
cevent.CveContactoCRM = dr("CveContactoCRM").ToString
|
|
cevent.CveAcercamientoCRM = dr("CveAcercamientoCRM").ToString
|
|
|
|
cevent.CvePersonal = dr("CvePersonal").ToString.ToEntero
|
|
cevent.CveCliente = dr("CveCliente").ToString.ToEntero
|
|
cevent.CveProveedor = dr("CveProveedor").ToString.ToEntero
|
|
cevent.NombreCliente = dr("NombreCliente").ToString
|
|
cevent.NombreProveedor = dr("NombreProveedor").ToString
|
|
cevent.NomprePersonal = dr("NomprePersonal").ToString
|
|
|
|
cevent.CveCompra = dr("CveCompra").ToString.ToEntero
|
|
cevent.SerieFolioCompra = dr("SerieFolioCompra").ToString
|
|
|
|
cevent.CveVenta = dr("CveVenta").ToString.ToEntero
|
|
cevent.SerieFolioVenta = dr("SerieFolioVenta").ToString
|
|
|
|
cevent.CveOS = dr("CveOS").ToString.ToEntero
|
|
cevent.CveOSDetalle = dr("CveOSDetalle").ToString.ToEntero
|
|
cevent.CveUsuarioAtendio = dr("CveUsuarioAtendio").ToString.ToEntero
|
|
cevent.CveSubProyectoUsuarioAtendio = dr("CveSubProyectoUsuarioAtendio").ToString.ToEntero
|
|
|
|
cevent.NombreAcercamiento = dr("NombreAcercamiento").ToString
|
|
|
|
cevent.CveActivoFijo = dr("CveActivoFijo").ToString.ToEntero
|
|
cevent.AFCodigo = dr("AFCodigo").ToString
|
|
|
|
cevent.CveMovimiento = dr("CveMovimientoAlmacen").ToString.ToEntero
|
|
cevent.MovimientoFolio = dr("MovimientoFolio").ToString
|
|
|
|
cevent.CveIE = dr("CveIE").ToString.ToEntero
|
|
cevent.FolioIE = dr("FolioIE").ToString
|
|
|
|
|
|
'11/05/2018 - Evento Gasto Recurrente
|
|
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
|
|
If cevent.CveTipoEvento = 10 Then
|
|
cevent.Importe = dr("Importe").ToString.ToDouble
|
|
End If
|
|
|
|
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
|
|
cevent.backgroundColor = "#1BBC9B"
|
|
End If
|
|
|
|
If CveOS = -2 Then
|
|
cevent.backgroundColor = DT_SubProyectos.FiltroPrimeroValor("backgroundColor", $" CveSubProyecto = {cevent.CveSubProyectoUsuarioAtendio } ")
|
|
cevent.backgroundColor = If(cevent.backgroundColor.Trim = "", "#1BBC9B", cevent.backgroundColor.Trim)
|
|
End If
|
|
|
|
|
|
If usuarioActual_.Empresa.Funcionalidad(578) = "1" Then
|
|
|
|
Dim colorString As String = dr("BackgroundColorOS").ToString.Trim
|
|
|
|
If colorString.Length > 0 AndAlso IsValidHtmlColor(colorString) Then
|
|
cevent.backgroundColor = $"#{colorString}"
|
|
Else
|
|
If dr("TipoEstatusOS").ToString.ToEntero.Contiene(1, 2, 3) Then
|
|
cevent.backgroundColor = "#006699"
|
|
ElseIf dr("TipoEstatusOS").ToString.ToEntero.Contiene(4) Then
|
|
cevent.backgroundColor = "#025716"
|
|
ElseIf dr("TipoEstatusOS").ToString.ToEntero.Contiene(5) Then
|
|
cevent.backgroundColor = "#730505"
|
|
Else
|
|
cevent.backgroundColor = "#006699"
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
'VERIFICAMOS SI TIENE O NO RECURRENCIA
|
|
If Not cevent.recurrenciatipo > 0 Then
|
|
|
|
'AGREGAMOS CUANDO NO ES RECURRENTE
|
|
Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS())
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
|
|
If dr("FechaFin").ToString.ToDateTime > tFecha Or dr("FechaInicio").ToString.ToDateTime > tFecha Then
|
|
events.Add(cevent)
|
|
End If
|
|
Else
|
|
|
|
'EMPIEZA METODO PARA AGREGAR CUANDO SI ES RECURRENTE
|
|
|
|
Dim FinRecurrencia As Integer = cevent.recurrenciafin.ToEntero
|
|
Dim FI As DateTime, FF As DateTime, FT As DateTime
|
|
Dim DiasSemana As String() = cevent.diassemana.Split(","c)
|
|
FI = cevent.start.ToDateTime
|
|
FF = cevent.end.ToDateTime
|
|
|
|
'OBTENEMOS LA FECHA TERMINO (FT) DE LA RECURRENCIA
|
|
Select Case FinRecurrencia
|
|
Case -1
|
|
FT = DateAdd(DateInterval.Year, 2, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 0
|
|
FT = dr("RecurrenciaFin").ToString.ToDate
|
|
Case Is > 0
|
|
FinRecurrencia -= 1
|
|
Select Case cevent.recurrenciatipo
|
|
Case 1
|
|
FT = DateAdd(DateInterval.Hour, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 2
|
|
FT = DateAdd(DateInterval.Day, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 3
|
|
FT = DateAdd(DateInterval.WeekOfYear, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
FT = DateAdd(DateInterval.Day, (7 - Weekday(FT)).ToString.ToDouble, FT)
|
|
Case 4
|
|
FT = DateAdd(DateInterval.Month, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 5
|
|
FT = DateAdd(DateInterval.Year, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
End Select
|
|
End Select
|
|
|
|
'SI ES TIPO SEMANAL Y DIASSEMANA TIENE VALORES CHECKEA ESTOS VALORES
|
|
Do
|
|
If DiasSemana.Length > 0 AndAlso DiasSemana(0) <> "" Then
|
|
For Each drDias As String In DiasSemana
|
|
Dim FIT As Date = FI, FFT As Date = FF
|
|
|
|
FIT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FI)).ToString.ToDouble, FI)
|
|
FFT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FF)).ToString.ToDouble, FF)
|
|
|
|
cevent = New CalendarEvent()
|
|
cevent.id = dr("CveEvento").ToString.ToEntero
|
|
cevent.title = dr("Asunto").ToString
|
|
cevent.description = dr("Descripcion").ToString
|
|
cevent.start = String.Format("{0:s}", FIT)
|
|
cevent.end = String.Format("{0:s}", FFT)
|
|
cevent.allDay = False
|
|
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
|
|
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
|
|
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
|
|
cevent.backgroundColor = dr("BackGroundColor").ToString
|
|
|
|
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
|
|
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
|
|
cevent.diassemana = dr("DiasSemana").ToString
|
|
cevent.dia = dr("Dia").ToString.ToEntero
|
|
cevent.mes = dr("Mes").ToString.ToEntero
|
|
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
|
|
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
|
|
cevent.Prospecto = dr("Prospecto").ToString
|
|
|
|
|
|
|
|
'11/05/2018 - Evento Gasto Recurrente
|
|
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
|
|
If cevent.CveTipoEvento = 10 Then
|
|
cevent.Importe = dr("Importe").ToString.ToDouble
|
|
End If
|
|
|
|
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
|
|
cevent.backgroundColor = "#1BBC9B"
|
|
End If
|
|
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL Y/0 SI LA FECHA INICIAL DE LA RECURRENCIA ES MENOR A LA FECHA QUE SE CREO EL EVENTO NO LO AGREGA
|
|
If FIT > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) And FIT >= dr("FechaInicio").ToString.ToDateTime Then
|
|
events.Add(cevent)
|
|
End If
|
|
Next
|
|
Else
|
|
cevent = New CalendarEvent()
|
|
cevent.id = dr("CveEvento").ToString.ToEntero
|
|
cevent.title = dr("Asunto").ToString
|
|
cevent.description = dr("Descripcion").ToString
|
|
cevent.start = String.Format("{0:s}", FI)
|
|
cevent.end = String.Format("{0:s}", FF)
|
|
cevent.allDay = False
|
|
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
|
|
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
|
|
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
|
|
cevent.backgroundColor = dr("BackGroundColor").ToString
|
|
|
|
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
|
|
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
|
|
cevent.diassemana = dr("DiasSemana").ToString
|
|
cevent.dia = dr("Dia").ToString.ToEntero
|
|
cevent.mes = dr("Mes").ToString.ToEntero
|
|
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
|
|
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
|
|
cevent.Prospecto = dr("Prospecto").ToString
|
|
|
|
'11/05/2018 - Evento Gasto Recurrente
|
|
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
|
|
If cevent.CveTipoEvento = 10 Then
|
|
cevent.Importe = dr("Importe").ToString.ToDouble
|
|
End If
|
|
|
|
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
|
|
cevent.backgroundColor = "#1BBC9B"
|
|
End If
|
|
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
|
|
If FI > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) Then
|
|
events.Add(cevent)
|
|
End If
|
|
End If
|
|
|
|
Select Case cevent.recurrenciatipo
|
|
Case 1
|
|
FI = DateAdd(DateInterval.Hour, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Hour, cevent.frecuencia, FF)
|
|
Case 2
|
|
FI = DateAdd(DateInterval.Day, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Day, cevent.frecuencia, FF)
|
|
Case 3
|
|
FI = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FF)
|
|
Case 4
|
|
FI = DateAdd(DateInterval.Month, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Month, cevent.frecuencia, FF)
|
|
Case 5
|
|
FI = DateAdd(DateInterval.Year, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Year, cevent.frecuencia, FF)
|
|
End Select
|
|
|
|
Loop Until FI > FT
|
|
End If
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
End If
|
|
|
|
End If
|
|
ObjEventos.Dispose()
|
|
Return ErrorEventos
|
|
End Function
|
|
|
|
Private Function GetContratos(Optional context As HttpContext = Nothing) As Boolean
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
events = New List(Of CalendarEvent)
|
|
|
|
Dim DT_SubProyectos As New DataTable
|
|
Dim DT_EstatusOS As New DataTable
|
|
Dim usuarioActual_ As Usuario = UsuarioActual(context)
|
|
Dim ErrorEventos As Boolean = False
|
|
Dim tipoVista As String = context.Request("tipoVista")
|
|
DT_SubProyectos.Columns.Add("CveSubProyecto", GetType(Integer))
|
|
DT_SubProyectos.Columns.Add("backgroundColor")
|
|
DT_EstatusOS.Columns.Add("", GetType(Integer))
|
|
|
|
|
|
Dim cveContrato As Integer = If(context.Request("cveContrato") IsNot Nothing, context.Request("cveContrato").ToEntero, -1)
|
|
Dim CveSubProyecto As Integer = If(context.Request("CveSubProyecto") IsNot Nothing, context.Request("CveSubProyecto").ToEntero, -1)
|
|
Dim CveUsuarioPara As Integer = If(context.Request("CveUsuarioPara") IsNot Nothing, context.Request("CveUsuarioPara").ToEntero, -1)
|
|
|
|
Dim CveCliente As Integer = If(context.Request("CveCliente") IsNot Nothing, context.Request("CveCliente").ToEntero, -1)
|
|
Dim CveContratoEstatus As Integer = If(context.Request("CveContratoEstatus") IsNot Nothing, context.Request("CveContratoEstatus").ToEntero, -1)
|
|
Dim CveTipoActivoFijo As Integer = If(context.Request("CveTipoActivoFijo") IsNot Nothing, context.Request("CveTipoActivoFijo").ToEntero, -1)
|
|
Dim CvePersonal As Integer = If(context.Request("CvePersonal") IsNot Nothing, context.Request("CvePersonal").ToEntero, -1)
|
|
Dim FI As DateTime, FF As DateTime, FT As DateTime
|
|
FI = context.Request("start").ToDate
|
|
FF = context.Request("end").ToDate
|
|
|
|
|
|
If Not cveContrato > 0 Then
|
|
cveContrato = -1
|
|
End If
|
|
|
|
If Not CveCliente > 0 Then
|
|
CveCliente = -1
|
|
End If
|
|
|
|
If ObjContratos.GetContratosReporte(usuarioActual_.CveEmpresa, FI.ToString.ToDate, FF.ToString.ToDate, CveCliente:=CveCliente, CveTipoAF:=CveTipoActivoFijo,
|
|
CveTipoContrato:=34, CveEstatus:=CveContratoEstatus) Then
|
|
|
|
'CveTipoAF
|
|
'CveChofer, CveChofer2
|
|
Dim filtro As String = ""
|
|
If CveTipoActivoFijo > 0 Then
|
|
filtro = $"{filtro} CveTipoAF = {CveTipoActivoFijo}"
|
|
End If
|
|
|
|
If CvePersonal > 0 Then
|
|
If filtro.Length > 0 Then
|
|
filtro = $"{filtro} AND "
|
|
End If
|
|
filtro = $"{filtro} CveChofer = {CvePersonal} OR CveChofer2 = {CvePersonal} "
|
|
End If
|
|
|
|
|
|
If CveSubProyecto > 0 Then
|
|
If filtro.Length > 0 Then
|
|
filtro = $"{filtro} AND "
|
|
End If
|
|
filtro = $"{filtro} CveSubProyecto = {CveSubProyecto} "
|
|
End If
|
|
|
|
Dim DTContratos As DataTable = ObjContratos.DtResultados.FiltraParametros(filtro)
|
|
|
|
If DTContratos.Rows.Count > 0 Then
|
|
|
|
Try
|
|
For Each dr As DataRow In DTContratos.Rows
|
|
Dim cevent As CalendarEvent = New CalendarEvent()
|
|
|
|
cevent.id = dr("CveContrato").ToString.ToEntero
|
|
cevent.CveTipoAF = dr("CveTipoAF").ToString.ToEntero
|
|
cevent.title = $"-{dr("DescripcionContrato").ToString}"
|
|
|
|
|
|
If usuarioActual_.CveEmpresa = 188 AndAlso dr("CveTipoAF").ToString.Trim.Length > 0 Then
|
|
|
|
Dim TipoAfAbrebiado As String = ""
|
|
Select Case cevent.CveTipoAF
|
|
Case 181
|
|
TipoAfAbrebiado = "Bus"
|
|
Exit Select
|
|
'Case 183
|
|
' TipoAfAbrebiado = ""
|
|
' Exit Select
|
|
Case 184
|
|
TipoAfAbrebiado = "Spr"
|
|
Exit Select
|
|
'Case 185
|
|
' TipoAfAbrebiado = "Uti"
|
|
' Exit Select
|
|
Case 191
|
|
TipoAfAbrebiado = "Van"
|
|
Exit Select
|
|
Case 192
|
|
TipoAfAbrebiado = "Sed"
|
|
Exit Select
|
|
Case Else
|
|
Exit Select
|
|
End Select
|
|
|
|
cevent.title = $"-{TipoAfAbrebiado}#{dr("CodigoAF").ToString}-{dr("DescripcionContrato").ToString}"
|
|
'cevent.colorfont = "blue"
|
|
|
|
Else
|
|
cevent.title = $"#{dr("CodigoAF").ToString}-{dr("DescripcionContrato").ToString}"
|
|
End If
|
|
|
|
|
|
cevent.description = dr("DescripcionContrato").ToString
|
|
cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime)
|
|
cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime))
|
|
cevent.FechaFinal = String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)
|
|
cevent.allDay = False
|
|
cevent.NombreAcercamiento = dr("Ubicacion").ToString
|
|
cevent.CveCliente = dr("CveCliente").ToString.ToEntero
|
|
cevent.NombreComercial = dr("NombreComercial").ToString
|
|
cevent.CvePersonal = dr("CveChofer").ToString.ToEntero
|
|
cevent.CvePersonal2 = dr("CveChofer2").ToString.ToEntero
|
|
cevent.CveEventoEstatus = dr("CveContratosEstatus").ToString.ToEntero
|
|
cevent.Dolares = dr("Importe").ToString.ToDecimal
|
|
cevent.Pesos = dr("ImporteMax").ToString.ToDecimal
|
|
cevent.Anticipo = dr("ImporteMin").ToString.ToDecimal
|
|
cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero
|
|
|
|
cevent.CantidadPasajeros = dr("CantidadPasajeros").ToString
|
|
cevent.NumeroContrato = dr("NumeroContrato").ToString
|
|
cevent.Observaciones = dr("Observaciones").ToString
|
|
cevent.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
|
|
cevent.CveMoneda = dr("CveMoneda").ToString.ToEntero
|
|
cevent.Moneda = dr("Moneda").ToString
|
|
cevent.NumChoferes = dr("NumChoferes").ToString.ToEntero
|
|
|
|
cevent.CveVentaRemision = dr("CveVentaRemision").ToString.ToEntero
|
|
cevent.RemisionSerieFolio = dr("RemisionSerieFolio").ToString
|
|
cevent.RemisionSaldo = dr("RemisionSaldo").ToString.ToDecimal
|
|
cevent.TipoEstatus = dr("TipoEstatus").ToString.ToEntero
|
|
cevent.backgroundColor = dr("backgroundColor").ToString
|
|
|
|
Dim BGC_Atencion As String = "#bc9b1b"
|
|
If cevent.TipoEstatus <> 4 AndAlso cevent.TipoEstatus <> 3 Then
|
|
If dr("CveChofer").ToString.ToEntero <= 0 Or (dr("CveChofer2").ToString.ToEntero <= 0 And cevent.NumChoferes = 2) Or dr("CveAF").ToString.ToEntero <= 0 Then
|
|
cevent.backgroundColor = BGC_Atencion
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
|
|
If Not cevent.recurrenciatipo > 0 Then
|
|
|
|
'AGREGAMOS CUANDO NO ES RECURRENTE
|
|
Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS())
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
|
|
If dr("FechaFinal").ToString.ToDateTime > tFecha Or dr("FechaInicial").ToString.ToDateTime > tFecha Then
|
|
events.Add(cevent)
|
|
End If
|
|
Else
|
|
|
|
'EMPIEZA METODO PARA AGREGAR CUANDO SI ES RECURRENTE
|
|
|
|
Dim FinRecurrencia As Integer = cevent.recurrenciafin.ToEntero
|
|
|
|
Dim DiasSemana As String() = cevent.diassemana.Split(","c)
|
|
FI = cevent.start.ToDateTime
|
|
FF = cevent.end.ToDateTime
|
|
|
|
'OBTENEMOS LA FECHA TERMINO (FT) DE LA RECURRENCIA
|
|
Select Case FinRecurrencia
|
|
Case -1
|
|
FT = DateAdd(DateInterval.Year, 2, dr("FechaInicial").ToString.ToDateTime)
|
|
Case Is > 0
|
|
FinRecurrencia -= 1
|
|
Select Case cevent.recurrenciatipo
|
|
Case 1
|
|
FT = DateAdd(DateInterval.Hour, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime)
|
|
Case 2
|
|
FT = DateAdd(DateInterval.Day, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime)
|
|
Case 3
|
|
FT = DateAdd(DateInterval.WeekOfYear, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime)
|
|
FT = DateAdd(DateInterval.Day, (7 - Weekday(FT)).ToString.ToDouble, FT)
|
|
Case 4
|
|
FT = DateAdd(DateInterval.Month, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime)
|
|
Case 5
|
|
FT = DateAdd(DateInterval.Year, FinRecurrencia * cevent.frecuencia, dr("FechaInicial").ToString.ToDateTime)
|
|
End Select
|
|
End Select
|
|
|
|
'SI ES TIPO SEMANAL Y DIASSEMANA TIENE VALORES CHECKEA ESTOS VALORES
|
|
Do
|
|
If DiasSemana.Length > 0 AndAlso DiasSemana(0) <> "" Then
|
|
For Each drDias As String In DiasSemana
|
|
Dim FIT As Date = FI, FFT As Date = FF
|
|
|
|
FIT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FI)).ToString.ToDouble, FI)
|
|
FFT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FF)).ToString.ToDouble, FF)
|
|
|
|
cevent = New CalendarEvent()
|
|
cevent.id = dr("CveContrato").ToString.ToEntero
|
|
cevent.description = dr("DescripcionContrato").ToString
|
|
cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime)
|
|
cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime))
|
|
cevent.allDay = False
|
|
cevent.CveCliente = dr("CveCliente").ToString.ToEntero
|
|
cevent.NombreComercial = dr("NombreComercial").ToString
|
|
cevent.NombreAcercamiento = dr("Ubicacion").ToString
|
|
cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero
|
|
cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero
|
|
cevent.CvePersonal = dr("CveChofer").ToString.ToEntero
|
|
|
|
|
|
'11/05/2018 - Evento Gasto Recurrente
|
|
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
|
|
If cevent.CveTipoEvento = 10 Then
|
|
cevent.Importe = dr("Importe").ToString.ToDouble
|
|
End If
|
|
|
|
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
|
|
cevent.backgroundColor = "#1BBC9B"
|
|
End If
|
|
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL Y/0 SI LA FECHA INICIAL DE LA RECURRENCIA ES MENOR A LA FECHA QUE SE CREO EL EVENTO NO LO AGREGA
|
|
If FIT > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) And FIT >= dr("FechaInicial").ToString.ToDateTime Then
|
|
events.Add(cevent)
|
|
End If
|
|
Next
|
|
Else
|
|
cevent = New CalendarEvent()
|
|
cevent.id = dr("CveContrato").ToString.ToEntero
|
|
cevent.description = dr("DescripcionContrato").ToString
|
|
cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime)
|
|
cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime))
|
|
cevent.NombreAcercamiento = dr("Ubicacion").ToString
|
|
cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero
|
|
cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero
|
|
cevent.allDay = False
|
|
|
|
|
|
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
|
|
If FI > DateAdd(DateInterval.Month, -6, ClsPaginas.NowADS()) Then
|
|
events.Add(cevent)
|
|
End If
|
|
End If
|
|
|
|
Select Case cevent.recurrenciatipo
|
|
Case 1
|
|
FI = DateAdd(DateInterval.Hour, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Hour, cevent.frecuencia, FF)
|
|
Case 2
|
|
FI = DateAdd(DateInterval.Day, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Day, cevent.frecuencia, FF)
|
|
Case 3
|
|
FI = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FF)
|
|
Case 4
|
|
FI = DateAdd(DateInterval.Month, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Month, cevent.frecuencia, FF)
|
|
Case 5
|
|
FI = DateAdd(DateInterval.Year, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Year, cevent.frecuencia, FF)
|
|
End Select
|
|
|
|
Loop Until FI > FT
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
End If
|
|
|
|
End If
|
|
ObjContratos.Dispose()
|
|
Return ErrorEventos
|
|
End Function
|
|
|
|
ReadOnly Property UsuarioActual(ByVal context As HttpContext) As Usuario
|
|
Get
|
|
UsuarioActual = DirectCast(If(context IsNot Nothing, context.Session("UsuarioSIG"), Nothing), Usuario)
|
|
End Get
|
|
End Property
|
|
|
|
Private Function IsValidHtmlColor(colorString As String) As Boolean
|
|
Try
|
|
Dim color As System.Drawing.Color = System.Drawing.ColorTranslator.FromHtml(colorString)
|
|
' Si no se produce una excepción, el color es válido
|
|
Return True
|
|
Catch ex As Exception
|
|
' Se produce una excepción, el color no es válido
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
|
|
End Class
|