CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemPlacementSupplyList` AS SELECT `ips`.`id` AS `id`, `ips`.`itemFk` AS `itemFk`, `ips`.`quantity` AS `quantity`, `ips`.`priority` AS `priority`, IFNULL(`isps`.`created`, `ips`.`created`) AS `created`, `ips`.`userFk` AS `userFk`, `ips`.`repoUserFk` AS `repoUserFk`, `ips`.`quantity` - sum(IFNULL(`isps`.`quantity`, 0)) AS `saldo`, concat(`i`.`longName`, ' ', `i`.`size`) AS `longName`, `i`.`subName` AS `subName`, `i`.`size` AS `size`, `w`.`code` AS `workerCode`, `rw`.`code` AS `repoCode`, `ips`.`sectorFk` AS `sectorFk` FROM ( ( ( ( `vn`.`itemPlacementSupply` `ips` JOIN `vn`.`item` `i` ON(`i`.`id` = `ips`.`itemFk`) ) LEFT JOIN `vn`.`worker` `w` ON(`w`.`id` = `ips`.`userFk`) ) LEFT JOIN `vn`.`worker` `rw` ON(`rw`.`id` = `ips`.`repoUserFk`) ) LEFT JOIN `vn`.`itemShelvingPlacementSupply` `isps` ON(`isps`.`itemPlacementSupplyFk` = `ips`.`id`) ) WHERE `ips`.`created` >= `util`.`VN_CURDATE`() GROUP BY `ips`.`priority`, `ips`.`id`, `ips`.`sectorFk`