salix/db/routines/vn/views/expeditionCommon.sql

32 lines
954 B
SQL

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionCommon`
AS SELECT `rs`.`id` AS `truckFk`,
`rs`.`eta` AS `eta`,
IFNULL(ucase(`rs`.`description`), 'SIN ESCANEAR') AS `description`,
`es`.`palletFk` AS `palletFk`,
`t`.`routeFk` AS `routeFk`,
`es`.`id` AS `scanFk`,
`e`.`id` AS `expeditionFk`,
`r`.`roadmapStopFk` AS `roadmapStopFk`,
`t`.`warehouseFk` AS `warehouseFk`,
`e`.`created` AS `lastPacked`,
`t`.`id` AS `ticketFk`
FROM (
(
(
(
(
`vn`.`roadmapStop` `rs`
LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`roadmapStopFk`)
)
LEFT JOIN `vn`.`ticket` `t` ON(`r`.`routeFk` = `t`.`routeFk`)
)
LEFT JOIN `vn`.`expedition` `e` ON(`t`.`id` = `e`.`ticketFk`)
)
LEFT JOIN `vn`.`expeditionScan` `es` ON(`e`.`id` = `es`.`expeditionFk`)
)
LEFT JOIN `vn`.`expeditionPallet` `ep` ON(`es`.`palletFk` = `ep`.`id`)
)
WHERE `rs`.`eta` >= `util`.`VN_CURDATE`()