
-- ------ WORKFLOW ----------


-- dropping data
 delete from ud_workflow_step_email where 1;
 delete from ud_workflow_step_action_multi_performing_roles where 1;
 delete from ud_workflow_step_action where 1;
 delete from ud_workflow_step where 1;
 delete from ud_workflow_admin where 1;
 delete from ud_workflow where 1;
-- inserting data
-- ------ ENTITIES ----------


-- dropping data
 delete from ud_entity_tabs where 1;
 delete from ud_entity_sections where 1;
 delete from ud_entity_report where 1;
 delete from ud_entity_multi_choices where 1;
 delete from ud_entity_dashboards where 1;
 delete from ud_entity_children where 1;
 delete from ud_entity_fields where 1;
 delete from ud_entity_action where 1;
 delete from ud_entity where 1;
 delete from ud_entity_modules where 1;

-- dropping FKs
 call db_drop_foreign_key (ud_entity_sections, fk_entity_sections_to_tabs);
 call db_drop_foreign_key (ud_entity_tabs, fk_entity_tabs_to_entity);
 call db_drop_foreign_key (ud_entity_report, fk_entity_report_to_entity);

-- import entity tables

 -- inserting 152 rows into ud_entity_sections

 insert into ud_entity_sections (id,tab_id,sorter,name,caption,visible_if_code,enable_if_code) values
(1,1,1,'Company Details','Company Details','',''),
(2,1,2,'Tax','Tax Information','',''),
(3,1,3,'Address','Address','',''),
(4,2,1,'General','General','',''),
(5,3,1,'General','General','',''),
(6,4,1,'General','General','',''),
(7,5,1,'General','General','',''),
(8,6,1,'General','General','',''),
(9,7,1,'General','General','',''),
(10,8,1,'General','General','',''),
(11,9,1,'General','General','',''),
(12,10,1,'General','General','',''),
(13,11,1,'General','General','',''),
(14,12,1,'General','General','',''),
(15,13,1,'General','General','',''),
(16,14,1,'General','General','',''),
(17,15,1,'General','General','',''),
(18,16,1,'General','General','',''),
(19,17,1,'General','General','',''),
(20,18,1,'General','General','',''),
(21,19,1,'General','General','',''),
(22,20,1,'General','General','',''),
(23,21,1,'General','General','',''),
(24,22,1,'General','General','',''),
(25,23,1,'General','General','',''),
(26,24,1,'General','General','',''),
(27,25,1,'General','General','',''),
(28,26,1,'General','General','',''),
(29,27,1,'General','General','',''),
(30,28,1,'General','General','',''),
(31,29,1,'General','General','',''),
(32,30,1,'General','General','',''),
(33,31,1,'General','General','',''),
(34,32,1,'General','General','',''),
(35,33,1,'General','General','',''),
(36,34,1,'General','General','',''),
(37,35,1,'General','General','',''),
(38,36,1,'General','General','',''),
(39,37,1,'General','General','',''),
(40,38,1,'General','General','',''),
(41,39,1,'General','General','',''),
(42,40,1,'General','General','',''),
(43,41,1,'General','General','',''),
(44,42,1,'General','General','',''),
(45,43,1,'General','General','',''),
(46,44,1,'General','General','',''),
(47,45,1,'General','General','',''),
(48,46,1,'General','General','',''),
(49,47,1,'General','General','',''),
(50,48,1,'General','General','','');

 insert into ud_entity_sections (id,tab_id,sorter,name,caption,visible_if_code,enable_if_code) values
