
/*View structure for view `omsv_method_args` */

drop view if exists `omsv_method_args`;

drop table if exists `omsv_method_args`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `omsv_method_args` AS (select `a`.`id` AS `id`,`a`.`name` AS `name`,`a`.`type` AS `type`,`a`.`type2` AS `type2`,`a`.`type3` AS `type3`,`a`.`source` AS `source`,`a`.`destination` AS `destination`,`a`.`list_of_values` AS `list_of_values`,`a`.`default_value` AS `default_value`,`a`.`sql_query` AS `sql_query`,`m`.`id` AS `method_id`,`m`.`name` AS `method_name`,`m`.`type` AS `method_type`,`m`.`command` AS `method_cmd`,`m`.`description_id` AS `method_description_id`,`m`.`clif_classname` AS `clif_classname`,`m`.`svc_classname` AS `svc_classname`,`m`.`flags` AS `method_flags`,`m`.`args` AS `method_args` from (((`oms_sch_method` `m` join `oms_sch_method_argument` `a`) join `mtm_methods` `mtm`) join `oms_sch_relation` `r`) where ((`r`.`name` = _latin1'method2argument') and (`mtm`.`rel_id` = `r`.`id`) and (`mtm`.`id1` = `m`.`id`) and (`mtm`.`id2` = `a`.`id`)));

/*View structure for view `omsv_method_class_space` */

drop view if exists `omsv_method_class_space`;

drop table if exists `omsv_method_class_space`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `omsv_method_class_space` AS (select `m`.`id` AS `id`,`m`.`name` AS `name`,`m`.`type` AS `type`,`m`.`command` AS `command`,`m`.`description_id` AS `description_id`,`m`.`clif_classname` AS `clif_classname`,`m`.`svc_classname` AS `svc_classname`,`m`.`flags` AS `flags`,`m`.`args` AS `args`,`cl`.`id` AS `class_id`,`cl`.`name` AS `class_name`,`sp`.`id` AS `space_id`,`sp`.`name` AS `space_name` from ((((((`oms_sch_method` `m` join `oms_sch_class` `cl`) join `oms_gui_space` `sp`) join `mtm_methods` `mtm_m_cl`) join `mtm_methods` `mtm_m_sp`) join `oms_sch_relation` `rel_m_cl`) join `oms_sch_relation` `rel_m_sp`) where ((`m`.`id` = `mtm_m_cl`.`id1`) and (`cl`.`id` = `mtm_m_cl`.`id2`) and (`rel_m_cl`.`id` = `mtm_m_cl`.`rel_id`) and (`rel_m_cl`.`name` = _latin1'method2class') and (`m`.`id` = `mtm_m_sp`.`id1`) and (`sp`.`id` = `mtm_m_sp`.`id2`) and (`rel_m_sp`.`id` = `mtm_m_sp`.`rel_id`) and (`rel_m_sp`.`name` = _latin1'method2space')));

/*View structure for view `omsv_rbac_roleperms` */

drop view if exists `omsv_rbac_roleperms`;

drop table if exists `omsv_rbac_roleperms`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `omsv_rbac_roleperms` AS (select `r`.`id` AS `role_id`,`r`.`name` AS `rolename`,`r`.`status` AS `status`,`r`.`role2parent` AS `role2parent`,`p`.`name` AS `permname`,`p`.`id` AS `id`,`p`.`mode` AS `mode`,`p`.`allow` AS `allow`,`p`.`obj_type` AS `obj_type`,`p`.`obj_name` AS `obj_name`,`p`.`when_expression` AS `when_expression`,`p`.`rank` AS `rank` from ((`oms_rbac_perms` `p` join `oms_rbac_roles` `r`) join `oms_mtm_rbac_roleperm` `m`) where ((`r`.`id` = `m`.`id1`) and (`p`.`id` = `m`.`id2`)));

/*View structure for view `v_contact` */

drop view if exists `v_contact`;

