-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 17, 2017 at 11:35 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!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: `ETFnabavke2017`
--
CREATE DATABASE IF NOT EXISTS `ETFnabavke2017` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `ETFnabavke2017`;

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

--
-- Table structure for table `korisnik`
--

DROP TABLE IF EXISTS `korisnik`;
CREATE TABLE IF NOT EXISTS `korisnik` (
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `kabinet` int(11) NOT NULL,
  `datumrodj` date NOT NULL,
  `je_prodekan` tinyint(4) NOT NULL COMMENT 'fleg za tip korisnika',
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `korisnik`
--

INSERT INTO `korisnik` (`username`, `password`, `ime`, `prezime`, `kabinet`, `datumrodj`, `je_prodekan`) VALUES
('bosko', 'sifra123', 'Boško', 'Nikolić', 1910, '1970-05-05', 0),
('drasko', 'sifra123', 'Dražen', 'Drašković', 1909, '1990-08-08', 0),
('goran', 'prodekan123', 'Goran', 'Kvaščev', 1916, '1970-01-01', 1),
('majce', 'sifra123', 'Maja', 'Vukasović', 1914, '1995-05-25', 0),
('micko', 'sifra123', 'Marko', 'Mićović', 1909, '1995-07-10', 0),
('sanja', 'sifra123', 'Sanja', 'Delčeva', 1912, '1995-10-10', 0),
('uki', 'sifra123', 'Uroš', 'Radenković', 1909, '1995-09-25', 0),
('vlada', 'sifra123', 'Vladimir', 'Jocović', 1914, '1995-12-31', 0);

-- --------------------------------------------------------
--
-- Table structure for table `artikal`
--

DROP TABLE IF EXISTS `artikal`;
CREATE TABLE IF NOT EXISTS `artikal` (
  `IDart` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primarni ključ',
  `naziv` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `proizvodjac` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `boja` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
  `materijal` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
  `opis` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `tip` varchar(1) COLLATE utf8_unicode_ci NOT NULL COMMENT 'O - oprema, N - namestaj, K - kanc.materijal',
  PRIMARY KEY (`IDart`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;

--
-- Dumping data for table `artikal`
--

INSERT INTO `artikal` (`IDart`, `naziv`, `proizvodjac`, `boja`, `materijal`, `opis`, `tip`) VALUES
(1, 'Hemijska olovka', 'Staedtler', NULL, NULL, 'Piše "4 u 1": crvena, plava, zelena i žuta', 'K'),
(2, 'Radna stolica', 'Blažeks Kragujevac', 'crna', 'eko-koža', 'Udobna kancelarijska stolica sa sunđerom i drvenom zvezdom.', 'N'),
(3, 'Štampač M1613', 'Hewlett Packard', NULL, NULL, 'Laserski štampač u boji', 'O'),
(4, 'Papir A4', 'Papirus', NULL, NULL, 'Papir RIS - 500 kom. 125g težine', 'K'),
(5, 'Monitor E2220', 'Samsung ', NULL, NULL, 'LCD monitor 24"', 'O'),
(6, 'Registrator', 'Biro-line Srbija', NULL, NULL, 'sa automatskim mehanizmom', 'K'),
(7, 'Radni sto', 'Ktitor', 'bež', 'drvo', 'Radna ploča 180x80cm', 'N'),
(8, 'Čiviluk', 'Kika', 'braon', 'drvo/metal', 'Postolje od metala, čiviluk za 8 kaputa i posudom za kišobrane', 'N');

-- --------------------------------------------------------
--
-- Table structure for table `narudzbina`
--

DROP TABLE IF EXISTS `narudzbina`;
CREATE TABLE IF NOT EXISTS `narudzbina` (
  `IDnar` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primarni ključ',
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `IDart` int(11) NOT NULL,
  `kolicina` int(11) NOT NULL,
  `jedinicna_cena` double NOT NULL,
  `ukupna_cena` double NOT NULL,
  `odobrenje` int(11) NOT NULL COMMENT 'naruceno 1, odbijeno 0, odobreno 2',
  PRIMARY KEY (`IDnar`),
  KEY `username` (`username`,`IDart`),
  KEY `IDart` (`IDart`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;

--
-- Dumping data for table `narudzbina`
--

INSERT INTO `narudzbina` (`IDnar`, `username`, `IDart`, `kolicina`, `jedinicna_cena`, `ukupna_cena`, `odobrenje`) VALUES
(1, 'majce', 1, 50, 90, 4500, 1),
(2, 'sanja', 6, 18, 229, 4122, 2),
(3, 'drasko', 3, 1, 126000, 126000, 2),
(4, 'micko', 2, 4, 12500, 50000, 1),
(5, 'uki', 5, 3, 20800, 62400, 1),
(6, 'bosko', 4, 15, 450, 6757.5, 0),
(7, 'vlada', 7, 2, 13650.42, 27300.84, 1),
(8, 'majce', 8, 5, 2905.75, 14528.75, 1);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `narudzbina`
--
ALTER TABLE `narudzbina`
  ADD CONSTRAINT `narudzbina_ibfk_2` FOREIGN KEY (`IDart`) REFERENCES `artikal` (`IDart`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `narudzbina_ibfk_1` FOREIGN KEY (`username`) REFERENCES `korisnik` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;

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