(51,49,1,'General','General','',''),
(52,50,1,'General','General','',''),
(53,51,1,'General','General','',''),
(54,52,1,'General','General','',''),
(55,53,1,'General','General','',''),
(56,54,1,'General','General','',''),
(57,55,1,'General','General','',''),
(60,58,1,'General','General','',''),
(61,59,1,'General','General','',''),
(62,60,1,'General','General','',''),
(63,61,1,'General','General','',''),
(64,62,1,'General','General','',''),
(65,63,1,'General','General','',''),
(66,64,1,'General','General','',''),
(67,65,1,'General','General','',''),
(68,66,1,'General','General','',''),
(69,67,1,'General','General','',''),
(70,68,1,'General','General','',''),
(71,69,1,'General','General','',''),
(72,70,1,'General','General','',''),
(73,71,1,'General','General','',''),
(74,72,1,'General','General','',''),
(75,73,1,'General','General','',''),
(76,74,1,'General','General','',''),
(77,75,1,'General','General','',''),
(78,76,1,'General','General','',''),
(79,77,1,'General','General','',''),
(80,78,1,'General','General','',''),
(81,79,1,'General','General','',''),
(82,80,1,'General','General','',''),
(83,81,1,'General','General','',''),
(84,82,1,'General','General','',''),
(85,83,1,'General','General','',''),
(86,84,1,'General','General','',''),
(87,85,1,'General','General','',''),
(88,86,1,'General','General','',''),
(89,87,1,'General','General','',''),
(90,88,1,'General','General','',''),
(91,89,1,'General','General','',''),
(92,90,1,'General','General','',''),
(93,91,1,'General','General','',''),
(94,92,1,'General','General','',''),
(95,93,1,'General','General','',''),
(96,94,1,'General','General','',''),
(97,95,1,'General','General','',''),
(98,96,1,'General','General','',''),
(100,97,1,'General','General','',''),
(101,98,1,'General','General','',''),
(102,99,1,'General','General','',''),
(103,100,1,'General','General','','');
(104,101,1,'General','General','',''),
(105,102,1,'General','General','',''),
(106,103,1,'General','General','',''),
(107,104,1,'General','General','',''),
(108,105,1,'General','General','',''),
(109,106,1,'General','General','',''),
(110,107,1,'General','General','',''),
(111,108,1,'General','General','',''),
(112,109,1,'General','General','',''),
(113,110,1,'General','General','',''),
(114,111,1,'General','General','',''),
(115,112,1,'General','General','',''),
(116,113,1,'General','General','',''),
(117,114,1,'General','General','',''),
(118,115,1,'General','General','',''),
(119,116,1,'General','General','',''),
(121,118,1,'General','General','',''),
(122,119,1,'General','General','',''),
(123,120,1,'General','General','',''),
(124,121,1,'General','General','',''),
(125,122,1,'General','General','',''),
(126,123,1,'General','General','',''),
(127,124,1,'General','General','',''),
(128,125,1,'General','General','',''),
(129,126,1,'General','General','',''),
(130,127,1,'General','General','',''),
(131,128,1,'General','General','',''),
(132,129,1,'General','General','',''),
(259,60,2,'Carousel','Carousel Settings','',''),
(260,125,2,'multi_select_tab','Multi Select Tab','',''),
(261,130,1,'General','General','',''),
(262,131,1,'General','General','',''),
(263,122,2,'Parent Relations','','',''),
(264,124,2,'Character Settings','Character Settings','$record_details-&gt;type == &quot;string&quot;',''),
(265,124,3,'Numeric Settings','Numeric Settings','$record_details-&gt;type == &quot;numeric&quot;',''),
(266,124,99,'Other','Other','',''),
(267,124,4,'Sorting and Filtering','Sorting and Filtering','',''),
(268,124,5,'Visibility','Visibility','',''),
(269,124,6,'Entity Lookup','Entity Lookup','$record_details-&gt;type == &quot;entity_lookup&quot;',''),
(270,124,7,'Password','Password','$record_details-&gt;type == &quot;password&quot;',''),
(271,124,8,'Attachment','Attachment','$record_details-&gt;type == &quot;attachment&quot;',''),
(272,124,6,'Core Lookup','Core Lookup','$record_details-&gt;type == &quot;core_lookup&quot;',''),
(273,133,1,'General','General','',''),
(274,133,2,'SEO','SEO (Search Engine Optimization)','',''),
(275,133,3,'Statistics','Statistics','',''),
(276,134,1,'General','General','',''),
(277,135,1,'General','General','',''),
(278,136,1,'General','General','',''),
(279,137,1,'General','','',''),
(280,137,2,'Discount','','','');
(281,42,2,'Email','Email','',''),
(282,138,1,'General','General','','');

 -- inserting 134 rows into ud_entity_tabs

 insert into ud_entity_tabs (id,entity_id,sorter,name,caption,visible_if_code,enable_if_code) values
