CREATE TABLE `vwkpi_average_productivity` (
`prjmon_year` int(10) unsigned NULL DEFAULT '2015',
`quarter_id` int(10) unsigned NULL DEFAULT '1',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`prjmon_average_productivity` decimal(65,0) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwkpi_jos_generated` (
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_year` int(10) unsigned NULL DEFAULT '2015',
`quarter_id` int(10) unsigned NULL DEFAULT '1',
`job_count` decimal(45,0) NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`ug_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwkpi_rndagenda_formulated` (
`rndagenda_formulated` int(10) unsigned NULL DEFAULT '0',
`rndagenda_date` date NULL DEFAULT NULL,
`rndagenda_year` int(4) unsigned NULL DEFAULT NULL,
`rndagenda_month` int(2) NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwkpi_rndprj` (
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`rndprj_date` date NULL DEFAULT NULL,
`rndprj_year` int(4) unsigned NULL DEFAULT NULL,
`rndprj_month` int(2) NULL DEFAULT NULL,
`rndprj_implemented` tinyint(1) unsigned NULL DEFAULT '0',
`rndsec_id` bigint(20) unsigned NULL DEFAULT '0',
`rndprj_endorsed` tinyint(1) unsigned NULL DEFAULT '0',
`rndprj_evaluated` tinyint(1) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwkpi_technology_adaptors` (
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat1_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`adopt_date` date NULL DEFAULT NULL,
`adopt_year` int(4) unsigned NULL DEFAULT NULL,
`adopt_month` int(2) NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpki_production_generated` (
`production_gross` decimal(65,3) unsigned NULL DEFAULT '0.000',
`production_volume` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_year` int(10) unsigned NULL DEFAULT '2015',
`quarter_id` int(10) unsigned NULL DEFAULT '1',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`ug_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_activities` (
`activity_id` bigint(20) unsigned NULL DEFAULT '0',
`activity_type_id` bigint(20) unsigned NULL DEFAULT '0',
`activity_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`activity_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`activity_target_date` date NULL DEFAULT NULL,
`activity_date_accomplished` date NULL DEFAULT NULL,
`activity_date_accomplished_yr` int(4) unsigned NULL DEFAULT NULL,
`activity_date_accomplished_mo` int(2) NULL DEFAULT NULL,
`activity_year` int(4) unsigned NULL DEFAULT NULL,
`activity_month` int(2) NULL DEFAULT NULL,
`activity_csf` double unsigned NULL DEFAULT '0',
`activity_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`activity_no_participants` int(10) unsigned NULL DEFAULT '0',
`activity_no_male` int(10) unsigned NULL DEFAULT '0',
`activity_no_female` int(10) unsigned NULL DEFAULT '0',
`activity_no_pwd` int(10) unsigned NULL DEFAULT '0',
`activity_no_senior` int(10) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`activity_no_articles` bigint(20) unsigned NULL DEFAULT '1',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`activity_longitude` double unsigned NULL DEFAULT '0',
`activity_latitude` double unsigned NULL DEFAULT '0',
`activity_elevation` double unsigned NULL DEFAULT '0',
`activity_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`activity_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_agencies` (
`agency_id` bigint(20) unsigned NULL DEFAULT '0',
`agency_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_acronym` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`agency_contact` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_website` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`agency_longitude` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '121.223697066307',
`agency_latitude` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '14.1722468782053',
`agency_gmap_key` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT 'AIzaSyCMDx-ejfVStxIBhfqtBuLj98OV79kqbdY',
`agency_fb_appid` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '1685702521726852',
`agency_region_id` bigint(20) unsigned NULL DEFAULT '6',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` date NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`last_updated` date NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_calibrations` (
`cal_id` bigint(20) unsigned NULL DEFAULT '0',
`cal_month` int(10) unsigned NULL DEFAULT '0',
`cal_year` int(10) unsigned NULL DEFAULT '0',
`cal_no_tests` int(10) unsigned NULL DEFAULT '0',
`cal_no_tests_paid` int(10) unsigned NULL DEFAULT '0',
`cal_no_tests_free` int(10) unsigned NULL DEFAULT '0',
`cal_no_calibrations` int(10) unsigned NULL DEFAULT '0',
`cal_no_tests_received` int(11) unsigned NULL DEFAULT '0',
`cal_petrochemical_in` int(10) unsigned NULL DEFAULT '0',
`cal_calibration_in` int(10) unsigned NULL DEFAULT '0',
`cal_halal_in` int(10) unsigned NULL DEFAULT '0',
`cal_no_tests_referred` int(11) NULL DEFAULT '0',
`cal_petrochemical_referred` int(10) unsigned NULL DEFAULT '0',
`cal_calibration_referred` int(10) unsigned NULL DEFAULT '0',
`cal_halal_referred` int(10) unsigned NULL DEFAULT '0',
`cal_no_tests_sent` int(10) unsigned NULL DEFAULT '0',
`cal_no_clients` int(10) unsigned NULL DEFAULT '0',
`cal_no_clients_free` int(10) unsigned NULL DEFAULT '0',
`cal_no_firms` int(10) unsigned NULL DEFAULT '0',
`cal_no_tests_on_time` int(10) unsigned NULL DEFAULT '0',
`cal_no_additional_members` int(11) unsigned NULL DEFAULT '0',
`cal_passed_test_parameters` int(11) unsigned NULL DEFAULT '0',
`cal_passed_profeciency_certification` int(11) unsigned NULL DEFAULT '0',
`cal_income` decimal(65,3) unsigned NULL DEFAULT '0.000',
`cal_income_gross` decimal(65,3) unsigned NULL DEFAULT '0.000',
`cal_value_service` decimal(65,3) unsigned NULL DEFAULT '0.000',
`cal_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`lab_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`lab_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`lab_abbr` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_cities` (
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_id` bigint(20) unsigned NULL DEFAULT '0',
`district_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '0',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_collaborators` (
`col_id` bigint(20) unsigned NULL DEFAULT '0',
`col_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`col_abbr` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`col_listname` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ot_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_consultancies` (
`con_id` bigint(20) unsigned NULL DEFAULT '0',
`con_start` date NULL DEFAULT NULL,
`con_end` date NULL DEFAULT NULL,
`con_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`con_start_yr` int(4) unsigned NULL DEFAULT NULL,
`con_start_mo` int(2) NULL DEFAULT NULL,
`con_end_yr` int(4) unsigned NULL DEFAULT NULL,
`con_end_mo` int(2) NULL DEFAULT NULL,
`con_type_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`sp_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`con_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`coop_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_fax` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_website` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_year_established` int(10) unsigned NULL DEFAULT '0',
`sp_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_other_service` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_designation` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_contact_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_expertise` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_product_line` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_website` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_dti` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_sec` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_reg_cda` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_dti_date` date NULL DEFAULT NULL,
`coop_reg_sec_date` date NULL DEFAULT NULL,
`coop_reg_cda_date` date NULL DEFAULT NULL,
`coop_products` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_brief` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ot_cat1_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat3_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat2_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat1_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ot_cat2_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ot_cat3_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`con_no_participants` int(10) unsigned NULL DEFAULT '0',
`con_no_firms` int(10) unsigned NULL DEFAULT '0',
`con_no_po` int(10) unsigned NULL DEFAULT '0',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_coop_sector_list` (
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_list` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_cooperator_project_counts` (
`coop_count` bigint(21) NULL DEFAULT '0',
`coop_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_cooperator_projects` (
`prj_ben_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_year_approved` int(10) unsigned NULL DEFAULT '2015',
`prj_objective` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_expected_output` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_product_line` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_cost_setup` double unsigned NULL DEFAULT '0',
`prj_cost_nga` double unsigned NULL DEFAULT '0',
`prj_cost_lgu` double unsigned NULL DEFAULT '0',
`prj_cost_external` double unsigned NULL DEFAULT '0',
`prj_cost_local` double unsigned NULL DEFAULT '0',
`prj_cost_benefactor` double unsigned NULL DEFAULT '0',
`prj_cost_other` double unsigned NULL DEFAULT '0',
`prj_intervention` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_longitude` double unsigned NULL DEFAULT '0',
`prj_latitude` double unsigned NULL DEFAULT '0',
`prj_elevation` double unsigned NULL DEFAULT '0',
`prj_type_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_status_id` bigint(20) unsigned NULL DEFAULT '0',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`prj_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_status_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_sector_list` mediumtext CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`barangay_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_duration_from` date NULL DEFAULT NULL,
`prj_duration_to` date NULL DEFAULT NULL,
`prj_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_cost_benefactor_desc` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_fundingsource_local` tinyint(1) unsigned NULL DEFAULT '0',
`prj_fundingsource_external` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cofunded_lgu` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cofunded_nga` tinyint(1) unsigned NULL DEFAULT '0',
`district_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`prj_startup_assistance` tinyint(1) unsigned NULL DEFAULT '0',
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_fund_release_date` date NULL DEFAULT NULL,
`prj_refund_period_from` date NULL DEFAULT NULL,
`prj_refund_period_to` date NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_cooperators` (
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_p_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_brief` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_fax` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_gender` tinyint(1) unsigned NULL DEFAULT '0',
`coop_p_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_position` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_products` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_reg_cda` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_cda_date` date NULL DEFAULT NULL,
`coop_reg_dti` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_dti_date` date NULL DEFAULT NULL,
`coop_reg_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_reg_sec` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_sec_date` date NULL DEFAULT NULL,
`coop_website` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_year_established` int(10) unsigned NULL DEFAULT '0',
`ot_cat1_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat2_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat3_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat1_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ot_cat2_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ot_cat3_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_sector_list` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_courses` (
`course_id` bigint(20) unsigned NULL DEFAULT '0',
`course_cat_id` bigint(20) unsigned NULL DEFAULT '0',
`course_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`course_yearcount` int(11) unsigned NULL DEFAULT '4',
`course_cat_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`course_label` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_csf_ratings` (
`csrat_id` bigint(20) unsigned NULL DEFAULT '0',
`csrat_date` date NULL DEFAULT NULL,
`csrat_year` int(4) unsigned NULL DEFAULT NULL,
`csrat_month` int(2) NULL DEFAULT NULL,
`csrat_no_customers` int(10) unsigned NULL DEFAULT '0',
`csrat_rating` int(11) NULL DEFAULT '0',
`csrat_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`csrat_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`csrat_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_deferment_monthcounts` (
`rep_deferment_monthcount` decimal(32,0) NULL DEFAULT NULL,
`rep_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_drrm` (
`drrm_id` bigint(20) unsigned NULL DEFAULT '0',
`drrm_date` date NULL DEFAULT NULL,
`drrm_year` int(4) unsigned NULL DEFAULT NULL,
`drrm_month` int(2) NULL DEFAULT NULL,
`drrm_installed` int(10) unsigned NULL DEFAULT '0',
`drrm_maintained` int(10) unsigned NULL DEFAULT '0',
`drrm_activities` int(10) unsigned NULL DEFAULT '0',
`drrm_devices` int(10) unsigned NULL DEFAULT '0',
`drrm_iec` int(10) unsigned NULL DEFAULT '0',
`drrm_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`last_updated` datetime NULL DEFAULT NULL,
`drrm_collaborations` int(10) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_equipment` (
`eqp_id` bigint(20) unsigned NULL DEFAULT '0',
`eqp_specs` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`eqp_qty` int(10) unsigned NULL DEFAULT '0',
`eqp_amount_acquired` decimal(65,3) unsigned NULL DEFAULT '0.000',
`eqp_amount_approved` decimal(65,3) unsigned NULL DEFAULT '0.000',
`eqp_property_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`eqp_receipt_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`eqp_receipt_date` date NULL DEFAULT NULL,
`eqp_warranty` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`eqp_date_acquired` date NULL DEFAULT NULL,
`eqp_date_tagged` date NULL DEFAULT NULL,
`eqp_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`brand_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`sp_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`brand_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_other_service` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_designation` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_contact_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_expertise` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_product_line` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_website` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`imp_id` bigint(20) unsigned NULL DEFAULT '0',
`imp_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_fora` (
`fr_id` bigint(20) unsigned NULL DEFAULT '0',
`fr_requesting_party` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`fr_title` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`fr_sectors` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`fr_start` datetime NULL DEFAULT NULL,
`fr_end` datetime NULL DEFAULT NULL,
`fr_duration` double unsigned NULL DEFAULT '0',
`fr_location` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`fr_longitude` double unsigned NULL DEFAULT '0',
`fr_latitude` double unsigned NULL DEFAULT '0',
`fr_elevation` double unsigned NULL DEFAULT '0',
`fr_cost` double unsigned NULL DEFAULT '0',
`fr_csf` double unsigned NULL DEFAULT '0',
`fr_no_feminine` int(10) unsigned NULL DEFAULT '0',
`fr_no_masculine` int(10) unsigned NULL DEFAULT '0',
`fr_no_pwd` int(10) unsigned NULL DEFAULT '0',
`fr_no_seniors` int(10) unsigned NULL DEFAULT '0',
`fr_no_firms` int(10) unsigned NULL DEFAULT '0',
`fr_type_id` bigint(20) unsigned NULL DEFAULT '0',
`fr_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`fr_no_po` int(10) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`sp_id` bigint(20) unsigned NULL DEFAULT '0',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`fr_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`collaborator_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_year_approved` int(10) unsigned NULL DEFAULT '2015',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`fr_start_yr` int(4) unsigned NULL DEFAULT NULL,
`fr_start_mo` int(2) NULL DEFAULT NULL,
`fr_end_yr` int(4) unsigned NULL DEFAULT NULL,
`fr_end_mo` int(2) NULL DEFAULT NULL,
`fr_no_participants` bigint(11) unsigned NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_fora_collaborators` (
`fr_id` bigint(20) unsigned NULL DEFAULT '0',
`collaborator_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_fora_count_per_type` (
`fr_count_total` decimal(42,0) NULL DEFAULT NULL,
`fr_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_fora_count_per_year` (
`fr_count_total` decimal(42,0) NULL DEFAULT NULL,
`fr_year` int(4) unsigned NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_fora_documents` (
`frdoc_id` bigint(20) unsigned NULL DEFAULT '0',
`frdoc_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`frdoc_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`frdoc_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`fdoctype_id` bigint(20) unsigned NULL DEFAULT '0',
`fr_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`last_updated` datetime NULL DEFAULT NULL,
`fdoctype_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_innovation_hubs` (
`hub_id` bigint(20) unsigned NULL DEFAULT '0',
`hub_date` date NULL DEFAULT NULL,
`hub_year` int(4) unsigned NULL DEFAULT NULL,
`hub_month` int(2) NULL DEFAULT NULL,
`hub_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`hub_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`hub_longitude` double NULL DEFAULT '0',
`hub_latitude` double NULL DEFAULT '0',
`hub_elevation` double NULL DEFAULT '0',
`hub_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`hubt_id` bigint(20) unsigned NULL DEFAULT '0',
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`hubt_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`barangay_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_international_collaborations` (
`intc_id` bigint(20) unsigned NULL DEFAULT '0',
`intc_date` date NULL DEFAULT NULL,
`intc_year` int(4) unsigned NULL DEFAULT NULL,
`intc_month` int(2) NULL DEFAULT NULL,
`intc_description` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`intc_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_iso` (
`iso_id` bigint(20) unsigned NULL DEFAULT '0',
`iso_date` date NULL DEFAULT NULL,
`iso_year` int(4) unsigned NULL DEFAULT NULL,
`iso_month` int(2) NULL DEFAULT NULL,
`iso_maintained` tinyint(3) unsigned NULL DEFAULT NULL,
`iso_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`last_updated` datetime NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_kpi_pstc_total_targets` (
`kpitar_year` int(4) unsigned NULL DEFAULT NULL,
`kpitar_total_q1` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_q2` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_q3` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_q4` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_targets` decimal(35,0) NULL DEFAULT NULL,
`kpiind_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`kpitar_for` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_kpi_total_targets` (
`kpitar_year` int(4) unsigned NULL DEFAULT NULL,
`kpitar_total_q1` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_q2` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_q3` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_q4` decimal(32,0) NULL DEFAULT NULL,
`kpitar_total_targets` decimal(35,0) NULL DEFAULT NULL,
`kpiind_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_liquidation` (
`liq_id` bigint(20) unsigned NULL DEFAULT '0',
`liq_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`liq_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`liq_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`liqtype_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`liqtype_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_locations` (
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_id` bigint(20) unsigned NULL DEFAULT '0',
`district_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_num_users` (
`num_users` bigint(21) NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_otb_payments` (
`rep_otb_amount_paid` decimal(65,3) NULL DEFAULT NULL,
`rep_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_packaging` (
`pkg_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`pkg_date` date NULL DEFAULT NULL,
`pkg_year` int(4) unsigned NULL DEFAULT NULL,
`pkg_month` int(2) NULL DEFAULT NULL,
`pkg_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`pkg_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_product_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_brand_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_product_description` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_competitors` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_competitor_1` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_competitor_2` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_competitor_3` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_competitor_4` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_competitor_5` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_competitor_6` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_selling_point` tinyint(1) unsigned NULL DEFAULT '0',
`pkg_selling_point_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_performance` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_distribution` tinyint(1) unsigned NULL DEFAULT '0',
`pkg_ingredients` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_volume` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_packaging_material` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_label_size` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_preferred_colors` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_other_details` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_market_location` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`pkg_market_products_sold` bigint(20) unsigned NULL DEFAULT '0',
`pkg_market_date_established` date NULL DEFAULT NULL,
`pkg_sales_before_intervention` double unsigned NULL DEFAULT '0',
`pkg_sales_after_intervention` double unsigned NULL DEFAULT '0',
`pkg_sales_increase` double NULL DEFAULT NULL,
`pkg_employment_after_direct` bigint(20) unsigned NULL DEFAULT '0',
`pkg_employment_after_indirect` bigint(20) unsigned NULL DEFAULT '0',
`pkg_employment_after_months_employed` bigint(20) unsigned NULL DEFAULT '0',
`pkg_avg_productivity_improvement` double unsigned NULL DEFAULT '0',
`pkg_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pkg_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`pkg_no_new_markets` int(10) unsigned NULL DEFAULT '0',
`coop_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_label` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`dist_label` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`sync_date` datetime NULL DEFAULT NULL,
`synched` tinyint(1) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_packaging_designs` (
`design_id` bigint(20) unsigned NULL DEFAULT '0',
`design_date` datetime NULL DEFAULT NULL,
`design_description` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`draftlevel_id` bigint(20) unsigned NULL DEFAULT '1',
`pkg_id` bigint(20) unsigned NULL DEFAULT '0',
`design_image1` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`design_image2` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`design_filename1` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`design_filename2` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`draftlevel_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_projecttype` (
`prj_type_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_province` (
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_region` (
`region_id` int(11) NULL DEFAULT '0',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_sector` (
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_sector_no_empty` (
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_status` (
`prj_status_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_status_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_year_approved` (
`prj_year_approved` int(10) unsigned NULL DEFAULT '2015',
`prj_count` bigint(21) NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_prjcount_per_year_per_type` (
`prj_year_approved` int(10) unsigned NULL DEFAULT '2015',
`prj_count` bigint(21) NULL DEFAULT '0',
`prj_type_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_production_gross` (
`Sum_production_gross` decimal(65,3) NULL DEFAULT NULL,
`prjmon_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_products` (
`prod_id` bigint(20) unsigned NULL DEFAULT '0',
`prod_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prod_unit` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`unit_id` int(10) unsigned NULL DEFAULT '1',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`unit_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_beneficiaries` (
`prj_ben_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_p_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_fax` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_website` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_year_established` int(10) unsigned NULL DEFAULT '0',
`coop_reg_dti` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_sec` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_cda` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`coop_reg_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_reg_dti_date` date NULL DEFAULT NULL,
`coop_reg_sec_date` date NULL DEFAULT NULL,
`coop_reg_cda_date` date NULL DEFAULT NULL,
`coop_products` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_brief` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ot_cat1_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat2_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat3_id` bigint(20) unsigned NULL DEFAULT '0',
`ot_cat1_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ot_cat2_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ot_cat3_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_beneficiaries_list` (
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_p_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_calibrations` (
`cal_id` bigint(20) unsigned NULL DEFAULT '0',
`cal_month` int(10) unsigned NULL DEFAULT '0',
`cal_year` int(10) unsigned NULL DEFAULT '0',
`cal_no_parameters` int(10) unsigned NULL DEFAULT '0',
`cal_parameters` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`cal_no_tests_free` bigint(20) unsigned NULL DEFAULT '0',
`cal_no_products` int(10) unsigned NULL DEFAULT '0',
`cal_products` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`cal_income` decimal(65,3) unsigned NULL DEFAULT '0.000',
`cal_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`cal_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`lab_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`lab_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`lab_abbr` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_collaborators` (
`prj_col_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`col_id` bigint(20) unsigned NULL DEFAULT '0',
`col_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`col_abbr` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_collaborators_list` (
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`collaborator_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_cost_per_province` (
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_cost_total` double NULL DEFAULT '0',
`prj_cost_benefactor_total` double NULL DEFAULT '0',
`prj_cost_other_total` double NULL DEFAULT '0',
`prj_cost_nga_total` double NULL DEFAULT '0',
`prj_cost_lgu_total` double NULL DEFAULT '0',
`prj_cost_local_total` double NULL DEFAULT '0',
`prj_cost_external_total` double NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_cost_per_sector` (
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_cost_total` double NULL DEFAULT '0',
`prj_cost_benefactor_total` double NULL DEFAULT '0',
`prj_cost_other_total` double NULL DEFAULT '0',
`prj_cost_nga_total` double NULL DEFAULT '0',
`prj_cost_lgu_total` double NULL DEFAULT '0',
`prj_cost_local_total` double NULL DEFAULT '0',
`prj_cost_external_total` double NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_documents` (
`doc_id` bigint(20) unsigned NULL DEFAULT '0',
`doc_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`doc_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`doc_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`doctype_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`doctype_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_equipments` (
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`brand_id` bigint(20) unsigned NULL DEFAULT '0',
`brand_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_monitoring` (
`prjmon_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_year` int(10) unsigned NULL DEFAULT '2015',
`quarter_id` int(10) unsigned NULL DEFAULT '1',
`prjmon_total_assets_land` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_assets_building` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_assets_equipment` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_assets_working_capital` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_employment` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_volume_production_local` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_volume_production_export` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_gross_sales_local` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_gross_sales_export` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_countries_of_destination` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_assistance_process` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_equipment` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_quality_control` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_packaging_labeling` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_post_harvest` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_marketing` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_training` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_assistance_consultancy` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_assistance_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_problems_met` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_actions_taken` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_action_plan` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_status_of_funds` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_reasons_for_termination` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_final_obligation` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_impact_of_intervention` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_final_recommendation` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_expected_output` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_actual_accomplishment` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_output_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_liquidation_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_liquidation_used` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_liquidation_date` date NULL DEFAULT NULL,
`prjmon_liquidation_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_refund_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_schedule_from` date NULL DEFAULT NULL,
`prjmon_refund_schedule_to` date NULL DEFAULT NULL,
`prjmon_refund_amount_due` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_date` date NULL DEFAULT NULL,
`prjmon_refund_refunded` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_unsettled` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_delay_date` date NULL DEFAULT NULL,
`prjmon_setup_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_funds_release_date` date NULL DEFAULT NULL,
`prjmon_refund_period_from` date NULL DEFAULT NULL,
`prjmon_refund_period_to` date NULL DEFAULT NULL,
`prjmon_termination_date` date NULL DEFAULT NULL,
`prjmon_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_effectivity` date NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`prjform_id` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_volume_product_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prjmon_volume_of_production` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_volume_gross_sales` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_emp_total` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_pwd` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_senior` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_total` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_pwd` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_senior` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_forward_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_forward_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_backward_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_backward_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_market_existing` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_market_new` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_production_efficiency` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_production_actual_accomplishment` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_production_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`quarter_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prjform_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prjmon_gross_sales` decimal(65,3) NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_monitoring_summary` (
`prjmon_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_year` int(10) unsigned NULL DEFAULT '2015',
`quarter_id` int(10) unsigned NULL DEFAULT '1',
`prjmon_total_assets_land` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_assets_building` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_assets_equipment` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_assets_working_capital` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_total_employment` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_ch_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_dir_sh_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_backward_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_male` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_female` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_pwd` int(10) unsigned NULL DEFAULT '0',
`prjmon_indir_forward_senior` int(10) unsigned NULL DEFAULT '0',
`prjmon_volume_production_local` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_volume_production_export` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_gross_sales_local` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_gross_sales_export` decimal(65,3) NULL DEFAULT '0.000',
`prjmon_countries_of_destination` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_assistance_process` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_equipment` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_quality_control` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_packaging_labeling` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_post_harvest` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_marketing` tinyint(1) unsigned NULL DEFAULT '0',
`prjmon_assistance_training` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_assistance_consultancy` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_assistance_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_problems_met` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_actions_taken` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_action_plan` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_status_of_funds` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_reasons_for_termination` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_final_obligation` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_impact_of_intervention` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_final_recommendation` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_expected_output` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_actual_accomplishment` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_output_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_liquidation_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_liquidation_used` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_liquidation_date` date NULL DEFAULT NULL,
`prjmon_liquidation_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_refund_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_schedule_from` date NULL DEFAULT NULL,
`prjmon_refund_schedule_to` date NULL DEFAULT NULL,
`prjmon_refund_amount_due` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_date` date NULL DEFAULT NULL,
`prjmon_refund_refunded` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_unsettled` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_refund_delay_date` date NULL DEFAULT NULL,
`prjmon_setup_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_funds_release_date` date NULL DEFAULT NULL,
`prjmon_refund_period_from` date NULL DEFAULT NULL,
`prjmon_refund_period_to` date NULL DEFAULT NULL,
`prjmon_termination_date` date NULL DEFAULT NULL,
`prjmon_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_effectivity` date NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`prjform_id` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_volume_product_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prjmon_volume_of_production` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_volume_gross_sales` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjmon_emp_total` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_pwd` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_forward_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_forward_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_backward_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_indirect_backward_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_market_existing` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_market_new` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_production_efficiency` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`quarter_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prjform_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_year_approved` int(10) unsigned NULL DEFAULT '2015',
`prj_objective` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_expected_output` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_product_line` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_cost_setup` double unsigned NULL DEFAULT '0',
`prj_cost_benefactor` double unsigned NULL DEFAULT '0',
`prj_cost_other` double unsigned NULL DEFAULT '0',
`prj_intervention` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_longitude` double unsigned NULL DEFAULT '0',
`prj_latitude` double unsigned NULL DEFAULT '0',
`prj_elevation` double unsigned NULL DEFAULT '0',
`prj_type_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_status_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ru_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_fund_release_date` date NULL DEFAULT NULL,
`prj_refund_period_from` date NULL DEFAULT NULL,
`prj_refund_period_to` date NULL DEFAULT NULL,
`prj_province` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_city` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_barangay` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_pis_total_assets_land` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_assets_building` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_assets_equipment` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_assets_working_capital` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_employment` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_volume_production_local` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_volume_production_export` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_gross_sales_local` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_gross_sales_export` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_countries_of_destination` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_conceptualization` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_proposal_preparation` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_process` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_equipment` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_quality_control` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_packaging_labeling` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_post_harvest` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_marketing` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_training` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_consultancy` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_id` bigint(20) unsigned NULL DEFAULT '0',
`district_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`barangay_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_status_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_total_amount` decimal(65,3) unsigned NULL DEFAULT NULL,
`rep_refund_rate` decimal(65,7) NULL DEFAULT NULL,
`rep_total_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_paid` decimal(65,3) NULL DEFAULT '0.000',
`sector_list` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_sector_list` mediumtext CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_p_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`collaborator_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_duration_from` date NULL DEFAULT NULL,
`prj_duration_to` date NULL DEFAULT NULL,
`prj_fundingsource_local` tinyint(1) unsigned NULL DEFAULT '0',
`prj_fundingsource_external` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cofunded_nga` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cofunded_lgu` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cost_nga` double unsigned NULL DEFAULT '0',
`prj_cost_lgu` double unsigned NULL DEFAULT '0',
`prj_cost_local` double unsigned NULL DEFAULT '0',
`prj_cost_external` double unsigned NULL DEFAULT '0',
`prj_cost_benefactor_desc` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_startup_assistance` tinyint(1) unsigned NULL DEFAULT '0',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_production_actual_accomplishment` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_improvement_production_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjmon_emp_senior` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_total` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_male` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_female` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_pwd` bigint(20) unsigned NULL DEFAULT '0',
`prjmon_emp_in_senior` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_pis` (
`prjpis_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`prjpis_year` int(10) unsigned NULL DEFAULT '2017',
`sem_id` bigint(20) unsigned NULL DEFAULT '1',
`prjpis_total_assets_land` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjpis_total_assets_building` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjpis_total_assets_equipment` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjpis_total_assets_working_capital` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prjpis_total_employment` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_regular_male` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_regular_female` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_ch_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_regular_male` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_regular_female` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prjpis_dir_sh_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_backward_male` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_backward_female` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_backward_pwd` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_backward_senior` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_forward_male` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_forward_female` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_forward_pwd` int(10) unsigned NULL DEFAULT '0',
`prjpis_indir_forward_senior` int(10) unsigned NULL DEFAULT '0',
`prjpis_volume_production_local` decimal(65,3) NULL DEFAULT '0.000',
`prjpis_volume_production_export` decimal(65,3) NULL DEFAULT '0.000',
`prjpis_gross_sales_local` decimal(65,3) NULL DEFAULT '0.000',
`prjpis_gross_sales_export` decimal(65,3) NULL DEFAULT '0.000',
`prjpis_countries_of_destination` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_assistance_process` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_equipment` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_quality_control` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_packaging_labeling` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_post_harvest` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_marketing` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_training_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_assistance_consultancy_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_assistance_others_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`prjpis_assistance_training` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_consultancy` tinyint(1) unsigned NULL DEFAULT '0',
`prjpis_assistance_process_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_assistance_quality_control_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_assistance_post_harvest_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_assistance_marketing_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prjpis_assistance_others` tinyint(1) unsigned NULL DEFAULT '0',
`sem_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_sats` (
`sat_id` bigint(20) unsigned NULL DEFAULT '0',
`sat_date` date NULL DEFAULT NULL,
`sat_year` int(4) unsigned NULL DEFAULT NULL,
`sat_month` int(2) NULL DEFAULT NULL,
`sat_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sat_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sat_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`satt_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`satt_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_sector_list` (
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_list` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_sectors` (
`prjsect_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_sites` (
`prj_site_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_site_date` date NULL DEFAULT NULL,
`prj_site_yr` int(4) unsigned NULL DEFAULT NULL,
`prj_site_mo` int(2) NULL DEFAULT NULL,
`prj_site_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_site_longitude` double NULL DEFAULT '0',
`prj_site_latitude` double NULL DEFAULT '0',
`prj_site_elevation` double NULL DEFAULT '0',
`prj_site_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`brand_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`brand_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_id` bigint(20) unsigned NULL DEFAULT '0',
`district_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`barangay_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_project_videos` (
`vid_id` bigint(20) unsigned NULL DEFAULT '0',
`vid_date` date NULL DEFAULT NULL,
`vid_year` int(4) unsigned NULL DEFAULT NULL,
`vid_month` int(2) NULL DEFAULT NULL,
`vid_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`vid_file` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`vid_filename` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`vid_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_projects` (
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_year_approved` int(10) unsigned NULL DEFAULT '2015',
`prj_duration_from` date NULL DEFAULT NULL,
`prj_duration_to` date NULL DEFAULT NULL,
`prj_objective` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_expected_output` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_product_line` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_cost_setup` double unsigned NULL DEFAULT '0',
`prj_cost_benefactor` double unsigned NULL DEFAULT '0',
`prj_cost_other` double unsigned NULL DEFAULT '0',
`prj_intervention` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_longitude` double unsigned NULL DEFAULT '0',
`prj_latitude` double unsigned NULL DEFAULT '0',
`prj_elevation` double unsigned NULL DEFAULT '0',
`prj_type_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_status_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ru_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`prj_fund_release_date` date NULL DEFAULT NULL,
`prj_refund_period_from` date NULL DEFAULT NULL,
`prj_refund_period_to` date NULL DEFAULT NULL,
`prj_province` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_city` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_barangay` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_pis_total_assets_land` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_assets_building` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_assets_equipment` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_assets_working_capital` decimal(65,3) unsigned NULL DEFAULT '0.000',
`prj_pis_total_employment` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_ch_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_regular_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_dir_sh_part_time_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_backward_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_male` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_female` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_pwd` int(10) unsigned NULL DEFAULT '0',
`prj_pis_indir_forward_senior` int(10) unsigned NULL DEFAULT '0',
`prj_pis_volume_production_local` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_volume_production_export` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_gross_sales_local` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_gross_sales_export` decimal(65,3) NULL DEFAULT '0.000',
`prj_pis_countries_of_destination` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_conceptualization` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_proposal_preparation` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_process` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_equipment` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_quality_control` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_packaging_labeling` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_post_harvest` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_marketing` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_training` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_consultancy` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_assistance_others` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_pis_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_cost_benefactor_desc` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_fundingsource_local` tinyint(1) unsigned NULL DEFAULT '0',
`prj_fundingsource_external` tinyint(1) unsigned NULL DEFAULT '0',
`barangay_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_status_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_total_amount` decimal(65,3) unsigned NULL DEFAULT NULL,
`rep_refund_rate` decimal(65,7) NULL DEFAULT NULL,
`rep_total_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_paid` decimal(65,3) NULL DEFAULT '0.000',
`sector_list` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_sector_list` mediumtext CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_p_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`collaborator_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`prj_startup_assistance` tinyint(1) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_id` bigint(20) unsigned NULL DEFAULT '0',
`district_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_cofunded_nga` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cofunded_lgu` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cost_nga` double unsigned NULL DEFAULT '0',
`prj_cost_lgu` double unsigned NULL DEFAULT '0',
`prj_cost_local` double unsigned NULL DEFAULT '0',
`prj_cost_external` double unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_promotion_tech_list` (
`prom_id` bigint(20) unsigned NULL DEFAULT '0',
`tech_list` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_provinces` (
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '0',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_pstc` (
`ug_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_rcp` (
`rcp_id` bigint(20) unsigned NULL DEFAULT '0',
`rcp_date` date NULL DEFAULT NULL,
`rcp_year` int(4) unsigned NULL DEFAULT NULL,
`rcp_month` int(2) NULL DEFAULT NULL,
`rcp_implemented` int(10) unsigned NULL DEFAULT '0',
`rcp_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`last_updated` datetime NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_referrals` (
`ref_id` bigint(20) unsigned NULL DEFAULT '0',
`ref_date` date NULL DEFAULT NULL,
`ref_year` int(4) unsigned NULL DEFAULT NULL,
`ref_month` int(2) NULL DEFAULT NULL,
`ref_count` int(10) unsigned NULL DEFAULT '0',
`ref_cost` decimal(65,3) unsigned NULL DEFAULT '0.000',
`ref_customer` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ref_information` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ref_action` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ref_referred` int(10) unsigned NULL DEFAULT '0',
`ref_referral_to` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ref_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_regions` (
`region_id` int(11) NULL DEFAULT '0',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_repayments` (
`rep_id` bigint(20) unsigned NULL DEFAULT '0',
`rep_start_year` int(10) unsigned NULL DEFAULT '0',
`rep_start_month` int(10) unsigned NULL DEFAULT '1',
`rep_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_month_count` int(10) unsigned NULL DEFAULT '36',
`rep_otb_paid` tinyint(1) unsigned NULL DEFAULT '0',
`rep_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`rep_add_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_add_check_date` date NULL DEFAULT NULL,
`rep_add_check_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_ub_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_ub_check_date` date NULL DEFAULT NULL,
`rep_ub_check_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_monthly_payment` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_total_amount` decimal(65,3) unsigned NULL DEFAULT NULL,
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`rep_otb` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_total_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_final_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_final_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_payment_count` decimal(32,0) NULL DEFAULT '0',
`rep_deferment_monthcount` decimal(32,0) NULL DEFAULT '0',
`rep_total_penalty_amount_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_penalty_amount_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_balance` decimal(65,3) NULL DEFAULT '0.000',
`rep_balance` decimal(65,3) NULL DEFAULT '0.000',
`rep_real_balance` decimal(65,3) NULL DEFAULT '0.000',
`rep_real_balance2` decimal(65,3) NULL DEFAULT NULL,
`rep_otb_amount_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_otb_amount` decimal(65,6) NULL DEFAULT NULL,
`rep_amount_with_otb` decimal(65,6) NULL DEFAULT NULL,
`rep_ub_receipt_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_refund_rate` decimal(65,7) NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_repayments_all` (
`rep_all_due` decimal(65,3) NULL DEFAULT NULL,
`rep_all_paid` decimal(65,3) NULL DEFAULT NULL,
`rep_all_balance` decimal(65,3) NULL DEFAULT NULL,
`rep_all_amount` decimal(65,3) NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_repayments_payments` (
`pay_id` bigint(20) unsigned NULL DEFAULT '0',
`pay_year` int(10) unsigned NULL DEFAULT '2015',
`pay_month` int(10) unsigned NULL DEFAULT '1',
`pay_count` int(10) unsigned NULL DEFAULT '1',
`pay_level` int(10) unsigned NULL DEFAULT '1',
`pay_amount_due` decimal(65,3) NULL DEFAULT '0.000',
`pay_amount_paid` decimal(65,3) unsigned NULL DEFAULT '0.000',
`pay_amount_date_paid` date NULL DEFAULT NULL,
`pay_check_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pay_check_date` date NULL DEFAULT NULL,
`pay_receipt_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pay_type_id` bigint(20) unsigned NULL DEFAULT '0',
`pay_otb` tinyint(1) unsigned NULL DEFAULT '0',
`pay_penalty_amount_due` decimal(65,3) unsigned NULL DEFAULT '0.000',
`pay_penalty_amount_paid` decimal(65,3) unsigned NULL DEFAULT '0.000',
`pay_penalty_date_paid` date NULL DEFAULT NULL,
`pay_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`rep_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`pay_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`pay_overdue_amount_due` decimal(65,3) unsigned NULL DEFAULT '0.000',
`pay_overdue_amount_paid` decimal(65,3) unsigned NULL DEFAULT '0.000',
`pay_overdue_date_paid` date NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_repayments_totals` (
`rep_total_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_payment_count` decimal(32,0) NULL DEFAULT '0',
`rep_total_penalty_amount_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_penalty_amount_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_final_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_final_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_repayments_totals_per_province` (
`rep_total_due` decimal(65,3) NULL DEFAULT NULL,
`rep_total_paid` decimal(65,3) NULL DEFAULT NULL,
`rep_payment_count` decimal(32,0) NULL DEFAULT NULL,
`rep_total_penalty_amount_due` decimal(65,3) NULL DEFAULT NULL,
`rep_total_penalty_amount_paid` decimal(65,3) NULL DEFAULT NULL,
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_repayments_with_projects` (
`rep_id` bigint(20) unsigned NULL DEFAULT '0',
`rep_start_year` int(10) unsigned NULL DEFAULT '0',
`rep_start_month` int(10) unsigned NULL DEFAULT '1',
`rep_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_month_count` int(10) unsigned NULL DEFAULT '36',
`rep_otb_paid` tinyint(1) unsigned NULL DEFAULT '0',
`rep_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`rep_add_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_add_check_date` date NULL DEFAULT NULL,
`rep_add_check_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_ub_amount` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_ub_check_date` date NULL DEFAULT NULL,
`rep_ub_check_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_monthly_payment` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_total_amount` decimal(65,3) unsigned NULL DEFAULT NULL,
`prj_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`rep_otb` decimal(65,3) unsigned NULL DEFAULT '0.000',
`rep_total_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_payment_count` decimal(32,0) NULL DEFAULT '0',
`rep_deferment_monthcount` decimal(32,0) NULL DEFAULT '0',
`rep_total_penalty_amount_due` decimal(65,3) NULL DEFAULT '0.000',
`rep_total_penalty_amount_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_balance` decimal(65,3) NULL DEFAULT '0.000',
`rep_otb_amount_paid` decimal(65,3) NULL DEFAULT '0.000',
`rep_otb_amount` decimal(65,6) NULL DEFAULT NULL,
`rep_amount_with_otb` decimal(65,6) NULL DEFAULT NULL,
`rep_ub_receipt_no` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rep_refund_rate` decimal(65,7) NULL DEFAULT NULL,
`prj_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_year_approved` int(10) unsigned NULL DEFAULT '2015',
`prj_objective` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_expected_output` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_product_line` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_cost_setup` double unsigned NULL DEFAULT '0',
`prj_cost_benefactor` double unsigned NULL DEFAULT '0',
`prj_cost_other` double unsigned NULL DEFAULT '0',
`prj_intervention` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_longitude` double unsigned NULL DEFAULT '0',
`prj_latitude` double unsigned NULL DEFAULT '0',
`prj_elevation` double unsigned NULL DEFAULT '0',
`prj_type_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_status_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`city_id` bigint(20) unsigned NULL DEFAULT '0',
`barangay_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_type_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_status_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`city_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`barangay_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_fund_release_date` date NULL DEFAULT NULL,
`prj_refund_period_from` date NULL DEFAULT NULL,
`prj_refund_period_to` date NULL DEFAULT NULL,
`prj_province` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_city` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_barangay` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prj_sector_list` mediumtext CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`collaborator_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`prj_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`coop_p_names` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sector_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`district_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`sector_id` bigint(20) unsigned NULL DEFAULT '0',
`prj_duration_from` date NULL DEFAULT NULL,
`prj_duration_to` date NULL DEFAULT NULL,
`prj_startup_assistance` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cofunded_nga` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cost_nga` double unsigned NULL DEFAULT '0',
`prj_cofunded_lgu` tinyint(1) unsigned NULL DEFAULT '0',
`prj_cost_lgu` double unsigned NULL DEFAULT '0',
`prj_cost_local` double unsigned NULL DEFAULT '0',
`prj_cost_external` double unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_rndagenda` (
`rndagenda_id` bigint(20) unsigned NULL DEFAULT '0',
`rndagenda_date` date NULL DEFAULT NULL,
`rndagenda_year` int(4) unsigned NULL DEFAULT NULL,
`rndagenda_month` int(2) NULL DEFAULT NULL,
`rndagenda_formulated` int(10) unsigned NULL DEFAULT '0',
`rndagenda_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`last_updated` datetime NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_rndprj` (
`rndprj_id` bigint(20) unsigned NULL DEFAULT '0',
`rndprj_date` date NULL DEFAULT NULL,
`rndprj_year` int(4) unsigned NULL DEFAULT NULL,
`rndprj_month` int(2) NULL DEFAULT NULL,
`rndprj_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`rndprj_description` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`rndprj_evaluated` tinyint(1) unsigned NULL DEFAULT '0',
`rndprj_endorsed` tinyint(1) unsigned NULL DEFAULT '0',
`rndprj_inhouse` tinyint(1) unsigned NULL DEFAULT '0',
`rndprj_implemented` tinyint(1) unsigned NULL DEFAULT '0',
`rndprj_colaborative` tinyint(1) unsigned NULL DEFAULT '0',
`rndprj_colaborators` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`rndprj_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`rndsec_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`last_updated` datetime NULL DEFAULT NULL,
`rndsec_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_ro` (
`ug_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_sales_gross` (
`prjmon_gross_sales` decimal(65,3) NULL DEFAULT NULL,
`prjmon_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_scholarships` (
`scholar_id` bigint(20) unsigned NULL DEFAULT '0',
`scholar_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`scholar_suffix` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`scholar_year_award` int(10) unsigned NULL DEFAULT '0',
`scholar_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`scholar_stat_id` bigint(20) unsigned NULL DEFAULT '0',
`scholar_prog_id` bigint(20) unsigned NULL DEFAULT '0',
`school_id` bigint(20) unsigned NULL DEFAULT '0',
`course_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`scholar_prog_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_prog_desc` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`school_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`school_acronym` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`school_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`school_coordinator` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`school_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`school_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`school_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`course_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`course_cat_id` bigint(20) unsigned NULL DEFAULT '0',
`course_yearcount` int(11) unsigned NULL DEFAULT '4',
`course_cat_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`course_label` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`scholar_stat_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`scholar_stat_abbr` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_service_provider_services` (
`sps_id` bigint(20) unsigned NULL DEFAULT '0',
`sp_id` bigint(20) unsigned NULL DEFAULT '0',
`service_id` bigint(20) unsigned NULL DEFAULT '0',
`service_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_service_providers` (
`sp_id` bigint(20) unsigned NULL DEFAULT '0',
`sp_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_other_service` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_designation` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_contact_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_address` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_expertise` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`sp_product_line` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_phone` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`sp_website` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_suc_assistance` (
`suca_id` bigint(20) unsigned NULL DEFAULT '0',
`suca_date` date NULL DEFAULT NULL,
`suca_year` int(4) unsigned NULL DEFAULT NULL,
`suca_month` int(2) NULL DEFAULT NULL,
`suca_assistance` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`suca_no_ipr` int(11) NULL DEFAULT '0',
`suca_ipr` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`suca_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`school_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`school_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`school_acronym` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_technology_adopter_counts` (
`coop_id_count` bigint(21) NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`adopt_date` date NULL DEFAULT NULL,
`adopt_year` int(4) unsigned NULL DEFAULT NULL,
`adopt_month` int(2) NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_technology_adoptions` (
`adopt_id` bigint(20) unsigned NULL DEFAULT '0',
`adopt_date` date NULL DEFAULT NULL,
`adopt_year` int(4) unsigned NULL DEFAULT NULL,
`adopt_month` int(2) NULL DEFAULT NULL,
`tech_id` bigint(20) unsigned NULL DEFAULT '0',
`coop_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`adopt_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`adopt_commercialized` tinyint(3) unsigned NULL DEFAULT '0',
`tech_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`coop_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_technology_promotions` (
`prom_id` bigint(20) unsigned NULL DEFAULT '0',
`prom_date` date NULL DEFAULT NULL,
`prom_year` int(4) unsigned NULL DEFAULT NULL,
`prom_month` int(2) NULL DEFAULT NULL,
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`prompt_id` bigint(20) unsigned NULL DEFAULT '0',
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`date_encoded` datetime NULL DEFAULT NULL,
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`last_updated` datetime NULL DEFAULT NULL,
`prom_remarks` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`prompt_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`tech_list` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`region_id` bigint(20) unsigned NULL DEFAULT '6'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_technology_promotions_for_kpi` (
`promoted_id` bigint(20) unsigned NULL DEFAULT '0',
`tech_id` bigint(20) unsigned NULL DEFAULT '0',
`prom_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`prom_date` date NULL DEFAULT NULL,
`prom_year` int(4) unsigned NULL DEFAULT NULL,
`prom_month` int(2) NULL DEFAULT NULL,
`ug_id` bigint(20) unsigned NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_unit_heads` (
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_parent_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_unit_head` bigint(20) unsigned NULL DEFAULT '0',
`u_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_username` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_password` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_enabled` tinyint(1) unsigned NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_user_log` (
`log_id` bigint(20) unsigned NULL DEFAULT '0',
`log_date` datetime NULL DEFAULT NULL,
`log_year` int(4) unsigned NULL DEFAULT NULL,
`log_month` int(2) NULL DEFAULT NULL,
`log_day` int(2) NULL DEFAULT NULL,
`log_page_title` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`log_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`log_url` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`log_msg` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`log_referer` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`log_usergroup` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`log_querystring` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`log_agent` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`log_ip` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_usergroup_rights` (
`ugr_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`ur_id` bigint(20) unsigned NULL DEFAULT '0',
`ugr_view` tinyint(1) unsigned NULL DEFAULT '1',
`ugr_add` tinyint(1) unsigned NULL DEFAULT '1',
`ugr_edit` tinyint(1) unsigned NULL DEFAULT '1',
`ugr_delete` tinyint(1) unsigned NULL DEFAULT '1',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ur_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_usergroups` (
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`num_users` bigint(21) NULL DEFAULT '0',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_text` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`ug_parent_id` bigint(20) unsigned NULL DEFAULT '0',
`province_id` bigint(20) unsigned NULL DEFAULT '0',
`province_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_parent_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_parent_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vwpsi_users` (
`u_id` bigint(20) unsigned NULL DEFAULT '0',
`u_username` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_password` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`u_name_rev` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`u_lname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_fname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_mname` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_mobile` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_email` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_enabled` tinyint(1) unsigned NULL DEFAULT '1',
`ug_id` bigint(20) unsigned NULL DEFAULT '0',
`synched` tinyint(1) unsigned NULL DEFAULT '0',
`sync_date` datetime NULL DEFAULT NULL,
`date_encoded` datetime NULL DEFAULT NULL,
`last_updated` datetime NULL DEFAULT NULL,
`encoder` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`updater` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_id` bigint(20) unsigned NULL DEFAULT '6',
`remember_token` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`remember_expiry` datetime NULL DEFAULT NULL,
`ug_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_is_admin` tinyint(1) unsigned NULL DEFAULT '0',
`ug_display_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`ug_parent_id` bigint(20) unsigned NULL DEFAULT '0',
`region_code` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`region_name` varchar(255) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '',
`u_region_name` text CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE VIEW `vwkpi_average_productivity` AS select `psi_project_monitoring`.`prjmon_year` AS `prjmon_year`,`psi_project_monitoring`.`quarter_id` AS `quarter_id`,`psi_projects`.`ug_id` AS `ug_id`,`psi_project_monitoring`.`region_id` AS `region_id`,`psi_project_monitoring`.`prjmon_average_productivity` AS `prjmon_average_productivity` from (`psi_project_monitoring` left join `psi_projects` on((`psi_projects`.`prj_id` = `psi_project_monitoring`.`prj_id`))) order by `psi_project_monitoring`.`prjmon_year` desc,`psi_project_monitoring`.`quarter_id`;

CREATE VIEW `vwkpi_jos_generated` AS select `psi_project_monitoring`.`prj_id` AS `prj_id`,`psi_project_monitoring`.`prjmon_year` AS `prjmon_year`,`psi_project_monitoring`.`quarter_id` AS `quarter_id`,sum((((`psi_project_monitoring`.`prjmon_emp_male` + `psi_project_monitoring`.`prjmon_emp_female`) + `psi_project_monitoring`.`prjmon_emp_in_male`) + `psi_project_monitoring`.`prjmon_emp_in_female`)) AS `job_count`,`psi_project_monitoring`.`region_id` AS `region_id`,`psi_projects`.`ug_id` AS `ug_id` from (`psi_project_monitoring` left join `psi_projects` on((`psi_projects`.`prj_id` = `psi_project_monitoring`.`prj_id`))) group by `psi_project_monitoring`.`prjmon_year`,`psi_project_monitoring`.`quarter_id`,`psi_projects`.`ug_id`;

CREATE VIEW `vwkpi_rndagenda_formulated` AS select `psi_rndagenda`.`rndagenda_formulated` AS `rndagenda_formulated`,`psi_rndagenda`.`rndagenda_date` AS `rndagenda_date`,year(`psi_rndagenda`.`rndagenda_date`) AS `rndagenda_year`,month(`psi_rndagenda`.`rndagenda_date`) AS `rndagenda_month`,`psi_rndagenda`.`region_id` AS `region_id` from `psi_rndagenda`;

CREATE VIEW `vwkpi_rndprj` AS select `psi_rndprj`.`region_id` AS `region_id`,`psi_rndprj`.`rndprj_date` AS `rndprj_date`,year(`psi_rndprj`.`rndprj_date`) AS `rndprj_year`,month(`psi_rndprj`.`rndprj_date`) AS `rndprj_month`,`psi_rndprj`.`rndprj_implemented` AS `rndprj_implemented`,`psi_rndprj`.`rndsec_id` AS `rndsec_id`,`psi_rndprj`.`rndprj_endorsed` AS `rndprj_endorsed`,`psi_rndprj`.`rndprj_evaluated` AS `rndprj_evaluated` from `psi_rndprj`;

CREATE VIEW `vwkpi_technology_adaptors` AS select `psi_technology_adoptions`.`coop_id` AS `coop_id`,`psi_cooperators`.`ot_cat1_id` AS `ot_cat1_id`,`psi_technology_adoptions`.`ug_id` AS `ug_id`,`psi_technology_adoptions`.`adopt_date` AS `adopt_date`,year(`psi_technology_adoptions`.`adopt_date`) AS `adopt_year`,month(`psi_technology_adoptions`.`adopt_date`) AS `adopt_month`,`psi_technology_adoptions`.`region_id` AS `region_id` from (`psi_technology_adoptions` left join `psi_cooperators` on((`psi_cooperators`.`coop_id` = `psi_technology_adoptions`.`coop_id`)));

CREATE VIEW `vwpki_production_generated` AS select `psi_project_production`.`production_gross` AS `production_gross`,`psi_project_production`.`production_volume` AS `production_volume`,`psi_project_monitoring`.`prjmon_year` AS `prjmon_year`,`psi_project_monitoring`.`quarter_id` AS `quarter_id`,`psi_project_production`.`region_id` AS `region_id`,`psi_projects`.`ug_id` AS `ug_id` from ((`psi_project_production` left join `psi_project_monitoring` on((`psi_project_monitoring`.`prjmon_id` = `psi_project_production`.`prjmon_id`))) left join `psi_projects` on((`psi_projects`.`prj_id` = `psi_project_monitoring`.`prj_id`)));

CREATE VIEW `vwpsi_activities` AS select `psi_activities`.`activity_id` AS `activity_id`,`psi_activities`.`activity_type_id` AS `activity_type_id`,`psi_activities`.`activity_title` AS `activity_title`,`psi_activities`.`activity_address` AS `activity_address`,`psi_activities`.`activity_target_date` AS `activity_target_date`,`psi_activities`.`activity_date_accomplished` AS `activity_date_accomplished`,year(`psi_activities`.`activity_date_accomplished`) AS `activity_date_accomplished_yr`,month(`psi_activities`.`activity_date_accomplished`) AS `activity_date_accomplished_mo`,year(`psi_activities`.`activity_date_accomplished`) AS `activity_year`,month(`psi_activities`.`activity_date_accomplished`) AS `activity_month`,`psi_activities`.`activity_csf` AS `activity_csf`,`psi_activities`.`activity_remarks` AS `activity_remarks`,`psi_activities`.`activity_no_participants` AS `activity_no_participants`,`psi_activities`.`activity_no_male` AS `activity_no_male`,`psi_activities`.`activity_no_female` AS `activity_no_female`,`psi_activities`.`activity_no_pwd` AS `activity_no_pwd`,`psi_activities`.`activity_no_senior` AS `activity_no_senior`,`psi_activities`.`encoder` AS `encoder`,`psi_activities`.`date_encoded` AS `date_encoded`,`psi_activities`.`updater` AS `updater`,`psi_activities`.`last_updated` AS `last_updated`,`psi_activities`.`activity_no_articles` AS `activity_no_articles`,`psi_activities`.`region_id` AS `region_id`,`psi_activities`.`synched` AS `synched`,`psi_activities`.`sync_date` AS `sync_date`,`psi_activities`.`ug_id` AS `ug_id`,`psi_activities`.`province_id` AS `province_id`,`psi_activities`.`city_id` AS `city_id`,`psi_activities`.`barangay_id` AS `barangay_id`,`psi_activities`.`activity_longitude` AS `activity_longitude`,`psi_activities`.`activity_latitude` AS `activity_latitude`,`psi_activities`.`activity_elevation` AS `activity_elevation`,`psi_activities`.`activity_cost` AS `activity_cost`,`psi_activity_types`.`activity_type_name` AS `activity_type_name` from (`psi_activities` left join `psi_activity_types` on((`psi_activities`.`activity_type_id` = `psi_activity_types`.`activity_type_id`)));

CREATE VIEW `vwpsi_agencies` AS select `psi_agencies`.`agency_id` AS `agency_id`,`psi_agencies`.`agency_name` AS `agency_name`,`psi_agencies`.`agency_acronym` AS `agency_acronym`,`psi_agencies`.`agency_filename` AS `agency_filename`,`psi_agencies`.`agency_file` AS `agency_file`,`psi_agencies`.`agency_address` AS `agency_address`,`psi_agencies`.`agency_contact` AS `agency_contact`,`psi_agencies`.`agency_email` AS `agency_email`,`psi_agencies`.`agency_phone` AS `agency_phone`,`psi_agencies`.`agency_website` AS `agency_website`,`psi_agencies`.`agency_mobile` AS `agency_mobile`,`psi_agencies`.`agency_longitude` AS `agency_longitude`,`psi_agencies`.`agency_latitude` AS `agency_latitude`,`psi_agencies`.`agency_gmap_key` AS `agency_gmap_key`,`psi_agencies`.`agency_fb_appid` AS `agency_fb_appid`,`psi_agencies`.`agency_region_id` AS `agency_region_id`,`psi_regions`.`region_name` AS `region_name`,`psi_regions`.`region_code` AS `region_code`,`psi_agencies`.`encoder` AS `encoder`,`psi_agencies`.`date_encoded` AS `date_encoded`,`psi_agencies`.`updater` AS `updater`,`psi_agencies`.`last_updated` AS `last_updated` from (`psi_agencies` left join `psi_regions` on((`psi_agencies`.`agency_region_id` = `psi_regions`.`region_id`)));

CREATE VIEW `vwpsi_calibrations` AS select `psi_calibrations`.`cal_id` AS `cal_id`,`psi_calibrations`.`cal_month` AS `cal_month`,`psi_calibrations`.`cal_year` AS `cal_year`,`psi_calibrations`.`cal_no_tests` AS `cal_no_tests`,`psi_calibrations`.`cal_no_tests_paid` AS `cal_no_tests_paid`,`psi_calibrations`.`cal_no_tests_free` AS `cal_no_tests_free`,`psi_calibrations`.`cal_no_calibrations` AS `cal_no_calibrations`,`psi_calibrations`.`cal_no_tests_received` AS `cal_no_tests_received`,`psi_calibrations`.`cal_petrochemical_in` AS `cal_petrochemical_in`,`psi_calibrations`.`cal_calibration_in` AS `cal_calibration_in`,`psi_calibrations`.`cal_halal_in` AS `cal_halal_in`,`psi_calibrations`.`cal_no_tests_referred` AS `cal_no_tests_referred`,`psi_calibrations`.`cal_petrochemical_referred` AS `cal_petrochemical_referred`,`psi_calibrations`.`cal_calibration_referred` AS `cal_calibration_referred`,`psi_calibrations`.`cal_halal_referred` AS `cal_halal_referred`,`psi_calibrations`.`cal_no_tests_sent` AS `cal_no_tests_sent`,`psi_calibrations`.`cal_no_clients` AS `cal_no_clients`,`psi_calibrations`.`cal_no_clients_free` AS `cal_no_clients_free`,`psi_calibrations`.`cal_no_firms` AS `cal_no_firms`,`psi_calibrations`.`cal_no_tests_on_time` AS `cal_no_tests_on_time`,`psi_calibrations`.`cal_no_additional_members` AS `cal_no_additional_members`,`psi_calibrations`.`cal_passed_test_parameters` AS `cal_passed_test_parameters`,`psi_calibrations`.`cal_passed_profeciency_certification` AS `cal_passed_profeciency_certification`,`psi_calibrations`.`cal_income` AS `cal_income`,`psi_calibrations`.`cal_income_gross` AS `cal_income_gross`,`psi_calibrations`.`cal_value_service` AS `cal_value_service`,`psi_calibrations`.`cal_cost` AS `cal_cost`,`psi_calibrations`.`lab_id` AS `lab_id`,`psi_calibrations`.`ug_id` AS `ug_id`,`psi_calibrations`.`region_id` AS `region_id`,`psi_calibrations`.`encoder` AS `encoder`,`psi_calibrations`.`date_encoded` AS `date_encoded`,`psi_calibrations`.`updater` AS `updater`,`psi_calibrations`.`last_updated` AS `last_updated`,`psi_calibrations`.`synched` AS `synched`,`psi_calibrations`.`sync_date` AS `sync_date`,`psi_laboratories`.`lab_name` AS `lab_name`,`psi_laboratories`.`lab_abbr` AS `lab_abbr`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from ((`psi_calibrations` left join `psi_laboratories` on((`psi_calibrations`.`lab_id` = `psi_laboratories`.`lab_id`))) left join `psi_usergroups` on((`psi_calibrations`.`ug_id` = `psi_usergroups`.`ug_id`)));

CREATE VIEW `vwpsi_cities` AS select `psi_cities`.`city_id` AS `city_id`,`psi_cities`.`province_id` AS `province_id`,`psi_cities`.`city_name` AS `city_name`,`psi_cities`.`district_id` AS `district_id`,`psi_districts`.`district_name` AS `district_name`,`psi_provinces`.`province_name` AS `province_name`,`psi_provinces`.`region_id` AS `region_id`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name` from (((`psi_cities` left join `psi_districts` on((`psi_districts`.`district_id` = `psi_cities`.`district_id`))) left join `psi_provinces` on((`psi_provinces`.`province_id` = `psi_cities`.`province_id`))) left join `psi_regions` on((`psi_regions`.`region_id` = `psi_provinces`.`region_id`)));

CREATE VIEW `vwpsi_collaborators` AS select `psi_collaborators`.`col_id` AS `col_id`,`psi_collaborators`.`col_name` AS `col_name`,`psi_collaborators`.`col_abbr` AS `col_abbr`,concat(`psi_collaborators`.`col_abbr`,' (',`psi_collaborators`.`col_name`,')') AS `col_listname`,`psi_collaborators`.`ot_id` AS `ot_id`,`psi_organization_types`.`ot_name` AS `ot_name` from (`psi_collaborators` left join `psi_organization_types` on((`psi_collaborators`.`ot_id` = `psi_organization_types`.`ot_id`)));

CREATE VIEW `vwpsi_consultancies` AS select `psi_consultancies`.`con_id` AS `con_id`,`psi_consultancies`.`con_start` AS `con_start`,`psi_consultancies`.`con_end` AS `con_end`,`psi_consultancies`.`con_cost` AS `con_cost`,year(`psi_consultancies`.`con_start`) AS `con_start_yr`,month(`psi_consultancies`.`con_start`) AS `con_start_mo`,year(`psi_consultancies`.`con_end`) AS `con_end_yr`,month(`psi_consultancies`.`con_end`) AS `con_end_mo`,`psi_consultancies`.`con_type_id` AS `con_type_id`,`psi_consultancies`.`prj_id` AS `prj_id`,`psi_consultancies`.`coop_id` AS `coop_id`,`psi_consultancies`.`sp_id` AS `sp_id`,`psi_consultancies`.`ug_id` AS `ug_id`,`psi_consultancies`.`encoder` AS `encoder`,`psi_consultancies`.`date_encoded` AS `date_encoded`,`psi_consultancies`.`updater` AS `updater`,`psi_consultancies`.`last_updated` AS `last_updated`,`psi_consultancy_types`.`con_type_name` AS `con_type_name`,`psi_consultancies`.`region_id` AS `region_id`,`vwpsi_cooperators`.`coop_name` AS `coop_name`,`vwpsi_cooperators`.`coop_p_fname` AS `coop_p_fname`,`vwpsi_cooperators`.`coop_p_mname` AS `coop_p_mname`,`vwpsi_cooperators`.`coop_p_lname` AS `coop_p_lname`,`vwpsi_cooperators`.`coop_p_name` AS `coop_p_name`,`vwpsi_cooperators`.`coop_address` AS `coop_address`,`vwpsi_cooperators`.`coop_phone` AS `coop_phone`,`vwpsi_cooperators`.`coop_fax` AS `coop_fax`,`vwpsi_cooperators`.`coop_mobile` AS `coop_mobile`,`vwpsi_cooperators`.`coop_email` AS `coop_email`,`vwpsi_cooperators`.`coop_website` AS `coop_website`,`vwpsi_cooperators`.`coop_year_established` AS `coop_year_established`,`vwpsi_service_providers`.`sp_name` AS `sp_name`,`vwpsi_service_providers`.`sp_other_service` AS `sp_other_service`,`vwpsi_service_providers`.`sp_designation` AS `sp_designation`,`vwpsi_service_providers`.`sp_fname` AS `sp_fname`,`vwpsi_service_providers`.`sp_mname` AS `sp_mname`,`vwpsi_service_providers`.`sp_lname` AS `sp_lname`,`vwpsi_service_providers`.`sp_contact_name` AS `sp_contact_name`,`vwpsi_service_providers`.`sp_address` AS `sp_address`,`vwpsi_service_providers`.`sp_expertise` AS `sp_expertise`,`vwpsi_service_providers`.`sp_product_line` AS `sp_product_line`,`vwpsi_service_providers`.`sp_phone` AS `sp_phone`,`vwpsi_service_providers`.`sp_mobile` AS `sp_mobile`,`vwpsi_service_providers`.`sp_email` AS `sp_email`,`vwpsi_service_providers`.`sp_website` AS `sp_website`,`psi_usergroups`.`ug_name` AS `ug_name`,`vwpsi_cooperators`.`coop_reg_dti` AS `coop_reg_dti`,`vwpsi_cooperators`.`coop_reg_sec` AS `coop_reg_sec`,`vwpsi_cooperators`.`coop_reg_others` AS `coop_reg_others`,`vwpsi_cooperators`.`coop_reg_cda` AS `coop_reg_cda`,`vwpsi_cooperators`.`coop_reg_dti_date` AS `coop_reg_dti_date`,`vwpsi_cooperators`.`coop_reg_sec_date` AS `coop_reg_sec_date`,`vwpsi_cooperators`.`coop_reg_cda_date` AS `coop_reg_cda_date`,`vwpsi_cooperators`.`coop_products` AS `coop_products`,`vwpsi_cooperators`.`coop_brief` AS `coop_brief`,`vwpsi_cooperators`.`ot_cat1_id` AS `ot_cat1_id`,`vwpsi_cooperators`.`ot_cat3_id` AS `ot_cat3_id`,`vwpsi_cooperators`.`ot_cat2_id` AS `ot_cat2_id`,`vwpsi_cooperators`.`ot_cat1_name` AS `ot_cat1_name`,`vwpsi_cooperators`.`ot_cat2_name` AS `ot_cat2_name`,`vwpsi_cooperators`.`ot_cat3_name` AS `ot_cat3_name`,`psi_consultancies`.`con_no_participants` AS `con_no_participants`,`psi_consultancies`.`con_no_firms` AS `con_no_firms`,`psi_consultancies`.`con_no_po` AS `con_no_po`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from ((((`psi_consultancies` left join `psi_consultancy_types` on((`psi_consultancies`.`con_type_id` = `psi_consultancy_types`.`con_type_id`))) left join `vwpsi_cooperators` on((`psi_consultancies`.`coop_id` = `vwpsi_cooperators`.`coop_id`))) left join `vwpsi_service_providers` on((`psi_consultancies`.`sp_id` = `vwpsi_service_providers`.`sp_id`))) left join `psi_usergroups` on((`psi_consultancies`.`ug_id` = `psi_usergroups`.`ug_id`)));

CREATE VIEW `vwpsi_coop_sector_list` AS select `psi_coop_sectors`.`coop_id` AS `coop_id`,group_concat(`psi_sectors`.`sector_name` separator ', ') AS `sector_list` from (`psi_coop_sectors` left join `psi_sectors` on((`psi_coop_sectors`.`sector_id` = `psi_sectors`.`sector_id`))) group by `psi_coop_sectors`.`coop_id`;

CREATE VIEW `vwpsi_cooperator_project_counts` AS select count(`psi_project_beneficiaries`.`prj_ben_id`) AS `coop_count`,`psi_project_beneficiaries`.`coop_id` AS `coop_id` from `psi_project_beneficiaries` group by `psi_project_beneficiaries`.`coop_id`;

CREATE VIEW `vwpsi_cooperator_projects` AS select `psi_project_beneficiaries`.`prj_ben_id` AS `prj_ben_id`,`psi_project_beneficiaries`.`prj_id` AS `prj_id`,`psi_project_beneficiaries`.`coop_id` AS `coop_id`,`vwpsi_projects`.`prj_title` AS `prj_title`,`vwpsi_projects`.`prj_code` AS `prj_code`,`vwpsi_projects`.`prj_year_approved` AS `prj_year_approved`,`vwpsi_projects`.`prj_objective` AS `prj_objective`,`vwpsi_projects`.`prj_expected_output` AS `prj_expected_output`,`vwpsi_projects`.`prj_product_line` AS `prj_product_line`,`vwpsi_projects`.`prj_cost_setup` AS `prj_cost_setup`,`vwpsi_projects`.`prj_cost_nga` AS `prj_cost_nga`,`vwpsi_projects`.`prj_cost_lgu` AS `prj_cost_lgu`,`vwpsi_projects`.`prj_cost_external` AS `prj_cost_external`,`vwpsi_projects`.`prj_cost_local` AS `prj_cost_local`,`vwpsi_projects`.`prj_cost_benefactor` AS `prj_cost_benefactor`,`vwpsi_projects`.`prj_cost_other` AS `prj_cost_other`,`vwpsi_projects`.`prj_intervention` AS `prj_intervention`,`vwpsi_projects`.`prj_longitude` AS `prj_longitude`,`vwpsi_projects`.`prj_latitude` AS `prj_latitude`,`vwpsi_projects`.`prj_elevation` AS `prj_elevation`,`vwpsi_projects`.`prj_type_id` AS `prj_type_id`,`vwpsi_projects`.`prj_status_id` AS `prj_status_id`,`vwpsi_projects`.`province_id` AS `province_id`,`vwpsi_projects`.`city_id` AS `city_id`,`vwpsi_projects`.`barangay_id` AS `barangay_id`,`vwpsi_projects`.`ug_id` AS `ug_id`,`vwpsi_projects`.`encoder` AS `encoder`,`vwpsi_projects`.`date_encoded` AS `date_encoded`,`vwpsi_projects`.`updater` AS `updater`,`vwpsi_projects`.`last_updated` AS `last_updated`,`vwpsi_projects`.`prj_type_name` AS `prj_type_name`,`vwpsi_projects`.`prj_status_name` AS `prj_status_name`,`vwpsi_projects`.`prj_sector_list` AS `prj_sector_list`,`vwpsi_projects`.`province_name` AS `province_name`,`vwpsi_projects`.`region_name` AS `region_name`,`vwpsi_projects`.`city_name` AS `city_name`,`vwpsi_projects`.`barangay_name` AS `barangay_name`,`vwpsi_projects`.`ug_name` AS `ug_name`,`vwpsi_projects`.`prj_duration_from` AS `prj_duration_from`,`vwpsi_projects`.`prj_duration_to` AS `prj_duration_to`,`vwpsi_projects`.`prj_remarks` AS `prj_remarks`,`vwpsi_projects`.`prj_address` AS `prj_address`,`vwpsi_projects`.`prj_cost_benefactor_desc` AS `prj_cost_benefactor_desc`,`vwpsi_projects`.`prj_fundingsource_local` AS `prj_fundingsource_local`,`vwpsi_projects`.`prj_fundingsource_external` AS `prj_fundingsource_external`,`vwpsi_projects`.`prj_cofunded_lgu` AS `prj_cofunded_lgu`,`vwpsi_projects`.`prj_cofunded_nga` AS `prj_cofunded_nga`,`vwpsi_projects`.`district_name` AS `district_name`,`vwpsi_projects`.`district_id` AS `district_id`,`vwpsi_projects`.`region_id` AS `region_id`,`vwpsi_projects`.`prj_startup_assistance` AS `prj_startup_assistance`,`vwpsi_projects`.`sector_id` AS `sector_id`,`vwpsi_projects`.`sector_name` AS `sector_name`,`vwpsi_projects`.`prj_fund_release_date` AS `prj_fund_release_date`,`vwpsi_projects`.`prj_refund_period_from` AS `prj_refund_period_from`,`vwpsi_projects`.`prj_refund_period_to` AS `prj_refund_period_to` from (`psi_project_beneficiaries` left join `vwpsi_projects` on((`psi_project_beneficiaries`.`prj_id` = `vwpsi_projects`.`prj_id`)));

CREATE VIEW `vwpsi_cooperators` AS select `psi_cooperators`.`coop_id` AS `coop_id`,concat(`psi_cooperators`.`coop_p_fname`,convert(if((char_length(`psi_cooperators`.`coop_p_fname`) > 0),' ','') using utf8mb4),`psi_cooperators`.`coop_p_mname`,convert(if((char_length(`psi_cooperators`.`coop_p_mname`) > 0),' ','') using utf8mb4),`psi_cooperators`.`coop_p_lname`) AS `coop_p_name`,`psi_cooperators`.`coop_address` AS `coop_address`,`psi_cooperators`.`coop_brief` AS `coop_brief`,`psi_cooperators`.`coop_email` AS `coop_email`,`psi_cooperators`.`coop_fax` AS `coop_fax`,`psi_cooperators`.`coop_mobile` AS `coop_mobile`,`psi_cooperators`.`coop_name` AS `coop_name`,`psi_cooperators`.`coop_p_fname` AS `coop_p_fname`,`psi_cooperators`.`coop_p_gender` AS `coop_p_gender`,`psi_cooperators`.`coop_p_lname` AS `coop_p_lname`,`psi_cooperators`.`coop_p_mname` AS `coop_p_mname`,`psi_cooperators`.`coop_p_position` AS `coop_p_position`,`psi_cooperators`.`coop_phone` AS `coop_phone`,`psi_cooperators`.`coop_products` AS `coop_products`,`psi_cooperators`.`coop_reg_cda` AS `coop_reg_cda`,`psi_cooperators`.`coop_reg_cda_date` AS `coop_reg_cda_date`,`psi_cooperators`.`coop_reg_dti` AS `coop_reg_dti`,`psi_cooperators`.`coop_reg_dti_date` AS `coop_reg_dti_date`,`psi_cooperators`.`coop_reg_others` AS `coop_reg_others`,`psi_cooperators`.`coop_reg_sec` AS `coop_reg_sec`,`psi_cooperators`.`coop_reg_sec_date` AS `coop_reg_sec_date`,`psi_cooperators`.`coop_website` AS `coop_website`,`psi_cooperators`.`coop_year_established` AS `coop_year_established`,`psi_cooperators`.`ot_cat1_id` AS `ot_cat1_id`,`psi_cooperators`.`ot_cat2_id` AS `ot_cat2_id`,`psi_cooperators`.`ot_cat3_id` AS `ot_cat3_id`,`psi_cooperators`.`region_id` AS `region_id`,`psi_cooperators`.`ug_id` AS `ug_id`,`psi_organization_types_cat1`.`ot_cat1_name` AS `ot_cat1_name`,`psi_organization_types_cat2`.`ot_cat2_name` AS `ot_cat2_name`,`psi_organization_types_cat3`.`ot_cat3_name` AS `ot_cat3_name`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_cooperators`.`date_encoded` AS `date_encoded`,`psi_cooperators`.`encoder` AS `encoder`,`psi_cooperators`.`last_updated` AS `last_updated`,`psi_cooperators`.`updater` AS `updater`,`totals`.`sector_list` AS `coop_sector_list`,ifnull(`counts`.`coop_count`,0) AS `coop_count` from (((((((`psi_cooperators` left join `psi_organization_types_cat1` on((`psi_organization_types_cat1`.`ot_cat1_id` = `psi_cooperators`.`ot_cat1_id`))) left join `psi_organization_types_cat2` on((`psi_organization_types_cat2`.`ot_cat2_id` = `psi_cooperators`.`ot_cat2_id`))) left join `psi_organization_types_cat3` on((`psi_organization_types_cat3`.`ot_cat3_id` = `psi_cooperators`.`ot_cat3_id`))) left join `psi_regions` on((`psi_regions`.`region_id` = `psi_cooperators`.`region_id`))) left join `psi_usergroups` on((`psi_usergroups`.`ug_id` = `psi_cooperators`.`ug_id`))) left join (select `psi_coop_sectors`.`coop_id` AS `coop_id`,group_concat(`psi_sectors`.`sector_name` separator ', ') AS `sector_list` from (`psi_coop_sectors` left join `psi_sectors` on((`psi_coop_sectors`.`sector_id` = `psi_sectors`.`sector_id`))) group by `psi_coop_sectors`.`coop_id`) `totals` on((`totals`.`coop_id` = `psi_cooperators`.`coop_id`))) left join (select count(`psi_project_beneficiaries`.`prj_ben_id`) AS `coop_count`,`psi_project_beneficiaries`.`coop_id` AS `coop_id` from `psi_project_beneficiaries` group by `psi_project_beneficiaries`.`coop_id`) `counts` on((`counts`.`coop_id` = `psi_cooperators`.`coop_id`)));

CREATE VIEW `vwpsi_courses` AS select `psi_courses`.`course_id` AS `course_id`,`psi_courses`.`course_cat_id` AS `course_cat_id`,`psi_courses`.`course_name` AS `course_name`,`psi_courses`.`course_yearcount` AS `course_yearcount`,`psi_course_categories`.`course_cat_name` AS `course_cat_name`,concat(`psi_course_categories`.`course_cat_name`,' - ',`psi_courses`.`course_name`) AS `course_label` from (`psi_courses` left join `psi_course_categories` on((`psi_courses`.`course_cat_id` = `psi_course_categories`.`course_cat_id`))) order by `psi_course_categories`.`course_cat_name`,`psi_courses`.`course_name`;

CREATE VIEW `vwpsi_csf_ratings` AS select `psi_csf_ratings`.`csrat_id` AS `csrat_id`,`psi_csf_ratings`.`csrat_date` AS `csrat_date`,year(`psi_csf_ratings`.`csrat_date`) AS `csrat_year`,month(`psi_csf_ratings`.`csrat_date`) AS `csrat_month`,`psi_csf_ratings`.`csrat_no_customers` AS `csrat_no_customers`,`psi_csf_ratings`.`csrat_rating` AS `csrat_rating`,`psi_csf_ratings`.`csrat_remarks` AS `csrat_remarks`,`psi_csf_ratings`.`ug_id` AS `ug_id`,`psi_csf_ratings`.`encoder` AS `encoder`,`psi_csf_ratings`.`date_encoded` AS `date_encoded`,`psi_csf_ratings`.`updater` AS `updater`,`psi_csf_ratings`.`last_updated` AS `last_updated`,`psi_csf_ratings`.`csrat_file` AS `csrat_file`,`psi_csf_ratings`.`csrat_filename` AS `csrat_filename`,`psi_csf_ratings`.`region_id` AS `region_id`,`psi_csf_ratings`.`synched` AS `synched`,`psi_csf_ratings`.`sync_date` AS `sync_date`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from (`psi_csf_ratings` left join `psi_usergroups` on((`psi_csf_ratings`.`ug_id` = `psi_usergroups`.`ug_id`)));

CREATE VIEW `vwpsi_deferment_monthcounts` AS select sum(`psi_repayments_payments`.`pay_count`) AS `rep_deferment_monthcount`,`psi_repayments_payments`.`rep_id` AS `rep_id` from `psi_repayments_payments` where (`psi_repayments_payments`.`pay_otb` = 2) group by `psi_repayments_payments`.`rep_id`;

CREATE VIEW `vwpsi_drrm` AS select `psi_drrm`.`drrm_id` AS `drrm_id`,`psi_drrm`.`drrm_date` AS `drrm_date`,year(`psi_drrm`.`drrm_date`) AS `drrm_year`,month(`psi_drrm`.`drrm_date`) AS `drrm_month`,`psi_drrm`.`drrm_installed` AS `drrm_installed`,`psi_drrm`.`drrm_maintained` AS `drrm_maintained`,`psi_drrm`.`drrm_activities` AS `drrm_activities`,`psi_drrm`.`drrm_devices` AS `drrm_devices`,`psi_drrm`.`drrm_iec` AS `drrm_iec`,`psi_drrm`.`drrm_remarks` AS `drrm_remarks`,`psi_drrm`.`ug_id` AS `ug_id`,`psi_drrm`.`encoder` AS `encoder`,`psi_drrm`.`date_encoded` AS `date_encoded`,`psi_drrm`.`updater` AS `updater`,`psi_drrm`.`last_updated` AS `last_updated`,`psi_drrm`.`drrm_collaborations` AS `drrm_collaborations`,`psi_drrm`.`region_id` AS `region_id`,`psi_drrm`.`synched` AS `synched`,`psi_drrm`.`sync_date` AS `sync_date`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from (`psi_drrm` left join `psi_usergroups` on((`psi_usergroups`.`ug_id` = `psi_drrm`.`ug_id`)));

CREATE VIEW `vwpsi_equipment` AS select `psi_equipment`.`eqp_id` AS `eqp_id`,`psi_equipment`.`eqp_specs` AS `eqp_specs`,`psi_equipment`.`eqp_qty` AS `eqp_qty`,`psi_equipment`.`eqp_amount_acquired` AS `eqp_amount_acquired`,`psi_equipment`.`eqp_amount_approved` AS `eqp_amount_approved`,`psi_equipment`.`eqp_property_no` AS `eqp_property_no`,`psi_equipment`.`eqp_receipt_no` AS `eqp_receipt_no`,`psi_equipment`.`eqp_receipt_date` AS `eqp_receipt_date`,`psi_equipment`.`eqp_warranty` AS `eqp_warranty`,`psi_equipment`.`eqp_date_acquired` AS `eqp_date_acquired`,`psi_equipment`.`eqp_date_tagged` AS `eqp_date_tagged`,`psi_equipment`.`eqp_remarks` AS `eqp_remarks`,`psi_equipment`.`brand_id` AS `brand_id`,`psi_equipment`.`prj_id` AS `prj_id`,`psi_equipment`.`sp_id` AS `sp_id`,`psi_equipment`.`encoder` AS `encoder`,`psi_equipment`.`date_encoded` AS `date_encoded`,`psi_equipment`.`updater` AS `updater`,`psi_equipment`.`last_updated` AS `last_updated`,`psi_equipment_brands`.`brand_name` AS `brand_name`,`psi_service_providers`.`sp_name` AS `sp_name`,`psi_service_providers`.`sp_other_service` AS `sp_other_service`,`psi_service_providers`.`sp_designation` AS `sp_designation`,`psi_service_providers`.`sp_fname` AS `sp_fname`,`psi_service_providers`.`sp_mname` AS `sp_mname`,`psi_service_providers`.`sp_lname` AS `sp_lname`,concat(`psi_service_providers`.`sp_fname`,convert(convert(convert(convert(if((char_length(`psi_service_providers`.`sp_fname`) > 0),' ','') using latin1) using utf8) using utf8) using utf8mb4),`psi_service_providers`.`sp_mname`,convert(convert(convert(convert(if((char_length(`psi_service_providers`.`sp_mname`) > 0),' ','') using latin1) using utf8) using utf8) using utf8mb4),`psi_service_providers`.`sp_lname`) AS `sp_contact_name`,`psi_service_providers`.`sp_address` AS `sp_address`,`psi_service_providers`.`sp_expertise` AS `sp_expertise`,`psi_service_providers`.`sp_product_line` AS `sp_product_line`,`psi_service_providers`.`sp_phone` AS `sp_phone`,`psi_service_providers`.`sp_mobile` AS `sp_mobile`,`psi_service_providers`.`sp_email` AS `sp_email`,`psi_service_providers`.`sp_website` AS `sp_website`,`psi_equipment`.`imp_id` AS `imp_id`,`psi_improvements`.`imp_name` AS `imp_name` from (((`psi_equipment` left join `psi_equipment_brands` on((`psi_equipment`.`brand_id` = `psi_equipment_brands`.`brand_id`))) left join `psi_service_providers` on((`psi_equipment`.`sp_id` = `psi_service_providers`.`sp_id`))) left join `psi_improvements` on((`psi_equipment`.`imp_id` = `psi_improvements`.`imp_id`)));

CREATE VIEW `vwpsi_fora` AS select `psi_fora`.`fr_id` AS `fr_id`,`psi_fora`.`fr_requesting_party` AS `fr_requesting_party`,`psi_fora`.`fr_title` AS `fr_title`,`psi_fora`.`fr_sectors` AS `fr_sectors`,`psi_fora`.`fr_start` AS `fr_start`,`psi_fora`.`fr_end` AS `fr_end`,`psi_fora`.`fr_duration` AS `fr_duration`,`psi_fora`.`fr_location` AS `fr_location`,`psi_fora`.`fr_longitude` AS `fr_longitude`,`psi_fora`.`fr_latitude` AS `fr_latitude`,`psi_fora`.`fr_elevation` AS `fr_elevation`,`psi_fora`.`fr_cost` AS `fr_cost`,`psi_fora`.`fr_csf` AS `fr_csf`,`psi_fora`.`fr_no_feminine` AS `fr_no_feminine`,`psi_fora`.`fr_no_masculine` AS `fr_no_masculine`,`psi_fora`.`fr_no_pwd` AS `fr_no_pwd`,`psi_fora`.`fr_no_seniors` AS `fr_no_seniors`,`psi_fora`.`fr_no_firms` AS `fr_no_firms`,`psi_fora`.`fr_type_id` AS `fr_type_id`,`psi_fora`.`fr_remarks` AS `fr_remarks`,`psi_fora`.`prj_id` AS `prj_id`,`psi_fora`.`ug_id` AS `ug_id`,`psi_fora`.`encoder` AS `encoder`,`psi_fora`.`date_encoded` AS `date_encoded`,`psi_fora`.`updater` AS `updater`,`psi_fora`.`last_updated` AS `last_updated`,`psi_fora`.`fr_no_po` AS `fr_no_po`,`psi_fora`.`region_id` AS `region_id`,`psi_fora`.`synched` AS `synched`,`psi_fora`.`sync_date` AS `sync_date`,`psi_fora`.`sp_id` AS `sp_id`,`psi_fora`.`province_id` AS `province_id`,`psi_fora`.`city_id` AS `city_id`,`psi_fora`.`barangay_id` AS `barangay_id`,`psi_fora_types`.`fr_type_name` AS `fr_type_name`,`vwpsi_fora_collaborators`.`collaborator_names` AS `collaborator_names`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name`,`psi_projects`.`prj_title` AS `prj_title`,`psi_projects`.`prj_code` AS `prj_code`,`psi_projects`.`prj_year_approved` AS `prj_year_approved`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_display_name` AS `ug_display_name`,year(`psi_fora`.`fr_start`) AS `fr_start_yr`,month(`psi_fora`.`fr_start`) AS `fr_start_mo`,year(`psi_fora`.`fr_end`) AS `fr_end_yr`,month(`psi_fora`.`fr_end`) AS `fr_end_mo`,(`psi_fora`.`fr_no_feminine` + `psi_fora`.`fr_no_masculine`) AS `fr_no_participants` from (((((`psi_fora` left join `psi_fora_types` on((`psi_fora`.`fr_type_id` = `psi_fora_types`.`fr_type_id`))) left join `psi_regions` on((`psi_fora`.`region_id` = `psi_regions`.`region_id`))) left join `psi_projects` on((`psi_fora`.`prj_id` = `psi_projects`.`prj_id`))) left join `psi_usergroups` on((`psi_fora`.`ug_id` = `psi_usergroups`.`ug_id`))) left join `vwpsi_fora_collaborators` on((`psi_fora`.`fr_id` = `vwpsi_fora_collaborators`.`fr_id`)));

CREATE VIEW `vwpsi_fora_collaborators` AS select `psi_fora_collaborators`.`fr_id` AS `fr_id`,group_concat(`vwpsi_collaborators`.`col_name` separator ', ') AS `collaborator_names` from (`psi_fora_collaborators` left join `vwpsi_collaborators` on((`psi_fora_collaborators`.`col_id` = `vwpsi_collaborators`.`col_id`))) group by `psi_fora_collaborators`.`fr_id`;

CREATE VIEW `vwpsi_fora_count_per_type` AS select sum(`psi_fora`.`fr_id`) AS `fr_count_total`,`psi_fora_types`.`fr_type_name` AS `fr_type_name` from (`psi_fora` left join `psi_fora_types` on((`psi_fora`.`fr_type_id` = `psi_fora_types`.`fr_type_id`))) group by `psi_fora_types`.`fr_type_name` order by `fr_count_total`;

CREATE VIEW `vwpsi_fora_count_per_year` AS select sum(`psi_fora`.`fr_id`) AS `fr_count_total`,year(`psi_fora`.`fr_end`) AS `fr_year` from `psi_fora` group by year(`psi_fora`.`fr_end`) order by `fr_count_total`;

CREATE VIEW `vwpsi_fora_documents` AS select `psi_fora_documents`.`frdoc_id` AS `frdoc_id`,`psi_fora_documents`.`frdoc_file` AS `frdoc_file`,`psi_fora_documents`.`frdoc_filename` AS `frdoc_filename`,`psi_fora_documents`.`frdoc_remarks` AS `frdoc_remarks`,`psi_fora_documents`.`fdoctype_id` AS `fdoctype_id`,`psi_fora_documents`.`fr_id` AS `fr_id`,`psi_fora_documents`.`encoder` AS `encoder`,`psi_fora_documents`.`date_encoded` AS `date_encoded`,`psi_fora_documents`.`updater` AS `updater`,`psi_fora_documents`.`last_updated` AS `last_updated`,`psi_fora_document_types`.`fdoctype_name` AS `fdoctype_name` from (`psi_fora_documents` left join `psi_fora_document_types` on((`psi_fora_documents`.`fdoctype_id` = `psi_fora_document_types`.`fdoctype_id`)));

CREATE VIEW `vwpsi_innovation_hubs` AS select `psi_innovation_hubs`.`hub_id` AS `hub_id`,`psi_innovation_hubs`.`hub_date` AS `hub_date`,year(`psi_innovation_hubs`.`hub_date`) AS `hub_year`,month(`psi_innovation_hubs`.`hub_date`) AS `hub_month`,`psi_innovation_hubs`.`hub_name` AS `hub_name`,`psi_innovation_hubs`.`hub_address` AS `hub_address`,`psi_innovation_hubs`.`hub_longitude` AS `hub_longitude`,`psi_innovation_hubs`.`hub_latitude` AS `hub_latitude`,`psi_innovation_hubs`.`hub_elevation` AS `hub_elevation`,`psi_innovation_hubs`.`hub_remarks` AS `hub_remarks`,`psi_innovation_hubs`.`region_id` AS `region_id`,`psi_innovation_hubs`.`province_id` AS `province_id`,`psi_innovation_hubs`.`city_id` AS `city_id`,`psi_innovation_hubs`.`barangay_id` AS `barangay_id`,`psi_innovation_hubs`.`ug_id` AS `ug_id`,`psi_innovation_hubs`.`encoder` AS `encoder`,`psi_innovation_hubs`.`date_encoded` AS `date_encoded`,`psi_innovation_hubs`.`updater` AS `updater`,`psi_innovation_hubs`.`last_updated` AS `last_updated`,`psi_innovation_hubs`.`hubt_id` AS `hubt_id`,`psi_innovation_hubs`.`synched` AS `synched`,`psi_innovation_hubs`.`sync_date` AS `sync_date`,`psi_hub_types`.`hubt_name` AS `hubt_name`,`psi_provinces`.`province_name` AS `province_name`,`psi_cities`.`city_name` AS `city_name`,`psi_barangays`.`barangay_name` AS `barangay_name`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from (((((`psi_innovation_hubs` left join `psi_provinces` on((`psi_innovation_hubs`.`province_id` = `psi_provinces`.`province_id`))) left join `psi_cities` on((`psi_innovation_hubs`.`city_id` = `psi_cities`.`city_id`))) left join `psi_barangays` on((`psi_innovation_hubs`.`barangay_id` = `psi_barangays`.`barangay_id`))) left join `psi_usergroups` on((`psi_innovation_hubs`.`ug_id` = `psi_usergroups`.`ug_id`))) left join `psi_hub_types` on((`psi_innovation_hubs`.`hubt_id` = `psi_hub_types`.`hubt_id`)));

CREATE VIEW `vwpsi_international_collaborations` AS select `psi_international_collaborations`.`intc_id` AS `intc_id`,`psi_international_collaborations`.`intc_date` AS `intc_date`,year(`psi_international_collaborations`.`intc_date`) AS `intc_year`,month(`psi_international_collaborations`.`intc_date`) AS `intc_month`,`psi_international_collaborations`.`intc_description` AS `intc_description`,`psi_international_collaborations`.`intc_remarks` AS `intc_remarks`,`psi_international_collaborations`.`encoder` AS `encoder`,`psi_international_collaborations`.`date_encoded` AS `date_encoded`,`psi_international_collaborations`.`updater` AS `updater`,`psi_international_collaborations`.`last_updated` AS `last_updated`,`psi_international_collaborations`.`ug_id` AS `ug_id`,`psi_international_collaborations`.`region_id` AS `region_id`,`psi_international_collaborations`.`synched` AS `synched`,`psi_international_collaborations`.`sync_date` AS `sync_date`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from (`psi_international_collaborations` left join `psi_usergroups` on((`psi_usergroups`.`ug_id` = `psi_international_collaborations`.`ug_id`)));

CREATE VIEW `vwpsi_iso` AS select `psi_iso`.`iso_id` AS `iso_id`,`psi_iso`.`iso_date` AS `iso_date`,year(`psi_iso`.`iso_date`) AS `iso_year`,month(`psi_iso`.`iso_date`) AS `iso_month`,`psi_iso`.`iso_maintained` AS `iso_maintained`,`psi_iso`.`iso_remarks` AS `iso_remarks`,`psi_iso`.`encoder` AS `encoder`,`psi_iso`.`date_encoded` AS `date_encoded`,`psi_iso`.`updater` AS `updater`,`psi_iso`.`last_updated` AS `last_updated` from `psi_iso`;

CREATE VIEW `vwpsi_kpi_pstc_total_targets` AS select year(`psi_kpi_targets`.`kpitar_date`) AS `kpitar_year`,sum(`psi_kpi_targets`.`kpitar_q1`) AS `kpitar_total_q1`,sum(`psi_kpi_targets`.`kpitar_q2`) AS `kpitar_total_q2`,sum(`psi_kpi_targets`.`kpitar_q3`) AS `kpitar_total_q3`,sum(`psi_kpi_targets`.`kpitar_q4`) AS `kpitar_total_q4`,sum((((`psi_kpi_targets`.`kpitar_q1` + `psi_kpi_targets`.`kpitar_q2`) + `psi_kpi_targets`.`kpitar_q3`) + `psi_kpi_targets`.`kpitar_q4`)) AS `kpitar_total_targets`,`psi_kpi_targets`.`kpiind_id` AS `kpiind_id`,`psi_kpi_targets`.`region_id` AS `region_id`,`psi_kpi_targets`.`kpitar_for` AS `kpitar_for` from `psi_kpi_targets` group by year(`psi_kpi_targets`.`kpitar_date`),`psi_kpi_targets`.`kpiind_id`,`psi_kpi_targets`.`region_id`,`psi_kpi_targets`.`kpitar_for`;

CREATE VIEW `vwpsi_kpi_total_targets` AS select year(`psi_kpi_targets`.`kpitar_date`) AS `kpitar_year`,sum(`psi_kpi_targets`.`kpitar_q1`) AS `kpitar_total_q1`,sum(`psi_kpi_targets`.`kpitar_q2`) AS `kpitar_total_q2`,sum(`psi_kpi_targets`.`kpitar_q3`) AS `kpitar_total_q3`,sum(`psi_kpi_targets`.`kpitar_q4`) AS `kpitar_total_q4`,sum((((`psi_kpi_targets`.`kpitar_q1` + `psi_kpi_targets`.`kpitar_q2`) + `psi_kpi_targets`.`kpitar_q3`) + `psi_kpi_targets`.`kpitar_q4`)) AS `kpitar_total_targets`,`psi_kpi_targets`.`kpiind_id` AS `kpiind_id`,`psi_kpi_targets`.`region_id` AS `region_id` from `psi_kpi_targets` group by year(`psi_kpi_targets`.`kpitar_date`),`psi_kpi_targets`.`kpiind_id`,`psi_kpi_targets`.`region_id`;

CREATE VIEW `vwpsi_liquidation` AS select `psi_project_liquidation`.`liq_id` AS `liq_id`,`psi_project_liquidation`.`liq_file` AS `liq_file`,`psi_project_liquidation`.`liq_filename` AS `liq_filename`,`psi_project_liquidation`.`liq_remarks` AS `liq_remarks`,`psi_project_liquidation`.`prj_id` AS `prj_id`,`psi_project_liquidation`.`liqtype_id` AS `liqtype_id`,`psi_project_liquidation`.`encoder` AS `encoder`,`psi_project_liquidation`.`date_encoded` AS `date_encoded`,`psi_project_liquidation`.`updater` AS `updater`,`psi_project_liquidation`.`last_updated` AS `last_updated`,`psi_project_liquidation_types`.`liqtype_name` AS `liqtype_name` from (`psi_project_liquidation` left join `psi_project_liquidation_types` on((`psi_project_liquidation`.`liqtype_id` = `psi_project_liquidation_types`.`liqtype_id`)));

CREATE VIEW `vwpsi_locations` AS select `psi_barangays`.`barangay_id` AS `barangay_id`,`psi_barangays`.`barangay_name` AS `barangay_name`,`psi_barangays`.`city_id` AS `city_id`,`psi_cities`.`province_id` AS `province_id`,`psi_cities`.`city_name` AS `city_name`,`psi_cities`.`district_id` AS `district_id`,`psi_districts`.`district_name` AS `district_name`,`psi_provinces`.`region_id` AS `region_id`,`psi_provinces`.`province_name` AS `province_name`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name` from ((((`psi_barangays` left join `psi_cities` on((`psi_barangays`.`city_id` = `psi_cities`.`city_id`))) left join `psi_provinces` on((`psi_cities`.`province_id` = `psi_provinces`.`province_id`))) left join `psi_regions` on((`psi_provinces`.`region_id` = `psi_regions`.`region_id`))) left join `psi_districts` on((`psi_cities`.`district_id` = `psi_districts`.`district_id`)));

CREATE VIEW `vwpsi_num_users` AS select count(`psi_users`.`u_id`) AS `num_users`,`psi_users`.`ug_id` AS `ug_id`,`psi_users`.`region_id` AS `region_id` from `psi_users` group by `psi_users`.`ug_id`,`psi_users`.`region_id`;

CREATE VIEW `vwpsi_otb_payments` AS select sum(`psi_repayments_payments`.`pay_amount_paid`) AS `rep_otb_amount_paid`,`psi_repayments_payments`.`rep_id` AS `rep_id` from `psi_repayments_payments` where (`psi_repayments_payments`.`pay_otb` = 1) group by `psi_repayments_payments`.`rep_id`;

CREATE VIEW `vwpsi_packaging` AS select `psi_packaging`.`pkg_id` AS `pkg_id`,`psi_packaging`.`coop_id` AS `coop_id`,`psi_packaging`.`pkg_date` AS `pkg_date`,year(`psi_packaging`.`pkg_date`) AS `pkg_year`,month(`psi_packaging`.`pkg_date`) AS `pkg_month`,`psi_packaging`.`pkg_cost` AS `pkg_cost`,`psi_packaging`.`pkg_remarks` AS `pkg_remarks`,`psi_packaging`.`pkg_product_name` AS `pkg_product_name`,`psi_packaging`.`pkg_brand_name` AS `pkg_brand_name`,`psi_packaging`.`pkg_product_description` AS `pkg_product_description`,`psi_packaging`.`pkg_competitors` AS `pkg_competitors`,`psi_packaging`.`pkg_competitor_1` AS `pkg_competitor_1`,`psi_packaging`.`pkg_competitor_2` AS `pkg_competitor_2`,`psi_packaging`.`pkg_competitor_3` AS `pkg_competitor_3`,`psi_packaging`.`pkg_competitor_4` AS `pkg_competitor_4`,`psi_packaging`.`pkg_competitor_5` AS `pkg_competitor_5`,`psi_packaging`.`pkg_competitor_6` AS `pkg_competitor_6`,`psi_packaging`.`pkg_selling_point` AS `pkg_selling_point`,`psi_packaging`.`pkg_selling_point_others` AS `pkg_selling_point_others`,`psi_packaging`.`pkg_performance` AS `pkg_performance`,`psi_packaging`.`pkg_distribution` AS `pkg_distribution`,`psi_packaging`.`pkg_ingredients` AS `pkg_ingredients`,`psi_packaging`.`pkg_volume` AS `pkg_volume`,`psi_packaging`.`pkg_packaging_material` AS `pkg_packaging_material`,`psi_packaging`.`pkg_label_size` AS `pkg_label_size`,`psi_packaging`.`pkg_preferred_colors` AS `pkg_preferred_colors`,`psi_packaging`.`pkg_other_details` AS `pkg_other_details`,`psi_packaging`.`pkg_market_location` AS `pkg_market_location`,`psi_packaging`.`pkg_market_products_sold` AS `pkg_market_products_sold`,`psi_packaging`.`pkg_market_date_established` AS `pkg_market_date_established`,`psi_packaging`.`pkg_sales_before_intervention` AS `pkg_sales_before_intervention`,`psi_packaging`.`pkg_sales_after_intervention` AS `pkg_sales_after_intervention`,(`psi_packaging`.`pkg_sales_after_intervention` - `psi_packaging`.`pkg_sales_before_intervention`) AS `pkg_sales_increase`,`psi_packaging`.`pkg_employment_after_direct` AS `pkg_employment_after_direct`,`psi_packaging`.`pkg_employment_after_indirect` AS `pkg_employment_after_indirect`,`psi_packaging`.`pkg_employment_after_months_employed` AS `pkg_employment_after_months_employed`,`psi_packaging`.`pkg_avg_productivity_improvement` AS `pkg_avg_productivity_improvement`,`psi_packaging`.`pkg_file` AS `pkg_file`,`psi_packaging`.`pkg_filename` AS `pkg_filename`,`psi_packaging`.`encoder` AS `encoder`,`psi_packaging`.`date_encoded` AS `date_encoded`,`psi_packaging`.`updater` AS `updater`,`psi_packaging`.`last_updated` AS `last_updated`,`psi_packaging`.`prj_id` AS `prj_id`,`psi_packaging`.`ug_id` AS `ug_id`,`psi_packaging`.`pkg_no_new_markets` AS `pkg_no_new_markets`,`psi_cooperators`.`coop_name` AS `coop_name`,`psi_sellingpoints`.`sp_label` AS `sp_label`,`psi_distributions`.`dist_label` AS `dist_label`,`psi_packaging`.`region_id` AS `region_id`,`psi_packaging`.`sync_date` AS `sync_date`,`psi_packaging`.`synched` AS `synched` from (((`psi_packaging` left join `psi_cooperators` on((`psi_packaging`.`coop_id` = `psi_cooperators`.`coop_id`))) left join `psi_sellingpoints` on((`psi_packaging`.`pkg_selling_point` = `psi_sellingpoints`.`sp_id`))) left join `psi_distributions` on((`psi_packaging`.`pkg_distribution` = `psi_distributions`.`dist_id`)));

CREATE VIEW `vwpsi_packaging_designs` AS select `psi_packaging_designs`.`design_id` AS `design_id`,`psi_packaging_designs`.`design_date` AS `design_date`,`psi_packaging_designs`.`design_description` AS `design_description`,`psi_packaging_designs`.`draftlevel_id` AS `draftlevel_id`,`psi_packaging_designs`.`pkg_id` AS `pkg_id`,`psi_packaging_designs`.`design_image1` AS `design_image1`,`psi_packaging_designs`.`design_image2` AS `design_image2`,`psi_packaging_designs`.`design_filename1` AS `design_filename1`,`psi_packaging_designs`.`design_filename2` AS `design_filename2`,`psi_draftlevels`.`draftlevel_name` AS `draftlevel_name` from (`psi_packaging_designs` left join `psi_draftlevels` on((`psi_packaging_designs`.`draftlevel_id` = `psi_draftlevels`.`draftlevel_id`)));

CREATE VIEW `vwpsi_prjcount_per_projecttype` AS select `psi_project_types`.`prj_type_id` AS `prj_type_id`,`psi_project_types`.`prj_type_name` AS `prj_type_name`,ifnull(`totals`.`prj_count`,0) AS `prj_count` from (`psi_project_types` left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`prj_type_id` AS `prj_type_id` from `psi_projects` group by `psi_projects`.`prj_type_id`) `totals` on((`totals`.`prj_type_id` = `psi_project_types`.`prj_type_id`))) order by ifnull(`totals`.`prj_count`,0);

CREATE VIEW `vwpsi_prjcount_per_province` AS select distinct `psi_projects`.`province_id` AS `province_id`,`psi_provinces`.`province_name` AS `province_name`,ifnull(`totals`.`prj_count`,0) AS `prj_count` from ((`psi_projects` left join `psi_provinces` on((`psi_provinces`.`province_id` = `psi_projects`.`province_id`))) left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`province_id` AS `province_id` from `psi_projects` group by `psi_projects`.`province_id`) `totals` on((`totals`.`province_id` = `psi_projects`.`province_id`))) order by `prj_count`;

CREATE VIEW `vwpsi_prjcount_per_region` AS select `psi_regions`.`region_id` AS `region_id`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name`,ifnull(`totals`.`prj_count`,0) AS `prj_count` from (`psi_regions` left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`region_id` AS `region_id` from `psi_projects` group by `psi_projects`.`region_id`) `totals` on((`totals`.`region_id` = `psi_regions`.`region_id`))) order by `totals`.`prj_count`;

CREATE VIEW `vwpsi_prjcount_per_sector` AS select `psi_sectors`.`sector_name` AS `sector_name`,`psi_sectors`.`sector_id` AS `sector_id`,ifnull(`totals`.`prj_count`,0) AS `prj_count` from (`psi_sectors` left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`sector_id` AS `sector_id` from `psi_projects` group by `psi_projects`.`sector_id`) `totals` on((`psi_sectors`.`sector_id` = `totals`.`sector_id`))) order by `totals`.`prj_count`;

CREATE VIEW `vwpsi_prjcount_per_sector_no_empty` AS select `psi_sectors`.`sector_name` AS `sector_name`,`psi_sectors`.`sector_id` AS `sector_id`,`totals`.`prj_count` AS `prj_count` from (`psi_sectors` left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`sector_id` AS `sector_id` from (`psi_projects` left join `psi_sectors` on((`psi_sectors`.`sector_id` = `psi_projects`.`sector_id`))) group by `psi_projects`.`sector_id`) `totals` on((`psi_sectors`.`sector_id` = `totals`.`sector_id`))) order by `totals`.`prj_count`;

CREATE VIEW `vwpsi_prjcount_per_status` AS select `psi_project_status`.`prj_status_id` AS `prj_status_id`,`psi_project_status`.`prj_status_name` AS `prj_status_name`,ifnull(`totals`.`prj_count`,0) AS `prj_count` from (`psi_project_status` left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`prj_status_id` AS `prj_status_id` from `psi_projects` group by `psi_projects`.`prj_status_id`) `totals` on((`totals`.`prj_status_id` = `psi_project_status`.`prj_status_id`))) order by ifnull(`totals`.`prj_count`,0);

CREATE VIEW `vwpsi_prjcount_per_year_approved` AS select distinct `psi_projects`.`prj_year_approved` AS `prj_year_approved`,ifnull(`totals`.`prj_count`,0) AS `prj_count` from (`psi_projects` left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`prj_year_approved` AS `prj_year_approved` from `psi_projects` group by `psi_projects`.`prj_year_approved`) `totals` on((`psi_projects`.`prj_year_approved` = `totals`.`prj_year_approved`))) order by `psi_projects`.`prj_year_approved`;

CREATE VIEW `vwpsi_prjcount_per_year_per_type` AS select distinct `psi_projects`.`prj_year_approved` AS `prj_year_approved`,`type_counts`.`prj_count` AS `prj_count`,`type_counts`.`prj_type_id` AS `prj_type_id` from (`psi_projects` left join (select count(`psi_projects`.`prj_id`) AS `prj_count`,`psi_projects`.`prj_type_id` AS `prj_type_id`,`psi_projects`.`prj_year_approved` AS `prj_year_approved` from `psi_projects` group by `psi_projects`.`prj_type_id`,`psi_projects`.`prj_year_approved` order by `prj_count` desc) `type_counts` on((`type_counts`.`prj_year_approved` = `psi_projects`.`prj_year_approved`))) order by `psi_projects`.`prj_year_approved`;

CREATE VIEW `vwpsi_production_gross` AS select sum(`psi_project_production`.`production_gross`) AS `Sum_production_gross`,`psi_project_production`.`prjmon_id` AS `prjmon_id` from `psi_project_production` group by `psi_project_production`.`prjmon_id`;

CREATE VIEW `vwpsi_products` AS select `psi_project_products`.`prod_id` AS `prod_id`,`psi_project_products`.`prod_name` AS `prod_name`,`psi_project_products`.`prod_unit` AS `prod_unit`,`psi_project_products`.`unit_id` AS `unit_id`,`psi_project_products`.`prj_id` AS `prj_id`,`psi_project_products`.`encoder` AS `encoder`,`psi_project_products`.`date_encoded` AS `date_encoded`,`psi_project_products`.`updater` AS `updater`,`psi_project_products`.`last_updated` AS `last_updated`,`psi_units`.`unit_name` AS `unit_name` from (`psi_project_products` left join `psi_units` on((`psi_project_products`.`unit_id` = `psi_units`.`unit_id`)));

CREATE VIEW `vwpsi_project_beneficiaries` AS select `psi_project_beneficiaries`.`prj_ben_id` AS `prj_ben_id`,`psi_project_beneficiaries`.`prj_id` AS `prj_id`,`psi_project_beneficiaries`.`coop_id` AS `coop_id`,`vwpsi_cooperators`.`coop_name` AS `coop_name`,`vwpsi_cooperators`.`coop_p_fname` AS `coop_p_fname`,`vwpsi_cooperators`.`coop_p_mname` AS `coop_p_mname`,`vwpsi_cooperators`.`coop_p_lname` AS `coop_p_lname`,`vwpsi_cooperators`.`coop_p_name` AS `coop_p_name`,`vwpsi_cooperators`.`coop_address` AS `coop_address`,`vwpsi_cooperators`.`coop_phone` AS `coop_phone`,`vwpsi_cooperators`.`coop_fax` AS `coop_fax`,`vwpsi_cooperators`.`coop_mobile` AS `coop_mobile`,`vwpsi_cooperators`.`coop_email` AS `coop_email`,`vwpsi_cooperators`.`coop_website` AS `coop_website`,`vwpsi_cooperators`.`coop_year_established` AS `coop_year_established`,`vwpsi_cooperators`.`coop_reg_dti` AS `coop_reg_dti`,`vwpsi_cooperators`.`coop_reg_sec` AS `coop_reg_sec`,`vwpsi_cooperators`.`coop_reg_cda` AS `coop_reg_cda`,`vwpsi_cooperators`.`coop_reg_others` AS `coop_reg_others`,`vwpsi_cooperators`.`coop_reg_dti_date` AS `coop_reg_dti_date`,`vwpsi_cooperators`.`coop_reg_sec_date` AS `coop_reg_sec_date`,`vwpsi_cooperators`.`coop_reg_cda_date` AS `coop_reg_cda_date`,`vwpsi_cooperators`.`coop_products` AS `coop_products`,`vwpsi_cooperators`.`coop_brief` AS `coop_brief`,`vwpsi_cooperators`.`ot_cat1_id` AS `ot_cat1_id`,`vwpsi_cooperators`.`ot_cat2_id` AS `ot_cat2_id`,`vwpsi_cooperators`.`ot_cat3_id` AS `ot_cat3_id`,`vwpsi_cooperators`.`ot_cat1_name` AS `ot_cat1_name`,`vwpsi_cooperators`.`ot_cat2_name` AS `ot_cat2_name`,`vwpsi_cooperators`.`ot_cat3_name` AS `ot_cat3_name` from (`psi_project_beneficiaries` left join `vwpsi_cooperators` on((`psi_project_beneficiaries`.`coop_id` = `vwpsi_cooperators`.`coop_id`)));

CREATE VIEW `vwpsi_project_beneficiaries_list` AS select `psi_project_beneficiaries`.`prj_id` AS `prj_id`,group_concat(`vwpsi_cooperators`.`coop_name` separator ', ') AS `coop_names`,group_concat(`vwpsi_cooperators`.`coop_p_name` separator ', ') AS `coop_p_names` from (`psi_project_beneficiaries` left join `vwpsi_cooperators` on((`psi_project_beneficiaries`.`coop_id` = `vwpsi_cooperators`.`coop_id`))) group by `psi_project_beneficiaries`.`prj_id`;

CREATE VIEW `vwpsi_project_calibrations` AS select `psi_project_calibrations`.`cal_id` AS `cal_id`,`psi_project_calibrations`.`cal_month` AS `cal_month`,`psi_project_calibrations`.`cal_year` AS `cal_year`,`psi_project_calibrations`.`cal_no_parameters` AS `cal_no_parameters`,`psi_project_calibrations`.`cal_parameters` AS `cal_parameters`,`psi_project_calibrations`.`cal_no_tests_free` AS `cal_no_tests_free`,`psi_project_calibrations`.`cal_no_products` AS `cal_no_products`,`psi_project_calibrations`.`cal_products` AS `cal_products`,`psi_project_calibrations`.`cal_income` AS `cal_income`,`psi_project_calibrations`.`cal_cost` AS `cal_cost`,`psi_project_calibrations`.`cal_remarks` AS `cal_remarks`,`psi_project_calibrations`.`region_id` AS `region_id`,`psi_project_calibrations`.`ug_id` AS `ug_id`,`psi_project_calibrations`.`prj_id` AS `prj_id`,`psi_project_calibrations`.`lab_id` AS `lab_id`,`psi_project_calibrations`.`encoder` AS `encoder`,`psi_project_calibrations`.`date_encoded` AS `date_encoded`,`psi_project_calibrations`.`updater` AS `updater`,`psi_project_calibrations`.`last_updated` AS `last_updated`,`psi_project_calibrations`.`synched` AS `synched`,`psi_project_calibrations`.`sync_date` AS `sync_date`,`psi_laboratories`.`lab_name` AS `lab_name`,`psi_laboratories`.`lab_abbr` AS `lab_abbr`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from ((`psi_project_calibrations` left join `psi_laboratories` on((`psi_project_calibrations`.`lab_id` = `psi_laboratories`.`lab_id`))) left join `psi_usergroups` on((`psi_project_calibrations`.`ug_id` = `psi_usergroups`.`ug_id`)));

CREATE VIEW `vwpsi_project_collaborators` AS select `psi_project_collaborators`.`prj_col_id` AS `prj_col_id`,`psi_project_collaborators`.`prj_id` AS `prj_id`,`psi_project_collaborators`.`col_id` AS `col_id`,`psi_collaborators`.`col_name` AS `col_name`,`psi_collaborators`.`col_abbr` AS `col_abbr` from (`psi_project_collaborators` left join `psi_collaborators` on((`psi_project_collaborators`.`col_id` = `psi_collaborators`.`col_id`)));

CREATE VIEW `vwpsi_project_collaborators_list` AS select `psi_project_collaborators`.`prj_id` AS `prj_id`,group_concat(`vwpsi_collaborators`.`col_name` separator ', ') AS `collaborator_names` from (`psi_project_collaborators` left join `vwpsi_collaborators` on((`psi_project_collaborators`.`col_id` = `vwpsi_collaborators`.`col_id`))) group by `psi_project_collaborators`.`prj_id`;

CREATE VIEW `vwpsi_project_cost_per_province` AS select distinct `psi_projects`.`province_id` AS `province_id`,`psi_provinces`.`province_name` AS `province_name`,ifnull(`totals`.`prj_cost_total`,0) AS `prj_cost_total`,ifnull(`totals`.`prj_cost_benefactor_total`,0) AS `prj_cost_benefactor_total`,ifnull(`totals`.`prj_cost_other_total`,0) AS `prj_cost_other_total`,ifnull(`totals`.`prj_cost_nga_total`,0) AS `prj_cost_nga_total`,ifnull(`totals`.`prj_cost_lgu_total`,0) AS `prj_cost_lgu_total`,ifnull(`totals`.`prj_cost_local_total`,0) AS `prj_cost_local_total`,ifnull(`totals`.`prj_cost_external_total`,0) AS `prj_cost_external_total` from ((`psi_projects` left join `psi_provinces` on((`psi_provinces`.`province_id` = `psi_projects`.`province_id`))) left join (select sum(`psi_projects`.`prj_cost_setup`) AS `prj_cost_total`,sum(`psi_projects`.`prj_cost_benefactor`) AS `prj_cost_benefactor_total`,sum(`psi_projects`.`prj_cost_other`) AS `prj_cost_other_total`,sum(`psi_projects`.`prj_cost_nga`) AS `prj_cost_nga_total`,sum(`psi_projects`.`prj_cost_lgu`) AS `prj_cost_lgu_total`,sum(`psi_projects`.`prj_cost_local`) AS `prj_cost_local_total`,sum(`psi_projects`.`prj_cost_external`) AS `prj_cost_external_total`,`psi_projects`.`province_id` AS `province_id` from `psi_projects` group by `psi_projects`.`province_id`) `totals` on((`totals`.`province_id` = `psi_projects`.`province_id`))) order by `prj_cost_total`;

CREATE VIEW `vwpsi_project_cost_per_sector` AS select distinct `psi_projects`.`sector_id` AS `sector_id`,`psi_sectors`.`sector_name` AS `sector_name`,ifnull(`totals`.`prj_cost_total`,0) AS `prj_cost_total`,ifnull(`totals`.`prj_cost_benefactor_total`,0) AS `prj_cost_benefactor_total`,ifnull(`totals`.`prj_cost_other_total`,0) AS `prj_cost_other_total`,ifnull(`totals`.`prj_cost_nga_total`,0) AS `prj_cost_nga_total`,ifnull(`totals`.`prj_cost_lgu_total`,0) AS `prj_cost_lgu_total`,ifnull(`totals`.`prj_cost_local_total`,0) AS `prj_cost_local_total`,ifnull(`totals`.`prj_cost_external_total`,0) AS `prj_cost_external_total` from ((`psi_projects` left join `psi_sectors` on((`psi_sectors`.`sector_id` = `psi_projects`.`sector_id`))) left join (select sum(`psi_projects`.`prj_cost_setup`) AS `prj_cost_total`,sum(`psi_projects`.`prj_cost_benefactor`) AS `prj_cost_benefactor_total`,sum(`psi_projects`.`prj_cost_other`) AS `prj_cost_other_total`,sum(`psi_projects`.`prj_cost_nga`) AS `prj_cost_nga_total`,sum(`psi_projects`.`prj_cost_lgu`) AS `prj_cost_lgu_total`,sum(`psi_projects`.`prj_cost_local`) AS `prj_cost_local_total`,sum(`psi_projects`.`prj_cost_external`) AS `prj_cost_external_total`,`psi_projects`.`sector_id` AS `sector_id` from `psi_projects` group by `psi_projects`.`sector_id`) `totals` on((`totals`.`sector_id` = `psi_projects`.`sector_id`))) order by `prj_cost_total`;

CREATE VIEW `vwpsi_project_documents` AS select `psi_project_documents`.`doc_id` AS `doc_id`,`psi_project_documents`.`doc_file` AS `doc_file`,`psi_project_documents`.`doc_filename` AS `doc_filename`,`psi_project_documents`.`doc_remarks` AS `doc_remarks`,`psi_project_documents`.`prj_id` AS `prj_id`,`psi_project_documents`.`doctype_id` AS `doctype_id`,`psi_project_documents`.`encoder` AS `encoder`,`psi_project_documents`.`date_encoded` AS `date_encoded`,`psi_project_documents`.`updater` AS `updater`,`psi_project_documents`.`last_updated` AS `last_updated`,`psi_project_document_types`.`doctype_name` AS `doctype_name`,`psi_projects`.`ug_id` AS `ug_id` from ((`psi_project_documents` left join `psi_project_document_types` on((`psi_project_documents`.`doctype_id` = `psi_project_document_types`.`doctype_id`))) left join `psi_projects` on((`psi_project_documents`.`prj_id` = `psi_projects`.`prj_id`)));

CREATE VIEW `vwpsi_project_equipments` AS select `psi_equipment`.`prj_id` AS `prj_id`,`psi_equipment`.`brand_id` AS `brand_id`,`psi_equipment_brands`.`brand_name` AS `brand_name` from (`psi_equipment` left join `psi_equipment_brands` on((`psi_equipment`.`brand_id` = `psi_equipment_brands`.`brand_id`)));

CREATE VIEW `vwpsi_project_monitoring` AS select `psi_project_monitoring`.`prjmon_id` AS `prjmon_id`,`psi_project_monitoring`.`prj_id` AS `prj_id`,`psi_project_monitoring`.`prjmon_year` AS `prjmon_year`,`psi_project_monitoring`.`quarter_id` AS `quarter_id`,`psi_project_monitoring`.`prjmon_total_assets_land` AS `prjmon_total_assets_land`,`psi_project_monitoring`.`prjmon_total_assets_building` AS `prjmon_total_assets_building`,`psi_project_monitoring`.`prjmon_total_assets_equipment` AS `prjmon_total_assets_equipment`,`psi_project_monitoring`.`prjmon_total_assets_working_capital` AS `prjmon_total_assets_working_capital`,`psi_project_monitoring`.`prjmon_total_employment` AS `prjmon_total_employment`,`psi_project_monitoring`.`prjmon_dir_ch_regular_male` AS `prjmon_dir_ch_regular_male`,`psi_project_monitoring`.`prjmon_dir_ch_regular_female` AS `prjmon_dir_ch_regular_female`,`psi_project_monitoring`.`prjmon_dir_ch_regular_pwd` AS `prjmon_dir_ch_regular_pwd`,`psi_project_monitoring`.`prjmon_dir_ch_regular_senior` AS `prjmon_dir_ch_regular_senior`,`psi_project_monitoring`.`prjmon_dir_ch_part_time_male` AS `prjmon_dir_ch_part_time_male`,`psi_project_monitoring`.`prjmon_dir_ch_part_time_female` AS `prjmon_dir_ch_part_time_female`,`psi_project_monitoring`.`prjmon_dir_ch_part_time_pwd` AS `prjmon_dir_ch_part_time_pwd`,`psi_project_monitoring`.`prjmon_dir_ch_part_time_senior` AS `prjmon_dir_ch_part_time_senior`,`psi_project_monitoring`.`prjmon_dir_sh_regular_male` AS `prjmon_dir_sh_regular_male`,`psi_project_monitoring`.`prjmon_dir_sh_regular_female` AS `prjmon_dir_sh_regular_female`,`psi_project_monitoring`.`prjmon_dir_sh_regular_pwd` AS `prjmon_dir_sh_regular_pwd`,`psi_project_monitoring`.`prjmon_dir_sh_regular_senior` AS `prjmon_dir_sh_regular_senior`,`psi_project_monitoring`.`prjmon_dir_sh_part_time_male` AS `prjmon_dir_sh_part_time_male`,`psi_project_monitoring`.`prjmon_dir_sh_part_time_female` AS `prjmon_dir_sh_part_time_female`,`psi_project_monitoring`.`prjmon_dir_sh_part_time_pwd` AS `prjmon_dir_sh_part_time_pwd`,`psi_project_monitoring`.`prjmon_dir_sh_part_time_senior` AS `prjmon_dir_sh_part_time_senior`,`psi_project_monitoring`.`prjmon_indir_backward_male` AS `prjmon_indir_backward_male`,`psi_project_monitoring`.`prjmon_indir_backward_female` AS `prjmon_indir_backward_female`,`psi_project_monitoring`.`prjmon_indir_backward_pwd` AS `prjmon_indir_backward_pwd`,`psi_project_monitoring`.`prjmon_indir_backward_senior` AS `prjmon_indir_backward_senior`,`psi_project_monitoring`.`prjmon_indir_forward_male` AS `prjmon_indir_forward_male`,`psi_project_monitoring`.`prjmon_indir_forward_female` AS `prjmon_indir_forward_female`,`psi_project_monitoring`.`prjmon_indir_forward_pwd` AS `prjmon_indir_forward_pwd`,`psi_project_monitoring`.`prjmon_indir_forward_senior` AS `prjmon_indir_forward_senior`,`psi_project_monitoring`.`prjmon_volume_production_local` AS `prjmon_volume_production_local`,`psi_project_monitoring`.`prjmon_volume_production_export` AS `prjmon_volume_production_export`,`psi_project_monitoring`.`prjmon_gross_sales_local` AS `prjmon_gross_sales_local`,`psi_project_monitoring`.`prjmon_gross_sales_export` AS `prjmon_gross_sales_export`,`psi_project_monitoring`.`prjmon_countries_of_destination` AS `prjmon_countries_of_destination`,`psi_project_monitoring`.`prjmon_assistance_process` AS `prjmon_assistance_process`,`psi_project_monitoring`.`prjmon_assistance_equipment` AS `prjmon_assistance_equipment`,`psi_project_monitoring`.`prjmon_assistance_quality_control` AS `prjmon_assistance_quality_control`,`psi_project_monitoring`.`prjmon_assistance_packaging_labeling` AS `prjmon_assistance_packaging_labeling`,`psi_project_monitoring`.`prjmon_assistance_post_harvest` AS `prjmon_assistance_post_harvest`,`psi_project_monitoring`.`prjmon_assistance_marketing` AS `prjmon_assistance_marketing`,`psi_project_monitoring`.`prjmon_assistance_training` AS `prjmon_assistance_training`,`psi_project_monitoring`.`prjmon_assistance_consultancy` AS `prjmon_assistance_consultancy`,`psi_project_monitoring`.`prjmon_assistance_others` AS `prjmon_assistance_others`,`psi_project_monitoring`.`prjmon_problems_met` AS `prjmon_problems_met`,`psi_project_monitoring`.`prjmon_actions_taken` AS `prjmon_actions_taken`,`psi_project_monitoring`.`prjmon_improvement_action_plan` AS `prjmon_improvement_action_plan`,`psi_project_monitoring`.`prjmon_status_of_funds` AS `prjmon_status_of_funds`,`psi_project_monitoring`.`prjmon_reasons_for_termination` AS `prjmon_reasons_for_termination`,`psi_project_monitoring`.`prjmon_final_obligation` AS `prjmon_final_obligation`,`psi_project_monitoring`.`prjmon_impact_of_intervention` AS `prjmon_impact_of_intervention`,`psi_project_monitoring`.`prjmon_final_recommendation` AS `prjmon_final_recommendation`,`psi_project_monitoring`.`prjmon_expected_output` AS `prjmon_expected_output`,`psi_project_monitoring`.`prjmon_actual_accomplishment` AS `prjmon_actual_accomplishment`,`psi_project_monitoring`.`prjmon_output_remarks` AS `prjmon_output_remarks`,`psi_project_monitoring`.`prjmon_liquidation_cost` AS `prjmon_liquidation_cost`,`psi_project_monitoring`.`prjmon_liquidation_used` AS `prjmon_liquidation_used`,`psi_project_monitoring`.`prjmon_liquidation_date` AS `prjmon_liquidation_date`,`psi_project_monitoring`.`prjmon_liquidation_remarks` AS `prjmon_liquidation_remarks`,`psi_project_monitoring`.`prjmon_refund_amount` AS `prjmon_refund_amount`,`psi_project_monitoring`.`prjmon_refund_schedule_from` AS `prjmon_refund_schedule_from`,`psi_project_monitoring`.`prjmon_refund_schedule_to` AS `prjmon_refund_schedule_to`,`psi_project_monitoring`.`prjmon_refund_amount_due` AS `prjmon_refund_amount_due`,`psi_project_monitoring`.`prjmon_refund_date` AS `prjmon_refund_date`,`psi_project_monitoring`.`prjmon_refund_refunded` AS `prjmon_refund_refunded`,`psi_project_monitoring`.`prjmon_refund_unsettled` AS `prjmon_refund_unsettled`,`psi_project_monitoring`.`prjmon_refund_delay_date` AS `prjmon_refund_delay_date`,`psi_project_monitoring`.`prjmon_setup_amount` AS `prjmon_setup_amount`,`psi_project_monitoring`.`prjmon_funds_release_date` AS `prjmon_funds_release_date`,`psi_project_monitoring`.`prjmon_refund_period_from` AS `prjmon_refund_period_from`,`psi_project_monitoring`.`prjmon_refund_period_to` AS `prjmon_refund_period_to`,`psi_project_monitoring`.`prjmon_termination_date` AS `prjmon_termination_date`,`psi_project_monitoring`.`prjmon_remarks` AS `prjmon_remarks`,`psi_project_monitoring`.`prjmon_effectivity` AS `prjmon_effectivity`,`psi_project_monitoring`.`encoder` AS `encoder`,`psi_project_monitoring`.`date_encoded` AS `date_encoded`,`psi_project_monitoring`.`updater` AS `updater`,`psi_project_monitoring`.`last_updated` AS `last_updated`,`psi_project_monitoring`.`prjform_id` AS `prjform_id`,`psi_project_monitoring`.`prjmon_volume_product_name` AS `prjmon_volume_product_name`,`psi_project_monitoring`.`prjmon_volume_of_production` AS `prjmon_volume_of_production`,`psi_project_monitoring`.`prjmon_volume_gross_sales` AS `prjmon_volume_gross_sales`,`psi_project_monitoring`.`prjmon_emp_total` AS `prjmon_emp_total`,`psi_project_monitoring`.`prjmon_emp_male` AS `prjmon_emp_male`,`psi_project_monitoring`.`prjmon_emp_female` AS `prjmon_emp_female`,`psi_project_monitoring`.`prjmon_emp_pwd` AS `prjmon_emp_pwd`,`psi_project_monitoring`.`prjmon_emp_senior` AS `prjmon_emp_senior`,`psi_project_monitoring`.`prjmon_emp_in_total` AS `prjmon_emp_in_total`,`psi_project_monitoring`.`prjmon_emp_in_male` AS `prjmon_emp_in_male`,`psi_project_monitoring`.`prjmon_emp_in_female` AS `prjmon_emp_in_female`,`psi_project_monitoring`.`prjmon_emp_in_pwd` AS `prjmon_emp_in_pwd`,`psi_project_monitoring`.`prjmon_emp_in_senior` AS `prjmon_emp_in_senior`,`psi_project_monitoring`.`prjmon_emp_indirect_forward_male` AS `prjmon_emp_indirect_forward_male`,`psi_project_monitoring`.`prjmon_emp_indirect_forward_female` AS `prjmon_emp_indirect_forward_female`,`psi_project_monitoring`.`prjmon_emp_indirect_backward_male` AS `prjmon_emp_indirect_backward_male`,`psi_project_monitoring`.`prjmon_emp_indirect_backward_female` AS `prjmon_emp_indirect_backward_female`,`psi_project_monitoring`.`prjmon_market_existing` AS `prjmon_market_existing`,`psi_project_monitoring`.`prjmon_market_new` AS `prjmon_market_new`,`psi_project_monitoring`.`prjmon_improvement_production_efficiency` AS `prjmon_improvement_production_efficiency`,`psi_project_monitoring`.`prjmon_improvement_production_actual_accomplishment` AS `prjmon_improvement_production_actual_accomplishment`,`psi_project_monitoring`.`prjmon_improvement_production_remarks` AS `prjmon_improvement_production_remarks`,`psi_quarters`.`quarter_name` AS `quarter_name`,`psi_project_forms`.`prjform_name` AS `prjform_name`,`vwpsi_sales_gross`.`prjmon_gross_sales` AS `prjmon_gross_sales` from (((`psi_project_monitoring` left join `psi_quarters` on((`psi_project_monitoring`.`quarter_id` = `psi_quarters`.`quarter_id`))) left join `psi_project_forms` on((`psi_project_monitoring`.`prjform_id` = `psi_project_forms`.`prjform_id`))) left join `vwpsi_sales_gross` on((`vwpsi_sales_gross`.`prjmon_id` = `psi_project_monitoring`.`prjmon_id`)));

CREATE VIEW `vwpsi_project_monitoring_summary` AS select `vwpsi_project_monitoring`.`prjmon_id` AS `prjmon_id`,`vwpsi_project_monitoring`.`prj_id` AS `prj_id`,`vwpsi_project_monitoring`.`prjmon_year` AS `prjmon_year`,`vwpsi_project_monitoring`.`quarter_id` AS `quarter_id`,`vwpsi_project_monitoring`.`prjmon_total_assets_land` AS `prjmon_total_assets_land`,`vwpsi_project_monitoring`.`prjmon_total_assets_building` AS `prjmon_total_assets_building`,`vwpsi_project_monitoring`.`prjmon_total_assets_equipment` AS `prjmon_total_assets_equipment`,`vwpsi_project_monitoring`.`prjmon_total_assets_working_capital` AS `prjmon_total_assets_working_capital`,`vwpsi_project_monitoring`.`prjmon_total_employment` AS `prjmon_total_employment`,`vwpsi_project_monitoring`.`prjmon_dir_ch_regular_male` AS `prjmon_dir_ch_regular_male`,`vwpsi_project_monitoring`.`prjmon_dir_ch_regular_female` AS `prjmon_dir_ch_regular_female`,`vwpsi_project_monitoring`.`prjmon_dir_ch_regular_pwd` AS `prjmon_dir_ch_regular_pwd`,`vwpsi_project_monitoring`.`prjmon_dir_ch_regular_senior` AS `prjmon_dir_ch_regular_senior`,`vwpsi_project_monitoring`.`prjmon_dir_ch_part_time_male` AS `prjmon_dir_ch_part_time_male`,`vwpsi_project_monitoring`.`prjmon_dir_ch_part_time_female` AS `prjmon_dir_ch_part_time_female`,`vwpsi_project_monitoring`.`prjmon_dir_ch_part_time_pwd` AS `prjmon_dir_ch_part_time_pwd`,`vwpsi_project_monitoring`.`prjmon_dir_ch_part_time_senior` AS `prjmon_dir_ch_part_time_senior`,`vwpsi_project_monitoring`.`prjmon_dir_sh_regular_male` AS `prjmon_dir_sh_regular_male`,`vwpsi_project_monitoring`.`prjmon_dir_sh_regular_female` AS `prjmon_dir_sh_regular_female`,`vwpsi_project_monitoring`.`prjmon_dir_sh_regular_pwd` AS `prjmon_dir_sh_regular_pwd`,`vwpsi_project_monitoring`.`prjmon_dir_sh_regular_senior` AS `prjmon_dir_sh_regular_senior`,`vwpsi_project_monitoring`.`prjmon_dir_sh_part_time_male` AS `prjmon_dir_sh_part_time_male`,`vwpsi_project_monitoring`.`prjmon_dir_sh_part_time_female` AS `prjmon_dir_sh_part_time_female`,`vwpsi_project_monitoring`.`prjmon_dir_sh_part_time_pwd` AS `prjmon_dir_sh_part_time_pwd`,`vwpsi_project_monitoring`.`prjmon_dir_sh_part_time_senior` AS `prjmon_dir_sh_part_time_senior`,`vwpsi_project_monitoring`.`prjmon_indir_backward_male` AS `prjmon_indir_backward_male`,`vwpsi_project_monitoring`.`prjmon_indir_backward_female` AS `prjmon_indir_backward_female`,`vwpsi_project_monitoring`.`prjmon_indir_backward_pwd` AS `prjmon_indir_backward_pwd`,`vwpsi_project_monitoring`.`prjmon_indir_backward_senior` AS `prjmon_indir_backward_senior`,`vwpsi_project_monitoring`.`prjmon_indir_forward_male` AS `prjmon_indir_forward_male`,`vwpsi_project_monitoring`.`prjmon_indir_forward_female` AS `prjmon_indir_forward_female`,`vwpsi_project_monitoring`.`prjmon_indir_forward_pwd` AS `prjmon_indir_forward_pwd`,`vwpsi_project_monitoring`.`prjmon_indir_forward_senior` AS `prjmon_indir_forward_senior`,`vwpsi_project_monitoring`.`prjmon_volume_production_local` AS `prjmon_volume_production_local`,`vwpsi_project_monitoring`.`prjmon_volume_production_export` AS `prjmon_volume_production_export`,`vwpsi_project_monitoring`.`prjmon_gross_sales_local` AS `prjmon_gross_sales_local`,`vwpsi_project_monitoring`.`prjmon_gross_sales_export` AS `prjmon_gross_sales_export`,`vwpsi_project_monitoring`.`prjmon_countries_of_destination` AS `prjmon_countries_of_destination`,`vwpsi_project_monitoring`.`prjmon_assistance_process` AS `prjmon_assistance_process`,`vwpsi_project_monitoring`.`prjmon_assistance_equipment` AS `prjmon_assistance_equipment`,`vwpsi_project_monitoring`.`prjmon_assistance_quality_control` AS `prjmon_assistance_quality_control`,`vwpsi_project_monitoring`.`prjmon_assistance_packaging_labeling` AS `prjmon_assistance_packaging_labeling`,`vwpsi_project_monitoring`.`prjmon_assistance_post_harvest` AS `prjmon_assistance_post_harvest`,`vwpsi_project_monitoring`.`prjmon_assistance_marketing` AS `prjmon_assistance_marketing`,`vwpsi_project_monitoring`.`prjmon_assistance_training` AS `prjmon_assistance_training`,`vwpsi_project_monitoring`.`prjmon_assistance_consultancy` AS `prjmon_assistance_consultancy`,`vwpsi_project_monitoring`.`prjmon_assistance_others` AS `prjmon_assistance_others`,`vwpsi_project_monitoring`.`prjmon_problems_met` AS `prjmon_problems_met`,`vwpsi_project_monitoring`.`prjmon_actions_taken` AS `prjmon_actions_taken`,`vwpsi_project_monitoring`.`prjmon_improvement_action_plan` AS `prjmon_improvement_action_plan`,`vwpsi_project_monitoring`.`prjmon_status_of_funds` AS `prjmon_status_of_funds`,`vwpsi_project_monitoring`.`prjmon_reasons_for_termination` AS `prjmon_reasons_for_termination`,`vwpsi_project_monitoring`.`prjmon_final_obligation` AS `prjmon_final_obligation`,`vwpsi_project_monitoring`.`prjmon_impact_of_intervention` AS `prjmon_impact_of_intervention`,`vwpsi_project_monitoring`.`prjmon_final_recommendation` AS `prjmon_final_recommendation`,`vwpsi_project_monitoring`.`prjmon_expected_output` AS `prjmon_expected_output`,`vwpsi_project_monitoring`.`prjmon_actual_accomplishment` AS `prjmon_actual_accomplishment`,`vwpsi_project_monitoring`.`prjmon_output_remarks` AS `prjmon_output_remarks`,`vwpsi_project_monitoring`.`prjmon_liquidation_cost` AS `prjmon_liquidation_cost`,`vwpsi_project_monitoring`.`prjmon_liquidation_used` AS `prjmon_liquidation_used`,`vwpsi_project_monitoring`.`prjmon_liquidation_date` AS `prjmon_liquidation_date`,`vwpsi_project_monitoring`.`prjmon_liquidation_remarks` AS `prjmon_liquidation_remarks`,`vwpsi_project_monitoring`.`prjmon_refund_amount` AS `prjmon_refund_amount`,`vwpsi_project_monitoring`.`prjmon_refund_schedule_from` AS `prjmon_refund_schedule_from`,`vwpsi_project_monitoring`.`prjmon_refund_schedule_to` AS `prjmon_refund_schedule_to`,`vwpsi_project_monitoring`.`prjmon_refund_amount_due` AS `prjmon_refund_amount_due`,`vwpsi_project_monitoring`.`prjmon_refund_date` AS `prjmon_refund_date`,`vwpsi_project_monitoring`.`prjmon_refund_refunded` AS `prjmon_refund_refunded`,`vwpsi_project_monitoring`.`prjmon_refund_unsettled` AS `prjmon_refund_unsettled`,`vwpsi_project_monitoring`.`prjmon_refund_delay_date` AS `prjmon_refund_delay_date`,`vwpsi_project_monitoring`.`prjmon_setup_amount` AS `prjmon_setup_amount`,`vwpsi_project_monitoring`.`prjmon_funds_release_date` AS `prjmon_funds_release_date`,`vwpsi_project_monitoring`.`prjmon_refund_period_from` AS `prjmon_refund_period_from`,`vwpsi_project_monitoring`.`prjmon_refund_period_to` AS `prjmon_refund_period_to`,`vwpsi_project_monitoring`.`prjmon_termination_date` AS `prjmon_termination_date`,`vwpsi_project_monitoring`.`prjmon_remarks` AS `prjmon_remarks`,`vwpsi_project_monitoring`.`prjmon_effectivity` AS `prjmon_effectivity`,`vwpsi_project_monitoring`.`encoder` AS `encoder`,`vwpsi_project_monitoring`.`date_encoded` AS `date_encoded`,`vwpsi_project_monitoring`.`updater` AS `updater`,`vwpsi_project_monitoring`.`last_updated` AS `last_updated`,`vwpsi_project_monitoring`.`prjform_id` AS `prjform_id`,`vwpsi_project_monitoring`.`prjmon_volume_product_name` AS `prjmon_volume_product_name`,`vwpsi_project_monitoring`.`prjmon_volume_of_production` AS `prjmon_volume_of_production`,`vwpsi_project_monitoring`.`prjmon_volume_gross_sales` AS `prjmon_volume_gross_sales`,`vwpsi_project_monitoring`.`prjmon_emp_total` AS `prjmon_emp_total`,`vwpsi_project_monitoring`.`prjmon_emp_male` AS `prjmon_emp_male`,`vwpsi_project_monitoring`.`prjmon_emp_female` AS `prjmon_emp_female`,`vwpsi_project_monitoring`.`prjmon_emp_pwd` AS `prjmon_emp_pwd`,`vwpsi_project_monitoring`.`prjmon_emp_indirect_forward_male` AS `prjmon_emp_indirect_forward_male`,`vwpsi_project_monitoring`.`prjmon_emp_indirect_forward_female` AS `prjmon_emp_indirect_forward_female`,`vwpsi_project_monitoring`.`prjmon_emp_indirect_backward_male` AS `prjmon_emp_indirect_backward_male`,`vwpsi_project_monitoring`.`prjmon_emp_indirect_backward_female` AS `prjmon_emp_indirect_backward_female`,`vwpsi_project_monitoring`.`prjmon_market_existing` AS `prjmon_market_existing`,`vwpsi_project_monitoring`.`prjmon_market_new` AS `prjmon_market_new`,`vwpsi_project_monitoring`.`prjmon_improvement_production_efficiency` AS `prjmon_improvement_production_efficiency`,`vwpsi_project_monitoring`.`quarter_name` AS `quarter_name`,`vwpsi_project_monitoring`.`prjform_name` AS `prjform_name`,`vwpsi_projects`.`prj_title` AS `prj_title`,`vwpsi_projects`.`prj_code` AS `prj_code`,`vwpsi_projects`.`prj_year_approved` AS `prj_year_approved`,`vwpsi_projects`.`prj_objective` AS `prj_objective`,`vwpsi_projects`.`prj_expected_output` AS `prj_expected_output`,`vwpsi_projects`.`prj_product_line` AS `prj_product_line`,`vwpsi_projects`.`prj_cost_setup` AS `prj_cost_setup`,`vwpsi_projects`.`prj_cost_benefactor` AS `prj_cost_benefactor`,`vwpsi_projects`.`prj_cost_other` AS `prj_cost_other`,`vwpsi_projects`.`prj_intervention` AS `prj_intervention`,`vwpsi_projects`.`prj_longitude` AS `prj_longitude`,`vwpsi_projects`.`prj_latitude` AS `prj_latitude`,`vwpsi_projects`.`prj_elevation` AS `prj_elevation`,`vwpsi_projects`.`prj_type_id` AS `prj_type_id`,`vwpsi_projects`.`prj_status_id` AS `prj_status_id`,`vwpsi_projects`.`prj_remarks` AS `prj_remarks`,`vwpsi_projects`.`ru_id` AS `ru_id`,`vwpsi_projects`.`prj_address` AS `prj_address`,`vwpsi_projects`.`province_id` AS `province_id`,`vwpsi_projects`.`city_id` AS `city_id`,`vwpsi_projects`.`barangay_id` AS `barangay_id`,`vwpsi_projects`.`ug_id` AS `ug_id`,`vwpsi_projects`.`prj_fund_release_date` AS `prj_fund_release_date`,`vwpsi_projects`.`prj_refund_period_from` AS `prj_refund_period_from`,`vwpsi_projects`.`prj_refund_period_to` AS `prj_refund_period_to`,`vwpsi_projects`.`prj_province` AS `prj_province`,`vwpsi_projects`.`prj_city` AS `prj_city`,`vwpsi_projects`.`prj_barangay` AS `prj_barangay`,`vwpsi_projects`.`sector_id` AS `sector_id`,`vwpsi_projects`.`sector_name` AS `sector_name`,`vwpsi_projects`.`prj_pis_total_assets_land` AS `prj_pis_total_assets_land`,`vwpsi_projects`.`prj_pis_total_assets_building` AS `prj_pis_total_assets_building`,`vwpsi_projects`.`prj_pis_total_assets_equipment` AS `prj_pis_total_assets_equipment`,`vwpsi_projects`.`prj_pis_total_assets_working_capital` AS `prj_pis_total_assets_working_capital`,`vwpsi_projects`.`prj_pis_total_employment` AS `prj_pis_total_employment`,`vwpsi_projects`.`prj_pis_dir_ch_regular_male` AS `prj_pis_dir_ch_regular_male`,`vwpsi_projects`.`prj_pis_dir_ch_regular_female` AS `prj_pis_dir_ch_regular_female`,`vwpsi_projects`.`prj_pis_dir_ch_regular_pwd` AS `prj_pis_dir_ch_regular_pwd`,`vwpsi_projects`.`prj_pis_dir_ch_regular_senior` AS `prj_pis_dir_ch_regular_senior`,`vwpsi_projects`.`prj_pis_dir_ch_part_time_male` AS `prj_pis_dir_ch_part_time_male`,`vwpsi_projects`.`prj_pis_dir_ch_part_time_female` AS `prj_pis_dir_ch_part_time_female`,`vwpsi_projects`.`prj_pis_dir_ch_part_time_pwd` AS `prj_pis_dir_ch_part_time_pwd`,`vwpsi_projects`.`prj_pis_dir_ch_part_time_senior` AS `prj_pis_dir_ch_part_time_senior`,`vwpsi_projects`.`prj_pis_dir_sh_regular_male` AS `prj_pis_dir_sh_regular_male`,`vwpsi_projects`.`prj_pis_dir_sh_regular_female` AS `prj_pis_dir_sh_regular_female`,`vwpsi_projects`.`prj_pis_dir_sh_regular_pwd` AS `prj_pis_dir_sh_regular_pwd`,`vwpsi_projects`.`prj_pis_dir_sh_regular_senior` AS `prj_pis_dir_sh_regular_senior`,`vwpsi_projects`.`prj_pis_dir_sh_part_time_male` AS `prj_pis_dir_sh_part_time_male`,`vwpsi_projects`.`prj_pis_dir_sh_part_time_female` AS `prj_pis_dir_sh_part_time_female`,`vwpsi_projects`.`prj_pis_dir_sh_part_time_pwd` AS `prj_pis_dir_sh_part_time_pwd`,`vwpsi_projects`.`prj_pis_dir_sh_part_time_senior` AS `prj_pis_dir_sh_part_time_senior`,`vwpsi_projects`.`prj_pis_indir_backward_male` AS `prj_pis_indir_backward_male`,`vwpsi_projects`.`prj_pis_indir_backward_female` AS `prj_pis_indir_backward_female`,`vwpsi_projects`.`prj_pis_indir_backward_pwd` AS `prj_pis_indir_backward_pwd`,`vwpsi_projects`.`prj_pis_indir_backward_senior` AS `prj_pis_indir_backward_senior`,`vwpsi_projects`.`prj_pis_indir_forward_male` AS `prj_pis_indir_forward_male`,`vwpsi_projects`.`prj_pis_indir_forward_female` AS `prj_pis_indir_forward_female`,`vwpsi_projects`.`prj_pis_indir_forward_pwd` AS `prj_pis_indir_forward_pwd`,`vwpsi_projects`.`prj_pis_indir_forward_senior` AS `prj_pis_indir_forward_senior`,`vwpsi_projects`.`prj_pis_volume_production_local` AS `prj_pis_volume_production_local`,`vwpsi_projects`.`prj_pis_volume_production_export` AS `prj_pis_volume_production_export`,`vwpsi_projects`.`prj_pis_gross_sales_local` AS `prj_pis_gross_sales_local`,`vwpsi_projects`.`prj_pis_gross_sales_export` AS `prj_pis_gross_sales_export`,`vwpsi_projects`.`prj_pis_countries_of_destination` AS `prj_pis_countries_of_destination`,`vwpsi_projects`.`prj_pis_assistance_conceptualization` AS `prj_pis_assistance_conceptualization`,`vwpsi_projects`.`prj_pis_assistance_proposal_preparation` AS `prj_pis_assistance_proposal_preparation`,`vwpsi_projects`.`prj_pis_assistance_process` AS `prj_pis_assistance_process`,`vwpsi_projects`.`prj_pis_assistance_equipment` AS `prj_pis_assistance_equipment`,`vwpsi_projects`.`prj_pis_assistance_quality_control` AS `prj_pis_assistance_quality_control`,`vwpsi_projects`.`prj_pis_assistance_packaging_labeling` AS `prj_pis_assistance_packaging_labeling`,`vwpsi_projects`.`prj_pis_assistance_post_harvest` AS `prj_pis_assistance_post_harvest`,`vwpsi_projects`.`prj_pis_assistance_marketing` AS `prj_pis_assistance_marketing`,`vwpsi_projects`.`prj_pis_assistance_training` AS `prj_pis_assistance_training`,`vwpsi_projects`.`prj_pis_assistance_consultancy` AS `prj_pis_assistance_consultancy`,`vwpsi_projects`.`prj_pis_assistance_others` AS `prj_pis_assistance_others`,`vwpsi_projects`.`prj_pis_remarks` AS `prj_pis_remarks`,`vwpsi_projects`.`province_name` AS `province_name`,`vwpsi_projects`.`region_id` AS `region_id`,`vwpsi_projects`.`region_name` AS `region_name`,`vwpsi_projects`.`city_name` AS `city_name`,`vwpsi_projects`.`district_id` AS `district_id`,`vwpsi_projects`.`district_name` AS `district_name`,`vwpsi_projects`.`barangay_name` AS `barangay_name`,`vwpsi_projects`.`prj_type_name` AS `prj_type_name`,`vwpsi_projects`.`prj_status_name` AS `prj_status_name`,`vwpsi_projects`.`ug_name` AS `ug_name`,`vwpsi_projects`.`rep_total_amount` AS `rep_total_amount`,`vwpsi_projects`.`rep_refund_rate` AS `rep_refund_rate`,`vwpsi_projects`.`rep_total_due` AS `rep_total_due`,`vwpsi_projects`.`rep_total_paid` AS `rep_total_paid`,`vwpsi_projects`.`sector_list` AS `sector_list`,`vwpsi_projects`.`prj_sector_list` AS `prj_sector_list`,`vwpsi_projects`.`coop_names` AS `coop_names`,`vwpsi_projects`.`coop_p_names` AS `coop_p_names`,`vwpsi_projects`.`collaborator_names` AS `collaborator_names`,`vwpsi_projects`.`prj_duration_from` AS `prj_duration_from`,`vwpsi_projects`.`prj_duration_to` AS `prj_duration_to`,`vwpsi_projects`.`prj_fundingsource_local` AS `prj_fundingsource_local`,`vwpsi_projects`.`prj_fundingsource_external` AS `prj_fundingsource_external`,`vwpsi_projects`.`prj_cofunded_nga` AS `prj_cofunded_nga`,`vwpsi_projects`.`prj_cofunded_lgu` AS `prj_cofunded_lgu`,`vwpsi_projects`.`prj_cost_nga` AS `prj_cost_nga`,`vwpsi_projects`.`prj_cost_lgu` AS `prj_cost_lgu`,`vwpsi_projects`.`prj_cost_local` AS `prj_cost_local`,`vwpsi_projects`.`prj_cost_external` AS `prj_cost_external`,`vwpsi_projects`.`prj_cost_benefactor_desc` AS `prj_cost_benefactor_desc`,`vwpsi_projects`.`prj_startup_assistance` AS `prj_startup_assistance`,`vwpsi_projects`.`region_code` AS `region_code`,`vwpsi_projects`.`region_text` AS `region_text`,`vwpsi_project_monitoring`.`prjmon_improvement_production_actual_accomplishment` AS `prjmon_improvement_production_actual_accomplishment`,`vwpsi_project_monitoring`.`prjmon_improvement_production_remarks` AS `prjmon_improvement_production_remarks`,`vwpsi_project_monitoring`.`prjmon_emp_senior` AS `prjmon_emp_senior`,`vwpsi_project_monitoring`.`prjmon_emp_in_total` AS `prjmon_emp_in_total`,`vwpsi_project_monitoring`.`prjmon_emp_in_male` AS `prjmon_emp_in_male`,`vwpsi_project_monitoring`.`prjmon_emp_in_female` AS `prjmon_emp_in_female`,`vwpsi_project_monitoring`.`prjmon_emp_in_pwd` AS `prjmon_emp_in_pwd`,`vwpsi_project_monitoring`.`prjmon_emp_in_senior` AS `prjmon_emp_in_senior` from (`vwpsi_project_monitoring` left join `vwpsi_projects` on((`vwpsi_project_monitoring`.`prj_id` = `vwpsi_projects`.`prj_id`)));

CREATE VIEW `vwpsi_project_pis` AS select `psi_project_pis`.`prjpis_id` AS `prjpis_id`,`psi_project_pis`.`prj_id` AS `prj_id`,`psi_project_pis`.`prjpis_year` AS `prjpis_year`,`psi_project_pis`.`sem_id` AS `sem_id`,`psi_project_pis`.`prjpis_total_assets_land` AS `prjpis_total_assets_land`,`psi_project_pis`.`prjpis_total_assets_building` AS `prjpis_total_assets_building`,`psi_project_pis`.`prjpis_total_assets_equipment` AS `prjpis_total_assets_equipment`,`psi_project_pis`.`prjpis_total_assets_working_capital` AS `prjpis_total_assets_working_capital`,`psi_project_pis`.`prjpis_total_employment` AS `prjpis_total_employment`,`psi_project_pis`.`prjpis_dir_ch_regular_male` AS `prjpis_dir_ch_regular_male`,`psi_project_pis`.`prjpis_dir_ch_regular_female` AS `prjpis_dir_ch_regular_female`,`psi_project_pis`.`prjpis_dir_ch_regular_pwd` AS `prjpis_dir_ch_regular_pwd`,`psi_project_pis`.`prjpis_dir_ch_regular_senior` AS `prjpis_dir_ch_regular_senior`,`psi_project_pis`.`prjpis_dir_ch_part_time_male` AS `prjpis_dir_ch_part_time_male`,`psi_project_pis`.`prjpis_dir_ch_part_time_female` AS `prjpis_dir_ch_part_time_female`,`psi_project_pis`.`prjpis_dir_ch_part_time_pwd` AS `prjpis_dir_ch_part_time_pwd`,`psi_project_pis`.`prjpis_dir_ch_part_time_senior` AS `prjpis_dir_ch_part_time_senior`,`psi_project_pis`.`prjpis_dir_sh_regular_male` AS `prjpis_dir_sh_regular_male`,`psi_project_pis`.`prjpis_dir_sh_regular_female` AS `prjpis_dir_sh_regular_female`,`psi_project_pis`.`prjpis_dir_sh_regular_pwd` AS `prjpis_dir_sh_regular_pwd`,`psi_project_pis`.`prjpis_dir_sh_regular_senior` AS `prjpis_dir_sh_regular_senior`,`psi_project_pis`.`prjpis_dir_sh_part_time_male` AS `prjpis_dir_sh_part_time_male`,`psi_project_pis`.`prjpis_dir_sh_part_time_female` AS `prjpis_dir_sh_part_time_female`,`psi_project_pis`.`prjpis_dir_sh_part_time_pwd` AS `prjpis_dir_sh_part_time_pwd`,`psi_project_pis`.`prjpis_dir_sh_part_time_senior` AS `prjpis_dir_sh_part_time_senior`,`psi_project_pis`.`prjpis_indir_backward_male` AS `prjpis_indir_backward_male`,`psi_project_pis`.`prjpis_indir_backward_female` AS `prjpis_indir_backward_female`,`psi_project_pis`.`prjpis_indir_backward_pwd` AS `prjpis_indir_backward_pwd`,`psi_project_pis`.`prjpis_indir_backward_senior` AS `prjpis_indir_backward_senior`,`psi_project_pis`.`prjpis_indir_forward_male` AS `prjpis_indir_forward_male`,`psi_project_pis`.`prjpis_indir_forward_female` AS `prjpis_indir_forward_female`,`psi_project_pis`.`prjpis_indir_forward_pwd` AS `prjpis_indir_forward_pwd`,`psi_project_pis`.`prjpis_indir_forward_senior` AS `prjpis_indir_forward_senior`,`psi_project_pis`.`prjpis_volume_production_local` AS `prjpis_volume_production_local`,`psi_project_pis`.`prjpis_volume_production_export` AS `prjpis_volume_production_export`,`psi_project_pis`.`prjpis_gross_sales_local` AS `prjpis_gross_sales_local`,`psi_project_pis`.`prjpis_gross_sales_export` AS `prjpis_gross_sales_export`,`psi_project_pis`.`prjpis_countries_of_destination` AS `prjpis_countries_of_destination`,`psi_project_pis`.`prjpis_assistance_process` AS `prjpis_assistance_process`,`psi_project_pis`.`prjpis_assistance_equipment` AS `prjpis_assistance_equipment`,`psi_project_pis`.`prjpis_assistance_quality_control` AS `prjpis_assistance_quality_control`,`psi_project_pis`.`prjpis_assistance_packaging_labeling` AS `prjpis_assistance_packaging_labeling`,`psi_project_pis`.`prjpis_assistance_post_harvest` AS `prjpis_assistance_post_harvest`,`psi_project_pis`.`prjpis_assistance_marketing` AS `prjpis_assistance_marketing`,`psi_project_pis`.`prjpis_assistance_training_text` AS `prjpis_assistance_training_text`,`psi_project_pis`.`prjpis_assistance_consultancy_text` AS `prjpis_assistance_consultancy_text`,`psi_project_pis`.`prjpis_assistance_others_text` AS `prjpis_assistance_others_text`,`psi_project_pis`.`prjpis_remarks` AS `prjpis_remarks`,`psi_project_pis`.`encoder` AS `encoder`,`psi_project_pis`.`date_encoded` AS `date_encoded`,`psi_project_pis`.`updater` AS `updater`,`psi_project_pis`.`last_updated` AS `last_updated`,`psi_project_pis`.`prjpis_assistance_training` AS `prjpis_assistance_training`,`psi_project_pis`.`prjpis_assistance_consultancy` AS `prjpis_assistance_consultancy`,`psi_project_pis`.`prjpis_assistance_process_text` AS `prjpis_assistance_process_text`,`psi_project_pis`.`prjpis_assistance_quality_control_text` AS `prjpis_assistance_quality_control_text`,`psi_project_pis`.`prjpis_assistance_post_harvest_text` AS `prjpis_assistance_post_harvest_text`,`psi_project_pis`.`prjpis_assistance_marketing_text` AS `prjpis_assistance_marketing_text`,`psi_project_pis`.`prjpis_assistance_others` AS `prjpis_assistance_others`,`psi_semesters`.`sem_name` AS `sem_name` from (`psi_project_pis` left join `psi_semesters` on((`psi_project_pis`.`sem_id` = `psi_semesters`.`sem_id`)));

CREATE VIEW `vwpsi_project_sats` AS select `psi_project_sats`.`sat_id` AS `sat_id`,`psi_project_sats`.`sat_date` AS `sat_date`,year(`psi_project_sats`.`sat_date`) AS `sat_year`,month(`psi_project_sats`.`sat_date`) AS `sat_month`,`psi_project_sats`.`sat_file` AS `sat_file`,`psi_project_sats`.`sat_filename` AS `sat_filename`,`psi_project_sats`.`sat_remarks` AS `sat_remarks`,`psi_project_sats`.`satt_id` AS `satt_id`,`psi_project_sats`.`prj_id` AS `prj_id`,`psi_project_sats`.`encoder` AS `encoder`,`psi_project_sats`.`date_encoded` AS `date_encoded`,`psi_project_sats`.`updater` AS `updater`,`psi_project_sats`.`last_updated` AS `last_updated`,`psi_project_sats`.`region_id` AS `region_id`,`psi_sattypes`.`satt_name` AS `satt_name` from (`psi_project_sats` left join `psi_sattypes` on((`psi_sattypes`.`satt_id` = `psi_project_sats`.`satt_id`)));

CREATE VIEW `vwpsi_project_sector_list` AS select `psi_project_sectors`.`prj_id` AS `prj_id`,group_concat(`psi_sectors`.`sector_name` separator ', ') AS `sector_list` from (`psi_project_sectors` left join `psi_sectors` on((`psi_project_sectors`.`sector_id` = `psi_sectors`.`sector_id`))) group by `psi_project_sectors`.`prj_id`;

CREATE VIEW `vwpsi_project_sectors` AS select `psi_project_sectors`.`prjsect_id` AS `prjsect_id`,`psi_project_sectors`.`prj_id` AS `prj_id`,`psi_project_sectors`.`sector_id` AS `sector_id`,`psi_sectors`.`sector_name` AS `sector_name` from (`psi_project_sectors` left join `psi_sectors` on((`psi_project_sectors`.`sector_id` = `psi_sectors`.`sector_id`)));

CREATE VIEW `vwpsi_project_sites` AS select `psi_project_sites`.`prj_site_id` AS `prj_site_id`,`psi_project_sites`.`prj_site_date` AS `prj_site_date`,year(`psi_project_sites`.`prj_site_date`) AS `prj_site_yr`,month(`psi_project_sites`.`prj_site_date`) AS `prj_site_mo`,`psi_project_sites`.`prj_site_remarks` AS `prj_site_remarks`,`psi_project_sites`.`prj_site_longitude` AS `prj_site_longitude`,`psi_project_sites`.`prj_site_latitude` AS `prj_site_latitude`,`psi_project_sites`.`prj_site_elevation` AS `prj_site_elevation`,`psi_project_sites`.`prj_site_address` AS `prj_site_address`,`psi_project_sites`.`province_id` AS `province_id`,`psi_project_sites`.`city_id` AS `city_id`,`psi_project_sites`.`barangay_id` AS `barangay_id`,`psi_project_sites`.`brand_id` AS `brand_id`,`psi_project_sites`.`prj_id` AS `prj_id`,`psi_project_sites`.`encoder` AS `encoder`,`psi_project_sites`.`date_encoded` AS `date_encoded`,`psi_project_sites`.`updater` AS `updater`,`psi_project_sites`.`last_updated` AS `last_updated`,`psi_equipment_brands`.`brand_name` AS `brand_name`,`psi_provinces`.`region_id` AS `region_id`,`psi_provinces`.`province_name` AS `province_name`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name`,`psi_cities`.`city_name` AS `city_name`,`psi_cities`.`district_id` AS `district_id`,`psi_districts`.`district_name` AS `district_name`,`psi_barangays`.`barangay_name` AS `barangay_name` from ((((((`psi_project_sites` left join `psi_equipment_brands` on((`psi_project_sites`.`brand_id` = `psi_equipment_brands`.`brand_id`))) left join `psi_provinces` on((`psi_project_sites`.`province_id` = `psi_provinces`.`province_id`))) left join `psi_regions` on((`psi_provinces`.`region_id` = `psi_regions`.`region_id`))) left join `psi_cities` on((`psi_project_sites`.`city_id` = `psi_cities`.`city_id`))) left join `psi_districts` on((`psi_cities`.`district_id` = `psi_districts`.`district_id`))) left join `psi_barangays` on((`psi_project_sites`.`barangay_id` = `psi_barangays`.`barangay_id`)));

CREATE VIEW `vwpsi_project_videos` AS select `psi_project_videos`.`vid_id` AS `vid_id`,`psi_project_videos`.`vid_date` AS `vid_date`,year(`psi_project_videos`.`vid_date`) AS `vid_year`,month(`psi_project_videos`.`vid_date`) AS `vid_month`,`psi_project_videos`.`vid_title` AS `vid_title`,`psi_project_videos`.`vid_file` AS `vid_file`,`psi_project_videos`.`vid_filename` AS `vid_filename`,`psi_project_videos`.`vid_remarks` AS `vid_remarks`,`psi_project_videos`.`prj_id` AS `prj_id`,`psi_project_videos`.`encoder` AS `encoder`,`psi_project_videos`.`date_encoded` AS `date_encoded`,`psi_project_videos`.`updater` AS `updater`,`psi_project_videos`.`last_updated` AS `last_updated` from `psi_project_videos`;

CREATE VIEW `vwpsi_projects` AS select `psi_projects`.`prj_id` AS `prj_id`,`psi_projects`.`prj_title` AS `prj_title`,`psi_projects`.`prj_code` AS `prj_code`,`psi_projects`.`prj_year_approved` AS `prj_year_approved`,`psi_projects`.`prj_duration_from` AS `prj_duration_from`,`psi_projects`.`prj_duration_to` AS `prj_duration_to`,`psi_projects`.`prj_objective` AS `prj_objective`,`psi_projects`.`prj_expected_output` AS `prj_expected_output`,`psi_projects`.`prj_product_line` AS `prj_product_line`,`psi_projects`.`prj_cost_setup` AS `prj_cost_setup`,`psi_projects`.`prj_cost_benefactor` AS `prj_cost_benefactor`,`psi_projects`.`prj_cost_other` AS `prj_cost_other`,`psi_projects`.`prj_intervention` AS `prj_intervention`,`psi_projects`.`prj_longitude` AS `prj_longitude`,`psi_projects`.`prj_latitude` AS `prj_latitude`,`psi_projects`.`prj_elevation` AS `prj_elevation`,`psi_projects`.`prj_type_id` AS `prj_type_id`,`psi_projects`.`prj_status_id` AS `prj_status_id`,`psi_projects`.`prj_remarks` AS `prj_remarks`,`psi_projects`.`ru_id` AS `ru_id`,`psi_projects`.`prj_address` AS `prj_address`,`psi_projects`.`province_id` AS `province_id`,`psi_projects`.`city_id` AS `city_id`,`psi_projects`.`barangay_id` AS `barangay_id`,`psi_projects`.`ug_id` AS `ug_id`,`psi_projects`.`encoder` AS `encoder`,`psi_projects`.`date_encoded` AS `date_encoded`,`psi_projects`.`updater` AS `updater`,`psi_projects`.`last_updated` AS `last_updated`,`psi_projects`.`prj_fund_release_date` AS `prj_fund_release_date`,`psi_projects`.`prj_refund_period_from` AS `prj_refund_period_from`,`psi_projects`.`prj_refund_period_to` AS `prj_refund_period_to`,`psi_projects`.`prj_province` AS `prj_province`,`psi_projects`.`prj_city` AS `prj_city`,`psi_projects`.`prj_barangay` AS `prj_barangay`,`psi_projects`.`sector_id` AS `sector_id`,`psi_sectors`.`sector_name` AS `sector_name`,`psi_projects`.`prj_pis_total_assets_land` AS `prj_pis_total_assets_land`,`psi_projects`.`prj_pis_total_assets_building` AS `prj_pis_total_assets_building`,`psi_projects`.`prj_pis_total_assets_equipment` AS `prj_pis_total_assets_equipment`,`psi_projects`.`prj_pis_total_assets_working_capital` AS `prj_pis_total_assets_working_capital`,`psi_projects`.`prj_pis_total_employment` AS `prj_pis_total_employment`,`psi_projects`.`prj_pis_dir_ch_regular_male` AS `prj_pis_dir_ch_regular_male`,`psi_projects`.`prj_pis_dir_ch_regular_female` AS `prj_pis_dir_ch_regular_female`,`psi_projects`.`prj_pis_dir_ch_regular_pwd` AS `prj_pis_dir_ch_regular_pwd`,`psi_projects`.`prj_pis_dir_ch_regular_senior` AS `prj_pis_dir_ch_regular_senior`,`psi_projects`.`prj_pis_dir_ch_part_time_male` AS `prj_pis_dir_ch_part_time_male`,`psi_projects`.`prj_pis_dir_ch_part_time_female` AS `prj_pis_dir_ch_part_time_female`,`psi_projects`.`prj_pis_dir_ch_part_time_pwd` AS `prj_pis_dir_ch_part_time_pwd`,`psi_projects`.`prj_pis_dir_ch_part_time_senior` AS `prj_pis_dir_ch_part_time_senior`,`psi_projects`.`prj_pis_dir_sh_regular_male` AS `prj_pis_dir_sh_regular_male`,`psi_projects`.`prj_pis_dir_sh_regular_female` AS `prj_pis_dir_sh_regular_female`,`psi_projects`.`prj_pis_dir_sh_regular_pwd` AS `prj_pis_dir_sh_regular_pwd`,`psi_projects`.`prj_pis_dir_sh_regular_senior` AS `prj_pis_dir_sh_regular_senior`,`psi_projects`.`prj_pis_dir_sh_part_time_male` AS `prj_pis_dir_sh_part_time_male`,`psi_projects`.`prj_pis_dir_sh_part_time_female` AS `prj_pis_dir_sh_part_time_female`,`psi_projects`.`prj_pis_dir_sh_part_time_pwd` AS `prj_pis_dir_sh_part_time_pwd`,`psi_projects`.`prj_pis_dir_sh_part_time_senior` AS `prj_pis_dir_sh_part_time_senior`,`psi_projects`.`prj_pis_indir_backward_male` AS `prj_pis_indir_backward_male`,`psi_projects`.`prj_pis_indir_backward_female` AS `prj_pis_indir_backward_female`,`psi_projects`.`prj_pis_indir_backward_pwd` AS `prj_pis_indir_backward_pwd`,`psi_projects`.`prj_pis_indir_backward_senior` AS `prj_pis_indir_backward_senior`,`psi_projects`.`prj_pis_indir_forward_male` AS `prj_pis_indir_forward_male`,`psi_projects`.`prj_pis_indir_forward_female` AS `prj_pis_indir_forward_female`,`psi_projects`.`prj_pis_indir_forward_pwd` AS `prj_pis_indir_forward_pwd`,`psi_projects`.`prj_pis_indir_forward_senior` AS `prj_pis_indir_forward_senior`,`psi_projects`.`prj_pis_volume_production_local` AS `prj_pis_volume_production_local`,`psi_projects`.`prj_pis_volume_production_export` AS `prj_pis_volume_production_export`,`psi_projects`.`prj_pis_gross_sales_local` AS `prj_pis_gross_sales_local`,`psi_projects`.`prj_pis_gross_sales_export` AS `prj_pis_gross_sales_export`,`psi_projects`.`prj_pis_countries_of_destination` AS `prj_pis_countries_of_destination`,`psi_projects`.`prj_pis_assistance_conceptualization` AS `prj_pis_assistance_conceptualization`,`psi_projects`.`prj_pis_assistance_proposal_preparation` AS `prj_pis_assistance_proposal_preparation`,`psi_projects`.`prj_pis_assistance_process` AS `prj_pis_assistance_process`,`psi_projects`.`prj_pis_assistance_equipment` AS `prj_pis_assistance_equipment`,`psi_projects`.`prj_pis_assistance_quality_control` AS `prj_pis_assistance_quality_control`,`psi_projects`.`prj_pis_assistance_packaging_labeling` AS `prj_pis_assistance_packaging_labeling`,`psi_projects`.`prj_pis_assistance_post_harvest` AS `prj_pis_assistance_post_harvest`,`psi_projects`.`prj_pis_assistance_marketing` AS `prj_pis_assistance_marketing`,`psi_projects`.`prj_pis_assistance_training` AS `prj_pis_assistance_training`,`psi_projects`.`prj_pis_assistance_consultancy` AS `prj_pis_assistance_consultancy`,`psi_projects`.`prj_pis_assistance_others` AS `prj_pis_assistance_others`,`psi_projects`.`prj_pis_remarks` AS `prj_pis_remarks`,`psi_projects`.`prj_cost_benefactor_desc` AS `prj_cost_benefactor_desc`,`psi_projects`.`prj_fundingsource_local` AS `prj_fundingsource_local`,`psi_projects`.`prj_fundingsource_external` AS `prj_fundingsource_external`,`psi_barangays`.`barangay_name` AS `barangay_name`,`psi_project_types`.`prj_type_name` AS `prj_type_name`,`psi_project_status`.`prj_status_name` AS `prj_status_name`,`psi_usergroups`.`ug_name` AS `ug_name`,`vwpsi_repayments`.`rep_total_amount` AS `rep_total_amount`,`vwpsi_repayments`.`rep_refund_rate` AS `rep_refund_rate`,`vwpsi_repayments`.`rep_total_due` AS `rep_total_due`,`vwpsi_repayments`.`rep_total_paid` AS `rep_total_paid`,`vwpsi_project_sector_list`.`sector_list` AS `sector_list`,ifnull(`vwpsi_project_sector_list`.`sector_list`,'') AS `prj_sector_list`,`vwpsi_project_beneficiaries_list`.`coop_names` AS `coop_names`,`vwpsi_project_beneficiaries_list`.`coop_p_names` AS `coop_p_names`,`vwpsi_project_collaborators_list`.`collaborator_names` AS `collaborator_names`,`psi_projects`.`region_id` AS `region_id`,`psi_projects`.`prj_startup_assistance` AS `prj_startup_assistance`,`psi_provinces`.`province_name` AS `province_name`,`psi_cities`.`city_name` AS `city_name`,`psi_cities`.`district_id` AS `district_id`,`psi_districts`.`district_name` AS `district_name`,`psi_regions`.`region_name` AS `region_name`,`psi_regions`.`region_code` AS `region_code`,concat(`psi_regions`.`region_code`,' (',`psi_regions`.`region_name`,')') AS `region_text`,`psi_projects`.`prj_cofunded_nga` AS `prj_cofunded_nga`,`psi_projects`.`prj_cofunded_lgu` AS `prj_cofunded_lgu`,`psi_projects`.`prj_cost_nga` AS `prj_cost_nga`,`psi_projects`.`prj_cost_lgu` AS `prj_cost_lgu`,`psi_projects`.`prj_cost_local` AS `prj_cost_local`,`psi_projects`.`prj_cost_external` AS `prj_cost_external` from (((((((((((((`psi_projects` left join `psi_sectors` on((`psi_projects`.`sector_id` = `psi_sectors`.`sector_id`))) left join `psi_project_types` on((`psi_projects`.`prj_type_id` = `psi_project_types`.`prj_type_id`))) left join `psi_project_status` on((`psi_projects`.`prj_status_id` = `psi_project_status`.`prj_status_id`))) left join `psi_barangays` on((`psi_projects`.`barangay_id` = `psi_barangays`.`barangay_id`))) left join `psi_usergroups` on((`psi_projects`.`ug_id` = `psi_usergroups`.`ug_id`))) left join `vwpsi_project_sector_list` on((`psi_projects`.`prj_id` = `vwpsi_project_sector_list`.`prj_id`))) left join `vwpsi_repayments` on((`psi_projects`.`prj_id` = `vwpsi_repayments`.`prj_id`))) left join `vwpsi_project_beneficiaries_list` on((`psi_projects`.`prj_id` = `vwpsi_project_beneficiaries_list`.`prj_id`))) left join `vwpsi_project_collaborators_list` on((`psi_projects`.`prj_id` = `vwpsi_project_collaborators_list`.`prj_id`))) left join `psi_provinces` on((`psi_projects`.`province_id` = `psi_provinces`.`province_id`))) left join `psi_cities` on((`psi_projects`.`city_id` = `psi_cities`.`city_id`))) left join `psi_districts` on((`psi_cities`.`district_id` = `psi_districts`.`district_id`))) left join `psi_regions` on((`psi_projects`.`region_id` = `psi_regions`.`region_id`)));

CREATE VIEW `vwpsi_promotion_tech_list` AS select `psi_technologies_promoted`.`prom_id` AS `prom_id`,group_concat(`psi_technologies`.`tech_name` separator ', ') AS `tech_list` from (`psi_technologies_promoted` left join `psi_technologies` on((`psi_technologies_promoted`.`tech_id` = `psi_technologies`.`tech_id`))) group by `psi_technologies_promoted`.`prom_id`;

CREATE VIEW `vwpsi_provinces` AS select `psi_provinces`.`province_id` AS `province_id`,`psi_provinces`.`province_name` AS `province_name`,`psi_provinces`.`region_id` AS `region_id`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name` from (`psi_provinces` left join `psi_regions` on((`psi_provinces`.`region_id` = `psi_regions`.`region_id`)));

CREATE VIEW `vwpsi_pstc` AS select `psi_usergroups`.`ug_id` AS `ug_id` from `psi_usergroups` where (`psi_usergroups`.`ug_name` like 'PSTC-%');

CREATE VIEW `vwpsi_rcp` AS select `psi_rcp`.`rcp_id` AS `rcp_id`,`psi_rcp`.`rcp_date` AS `rcp_date`,year(`psi_rcp`.`rcp_date`) AS `rcp_year`,month(`psi_rcp`.`rcp_date`) AS `rcp_month`,`psi_rcp`.`rcp_implemented` AS `rcp_implemented`,`psi_rcp`.`rcp_remarks` AS `rcp_remarks`,`psi_rcp`.`encoder` AS `encoder`,`psi_rcp`.`date_encoded` AS `date_encoded`,`psi_rcp`.`updater` AS `updater`,`psi_rcp`.`last_updated` AS `last_updated` from `psi_rcp`;

CREATE VIEW `vwpsi_referrals` AS select `psi_referrals`.`ref_id` AS `ref_id`,`psi_referrals`.`ref_date` AS `ref_date`,year(`psi_referrals`.`ref_date`) AS `ref_year`,month(`psi_referrals`.`ref_date`) AS `ref_month`,`psi_referrals`.`ref_count` AS `ref_count`,`psi_referrals`.`ref_cost` AS `ref_cost`,`psi_referrals`.`ref_customer` AS `ref_customer`,`psi_referrals`.`ref_information` AS `ref_information`,`psi_referrals`.`ref_action` AS `ref_action`,`psi_referrals`.`ref_referred` AS `ref_referred`,`psi_referrals`.`ref_referral_to` AS `ref_referral_to`,`psi_referrals`.`ref_remarks` AS `ref_remarks`,`psi_referrals`.`ug_id` AS `ug_id`,`psi_referrals`.`region_id` AS `region_id`,`psi_referrals`.`encoder` AS `encoder`,`psi_referrals`.`date_encoded` AS `date_encoded`,`psi_referrals`.`updater` AS `updater`,`psi_referrals`.`last_updated` AS `last_updated`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from (`psi_referrals` left join `psi_usergroups` on((`psi_referrals`.`ug_id` = `psi_usergroups`.`ug_id`)));

CREATE VIEW `vwpsi_regions` AS select `psi_regions`.`region_id` AS `region_id`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name`,concat(`psi_regions`.`region_code`,' (',`psi_regions`.`region_name`,')') AS `region_text` from `psi_regions`;

CREATE VIEW `vwpsi_repayments` AS select `psi_repayments`.`rep_id` AS `rep_id`,`psi_repayments`.`rep_start_year` AS `rep_start_year`,`psi_repayments`.`rep_start_month` AS `rep_start_month`,`psi_repayments`.`rep_amount` AS `rep_amount`,`psi_repayments`.`rep_month_count` AS `rep_month_count`,`psi_repayments`.`rep_otb_paid` AS `rep_otb_paid`,`psi_repayments`.`rep_remarks` AS `rep_remarks`,`psi_repayments`.`rep_add_amount` AS `rep_add_amount`,`psi_repayments`.`rep_add_check_date` AS `rep_add_check_date`,`psi_repayments`.`rep_add_check_no` AS `rep_add_check_no`,`psi_repayments`.`rep_ub_amount` AS `rep_ub_amount`,`psi_repayments`.`rep_ub_check_date` AS `rep_ub_check_date`,`psi_repayments`.`rep_ub_check_no` AS `rep_ub_check_no`,`psi_repayments`.`rep_monthly_payment` AS `rep_monthly_payment`,((`psi_repayments`.`rep_amount` + `psi_repayments`.`rep_add_amount`) - `psi_repayments`.`rep_ub_amount`) AS `rep_total_amount`,`psi_repayments`.`prj_id` AS `prj_id`,`psi_repayments`.`encoder` AS `encoder`,`psi_repayments`.`date_encoded` AS `date_encoded`,`psi_repayments`.`updater` AS `updater`,`psi_repayments`.`last_updated` AS `last_updated`,`psi_repayments`.`rep_otb` AS `rep_otb`,ifnull(`vwpsi_repayments_totals`.`rep_total_due`,0) AS `rep_total_due`,ifnull(`vwpsi_repayments_totals`.`rep_total_paid`,0) AS `rep_total_paid`,ifnull(`vwpsi_repayments_totals`.`rep_final_due`,0) AS `rep_final_due`,ifnull(`vwpsi_repayments_totals`.`rep_final_paid`,0) AS `rep_final_paid`,ifnull(`vwpsi_repayments_totals`.`rep_payment_count`,0) AS `rep_payment_count`,ifnull(`vwpsi_deferment_monthcounts`.`rep_deferment_monthcount`,0) AS `rep_deferment_monthcount`,ifnull(`vwpsi_repayments_totals`.`rep_total_penalty_amount_due`,0) AS `rep_total_penalty_amount_due`,ifnull(`vwpsi_repayments_totals`.`rep_total_penalty_amount_paid`,0) AS `rep_total_penalty_amount_paid`,(ifnull(`vwpsi_repayments_totals`.`rep_total_due`,0) - ifnull(`vwpsi_repayments_totals`.`rep_total_paid`,0)) AS `rep_total_balance`,(ifnull(`vwpsi_repayments_totals`.`rep_final_due`,0) - ifnull(`vwpsi_repayments_totals`.`rep_final_paid`,0)) AS `rep_balance`,(((ifnull(`psi_repayments`.`rep_amount`,0) + ifnull(`psi_repayments`.`rep_add_amount`,0)) - ifnull(`psi_repayments`.`rep_ub_amount`,0)) - ifnull(`vwpsi_repayments_totals`.`rep_total_paid`,0)) AS `rep_real_balance`,((`psi_repayments`.`rep_amount` + ifnull(`vwpsi_repayments_totals`.`rep_total_penalty_amount_due`,0)) - (ifnull(`vwpsi_repayments_totals`.`rep_total_penalty_amount_paid`,0) + ifnull(`vwpsi_repayments_totals`.`rep_total_paid`,0))) AS `rep_real_balance2`,ifnull(`vwpsi_otb_payments`.`rep_otb_amount_paid`,0) AS `rep_otb_amount_paid`,(((`psi_repayments`.`rep_amount` + `psi_repayments`.`rep_add_amount`) - `psi_repayments`.`rep_ub_amount`) * 0.005) AS `rep_otb_amount`,(((`psi_repayments`.`rep_amount` + `psi_repayments`.`rep_add_amount`) - `psi_repayments`.`rep_ub_amount`) + (`psi_repayments`.`rep_amount` * 0.005)) AS `rep_amount_with_otb`,`psi_repayments`.`rep_ub_receipt_no` AS `rep_ub_receipt_no`,if(((ifnull(`vwpsi_repayments_totals`.`rep_total_paid`,0) = 0) or (ifnull(`vwpsi_repayments_totals`.`rep_total_due`,0) = 0)),0,((`vwpsi_repayments_totals`.`rep_total_paid` / `vwpsi_repayments_totals`.`rep_total_due`) * 100)) AS `rep_refund_rate` from (((`psi_repayments` left join `vwpsi_repayments_totals` on((`psi_repayments`.`rep_id` = `vwpsi_repayments_totals`.`rep_id`))) left join `vwpsi_otb_payments` on((`psi_repayments`.`rep_id` = `vwpsi_otb_payments`.`rep_id`))) left join `vwpsi_deferment_monthcounts` on((`psi_repayments`.`rep_id` = `vwpsi_deferment_monthcounts`.`rep_id`)));

CREATE VIEW `vwpsi_repayments_all` AS select sum(`vwpsi_repayments`.`rep_total_due`) AS `rep_all_due`,sum(`vwpsi_repayments`.`rep_total_paid`) AS `rep_all_paid`,sum(`vwpsi_repayments`.`rep_balance`) AS `rep_all_balance`,sum(`vwpsi_repayments`.`rep_total_amount`) AS `rep_all_amount` from `vwpsi_repayments`;

CREATE VIEW `vwpsi_repayments_payments` AS select `psi_repayments_payments`.`pay_id` AS `pay_id`,`psi_repayments_payments`.`pay_year` AS `pay_year`,`psi_repayments_payments`.`pay_month` AS `pay_month`,`psi_repayments_payments`.`pay_count` AS `pay_count`,`psi_repayments_payments`.`pay_level` AS `pay_level`,`psi_repayments_payments`.`pay_amount_due` AS `pay_amount_due`,`psi_repayments_payments`.`pay_amount_paid` AS `pay_amount_paid`,`psi_repayments_payments`.`pay_amount_date_paid` AS `pay_amount_date_paid`,`psi_repayments_payments`.`pay_check_no` AS `pay_check_no`,`psi_repayments_payments`.`pay_check_date` AS `pay_check_date`,`psi_repayments_payments`.`pay_receipt_no` AS `pay_receipt_no`,`psi_repayments_payments`.`pay_type_id` AS `pay_type_id`,`psi_repayments_payments`.`pay_otb` AS `pay_otb`,`psi_repayments_payments`.`pay_penalty_amount_due` AS `pay_penalty_amount_due`,`psi_repayments_payments`.`pay_penalty_amount_paid` AS `pay_penalty_amount_paid`,`psi_repayments_payments`.`pay_penalty_date_paid` AS `pay_penalty_date_paid`,`psi_repayments_payments`.`pay_remarks` AS `pay_remarks`,`psi_repayments_payments`.`rep_id` AS `rep_id`,`psi_repayments_payments`.`encoder` AS `encoder`,`psi_repayments_payments`.`date_encoded` AS `date_encoded`,`psi_repayments_payments`.`updater` AS `updater`,`psi_repayments_payments`.`last_updated` AS `last_updated`,`psi_repayments_payment_types`.`pay_type_name` AS `pay_type_name`,`psi_repayments_payments`.`pay_overdue_amount_due` AS `pay_overdue_amount_due`,`psi_repayments_payments`.`pay_overdue_amount_paid` AS `pay_overdue_amount_paid`,`psi_repayments_payments`.`pay_overdue_date_paid` AS `pay_overdue_date_paid` from (`psi_repayments_payments` left join `psi_repayments_payment_types` on((`psi_repayments_payments`.`pay_type_id` = `psi_repayments_payment_types`.`pay_type_id`)));

CREATE VIEW `vwpsi_repayments_totals` AS select ifnull(sum(`psi_repayments_payments`.`pay_amount_due`),0) AS `rep_total_due`,ifnull(sum(`psi_repayments_payments`.`pay_amount_paid`),0) AS `rep_total_paid`,ifnull(sum(`psi_repayments_payments`.`pay_count`),0) AS `rep_payment_count`,ifnull(sum(`psi_repayments_payments`.`pay_penalty_amount_due`),0) AS `rep_total_penalty_amount_due`,ifnull(sum(`psi_repayments_payments`.`pay_penalty_amount_paid`),0) AS `rep_total_penalty_amount_paid`,ifnull((sum(`psi_repayments_payments`.`pay_amount_due`) + sum(`psi_repayments_payments`.`pay_penalty_amount_due`)),0) AS `rep_final_due`,ifnull((sum(`psi_repayments_payments`.`pay_amount_paid`) + sum(`psi_repayments_payments`.`pay_penalty_amount_paid`)),0) AS `rep_final_paid`,`psi_repayments_payments`.`rep_id` AS `rep_id` from `psi_repayments_payments` where (`psi_repayments_payments`.`pay_otb` = 0) group by `psi_repayments_payments`.`rep_id`;

CREATE VIEW `vwpsi_repayments_totals_per_province` AS select sum(`psi_repayments_payments`.`pay_amount_due`) AS `rep_total_due`,sum(`psi_repayments_payments`.`pay_amount_paid`) AS `rep_total_paid`,sum(`psi_repayments_payments`.`pay_count`) AS `rep_payment_count`,sum(`psi_repayments_payments`.`pay_penalty_amount_due`) AS `rep_total_penalty_amount_due`,sum(`psi_repayments_payments`.`pay_penalty_amount_paid`) AS `rep_total_penalty_amount_paid`,`psi_projects`.`province_id` AS `province_id`,`psi_provinces`.`province_name` AS `province_name` from (((`psi_repayments_payments` left join `psi_repayments` on((`psi_repayments`.`rep_id` = `psi_repayments_payments`.`rep_id`))) left join `psi_projects` on((`psi_projects`.`prj_id` = `psi_repayments`.`prj_id`))) left join `psi_provinces` on((`psi_provinces`.`province_id` = `psi_projects`.`province_id`))) where ((`psi_repayments_payments`.`pay_otb` = 0) and (`psi_projects`.`province_id` > 0)) group by `psi_projects`.`province_id`,`psi_provinces`.`province_name` order by `rep_total_paid`;

CREATE VIEW `vwpsi_repayments_with_projects` AS select `vwpsi_repayments`.`rep_id` AS `rep_id`,`vwpsi_repayments`.`rep_start_year` AS `rep_start_year`,`vwpsi_repayments`.`rep_start_month` AS `rep_start_month`,`vwpsi_repayments`.`rep_amount` AS `rep_amount`,`vwpsi_repayments`.`rep_month_count` AS `rep_month_count`,`vwpsi_repayments`.`rep_otb_paid` AS `rep_otb_paid`,`vwpsi_repayments`.`rep_remarks` AS `rep_remarks`,`vwpsi_repayments`.`rep_add_amount` AS `rep_add_amount`,`vwpsi_repayments`.`rep_add_check_date` AS `rep_add_check_date`,`vwpsi_repayments`.`rep_add_check_no` AS `rep_add_check_no`,`vwpsi_repayments`.`rep_ub_amount` AS `rep_ub_amount`,`vwpsi_repayments`.`rep_ub_check_date` AS `rep_ub_check_date`,`vwpsi_repayments`.`rep_ub_check_no` AS `rep_ub_check_no`,`vwpsi_repayments`.`rep_monthly_payment` AS `rep_monthly_payment`,`vwpsi_repayments`.`rep_total_amount` AS `rep_total_amount`,`vwpsi_repayments`.`prj_id` AS `prj_id`,`vwpsi_repayments`.`encoder` AS `encoder`,`vwpsi_repayments`.`date_encoded` AS `date_encoded`,`vwpsi_repayments`.`updater` AS `updater`,`vwpsi_repayments`.`last_updated` AS `last_updated`,`vwpsi_repayments`.`rep_otb` AS `rep_otb`,`vwpsi_repayments`.`rep_total_paid` AS `rep_total_paid`,`vwpsi_repayments`.`rep_payment_count` AS `rep_payment_count`,`vwpsi_repayments`.`rep_deferment_monthcount` AS `rep_deferment_monthcount`,`vwpsi_repayments`.`rep_total_penalty_amount_due` AS `rep_total_penalty_amount_due`,`vwpsi_repayments`.`rep_total_penalty_amount_paid` AS `rep_total_penalty_amount_paid`,`vwpsi_repayments`.`rep_balance` AS `rep_balance`,`vwpsi_repayments`.`rep_otb_amount_paid` AS `rep_otb_amount_paid`,`vwpsi_repayments`.`rep_otb_amount` AS `rep_otb_amount`,`vwpsi_repayments`.`rep_amount_with_otb` AS `rep_amount_with_otb`,`vwpsi_repayments`.`rep_ub_receipt_no` AS `rep_ub_receipt_no`,`vwpsi_repayments`.`rep_refund_rate` AS `rep_refund_rate`,`vwpsi_projects`.`prj_title` AS `prj_title`,`vwpsi_projects`.`prj_code` AS `prj_code`,`vwpsi_projects`.`prj_year_approved` AS `prj_year_approved`,`vwpsi_projects`.`prj_objective` AS `prj_objective`,`vwpsi_projects`.`prj_expected_output` AS `prj_expected_output`,`vwpsi_projects`.`prj_product_line` AS `prj_product_line`,`vwpsi_projects`.`prj_cost_setup` AS `prj_cost_setup`,`vwpsi_projects`.`prj_cost_benefactor` AS `prj_cost_benefactor`,`vwpsi_projects`.`prj_cost_other` AS `prj_cost_other`,`vwpsi_projects`.`prj_intervention` AS `prj_intervention`,`vwpsi_projects`.`prj_longitude` AS `prj_longitude`,`vwpsi_projects`.`prj_latitude` AS `prj_latitude`,`vwpsi_projects`.`prj_elevation` AS `prj_elevation`,`vwpsi_projects`.`prj_type_id` AS `prj_type_id`,`vwpsi_projects`.`prj_status_id` AS `prj_status_id`,`vwpsi_projects`.`prj_remarks` AS `prj_remarks`,`vwpsi_projects`.`province_id` AS `province_id`,`vwpsi_projects`.`city_id` AS `city_id`,`vwpsi_projects`.`barangay_id` AS `barangay_id`,`vwpsi_projects`.`ug_id` AS `ug_id`,`vwpsi_projects`.`prj_type_name` AS `prj_type_name`,`vwpsi_projects`.`prj_status_name` AS `prj_status_name`,`vwpsi_projects`.`province_name` AS `province_name`,`vwpsi_projects`.`region_name` AS `region_name`,`vwpsi_projects`.`city_name` AS `city_name`,`vwpsi_projects`.`barangay_name` AS `barangay_name`,`vwpsi_projects`.`ug_name` AS `ug_name`,`vwpsi_projects`.`prj_fund_release_date` AS `prj_fund_release_date`,`vwpsi_projects`.`prj_refund_period_from` AS `prj_refund_period_from`,`vwpsi_projects`.`prj_refund_period_to` AS `prj_refund_period_to`,`vwpsi_projects`.`prj_province` AS `prj_province`,`vwpsi_projects`.`prj_city` AS `prj_city`,`vwpsi_projects`.`prj_barangay` AS `prj_barangay`,`vwpsi_projects`.`prj_sector_list` AS `prj_sector_list`,`vwpsi_projects`.`coop_names` AS `coop_names`,`vwpsi_projects`.`collaborator_names` AS `collaborator_names`,`vwpsi_projects`.`prj_address` AS `prj_address`,`vwpsi_projects`.`coop_p_names` AS `coop_p_names`,`vwpsi_projects`.`sector_name` AS `sector_name`,`vwpsi_projects`.`district_name` AS `district_name`,`vwpsi_projects`.`district_id` AS `district_id`,`vwpsi_projects`.`region_id` AS `region_id`,`vwpsi_projects`.`sector_id` AS `sector_id`,`vwpsi_projects`.`prj_duration_from` AS `prj_duration_from`,`vwpsi_projects`.`prj_duration_to` AS `prj_duration_to`,`vwpsi_projects`.`prj_startup_assistance` AS `prj_startup_assistance`,`vwpsi_projects`.`prj_cofunded_nga` AS `prj_cofunded_nga`,`vwpsi_projects`.`prj_cost_nga` AS `prj_cost_nga`,`vwpsi_projects`.`prj_cofunded_lgu` AS `prj_cofunded_lgu`,`vwpsi_projects`.`prj_cost_lgu` AS `prj_cost_lgu`,`vwpsi_projects`.`prj_cost_local` AS `prj_cost_local`,`vwpsi_projects`.`prj_cost_external` AS `prj_cost_external` from (`vwpsi_repayments` join `vwpsi_projects` on((`vwpsi_repayments`.`prj_id` = `vwpsi_projects`.`prj_id`)));

CREATE VIEW `vwpsi_rndagenda` AS select `psi_rndagenda`.`rndagenda_id` AS `rndagenda_id`,`psi_rndagenda`.`rndagenda_date` AS `rndagenda_date`,year(`psi_rndagenda`.`rndagenda_date`) AS `rndagenda_year`,month(`psi_rndagenda`.`rndagenda_date`) AS `rndagenda_month`,`psi_rndagenda`.`rndagenda_formulated` AS `rndagenda_formulated`,`psi_rndagenda`.`rndagenda_remarks` AS `rndagenda_remarks`,`psi_rndagenda`.`encoder` AS `encoder`,`psi_rndagenda`.`date_encoded` AS `date_encoded`,`psi_rndagenda`.`updater` AS `updater`,`psi_rndagenda`.`last_updated` AS `last_updated` from `psi_rndagenda`;

CREATE VIEW `vwpsi_rndprj` AS select `psi_rndprj`.`rndprj_id` AS `rndprj_id`,`psi_rndprj`.`rndprj_date` AS `rndprj_date`,year(`psi_rndprj`.`rndprj_date`) AS `rndprj_year`,month(`psi_rndprj`.`rndprj_date`) AS `rndprj_month`,`psi_rndprj`.`rndprj_title` AS `rndprj_title`,`psi_rndprj`.`rndprj_description` AS `rndprj_description`,`psi_rndprj`.`rndprj_evaluated` AS `rndprj_evaluated`,`psi_rndprj`.`rndprj_endorsed` AS `rndprj_endorsed`,`psi_rndprj`.`rndprj_inhouse` AS `rndprj_inhouse`,`psi_rndprj`.`rndprj_implemented` AS `rndprj_implemented`,`psi_rndprj`.`rndprj_colaborative` AS `rndprj_colaborative`,`psi_rndprj`.`rndprj_colaborators` AS `rndprj_colaborators`,`psi_rndprj`.`rndprj_remarks` AS `rndprj_remarks`,`psi_rndprj`.`rndsec_id` AS `rndsec_id`,`psi_rndprj`.`encoder` AS `encoder`,`psi_rndprj`.`date_encoded` AS `date_encoded`,`psi_rndprj`.`updater` AS `updater`,`psi_rndprj`.`last_updated` AS `last_updated`,`psi_rnd_sectors`.`rndsec_name` AS `rndsec_name` from (`psi_rndprj` left join `psi_rnd_sectors` on((`psi_rnd_sectors`.`rndsec_id` = `psi_rndprj`.`rndsec_id`)));

CREATE VIEW `vwpsi_ro` AS select `psi_usergroups`.`ug_id` AS `ug_id` from `psi_usergroups` where (`psi_usergroups`.`ug_name` like 'RO-%');

CREATE VIEW `vwpsi_sales_gross` AS select sum(`psi_project_production`.`production_gross`) AS `prjmon_gross_sales`,`psi_project_production`.`prjmon_id` AS `prjmon_id` from `psi_project_production` group by `psi_project_production`.`prjmon_id`;

CREATE VIEW `vwpsi_scholarships` AS select `psi_scholarships`.`scholar_id` AS `scholar_id`,`psi_scholarships`.`scholar_fname` AS `scholar_fname`,`psi_scholarships`.`scholar_mname` AS `scholar_mname`,`psi_scholarships`.`scholar_lname` AS `scholar_lname`,concat(`psi_scholarships`.`scholar_fname`,convert(convert(convert(if((char_length(`psi_scholarships`.`scholar_fname`) > 0),' ','') using utf8) using utf8) using utf8mb4),`psi_scholarships`.`scholar_mname`,convert(convert(convert(if((char_length(`psi_scholarships`.`scholar_mname`) > 0),' ','') using utf8) using utf8) using utf8mb4),`psi_scholarships`.`scholar_lname`) AS `scholar_name`,`psi_scholarships`.`scholar_suffix` AS `scholar_suffix`,`psi_scholarships`.`scholar_mobile` AS `scholar_mobile`,`psi_scholarships`.`scholar_email` AS `scholar_email`,`psi_scholarships`.`scholar_address` AS `scholar_address`,`psi_scholarships`.`scholar_year_award` AS `scholar_year_award`,`psi_scholarships`.`scholar_remarks` AS `scholar_remarks`,`psi_scholarships`.`scholar_stat_id` AS `scholar_stat_id`,`psi_scholarships`.`scholar_prog_id` AS `scholar_prog_id`,`psi_scholarships`.`school_id` AS `school_id`,`psi_scholarships`.`course_id` AS `course_id`,`psi_scholarships`.`encoder` AS `encoder`,`psi_scholarships`.`date_encoded` AS `date_encoded`,`psi_scholarships`.`updater` AS `updater`,`psi_scholarships`.`last_updated` AS `last_updated`,`psi_scholarship_programs`.`scholar_prog_name` AS `scholar_prog_name`,`psi_scholarship_programs`.`scholar_prog_desc` AS `scholar_prog_desc`,`psi_schools`.`school_name` AS `school_name`,`psi_schools`.`school_acronym` AS `school_acronym`,`psi_schools`.`school_address` AS `school_address`,`psi_schools`.`school_coordinator` AS `school_coordinator`,`psi_schools`.`school_email` AS `school_email`,`psi_schools`.`school_phone` AS `school_phone`,`psi_schools`.`school_mobile` AS `school_mobile`,`vwpsi_courses`.`course_name` AS `course_name`,`vwpsi_courses`.`course_cat_id` AS `course_cat_id`,`vwpsi_courses`.`course_yearcount` AS `course_yearcount`,`vwpsi_courses`.`course_cat_name` AS `course_cat_name`,`vwpsi_courses`.`course_label` AS `course_label`,`psi_scholarship_status`.`scholar_stat_name` AS `scholar_stat_name`,`psi_scholarship_status`.`scholar_stat_abbr` AS `scholar_stat_abbr` from ((((`psi_scholarships` left join `psi_scholarship_programs` on((`psi_scholarships`.`scholar_prog_id` = `psi_scholarship_programs`.`scholar_prog_id`))) left join `psi_schools` on((`psi_scholarships`.`school_id` = `psi_schools`.`school_id`))) left join `vwpsi_courses` on((`psi_scholarships`.`course_id` = `vwpsi_courses`.`course_id`))) left join `psi_scholarship_status` on((`psi_scholarships`.`scholar_stat_id` = `psi_scholarship_status`.`scholar_stat_id`)));

CREATE VIEW `vwpsi_service_provider_services` AS select `psi_service_provider_services`.`sps_id` AS `sps_id`,`psi_service_provider_services`.`sp_id` AS `sp_id`,`psi_service_provider_services`.`service_id` AS `service_id`,`psi_services`.`service_name` AS `service_name` from (`psi_service_provider_services` left join `psi_services` on((`psi_service_provider_services`.`service_id` = `psi_services`.`service_id`)));

CREATE VIEW `vwpsi_service_providers` AS select `psi_service_providers`.`sp_id` AS `sp_id`,`psi_service_providers`.`sp_name` AS `sp_name`,`psi_service_providers`.`sp_other_service` AS `sp_other_service`,`psi_service_providers`.`sp_designation` AS `sp_designation`,`psi_service_providers`.`sp_fname` AS `sp_fname`,`psi_service_providers`.`sp_mname` AS `sp_mname`,`psi_service_providers`.`sp_lname` AS `sp_lname`,concat(`psi_service_providers`.`sp_fname`,convert(convert(convert(if((char_length(`psi_service_providers`.`sp_fname`) > 0),' ','') using utf8) using utf8) using utf8mb4),`psi_service_providers`.`sp_mname`,convert(convert(convert(if((char_length(`psi_service_providers`.`sp_mname`) > 0),' ','') using utf8) using utf8) using utf8mb4),`psi_service_providers`.`sp_lname`) AS `sp_contact_name`,`psi_service_providers`.`sp_address` AS `sp_address`,`psi_service_providers`.`sp_expertise` AS `sp_expertise`,`psi_service_providers`.`sp_product_line` AS `sp_product_line`,`psi_service_providers`.`sp_phone` AS `sp_phone`,`psi_service_providers`.`sp_mobile` AS `sp_mobile`,`psi_service_providers`.`sp_email` AS `sp_email`,`psi_service_providers`.`sp_website` AS `sp_website`,`psi_service_providers`.`encoder` AS `encoder`,`psi_service_providers`.`date_encoded` AS `date_encoded`,`psi_service_providers`.`updater` AS `updater`,`psi_service_providers`.`last_updated` AS `last_updated` from `psi_service_providers`;

CREATE VIEW `vwpsi_suc_assistance` AS select `psi_suc_assistance`.`suca_id` AS `suca_id`,`psi_suc_assistance`.`suca_date` AS `suca_date`,year(`psi_suc_assistance`.`suca_date`) AS `suca_year`,month(`psi_suc_assistance`.`suca_date`) AS `suca_month`,`psi_suc_assistance`.`suca_assistance` AS `suca_assistance`,`psi_suc_assistance`.`suca_no_ipr` AS `suca_no_ipr`,`psi_suc_assistance`.`suca_ipr` AS `suca_ipr`,`psi_suc_assistance`.`suca_remarks` AS `suca_remarks`,`psi_suc_assistance`.`school_id` AS `school_id`,`psi_suc_assistance`.`ug_id` AS `ug_id`,`psi_suc_assistance`.`encoder` AS `encoder`,`psi_suc_assistance`.`date_encoded` AS `date_encoded`,`psi_suc_assistance`.`updater` AS `updater`,`psi_suc_assistance`.`last_updated` AS `last_updated`,`psi_schools`.`school_name` AS `school_name`,`psi_schools`.`school_acronym` AS `school_acronym`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from ((`psi_suc_assistance` left join `psi_schools` on((`psi_suc_assistance`.`school_id` = `psi_schools`.`school_id`))) left join `psi_usergroups` on((`psi_suc_assistance`.`ug_id` = `psi_usergroups`.`ug_id`)));

CREATE VIEW `vwpsi_technology_adopter_counts` AS select count(distinct `psi_technology_adoptions`.`coop_id`) AS `coop_id_count`,`psi_technology_adoptions`.`ug_id` AS `ug_id`,`psi_technology_adoptions`.`adopt_date` AS `adopt_date`,year(`psi_technology_adoptions`.`adopt_date`) AS `adopt_year`,month(`psi_technology_adoptions`.`adopt_date`) AS `adopt_month`,`psi_technology_adoptions`.`region_id` AS `region_id` from `psi_technology_adoptions` group by `psi_technology_adoptions`.`ug_id`;

CREATE VIEW `vwpsi_technology_adoptions` AS select `psi_technology_adoptions`.`adopt_id` AS `adopt_id`,`psi_technology_adoptions`.`adopt_date` AS `adopt_date`,year(`psi_technology_adoptions`.`adopt_date`) AS `adopt_year`,month(`psi_technology_adoptions`.`adopt_date`) AS `adopt_month`,`psi_technology_adoptions`.`tech_id` AS `tech_id`,`psi_technology_adoptions`.`coop_id` AS `coop_id`,`psi_technology_adoptions`.`ug_id` AS `ug_id`,`psi_technology_adoptions`.`encoder` AS `encoder`,`psi_technology_adoptions`.`date_encoded` AS `date_encoded`,`psi_technology_adoptions`.`updater` AS `updater`,`psi_technology_adoptions`.`last_updated` AS `last_updated`,`psi_technology_adoptions`.`adopt_remarks` AS `adopt_remarks`,`psi_technology_adoptions`.`adopt_commercialized` AS `adopt_commercialized`,`psi_technologies`.`tech_name` AS `tech_name`,`psi_technology_adoptions`.`region_id` AS `region_id`,`psi_cooperators`.`coop_name` AS `coop_name`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name` from (((`psi_technology_adoptions` left join `psi_technologies` on((`psi_technology_adoptions`.`tech_id` = `psi_technologies`.`tech_id`))) left join `psi_cooperators` on((`psi_technology_adoptions`.`coop_id` = `psi_cooperators`.`coop_id`))) left join `psi_usergroups` on((`psi_technology_adoptions`.`ug_id` = `psi_usergroups`.`ug_id`)));

CREATE VIEW `vwpsi_technology_promotions` AS select `psi_technology_promotions`.`prom_id` AS `prom_id`,`psi_technology_promotions`.`prom_date` AS `prom_date`,year(`psi_technology_promotions`.`prom_date`) AS `prom_year`,month(`psi_technology_promotions`.`prom_date`) AS `prom_month`,`psi_technology_promotions`.`ug_id` AS `ug_id`,`psi_technology_promotions`.`prompt_id` AS `prompt_id`,`psi_technology_promotions`.`encoder` AS `encoder`,`psi_technology_promotions`.`date_encoded` AS `date_encoded`,`psi_technology_promotions`.`updater` AS `updater`,`psi_technology_promotions`.`last_updated` AS `last_updated`,`psi_technology_promotions`.`prom_remarks` AS `prom_remarks`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_display_name` AS `ug_display_name`,`psi_promotion_types`.`prompt_name` AS `prompt_name`,`vwpsi_promotion_tech_list`.`tech_list` AS `tech_list`,`psi_technology_promotions`.`region_id` AS `region_id` from (((`psi_technology_promotions` left join `psi_usergroups` on((`psi_technology_promotions`.`ug_id` = `psi_usergroups`.`ug_id`))) left join `psi_promotion_types` on((`psi_technology_promotions`.`prompt_id` = `psi_promotion_types`.`prompt_id`))) left join `vwpsi_promotion_tech_list` on((`psi_technology_promotions`.`prom_id` = `vwpsi_promotion_tech_list`.`prom_id`)));

CREATE VIEW `vwpsi_technology_promotions_for_kpi` AS select `psi_technologies_promoted`.`promoted_id` AS `promoted_id`,`psi_technologies_promoted`.`tech_id` AS `tech_id`,`psi_technologies_promoted`.`prom_id` AS `prom_id`,`psi_technologies_promoted`.`region_id` AS `region_id`,`psi_technology_promotions`.`prom_date` AS `prom_date`,year(`psi_technology_promotions`.`prom_date`) AS `prom_year`,month(`psi_technology_promotions`.`prom_date`) AS `prom_month`,`psi_technology_promotions`.`ug_id` AS `ug_id` from (`psi_technologies_promoted` left join `psi_technology_promotions` on((`psi_technology_promotions`.`prom_id` = `psi_technologies_promoted`.`prom_id`)));

CREATE VIEW `vwpsi_unit_heads` AS select `psi_usergroups`.`ug_id` AS `ug_id`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_parent_id` AS `ug_parent_id`,`psi_usergroups`.`ug_unit_head` AS `ug_unit_head`,`psi_users`.`u_mobile` AS `u_mobile`,`psi_users`.`u_email` AS `u_email`,`psi_usergroups`.`province_id` AS `province_id`,`psi_usergroups`.`region_id` AS `region_id`,`psi_usergroups`.`ug_display_name` AS `ug_display_name`,`psi_users`.`u_username` AS `u_username`,`psi_users`.`u_password` AS `u_password`,`psi_users`.`u_lname` AS `u_lname`,`psi_users`.`u_fname` AS `u_fname`,`psi_users`.`u_mname` AS `u_mname`,`psi_users`.`u_enabled` AS `u_enabled` from (`psi_usergroups` left join `psi_users` on((`psi_users`.`u_id` = `psi_usergroups`.`ug_unit_head`)));

CREATE VIEW `vwpsi_user_log` AS select `psi_user_log`.`log_id` AS `log_id`,`psi_user_log`.`log_date` AS `log_date`,year(`psi_user_log`.`log_date`) AS `log_year`,month(`psi_user_log`.`log_date`) AS `log_month`,dayofmonth(`psi_user_log`.`log_date`) AS `log_day`,`psi_user_log`.`log_page_title` AS `log_page_title`,`psi_user_log`.`log_name` AS `log_name`,`psi_user_log`.`log_url` AS `log_url`,`psi_user_log`.`log_msg` AS `log_msg`,`psi_user_log`.`log_referer` AS `log_referer`,`psi_user_log`.`log_usergroup` AS `log_usergroup`,`psi_user_log`.`log_querystring` AS `log_querystring`,`psi_user_log`.`log_agent` AS `log_agent`,`psi_user_log`.`log_ip` AS `log_ip` from `psi_user_log`;

CREATE VIEW `vwpsi_usergroup_rights` AS select `psi_usergroup_rights`.`ugr_id` AS `ugr_id`,`psi_usergroup_rights`.`ug_id` AS `ug_id`,`psi_usergroup_rights`.`ur_id` AS `ur_id`,`psi_usergroup_rights`.`ugr_view` AS `ugr_view`,`psi_usergroup_rights`.`ugr_add` AS `ugr_add`,`psi_usergroup_rights`.`ugr_edit` AS `ugr_edit`,`psi_usergroup_rights`.`ugr_delete` AS `ugr_delete`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_user_rights`.`ur_name` AS `ur_name` from ((`psi_usergroup_rights` left join `psi_usergroups` on((`psi_usergroup_rights`.`ug_id` = `psi_usergroups`.`ug_id`))) left join `psi_user_rights` on((`psi_usergroup_rights`.`ur_id` = `psi_user_rights`.`ur_id`)));

CREATE VIEW `vwpsi_usergroups` AS select `psi_usergroups`.`ug_id` AS `ug_id`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_display_name` AS `ug_display_name`,`psi_usergroups`.`region_id` AS `region_id`,`totals`.`num_users` AS `num_users`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name`,concat(`psi_regions`.`region_code`,' (',`psi_regions`.`region_name`,')') AS `region_text`,`psi_usergroups`.`ug_parent_id` AS `ug_parent_id`,`psi_usergroups`.`province_id` AS `province_id`,`psi_provinces`.`province_name` AS `province_name`,`parent`.`ug_name` AS `ug_parent_name`,`parent`.`ug_display_name` AS `ug_parent_display_name` from ((((`psi_usergroups` left join (select count(`psi_users`.`u_id`) AS `num_users`,`psi_users`.`ug_id` AS `ug_id`,`psi_users`.`region_id` AS `region_id` from `psi_users` group by `psi_users`.`ug_id`,`psi_users`.`region_id`) `totals` on((`totals`.`ug_id` = `psi_usergroups`.`ug_id`))) left join `psi_regions` on((`psi_regions`.`region_id` = `psi_usergroups`.`region_id`))) left join `psi_provinces` on((`psi_provinces`.`province_id` = `psi_usergroups`.`province_id`))) left join `psi_usergroups` `parent` on((`parent`.`ug_id` = `psi_usergroups`.`ug_parent_id`)));

CREATE VIEW `vwpsi_users` AS select `psi_users`.`u_id` AS `u_id`,`psi_users`.`u_username` AS `u_username`,`psi_users`.`u_password` AS `u_password`,concat(`psi_users`.`u_fname`,convert(if((char_length(`psi_users`.`u_mname`) > 0),' ','') using utf8mb4),`psi_users`.`u_mname`,convert(if((char_length(`psi_users`.`u_lname`) > 0),' ','') using utf8mb4),`psi_users`.`u_lname`) AS `u_name`,concat(`psi_users`.`u_lname`,', ',`psi_users`.`u_fname`,' ',`psi_users`.`u_mname`) AS `u_name_rev`,`psi_users`.`u_lname` AS `u_lname`,`psi_users`.`u_fname` AS `u_fname`,`psi_users`.`u_mname` AS `u_mname`,`psi_users`.`u_mobile` AS `u_mobile`,`psi_users`.`u_email` AS `u_email`,`psi_users`.`u_enabled` AS `u_enabled`,`psi_users`.`ug_id` AS `ug_id`,`psi_users`.`synched` AS `synched`,`psi_users`.`sync_date` AS `sync_date`,`psi_users`.`date_encoded` AS `date_encoded`,`psi_users`.`last_updated` AS `last_updated`,`psi_users`.`encoder` AS `encoder`,`psi_users`.`updater` AS `updater`,`psi_users`.`region_id` AS `region_id`,`psi_users`.`remember_token` AS `remember_token`,`psi_users`.`remember_expiry` AS `remember_expiry`,`psi_usergroups`.`ug_name` AS `ug_name`,`psi_usergroups`.`ug_is_admin` AS `ug_is_admin`,`psi_usergroups`.`ug_display_name` AS `ug_display_name`,`psi_usergroups`.`ug_parent_id` AS `ug_parent_id`,`psi_regions`.`region_code` AS `region_code`,`psi_regions`.`region_name` AS `region_name`,concat(`psi_regions`.`region_code`,' (',`psi_regions`.`region_name`,')') AS `u_region_name` from ((`psi_users` left join `psi_usergroups` on((`psi_users`.`ug_id` = `psi_usergroups`.`ug_id`))) left join `psi_regions` on((`psi_users`.`region_id` = `psi_regions`.`region_id`)));