drop table if exists `v_contact`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_contact` AS (select `c`.`oid` AS `oid`,`c`.`status` AS `status`,`c`.`contact2person` AS `contact2person`,`c`.`contact2info` AS `contact2info`,`p`.`oid` AS `person_oid`,`p`.`title` AS `title`,`p`.`firstname` AS `firstname`,`p`.`lastname` AS `lastname`,`p`.`lastname2` AS `lastname2`,`p`.`id_type` AS `id_type`,`p`.`id_number` AS `id_number`,`p`.`date_of_birth` AS `date_of_birth`,`ci`.`oid` AS `contact_info_oid`,`ci`.`phone` AS `phone`,`ci`.`phone2` AS `phone2`,`ci`.`email` AS `email`,`ci`.`web` AS `web` from ((`t_contact` `c` join `t_person` `p`) join `t_contact_info` `ci`) where ((`c`.`contact2person` = `p`.`oid`) and (`c`.`contact2info` = `ci`.`oid`)));

/*View structure for view `v_site` */

drop view if exists `v_site`;

drop table if exists `v_site`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_site` AS select `t_site`.`oid` AS `oid`,`t_site`.`name` AS `name`,`t_site`.`site2account` AS `site2account`,`t_site`.`site2address` AS `site2address`,`ac`.`oid` AS `account_oid`,`ac`.`id` AS `id`,`ac`.`type` AS `account_type`,`ac`.`status` AS `account_status`,`ac`.`account_name` AS `account_name`,`ad`.`oid` AS `address_oid`,`ad`.`recipient` AS `address_recipient`,`ad`.`address` AS `address`,`ad`.`address2` AS `address2`,`ad`.`city` AS `city`,`ad`.`county` AS `county`,`ad`.`country` AS `country`,`ad`.`zipcode` AS `zipcode` from ((`t_site` join `t_account` `ac`) join `t_address` `ad`) where ((`t_site`.`site2account` = `ac`.`oid`) and (`t_site`.`site2address` = `ad`.`oid`));

/*View structure for view `v_wfo_case` */

drop view if exists `v_wfo_case`;

drop table if exists `v_wfo_case`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_wfo_case` AS (select `w`.`id` AS `id`,`a`.`oid` AS `oid`,`a`.`ref` AS `ref`,`a`.`title` AS `title`,`a`.`creation_time` AS `creation_time`,`a`.`priority` AS `priority`,`w`.`type` AS `type`,`a`.`status` AS `status`,`u`.`username` AS `owner` from ((`t_case` `a` join `oms_wfo` `w`) join `oms_user` `u`) where ((`w`.`type` = _latin1't_case') and (`w`.`focus_id` = `a`.`oid`) and (`a`.`owner` = `u`.`id`)));

/*View structure for view `v_wfo_opportunity` */

drop view if exists `v_wfo_opportunity`;

drop table if exists `v_wfo_opportunity`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_wfo_opportunity` AS (select `w`.`id` AS `id`,`a`.`oid` AS `oid`,`a`.`ref` AS `ref`,`a`.`title` AS `title`,`a`.`creation_time` AS `creation_time`,_latin1' ' AS `priority`,`w`.`type` AS `type`,`a`.`status` AS `status`,`u`.`username` AS `owner` from ((`t_opportunity` `a` join `oms_wfo` `w`) join `oms_user` `u`) where ((`w`.`type` = _latin1't_opportunity') and (`w`.`focus_id` = `a`.`oid`) and (`a`.`owner` = `u`.`id`)));

/*View structure for view `v_wfo_order` */

drop view if exists `v_wfo_order`;

