2.8.4. bi_equipos_movimiento

 
Nombre de la vista en Redash:

bi_equipos_movimiento

Nombre de la vista en BD:

bi_equipos_movimiento

Descripción del objetivo de la vista:
Muestra los movimientos de los equipos hechos en el crm.
Tipo de vista:
En linea
Fecha versión actual:
21-Junio-2022
Declaración SQL:
select
   date_format(`vtiger_movequipos`.`mv_date`, '%Y%m%d') AS `agno_mes_dia`,
   date_format(`vtiger_movequipos`.`mv_date`, '%Y%m') AS `agno_mes`,
   yearweek(`vtiger_movequipos`.`mv_date`, 0) AS `agno_semana`,
   `vtiger_movequipos`.`mvid` AS `mvid`,
   `vtiger_movequipos`.`movequiposid` AS `movequiposid`,
   `vtiger_movequipos`.`mv_equipo` AS `mv_equipo`,
   `activo`.`nombre_activo` AS `nombre_activo`,
   `activo`.`codigo_barras` AS `codigo_barras`,
   `activo`.`propiedadequipo` AS `propiedadequipo`,
   `activo`.`modeloequipo` AS `modeloequipo`,
   `activo`.`supertipo` AS `supertipo`,
   `activo`.`subtipo` AS `subtipo`,
   `activo`.`situacionequipo` AS `situacionequipo`,
   `activo`.`linea_servicio` AS `linea_servicio`,
   `activo`.`estado_activo` AS `estado_activo_actual`,
   `vtiger_movequipos`.`mv_date` AS `FechaMovimiento`,
   `vtiger_movequipos`.`tipomovimiento` AS `TIPOMOVIMIENTO`,
   `vtiger_movequipos`.`tiposoporte` AS `TIPOSOPORTE`,
  #01  (
      case
         when
            (
               `crminfofuente`.`setype` = 'PacientesII'
            )
         then
