2.8.5. ba_equipos_inventario

 
Nombre de la vista en Redash:

ba_equipos_inventario

Nombre de la vista en BD:

ba_equipos_inventario

Descripción del objetivo de la vista:
---------------------------------------------------------------------------------------------
Tipo de vista:
En linea
Fecha versión actual:
14-Octubre-2022
Declaración SQL:
select
   `activo`.`propietario` AS `propietario`,
   `activo`.`linea_servicio` AS `linea_servicio`,
   `activo`.`supertipo` AS `supertipo`,
   `activo`.`tipo_equipo` AS `tipo_equipo`,
   `activo`.`subtipo` AS `subtipo`,
   `activo`.`modeloequipo` AS `modeloequipo`,
   `activo`.`situacionequipo` AS `Situacionequipo`,
  #01 (
      case
         when
            (
               `crminfo`.`setype` = 'PacientesII'
            )
         then
            concat(substr((
            select
               `acc`.`groupname`
            from
               (
                  `vtiger_accountgrouprelation` `acc`
                  join
                     `vtiger_pacientesii` `pac`
               )
            where
               (
(`activo`.`ubicacion` = `pac`.`pacientesiiid`)
                  and
                  (
                     `pac`.`accountid` = `acc`.`accountid`
                  )
               )
), 1, 4), '-', 'Pacientes')
            when
               (
                  `crminfo`.`setype` = 'Sedes'
               )
            then
               concat(substr((
               select
                  `vtiger_sedescf`.`cf_2271`
               from
                  `vtiger_sedescf`
               where
                  (
                     `activo`.`ubicacion` = `vtiger_sedescf`.`sedesid`
                  )
), 1, 4), '-',
                  (
                     select
                        `vtiger_sedescf`.`cf_2239`
                     from
                        `vtiger_sedescf`
                     where
                        (
                           `activo`.`ubicacion` = `vtiger_sedescf`.`sedesid`
                        )
                  )
)
               when
                  (
                     `crminfo`.`setype` = 'PlanillasTrabajo'
                  )
               then
                  concat(substr((
                  select
                     `rutascf`.`cf_2961`
                  from
                     (
                        `vtiger_rutascf` `rutascf`
                        join
                           `vtiger_planillastrabajo` `pt`
                     )
                  where
                     (
(`activo`.`ubicacion` = `pt`.`planillastrabajoid`)
                        and
                        (
                           `pt`.`ruta` = `rutascf`.`rutasid`
                        )
                     )
), 1, 4), '-', 'Planilla', '-',
                     (
                        select
                           `rutas`.`tiporuta`
                        from
                           (
                              `vtiger_rutas` `rutas`
                              join
                                 `vtiger_planillastrabajo` `pt`
                           )
                        where
                           (
(`activo`.`ubicacion` = `pt`.`planillastrabajoid`)
                              and
                              (
                                 `pt`.`ruta` = `rutas`.`rutasid`
                              )
                           )
                     )
)
      end
   )
   AS `AgroupUbic`,
   `crminfo`.`setype` AS `TipoUbicacion`,
 #02  (
      case
         when
            (
               `crminfo`.`setype` = 'PacientesII'
            )
         then