(1,123,1,'Properties','Properties','',''),
(2,1,1,'Properties','Properties','',''),
(3,11,1,'Properties','Properties','',''),
(4,12,1,'Properties','Properties','',''),
(5,13,1,'Properties','Properties','',''),
(6,14,1,'Properties','Properties','',''),
(7,16,1,'Properties','Properties','',''),
(8,21,1,'Properties','Properties','',''),
(9,28,1,'Properties','Properties','',''),
(10,29,1,'Properties','Properties','',''),
(11,30,1,'Properties','Properties','',''),
(12,31,1,'Properties','Properties','',''),
(13,32,1,'Properties','Properties','',''),
(14,33,1,'Properties','Properties','',''),
(15,34,1,'Properties','Properties','',''),
(16,35,1,'Properties','Properties','',''),
(17,36,1,'Properties','Properties','',''),
(18,37,1,'Properties','Properties','',''),
(19,38,1,'Properties','Properties','',''),
(20,39,1,'Properties','Properties','',''),
(21,40,1,'Properties','Properties','',''),
(22,42,1,'Properties','Properties','',''),
(23,43,1,'Properties','Properties','',''),
(24,44,1,'Properties','Properties','',''),
(25,45,1,'Properties','Properties','',''),
(26,46,1,'Properties','Properties','',''),
(27,47,1,'Properties','Properties','',''),
(28,48,1,'Properties','Properties','',''),
(29,49,1,'Properties','Properties','',''),
(30,50,1,'Properties','Properties','',''),
(31,51,1,'Properties','Properties','',''),
(32,52,1,'Properties','Properties','',''),
(33,53,1,'Properties','Properties','',''),
(34,54,1,'Properties','Properties','',''),
(35,55,1,'Properties','Properties','',''),
(36,56,1,'Properties','Properties','',''),
(37,57,1,'Properties','Properties','',''),
(38,59,1,'Properties','Properties','',''),
(39,61,1,'Properties','Properties','',''),
(40,62,1,'Properties','Properties','',''),
(41,63,1,'Properties','Properties','',''),
(42,64,1,'Properties','Properties','',''),
(43,65,1,'Properties','Properties','',''),
(44,66,1,'Properties','Properties','',''),
(45,67,1,'Properties','Properties','',''),
(46,69,1,'Properties','Properties','',''),
(47,70,1,'Properties','Properties','',''),
(48,71,1,'Properties','Properties','',''),
(49,72,1,'Properties','Properties','',''),
(50,73,1,'Properties','Properties','','');

 insert into ud_entity_tabs (id,entity_id,sorter,name,caption,visible_if_code,enable_if_code) values
(51,74,1,'Properties','Properties','',''),
(52,75,1,'Properties','Properties','',''),
(53,76,1,'Properties','Properties','',''),
(54,77,1,'Properties','Properties','',''),
(55,78,1,'Properties','Properties','',''),
(58,81,1,'Properties','Properties','',''),
(59,82,1,'Properties','Properties','',''),
(60,83,1,'Properties','Properties','',''),
(61,84,1,'Properties','Properties','',''),
(62,85,1,'Properties','Properties','',''),
(63,86,1,'Properties','Properties','',''),
(64,87,1,'Properties','Properties','',''),
(65,89,1,'Properties','Properties','',''),
(66,90,1,'Properties','Properties','',''),
(67,91,1,'Properties','Properties','',''),
(68,92,1,'Properties','Properties','',''),
(69,93,1,'Properties','Properties','',''),
(70,94,1,'Properties','Properties','',''),
(71,95,1,'Properties','Properties','',''),
(72,96,1,'Properties','Properties','',''),
(73,97,1,'Properties','Properties','',''),
(74,98,1,'Properties','Properties','',''),
(75,99,1,'Properties','Properties','',''),
(76,100,1,'Properties','Properties','',''),
(77,101,1,'Properties','Properties','',''),
(78,102,1,'Properties','Properties','',''),
(79,103,1,'Properties','Properties','',''),
(80,104,1,'Properties','Properties','',''),
(81,105,1,'Properties','Properties','',''),
(82,106,1,'Properties','Properties','',''),
(83,107,1,'Properties','Properties','',''),
(84,108,1,'Properties','Properties','',''),
(85,109,1,'Properties','Properties','',''),
(86,110,1,'Properties','Properties','',''),
(87,111,1,'Properties','Properties','',''),
(88,112,1,'Properties','Properties','',''),
(89,113,1,'Properties','Properties','',''),
(90,114,1,'Properties','Properties','',''),
(91,115,1,'Properties','Properties','',''),
(92,116,1,'Properties','Properties','',''),
(93,117,1,'Properties','Properties','',''),
(94,118,1,'Properties','Properties','',''),
(95,120,1,'Properties','Properties','',''),
(96,121,1,'Properties','Properties','',''),
(97,124,1,'Properties','Properties','',''),
(98,125,1,'Properties','Properties','',''),
(99,126,1,'Properties','Properties','',''),
(100,127,1,'Properties','Properties','',''),
(101,142,1,'Properties','Properties','',''),
(102,145,1,'Properties','Properties','','');
(103,147,1,'Properties','Properties','',''),
(104,148,1,'Properties','Properties','',''),
(105,149,1,'Properties','Properties','',''),
(106,151,1,'Properties','Properties','',''),
(107,152,1,'Properties','Properties','',''),
(108,153,1,'Properties','Properties','',''),
(109,154,1,'Properties','Properties','',''),
(110,155,1,'Properties','Properties','',''),
(111,156,1,'Properties','Properties','',''),
(112,157,1,'Properties','Properties','',''),
(113,158,1,'Properties','Properties','',''),
(114,159,1,'Properties','Properties','',''),
(115,160,1,'Properties','Properties','',''),
(116,161,1,'Properties','Properties','',''),
(118,163,1,'Properties','Properties','',''),
(119,164,1,'Properties','Properties','',''),
(120,165,1,'Properties','Properties','',''),
(121,166,1,'Properties','Properties','',''),
(122,167,1,'Properties','Properties','',''),
(123,168,1,'Properties','Properties','',''),
(124,169,1,'Properties','Properties','',''),
(125,170,1,'Properties','Properties','',''),
(126,171,1,'Properties','Properties','',''),
(127,172,1,'Properties','Properties','',''),
(128,173,1,'Properties','Properties','',''),
(129,174,1,'Properties','Properties','',''),
(130,175,1,'Properties','Properties','',''),
(131,176,1,'Properties','Properties','',''),
(133,182,1,'Properties','Propetries','',''),
(134,186,1,'Properties','Properties','',''),
(135,188,1,'Properties','Properties','',''),
(136,187,1,'Properties','Properties','',''),
(137,189,1,'Properties','','',''),
(138,190,1,'Properties','Properties','','');

 -- inserting 2 rows into ud_entity_report

 insert into ud_entity_report (id,entity_id,sorter,name,caption,type,library,link,funct,header,has_preprocessing) values