(
            select
               `acc`.`groupname`
            from
               (
                  `vtiger_accountgrouprelation` `acc`
                  join
                     `vtiger_pacientesii` `pac`
               )
            where
               (
(`vtiger_movequipos`.`mv_fuente` = `pac`.`pacientesiiid`)
                  and
                  (
                     `pac`.`accountid` = `acc`.`accountid`
                  )
               )
)
            when
               (
                  `crminfofuente`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedescf`.`cf_2271`
               from
                  `vtiger_sedescf`
               where
                  (
                     `vtiger_movequipos`.`mv_fuente` = `vtiger_sedescf`.`sedesid`
                  )
)
               when
                  (
                     `crminfofuente`.`setype` = 'PlanillasTrabajo'
                  )
               then
(
                  select
                     `rutascf`.`cf_2961`
                  from
                     (
                        `vtiger_rutascf` `rutascf`
                        join
                           `vtiger_planillastrabajo` `pt`
                     )
                  where
                     (
(`vtiger_movequipos`.`mv_fuente` = `pt`.`planillastrabajoid`)
                        and
                        (
                           `pt`.`ruta` = `rutascf`.`rutasid`
                        )
                     )
)
      end
   )
   AS `REGIONAL_FUENTE`,
 #02 (
      case
         when
            (
               `crminfodestino`.`setype` = 'PacientesII'
            )
         then
(
            select
               `acc`.`groupname`
            from
               (
                  `vtiger_accountgrouprelation` `acc`
                  join
                     `vtiger_pacientesii` `pac`
               )
            where
               (
(`vtiger_movequipos`.`mv_destino` = `pac`.`pacientesiiid`)
                  and
                  (
                     `pac`.`accountid` = `acc`.`accountid`
                  )
               )
)
            when
               (
                  `crminfodestino`.`setype` = 'Sedes'
               )
            then
(
               select
                  `vtiger_sedescf`.`cf_2271`
               from
                  `vtiger_sedescf`
               where
                  (
                     `vtiger_movequipos`.`mv_destino` = `vtiger_sedescf`.`sedesid`
                  )
)
               when
                  (
                     `crminfodestino`.`setype` = 'PlanillasTrabajo'
                  )
               then
(
                  select
                     `rutascf`.`cf_2961`
                  from
                     (
                        `vtiger_rutascf` `rutascf`
                        join
                           `vtiger_planillastrabajo` `pt`
                     )
                  where
                     (
(`vtiger_movequipos`.`mv_destino` = `pt`.`planillastrabajoid`)
                        and
                        (
                           `pt`.`ruta` = `rutascf`.`rutasid`
                        )
                     )
)
      end
   )
   AS `REGIONAL_DESTINO`,
 #03  (
      case
         when
            (
               `crminfofuente`.`setype` = 'PacientesII'
            )
         then
            'Paciente'
         when
            (
               `crminfofuente`.`setype` = 'Sedes'
            )
         then
            'Sede'
         when
            (
               `crminfofuente`.`setype` = 'PlanillasTrabajo'
            )
         then
            'Planilla'
         when
            (
               `crminfofuente`.`setype` = 'Accounts'
            )
         then
            'Entidad'
         when
            (
               `crminfofuente`.`setype` = 'Vendors'
            )
         then
            'Proveedor'
      end
   )
   AS `TipoUbicacionFuente`,
 #04  (
      case
         when
            (
               `crminfodestino`.`setype` = 'PacientesII'
            )
         then
            'Paciente'
         when
            (
               `crminfodestino`.`setype` = 'Sedes'
            )
         then
            'Sede'
         when
            (
               `crminfodestino`.`setype` = 'PlanillasTrabajo'
            )
         then
            'Planilla'
         when
            (
               `crminfodestino`.`setype` = 'Accounts'
            )
         then
            'Entidad'
         when
            (
               `crminfodestino`.`setype` = 'Vendors'
            )
         then
            'Proveedor'
      end
   )
   AS `TipoUbicacionDestino`,
 #05  (
      case
         when
            (
               `crminfofuente`.`setype` = 'PacientesII'
            )
         then
            'Paciente'
         when
            (
               `crminfofuente`.`setype` = 'Sedes'
            )
         then
(
            select
               `vtiger_sedes`.`clasesede`
            from
               `vtiger_sedes`
            where
               (
                  `vtiger_sedes`.`sedesid` = `vtiger_movequipos`.`mv_fuente`
               )
)
            when
               (
                  `crminfofuente`.`setype` = 'PlanillasTrabajo'
               )
            then
(
               select
                  `vtiger_rutas`.`tiporuta`
               from
                  (
                     `vtiger_planillastrabajo`
                     join
                        `vtiger_rutas`
                        on((`vtiger_planillastrabajo`.`ruta` = `vtiger_rutas`.`rutasid`))
                  )
               where
                  (
                     `vtiger_planillastrabajo`.`planillastrabajoid` = `vtiger_movequipos`.`mv_fuente`
                  )
)
               when
                  (
                     `crminfofuente`.`setype` = 'Accounts'
                  )
               then
(
                  select
                     `vtiger_account`.`epsconsolidada`
                  from
                     `vtiger_account`
                  where
                     (
                        `vtiger_account`.`accountid` = `vtiger_movequipos`.`mv_fuente`
                     )
)
                  when
                     (
                        `crminfofuente`.`setype` = 'Vendors'
                     )
                  then
(
                     select
                        `vtiger_vendor`.`vendorname`
                     from
                        `vtiger_vendor`
                     where
                        (
                           `vtiger_vendor`.`vendorid` = `vtiger_movequipos`.`mv_fuente`
                        )
)
      end
   )
   AS `N1_Fuente`,
 #06 (
      case
         when
            (
               `crminfodestino`.`setype` = 'PacientesII'
            )
         then
            'Paciente'
         when
            (
               `crminfodestino`.`setype` = 'Sedes'
            )
         then
(
            select
               `vtiger_sedes`.`clasesede`
            from
               `vtiger_sedes`
            where
               (
                  `vtiger_sedes`.`sedesid` = `vtiger_movequipos`.`mv_destino`
               )
)
            when
               (
                  `crminfodestino`.`setype` = 'PlanillasTrabajo'
               )
            then
(
               select
                  `vtiger_rutas`.`tiporuta`
               from
                  (
                     `vtiger_planillastrabajo`
                     join
                        `vtiger_rutas`
                        on((`vtiger_planillastrabajo`.`ruta` = `vtiger_rutas`.`rutasid`))
                  )
               where
                  (
                     `vtiger_planillastrabajo`.`planillastrabajoid` = `vtiger_movequipos`.`mv_destino`
                  )
)
               when
                  (
                     `crminfodestino`.`setype` = 'Accounts'
                  )
               then
(
                  select
                     `vtiger_account`.`epsconsolidada`
                  from
                     `vtiger_account`
                  where
                     (
                        `vtiger_account`.`accountid` = `vtiger_movequipos`.`mv_destino`
                     )
)
                  when
                     (
                        `crminfodestino`.`setype` = 'Vendors'
                     )
                  then
(
                     select
                        `vtiger_vendor`.`vendorname`
                     from
                        `vtiger_vendor`
                     where
                        (
                           `vtiger_vendor`.`vendorid` = `vtiger_movequipos`.`mv_destino`
                        )
)
      end
   )
   AS `N1_Destino`,
   `vtiger_movequipos`.`mv_destino` AS `mv_destino`,
   `vtiger_movequipos`.`mv_fuente` AS `mv_fuente`,
 #07 (
      case
         when
            (
               `crminfofuente`.`setype` = 'PacientesII'
            )
         then
            concat('Paciente - ',
            (
               select
                  `acc`.`groupname`
               from
                  (
                     `vtiger_accountgrouprelation` `acc`
                     join
                        `vtiger_pacientesii` `pac`
                        on((`pac`.`accountid` = `acc`.`accountid`))
                  )
               where
                  (
                     `vtiger_movequipos`.`mv_fuente` = `pac`.`pacientesiiid`
                  )
            )
, ' - ',
            (
               select
                  `vtiger_account`.`epsconsolidada`
               from
                  (
                     `vtiger_account`
                     join
                        `vtiger_pacientesii`
                        on((`vtiger_pacientesii`.`accountid` = `vtiger_account`.`accountid`))
                  )
               where
                  (
                     `vtiger_movequipos`.`mv_fuente` = `vtiger_pacientesii`.`pacientesiiid`
                  )
            )
)
         when
            (
               `crminfofuente`.`setype` = 'Sedes'
            )
         then
(
            select
               `vtiger_sedes`.`sede`
            from
               `vtiger_sedes`
            where
               (
                  `vtiger_sedes`.`sedesid` = `crminfofuente`.`crmid`
               )
)
            when
               (
                  `crminfofuente`.`setype` = 'PlanillasTrabajo'
               )
            then
(
               select
                  `vtiger_planillastrabajo`.`identificador`
               from
                  `vtiger_planillastrabajo`
               where
                  (
                     `vtiger_planillastrabajo`.`planillastrabajoid` = `crminfofuente`.`crmid`
                  )
)
               when
                  (
                     `crminfofuente`.`setype` = 'Accounts'
                  )
               then
(
                  select
                     `vtiger_account`.`accountname`
                  from
                     `vtiger_account`
                  where
                     (
                        `vtiger_account`.`accountid` = `crminfofuente`.`crmid`
                     )
)
                  when
                     (
                        `crminfofuente`.`setype` = 'Vendors'
                     )
                  then
(
                     select
                        `vtiger_vendor`.`vendorname`
                     from
                        `vtiger_vendor`
                     where
                        (
                           `vtiger_vendor`.`vendorid` = `crminfofuente`.`crmid`
                        )
)
      end
   )
   AS `NombreUbicacionFuente`,
 #08  (
      case
         when
            (
               `crminfodestino`.`setype` = 'PacientesII'
            )
         then
            concat('Paciente - ',
            (
               select
                  `acc`.`groupname`
               from
                  (
                     `vtiger_accountgrouprelation` `acc`
                     join
                        `vtiger_pacientesii` `pac`
                        on((`pac`.`accountid` = `acc`.`accountid`))
                  )
               where
                  (
                     `vtiger_movequipos`.`mv_destino` = `pac`.`pacientesiiid`
                  )
            )
, ' - ',
            (
               select
                  `vtiger_account`.`epsconsolidada`
               from
                  (
                     `vtiger_account`
                     join
                        `vtiger_pacientesii`
                        on((`vtiger_pacientesii`.`accountid` = `vtiger_account`.`accountid`))
                  )
               where
                  (
                     `vtiger_movequipos`.`mv_destino` = `vtiger_pacientesii`.`pacientesiiid`
                  )
            )
)
         when
            (
               `crminfodestino`.`setype` = 'Sedes'
            )
         then
(
            select
               `vtiger_sedes`.`sede`
            from
               `vtiger_sedes`
            where
               (
                  `vtiger_sedes`.`sedesid` = `crminfodestino`.`crmid`
               )
)
            when
               (
                  `crminfodestino`.`setype` = 'PlanillasTrabajo'
               )
            then
(
               select
                  `vtiger_planillastrabajo`.`identificador`
               from
                  `vtiger_planillastrabajo`
               where
                  (
                     `vtiger_planillastrabajo`.`planillastrabajoid` = `crminfodestino`.`crmid`
                  )
)
               when
                  (
                     `crminfodestino`.`setype` = 'Accounts'
                  )
               then
(
                  select
                     `vtiger_account`.`accountname`
                  from
                     `vtiger_account`
                  where
                     (
                        `vtiger_account`.`accountid` = `crminfodestino`.`crmid`
                     )
)
                  when
                     (
                        `crminfodestino`.`setype` = 'Vendors'
                     )
                  then
(
                     select
                        `vtiger_vendor`.`vendorname`
                     from
                        `vtiger_vendor`
                     where
                        (
                           `vtiger_vendor`.`vendorid` = `crminfodestino`.`crmid`
                        )
)
      end
   )
   AS `NombreUbicacionDestino`,
  #09 (
      case
         when
            (
               `Uorigen`.`id` = `vtiger_remisiondeequipos`.`personaor`
            )
         then
            `Uorigen`.`user_name`
         when
            (
               `REMempOR`.`empleadosid` = `vtiger_remisiondeequipos`.`personaor`
            )
         then
            `vtiger_users`.`user_name`
      end
   )
   AS `Persona_Origen`,
 #10  (
      case
         when
            (
               `Udestino`.`id` = `vtiger_remisiondeequipos`.`personades`
            )
         then
            `Udestino`.`user_name`
      end
   )
   AS `Persona_Destino`,
`vtiger_movequipos`.`soporte` AS `SOPORTE`
from
   (
(((((((((((`vtiger_movequipos`
      left join
         `vtiger_remisiondeequipos`
         on((`vtiger_remisiondeequipos`.`remisiondeequiposid` = `vtiger_movequipos`.`soporte`)))
      left join
         `vtiger_activosretornables` `activo`
         on((`activo`.`activosretornablesid` = `vtiger_movequipos`.`mv_equipo`)))
      left join
         `vtiger_crmentity` `crminfo`
         on(((`crminfo`.`crmid` = `activo`.`ubicacion`)
         and
         (
            `vtiger_movequipos`.`mv_date` = curdate()
         )
)))
      left join
         `vtiger_crmentity` `crminfofuente`
         on((`vtiger_movequipos`.`mv_fuente` = `crminfofuente`.`crmid`)))
      left join
         `vtiger_crmentity` `crminfodestino`
         on((`vtiger_movequipos`.`mv_destino` = `crminfodestino`.`crmid`)))
      left join
         `vtiger_crmentity` `crmentity`
         on((`vtiger_movequipos`.`movequiposid` = `crmentity`.`crmid`)))
      left join
         `vtiger_users` `Uorigen`
         on((`vtiger_remisiondeequipos`.`personaor` = `Uorigen`.`id`)))
      left join
         `vtiger_empleados` `REMempOR`
         on((`REMempOR`.`empleadosid` = `vtiger_remisiondeequipos`.`personaor`)))
      left join
         `vtiger_users`
         on((`REMempOR`.`usuario` = `vtiger_users`.`id`)))
      left join
         `vtiger_users` `Udestino`
         on((`vtiger_remisiondeequipos`.`personades` = `Udestino`.`id`)))
      left join
         `vtiger_empleados` `REMempDES`
         on((`REMempDES`.`empleadosid` = `vtiger_remisiondeequipos`.`personades`)))
      left join
         `vtiger_empleados` `EmpDestino`
         on((`EmpDestino`.`usuario` = `Udestino`.`id`))
   )
where
   (
      `crminfodestino`.`deleted` = 0
   )
order by
   `vtiger_movequipos`.`mv_date` desc
Tablas involucradas:
  •  vtiger_empleados.
  •  vtiger_crmentity (Datos de creación).
  •  vtiger_users (usuarios).
  •  vtiger_movequipos (Movimiento de equipos).
  •  vtiger_remisiondeequipos (equipos).
Columnas involucradas:
  •  date_format(`vtiger_movequipos`.`mv_date`, '%Y%m%d') AS `agno_mes_dia`.
  •  date_format(`vtiger_movequipos`.`mv_date`, '%Y%m') AS `agno_mes`.
  •  yearweek(`vtiger_movequipos`.`mv_date`, 0) AS `agno_semana`.
  •  `vtiger_movequipos`.`mvid` AS `mvid`.
  •  `vtiger_movequipos`.`movequiposid` AS `movequiposid`.
  •  `vtiger_movequipos`.`mv_equipo` AS `mv_equipo`.
  •  `activo`.`nombre_activo` AS `nombre_activo`.
  •  `activo`.`codigo_barras` AS `codigo_barras`.
  •  `activo`.`propiedadequipo` AS `propiedadequipo`.
  •  `activo`.`modeloequipo` AS `modeloequipo`.
  •  `activo`.`supertipo` AS `supertipo`.
  •  `activo`.`subtipo` AS `subtipo`.
  •  `activo`.`situacionequipo` AS `situacionequipo`.
  •  `activo`.`linea_servicio` AS `linea_servicio`.
  •  `activo`.`estado_activo` AS `estado_activo_actual`.
  •  `vtiger_movequipos`.`mv_date` AS `FechaMovimiento`.
  •  `vtiger_movequipos`.`tipomovimiento` AS `TIPOMOVIMIENTO`.
  •  `vtiger_movequipos`.`tiposoporte` AS `TIPOSOPORTE`.
  •  #01 (Regional fuente).
  •  #02 (Regional destino).
  •  #03 (Tipo de Ubicacion Fuente).
  •  #04 (Tipo de Ubicacion Destino).
  •  #05 (N1 fuente).
  •  #06 (N1 destino).
  •  `vtiger_movequipos`.`mv_destino` AS `mv_destino`.
  •   `vtiger_movequipos`.`mv_fuente` AS `mv_fuente`.
  •  #07 (Nombre ubicacion Fuente).
  •  #08 (Nombre ubicacion Destino).
  •  #09 (Persona origen).
  •  #10 (Persona destino).
  •  `vtiger_movequipos`.`soporte` AS `SOPORTE`.
Ubicación (URL ) en Redash:
-------------------------------------------------------------------------------
Ubicación (RUTA) en base de datos:
206.189.187.192/CRM/Views/bi_equipos_movimiento
Especificaciones técnicas de los campos involucrados: