2.12.5. bi_listastrabajo

 
Nombre de la tabla en Redash:

bi_listastrabajo

Nombre de la tabla en BD:

bi_listastrabajo

Descripción del objetivo de la Tabla:
Muestra todas las listas de trabajo, que no se encuentren en estado terminado y anulado,  adicionalmente no deben ser listas de tipo, Referencias, Hidros o Encuestas Pendientes.
Tipo de tabla:
En linea
Fecha versión actual:
2022-10-05
Declaración SQL:
select
   `vtiger_listastrabajo`.`listastrabajoid` AS `listastrabajoid`,
   `vtiger_listastrabajo`.`asunto` AS `asunto`,
   `vtiger_listastrabajo`.`consecutivo` AS `consecutivo`,
   `vtiger_listastrabajo`.`tipoitemlista` AS `tipoitemlista`,
   `vtiger_listastrabajo`.`paciente` AS `paciente`,
   `vtiger_listastrabajo`.`relacionadocon` AS `relacionadocon`,
   `vtiger_listastrabajo`.`formaitemlista` AS `formaitemlista`,
   `vtiger_listastrabajo`.`fechadeteccion` AS `fechadeteccion`,
   `vtiger_listastrabajo`.`fechaproceso` AS `fechaproceso`,
   `vtiger_listastrabajo`.`fechafin` AS `fechafin`,
   `vtiger_listastrabajo`.`prioritario` AS `prioritario`,
   `vtiger_listastrabajo`.`semaforo` AS `semaforo`,
   `vtiger_listastrabajo`.`osprogramada` AS `osprogramada`,
   `vtiger_listastrabajo`.`diastotales` AS `diastotales`,
   `vtiger_listastrabajo`.`subtipolista` AS `subtipolista`,
   `vtiger_listastrabajo`.`prioridadlista` AS `prioridadlista`,
   `vtiger_listastrabajo`.`responsableasignado` AS `responsableasignado`,
   `vtiger_listastrabajo`.`visto` AS `visto`,
   `vtiger_listastrabajo`.`estadoitemlista` AS `estadoitemlista`,
   `vtiger_listastrabajo`.`fechaactivacion` AS `fechaactivacion`,
   `vtiger_listastrabajo`.`historial` AS `historial`,
   `vtiger_listastrabajo`.`tipoencuesta` AS `tipoencuesta`,
   `vtiger_listastrabajo`.`fechanovedad` AS `fechanovedad`,
   `vtiger_listastrabajo`.`textonovedad` AS `textonovedad`,
   `vtiger_listastrabajo`.`conteogestion` AS `conteogestion`,
   `vtiger_listastrabajo`.`pais` AS `pais`,
   `vtiger_listastrabajo`.`departamento` AS `departamento`,
   `vtiger_listastrabajo`.`ciudad` AS `ciudad`,
   `vtiger_listastrabajo`.`barrio` AS `barrio`,
   `vtiger_listastrabajo`.`zona_barrio` AS `zona_barrio`,
   `vtiger_listastrabajo`.`direccion` AS `direccion`,
   `vtiger_listastrabajo`.`phone` AS `phone`,
   `vtiger_listastrabajocf`.`cf_3465` AS `InconsistenciaCierre`,
   `vtiger_listastrabajocf`.`cf_3467` AS `ObsCierre`,
   `vtiger_crmentity`.`description` AS `description`,
   `vtiger_barrios`.`localidad` AS `localidad`,
   `vtiger_pacientesii`.`identificador_paciente` AS `identificador_paciente`,
   `vtiger_pacientesii`.`entidadpadrename` AS `entidadpadrename`,
   `vtiger_account`.`epsconsolidada` AS `epsconsolidada`,
   `vtiger_pacientesii`.`empresa` AS `idempresa`,
   `vtiger_empresa`.`empresa` AS `nombreempresa`,
   `vtiger_pacientesiicf`.`cf_1619` AS `EstadoPaciente`,
   `vtiger_pacientesiicf`.`cf_1679` AS `perdidorecuperacion`,
   date_format(`vtiger_crmentity`.`createdtime`, '%Y%m') AS `agno_mes`,
   date_format(`vtiger_crmentity`.`createdtime`, '%Y%m%d') AS `agno_mes_dia`,
   yearweek(`vtiger_crmentity`.`createdtime`, 0) AS `agno_semana`,
   `vtiger_users`.`user_name` AS `usuario_creacion`,
   concat(`vtiger_users`.`first_name`, ' ', `vtiger_users`.`last_name`) AS `nombre_usuario_creacion`,
  #01 (
      select
         `vtiger_crmentity`.`setype`
      from
         `vtiger_crmentity`
      where
         (
            `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
         )
   )
   AS `ModuloRelacionado`,
 #02  if((isnull(`vtiger_listastrabajogrouprel`.`groupname`)
   or
   (
      `vtiger_listastrabajogrouprel`.`groupname` = ''
   )
),
   (
      case
         when
            (
(
               select
                  `vtiger_crmentity`.`setype`
               from
                  `vtiger_crmentity`
               where
                  (
                     `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                  )
) = 'OrdenesServicio'
            )
         then
