SELECT `activo`.`activosretornablesid` AS `activosretornablesid`,
`activo`.`codigo_barras` AS `codigo_barras`,
`activo`.`nombre_activo` AS `nombre_activo`,
`activo`.`abrv` AS `abrv`,
`activo`.`rangoedad` AS `rangoedad`,
`activo`.`tipo_equipo` AS `tipo_equipo`,
`activo`.`subtipo` AS `subtipo`,
`activo`.`serialno` AS `serialno`,
`activo`.`ubicacion` AS `ubicacion`,
`activo`.`ubicaciones` AS `ubicaciones`,
`activo`.`propietario` AS `propietario`,
`activo`.`linea_servicio` AS `linea_servicio`,
`activo`.`situacionequipo` AS `Situacionequipo`,
`activo`.`observaciones` AS `observaciones`,
`activo`.`fultimomantenimiento` AS `fultimomantenimiento`,
`activo`.`fechamovimiento` AS `fechamovimiento`,
CAST(`activo`.`fecha_proximo_mantenimiento` AS DATE) AS `fecha_proximo_mantenimiento`,
`activo`.`horasuso` AS `horasuso`,
`activo`.`estado_activo` AS `estado_activo`,
#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 if((`crminfo`.`setype` = 'PacientesII'),
(SELECT `vtiger_pacientesii`.`docid`
FROM `vtiger_pacientesii`
WHERE (`activo`.`ubicacion` = `vtiger_pacientesii`.`pacientesiiid`)),0) AS `docid`,
`cilindro`.`tipogases` AS `tipogases`,
`cilindro`.`fecha_proxima_hidrostatica` AS `fecha_proxima_hidrostatica`,
`cilindro`.`lote` AS `lote`,
#03 (CASE
WHEN (`crminfo`.`setype` = 'PacientesII') THEN
(SELECT `vtiger_pacientesii`.`identificador_paciente`
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 `vtiger_planillastrabajo`.`identificador`
FROM `vtiger_planillastrabajo`
WHERE (`activo`.`ubicacion` = `vtiger_planillastrabajo`.`planillastrabajoid`))
WHEN (`crminfo`.`setype` = 'Accounts') THEN
(SELECT `vac`.`accountname`
FROM `vtiger_account` `vac`
WHERE (`activo`.`ubicacion` = `vac`.`accountname`))
WHEN (`crminfo`.`setype` = 'Vendors') THEN `vendor`.`vendorname`
END) AS `ubicacionNombre`,
#04 (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`
JOIN `vtiger_account` `vac`)
WHERE ((`activo`.`ubicacion` = `vac`.`accountid`)
AND (`vac`.`accountid` = `acc`.`accountid`)))
END) AS `Regional`,
#05 (CASE
WHEN (`crminfo`.`setype` = 'PacientesII') THEN 'Paciente'
WHEN (`crminfo`.`setype` = 'Sedes') THEN 'Sede'
WHEN (`crminfo`.`setype` = 'PlanillasTrabajo') THEN 'Planilla'
WHEN (`crminfo`.`setype` = 'Accounts') THEN 'Entidad'
WHEN (`crminfo`.`setype` = 'Vendors') THEN 'Proveedor'
END) AS `TipoUbicación`,
`activo`.`propiedad` AS `propiedad`,
#06 (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`,
`activo`.`modeloequipo` AS `modeloequipo`,
`activo`.`supertipo` AS `supertipo`,
`activo`.`fabricante` AS `fabricante`,
`activo`.`vendor_id` AS `vendor_id`,
`vendor`.`vendorname` AS `vendor_name`,
#07 (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`,
#08 (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`
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`,
#09 (CASE
WHEN (`crminfo`.`setype` = 'PacientesII') THEN
(SELECT `pac_cf`.`cf_1619`
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')
WHERE (`activo`.`ubicacion` = `pt`.`planillastrabajoid`)) USING latin1)
WHEN (`crminfo`.`setype` = 'Accounts') THEN
(SELECT `vac`.`visualizacioncreacionpaciente`
WHERE (`activo`.`ubicacion` = `vac`.`accountname`))
WHEN (`crminfo`.`setype` = 'Vendors') THEN `vendor`.`situacionproveedor`
END) AS `EstadoUbicacion`,
#10 (SELECT `vtiger_sedescf`.`cf_3330`
WHERE ((`activo`.`ubicacion` = `vtiger_sedes`.`sedesid`)
AND (`vtiger_sedes`.`sedesid` = `vtiger_sedescf`.`sedesid`))) AS `enproceso_Sede`,
(CASE
WHEN isnull(`cilindro`.`cilindrosid`) THEN 'Electrico'
WHEN (`cilindro`.`cilindrosid` IS NOT NULL) THEN 'Gases'
END) AS `modulo`
LEFT JOIN ` vtiger_cilindros` `cilindro` on((`activo`.`activosretornablesid` = `cilindro`.`cilindrosid`)))
LEFT JOIN ` vtiger_vendor` `vendor` on((`activo`.`vendor_id` = `vendor`.`vendorid`))))
WHERE (`activo`.`ubicacion` = `crminfo`.`crmid`);
|