(1,104,1,'export_rqc','RQC Export','1308','exports','project/Exports','RQC_Export','Project,Ticket ID,Subject,Requested By,Description,Priority,Date Created,Status,Issue Type,Closed Date,Resolution,Duration,Duration [working hours],SLA_Resolution,SLA_Resolution [hours]','Y'),
(2,115,1,'fed_quart_941','Fed Quarterly 941','','payroll','accounting/payroll','fed_quart_941','none','Y');

 -- inserting 17 rows into ud_entity_action

 insert into ud_entity_action (id,entity_id,sorter,name,caption,action_type,action_library,action_category,action_function) values
(2,118,1,'add_transaction','Add Transaction',1313,'transactions','accounting','AddIncomeTransaction'),
(3,114,1,'prepare','Prepare',1309,'payroll','accounting','setupFiscalYear'),
(4,124,1,'calculate_paystub_values','Calculate Paystub Values',1313,'payroll','accounting','createPayStub'),
(5,125,1,'calculate_w2_values','Calculate W2 Values',1313,'payroll','accounting','createW2'),
(6,126,1,'calculate_w3_values','Calculate W3 Values',1313,'payroll','accounting','createW3'),
(7,167,1,'synchronize','Synchronize',1309,'tools','entity_manager','synchronize_entity'),
(9,149,1,'after_insert','After Insert',1313,'users','sport','insert_user'),
(10,148,1,'after_insert_set_club_admin','after_insert_set_club_admin',1313,'users','sport','set_club_admin'),
(11,148,2,'after_update_set_club_admin','after_update_set_club_admin',1314,'users','sport','set_club_admin'),
(12,110,1,'clear_log','Clear Log',1310,'mylog','let','clear_log'),
(13,160,1,'add_campaign_players','Add Players',1313,'campaign','sport','add_default_players'),
(14,161,1,'start_all_players_nopay','Start All Players (No Pay)',1310,'campaign','sport','start_all_players_nopay'),
(15,161,2,'start_all_players_pay','Start All Players (Pay)',1310,'campaign','sport','start_all_players_pay'),
(16,167,2,'sync_selection','Sync Selection',1310,'tools','entity_manager','syncrhonize_selection'),
(17,12,1,'US_FL_Broward_FindSales','Get Broward Sales',1310,'US_FL_Broward','realestate','getLastSales'),
(18,12,2,'generate_mail_welcome','Create Welcome Letter',1310,'reports','crm','create_welcome_letter'),
(19,12,3,'mark_as_contacted','Mark as Contacted',1310,'statuses','crm','mark_as_contacted');

 -- inserting 135 rows into ud_entity

 insert into ud_entity (id,name) values
(1,'Inv - Unit Types'),
(11,'ORG - Organization Types'),
(12,'ORG - Organizations'),
(13,'PRJ - Projects'),
(14,'Security - App Categories'),
(16,'Security - Roles'),
(21,'Materials'),
(28,'PRJ - Project Resource Types'),
(29,'PRJ - Project Phase Resources'),
(30,'Security - User'),
(31,'CORE - Workflow'),
(32,'CORE - Workflow Step'),
(33,'Inv - Material Types'),
(34,'PRJ - Project Phase Timesheet'),
(35,'Admin - Settings'),
(36,'LIMS_TestCategory'),
(37,'LIMS_Test'),
(38,'LIMS_Method'),
(39,'Inv - Material'),
(40,'Inv - Unit'),
(42,'Locations'),
(43,'Groups'),
(44,'LIMS_Equip_Type'),
(45,'Admin - LookupTypes'),
(46,'Admin - LookupValues'),
(47,'LIMS_Test_Allocation'),
(48,'LIMS_Test_Spec'),
(49,'LIMS_Test_Spec_Limits'),
(50,'LIMS_Template_Type'),
(51,'LIMS_Template'),
(52,'LIMS_Template_CollectionPoints'),
(53,'LIMS_Template_CollTests'),
(54,'LIMS_Template_CollTests_Alloc'),
(55,'LIMS_dy_TankAnalysis_Login'),
(56,'Security - App Links'),
(57,'CORE - Indexes'),
(59,'PRJ - Project Phases'),
(61,'LIMS_dy_sample'),
(62,'LIMS_dy_test'),
(63,'CORE - Workflow Step Action'),
(64,'CORE - Company'),
(65,'PRJ - Project Phase Issues'),
(66,'Contacts'),
(67,'ORG - Accounts'),
(69,'Access - Items'),
(70,'Access - Accounts'),
(71,'Access - Category'),
(72,'Access - Subcategory'),
(73,'Accounting - Expense Types'),
(74,'Accounting - Expense SubTypes');

 insert into ud_entity (id,name) values
(75,'Accounting - Bank Accounts'),
(76,'Accounting - Expenses'),
(77,'Accounting - Currencies'),
(78,'Training'),
(81,'Home - About Us'),
(82,'Home - Carousel'),
(83,'Home - Services'),
(84,'Home - News'),
(85,'Core - Background Services'),
(86,'Travel - Campgrounds'),
(87,'Travel - Campsite Search'),
(89,'PRJ - My Project Phases'),
(90,'PRJ - Project My Phases'),
(91,'PRJ - PRoject Phase Invoices'),
(92,'Wizzard'),
(93,'Wizzard Page'),
(94,'Wizzard Page Entity'),
(95,'PRJ - Project Phase Timesheet - My'),
(96,'PRJ - Project Phase Support Tickets'),
(97,'PRJ - Project Phase Issues - My'),
(98,'PRJ - Project Support Types'),
(99,'PRJ - Project Calendar'),
(100,'PRJ - Project Calendar Holidays'),
(101,'PRJ - Project Issue Types'),
(102,'DOC - Document Templates'),
(103,'DOC - Document Template Versions'),
(104,'PRJ - Project Phase Support Tickets - My'),
(105,'Investment Type'),
(106,'Accounting - Employees'),
(107,'Accounting - Employees Salary'),
(108,'CORE - Workflow Step Emails'),
(109,'CORE - Workflow Admins'),
(110,'CORE - Logs'),
(111,'PRJ - Project Invoices  - My'),
(112,'PRJ - Project Support Times'),
(113,'PRJ - Project Calendar Week'),
(114,'Accounting - Fiscal Year'),
(115,'Accounting - Payroll'),
(116,'Travel - Trip'),
(117,'Travel - Trip Drive'),
(118,'Accounting - Income'),
(120,'Accounting - Payments'),
(121,'Accounting - Transactions'),
(123,'Accounting - Settings'),
(124,'Accounting - Paystub'),
(125,'Accounting - W2'),
(126,'Accounting - W3'),
(127,'ORG - Organizations Admins'),
(142,'Team'),
(145,'Event');
(147,'Team Players'),
(148,'Club'),
(149,'Club Users'),
(151,'Club Management'),
(152,'Club Locations'),
(153,'Event Types'),
(154,'Player Positions'),
(155,'Games'),
(156,'Venues'),
(157,'My Teams'),
(158,'Club User Parents'),
(159,'My Team Games'),
(160,'Team Campaign'),
(161,'Team Campaing Player'),
(163,'Wizzard Type'),
(164,'DOC - Template Section'),
(165,'entity_tabs'),
(166,'entity_sections'),
(167,'CORE - Entity'),
(168,'CORE - Entity Modules'),
(169,'CORE - Entity Fields'),
(170,'CORE - Entity Children'),
(171,'CORE - Entity Dashboard'),
(172,'CORE - Entity Reports'),
(173,'CORE - Entity Action'),
(174,'CORE - Entity Multi Choices'),
(175,'black_listed_ips'),
(176,'security_login_attempts'),
(181,'Home Settings'),
(182,'Stories'),
(186,'Modules Categories'),
(187,'Modules Pricing'),
(188,'Module Available'),
(189,'Company Modules'),
(190,'Admin Users');