(
            select
               `vtiger_ordenesserviciogrouprel`.`groupname`
            from
               `vtiger_ordenesserviciogrouprel`
            where
               (
                  `vtiger_ordenesserviciogrouprel`.`ordenesservicioid` = `vtiger_listastrabajo`.`relacionadocon`
               )
)
            when
               (
(
                  select
                     `vtiger_crmentity`.`setype`
                  from
                     `vtiger_crmentity`
                  where
                     (
                        `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                     )
) = 'Cilindros'
               )
            then
(
               select
                  `vtiger_cilindrosgrouprel`.`groupname`
               from
                  `vtiger_cilindrosgrouprel`
               where
                  (
                     `vtiger_cilindrosgrouprel`.`cilindrosid` = `vtiger_listastrabajo`.`relacionadocon`
                  )
)
               when
                  (
(
                     select
                        `vtiger_crmentity`.`setype`
                     from
                        `vtiger_crmentity`
                     where
                        (
                           `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                        )
) = 'PacientesII'
                  )
               then
(
                  select
                     `vtiger_pacientesiigrouprel`.`groupname`
                  from
                     `vtiger_pacientesiigrouprel`
                  where
                     (
                        `vtiger_pacientesiigrouprel`.`pacientesiiid` = `vtiger_listastrabajo`.`relacionadocon`
                     )
)
                  when
                     (
(
                        select
                           `vtiger_crmentity`.`setype`
                        from
                           `vtiger_crmentity`
                        where
                           (
                              `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                           )
) = 'ItemsDagnos'
                     )
                  then
(
                     select
                        `vtiger_itemsdagnosgrouprel`.`groupname`
                     from
                        `vtiger_itemsdagnosgrouprel`
                     where
                        (
                           `vtiger_itemsdagnosgrouprel`.`itemsdagnosid` = `vtiger_listastrabajo`.`relacionadocon`
                        )
)
                     when
                        (
(
                           select
                              `vtiger_crmentity`.`setype`
                           from
                              `vtiger_crmentity`
                           where
                              (
                                 `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                              )
) = 'Visitas'
                        )
                     then
(
                        select
                           `vtiger_visitasgrouprel`.`groupname`
                        from
                           `vtiger_visitasgrouprel`
                        where
                           (
                              `vtiger_visitasgrouprel`.`visitasid` = `vtiger_listastrabajo`.`relacionadocon`
                           )
)
                        when
                           (
(
                              select
                                 `vtiger_crmentity`.`setype`
                              from
                                 `vtiger_crmentity`
                              where
                                 (
                                    `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                                 )
) = 'PlanillasTrabajo'
                           )
                        then
(
                           select
                              `vtiger_planillastrabajogrouprel`.`groupname`
                           from
                              `vtiger_planillastrabajogrouprel`
                           where
                              (
                                 `vtiger_planillastrabajogrouprel`.`planillastrabajoid` = `vtiger_listastrabajo`.`relacionadocon`
                              )
)
                           when
                              (
(
                                 select
                                    `vtiger_crmentity`.`setype`
                                 from
                                    `vtiger_crmentity`
                                 where
                                    (
                                       `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                                    )
) = 'Recogidas'
                              )
                           then
(
                              select
                                 `vtiger_recogidasgrouprel`.`groupname`
                              from
                                 `vtiger_recogidasgrouprel`
                              where
                                 (
                                    `vtiger_recogidasgrouprel`.`recogidasid` = `vtiger_listastrabajo`.`relacionadocon`
                                 )
)
                              when
                                 (
(
                                    select
                                       `vtiger_crmentity`.`setype`
                                    from
                                       `vtiger_crmentity`
                                    where
                                       (
                                          `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                                       )
) = 'ActivosRetornables'
                                 )
                              then
(
                                 select
                                    `vtiger_activosretornablesgrouprel`.`groupname`
                                 from
                                    `vtiger_activosretornablesgrouprel`
                                 where
                                    (
                                       `vtiger_activosretornablesgrouprel`.`activosretornablesid` = `vtiger_listastrabajo`.`relacionadocon`
                                    )
)
                                 when
                                    (
(
                                       select
                                          `vtiger_crmentity`.`setype`
                                       from
                                          `vtiger_crmentity`
                                       where
                                          (
                                             `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                                          )
) = 'RecibosCaja'
                                    )
                                 then