drop table if exists `v_wfo_order`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_wfo_order` AS (select `w`.`id` AS `id`,`a`.`oid` AS `oid`,`a`.`ref` AS `ref`,`a`.`title` AS `title`,`a`.`creation_time` AS `creation_time`,_latin1' ' AS `priority`,`w`.`type` AS `type`,`a`.`status` AS `status`,`u`.`username` AS `owner` from ((`t_order` `a` join `oms_wfo` `w`) join `oms_user` `u`) where ((`w`.`type` = _latin1't_order') and (`w`.`focus_id` = `a`.`oid`) and (`a`.`owner` = `u`.`id`)));

/*View structure for view `v_wfo_quote` */

drop view if exists `v_wfo_quote`;

drop table if exists `v_wfo_quote`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_wfo_quote` AS (select `w`.`id` AS `id`,`a`.`oid` AS `oid`,`a`.`ref` AS `ref`,`a`.`title` AS `title`,`a`.`creation_time` AS `creation_time`,_latin1' ' AS `priority`,`w`.`type` AS `type`,`a`.`status` AS `status`,`u`.`username` AS `owner` from ((`t_quote` `a` join `oms_wfo` `w`) join `oms_user` `u`) where ((`w`.`type` = _latin1't_quote') and (`w`.`focus_id` = `a`.`oid`) and (`a`.`owner` = `u`.`id`)));

/*View structure for view `v_wfo_solution` */

drop view if exists `v_wfo_solution`;

drop table if exists `v_wfo_solution`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_wfo_solution` AS (select `w`.`id` AS `id`,`a`.`oid` AS `oid`,`a`.`ref` AS `ref`,`a`.`title` AS `title`,`a`.`creation_time` AS `creation_time`,_latin1' ' AS `priority`,`w`.`type` AS `type`,`a`.`status` AS `status`,`u`.`username` AS `owner` from ((`t_solution` `a` join `oms_wfo` `w`) join `oms_user` `u`) where ((`w`.`type` = _latin1't_solution') and (`w`.`focus_id` = `a`.`oid`) and (`a`.`owner` = `u`.`id`)));

/*View structure for view `v_wfo` */

drop view if exists `v_wfo`;

drop table if exists `v_wfo`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_wfo` AS select `v_wfo_case`.`id` AS `id`,`v_wfo_case`.`oid` AS `oid`,`v_wfo_case`.`title` AS `title`,`v_wfo_case`.`creation_time` AS `creation_time`,`v_wfo_case`.`priority` AS `priority`,`v_wfo_case`.`type` AS `type`,`v_wfo_case`.`status` AS `status`,`v_wfo_case`.`owner` AS `owner` from `v_wfo_case` union select `v_wfo_order`.`id` AS `id`,`v_wfo_order`.`oid` AS `oid`,`v_wfo_order`.`title` AS `title`,`v_wfo_order`.`creation_time` AS `creation_time`,`v_wfo_order`.`priority` AS `priority`,`v_wfo_order`.`type` AS `type`,`v_wfo_order`.`status` AS `status`,`v_wfo_order`.`owner` AS `owner` from `v_wfo_order` union select `v_wfo_opportunity`.`id` AS `id`,`v_wfo_opportunity`.`oid` AS `oid`,`v_wfo_opportunity`.`title` AS `title`,`v_wfo_opportunity`.`creation_time` AS `creation_time`,`v_wfo_opportunity`.`priority` AS `priority`,`v_wfo_opportunity`.`type` AS `type`,`v_wfo_opportunity`.`status` AS `status`,`v_wfo_opportunity`.`owner` AS `owner` from `v_wfo_opportunity` union select `v_wfo_quote`.`id` AS `id`,`v_wfo_quote`.`oid` AS `oid`,`v_wfo_quote`.`title` AS `title`,`v_wfo_quote`.`creation_time` AS `creation_time`,`v_wfo_quote`.`priority` AS `priority`,`v_wfo_quote`.`type` AS `type`,`v_wfo_quote`.`status` AS `status`,`v_wfo_quote`.`owner` AS `owner` from `v_wfo_quote` union select `v_wfo_solution`.`id` AS `id`,`v_wfo_solution`.`oid` AS `oid`,`v_wfo_solution`.`title` AS `title`,`v_wfo_solution`.`creation_time` AS `creation_time`,`v_wfo_solution`.`priority` AS `priority`,`v_wfo_solution`.`type` AS `type`,`v_wfo_solution`.`status` AS `status`,`v_wfo_solution`.`owner` AS `owner` from `v_wfo_solution`;