(
            select
               `acc`.`groupname`
            from
               (
                  `vtiger_accountgrouprelation` `acc`
                  join
                     `vtiger_pacientesii` `pac`
               )
            where
               (
(`activo`.`ubicacion` = `pac`.`pacientesiiid`)
                  and
                  (
                     `pac`.`accountid` = `acc`.`accountid`
                  )
               )
)
            when
               (
                  `crminfo`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedescf`.`cf_2271`
               from
                  `vtiger_sedescf`
               where
                  (
                     `activo`.`ubicacion` = `vtiger_sedescf`.`sedesid`
                  )
)
               when
                  (
                     `crminfo`.`setype` = 'PlanillasTrabajo'
                  )
               then
(
                  select
                     `rutascf`.`cf_2961`
                  from
                     (
                        `vtiger_rutascf` `rutascf`
                        join
                           `vtiger_planillastrabajo` `pt`
                     )
                  where
                     (
(`activo`.`ubicacion` = `pt`.`planillastrabajoid`)
                        and
                        (
                           `pt`.`ruta` = `rutascf`.`rutasid`
                        )
                     )
)
                  when
                     (
                        `crminfo`.`setype` = 'Vendors'
                     )
                  then
                     'CUNDINAMARCA'
                  when
                     (
                        `crminfo`.`setype` = 'Accounts'
                     )
                  then
(
                     select
                        `acc`.`groupname`
                     from
                        (
                           `vtiger_accountgrouprelation` `acc`
                           join
                              `vtiger_account` `vac`
                        )
                     where
                        (
(`activo`.`ubicacion` = `vac`.`accountid`)
                           and
                           (
                              `vac`.`accountid` = `acc`.`accountid`
                           )
                        )
)
      end
   )
   AS `Regional`,
 #03  (
      case
         when
            (
               `crminfo`.`setype` = 'PacientesII'
            )
         then
(
            select
               `pacf`.`cf_1679`
            from
               (
                  `vtiger_pacientesii` `pac`
                  join
                     `vtiger_pacientesiicf` `pacf`
                     on((`pac`.`pacientesiiid` = `pacf`.`pacientesiiid`))
               )
            where
               (
                  `activo`.`ubicacion` = `pac`.`pacientesiiid`
               )
)
            when
               (
                  `crminfo`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedes`.`clasesede`
               from
                  `vtiger_sedes`
               where
                  (
                     `activo`.`ubicacion` = `vtiger_sedes`.`sedesid`
                  )
)
               when
                  (
                     `crminfo`.`setype` = 'PlanillasTrabajo'
                  )
               then
                  'PlanillasTrabaj\no'
               when
                  (
                     `crminfo`.`setype` = 'Accounts'
                  )
               then
                  'Accounts'
      end
   )
   AS `ClaseSede`,
 #04  (
      case
         when
            (
               `crminfo`.`setype` = 'PacientesII'
            )
         then
(
            select
               `vac`.`epsconsolidada`
            from
               (
                  `vtiger_account` `vac`
                  join
                     `vtiger_pacientesii` `pac`
                     on((`pac`.`accountid` = `vac`.`accountid`))
               )
            where
               (
                  `activo`.`ubicacion` = `pac`.`pacientesiiid`
               )
)
            when
               (
                  `crminfo`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedes`.`clasesede`
               from
                  `vtiger_sedes`
               where
                  (
                     `activo`.`ubicacion` = `vtiger_sedes`.`sedesid`
                  )
)
               when
                  (
                     `crminfo`.`setype` = 'PlanillasTrabajo'
                  )
               then
(
                  select
                     `rutas`.`tiporuta`
                  from
                     (
                        `vtiger_rutas` `rutas`
                        join
                           `vtiger_planillastrabajo` `pt`
                     )
                  where
                     (
(`activo`.`ubicacion` = `pt`.`planillastrabajoid`)
                        and
                        (
                           `pt`.`ruta` = `rutas`.`rutasid`
                        )
                     )
)
                  when
                     (
                        `crminfo`.`setype` = 'Accounts'
                     )
                  then
(
                     select
                        `vac`.`epsconsolidada`
                     from
                        `vtiger_account` `vac`
                     where
                        (
                           `activo`.`ubicacion` = `vac`.`accountid`
                        )
)
                     when
                        (
                           `crminfo`.`setype` = 'Vendors'
                        )
                     then
                        `vendor`.`vendorname`
      end
   )
   AS `N1`,
 #05  (
      case
         when
            (
               `crminfo`.`setype` = 'PacientesII'
            )
         then
(
            select
               `vtiger_pacientesii`.`entidadpadrename`
            from
               `vtiger_pacientesii`
            where
               (
                  `activo`.`ubicacion` = `vtiger_pacientesii`.`pacientesiiid`
               )
)
            when
               (
                  `crminfo`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedes`.`sede`
               from
                  `vtiger_sedes`
               where
                  (
                     `activo`.`ubicacion` = `vtiger_sedes`.`sedesid`
                  )
)
               when
                  (
                     `crminfo`.`setype` = 'PlanillasTrabajo'
                  )
               then
