CREATE SCHEMA IF NOT EXISTS `vn2008`; USE `vn`; CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `ticketState` AS SELECT `tt`.`created` AS `updated`, `tt`.`stateFk` AS `stateFk`, `tt`.`userFk` AS `workerFk`, `tls`.`ticketFk` AS `ticketFk`, `s`.`id` AS `state`, `s`.`order` AS `productionOrder`, `s`.`alertLevel` AS `alertLevel`, `s`.`code` AS `code`, `tls`.`ticketFk` AS `ticket`, `tt`.`userFk` AS `worker`, `s`.`isPreviousPreparable` AS `isPreviousPreparable`, `s`.`isPicked` AS `isPicked` FROM ( ( `ticketLastState` `tls` JOIN `ticketTracking` `tt` ON(`tt`.`id` = `tls`.`ticketTrackingFk`) ) JOIN `state` `s` ON(`s`.`id` = `tt`.`stateFk`) ); CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`v_inter` AS SELECT `tt`.`id` AS `inter_id`, `tt`.`stateFk` AS `state_id`, `tt`.`notes` AS `nota`, `tt`.`created` AS `odbc_date`, `tt`.`ticketFk` AS `Id_Ticket`, `tt`.`userFk` AS `Id_Trabajador`, `tt`.`supervisorFk` AS `Id_supervisor` FROM `vn`.`ticketTracking` `tt`; CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `ticketStateToday` AS SELECT `ts`.`ticket` AS `ticket`, `ts`.`state` AS `state`, `ts`.`productionOrder` AS `productionOrder`, `ts`.`alertLevel` AS `alertLevel`, `ts`.`worker` AS `worker`, `ts`.`code` AS `code`, `ts`.`updated` AS `updated`, `ts`.`isPicked` AS `isPicked` FROM (`ticketState` `ts` JOIN `ticket` `t` ON (`t`.`id` = `ts`.`ticket`)) WHERE `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `MIDNIGHT`(`util`.`VN_CURDATE`());