--
-- Host: localhost    Database: flowpoint
-- ------------------------------------------------------


--
-- Table structure for table `fp_business_area`
--

CREATE TABLE `fp_business_area` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `label` varchar(255) NOT NULL,
  `company_id` int(11) NOT NULL,
  `responsible_staff_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fp_business_area_history`
--

CREATE TABLE `fp_business_area_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `business_area_id` int(11) NOT NULL,
  `productive_hours` decimal(10,2) DEFAULT NULL,
  `gross_margin_per_hour` decimal(10,2) DEFAULT NULL,
  `effective_from` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_company`
--

CREATE TABLE `fp_company` (
  `id` int(8) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `autocheck_enabled` tinyint(1) NOT NULL DEFAULT '1',
  `autocheck_time` int(11) DEFAULT NULL,
  `autocheck_weekday` int(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_estimation`
--

CREATE TABLE `fp_estimation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `pm_open_hours` decimal(10,2) DEFAULT NULL,
  `pm_user_id` int(6) DEFAULT NULL,
  `pm_timestamp` int(11) DEFAULT NULL,
  `tm_open_hours` decimal(10,2) DEFAULT NULL,
  `tm_user_id` int(6) DEFAULT NULL,
  `tm_timestamp` int(11) DEFAULT NULL,
  `estimated_timestamp` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_event`
--

CREATE TABLE `fp_event` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `date` int(11) NOT NULL,
  `initiator_id` int(2) NOT NULL,
  `reason_id` int(2) NOT NULL,
  `hours` decimal(10,2) DEFAULT NULL,
  `material` decimal(10,2) DEFAULT NULL,
  `external_service` decimal(10,2) DEFAULT NULL,
  `order_volume` decimal(10,2) DEFAULT NULL,
  `comment` varchar(255) DEFAULT NULL,
  `staff_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_measure`
--

CREATE TABLE `fp_measure` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `date` int(11) NOT NULL,
  `initiator_id` int(2) NOT NULL,
  `reason_id` int(2) NOT NULL,
  `hours` decimal(10,2) DEFAULT NULL,
  `material` decimal(10,2) DEFAULT NULL,
  `external_service` decimal(10,2) DEFAULT NULL,
  `order_volume` decimal(10,2) DEFAULT NULL,
  `comment` varchar(255) DEFAULT NULL,
  `staff_id` int(11) NOT NULL,
  `status` int(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fp_project`
--

CREATE TABLE `fp_project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `company_id` int(11) NOT NULL,
  `ba_id` int(2) DEFAULT NULL,
  `responsible` int(11) DEFAULT NULL,
  `team_manager_id` int(11) DEFAULT NULL,
  `price_overall` decimal(14,2) DEFAULT NULL,
  `material_costs` decimal(14,2) DEFAULT NULL,
  `external_service_costs` decimal(14,2) DEFAULT NULL,
  `productive_hours` decimal(10,2) DEFAULT NULL,
  `status_id` int(11) NOT NULL,
  `project_start` int(11) DEFAULT NULL,
  `project_end` int(11) DEFAULT NULL,
  `is_archived` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fp_project_calculation_contract`
--

CREATE TABLE `fp_project_calculation_contract` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `costs` int(11) NOT NULL,
  `explanation` text NOT NULL,
  `staff_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_project_calculation_material`
--

CREATE TABLE `fp_project_calculation_material` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `costs` int(11) NOT NULL,
  `explanation` text NOT NULL,
  `staff_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_project_calculation_measure`
--

CREATE TABLE `fp_project_calculation_measure` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `measure` text NOT NULL,
  `project_effect` int(11) NOT NULL,
  `productive_effect` int(11) NOT NULL,
  `working_hours_effect` int(11) NOT NULL,
  `staff_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fp_project_calculation_process`
--

CREATE TABLE `fp_project_calculation_process` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(11) NOT NULL,
  `costs` int(11) NOT NULL,
  `explanation` text NOT NULL,
  `staff_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fp_role_alloc`
--

CREATE TABLE `fp_role_alloc` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role_id` int(11) NOT NULL,
  `staff_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_staff`
--

CREATE TABLE `fp_staff` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `company_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_submission`
--

CREATE TABLE `fp_submission` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sub_project_id` int(11) NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `rank` int(3) NOT NULL,
  `amount` decimal(11,2) NOT NULL,
  `is_from_company` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


--
-- Table structure for table `fp_submission_project`
--

CREATE TABLE `fp_submission_project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `label` varchar(255) NOT NULL,
  `company_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fp_work_progress`
--

CREATE TABLE `fp_work_progress` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(6) NOT NULL,
  `post_hours` decimal(10,2) DEFAULT NULL,
  `post_material_costs` decimal(12,2) DEFAULT NULL,
  `post_external_costs` decimal(12,2) DEFAULT NULL,
  `gross_profit_working` decimal(12,2) DEFAULT NULL,
  `hours_working` decimal(12,2) DEFAULT NULL,
  `accouting_staff_id` int(6) DEFAULT NULL,
  `accounting_1` decimal(12,2) DEFAULT NULL,
  `accounting_2` decimal(12,2) DEFAULT NULL,
  `accounting_date` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