(
                                    select
                                       `vtiger_reciboscajagrouprel`.`groupname`
                                    from
                                       `vtiger_reciboscajagrouprel`
                                    where
                                       (
                                          `vtiger_reciboscajagrouprel`.`reciboscajaid` = `vtiger_listastrabajo`.`relacionadocon`
                                       )
)
                                    when
                                       (
(
                                          select
                                             `vtiger_crmentity`.`setype`
                                          from
                                             `vtiger_crmentity`
                                          where
                                             (
                                                `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                                             )
) = 'MantenimientoGases'
                                       )
                                    then
(
                                       select
                                          `vtiger_mantenimientogasesgrouprel`.`groupname`
                                       from
                                          `vtiger_mantenimientogasesgrouprel`
                                       where
                                          (
                                             `vtiger_mantenimientogasesgrouprel`.`mantenimientogasesid` = `vtiger_listastrabajo`.`relacionadocon`
                                          )
)
                                       when
                                          (
(
                                             select
                                                `vtiger_crmentity`.`setype`
                                             from
                                                `vtiger_crmentity`
                                             where
                                                (
                                                   `vtiger_crmentity`.`crmid` = `vtiger_listastrabajo`.`relacionadocon`
                                                )
) = 'Empleados'
                                          )
                                       then
(
                                          select
                                             `vtiger_empleadosgrouprel`.`groupname`
                                          from
                                             `vtiger_empleadosgrouprel`
                                          where
                                             (
                                                `vtiger_empleadosgrouprel`.`empleadosid` = `vtiger_listastrabajo`.`relacionadocon`
                                             )
)
                                          else
                                             'Sin Regional'
      end
   )
, `vtiger_listastrabajogrouprel`.`groupname`) AS `REGIONAL`
from
   (
      join
         `vtiger_listastrabajocf`
         on((`vtiger_listastrabajo`.`listastrabajoid` = `vtiger_listastrabajocf`.`listastrabajoid`)))
      join
         `vtiger_crmentity`
         on((`vtiger_listastrabajo`.`listastrabajoid` = `vtiger_crmentity`.`crmid`)))
      left join
         `vtiger_pacientesii`
         on((`vtiger_listastrabajo`.`paciente` = `vtiger_pacientesii`.`pacientesiiid`)))
      left join
         `vtiger_pacientesiicf`
         on((`vtiger_pacientesiicf`.`pacientesiiid` = `vtiger_pacientesii`.`pacientesiiid`)))
      left join
         `vtiger_empresa`
         on((`vtiger_empresa`.`empresaid` = `vtiger_pacientesii`.`empresa`)))
      left join
         on((`vtiger_listastrabajogrouprel`.`listastrabajoid` = `vtiger_listastrabajo`.`listastrabajoid`)))
      left join
         `vtiger_barrios`
         on((`vtiger_barrios`.`barriosid` = `vtiger_listastrabajo`.`barrio`)))
      left join
         `vtiger_account`
         on((`vtiger_account`.`accountid` = `vtiger_pacientesii`.`accountid`)))
      left join
         `vtiger_users`
         on((`vtiger_users`.`id` = `vtiger_crmentity`.`smcreatorid`)))
      left join
         `vtiger_tipoitemlista`
         on((`vtiger_listastrabajo`.`tipoitemlista` = `vtiger_tipoitemlista`.`tipoitemlista`))
   )
where
   (
(`vtiger_listastrabajo`.`estadoitemlista` <> 'Terminado')
      and
      (
         `vtiger_listastrabajo`.`estadoitemlista` <> 'Anulado'
      )
      and
      (
         not((`vtiger_listastrabajo`.`tipoitemlista` like 'Referencias%'))
      )
      and
      (
         not((`vtiger_listastrabajo`.`tipoitemlista` like '%Hidros%'))
      )
      and
      (
         not((`vtiger_listastrabajo`.`tipoitemlista` like 'Encuestas Pendientes'))
      )
   )
Tablas involucradas:
  •  vtiger_listastrabajo (Listas de trabajo).
  •  vtiger_listastrabajocf (Campos personalizados creados desde CRM).
  •  vtiger_pacientesii (Pacientes).
  •  vtiger_pacientesiicf (Campos personalizados creados desde CRM).
  •  vtiger_pacientesiigrouprel (Grupos de pacientes).
  •  vtiger_empresa (Empresas).
  •  vtiger_listastrabajogrouprel (Grupos).
  •  vtiger_barrios (Barrios).
  •  vtiger_account (Entidades).
  •  vtiger_users (Usuarios)
  •  vtiger_tipoitemlista (TIpo item lista).
  •  vtiger_crmentity (Datos de creación).
Columnas involucradas:
  •  `vtiger_listastrabajo`.`listastrabajoid` AS `listastrabajoid`.
  •  `vtiger_listastrabajo`.`asunto` AS `asunto`.
  •  `vtiger_listastrabajo`.`consecutivo` AS `consecutivo`.
  •  `vtiger_listastrabajo`.`tipoitemlista` AS `tipoitemlista`.
  •  `vtiger_listastrabajo`.`paciente` AS `paciente`.
  •  `vtiger_listastrabajo`.`relacionadocon` AS `relacionadocon`.
  •  `vtiger_listastrabajo`.`formaitemlista` AS `formaitemlista`.
  •  `vtiger_listastrabajo`.`fechadeteccion` AS `fechadeteccion`.
  •  `vtiger_listastrabajo`.`fechaproceso` AS `fechaproceso`.
  •  `vtiger_listastrabajo`.`fechafin` AS `fechafin`.
  •  `vtiger_listastrabajo`.`prioritario` AS `prioritario`.
  •  `vtiger_listastrabajo`.`semaforo` AS `semaforo`.
  •  `vtiger_listastrabajo`.`osprogramada` AS `osprogramada`.
  •  `vtiger_listastrabajo`.`diastotales` AS `diastotales`.
  •  `vtiger_listastrabajo`.`subtipolista` AS `subtipolista`.
  •  `vtiger_listastrabajo`.`prioridadlista` AS `prioridadlista`.
  •  `vtiger_listastrabajo`.`responsableasignado` AS `responsableasignado`.
  •  `vtiger_listastrabajo`.`visto` AS `visto`.
  •  `vtiger_listastrabajo`.`estadoitemlista` AS `estadoitemlista`.
  •  `vtiger_listastrabajo`.`fechaactivacion` AS `fechaactivacion`.
  •  `vtiger_listastrabajo`.`historial` AS `historial`.
  •  `vtiger_listastrabajo`.`tipoencuesta` AS `tipoencuesta`.
  •  `vtiger_listastrabajo`.`fechanovedad` AS `fechanovedad`.
  •  `vtiger_listastrabajo`.`textonovedad` AS `textonovedad`.
  •  `vtiger_listastrabajo`.`conteogestion` AS `conteogestion`.
  •  `vtiger_listastrabajo`.`pais` AS `pais`.
  •  `vtiger_listastrabajo`.`departamento` AS `departamento`.
  •  `vtiger_listastrabajo`.`ciudad` AS `ciudad`.
  •  `vtiger_listastrabajo`.`barrio` AS `barrio`.
  •  `vtiger_listastrabajo`.`zona_barrio` AS `zona_barrio`.
  •  `vtiger_listastrabajo`.`direccion` AS `direccion`.
  •  `vtiger_listastrabajo`.`phone` AS `phone`.
  •  `vtiger_listastrabajocf`.`cf_3465` AS `InconsistenciaCierre`.
  •  `vtiger_listastrabajocf`.`cf_3467` AS `ObsCierre`.
  •  `vtiger_crmentity`.`description` AS `description`.
  •  `vtiger_barrios`.`localidad` AS `localidad`.
  •  `vtiger_pacientesii`.`identificador_paciente` AS `identificador_paciente`.
  •  `vtiger_pacientesii`.`entidadpadrename` AS `entidadpadrename`.
  •  `vtiger_account`.`epsconsolidada` AS `epsconsolidada`.
  •  `vtiger_pacientesii`.`empresa` AS `idempresa`.
  •  `vtiger_empresa`.`empresa` AS `nombreempresa`.
  •  `vtiger_pacientesiicf`.`cf_1619` AS `EstadoPaciente`.
  •  `vtiger_pacientesiicf`.`cf_1679` AS `perdidorecuperacion`.
  •  date_format(`vtiger_crmentity`.`createdtime`, '%Y%m') AS `agno_mes`.
  •  date_format(`vtiger_crmentity`.`createdtime`, '%Y%m%d') AS `agno_mes_dia`.
  •  yearweek(`vtiger_crmentity`.`createdtime`, 0) AS `agno_semana`.
  •  `vtiger_users`.`user_name` AS `usuario_creacion`.
  •  concat(`vtiger_users`.`first_name`, ' ', `vtiger_users`.`last_name`) AS `nombre_usuario_creacion`.
  •  #01 (Modulo Relacionado).
  •  #02 (Regional).
Ubicación (URL) en Redash:
Ubicación (RUTA) en base de datos:
206.189.187.192/CRM/Views/bi_listastrabajo
Especificaciones técnicas de los campos involucrados: