diff --git a/result.log b/result.log new file mode 100644 index 0000000..71451fd --- /dev/null +++ b/result.log @@ -0,0 +1,1121 @@ +This is METAFONT, Version 2.71828 (Web2C 7.5.4) (base=mf 2015.3.24) 25 OCT 2017 09:34 +**templates/result.html templates/result_componants.html +(templates/result.html +! A statement can't begin with `<'. + + < +l.1 < + h3>Résultat: +? +! Extra tokens will be flushed. + + < +l.1 < + h3>Résultat: +? +! Interruption. +l.1 < + h3>Résultat: +? +! Text line contains an invalid character. +l.1

RÃ + ©sultat:

+? +! Text line contains an invalid character. +l.1

Ré + sultat:

+? q +OK, entering batchmode... +! Text line contains an invalid character. +l.6 ...'>{{ row_count }} objet{{ ss }} selectionnà + ©{{ ss }} +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +! Text line contains an invalid character. +l.6 ...>{{ row_count }} objet{{ ss }} selectionné + {{ ss }} +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +! A tertiary expression can't begin with `<'. + + 0 + + < +l.8 < + label onclick='javascript:update_componants_by_reference(... +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> ' +! Unknown relation will be considered false. + + < +l.8 < + label onclick='javascript:update_componants_by_reference(... +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +>> false +>> label.onclick +! Not implemented: (boolean)<(unknown numeric). + + = +l.8 +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +! Text line contains an invalid character. +l.8 ...ponants_by_reference("{{ order }}");'>Réfà + ©rence +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +! Text line contains an invalid character. +l.8 ...onants_by_reference("{{ order }}");'>Réfé + rence +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +>> -R.f.rence+' +! Unknown relation will be considered false. + + < +l.8 ..._by_reference("{{ order }}");'>Référence< + /label> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.8 ...by_reference("{{ order }}");'>Référence +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +>> label +! Not implemented: (known numeric)/(unknown numeric). + + > +l.8 ...erence("{{ order }}");'>Référence + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> false +>> label +! Not implemented: (boolean)<(unknown numeric). + + > +l.8 ...erence("{{ order }}");'>Référence + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +! A tertiary expression can't begin with `<'. + + 0 + + < +l.9 < + label onclick='javascript:update_componants_by_designatio... +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> label +! Unknown relation will be considered false. + + < +l.9 < + label onclick='javascript:update_componants_by_designatio... +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +>> false +>> label.onclick +! Not implemented: (boolean)<(unknown numeric). + + = +l.9 +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +>> -D.signation+' +! Unknown relation will be considered false. + + < +l.9 ...r_left' style='width: 440px;'>Désignation< + /label> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.9 ..._left' style='width: 440px;'>Désignation +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +>> label +! Not implemented: (known numeric)/(unknown numeric). + + > +l.9 ... style='width: 440px;'>Désignation + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> false +>> label +! Not implemented: (boolean)<(unknown numeric). + + > +l.9 ... style='width: 440px;'>Désignation + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +! A tertiary expression can't begin with `<'. + + 0 + + < +l.10 < + label onclick='javascript:update_componants_by_quantity(... +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> label +! Unknown relation will be considered false. + + < +l.10 < + label onclick='javascript:update_componants_by_quantity(... +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +>> false +>> label.onclick +! Not implemented: (boolean)<(unknown numeric). + + = +l.10 +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +! Text line contains an invalid character. +l.10 ...order_left' style='width: 100px;'>Quantità + © +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +! Text line contains an invalid character. +l.10 ...rder_left' style='width: 100px;'>Quantité + +A funny symbol that I can't read has just been input. +Continue, and I'll forget that it ever happened. + +>> -Quantit+' +! Unknown relation will be considered false. + + < +l.10 ...der_left' style='width: 100px;'>Quantité< + /label> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.10 ...er_left' style='width: 100px;'>Quantité +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +>> label +! Not implemented: (known numeric)/(unknown numeric). + + > +l.10 ...t' style='width: 100px;'>Quantité + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> false +>> label +! Not implemented: (boolean)<(unknown numeric). + + > +l.10 ...t' style='width: 100px;'>Quantité + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +! A tertiary expression can't begin with `<'. + + 0 + + < +l.11 < + label onclick='javascript:update_componants_by_place("{{... +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> label +! Unknown relation will be considered false. + + < +l.11 < + label onclick='javascript:update_componants_by_place("{{... +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +>> false +>> label.onclick +! Not implemented: (boolean)<(unknown numeric). + + = +l.11 + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> false +>> label +! Not implemented: (boolean)<(unknown numeric). + + > +l.11 ... style='width: 160px;'>Emplacement + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +! A tertiary expression can't begin with `<'. + + 0 + + < +l.12 < + label style='width: 106px; cursor: default;'>Action +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> label +! Unknown relation will be considered false. + + < +l.12 < + label style='width: 106px; cursor: default;'>Action +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +>> false +>> label.style +! Not implemented: (boolean)<(unknown numeric). + + = +l.12 +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +! Extra tokens will be flushed. + + : +l.12 +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +>> cursor +! Isolated expression. + + : +l.12 ... +I couldn't find an `=' or `:=' after the +expression that is shown above this error message, +so I guess I'll just ignore it and carry on. + +! Extra tokens will be flushed. + + : +l.12 ... +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +>> -Action+' +! Unknown relation will be considered false. + + < +l.12 ...e='width: 106px; cursor: default;'>Action< + /label> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.12 ...='width: 106px; cursor: default;'>Action +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +>> label +! Not implemented: (known numeric)/(unknown numeric). + + > +l.12 ...h: 106px; cursor: default;'>Action + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> false +>> label +! Not implemented: (boolean)<(unknown numeric). + + > +l.12 ...h: 106px; cursor: default;'>Action + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +! A tertiary expression can't begin with `<'. + + 0 + + < +l.13 < + /div> +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> label +! Unknown relation will be considered false. + + < +l.13 < + /div> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.13 +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +! A primary expression can't begin with `primarydef'd macro: +floor((EXPR0)/(EXPR1))'. + + 0 + + div +l.13 +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +! Division by zero. + + div +l.13 +You're trying to divide the quantity shown above the error +message by zero. I'm going to divide it by one instead. + +! A primary expression can't begin with `>'. + + 0 + + > +l.13 + +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +! Division by zero. + + ) + + > +l.13 + +You're trying to divide the quantity shown above the error +message by zero. I'm going to divide it by one instead. + +>> false +>> 0 +! Not implemented: (boolean)<(known numeric). + + > +l.13 + +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +! A tertiary expression can't begin with `{'. + + 0 + + { +l.14 { + % set row_class = cycler('odd', 'even') %} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> false +! Isolated expression. + + { +l.14 { + % set row_class = cycler('odd', 'even') %} +I couldn't find an `=' or `:=' after the +expression that is shown above this error message, +so I guess I'll just ignore it and carry on. + +! Extra tokens will be flushed. + + { +l.14 { + % set row_class = cycler('odd', 'even') %} +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +>> -{{componant.reference}}+' +! Unknown relation will be considered false. + + < +l.17 ...'width: 192px;'>{{ componant.reference }}< + /text> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.17 ...width: 192px;'>{{ componant.reference }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +! A primary expression can't begin with `text'. + + 0 + + text +l.17 ...h: 192px;'>{{ componant.reference }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +! Division by zero. + + text +l.17 ...h: 192px;'>{{ componant.reference }} +You're trying to divide the quantity shown above the error +message by zero. I'm going to divide it by one instead. + +>> false +>> 0 +! Not implemented: (boolean)<(known numeric). + + text +l.17 ...h: 192px;'>{{ componant.reference }} +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> 0 +! Isolated expression. + + text +l.17 ...h: 192px;'>{{ componant.reference }} +I couldn't find an `=' or `:=' after the +expression that is shown above this error message, +so I guess I'll just ignore it and carry on. + +! Extra tokens will be flushed. + + text +l.17 ...h: 192px;'>{{ componant.reference }} +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +>> -{{componant.designation}}+' +! Unknown relation will be considered false. + + < +l.18 ...idth: 432px;'>{{ componant.designation }}< + /text> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.18 ...dth: 432px;'>{{ componant.designation }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +! A primary expression can't begin with `text'. + + 0 + + text +l.18 ... 432px;'>{{ componant.designation }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +! Division by zero. + + text +l.18 ... 432px;'>{{ componant.designation }} +You're trying to divide the quantity shown above the error +message by zero. I'm going to divide it by one instead. + +>> false +>> 0 +! Not implemented: (boolean)<(known numeric). + + text +l.18 ... 432px;'>{{ componant.designation }} +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> 0 +! Isolated expression. + + text +l.18 ... 432px;'>{{ componant.designation }} +I couldn't find an `=' or `:=' after the +expression that is shown above this error message, +so I guess I'll just ignore it and carry on. + +! Extra tokens will be flushed. + + text +l.18 ... 432px;'>{{ componant.designation }} +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +>> -{{componant.quantity}}+' +! Unknown relation will be considered false. + + < +l.19 ...e='width: 92px;'>{{ componant.quantity }}< + /text> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.19 ...='width: 92px;'>{{ componant.quantity }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +! A primary expression can't begin with `text'. + + 0 + + text +l.19 ...dth: 92px;'>{{ componant.quantity }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +! Division by zero. + + text +l.19 ...dth: 92px;'>{{ componant.quantity }} +You're trying to divide the quantity shown above the error +message by zero. I'm going to divide it by one instead. + +>> false +>> 0 +! Not implemented: (boolean)<(known numeric). + + text +l.19 ...dth: 92px;'>{{ componant.quantity }} +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> 0 +! Isolated expression. + + text +l.19 ...dth: 92px;'>{{ componant.quantity }} +I couldn't find an `=' or `:=' after the +expression that is shown above this error message, +so I guess I'll just ignore it and carry on. + +! Extra tokens will be flushed. + + text +l.19 ...dth: 92px;'>{{ componant.quantity }} +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +>> -{{componant.place}}+' +! Unknown relation will be considered false. + + < +l.20 ...yle='width: 152px;'>{{ componant.place }}< + /text> +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `/'. + + 0 + + / +l.20 ...le='width: 152px;'>{{ componant.place }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +! A primary expression can't begin with `text'. + + 0 + + text +l.20 ...width: 152px;'>{{ componant.place }} +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> 0 +! Division by zero. + + text +l.20 ...width: 152px;'>{{ componant.place }} +You're trying to divide the quantity shown above the error +message by zero. I'm going to divide it by one instead. + +>> false +>> 0 +! Not implemented: (boolean)<(known numeric). + + text +l.20 ...width: 152px;'>{{ componant.place }} +I'm afraid I don't know how to apply that operation to that +combination of types. Continue, and I'll return the second +argument (see above) as the result of the operation. + +>> 0 +! Isolated expression. + + text +l.20 ...width: 152px;'>{{ componant.place }} +I couldn't find an `=' or `:=' after the +expression that is shown above this error message, +so I guess I'll just ignore it and carry on. + +! Extra tokens will be flushed. + + text +l.20 ...width: 152px;'>{{ componant.place }} +I've just read as much of that statement as I could fathom, +so a semicolon should have been next. It's very puzzling... +but I'll try to get myself back together, by ignoring +everything up to the next `;'. Please insert a semicolon +now in front of anything that you don't want me to delete. +(See Chapter 27 of The METAFONTbook for an example.) + +! A tertiary expression can't begin with `<'. + + 0 + + < +l.22 < + text class='edit' title='Éditer' onclick='javascript:... +I'm afraid I need some sort of value in order to continue, +so I've tentatively inserted `0'. You may want to +delete this zero and insert something else; +see Chapter 27 of The METAFONTbook for an example. + +>> ' +! Unknown relation will be considered false. + + < +l.22 < + text class='edit' title='Éditer' onclick='javascript:... +Oh dear. I can't decide if the expression above is positive, +negative, or zero. So this comparison test won't be `true'. + +! A tertiary expression can't begin with `text'. + + 0 + + text +l.22 > false +>> 0 +! Not implemented: (boolean)<(known numeric). + + text +l.22 > 0 +! Isolated expression. + + text +l.22 + text +l.22 0){ - var errr = true; + var err = true; obj[0] = document.getElementById('reference'); } if (getcookie('c_designation').length < 1){ @@ -160,6 +163,9 @@ function new_componant() { var err = true; obj[2] = document.getElementById('place'); } + if (document.getElementById('provider_id').value == 1){ + setcookie('c_provider', '2', 30); + } if (err == true) { for (i in obj){ invalid_input(obj[i]); @@ -194,9 +200,8 @@ function create_componant() { xhttp.send(); } -/////////////////////////////////////////// // Update componant -/////////////////////////////////////////// + function update_componant(obj, componant_id, type) { if (type == 'numeric') { if (isNaN(obj.value)) { @@ -226,3 +231,182 @@ function update_componant(obj, componant_id, type) { xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhttp.send('field='+obj.id+'&value='+obj.value); } + +/* ************************************************************************************** + * PROVIDERS + * **************************************************************************************/ + +// Update result +function update_providers() { + 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', '/providers/update', true); + xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhttp.send(); +} + +// Result ordering + +function update_providers_by_name(order) { + setcookie('p_order', order, 30); + setcookie('p_sort', 'name', 30); + setcookie('p_order_refresh', '1', 30); + update_providers(); +} + +function update_providers_by_address(order) { + setcookie('p_order', order, 30); + setcookie('p_sort', 'address', 30); + setcookie('p_order_refresh', '1', 30); + update_providers(); +} + +function update_providers_by_mail(order) { + setcookie('p_order', order, 30); + setcookie('p_sort', 'mail', 30); + setcookie('p_order_refresh', '1', 30); + update_providers(); +} + +function update_providers_by_url(order) { + setcookie('p_order', order, 30); + setcookie('p_sort', 'url', 30); + setcookie('p_order_refresh', '1', 30); + update_providers(); +} + +function update_providers_by_commentl(order) { + setcookie('p_order', order, 30); + setcookie('p_sort', 'comment', 30); + setcookie('p_order_refresh', '1', 30); + update_providers(); +} + +function p_previous_page(prevhop) { + setcookie('p_offset', prevhop, 30); + update_providers(); +} + +function p_next_page(nexthop) { + setcookie('p_offset', nexthop, 30); + update_providers(); +} + +// Search providers + +function search_providers_by_name(obj) { + setcookie('p_name', obj.value, 30); + update_providers(); +} + +function search_providers_by_address(obj) { + setcookie('p_address', obj.value, 30); + update_providers(); +} + +function search_providers_by_mail(obj) { + setcookie('p_mail', obj.value, 30); + update_providers(); +} + +function search_providers_by_url(obj) { + setcookie('p_url', obj.value, 30); + update_providers(); +} + +function search_providers_by_comment(obj) { + setcookie('p_comment', obj.value, 30); + update_providers(); +} + +// New provider + +function new_provider() { + var err = false; + var obj = {}; + if (getcookie('p_count') > 0){ + var err = true; + obj[0] = document.getElementById('name'); + } + if (err == true) { + for (i in obj){ + invalid_input(obj[i]); + } + return; + } + create_provider(); + update_providers(); +} + +function create_provider() { + var MSG='Erreur lors de la creation du fournisseur.'; + 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', '/providers/new', true); + xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhttp.send(); +} + +// 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(){ + invalid_input(obj); + }; + + xhttp.onload = function(){ + if (xhttp.readyState == 4 && xhttp.status == 200) { + var response = xhttp.responseText; + if (response == 'OK'){ + valid_input(obj); + return; + } + obj.style.borderColor = red; + invalid_input(obj); + } + }; + + xhttp.open('POST', '/providers/update/'+provider_id, true); + xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhttp.send('field='+obj.id+'&value='+obj.value); +} diff --git a/static/style/style.css b/static/style/style.css index 624c135..d21e2cb 100644 --- a/static/style/style.css +++ b/static/style/style.css @@ -140,8 +140,8 @@ div.content { } div.note { - font-size: 12px; - line-height: 12px; + font-size: 14px; + line-height: 14px; } div.error { @@ -177,226 +177,6 @@ div.footer { text-align: center; } -/* *********************************** - * Résultats -*********************************** */ - -div.row_count { - padding: 5px; -} - -div.result_container { - text-align: left; -} - -.border_left { - border-left-width: 1px; - border-left-style: solid; -} - -.border_right { - border-right-width: 1px; - border-right-style: solid; -} - -div.block, div.noborder { - overflow: hidden; - border-top-style: solid; - border-top-width: 1px; - height: 20px; -} - -div.noborder { - border-style: none; -} - -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); - margin: 2px 0px 0px 20px; -} - -div.inner text.trash { - background: url(../images/trash.png); - margin: 2px 0px 0px 20px; -} - -div.block text.refresh { - background: url(../images/refresh.png); - margin: 2px 0px 0px 20px; -} - -div.block text.search { - background: url(../images/search.png); - margin-left: 255px; -} - -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; - 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, -div.block text.search, -div.block text.save { - width: 8px; - float:left; - height: 16px; - border-radius: 2px; - background-repeat: no-repeat; -} - -div.even { - background-color: #E5E5E5; -} - -div.odd { - background-color: #FFFFFF; -} - -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: 20px; - text-align: left; - vertical-align: middle; - 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: 20px; -} - -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: 20px; -} - -div.block input { - height: 17px; - width: 300px; -} - - /* *********************************** * Classes génériques *********************************** */ @@ -419,18 +199,184 @@ span.bold { font-weight: bold; } -table { - border-collapse: collapse; - width: 100%; +/* *********************************** + * Search +*********************************** */ + +div.main_block { + padding: 0; + margin: 0; + width: 1000px; + float: left; } -th { - background-color: #FFB387; +div.main_block text { + display: block; + font-weight: bold; + margin-bottom: 4px; } -th, td { - text-align: left; - padding: 8px; +div.button_block { + margin: 0 0 4px 0; + height: 20px; + width: 525px; } -tr:nth-child(even){background-color: #f2f2f2} +div.button_block input { + position: relative; + width: 16px; + height: 16px; + border-radius: 2px; + margin-right: 32px; + left: 250px; +} + +div.button_block input:hover { + cursor: pointer; + background-color: #FF5D00; +} + +div.input_block { + margin: 0 0 4px 0; + height: 20px; + width: 525px; +} + +div.input_block label { + display: block; + float: left; + width: 200px; + text-align: center; + font-weight: bold; + background-color: #FF5D00; + height: 20px; + text-align: left; + vertical-align: middle; + padding: 0 4px 0 4px; +} + +div.input_block select, div.input_block input { + width: 310px; + float: right; + 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: 20px; +} + +div.input_block input { + float: right; + height: 17px; + width: 300px; +} + +/* *********************************** + * Result +*********************************** */ + +.border_bottom { + border-bottom-style: solid; + border-bottom-width: 1px; +} + +.border_top { + border-top-style: solid; + border-top-width: 1px; +} + +.border_left { + border-left-width: 1px; + border-left-style: solid; +} + +div.even { + background-color: #E5E5E5; +} + +div.odd { + background-color: #FFFFFF; +} + +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; +} + +div.row_block { + margin: 0 0 4px 0; + height: 20px; + width: 1000px; +} + +div.nav_page_block { + text-align: right; + height: 20px; + width: 1000px; +} + +div.action_bar_block { + overflow: hidden; + float: center; + height: 20px; +} + +div.row_block label { + display: block; + float: left; + text-align: center; + font-weight: bold; + background-color: #FF5D00; + vertical-align: middle; +} + +div.row_block label:hover { + cursor: pointer; +} + +div.row_block label.border_left, +div.row_block text.border_left { + border-left-style: solid; + border-left-width: 1; +} + +div.row_block text { + display: block; + float: left; + font-weight: normal; + text-align: left; + overflow: hidden; + vertical-align: middle; + padding: 0 5px 0 5px; + white-space: nowrap; +} + +div.row_block text.num { + text-align: right; +} + +div.nav_page_block text { + display: block; + white-space: nowrap; +} + +div.action_bar_block input { + height: 17px; + width: 16px; + margin-left: 20px; +} diff --git a/stock.sql b/stock.sql index b5a7c0c..3c642f3 100644 --- a/stock.sql +++ b/stock.sql @@ -20,7 +20,7 @@ CREATE TABLE stock_kits ( CREATE TABLE stock_providers ( id serial primary key, - name text not NULL, + name text unique not NULL, address text not NULL, mail text not NULL, url text not NULL, @@ -58,7 +58,7 @@ insert into stock_providers (name, address, mail, url, comment) 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) - values ('China Elec Co', 'Beijing', 'sales@chinaelecco.cc', 'https://chinaelecco', 'Pas cher, mais...'); + values ('China Elec Co', 'Beijing', 'sales@chinaelecco.cc', 'https://chinaelecco.cc', 'Pas cher mais délai excessif et composants pourris'); 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', 3); diff --git a/templates/componant.html b/templates/componant.html index ecff4e7..8a40813 100644 --- a/templates/componant.html +++ b/templates/componant.html @@ -3,7 +3,6 @@ {% block top_menu %} Rechercher un composant Éditer un composant - Nouveau composant Entrée de stock Sortie de stock {% endblock %} @@ -24,111 +23,111 @@ {% 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:

-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+
+ 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 index 9ac068d..5e931ae 100644 --- a/templates/componants.html +++ b/templates/componants.html @@ -4,8 +4,7 @@ {% endblock %} {% block title %}Liste des composants{% endblock %} {% block top_menu %} - Rechercher un composant - Nouveau composant + Gestion des composants Entrée de stock Sortie de stock {% endblock %} @@ -29,66 +28,73 @@ -

Recherche:

-
- - -
-
- - -
-
- - -
-
- - -
-
- - + -
+
{% endblock %} diff --git a/templates/provider.html b/templates/provider.html new file mode 100644 index 0000000..8c0aeb0 --- /dev/null +++ b/templates/provider.html @@ -0,0 +1,76 @@ +{% extends "index.html" %} +{% block title %}Éditer un fournisseur{% endblock %} + {% block top_menu %} + Gérer les fournisseurs + Éditer un fournisseur + {% endblock %} + {% block left_menu %} +
+ Accueil +
+
+ Composants +
+
+ Kits +
+
+ Fournisseurs +
+ {% endblock %} + + {% block content %} +
+ Composant: +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ {% endblock %} diff --git a/templates/providers.html b/templates/providers.html new file mode 100644 index 0000000..76c0a5d --- /dev/null +++ b/templates/providers.html @@ -0,0 +1,90 @@ +{% extends "index.html" %} +{% block bodyheader %} + +{% endblock %} +{% block title %}Liste des fournisseurs{% endblock %} + {% block top_menu %} + Gérer les fournisseurs + {% endblock %} + + {% block left_menu %} +
+ Accueil +
+
+ Composants +
+
+ Kits +
+
+ Fournisseurs +
+ {% endblock %} + + {% block content %} + + + +
+ +
+ {% endblock %} diff --git a/templates/result.html b/templates/result.html deleted file mode 100644 index 4a5896e..0000000 --- a/templates/result.html +++ /dev/null @@ -1,31 +0,0 @@ -

Résultat:

- {% set ss='' %} - {% if row_count > 1 %} - {% set ss='s' %} - {% endif %} -
{{ row_count }} objet{{ ss }} selectionné{{ ss }}
-
- - - - - -
- {% set row_class = cycler('odd', 'even') %} - {% for componant in componants %} -
- {{ componant.reference }} - {{ componant.designation }} - {{ componant.quantity }} - {{ componant.place }} -
- - -
-
- {% endfor %} -
- < - {{ page }} / {{ page_count }} - > -
diff --git a/templates/result_componants.html b/templates/result_componants.html new file mode 100644 index 0000000..024c014 --- /dev/null +++ b/templates/result_componants.html @@ -0,0 +1,44 @@ +
+ Résultat: + {% set ss='' %} + {% if row_count > 1 %} + {% set ss='s' %} + {% endif %} + {{ row_count }} objet{{ ss }} selectionné{{ ss }} + +
+ + + + + +
+ {% set row_class = cycler('odd', 'even') %} + {% for componant in componants %} +
+ {{ componant.reference }} + {{ componant.designation }} + {{ componant.quantity }} + {{ componant.place }} +
+ + +
+
+ {% endfor %} + +
diff --git a/templates/result_providers.html b/templates/result_providers.html new file mode 100644 index 0000000..18d9818 --- /dev/null +++ b/templates/result_providers.html @@ -0,0 +1,44 @@ +
+ Résultat: + {% set ss='' %} + {% if row_count > 1 %} + {% set ss='s' %} + {% endif %} + {{ row_count }} objet{{ ss }} selectionné{{ ss }} + +
+ + + + + +
+ {% set row_class = cycler('odd', 'even') %} + {% for provider in providers %} +
+ {{ provider.name }} + {{ provider.address }} + {{ provider.mail }} + {{ provider.url }} +
+ + +
+
+ {% endfor %} + +
diff --git a/templates/test.html b/templates/test.html new file mode 100644 index 0000000..5e931ae --- /dev/null +++ b/templates/test.html @@ -0,0 +1,100 @@ +{% extends "index.html" %} +{% block bodyheader %} + +{% endblock %} +{% block title %}Liste des composants{% endblock %} + {% block top_menu %} + Gestion des composants + Entrée de stock + Sortie de stock + {% endblock %} + + {% block left_menu %} +
+ Accueil +
+
+ Composants +
+
+ Kits +
+
+ Fournisseurs +
+ {% endblock %} + + {% block content %} + + + +
+ +
+ {% endblock %} diff --git a/tetastock.py b/tetastock.py index 24a9067..7be8849 100755 --- a/tetastock.py +++ b/tetastock.py @@ -42,6 +42,7 @@ class Stock_providers(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text, nullable=False) address = db.Column(db.Text) + mail = db.Column(db.Text) url = db.Column(db.Text) comment = db.Column(db.Text) @@ -60,16 +61,19 @@ def resume_session(func): @wraps(func) def check(*args, **kwargs): # default - limit = 8 + limit = 10 offset = 0 + page = 1 nexthop = offset + limit prevhop = offset - sort = 'reference' order = 'asc' order_refresh = 0 c_empty = '' + c_sort = 'reference' c_provider = 0 c_count = 0 + p_empty = '' + p_sort = 'name' offset_reset = ['c_reference', 'c_designation', 'c_place', 'c_provider'] if not 'session' in session: session['session'] = '' @@ -78,11 +82,13 @@ def resume_session(func): if not 'c_offest' in session: session['c_offset'] = offset if not 'c_sort' in session: - session['c_sort'] = sort + session['c_sort'] = c_sort if not 'c_order' in session: session['c_order'] = order if not 'c_order_refresh' in session: session['c_order_refresh'] = order_refresh + if not 'c_page' in session: + session['c_page'] = page if not 'c_nexthop' in session: session['c_nexthop'] = nexthop if not 'c_prevhop' in session: @@ -97,6 +103,33 @@ def resume_session(func): session['c_provider'] = c_provider if not 'c_count' in session: session['c_count'] = c_count + if not 'p_sort' in session: + session['p_sort'] = p_sort + if not 'p_order' in session: + session['p_order'] = order + if not 'p_order_refresh' in session: + session['p_order_refresh'] = order_refresh + if not 'p_page' in session: + session['p_page'] = page + if not 'p_nexthop' in session: + session['p_nexthop'] = nexthop + if not 'p_prevhop' in session: + session['p_prevhop'] = prevhop + if not 'p_offset' in session: + session['p_offset'] = offset + if not 'p_limit' in session: + session['p_limit'] = limit + if not 'p_name' in session: + session['p_name'] = p_empty + if not 'p_address' in session: + session['p_address'] = p_empty + if not 'p_mail' in session: + session['p_mail'] = p_empty + if not 'p_url' in session: + session['p_url'] = p_empty + if not 'p_comment' in session: + session['p_comment'] = p_empty + # Cookies/session sync for key in request.cookies: old = str(session[key]) @@ -109,14 +142,18 @@ def resume_session(func): session['c_offset'] = 0 if key != 'session': - print '+', key, request.cookies[key] + print '[s]', key, request.cookies[key] # Switch sort order if session['c_order_refresh'] == 1: refresh = {'desc': 'asc', 'asc': 'desc'} session['c_order'] = refresh[session['c_order']] - session['c_order_refresh'] = 0 + session['c_order_refresh'] = 0 + if session['p_order_refresh'] == 1: + refresh = {'desc': 'asc', 'asc': 'desc'} + session['p_order'] = refresh[session['p_order']] + session['p_order_refresh'] = 0 return func(*args, **kwargs) return check @@ -149,6 +186,7 @@ def componants(): provider_id=session['c_provider']) @app.route('/componants/') +@resume_session def get_componant(componant_id): """ Edit componant """ try: @@ -164,6 +202,7 @@ def get_componant(componant_id): return render_template('error.html'), 404 @app.route('/componants/update/', methods=['POST']) +@resume_session def update_componant(componant_id): """ Update componant field""" field = request.form['field'] @@ -180,14 +219,17 @@ def update_componant(componant_id): return 'KO' @app.route('/componants/delete/') +@resume_session def delete_componant(componant_id): """ Delete componant """ try: componant_id = int(componant_id) + Stock_componants.query.filter_by(id=componant_id).delete() + db.session.commit() except ValueError as e: return render_template('error.html'), 404 - Stock_componants.query.filter_by(id=componant_id).delete() - db.session.commit() + except Exception as e: + print "[+] Error at delete_componant:\n------------------------------\n%s------------------------------" % e.message return componants() @app.route('/componants/new', methods=['POST']) @@ -206,18 +248,20 @@ def new_componant(): db.session.add(componant) commit = db.session.commit() except Exception as e: - print e + print "[+] Error at new_componant:\n------------------------------\n%s------------------------------" % e.message return 'KO' if commit != None: return 'KO' return 'OK' @app.route('/componants/in/') +@resume_session def in_componants(): """ Incoming order """ return render_template('wip.html') @app.route('/componants/out/') +@resume_session def out_componants(): """ Outgoing order """ return render_template('wip.html') @@ -246,7 +290,6 @@ def update_componants(): if session['c_page'] > session['c_pagecount']: session['c_page'] = session['c_pagecount'] session['c_offset'] = 0 - print "*****", componants.count(), session['c_pagecount'], session['c_page'] session['c_nexthop'] = session['c_offset'] + session['c_limit'] if session['c_nexthop'] > session['c_count'] - 1: session['c_nexthop'] = int(session['c_offset']) @@ -265,7 +308,7 @@ def update_componants(): # Get result componants = componants.all() - response = app.make_response(render_template('result.html', + response = app.make_response(render_template('result_componants.html', componants=componants, offset=session['c_offset'] , nexthop=session['c_nexthop'], @@ -278,101 +321,160 @@ def update_componants(): for key in session: response.set_cookie(key, value=str(session[key])) if key != 'session': - print '++', key, session[key] + print '[c]', key, session[key] + return response + +######################################################################## +# Providers +######################################################################## +@app.route('/providers', methods=['GET', 'POST']) +@resume_session +def providers(): + return render_template('providers.html', + name=session['p_name'], + address=session['p_address'], + mail=session['p_mail'], + url=session['p_url'], + comment=session['p_comment']) + +@app.route('/providers/') +@resume_session +def get_provider(provider_id): + """ Edit provider """ + try: + provider_id = int(provider_id) + except ValueError as e: + return render_template('error.html'), 404 + provider = Stock_providers.query.filter_by(id=provider_id).first() + if provider: + return render_template('provider.html', provider=provider) + return render_template('error.html'), 404 + + +@app.route('/providers/update/', methods=['POST']) +@resume_session +def update_provider(provider_id): + """ Update provider field""" + field = request.form['field'] + value = request.form['value'] + if field and value: + try: + provider = Stock_providers.query.filter_by(id=provider_id).first() + setattr(provider, field, value) + commit = db.session.commit() + if commit == None: + return 'OK' + except Exception as e: + pass + return 'KO' + +@app.route('/providers/new', methods=['POST']) +@resume_session +def new_provider(): + """ Add provider """ + provider = Stock_providers(name=session['p_name'], + address=session['p_address'], + mail=session['p_mail'], + url=session['p_url'], + comment=session['p_comment']) + try: + db.session.add(provider) + commit = db.session.commit() + except Exception as e: + print 'Error at new_provider():', e + print 'Commit = ', commit + return 'KO' + if commit != None: + return 'KO' + return 'OK' + +@app.route('/providers/delete/') +@resume_session +def delete_provider(provider_id): + """ Delete provider """ + try: + provider_id = int(provider_id) + Stock_providers.query.filter_by(id=provider_id).delete() + db.session.commit() + except ValueError as e: + return render_template('error.html'), 404 + except Exception as e: + print "[+] Error at delete_provider:\n-----------------------------\n%s-----------------------------" % e.message + return providers() + +@app.route('/providers/update', methods=['POST']) +@resume_session +def search_providers(): + """ Display componants list """ + # search by reference + like = '%s%s%s' % ('%', str(session['p_name']), '%') + providers = Stock_providers.query.filter(Stock_providers.name.like(like)) + # search by designation + like = '%s%s%s' % ('%', str(session['p_address']), '%') + providers = providers.filter(Stock_providers.address.like(like)) + # search by place + like = '%s%s%s' % ('%', str(session['p_mail']),'%') + providers = providers.filter(Stock_providers.mail.like(like)) + # search by place + like = '%s%s%s' % ('%', str(session['p_url']),'%') + providers = providers.filter(Stock_providers.url.like(like)) + # search by place + like = '%s%s%s' % ('%', str(session['p_comment']),'%') + providers = providers.filter(Stock_providers.comment.like(like)) + # Don't take 'all' and 'none' entry + providers = providers.filter(Stock_providers.id > 2) + + # Pages calculation + session['p_count'] = providers.count() + session['p_pagecount'] = int(math.ceil(session['p_count'] / float(session['p_limit']))) + session['p_page'] = int(math.ceil(float(float(session['p_offset']) + 1) / float(session['p_limit']))) + if session['p_page'] > session['p_pagecount']: + session['p_page'] = session['p_pagecount'] + session['p_offset'] = 0 + session['p_nexthop'] = session['p_offset'] + session['p_limit'] + if session['p_nexthop'] > session['p_count'] - 1: + session['p_nexthop'] = int(session['p_offset']) + session['p_prevhop'] = int(session['p_offset']) - session['p_limit'] + if session['p_prevhop'] < 0: + session['p_prevhop'] = 0 + # Sorting + sort = getattr(Stock_providers, session['p_sort']) + if session['p_order'] == 'desc': + sort = getattr(Stock_providers, session['p_sort']).desc() + providers = providers.order_by(sort) + # Applying offset + providers = providers.offset(session['p_offset']) + # Applying limit + providers = providers.limit(session['p_limit']) + # Get result + providers = providers.all() + response = app.make_response(render_template('result_providers.html', + providers=providers, + offset=session['p_offset'] , + nexthop=session['p_nexthop'], + prevhop=session['p_prevhop'], + page_count=session['p_pagecount'], + page=session['p_page'], + sort=session['p_sort'], + order=session['p_order'], + row_count=session['p_count'])) + for key in session: + response.set_cookie(key, value=str(session[key])) + if key != 'session': + print '[c]', key, session[key] return response ######################################################################## # Kits ######################################################################## -@app.route('/kits') -def get_kits(): - return render_template('kits.html') -@app.route('/kits/') -def get_kit(kit_id): - return render_template('wip.html') - -@app.route('/kits/add/') -def add_kit(kit_id): - return render_template('wip.html') - -@app.route('/kits/edit/') -def edit_kit(kit_id): - return render_template('wip.html') - -@app.route('/kits/delete/') -def delete_kit(kit_id): - return render_template('wip.html') - -@app.route('/kits/search') -def search_kits(): - return render_template('wip.html') -######################################################################## -# Providers -######################################################################## -@app.route('/providers') -def get_providers(): - return render_template('providers.html') - -@app.route('/providers/') -def get_provider(provider_id): - return render_template('wip.html') - -@app.route('/providers/add/') -def add_provider(provider_id): - return render_template('wip.html') - -@app.route('/providers/edit/') -def edit_provider(provider_id): - return render_template('wip.html') - -@app.route('/providers/delete/') -def delete_provider(provider_id): - return render_template('wip.html') - -@app.route('/providers/search') -def search_providers(): - return render_template('wip.html') ######################################################################## # Users ######################################################################## -@app.route('/users') -def get_users(): - return render_template('wip.html') -@app.route('/users/') -def get_user(user_id): - return render_template('wip.html') - -@app.route('/users/add/') -def add_user(user_id): - return render_template('wip.html') - -@app.route('/users/edit/') -def edit_user(user_id): - return render_template('wip.html') - -@app.route('/users/delete/') -def delete_user(user_id): - return render_template('wip.html') - -@app.route('/users/search') -def search_users(): - return render_template('wip.html') - -############################################## -# SQL -############################################## -def sql_get_distinct(query): - results = [] - for result in query: - result = result[0] - if result not in results: - results.append(result) - return results # Main #######################################