diff --git a/static/images/edit.png b/static/images/edit.png
new file mode 100644
index 0000000..49e0b4f
Binary files /dev/null and b/static/images/edit.png differ
diff --git a/static/images/refresh.png b/static/images/refresh.png
new file mode 100644
index 0000000..2fae1f2
Binary files /dev/null and b/static/images/refresh.png differ
diff --git a/static/images/trash.png b/static/images/trash.png
new file mode 100644
index 0000000..ed387d9
Binary files /dev/null and b/static/images/trash.png differ
diff --git a/static/scripts/tetalab.js b/static/scripts/tetalab.js
index e69de29..f706fc8 100644
--- a/static/scripts/tetalab.js
+++ b/static/scripts/tetalab.js
@@ -0,0 +1,59 @@
+var red = "#FF0000";
+var green = "#00FF00";
+var light_red = "#FCD5DC";
+var light_green = "#D5FCD8";
+var base_bg = "#FEFEFE";
+var base_border = "#555555";
+
+function update_componant(obj, componant_id, type) {
+ if (type == 'numeric') {
+ if (isNaN(obj.value)) {
+ alert('Valeur numérique uniquement');
+ return;
+ }
+ }
+
+ var xhttp = new XMLHttpRequest();
+ xhttp.onerror = function(){
+ obj.style.backgroundColor = light_red;
+ setTimeout( function() {
+ obj.style.backgroundColor = base_bg;
+ }
+ , 2000);
+ };
+
+ xhttp.onload = function(){
+ var bg_color = light_red;
+ var border_color = red;
+ if (xhttp.status == 200) {
+ var response = xhttp.responseText;
+ if (response == 'OK'){
+ bg_color = light_green;
+ border_color = base_border;
+ }
+ }
+ obj.style.backgroundColor = bg_color;
+ obj.style.borderColor = border_color;
+ setTimeout( function() {
+ obj.style.backgroundColor = base_bg;
+ }
+ , 2000);
+ };
+
+ xhttp.onreadystatechange = function() {
+ if (xhttp.readyState == 4 && xhttp.status == 200) {
+ var reponse = xhttp.responseText;
+ if (xhttp.responseText != 'OK')
+ obj.style.backgroundColor = light_red;
+ }
+ };
+
+ xhttp.open('POST', '/componant/update/'+componant_id, true);
+ xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ xhttp.send('field='+obj.id+'&value='+obj.value);
+}
+
+function confirm_delete() {
+ var msg="La suppression est définitive \net n'est pas autorisée si le \ncomposant fait partie d'un Kit.\n\nConfirmer ?";
+ return confirm(msg)
+}
diff --git a/static/style/style.css b/static/style/style.css
index 10d2f85..d0f1a42 100644
--- a/static/style/style.css
+++ b/static/style/style.css
@@ -184,6 +184,195 @@ div.footer {
text-align: center;
}
+/* ***********************************
+ * Tables
+*********************************** */
+
+.border_left {
+ border-left-width: 1px;
+ border-left-style: solid;
+}
+
+.border_right {
+ border-right-width: 1px;
+ border-right-style: solid;
+}
+
+div.block {
+ overflow: hidden;
+ width: 1000px;
+ border-top-style: solid;
+ border-top-width: 1px;
+ height: 20px;
+/*
+ background-color: red;
+*/
+}
+
+div.inner{
+ overflow: hidden;
+ float: center;
+ height: 20px;
+}
+
+div.pages_nav_bar {
+ overflow: hidden;
+ width: 1000px;
+ border-top-style: solid;
+ border-top-width: 1px;
+ height: 20px;
+ text-align: right;
+ padding-top: 10px;
+}
+
+div.block text{
+ width: 200px;
+ float: left;
+ text-align: left;
+ padding: 0 4px 0 4px;
+}
+
+div.block text.num{
+ width: 200px;
+ float: left;
+ padding: 0 4px 0 4px;
+ text-align: right;
+}
+
+div.inner text.edit, div.block text.edit {
+ background: url(../images/edit.png);
+}
+
+div.inner text.trash {
+ background: url(../images/trash.png);
+}
+
+div.block text.refresh {
+ background: url(../images/refresh.png);
+}
+
+div.inner text.edit:hover, div.inner text.trash:hover, div.block text.refresh:hover {
+ background-color: #FFB387;
+ cursor: pointer;
+}
+
+div.inner text.edit {
+ width: 16px;
+ float:left;
+ height: 16px;
+ margin: 2px 0px 0px 20px;
+ border-radius: 2px;
+ background-repeat: no-repeat;
+}
+
+div.inner text.trash, div.inner text.edit, div.block text.refresh {
+ width: 8px;
+ float:left;
+ height: 16px;
+ margin: 2px 0px 0px 20px;
+ border-radius: 2px;
+ background-repeat: no-repeat;
+}
+
+div.even {
+ background-color: #FFFFFF;
+}
+
+div.odd {
+ background-color: #E5E5E5;
+}
+
+div.block label {
+ width: 200px;
+ display: block;
+ float: left;
+ text-align: center;
+ font-weight: bold;
+ background-color: #FF5D00;
+}
+
+div.block label:hover {
+ cursor: pointer;
+}
+
+div.block .input{
+ margin-left:4px;
+ float:left;
+}
+
+
+div.action_bar {
+ display: inline-block;
+ width: 50px;
+ height: 32px;
+}
+
+
+span.prev_page, span.next_page {
+ color: #FF5D00;
+ font-weight: bold;
+ font-size: 12px;
+}
+
+span.prev_page:hover, span.next_page:hover {
+ color: #FFFFFF;
+ background-color: #FF5D00;
+ cursor: pointer;
+}
+
+span.page_num {
+ font-size: 12px;
+}
+
+/* ***********************************
+ * Editables
+*********************************** */
+
+div.no_border {
+ border-style: none;
+ border-width: 0px;
+}
+
+div.margin_bottom {
+ margin-bottom: 4px;
+}
+
+div.block label.editable {
+ height: 18px;
+ text-align: left;
+ padding: 0 4px 0 4px;
+}
+
+div.block text.editable {
+ width: 200px;
+ float: left;
+ padding: 0 4px 0 4px;
+ margin-left: 4px;
+ text-align: right;
+ background-color: #FFFFFF;
+ border-style: solid;
+ border-width: 1px;
+ height: 18px;
+}
+
+div.block select, div.block input {
+ width: 310px;
+ float: left;
+ padding: 0 4px 0 4px;
+ margin-left: 4px;
+ text-align: right;
+ background-color: #FFFFFF;
+ border-style: solid;
+ border-width: 1px;
+ border-color: #555555;
+ color: #555555;
+ height: 18px;
+}
+
+div.block input {
+ height: 17px;
+ width: 300px;
+}
/* ***********************************
* Classes génériques
diff --git a/stock.sql b/stock.sql
index 1786748..ac11f69 100644
--- a/stock.sql
+++ b/stock.sql
@@ -1,43 +1,109 @@
-CREATE TABLE Stock_users (
+drop database tetalab_stock;
+create database tetalab_stock;
+
+\c tetalab_stock;
+
+CREATE TABLE stock_users (
id serial primary key,
mail text not NULL,
password text not NULL,
name text not NULL
);
-
-CREATE TABLE Stock_kits (
+CREATE TABLE stock_kits (
id serial primary key,
name text not NULL,
description text not NULL
);
-
-CREATE TABLE Stock_providers (
+CREATE TABLE stock_providers (
id serial primary key,
+ name text not NULL,
address text not NULL,
mail text not NULL,
url text not NULL,
comment text not NULL
);
-
-CREATE TABLE Stock_componants (
+CREATE TABLE stock_componants (
id serial primary key,
- name text not NULL,
- description text not NULL,
+ reference varchar(20) unique not NULL,
+ designation varchar(50) not NULL,
last_price NUMERIC not NULL,
mean_price NUMERIC not NULL,
quantity NUMERIC not NULL,
min_quantity NUMERIC not NULL,
- place text not NULL,
- provider_id integer REFERENCES Stock_providers(id)
+ place varchar(15) not NULL,
+ provider_id integer REFERENCES stock_providers(id)
);
-
-CREATE TABLE Stock_kit_compositions (
+CREATE TABLE stock_kit_compositions (
id serial primary key,
kit_id integer REFERENCES Stock_kits(id),
- componant_id integer REFERENCES Stock_componants(id),
+ componant_id integer REFERENCES stock_componants(id),
quantity integer not NULL
);
+
+alter table stock_users owner to tetalab_user;
+alter table stock_kits owner to tetalab_user;
+alter table stock_providers owner to tetalab_user;
+alter table stock_componants owner to tetalab_user;
+alter table stock_kit_compositions owner to tetalab_user;
+alter database tetalab_stock owner to tetalab_user;
+
+
+insert into stock_providers (name, address, mail, url, comment)
+ values ('China Elec Co', 'Beijing', 'sales@chinaelecco.cc', 'https://chinaelecco', 'Pas cher, mais...');
+
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-01', 'Resistance 10KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Lor-01', '1 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-02', 'Resistance 11KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-03', 'Resistance 12KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-04', 'Resistance 13KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-05', 'Resistance 14KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Lor-02', '2 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-06', 'Resistance 15KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-07', 'Resistance 16KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-08', 'Resistance 17KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-09', 'Resistance 18KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Lor-03', '3 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-10', 'Resistance 19KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-11', 'Resistance 20KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-12', 'Resistance 21KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-13', 'Resistance 22KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Lor-04', '4 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-14', 'Resistance 23KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-15', 'Resistance 24KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-16', 'Resistance 25KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-17', 'Resistance 26KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Lor-05', '5 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-18', 'Resistance 27KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-19', 'Resistance 28KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
+ values ('Res-20', 'Resistance 29KΩ', 13.34, 12.42, 73, 0, 'B 43', 1);
+
+\c postgres;
diff --git a/templates/componant.html b/templates/componant.html
new file mode 100644
index 0000000..d5f798c
--- /dev/null
+++ b/templates/componant.html
@@ -0,0 +1,132 @@
+{% extends "index.html" %}
+{% block title %}Éditer un composant{% endblock %}
+ {% block top_menu %}
+
+
+
+
+
+ {% endblock %}
+
+ {% block left_menu %}
+
+
+
+
+ {% endblock %}
+
+ {% block content %}
+ Note:
+ Cette page vous permet de modifier directement un composant.
+ À moins de vouloir corriger une erreur de saisie, ou de saisir un inventaire vous ne devez
+ PAS modifier directement
+ les quantités d'un composant.
+ Cliquez sur les liens suivants pour saisir des entrées
+ ou sorties de stock.
+ Composant:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% endblock %}
diff --git a/templates/componants.html b/templates/componants.html
new file mode 100644
index 0000000..db43549
--- /dev/null
+++ b/templates/componants.html
@@ -0,0 +1,52 @@
+{% extends "index.html" %}
+{% block title %}Liste des composants{% endblock %}
+ {% block top_menu %}
+
+
+
+
+ {% endblock %}
+
+ {% block left_menu %}
+
+
+
+
+ {% endblock %}
+
+ {% block content %}
+ Liste des composants
+
+
+
+
+
+
+
+ {% set row_class = cycler('odd', 'even') %}
+ {% for componant in componants %}
+
+
{{ componant.reference }}
+
{{ componant.designation }}
+
{{ componant.quantity }}
+
{{ componant.place }}
+
+
+
+
+
+ {% endfor %}
+
+ <
+ {{ page }} / {{ page_count }}
+ >
+
+ {% endblock %}
diff --git a/templates/index.html b/templates/index.html
index f0a0f24..6977762 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,8 +1,7 @@
-
- Stock Tetalab - {% block title %}Accueil{% endblock %}
+ Tetastock - {% block title %}Accueil{% endblock %}
@@ -12,7 +11,7 @@
- Stock Tetalab
+ Tetastock