-- phpMyAdmin SQL Dump
-- version 3.1.3.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 12, 2009 at 11:32 PM
-- Server version: 5.1.33
-- PHP Version: 5.2.9

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `nutrition`
--

-- --------------------------------------------------------

--
-- Table structure for table `configuration`
--

CREATE TABLE IF NOT EXISTS `configuration` (
  `configuration_id` int(10) NOT NULL AUTO_INCREMENT,
  `configuration_key` varchar(30) NOT NULL,
  `configuration_name` varchar(60) NOT NULL,
  `configuration_value` varchar(50) NOT NULL,
  `configuration_sort` int(3) NOT NULL,
  PRIMARY KEY (`configuration_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `configuration`
--

INSERT INTO `configuration` (`configuration_id`, `configuration_key`, `configuration_name`, `configuration_value`, `configuration_sort`) VALUES
(1, 'TITLE', 'WebSite Name', 'NUTRITION MATTERS SDN BHD', 1),
(2, 'EMAIL', 'Email', 'master@nutritionm.com', 2);

-- --------------------------------------------------------

--
-- Table structure for table `dealer`
--

CREATE TABLE IF NOT EXISTS `dealer` (
  `d_id` varchar(15) NOT NULL,
  `d_name` varchar(40) NOT NULL,
  `d_contact` varchar(12) NOT NULL,
  `d_person` varchar(40) NOT NULL,
  `d_region` varchar(6) NOT NULL,
  `d_date` date DEFAULT NULL,
  `d_adv` char(3) NOT NULL DEFAULT 'No',
  PRIMARY KEY (`d_id`),
  KEY `d_region` (`d_region`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `dealer`
--

INSERT INTO `dealer` (`d_id`, `d_name`, `d_contact`, `d_person`, `d_region`, `d_date`, `d_adv`) VALUES
('D001', 'ABC', '323213', 'dasdkla', 'SOU', '2009-12-12', 'No');

-- --------------------------------------------------------

--
-- Table structure for table `dealer_assign`
--

CREATE TABLE IF NOT EXISTS `dealer_assign` (
  `da_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `da_staff` int(11) NOT NULL,
  `da_dealer` varchar(15) NOT NULL,
  `da_fdate` date NOT NULL,
  `da_tdate` date NOT NULL,
  PRIMARY KEY (`da_id`),
  KEY `da_staff` (`da_staff`),
  KEY `da_dealer` (`da_dealer`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `dealer_assign`
--

INSERT INTO `dealer_assign` (`da_id`, `da_staff`, `da_dealer`, `da_fdate`, `da_tdate`) VALUES
(2, 1, 'D001', '2009-12-12', '2010-01-01');

-- --------------------------------------------------------

--
-- Table structure for table `job_location`
--

CREATE TABLE IF NOT EXISTS `job_location` (
  `jl_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `jl_staff` int(11) NOT NULL,
  `jl_fdate` date NOT NULL,
  `jl_tdate` date NOT NULL,
  `jl_region` varchar(6) NOT NULL,
  PRIMARY KEY (`jl_id`),
  KEY `jl_staff` (`jl_staff`),
  KEY `jl_region` (`jl_region`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `job_location`
--

INSERT INTO `job_location` (`jl_id`, `jl_staff`, `jl_fdate`, `jl_tdate`, `jl_region`) VALUES
(2, 1, '2009-12-12', '2010-01-01', 'CTR');

-- --------------------------------------------------------

--
-- Table structure for table `product`
--

CREATE TABLE IF NOT EXISTS `product` (
  `p_id` int(11) NOT NULL AUTO_INCREMENT,
  `p_code` varchar(15) NOT NULL,
  `p_name` varchar(50) NOT NULL,
  `p_price` decimal(10,2) NOT NULL,
  `p_area` varchar(20) NOT NULL,
  PRIMARY KEY (`p_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `product`
--

INSERT INTO `product` (`p_id`, `p_code`, `p_name`, `p_price`, `p_area`) VALUES
(1, 'OB1001', 'ObeXlim Konjac Soy Powder', 200.00, 'East'),
(2, 'OB1002', 'ObeD''tox Detoxofocation & Colon Cleansing', 88.00, 'East');

-- --------------------------------------------------------

--
-- Table structure for table `purchase`
--

CREATE TABLE IF NOT EXISTS `purchase` (
  `pu_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `pu_no` varchar(20) NOT NULL,
  `pu_date` date NOT NULL,
  `pu_staff` int(11) NOT NULL,
  `pu_dealer` varchar(15) NOT NULL,
  `pu_product` int(11) NOT NULL,
  `pu_qty` int(4) NOT NULL,
  `pu_price` decimal(10,2) NOT NULL,
  `pu_grossprice` decimal(10,2) NOT NULL,
  `pu_discount` decimal(10,2) NOT NULL,
  `pu_netprice` decimal(10,2) NOT NULL,
  `pu_foc` varchar(50) NOT NULL,
  PRIMARY KEY (`pu_id`),
  KEY `pu_staff` (`pu_staff`),
  KEY `pu_dealer` (`pu_dealer`),
  KEY `pu_product` (`pu_product`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `purchase`
--

INSERT INTO `purchase` (`pu_id`, `pu_no`, `pu_date`, `pu_staff`, `pu_dealer`, `pu_product`, `pu_qty`, `pu_price`, `pu_grossprice`, `pu_discount`, `pu_netprice`, `pu_foc`) VALUES
(2, '23233', '2009-12-12', 1, 'D001', 1, 2, 200.00, 400.00, 20.00, 380.00, 'ffsdfsfsdfsdf');

-- --------------------------------------------------------

--
-- Table structure for table `region`
--

CREATE TABLE IF NOT EXISTS `region` (
  `r_id` varchar(6) NOT NULL,
  `r_name` varchar(40) NOT NULL,
  `r_area` varchar(20) NOT NULL,
  `r_sort` int(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`r_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `region`
--

INSERT INTO `region` (`r_id`, `r_name`, `r_area`, `r_sort`) VALUES
('CTR', 'Center', 'East', 1),
('SOU', 'South', 'East', 2);

-- --------------------------------------------------------

--
-- Table structure for table `sales_commission`
--

CREATE TABLE IF NOT EXISTS `sales_commission` (
  `sc_id` int(11) NOT NULL AUTO_INCREMENT,
  `sc_min` decimal(10,2) NOT NULL,
  `sc_max` decimal(10,2) NOT NULL,
  `sc_percent` decimal(5,2) NOT NULL,
  `sc_type` varchar(7) NOT NULL,
  PRIMARY KEY (`sc_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;

--
-- Dumping data for table `sales_commission`
--

INSERT INTO `sales_commission` (`sc_id`, `sc_min`, `sc_max`, `sc_percent`, `sc_type`) VALUES
(2, 0.00, 10000.00, 0.00, 'New'),
(3, 10001.00, 50000.00, 1.50, 'New'),
(4, 50001.00, 100000.00, 2.00, 'New'),
(5, 100001.00, 200000.00, 2.50, 'New'),
(6, 200001.00, 999999.00, 3.00, 'New'),
(7, 0.00, 10000.00, 0.00, 'Renewal'),
(8, 10001.00, 100000.00, 0.50, 'Renewal'),
(9, 100001.00, 200000.00, 1.00, 'Renewal'),
(10, 200001.00, 999999.00, 1.50, 'Renewal'),
(11, 0.00, 10000.00, 0.00, 'Manager');

-- --------------------------------------------------------

--
-- Table structure for table `staff`
--

CREATE TABLE IF NOT EXISTS `staff` (
  `s_id` int(11) NOT NULL AUTO_INCREMENT,
  `s_name` varchar(40) NOT NULL,
  `s_ic` varchar(12) NOT NULL,
  `s_contact` varchar(12) NOT NULL,
  `s_email` varchar(40) NOT NULL,
  `s_position` varchar(30) NOT NULL,
  `s_waive` varchar(3) NOT NULL,
  PRIMARY KEY (`s_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `staff`
--

INSERT INTO `staff` (`s_id`, `s_name`, `s_ic`, `s_contact`, `s_email`, `s_position`, `s_waive`) VALUES
(1, 'VS SIM', '43434', '77567', 'sim@ll.com', 'Sales', 'No');

-- --------------------------------------------------------

--
-- Table structure for table `user`
--

CREATE TABLE IF NOT EXISTS `user` (
  `id` varchar(20) NOT NULL,
  `pwd` varchar(100) NOT NULL,
  `level` char(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `user`
--

INSERT INTO `user` (`id`, `pwd`, `level`) VALUES
('admin', 'e10adc3949ba59abbe56e057f20f883e', 'A');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `dealer`
--
ALTER TABLE `dealer`
  ADD CONSTRAINT `dealer_ibfk_1` FOREIGN KEY (`d_region`) REFERENCES `region` (`r_id`);

--
-- Constraints for table `dealer_assign`
--
ALTER TABLE `dealer_assign`
  ADD CONSTRAINT `dealer_assign_ibfk_1` FOREIGN KEY (`da_staff`) REFERENCES `staff` (`s_id`),
  ADD CONSTRAINT `dealer_assign_ibfk_2` FOREIGN KEY (`da_dealer`) REFERENCES `dealer` (`d_id`);

--
-- Constraints for table `job_location`
--
ALTER TABLE `job_location`
  ADD CONSTRAINT `job_location_ibfk_1` FOREIGN KEY (`jl_staff`) REFERENCES `staff` (`s_id`),
  ADD CONSTRAINT `job_location_ibfk_2` FOREIGN KEY (`jl_region`) REFERENCES `region` (`r_id`);

--
-- Constraints for table `purchase`
--
ALTER TABLE `purchase`
  ADD CONSTRAINT `purchase_ibfk_1` FOREIGN KEY (`pu_staff`) REFERENCES `staff` (`s_id`),
  ADD CONSTRAINT `purchase_ibfk_2` FOREIGN KEY (`pu_dealer`) REFERENCES `dealer` (`d_id`),
  ADD CONSTRAINT `purchase_ibfk_3` FOREIGN KEY (`pu_product`) REFERENCES `product` (`p_id`);