(
                  select
                     `pt`.`identificador`
                  from
                     (
                        `vtiger_rutas` `rutas`
                        join
                           `vtiger_planillastrabajo` `pt`
                     )
                  where
                     (
(`activo`.`ubicacion` = `pt`.`planillastrabajoid`)
                        and
                        (
                           `pt`.`ruta` = `rutas`.`rutasid`
                        )
                     )
)
                  when
                     (
                        `crminfo`.`setype` = 'Accounts'
                     )
                  then
(
                     select
                        `vac`.`epsconsolidada`
                     from
                        `vtiger_account` `vac`
                     where
                        (
                           `activo`.`ubicacion` = `vac`.`accountname`
                        )
)
                     when
                        (
                           `crminfo`.`setype` = 'Vendors'
                        )
                     then
                        `vendor`.`vendorname`
      end
   )
   AS `N2`,
  #06 (
      case
         when
            (
               `crminfo`.`setype` = 'PacientesII'
            )
         then
(
            select
               `pac_cf`.`cf_1619`
            from
               (
                  `vtiger_pacientesii`
                  join
                     `vtiger_pacientesiicf` `pac_cf`
               )
            where
               (
(`activo`.`ubicacion` = `vtiger_pacientesii`.`pacientesiiid`)
                  and
                  (
                     `pac_cf`.`pacientesiiid` = `vtiger_pacientesii`.`pacientesiiid`
                  )
               )
)
            when
               (
                  `crminfo`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedescf`.`cf_2235`
               from
                  (
                     `vtiger_sedes`
                     join
                        `vtiger_sedescf`
                  )
               where
                  (
(`activo`.`ubicacion` = `vtiger_sedes`.`sedesid`)
                     and
                     (
                        `vtiger_sedes`.`sedesid` = `vtiger_sedescf`.`sedesid`
                     )
                  )
)
               when
                  (
                     `crminfo`.`setype` = 'PlanillasTrabajo'
                  )
               then
                  convert((
                  select
                     if((`pt`.`fecha_fin` > (curdate() - 4)), 'Activa', 'Inactiva')
                  from
                     `vtiger_planillastrabajo` `pt`
                  where
                     (
                        `activo`.`ubicacion` = `pt`.`planillastrabajoid`
                     )
) using latin1)
                  when
                     (
                        `crminfo`.`setype` = 'Accounts'
                     )
                  then
(
                     select
                        `vac`.`visualizacioncreacionpaciente`
                     from
                        `vtiger_account` `vac`
                     where
                        (
                           `activo`.`ubicacion` = `vac`.`accountname`
                        )
)
                     when
                        (
                           `crminfo`.`setype` = 'Vendors'
                        )
                     then
                        `vendor`.`situacionproveedor`
      end
   )
   AS `EstadoUbicacion`,
 #07  (
      select
         `vtiger_sedescf`.`cf_3330`
      from
         (
            `vtiger_sedes`
            join
               `vtiger_sedescf`
         )
      where
         (
(`activo`.`ubicacion` = `vtiger_sedes`.`sedesid`)
            and
            (
               `vtiger_sedes`.`sedesid` = `vtiger_sedescf`.`sedesid`
            )
         )
   )
   AS `enproceso_Sede`,
 #08 (
      case
         when
            isnull(`cilindro`.`cilindrosid`)
         then
            'Electrico'
         when
            (
               `cilindro`.`cilindrosid` is not null
            )
         then
            'Gases'
      end
   )
   AS `modulo`,
`activo`.`abrv` AS `abrv`,
`activo`.`estado_activo` AS `estado_activo`,
`activo`.`ubicacion` AS `ubicacion`,
 #09 (
      case
         when
            (
               `crminfo`.`setype` = 'PacientesII'
            )
         then
(
            select
               `vtiger_pacientesii`.`entidadpadrename`
            from
               `vtiger_pacientesii`
            where
               (
                  `activo`.`ubicacion` = `vtiger_pacientesii`.`pacientesiiid`
               )
)
            when
               (
                  `crminfo`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedes`.`sede`
               from
                  `vtiger_sedes`
               where
                  (
                     `activo`.`ubicacion` = `vtiger_sedes`.`sedesid`
                  )
)
               when
                  (
                     `crminfo`.`setype` = 'PlanillasTrabajo'
                  )
               then
