"Gestion complète des compositions de kits"

This commit is contained in:
2017-10-28 11:22:59 +02:00
parent 45e7968544
commit 76cf51831b
14 changed files with 448 additions and 40 deletions

BIN
static/images/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 878 B

View File

@@ -9,9 +9,7 @@ var base_border = "#555555";
* GLOBAL
* **************************************************************************************/
///////////////////////////////////////////
// Cookies
///////////////////////////////////////////
function setcookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
@@ -25,10 +23,7 @@ function getcookie(cname) {
if (parts.length == 2) return parts.pop().split(";").shift();
}
///////////////////////////////////////////
// Eye candies
///////////////////////////////////////////
function invalid_input(obj) {
obj.style.backgroundColor = light_red;
setTimeout( function() {
@@ -106,8 +101,7 @@ function update_componants() {
xhttp.send();
}
// Result ordering
// Result ordering and navigation
function update_componants_by_reference(order) {
setcookie('c_order', order, 30);
setcookie('c_sort', 'reference', 30);
@@ -148,7 +142,6 @@ function c_next_page(nexthop) {
// Search componants
function search_componants_by_reference(obj) {
setcookie('c_reference', obj.value, 30);
update_componants();
@@ -170,14 +163,12 @@ function search_componants_by_provider(obj) {
}
// Delete componant
function confirm_componant_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);
}
// New componant
function new_componant() {
var err = false;
var obj = {};
@@ -231,7 +222,6 @@ function create_componant() {
}
// Update componant
function update_componant(obj, componant_id, type) {
if (type == 'numeric') {
if (isNaN(obj.value)) {
@@ -292,8 +282,7 @@ function update_providers() {
xhttp.send();
}
// Result ordering
// Result ordering and navigation
function update_providers_by_name(order) {
setcookie('p_order', order, 30);
setcookie('p_sort', 'name', 30);
@@ -340,7 +329,6 @@ function p_next_page(nexthop) {
}
// Search providers
function search_providers_by_name(obj) {
setcookie('p_name', obj.value, 30);
update_providers();
@@ -367,7 +355,6 @@ function search_providers_by_comment(obj) {
}
// New provider
function new_provider() {
var err = false;
var obj = {};
@@ -410,14 +397,12 @@ function create_provider() {
}
// Delete provider
function confirm_provider_delete() {
var msg="La suppression est définitive \net n'est pas autorisée si le \nfournisseur est référencé \npar un composant.\n\nConfirmer ?";
return confirm(msg);
}
// Update provider
function update_provider(obj, provider_id, type) {
var xhttp = new XMLHttpRequest();
xhttp.onerror = function(){
@@ -472,8 +457,7 @@ function update_kits() {
xhttp.send();
}
// Result ordering
// Result ordering and navigation
function update_kits_by_name(order) {
setcookie('k_order', order, 30);
setcookie('k_sort', 'name', 30);
@@ -506,7 +490,6 @@ function k_next_kage(nexthop) {
}
// Search kits
function search_kits_by_name(obj) {
setcookie('k_name', obj.value, 30);
update_kits();
@@ -518,7 +501,6 @@ function search_kits_by_designation(obj) {
}
// New kit
function new_kit() {
var err = false;
var obj = {};
@@ -569,14 +551,12 @@ function create_kit() {
}
// Delete kit
function confirm_kit_delete() {
var msg="La suppression d'un kit est définitive.\n\nConfirmer ?";
return confirm(msg);
}
// Update kit
function update_kit(obj, kit_id, type) {
var xhttp = new XMLHttpRequest();
xhttp.onerror = function(){
@@ -599,3 +579,146 @@ function update_kit(obj, kit_id, type) {
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send('field='+obj.id+'&value='+obj.value);
}
/* **************************************************************************************
* KIT COMPOSITIONS
* **************************************************************************************/
// Update kit composition
function update_kit_composition(kit_id) {
obj = document.getElementById('kit_composition');
var xhttp = new XMLHttpRequest();
xhttp.onerror = function(){
obj.innerHTML = "Erreur lors de la mise à jour de la liste (1)"
};
xhttp.onload = function(){
if (xhttp.status != 200) {
obj.innerHTML = "Erreur lors de la mise à jour de la liste (2)"
}
};
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var response = xhttp.responseText;
obj.innerHTML = response;
return true;
}
};
xhttp.open('POST', '/kits/composition/'+kit_id, true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send();
}
// Remove componant from kit
function confirm_componant_remove(designation) {
var msg="Supprimer le composant \n'"+designation+"'\ndu kit ?";
return confirm(msg);
}
// Add componant to kit
function add_kit_componant(kit_id, componant_id) {
var quantity = prompt("Quantité");
if (quantity < 1){
alert('La quantité doit être au moins égale à 1');
return;
}
setcookie('kc_quantity', quantity, 30);
setcookie('kc_componant_id', componant_id, 30);
var xhttp = new XMLHttpRequest();
xhttp.onerror = function(){
alert("Erreur lors de l'ajout du composant (1).");
};
xhttp.onload = function(){
if (xhttp.status != 200) {
alert("Erreur lors de l'ajout du composant (2).");
}
};
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var response = xhttp.responseText;
update_kit_composition(kit_id);
return true;
}
};
xhttp.open('POST', '/kits/add/'+kit_id+'/'+componant_id, true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send();
}
// Edit componant_composition quantity
function edit_kit_composition(kit_id, componant_id){
var quantity = prompt('Nouvelle quantité');
if (quantity < 1){
alert('La quantité doit être au moins égale à 1.');
return;
}
setcookie('kc_quantity', quantity, 30);
setcookie('kc_componant_id', componant_id, 30);
var xhttp = new XMLHttpRequest();
xhttp.onerror = function(){
alert("Erreur lors de la mise à jour de la liste (1)");
};
xhttp.onload = function(){
if (xhttp.status != 200) {
alert("Erreur lors de la mise à jour de la liste (2)");
}
};
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var response = xhttp.responseText;
update_kit_composition(kit_id);
return true;
}
};
xhttp.open('POST', '/kits/composition/update/'+kit_id, true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send();
}
// Update search result
function update_kit_componants(kit_id) {
obj = document.getElementById('result_container');
var xhttp = new XMLHttpRequest();
xhttp.onerror = function(){
obj.innerHTML = "Erreur lors de la mise à jour de la liste (1)"
};
xhttp.onload = function(){
if (xhttp.status != 200) {
obj.innerHTML = "Erreur lors de la mise à jour de la liste (2)"
}
};
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var response = xhttp.responseText;
obj.innerHTML = response;
return true;
}
};
xhttp.open('POST', '/kits/componants/update/'+kit_id, true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send();
}
// Search componants
function search_kit_componants_by_reference(obj, kit_id) {
setcookie('kc_reference', obj.value, 30);
update_kit_componants(kit_id);
}
function search_kit_componants_by_designation(obj, kit_id) {
setcookie('kc_designation', obj.value, 30);
update_kit_componants(kit_id);
}

View File

@@ -332,6 +332,7 @@ span.page_num {
}
div.row_block {
display: inline-block;
margin: 0 0 4px 0;
height: 20px;
width: 1000px;
@@ -344,13 +345,14 @@ div.nav_page_block {
}
div.action_bar_block {
display: inline;
overflow: hidden;
float: center;
height: 20px;
}
div.row_block label {
display: block;
display: inline;
float: left;
text-align: center;
font-weight: bold;
@@ -369,7 +371,7 @@ div.row_block text.border_left {
}
div.row_block text {
display: block;
display: inline;
float: left;
font-weight: normal;
text-align: left;
@@ -383,13 +385,27 @@ div.row_block text.num {
text-align: right;
}
div.row_block text.red {
color: #FF0000;
font-weight: bold;
border-color: #555555;
}
div.nav_page_block text {
display: block;
white-space: nowrap;
}
div.action_bar_block input {
display: inline;
height: 17px;
width: 16px;
margin-left: 20px;
margin-top: 1px;
background-color: #F5D00;
}
div.action_bar_block input:hover {
cursor: pointer;
background-color: #FF5D00;
}