"Added: Add componant feature"
This commit is contained in:
parent
6cf5daf2a1
commit
1e1ead5888
BIN
static/images/save.png
Normal file
BIN
static/images/save.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 357 B |
@ -15,6 +15,33 @@ function setcookie(cname, cvalue, exdays) {
|
|||||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getcookie(cname) {
|
||||||
|
var value = "; " + document.cookie;
|
||||||
|
var parts = value.split("; " + cname + "=");
|
||||||
|
if (parts.length == 2) return parts.pop().split(";").shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// Eye candies
|
||||||
|
///////////////////////////////////////////
|
||||||
|
|
||||||
|
function invalid_input(obj) {
|
||||||
|
obj.style.backgroundColor = light_red;
|
||||||
|
setTimeout( function() {
|
||||||
|
obj.style.backgroundColor = base_bg;
|
||||||
|
}
|
||||||
|
, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function valid_input(obj) {
|
||||||
|
obj.style.backgroundColor = light_green;
|
||||||
|
obj.style.borderColor = base_border;
|
||||||
|
setTimeout( function() {
|
||||||
|
obj.style.backgroundColor = base_bg;
|
||||||
|
}
|
||||||
|
, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
// Update result
|
// Update result
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
@ -26,18 +53,16 @@ function update_componants() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
xhttp.onload = function(){
|
xhttp.onload = function(){
|
||||||
if (xhttp.status == 200) {
|
if (xhttp.status != 200) {
|
||||||
var response = xhttp.responseText;
|
obj.innerHTML = "Erreur lors de la mise à jour de la liste (2)"
|
||||||
obj.innerHTML = response;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
obj.innerHTML = "Erreur lors de la mise à jour de la liste (2)"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||||
var response = xhttp.responseText;
|
var response = xhttp.responseText;
|
||||||
obj.innerHTML = response;
|
obj.innerHTML = response;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhttp.open('POST', '/componants/update', true);
|
xhttp.open('POST', '/componants/update', true);
|
||||||
@ -117,51 +142,86 @@ function confirm_delete() {
|
|||||||
return confirm(msg)
|
return confirm(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// New componant
|
||||||
|
///////////////////////////////////////////
|
||||||
|
function new_componant() {
|
||||||
|
var err = false;
|
||||||
|
var obj = {};
|
||||||
|
if (getcookie('c_count') > 0){
|
||||||
|
var errr = true;
|
||||||
|
obj[0] = document.getElementById('reference');
|
||||||
|
}
|
||||||
|
if (getcookie('c_designation').length < 1){
|
||||||
|
var err = true;
|
||||||
|
obj[1] = document.getElementById('designation');
|
||||||
|
}
|
||||||
|
if (getcookie('c_place').length < 1){
|
||||||
|
var err = true;
|
||||||
|
obj[2] = document.getElementById('place');
|
||||||
|
}
|
||||||
|
if (err == true) {
|
||||||
|
for (i in obj){
|
||||||
|
invalid_input(obj[i]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
create_componant();
|
||||||
|
update_componants();
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_componant() {
|
||||||
|
var MSG='Erreur lors de la creation de la référence.';
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onerror = function(){
|
||||||
|
alert(MSG);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
xhttp.onload = function(){
|
||||||
|
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||||
|
var response = xhttp.responseText;
|
||||||
|
if (response == 'OK'){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
alert(MSG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xhttp.open('POST', '/componants/new', true);
|
||||||
|
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
// Update componant
|
// Update componant
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
function update_componant(obj, componant_id, type) {
|
function update_componant(obj, componant_id, type) {
|
||||||
if (type == 'numeric') {
|
if (type == 'numeric') {
|
||||||
if (isNaN(obj.value)) {
|
if (isNaN(obj.value)) {
|
||||||
alert('Valeur numérique uniquement');
|
alert('Valeur numérique uniquement: '+obj.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
xhttp.onerror = function(){
|
xhttp.onerror = function(){
|
||||||
obj.style.backgroundColor = light_red;
|
invalid_input(obj);
|
||||||
setTimeout( function() {
|
|
||||||
obj.style.backgroundColor = base_bg;
|
|
||||||
}
|
|
||||||
, 2000);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
xhttp.onload = function(){
|
xhttp.onload = function(){
|
||||||
var bg_color = light_red;
|
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||||
var border_color = red;
|
|
||||||
if (xhttp.status == 200) {
|
|
||||||
var response = xhttp.responseText;
|
var response = xhttp.responseText;
|
||||||
if (response == 'OK'){
|
if (response == 'OK'){
|
||||||
bg_color = light_green;
|
valid_input(obj);
|
||||||
border_color = base_border;
|
return;
|
||||||
}
|
}
|
||||||
|
obj.style.borderColor = red;
|
||||||
|
invalid_input(obj);
|
||||||
}
|
}
|
||||||
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', '/componants/update/'+componant_id, true);
|
xhttp.open('POST', '/componants/update/'+componant_id, true);
|
||||||
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
xhttp.send('field='+obj.id+'&value='+obj.value);
|
xhttp.send('field='+obj.id+'&value='+obj.value);
|
||||||
|
@ -139,16 +139,9 @@ div.content {
|
|||||||
text-align: justify;
|
text-align: justify;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.git_desc, pre {
|
div.note {
|
||||||
border-style: solid;
|
font-size: 12px;
|
||||||
border-color: #FF5D00;
|
line-height: 12px;
|
||||||
border-width: 1px;
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.git_desc {
|
|
||||||
text-align: justify;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.error {
|
div.error {
|
||||||
@ -206,13 +199,17 @@ div.result_container {
|
|||||||
border-right-style: solid;
|
border-right-style: solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.block {
|
div.block, div.noborder {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-top-style: solid;
|
border-top-style: solid;
|
||||||
border-top-width: 1px;
|
border-top-width: 1px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.noborder {
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
div.inner{
|
div.inner{
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
float: center;
|
float: center;
|
||||||
@ -260,10 +257,19 @@ div.block text.refresh {
|
|||||||
|
|
||||||
div.block text.search {
|
div.block text.search {
|
||||||
background: url(../images/search.png);
|
background: url(../images/search.png);
|
||||||
margin-left: 275px;
|
margin-left: 255px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.inner text.edit:hover, div.inner text.trash:hover, div.block text.refresh:hover, div.block text.search:hover{
|
div.block text.save {
|
||||||
|
background: url(../images/save.png);
|
||||||
|
margin-left: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.inner text.edit:hover,
|
||||||
|
div.inner text.trash:hover,
|
||||||
|
div.block text.refresh:hover,
|
||||||
|
div.block text.search:hover,
|
||||||
|
div.block text.save:hover{
|
||||||
background-color: #FFB387;
|
background-color: #FFB387;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@ -277,7 +283,11 @@ div.inner text.edit {
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.inner text.trash, div.inner text.edit, div.block text.refresh, div.block text.search {
|
div.inner text.trash,
|
||||||
|
div.inner text.edit,
|
||||||
|
div.block text.refresh,
|
||||||
|
div.block text.search,
|
||||||
|
div.block text.save {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
float:left;
|
float:left;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
@ -286,11 +296,11 @@ div.inner text.trash, div.inner text.edit, div.block text.refresh, div.block tex
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.even {
|
div.even {
|
||||||
background-color: #FFFFFF;
|
background-color: #E5E5E5;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.odd {
|
div.odd {
|
||||||
background-color: #E5E5E5;
|
background-color: #FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.block label {
|
div.block label {
|
||||||
|
67
stock.sql
67
stock.sql
@ -1,3 +1,5 @@
|
|||||||
|
\c postgres;
|
||||||
|
|
||||||
drop database tetalab_stock;
|
drop database tetalab_stock;
|
||||||
create database tetalab_stock;
|
create database tetalab_stock;
|
||||||
|
|
||||||
@ -29,10 +31,10 @@ CREATE TABLE stock_componants (
|
|||||||
id serial primary key,
|
id serial primary key,
|
||||||
reference varchar(20) unique not NULL,
|
reference varchar(20) unique not NULL,
|
||||||
designation varchar(50) not NULL,
|
designation varchar(50) not NULL,
|
||||||
last_price NUMERIC not NULL,
|
last_price NUMERIC not NULL default 0,
|
||||||
mean_price NUMERIC not NULL,
|
mean_price NUMERIC not NULL default 0,
|
||||||
quantity NUMERIC not NULL,
|
quantity NUMERIC not NULL default 0,
|
||||||
min_quantity NUMERIC not NULL,
|
min_quantity NUMERIC not NULL default 0,
|
||||||
place varchar(15) not NULL,
|
place varchar(15) not NULL,
|
||||||
provider_id integer REFERENCES stock_providers(id)
|
provider_id integer REFERENCES stock_providers(id)
|
||||||
);
|
);
|
||||||
@ -51,59 +53,60 @@ alter table stock_componants owner to tetalab_user;
|
|||||||
alter table stock_kit_compositions owner to tetalab_user;
|
alter table stock_kit_compositions owner to tetalab_user;
|
||||||
alter database tetalab_stock owner to tetalab_user;
|
alter database tetalab_stock owner to tetalab_user;
|
||||||
|
|
||||||
|
insert into stock_providers (name, address, mail, url, comment)
|
||||||
|
values ('Tous', 'N/A', 'N/A', 'N/A', 'N/A');
|
||||||
|
insert into stock_providers (name, address, mail, url, comment)
|
||||||
|
values ('Aucun', 'N/A', 'N/A', 'N/A', 'N/A');
|
||||||
insert into stock_providers (name, address, mail, url, comment)
|
insert into stock_providers (name, address, mail, url, comment)
|
||||||
values ('China Elec Co', 'Beijing', 'sales@chinaelecco.cc', 'https://chinaelecco', 'Pas cher, mais...');
|
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)
|
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);
|
values ('Res-01', 'Resistance 10KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Lor-01', '1 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-02', 'Resistance 11KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-03', 'Resistance 12KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-04', 'Resistance 13KΩ', 13.34, 12.42, 73, 0, 'B 43', 2);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-05', 'Resistance 14KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Lor-02', '2 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-06', 'Resistance 15KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-07', 'Resistance 16KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-08', 'Resistance 17KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-09', 'Resistance 18KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Lor-03', '3 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-10', 'Resistance 19KΩ', 13.34, 12.42, 73, 0, 'B 43', 2);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-11', 'Resistance 20KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-12', 'Resistance 21KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-13', 'Resistance 22KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Lor-04', '4 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-14', 'Resistance 23KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-15', 'Resistance 24KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-16', 'Resistance 25KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-17', 'Resistance 26KΩ', 13.34, 12.42, 73, 0, 'B 43', 2);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Lor-05', '5 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-18', 'Resistance 27KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-19', 'Resistance 28KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
|
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);
|
values ('Res-20', 'Resistance 29KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
|
||||||
|
|
||||||
\c postgres;
|
|
||||||
|
@ -25,12 +25,14 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>Note:</h3>
|
<h3>Note:</h3>
|
||||||
<p>Cette page vous permet de modifier directement un composant.</p>
|
<div class='note'>
|
||||||
<p>À moins de vouloir corriger une erreur de saisie, ou de saisir un inventaire vous ne devez
|
<p>Cette page vous permet de modifier directement un composant.</p>
|
||||||
<strong>PAS</strong> modifier directement
|
<p>À moins de vouloir corriger une erreur de saisie, ou de saisir un inventaire vous ne devez
|
||||||
les quantités d'un composant.</p>
|
<strong>PAS</strong> modifier directement
|
||||||
<p>Cliquez sur les liens suivants pour saisir des <a href='/componant/in/{{ componant.id }}'>entrées</a>
|
les quantités d'un composant.</p>
|
||||||
ou <a href='/componant/out/{{ componant.id }}'>sorties</a> de stock.</p>
|
<p>Cliquez sur les liens suivants pour saisir des <a href='/componant/in/{{ componant.id }}'>entrées</a>
|
||||||
|
ou <a href='/componant/out/{{ componant.id }}'>sorties</a> de stock.</p>
|
||||||
|
</div>
|
||||||
<h3>Composant:</h3>
|
<h3>Composant:</h3>
|
||||||
<div class='block margin_bottom no_border'>
|
<div class='block margin_bottom no_border'>
|
||||||
<label class='editable'>Référence (unique)</label>
|
<label class='editable'>Référence (unique)</label>
|
||||||
@ -125,7 +127,7 @@
|
|||||||
{% if prov.id == provider.id %}
|
{% if prov.id == provider.id %}
|
||||||
{% set option_selected = 'selected="selected"' %}
|
{% set option_selected = 'selected="selected"' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<option {{ option_selected }} value='prov.id'>{{ prov.name }}</option>
|
<option {{ option_selected }} value='{{ prov.id }}'>{{ prov.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
{% extends "index.html" %}
|
{% extends "index.html" %}
|
||||||
|
{% block bodyheader %}
|
||||||
|
<body onload="javascript:update_componants();">
|
||||||
|
{% endblock %}
|
||||||
{% block title %}Liste des composants{% endblock %}
|
{% block title %}Liste des composants{% endblock %}
|
||||||
{% block top_menu %}
|
{% block top_menu %}
|
||||||
<span class='top_menu_item_selected' onclick='javascript:document.location="/componants/search";'>Rechercher un composant</span>
|
<span class='top_menu_item_selected' onclick='javascript:document.location="/componants/search";'>Rechercher un composant</span>
|
||||||
@ -69,7 +72,6 @@
|
|||||||
id='provider_id'
|
id='provider_id'
|
||||||
onchange='javascript:search_componants_by_provider(this, "numeric");'
|
onchange='javascript:search_componants_by_provider(this, "numeric");'
|
||||||
title='Fournisseur'>
|
title='Fournisseur'>
|
||||||
<option value='0' selected>Tous</option>
|
|
||||||
{% for prov in providers %}
|
{% for prov in providers %}
|
||||||
{% set selected = '' %}
|
{% set selected = '' %}
|
||||||
{% if prov.id == provider_id %}
|
{% if prov.id == provider_id %}
|
||||||
@ -81,6 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class='block margin_bottom no_border center'>
|
<div class='block margin_bottom no_border center'>
|
||||||
<text title='Rechercher' class='search' onclick='javascript:update_componants("reference");'></text>
|
<text title='Rechercher' class='search' onclick='javascript:update_componants("reference");'></text>
|
||||||
|
<text title='Enregistrer' class='save' onclick='javascript:new_componant();'></text>
|
||||||
</div>
|
</div>
|
||||||
<!-- ----------------------------------------------------
|
<!-- ----------------------------------------------------
|
||||||
Resultat
|
Resultat
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="/static/style/style.css" />
|
<link rel="stylesheet" type="text/css" href="/static/style/style.css" />
|
||||||
<script type="text/javascript" src="/static/scripts/tetalab.js"></script>
|
<script type="text/javascript" src="/static/scripts/tetalab.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
{% block bodyheader %}
|
||||||
<body>
|
<body>
|
||||||
|
{% endblock %}
|
||||||
<div class='main_wrapper'>
|
<div class='main_wrapper'>
|
||||||
<div class='center'>
|
<div class='center'>
|
||||||
<div class='banner' title='Stock Tetalab'>
|
<div class='banner' title='Stock Tetalab'>
|
||||||
@ -34,15 +36,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Gestion du stock</h1>
|
<h1>Tetastock</h1>
|
||||||
<p>Ceci est l'outil de gestion de stock du <a href='https://www.tetalab.org'>Tetalab</a>.</p>
|
<div class='note'>
|
||||||
<p>Cet outil vous permet:
|
<p>Ceci est l'outil de gestion de stock du <a href='https://www.tetalab.org'>Tetalab</a>.</p>
|
||||||
<ul>
|
<p>Cet outil vous permet:
|
||||||
<li>De gérer la liste des composants électroniques en possession du Tetalab</li>
|
<ul>
|
||||||
<li>De gérer la liste des fournisseurs de composants</li>
|
<li>De gérer la liste des composants électroniques en possession du Tetalab</li>
|
||||||
<li>De gérer la liste des kits de montage</li>
|
<li>De gérer la liste des fournisseurs de composants</li>
|
||||||
</ul>
|
<li>De gérer la liste des kits de montage</li>
|
||||||
</p>
|
</ul>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
87
templates/new_componant.html
Normal file
87
templates/new_componant.html
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
{% extends "index.html" %}
|
||||||
|
{% block bodyheader %}
|
||||||
|
<body onload="javascript:update_componants();">
|
||||||
|
{% endblock %}
|
||||||
|
{% block title %}Nouveau composant{% endblock %}
|
||||||
|
{% block top_menu %}
|
||||||
|
<span class='top_menu_item' onclick='javascript:document.location="/componants";'>Rechercher un composant</span>
|
||||||
|
<span class='top_menu_item_selected' onclick='javascript:document.location="/componants/new";'>Nouveau composant</span>
|
||||||
|
<span class='top_menu_item' onclick='javascript:document.location="/componants/in";'>Entrée de stock</span>
|
||||||
|
<span class='top_menu_item' onclick='javascript:document.location="/componants/out";'>Sortie de stock</span>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block left_menu %}
|
||||||
|
<div class='left_menu_item' onclick='javascript:document.location="/";'>
|
||||||
|
Accueil
|
||||||
|
</div>
|
||||||
|
<div class='left_menu_item_selected' onclick='javascript:document.location="/componants";'>
|
||||||
|
Composants
|
||||||
|
</div>
|
||||||
|
<div class='left_menu_item' onclick='javascript:document.location="/kits";'>
|
||||||
|
Kits
|
||||||
|
</div>
|
||||||
|
<div class='left_menu_item' onclick='javascript:document.location="/providers";'>
|
||||||
|
Fournisseurs
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<!-- ----------------------------------------------------
|
||||||
|
Recherche
|
||||||
|
----------------------------------------------------- -->
|
||||||
|
<h3>Recherche:</h3>
|
||||||
|
<div class='block margin_bottom no_border'>
|
||||||
|
<label class='editable'>Référence (unique)</label>
|
||||||
|
<input
|
||||||
|
id='reference'
|
||||||
|
type='text'
|
||||||
|
class='editable'
|
||||||
|
onkeyup='javascript:search_reference(this);'
|
||||||
|
maxlength='20'
|
||||||
|
title='Référence interne unique (max. 20)'
|
||||||
|
placeholder='Référence interne unique (max. 20)'
|
||||||
|
value='' />
|
||||||
|
</div>
|
||||||
|
<div class='block margin_bottom no_border'>
|
||||||
|
<label class='editable'>Désignation</label>
|
||||||
|
<input
|
||||||
|
id='designation'
|
||||||
|
type='text'
|
||||||
|
class='editable'
|
||||||
|
maxlength='50'
|
||||||
|
title='Désignation (max. 50)'
|
||||||
|
placeholder='Désignation (max. 50)'
|
||||||
|
value='' />
|
||||||
|
</div>
|
||||||
|
<div class='block margin_bottom no_border'>
|
||||||
|
<label class='editable'>Emplacement</label>
|
||||||
|
<input
|
||||||
|
id='place'
|
||||||
|
type='text'
|
||||||
|
class='editable'
|
||||||
|
maxlength='15'
|
||||||
|
title='Emplacement (max. 15)'
|
||||||
|
placeholder='Emplacement (max. 15)'
|
||||||
|
value='' />
|
||||||
|
</div>
|
||||||
|
<div class='block margin_bottom no_border'>
|
||||||
|
<label class='editable'>Fournisseur</label>
|
||||||
|
<select
|
||||||
|
id='provider_id'
|
||||||
|
title='Fournisseur'>
|
||||||
|
<option value='0' selected>Tous</option>
|
||||||
|
{% for prov in providers %}
|
||||||
|
<option value='{{ prov.id }}'>{{ prov.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class='block margin_bottom no_border center'>
|
||||||
|
<text title='Enregistrer' class='save' onclick='javascript:new_componant();'></text>
|
||||||
|
</div>
|
||||||
|
<!-- ----------------------------------------------------
|
||||||
|
Resultat
|
||||||
|
----------------------------------------------------- -->
|
||||||
|
<div id='result_container' class='result_container'>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
71
tetastock.py
71
tetastock.py
@ -2,10 +2,12 @@
|
|||||||
# -*- coding: utf-8
|
# -*- coding: utf-8
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import psycopg2
|
||||||
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
|
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# App settings
|
# App settings
|
||||||
########################################################################
|
########################################################################
|
||||||
@ -66,8 +68,11 @@ def resume_session(func):
|
|||||||
order = 'asc'
|
order = 'asc'
|
||||||
order_refresh = 0
|
order_refresh = 0
|
||||||
c_empty = ''
|
c_empty = ''
|
||||||
c_provider = 1
|
c_provider = 0
|
||||||
|
c_count = 0
|
||||||
offset_reset = ['c_reference', 'c_designation', 'c_place', 'c_provider']
|
offset_reset = ['c_reference', 'c_designation', 'c_place', 'c_provider']
|
||||||
|
if not 'session' in session:
|
||||||
|
session['session'] = ''
|
||||||
if not 'c_limit' in session:
|
if not 'c_limit' in session:
|
||||||
session['c_limit'] = limit
|
session['c_limit'] = limit
|
||||||
if not 'c_offest' in session:
|
if not 'c_offest' in session:
|
||||||
@ -90,6 +95,8 @@ def resume_session(func):
|
|||||||
session['c_place'] = c_empty
|
session['c_place'] = c_empty
|
||||||
if not 'c_provider' in session:
|
if not 'c_provider' in session:
|
||||||
session['c_provider'] = c_provider
|
session['c_provider'] = c_provider
|
||||||
|
if not 'c_count' in session:
|
||||||
|
session['c_count'] = c_count
|
||||||
# Cookies/session sync
|
# Cookies/session sync
|
||||||
for key in request.cookies:
|
for key in request.cookies:
|
||||||
old = str(session[key])
|
old = str(session[key])
|
||||||
@ -129,11 +136,11 @@ def authenticate():
|
|||||||
# Componants
|
# Componants
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
## Main ##
|
|
||||||
@app.route('/componants', methods=['GET', 'POST'])
|
@app.route('/componants', methods=['GET', 'POST'])
|
||||||
@resume_session
|
@resume_session
|
||||||
def get_componants():
|
def componants():
|
||||||
providers = Stock_providers.query.order_by(Stock_providers.name).all()
|
""" Main page """
|
||||||
|
providers = Stock_providers.query.order_by(Stock_providers.id).all()
|
||||||
return render_template('componants.html',
|
return render_template('componants.html',
|
||||||
providers=providers,
|
providers=providers,
|
||||||
reference=session['c_reference'],
|
reference=session['c_reference'],
|
||||||
@ -141,9 +148,9 @@ def get_componants():
|
|||||||
place=session['c_place'],
|
place=session['c_place'],
|
||||||
provider_id=session['c_provider'])
|
provider_id=session['c_provider'])
|
||||||
|
|
||||||
## Componant edition ##
|
|
||||||
@app.route('/componants/<componant_id>')
|
@app.route('/componants/<componant_id>')
|
||||||
def get_componant(componant_id):
|
def get_componant(componant_id):
|
||||||
|
""" Edit componant """
|
||||||
try:
|
try:
|
||||||
componant_id = int(componant_id)
|
componant_id = int(componant_id)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -156,50 +163,70 @@ def get_componant(componant_id):
|
|||||||
return render_template('componant.html', componant=componant, providers=providers, provider=provider)
|
return render_template('componant.html', componant=componant, providers=providers, provider=provider)
|
||||||
return render_template('error.html'), 404
|
return render_template('error.html'), 404
|
||||||
|
|
||||||
## Componant update ##
|
|
||||||
@app.route('/componants/update/<componant_id>', methods=['POST'])
|
@app.route('/componants/update/<componant_id>', methods=['POST'])
|
||||||
def update_componant(componant_id):
|
def update_componant(componant_id):
|
||||||
|
""" Update componant field"""
|
||||||
field = request.form['field']
|
field = request.form['field']
|
||||||
value = request.form['value']
|
value = request.form['value']
|
||||||
if field and value:
|
if field and value:
|
||||||
try:
|
try:
|
||||||
componant = Stock_componants.query.filter_by(id=componant_id).first()
|
componant = Stock_componants.query.filter_by(id=componant_id).first()
|
||||||
setattr(componant, field, value)
|
setattr(componant, field, value)
|
||||||
db.session.commit()
|
commit = db.session.commit()
|
||||||
|
if commit == None:
|
||||||
|
return 'OK'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return 'KO'
|
pass
|
||||||
return 'OK'
|
return 'KO'
|
||||||
|
|
||||||
## Componant deletion ##
|
|
||||||
@app.route('/componants/delete/<componant_id>')
|
@app.route('/componants/delete/<componant_id>')
|
||||||
def delete_componant(componant_id):
|
def delete_componant(componant_id):
|
||||||
|
""" Delete componant """
|
||||||
try:
|
try:
|
||||||
componant_id = int(componant_id)
|
componant_id = int(componant_id)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return render_template('error.html'), 404
|
return render_template('error.html'), 404
|
||||||
Stock_componants.query.filter_by(id=componant_id).delete()
|
Stock_componants.query.filter_by(id=componant_id).delete()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return get_componants()
|
return componants()
|
||||||
|
|
||||||
## Componant creation ##
|
@app.route('/componants/new', methods=['POST'])
|
||||||
@app.route('/componants/new/<componant_id>')
|
@resume_session
|
||||||
def add_componant(componant_id):
|
def new_componant():
|
||||||
return render_template('wip.html')
|
""" Add componant """
|
||||||
|
componant = Stock_componants(reference=session['c_reference'],
|
||||||
|
designation=session['c_designation'],
|
||||||
|
last_price=0,
|
||||||
|
mean_price=0,
|
||||||
|
quantity=0,
|
||||||
|
min_quantity=0,
|
||||||
|
place=session['c_place'],
|
||||||
|
provider_id=session['c_provider'])
|
||||||
|
try:
|
||||||
|
db.session.add(componant)
|
||||||
|
commit = db.session.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print e
|
||||||
|
return 'KO'
|
||||||
|
if commit != None:
|
||||||
|
return 'KO'
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
## Componants stock in ##
|
|
||||||
@app.route('/componants/in/<componant_id>')
|
@app.route('/componants/in/<componant_id>')
|
||||||
def in_componants():
|
def in_componants():
|
||||||
|
""" Incoming order """
|
||||||
return render_template('wip.html')
|
return render_template('wip.html')
|
||||||
|
|
||||||
## Componants stock out ##
|
|
||||||
@app.route('/componants/out/<componant_id>')
|
@app.route('/componants/out/<componant_id>')
|
||||||
def out_componants():
|
def out_componants():
|
||||||
|
""" Outgoing order """
|
||||||
return render_template('wip.html')
|
return render_template('wip.html')
|
||||||
|
|
||||||
## Componants update result set
|
## Componants update result set
|
||||||
@app.route('/componants/update', methods=['POST'])
|
@app.route('/componants/update', methods=['POST'])
|
||||||
@resume_session
|
@resume_session
|
||||||
def update_componants():
|
def update_componants():
|
||||||
|
""" Display componants list """
|
||||||
# search by reference
|
# search by reference
|
||||||
like = '%s%s%s' % ('%', str(session['c_reference']), '%')
|
like = '%s%s%s' % ('%', str(session['c_reference']), '%')
|
||||||
componants = Stock_componants.query.filter(Stock_componants.reference.like(like))
|
componants = Stock_componants.query.filter(Stock_componants.reference.like(like))
|
||||||
@ -210,18 +237,18 @@ def update_componants():
|
|||||||
like = '%s%s%s' % ('%', str(session['c_place']),'%')
|
like = '%s%s%s' % ('%', str(session['c_place']),'%')
|
||||||
componants = componants.filter(Stock_componants.place.like(like))
|
componants = componants.filter(Stock_componants.place.like(like))
|
||||||
# search by provider
|
# search by provider
|
||||||
if session['c_provider'] > 0:
|
if session['c_provider'] > 1:
|
||||||
componants = componants.filter_by(provider_id=session['c_provider'])
|
componants = componants.filter_by(provider_id=session['c_provider'])
|
||||||
# Pages calculation
|
# Pages calculation
|
||||||
row_count = componants.count()
|
session['c_count'] = componants.count()
|
||||||
session['c_pagecount'] = int(math.ceil(row_count / float(session['c_limit'])))
|
session['c_pagecount'] = int(math.ceil(session['c_count'] / float(session['c_limit'])))
|
||||||
session['c_page'] = int(math.ceil(float(float(session['c_offset']) + 1) / float(session['c_limit'])))
|
session['c_page'] = int(math.ceil(float(float(session['c_offset']) + 1) / float(session['c_limit'])))
|
||||||
if session['c_page'] > session['c_pagecount']:
|
if session['c_page'] > session['c_pagecount']:
|
||||||
session['c_page'] = session['c_pagecount']
|
session['c_page'] = session['c_pagecount']
|
||||||
session['c_offset'] = 0
|
session['c_offset'] = 0
|
||||||
print "*****", componants.count(), session['c_pagecount'], session['c_page']
|
print "*****", componants.count(), session['c_pagecount'], session['c_page']
|
||||||
session['c_nexthop'] = session['c_offset'] + session['c_limit']
|
session['c_nexthop'] = session['c_offset'] + session['c_limit']
|
||||||
if session['c_nexthop'] > row_count - 1:
|
if session['c_nexthop'] > session['c_count'] - 1:
|
||||||
session['c_nexthop'] = int(session['c_offset'])
|
session['c_nexthop'] = int(session['c_offset'])
|
||||||
session['c_prevhop'] = int(session['c_offset']) - session['c_limit']
|
session['c_prevhop'] = int(session['c_offset']) - session['c_limit']
|
||||||
if session['c_prevhop'] < 0:
|
if session['c_prevhop'] < 0:
|
||||||
@ -247,7 +274,7 @@ def update_componants():
|
|||||||
page=session['c_page'],
|
page=session['c_page'],
|
||||||
sort=session['c_sort'],
|
sort=session['c_sort'],
|
||||||
order=session['c_order'],
|
order=session['c_order'],
|
||||||
row_count=row_count))
|
row_count=session['c_count']))
|
||||||
for key in session:
|
for key in session:
|
||||||
response.set_cookie(key, value=str(session[key]))
|
response.set_cookie(key, value=str(session[key]))
|
||||||
if key != 'session':
|
if key != 'session':
|
||||||
|
Loading…
Reference in New Issue
Block a user