DOCUMENTACIÓN OXIPRO
Manual de instrucciones - Base de Datos
 
×
Menú
Índice
  • 3. Tablas
  • 3.18. ba_equipos_movimiento_cierre_mes
 

3.18. ba_equipos_movimiento_cierre_mes

 
Nombre de la tabla en Redash:

ba_equipos_movimiento_cierre_mes

Nombre de la tabla en BD:

ba_equipos_movimiento_cierre_mes

Descripción del objetivo de la Tabla:
Corresponde a una tabla historica del modulo movimiento de equipos, Se encuentra filtrada por mes anterior, y esta agrupada por origen,destino y subtipo.
Tipo de tabla:
Historica
Fecha versión actual:
------------------------------------------------------------------------------------
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,
       activo.subtipo,
 #01       CASE
            WHEN crminfofuente.setype = 'PacientesII' THEN
                CONCAT('Paciente - ', (SELECT acc.groupname
                    FROM vtiger_accountgrouprelation acc
                          INNER JOIN vtiger_pacientesii pac ON pac.accountid = acc.accountid
                    WHERE vtiger_movequipos.mv_fuente = pac.pacientesiiid), ' - ',
                           (select vtiger_account.epsconsolidada from vtiger_account inner 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,
        CASE
            WHEN crminfodestino.setype = 'PacientesII' THEN
                CONCAT('Paciente - ', (SELECT acc.groupname
                    FROM vtiger_accountgrouprelation acc
                          INNER JOIN vtiger_pacientesii pac ON pac.accountid = acc.accountid
                    WHERE vtiger_movequipos.mv_destino = pac.pacientesiiid), ' - ',
                           (select vtiger_account.epsconsolidada from vtiger_account inner 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,
        count(*) as Cantidad
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
where vtiger_movequipos.mv_date BETWEEN DATE_FORMAT(NOW() - INTERVAL 1 MONTH, '%Y-%m-%d 00:00:00') AND DATE_FORMAT(NOW(), '%Y-%m-%d 00:00:00')
AND crminfodestino.deleted = 0
group by subtipo, NombreUbicacionFuente, NombreUbicacionDestino
ORDER BY vtiger_movequipos.mv_date DESC
Tablas involucradas:
  •  vtiger_movequipos (Movimiento de equipos).
  •  vtiger_remisiondeequipos (Traslado de equipos).
  •  vtiger_activosretornables (Equipos electricos).
  •  vtiger_crmentity (Datos de creación).
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.
  •  activo.subtipo (Subtipo del equipo).
  •  #01 (Nombre del destino , ubicación).
Ubicación (URL) en Redash:
Ubicación (RUTA) en base de datos:
206.189.187.192/CRM/Tables/

ba_equipos_movimiento_cierre_mes

Especificaciones técnicas de los campos involucrados:
Tiempo de ejecución CRON:
Se actualiza a cierre de mes, con una periodicidad mensual.