(
                  select
                     `pt`.`identificador`
                  from
                     (
                        `vtiger_rutas` `rutas`
                        join
                           `vtiger_planillastrabajo` `pt`
                     )
                  where
                     (
(`activo`.`ubicacion` = `pt`.`planillastrabajoid`)
                        and
                        (
                           `pt`.`ruta` = `rutas`.`rutasid`
                        )
                     )
)
                  when
                     (
                        `crminfo`.`setype` = 'Accounts'
                     )
                  then
(
                     select
                        `vac`.`epsconsolidada`
                     from
                        `vtiger_account` `vac`
                     where
                        (
                           `activo`.`ubicacion` = `vac`.`accountid`
                        )
)
                     when
                        (
                           `crminfo`.`setype` = 'Vendors'
                        )
                     then
                        `vendor`.`vendorname`
      end
   )
   AS `NomUbicacion`,
sum(1) AS `frec`, count(0) AS `Cantidad`
from
   (
      left join
         `vtiger_crmentity` `crminfo`
         on((`activo`.`ubicacion` = `crminfo`.`crmid`)))
      left join
         `vtiger_cilindros` `cilindro`
         on((`activo`.`activosretornablesid` = `cilindro`.`cilindrosid`)))
      left join
         `vtiger_vendor` `vendor`
         on((`activo`.`vendor_id` = `vendor`.`vendorid`))
   )
group by
   `activo`.`subtipo`, `activo`.`propietario`, `NomUbicacion`, `activo`.`modeloequipo`, `EstadoUbicacion`, `activo`.`estado_activo`
Tablas involucradas:
  •  vtiger_activosretornables (Equipos electricos).
  •  vtiger_crmentity (Datos de creación).
  •  vtiger_cilindros (Equipos de gases).
  •  vtiger_vendor (Proveedores).
Columnas involucradas:
  •  `activo`.`propietario` AS `propietario`.
  •  `activo`.`linea_servicio` AS `linea_servicio`.
  •  `activo`.`supertipo` AS `supertipo`.
  •  `activo`.`tipo_equipo` AS `tipo_equipo`.
  •  `activo`.`subtipo` AS `subtipo`.
  •  `activo`.`modeloequipo` AS `modeloequipo`.
  •  `activo`.`situacionequipo` AS `Situacionequipo`.
  •  #01 (Agroup Ubicación).
  •  `crminfo`.`setype` AS `TipoUbicacion`.
  •  #02 (Regional).
  •  #03 (Clase sede).
  •  #04 (N1).
  •  #05 (N2).
  •  #06 (Estado sede).
  •  #07 (En proceso sede).
  •  #08 (Modulo).
  •  `activo`.`abrv` AS `abrv`.
  •  `activo`.`estado_activo` AS `estado_activo`.
  •  `activo`.`ubicacion` AS `ubicacion`.
  •  Nombre ubicacion
  •  sum(1) AS `frec`, count(0) AS `Cantidad`
Ubicación (URL ) en Redash:
Ubicación (RUTA) en base de datos:
206.189.187.192/CRM/Views/ba_equipos_inventario
Especificaciones técnicas de los campos involucrados: