diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ebbbe48 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "pasteAndIndent.selectAfter": true +} \ No newline at end of file diff --git a/README.md b/README.md index 9a5da7d..1e8f65e 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ php_HelloWorld + +TODO: + +-oddzielic tytuł main-contentu (divy -> grid display -> gap) \ No newline at end of file diff --git a/add-ah30.php b/add-ah30.php new file mode 100644 index 0000000..d5a5a1a --- /dev/null +++ b/add-ah30.php @@ -0,0 +1,30 @@ + prepare('SELECT * FROM ah30 WHERE address = ?'); + $query->execute([$_POST['address']]); + + $e100 = $query->fetchColumn(); + if(!$e100){ + $query = $db->prepare('INSERT INTO ah30 (address, available) VALUES (?,?)'); + $query->execute([$_POST['address'], TRUE]); + } + else{ + $_SESSION['existing-address'] = true; + } + header("Location: {$_POST['place']}"); +?> \ No newline at end of file diff --git a/add-current-element.php b/add-current-element.php new file mode 100644 index 0000000..56d0ac0 --- /dev/null +++ b/add-current-element.php @@ -0,0 +1,25 @@ + prepare("SELECT quantity FROM inventory WHERE name=? "); + $invPartsQuery->execute([$_POST['name-curr']]); + + $partQty = $invPartsQuery->fetch(); + + $partQty = $partQty['quantity']; + + $partQty += intval($_POST['quantity-curr']); + + $query = $db->prepare('UPDATE `inventory` SET `quantity` = :quantity WHERE `inventory`.`name` = :namee'); + $query->execute([':namee' => $_POST['name-curr'], ':quantity' => intval($partQty)]); + + header("Location: {$_POST['place']}"); +?> \ No newline at end of file diff --git a/add-e100.php b/add-e100.php new file mode 100644 index 0000000..d626058 --- /dev/null +++ b/add-e100.php @@ -0,0 +1,30 @@ + prepare('SELECT * FROM e100 WHERE address = ?'); + $query->execute([$_POST['address']]); + + $e100 = $query->fetchColumn(); + if(!$e100){ + $query = $db->prepare('INSERT INTO e100 (address, available) VALUES (?,?)'); + $query->execute([$_POST['address'], TRUE]); + } + else{ + $_SESSION['existing-address'] = true; + } + header("Location: {$_POST['place']}"); +?> \ No newline at end of file diff --git a/add-new-element.php b/add-new-element.php index 760b314..5c0fa29 100644 --- a/add-new-element.php +++ b/add-new-element.php @@ -5,27 +5,27 @@ function clog( $data ){ echo ''; } - session_start(); #otwiera sesje (zmienne) + session_start(); - //formulaz wysłany? if(!isset($_POST['place'])) { header('Location: inventory-panel.php'); exit(); } - if(strlen($_POST['name'])<3){ + //warunek ilosci znakow + if(strlen($_POST['name-new'])<3){ $_SESSION['name_len'] = true; header("Location: {$_POST['place']}"); exit(); } - require_once 'database.php'; + $db = require_once 'database.php'; - $query = $db->prepare('INSERT INTO inventory (nazwa, ilosc, symbol) VALUES (:namee, :quantity, :symbol)'); - $query->bindValue(':namee', $_POST['name'], PDO::PARAM_STR); - $query->bindValue(':quantity', intval($_POST['quantity']), PDO::PARAM_INT); - $query->bindValue(':symbol', $_POST['symbol'], PDO::PARAM_STR); + $query = $db->prepare('INSERT INTO inventory (name, quantity, symbol) VALUES (:namee, :quantity, :symbol)'); + $query->bindValue(':namee', $_POST['name-new'], PDO::PARAM_STR); + $query->bindValue(':quantity', intval($_POST['quantity-new']), PDO::PARAM_INT); + $query->bindValue(':symbol', $_POST['symbol-new'], PDO::PARAM_STR); $query->execute(); diff --git a/add-pinio.php b/add-pinio.php new file mode 100644 index 0000000..3893733 --- /dev/null +++ b/add-pinio.php @@ -0,0 +1,34 @@ + prepare('SELECT * FROM ah30 WHERE address = ?'); + $query->execute([$_POST['address']]); + + $ah30 = $query->fetchAll(); + if($ah30){ + + if($ah30[0]['available']){ + $query = $db->prepare('INSERT INTO pinio (address, available) VALUES (?,?)'); + $query->execute([$_POST['address'], TRUE]); + + $query = $db->prepare('UPDATE ah30 SET available = ? WHERE ah30.address = ?'); + $query->execute([FALSE, $_POST['address']]); + } + else{ + $_SESSION['no-available'] = true; + } + + } + else{ + $_SESSION['nonexisting-address'] = true; + } + header("Location: {$_POST['place']}"); +?> \ No newline at end of file diff --git a/add-set.php b/add-set.php new file mode 100644 index 0000000..320f148 --- /dev/null +++ b/add-set.php @@ -0,0 +1,26 @@ + prepare('INSERT INTO `sets` (e100, pinio, mask_in, mask_out, trzpien, pad) VALUES (:e100, :pinio, :mask_in, :mask_out, :trzpien, :pad)'); + $query->execute( + [ + e100 => $_POST['e100-address'], + pinio => $_POST['pinio-address'], + mask_in => $_POST['mask-in'], + mask_out => $_POST['mask-out'], + trzpien => $_POST['trzpien'], + pad => $mask_pad + ]); + + header("Location: {$_POST['place']}"); +?> \ No newline at end of file diff --git a/change-ah30.php b/change-ah30.php new file mode 100644 index 0000000..78732dd --- /dev/null +++ b/change-ah30.php @@ -0,0 +1,16 @@ + prepare('UPDATE ah30 SET available = ? WHERE ah30.address = ?'); + $query->execute([$_POST['availibility'], $_POST['address-curr']]); + + header("Location: {$_POST['place']}"); +?> \ No newline at end of file diff --git a/change-e100.php b/change-e100.php new file mode 100644 index 0000000..e1ae4d3 --- /dev/null +++ b/change-e100.php @@ -0,0 +1,16 @@ + prepare('UPDATE e100 SET available = ? WHERE e100.address = ?'); + $query->execute([$_POST['availibility'], $_POST['address-curr']]); + + header("Location: {$_POST['place']}"); +?> \ No newline at end of file diff --git a/style.css b/css/style.css similarity index 51% rename from style.css rename to css/style.css index 6cdcc39..2c5fe1f 100644 --- a/style.css +++ b/css/style.css @@ -1,27 +1,54 @@ :root { --primary-color: #50a1ff; --second-color: #5bc0de; + --back-color: rgb(0, 25, 44); } body{ - background-color: rgb(0, 24, 42); - margin: 13px; + background-color: var(--back-color); font-family: 'Open-sans', sans-serif; } legend{ font-size: 25px; font-weight: bold; - padding-bottom: 15px; } -input[type="number"] { - width:35px; - } +input[type="number"]{ + width:50px; +} h3{ - border-top: 1px solid; + border-bottom: 1px solid; } +/* +* === SCROLLBAR === +*/ + +/* width */ +::-webkit-scrollbar { + width: 5px; + } + + /* Track */ + ::-webkit-scrollbar-track { + box-shadow: inset 0 0 5px rgb(100, 100, 100); + border-radius: 5px; + } + + /* Handle */ + ::-webkit-scrollbar-thumb { + background: var(--back-color); + border-radius: 10px; + } + + /* Handle on hover */ + ::-webkit-scrollbar-thumb:hover { + background: black; + } + + + /* * === LOGIN === */ @@ -40,6 +67,9 @@ h3{ margin-top: 8px; margin-bottom: 8px; } +.info{ + font-size: smaller; +} /* * === END LOGIN === @@ -95,14 +125,14 @@ h3{ */ .main-grid{ display: grid; - gap: 2px; + gap: 6px; grid-template-columns: 14% auto 20%; } - .left-bar{ background-color: var(--primary-color); padding: 10px; display: grid; + align-content: start; gap: 2px; } .main-content{ @@ -110,9 +140,16 @@ h3{ padding: 10px; } .right-bar{ + display: grid; + grid-gap: 5px; + min-width: 235px; background-color: var(--primary-color); padding: 10px; +} +.right-bar div{ + max-height: 200px; + overflow: auto; } /* @@ -121,6 +158,7 @@ h3{ table{ width: 100%; border-collapse: collapse; + margin-bottom: 10px; } table, th, td{ padding: 2px; @@ -144,6 +182,80 @@ tr:nth-child(even){ .add-form{ display: inline-grid; grid-template-columns: auto auto auto auto; - gap: 10px; +} +.add-new-section{ + padding-top: 15px; +} + +/* +* === E100 (AH30) FORM === +*/ + +.e100-main-content{ + width: 99%; + display: grid; + gap: 6px; + grid-template-columns: 75% 25%; + grid-template-rows: auto auto; +} +.e100-available{ + grid-column: 1; + grid-row: 2; +} +.e100-inventory{ + grid-column: 2; + grid-row: 1 / last-line; +} + +#availibility-select{ + display: none; +} + + +/* +* === SET FORM === +*/ + +.kit-form legend { + padding-bottom: 10px; +} +.kit-form label { + font-weight: bold; +} +.kit-form div { + padding: 5px; + border-bottom: 1px solid; +} +.kit-form-class{ + display: grid; + grid-template-columns: 35% 35% ; + justify-items: stretch; +} +.kit-form-add-button{ + margin:10px; + padding:5px; + width: 80px; + grid-column: 2; +} + +/* +* === INVENTORY PANEL === +*/ + +.inventory-panel{ + display: grid; + gap: inherit; + grid-template-columns: repeat(4, auto); + grid-column: 2/4; +} +.inventory-panel div{ + background-color: var(--primary-color); + padding: 10px; + height: fit-content; +} +.kits-inventory{ + margin-bottom: 15px; + grid-column: 1/5; + justify-self: start; } \ No newline at end of file diff --git a/database.php b/database.php index 6825661..6310c1e 100644 --- a/database.php +++ b/database.php @@ -4,10 +4,10 @@ try{ - $db = new PDO("mysql:host={$host};dbname={$db_name};charset=utf8", $db_user, $db_password, [ + return( new PDO("mysql:host={$host};dbname={$db_name};charset=utf8", $db_user, $db_password, [ PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION - ]); + ])); }catch(PDOException $error){ diff --git a/html-magazyn.php b/html-magazyn.php new file mode 100644 index 0000000..4a1db34 --- /dev/null +++ b/html-magazyn.php @@ -0,0 +1,84 @@ +query('SELECT * FROM inventory'); +$invParts = $invPartsQuery->fetchAll(); + +$e100Query = $db->query('SELECT * FROM e100'); +$e100 = $e100Query->fetchAll(); + +$pinioQuery = $db->query('SELECT * FROM pinio'); +$pinio = $pinioQuery->fetchAll(); + +$ah30Query = $db->query('SELECT * FROM ah30'); +$ah30 = $ah30Query->fetchAll(); + +?> +
+ Magazyn + + + + + + "; + } + ?> + +
IDNazwaIlośćSymbol
{$part['id']}{$part['name']}{$part['quantity']}{$part['symbol']}
+
+ +
+ Stan E100 + + + + + + "; + } + ?> + +
IDAdresDostępność
{$part['id']}{$part['address']}{$part['available']}
+
+ +
+ Stan PINIO: + + + + + + "; + } + ?> + +
IDAdresDostępność
{$part['id']}{$part['address']}{$part['available']}
+
+ +
+ Stan AH30 + + + + + + "; + } + ?> + +
IDAdresDostępność
{$part['id']}{$part['address']}{$part['available']}
+
diff --git a/index.php b/index.php index fccf578..f73a9fa 100644 --- a/index.php +++ b/index.php @@ -4,7 +4,6 @@ $haslo = "alex1" var_dump(password_hash($haslo, PASSWORD_DEFAULT)); exit(); - */ function clog( $data ){ echo ' diff --git a/inventory-add-ah30.php b/inventory-add-ah30.php new file mode 100644 index 0000000..1ee2731 --- /dev/null +++ b/inventory-add-ah30.php @@ -0,0 +1,175 @@ + +query('SELECT * FROM ah30'); + $ah30 = $ah30Query->fetchAll(); +?> + + + + + + + + Dodaj AH30 + + + + + + +
+
+ + + + Wyloguj się + +
+
+
+ Opcje + + + + + + +
+
+ AH30: + +
+ +
+
+

Dodaj AH30:

+ Nieprawidłowy adres (format: "[XX.XX.XX]")
'); + unset($_SESSION['invalid-address']); + } + if(isset($_SESSION['existing-address'])){ + echo('
Adres już istnieje w bazie
'); + unset($_SESSION['existing-address']); + } + ?> + + + + + +
+ +
+
+

Zmień dostępność:

+ + + + + +
+
+
+

Stan AH30:

+ + + + + + "; + } + ?> + +
IDAdresDostępność
{$part['id']}{$part['address']}{$part['available']}
+
+
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/inventory-add-e100.php b/inventory-add-e100.php new file mode 100644 index 0000000..5e0df34 --- /dev/null +++ b/inventory-add-e100.php @@ -0,0 +1,178 @@ + +query('SELECT * FROM e100'); + $e100 = $e100Query->fetchAll(); + +?> + + + + + + + + Dodaj E100 + + + + + + +
+
+ + + + Wyloguj się + +
+
+
+ Opcje + + + + + + +
+
+ E100: + +
+ +
+
+

Dodaj E100:

+ Nieprawidłowy adres (format: \"[XX.XX.XX]\")
'); + unset($_SESSION['invalid-address']); + } + if(isset($_SESSION['existing-address'])){ + echo('
Adres już istnieje w bazie
'); + unset($_SESSION['existing-address']); + } + + + ?> + + + + + +
+ +
+
+

Zmień dostępność:

+ + + + + +
+
+
+

Stan E100:

+ + + + + + "; + } + ?> + +
IDAdresDostępność
{$part['id']}{$part['address']}{$part['available']}
+
+
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/inventory-add-element.php b/inventory-add-element.php index 49e9db6..7fcb688 100644 --- a/inventory-add-element.php +++ b/inventory-add-element.php @@ -1,5 +1,17 @@ + '; + echo 'console.log('. json_encode( $data ) .')'; + echo ''; + } + clog("*** CONSOLE LOGS AVAILABLE ***"); + session_start(); if(!isset($_SESSION['log-in'])) @@ -8,10 +20,10 @@ exit(); } - require_once 'database.php'; - + $db = require_once 'database.php'; $invPartsQuery = $db->query('SELECT * FROM inventory'); $invParts = $invPartsQuery->fetchAll(); + ?> @@ -19,8 +31,8 @@ - - Magazyn Pinio.io + + Dodaj element @@ -38,36 +50,69 @@
Opcje - - - - + + + + +
- Dodaj akcesorium: -
-
+ Dodaj akcesorium: + +
+ +

Dodaj istniejący element

+
+
+ + +
+
+ + +
+
+ + + +
+ +
+

Dodaj nowy element

+ Nazwa musi posiadać co najmniej 3 znaki
'); + unset($_SESSION['name_len']); + } + ?>
- Nazwa - - - - + +
- Ilość - + +
- Symbol - + +
@@ -76,19 +121,9 @@
- Magazyn - - - - - - "; - } - ?> - -
IDNazwaIlośćSymbol
{$part['id']}{$part['nazwa']}{$part['ilosc']}{$part['symbol']}
+
+ + \ No newline at end of file diff --git a/inventory-add-set.php b/inventory-add-set.php new file mode 100644 index 0000000..b20f198 --- /dev/null +++ b/inventory-add-set.php @@ -0,0 +1,195 @@ + + +query('SELECT * FROM e100'); + $e100 = $e100Query->fetchAll(); + + $pinioQuery = $db->query('SELECT * FROM pinio'); + $pinio = $pinioQuery->fetchAll(); +?> + + + + + + + + Dodaj zestaw + + + + + +
+
+ + + + Wyloguj się + +
+
+
+ Opcje + + + + + + +
+
+
+ Dodaj zestaw: +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + +
+
+
+
+ +
+
+ +
+ + + + + \ No newline at end of file diff --git a/inventory-panel.php b/inventory-panel.php index eb7069c..861dca1 100644 --- a/inventory-panel.php +++ b/inventory-panel.php @@ -1,3 +1,9 @@ + + query('SELECT * FROM inventory'); - $invParts = $invPartsQuery->fetchAll(); + $setQuery = $db->query('SELECT * FROM `sets`'); + $sets = $setQuery->fetchAll(); ?> @@ -19,7 +25,7 @@ - + Magazyn Pinio.io @@ -37,32 +43,41 @@
Opcje - + - - - -
-
- Dostępne zestawy: - - + + + +
-
- Magazyn - - - - - - "; +
+
+ Dostępne zestawy + +
IDNazwaIlośćSymbol
{$part['id']}{$part['nazwa']}{$part['ilosc']}{$part['symbol']}
+ + + + + "; + if($set['pad']){ + echo ""; + } + else{ + echo ""; + } } - ?> - -
ID E100 PINIO Mask.(IN/OUT) Trzpień Podkładki
{$set['id']} {$set['e100']} {$set['pinio']}{$set['mask_in']}/{$set['mask_out']}{$set['trzpien']}2szt
brak
-
+ ?> + + +
+ + + diff --git a/login.php b/login.php index f2318bf..b5f17be 100644 --- a/login.php +++ b/login.php @@ -8,16 +8,14 @@ function clog( $data ){ define('SITE_KEY', '6LcJWdIUAAAAAEr28fa-1qZsY9mwNmA22LzJgyHl'); define('SECRET_KEY', '6LcJWdIUAAAAAPiz33XGansAvptf3vlY3uxUmCRr'); - session_start(); #otwiera sesje (zmienne) + session_start(); - //formulaz wysłany? if((!isset($_POST['mail'])) || (!isset($_POST['password']))) { header('Location: index.php'); exit(); } - - //formularz przyjety + $evertyhing_OK = true; //test captchy @@ -27,8 +25,7 @@ function getCaptcha($SecretKey){ return $Return; } $Return = getCaptcha($_POST['g-recaptcha-response']); - if(!(($Return -> success == true) && ($Return -> score > 0.5))){ //test captcha nie zaliczony - + if(!(($Return -> success == true) && ($Return -> score > 0.5))){ $evertyhing_OK = false; $_SESSION['err_CAPTCHA'] = "Test CAPTCHA nie przeszedł pomyślnie. Wynik: ".$Return -> score; header('Location: index.php'); @@ -38,9 +35,8 @@ function getCaptcha($SecretKey){ //test maila $mail = $_POST['mail']; - $sanitizeMail = filter_var($mail, FILTER_SANITIZE_EMAIL); //usuniecie z maila niedozwolonych znakow - - if((filter_var($sanitizeMail, FILTER_VALIDATE_EMAIL)==false) || ($sanitizeMail != $mail)){ //test poprawnosci maila + $sanitizeMail = filter_var($mail, FILTER_SANITIZE_EMAIL); + if((filter_var($sanitizeMail, FILTER_VALIDATE_EMAIL)==false) || ($sanitizeMail != $mail)){ $evertyhing_OK = false; $_SESSION['err_mail'] = "Niepoprawny E-mail"; header('Location: index.php'); @@ -49,53 +45,49 @@ function getCaptcha($SecretKey){ if($evertyhing_OK == true){ - //kod gdy testy zakoncza sie pomyslnie - require_once "connect.php"; #"wklejaj" tutaj to co jest w pliku connect.php (tam są dane do polaczenia sie z baza danych + require_once "connect.php"; mysqli_report(MYSQLI_REPORT_STRICT); try{ - $connect = new mysqli($host, $db_user, $db_password, $db_name); #laczy sie z baza o danych pobranych z pliku wyzej + $connect = new mysqli($host, $db_user, $db_password, $db_name); - if($connect -> connect_errno !=0) #sprawdza polaczenie, jezeli sie nie udalo to bedzie error + if($connect -> connect_errno !=0) { throw new Exception(mysqli_connect_errno()); }else{ - $mail = $_POST['mail']; #zaciaga zmienne wyslane do tego pliku metoda post + $mail = $_POST['mail']; $password = $_POST['password']; $mail = htmlentities($mail, ENT_QUOTES, "UTF-8"); $result = $connect -> query(sprintf("SELECT * FROM logins WHERE mail = '%s'", mysqli_real_escape_string($connect, $mail)));#wysyla zapytanie do bazy if(!$result) throw new Exception($connect->error); - $rows = $result -> num_rows; #pobiera informacje o ilosci wierszy - if($rows>0) #poprawny login, jezeli sa jakies pobrane wiersze (w przypadku logowania powinno byc zawsze 1 lub 0) + $rows = $result -> num_rows; + if($rows>0) { - $row = $result -> fetch_assoc(); #tablica asocjacyjna wartosci z tego wiersza - if(password_verify($password, $row['password'])){ #sprawdzanie hashowanego hasła - - $_SESSION['log-in'] = true; #zmienna flaga ktora mowi ze ktos jest zalogowany + $row = $result -> fetch_assoc(); + if(password_verify($password, $row['password'])){ + $_SESSION['log-in'] = true; - $_SESSION['id'] = $row['id']; #zmeinne sesyjne + $_SESSION['id'] = $row['id']; $_SESSION['mail'] = $row['mail']; - unset($_SESSION['err_mail']); #usun z pamieci zmienna bledu logowania + unset($_SESSION['err_mail']); unset($_SESSION['err_pass']); - $result -> close(); #czyszczenie pamieci + $result -> close(); header("Location: inventory-panel.php"); }else { $_SESSION['err_pass'] = 'Nieprawidłowe hasło'; header('Location: index.php'); } - } else { #mysql zwrocil 0 rekordow dotyczacych zapytania (nieprawidlowe dane) - + } else { $_SESSION['err_mail'] = 'Nieprawidłowy mail'; header('Location: index.php'); - } - $connect -> close(); #zamyka polaczenie + $connect -> close(); } } catch(Exception $e){ diff --git a/magazynpinio.sql b/magazynpinio.sql index faad38a..9294ea0 100644 --- a/magazynpinio.sql +++ b/magazynpinio.sql @@ -1,11 +1,11 @@ -- phpMyAdmin SQL Dump --- version 5.0.1 +-- version 4.9.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 --- Czas generowania: 05 Lut 2020, 14:13 --- Wersja serwera: 10.4.11-MariaDB --- Wersja PHP: 7.4.1 +-- Czas generowania: 21 Lut 2020, 17:20 +-- Wersja serwera: 10.4.10-MariaDB +-- Wersja PHP: 7.3.12 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; @@ -30,17 +30,27 @@ SET time_zone = "+00:00"; CREATE TABLE `ah30` ( `id` int(11) NOT NULL, - `adres` text NOT NULL, - `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() + `address` text NOT NULL, + `available` tinyint(1) NOT NULL, + `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `add_date` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Zrzut danych tabeli `ah30` -- -INSERT INTO `ah30` (`id`, `adres`, `timestamp`) VALUES -(1, '[09.26.00]', '2020-02-05 13:11:38'), -(2, '[xx.xx.xx]', '2020-02-05 13:07:03'); +INSERT INTO `ah30` (`id`, `address`, `available`, `timestamp`, `add_date`) VALUES +(1, '[09.26.00]', 0, '2020-02-21 11:59:49', '2020-02-05 14:49:12'), +(2, '[xx.xx.xx]', 0, '2020-02-17 17:55:01', '2020-02-05 14:49:12'), +(3, '[12.31.23]', 0, '2020-02-21 11:22:57', '2020-02-17 18:49:36'), +(7, '[SD.FA.SD]', 0, '2020-02-21 11:59:56', '2020-02-21 11:25:43'), +(8, '[AS.DF.AS]', 0, '2020-02-21 10:43:43', '2020-02-21 11:25:46'), +(9, '[21.34.54]', 0, '2020-02-21 12:22:50', '2020-02-21 11:25:49'), +(10, '[12.34.56]', 0, '2020-02-21 14:57:58', '2020-02-21 11:25:52'), +(11, '[12.34.53]', 0, '2020-02-21 10:44:03', '2020-02-21 11:26:02'), +(12, '[12.34.55]', 1, '2020-02-21 11:00:08', '2020-02-21 12:00:08'), +(13, '[AS.4F.D2]', 1, '2020-02-21 11:00:20', '2020-02-21 12:00:20'); -- -------------------------------------------------------- @@ -50,16 +60,26 @@ INSERT INTO `ah30` (`id`, `adres`, `timestamp`) VALUES CREATE TABLE `e100` ( `id` int(11) NOT NULL, - `adres` text NOT NULL, - `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() + `address` text NOT NULL, + `available` tinyint(1) NOT NULL, + `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `add_date` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Zrzut danych tabeli `e100` -- -INSERT INTO `e100` (`id`, `adres`, `timestamp`) VALUES -(1, '[0A.BA.1E]', '2020-02-05 13:09:40'); +INSERT INTO `e100` (`id`, `address`, `available`, `timestamp`, `add_date`) VALUES +(1, '[0A.BA.1E]', 1, '2020-02-17 12:35:25', '2020-02-05 14:49:34'), +(2, '[xx.xx.xx]', 1, '2020-02-21 08:23:12', '2020-02-14 16:17:51'), +(3, '[AS.AD.SD]', 0, '2020-02-21 08:23:16', '2020-02-14 16:19:41'), +(4, '[12.3D.AC]', 1, '2020-02-15 13:37:35', '2020-02-14 16:19:48'), +(5, '[12.34.56]', 1, '2020-02-17 19:51:46', '2020-02-14 16:28:37'), +(6, '[12.31.23]', 1, '2020-02-17 19:52:02', '2020-02-14 16:43:09'), +(7, '[AS.DA.SD]', 1, '2020-02-15 10:42:43', '2020-02-15 11:42:43'), +(42, 'sdfsd', 1, '2020-02-17 20:08:01', '2020-02-17 21:08:01'), +(43, 'asd', 1, '2020-02-17 20:10:18', '2020-02-17 21:10:18'); -- -------------------------------------------------------- @@ -69,20 +89,25 @@ INSERT INTO `e100` (`id`, `adres`, `timestamp`) VALUES CREATE TABLE `inventory` ( `id` int(11) NOT NULL, - `nazwa` text NOT NULL, - `ilosc` int(11) NOT NULL, + `name` text NOT NULL, + `quantity` int(11) NOT NULL, `symbol` text NOT NULL, - `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() + `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `add_date` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Zrzut danych tabeli `inventory` -- -INSERT INTO `inventory` (`id`, `nazwa`, `ilosc`, `symbol`, `timestamp`) VALUES -(1, 'E100', 1, '', '2020-02-05 13:12:29'), -(2, 'AH30', 1, '', '2020-02-05 13:12:29'), -(3, 'PINIO', 1, '', '2020-02-05 13:12:29'); +INSERT INTO `inventory` (`id`, `name`, `quantity`, `symbol`, `timestamp`, `add_date`) VALUES +(1, 'E100', 8, '', '2020-02-21 08:23:16', '2020-02-05 14:48:43'), +(2, 'AH30', 2, '', '2020-02-21 14:57:58', '2020-02-05 14:48:43'), +(3, 'PINIO', 2, '', '2020-02-13 13:28:58', '2020-02-05 14:48:43'), +(4, 'Bateria', 5, 'Philips003', '2020-02-13 13:28:52', '2020-02-11 20:46:07'), +(5, 'Karta pamięci', 1, 'memXD', '2020-02-13 13:00:41', '2020-02-13 12:40:48'), +(6, 'Test', 1, 't1', '2020-02-13 14:29:46', '2020-02-13 15:29:46'), +(7, 'test2', 1, '', '2020-02-21 10:31:06', '2020-02-21 11:31:06'); -- -------------------------------------------------------- @@ -94,16 +119,68 @@ CREATE TABLE `logins` ( `id` int(11) NOT NULL, `mail` text NOT NULL, `password` text NOT NULL, - `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() + `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `add_date` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Zrzut danych tabeli `logins` -- -INSERT INTO `logins` (`id`, `mail`, `password`, `timestamp`) VALUES -(1, 'al@pinio.io', '$2y$10$cNYxv5mncnVabh/n.6rz8uFlEgfUmw5Ln.ytzlLcEoSJ9nnCrd7du', '2020-02-05 13:13:12'), -(3, 'mail@mail.pl', '$2y$10$5FGZ1ius0Wq327bMGnPYoen5oyuKb8JvDjVZ89uoNtvS5hzTRBYse', '2020-02-05 13:13:12'); +INSERT INTO `logins` (`id`, `mail`, `password`, `timestamp`, `add_date`) VALUES +(1, 'al@pinio.io', '$2y$10$cNYxv5mncnVabh/n.6rz8uFlEgfUmw5Ln.ytzlLcEoSJ9nnCrd7du', '2020-02-05 13:46:04', '2020-02-05 14:23:00'), +(3, 'mail@mail.pl', '$2y$10$5FGZ1ius0Wq327bMGnPYoen5oyuKb8JvDjVZ89uoNtvS5hzTRBYse', '2020-02-05 13:22:24', '2020-02-05 14:22:15'); + +-- -------------------------------------------------------- + +-- +-- Struktura tabeli dla tabeli `pinio` +-- + +CREATE TABLE `pinio` ( + `id` int(11) NOT NULL, + `address` text NOT NULL, + `available` tinyint(1) NOT NULL, + `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `add_date` datetime NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Zrzut danych tabeli `pinio` +-- + +INSERT INTO `pinio` (`id`, `address`, `available`, `timestamp`, `add_date`) VALUES +(1, '[12.31.23]', 1, '2020-02-21 11:22:57', '2020-02-21 12:22:57'), +(2, '[09.26.00]', 1, '2020-02-21 11:59:49', '2020-02-21 12:59:49'), +(3, '[SD.FA.SD]', 1, '2020-02-21 11:59:56', '2020-02-21 12:59:56'), +(4, '[21.34.54]', 1, '2020-02-21 12:22:50', '2020-02-21 13:22:50'), +(5, '[12.34.56]', 1, '2020-02-21 14:57:58', '2020-02-21 15:57:58'); + +-- -------------------------------------------------------- + +-- +-- Struktura tabeli dla tabeli `sets` +-- + +CREATE TABLE `sets` ( + `id` int(11) NOT NULL, + `e100` text NOT NULL, + `pinio` text NOT NULL, + `mask_in` int(11) NOT NULL, + `mask_out` int(11) NOT NULL, + `trzpien` text NOT NULL, + `pad` tinyint(1) NOT NULL, + `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `add_date` datetime NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Zrzut danych tabeli `sets` +-- + +INSERT INTO `sets` (`id`, `e100`, `pinio`, `mask_in`, `mask_out`, `trzpien`, `pad`, `timestamp`, `add_date`) VALUES +(1, '[0A.BA.1E]', '[12.31.23]', 70, 70, '8/40-50', 1, '2020-02-21 15:44:51', '0000-00-00 00:00:00'), +(2, '[xx.xx.xx]', '[12.31.23]', 72, 72, '8mm/60-70mm (śruby M5x50 3szt.)', 0, '2020-02-21 16:09:59', '2020-02-21 17:09:59'); -- -- Indeksy dla zrzutów tabel @@ -134,32 +211,56 @@ ALTER TABLE `logins` ADD PRIMARY KEY (`id`); -- --- AUTO_INCREMENT for dumped tables +-- Indeksy dla tabeli `pinio` +-- +ALTER TABLE `pinio` + ADD PRIMARY KEY (`id`); + +-- +-- Indeksy dla tabeli `sets` +-- +ALTER TABLE `sets` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT dla tabel zrzutów -- -- -- AUTO_INCREMENT dla tabeli `ah30` -- ALTER TABLE `ah30` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14; -- -- AUTO_INCREMENT dla tabeli `e100` -- ALTER TABLE `e100` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=45; -- -- AUTO_INCREMENT dla tabeli `inventory` -- ALTER TABLE `inventory` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT dla tabeli `logins` -- ALTER TABLE `logins` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; + +-- +-- AUTO_INCREMENT dla tabeli `pinio` +-- +ALTER TABLE `pinio` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; + +-- +-- AUTO_INCREMENT dla tabeli `sets` +-- +ALTER TABLE `sets` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/set-e100ah30-qty.php b/set-e100ah30-qty.php new file mode 100644 index 0000000..fb65d83 --- /dev/null +++ b/set-e100ah30-qty.php @@ -0,0 +1,13 @@ +prepare('SELECT * FROM '.strtolower($part).' WHERE available = "1"'); + $query->execute(); + $query = $query->fetchAll(); + + $quantity = count($query); + + $query = $db->prepare('UPDATE inventory SET quantity = ? WHERE inventory.name = ?'); + $query->execute([$quantity, $part]); +} \ No newline at end of file diff --git a/testy.php b/testy.php new file mode 100644 index 0000000..7488c82 --- /dev/null +++ b/testy.php @@ -0,0 +1,65 @@ + + + + + + + + + + + +
+ + + +
+ + + +