diff --git a/app.py b/app.py index efabbad..3a120cc 100644 --- a/app.py +++ b/app.py @@ -119,23 +119,32 @@ def alloborud(): @app.route('/getall') def getall(): - oborud = db.session.query(Auditory, Oboruds).filter( - Oboruds.aud_id==Auditory.id - ).order_by(Oboruds.invNumber).all() + oborud = db.session.query(Oboruds).order_by(Oboruds.invNumber).all() results = [] - for auditory, oboruds in oborud : - results.append({ - 'invNumber': oboruds.invNumber, - 'nazvanie': oboruds.nazvanie, - 'raspologenie': oboruds.raspologenie, - 'balancenumber': oboruds.balancenumber, - 'kolichestvo': oboruds.kolichestvo, - 'numberppasu': oboruds.numberppasu, - 'numberved': oboruds.numberved, - 'aud': auditory.audnazvanie - - }) + for oboruds in oborud : + if oboruds.aud_id is None: + results.append({ + 'invNumber': oboruds.invNumber, + 'nazvanie': oboruds.nazvanie, + 'raspologenie': oboruds.raspologenie, + 'balancenumber': oboruds.balancenumber, + 'kolichestvo': oboruds.kolichestvo, + 'numberppasu': oboruds.numberppasu, + 'numberved': oboruds.numberved, + 'aud': "" }) + else: + aud = db.session.query(Auditory).filter_by(id=oboruds.aud_id).first() + results.append({ + 'invNumber': oboruds.invNumber, + 'nazvanie': oboruds.nazvanie, + 'raspologenie': oboruds.raspologenie, + 'balancenumber': oboruds.balancenumber, + 'kolichestvo': oboruds.kolichestvo, + 'numberppasu': oboruds.numberppasu, + 'numberved': oboruds.numberved, + 'aud': aud.audnazvanie }) + return jsonify(results) @@ -196,7 +205,7 @@ def addraspved(): query_string = request.data.decode() un_query_string = unquote(unquote(query_string)).split(',') - + ob = db.session.query(Oboruds).filter_by(invNumber=un_query_string[0]).first() @@ -211,7 +220,32 @@ def addraspved(): return jsonify({'success': True}, 200, {'ContentType': 'application/json'}) - + + +@app.route('/addoborudasu', methods=['GET', 'POST']) +def addoborud(): + if request.method == 'POST': + + query_string = request.data.decode() + + un_query_string = unquote(unquote(query_string)).split(',') + print(un_query_string) + + + db.session.add( + Oboruds(invNumber=un_query_string[0], + nazvanie=un_query_string[5], + raspologenie= un_query_string[4], + numberved=un_query_string[1], + kolichestvo=un_query_string[2], + balancenumber=un_query_string[3] + ) + ) + + db.session.commit() + + + return jsonify({'success': True}, 200, {'ContentType': 'application/json'}) # ================================================================================== diff --git a/static/js/allmatc.js b/static/js/allmatc.js index 644f435..acd3864 100644 --- a/static/js/allmatc.js +++ b/static/js/allmatc.js @@ -1,5 +1,18 @@ +function clearTable() { + var table = document.getElementById("alldatatable"); + var rowCount = table.rows.length; + + // Iterate through each row and remove it + for (var i = rowCount - 1; i > 0; i--) { + table.deleteRow(i); + } +} + function getAllData(){ + console.log('12321321') + ///clearTable(); + let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0]; i = 0; $.getJSON("/getall", function(data) { @@ -82,7 +95,7 @@ $( document ).ready(function() { }); - $('#modalclose').click(function(){ +$('#modalclose').click(function(){ let vednumber = document.getElementById('modal_vednumber') @@ -112,6 +125,7 @@ $('#modalsavetodb').click(function(){ let balancenumber = document.getElementById('modal_balance') let matcen = document.getElementById('modal_matcenn') let rasp = document.getElementById('modal_rapolog') + let nazv = document.getElementById('modal_nazvanie') @@ -124,6 +138,7 @@ $('#modalsavetodb').click(function(){ changeddata[3] = balancenumber.value; changeddata[4] = rasp.value; + let sendData = changeddata.join(',') console.log(sendData) @@ -138,19 +153,103 @@ $('#modalsavetodb').click(function(){ success: function(){ $('#getmodal').modal('hide') - - getAllData() - + + getAllData(); vednumber.value = ''; kolvo.value = ''; balancenumber.value = ''; matcen.value = ''; rasp.value = ''; - changeddata = [] - - + changeddata = []; }, }) -}) \ No newline at end of file +}) + + +$('#addoborud').click(function(){ + + $('#addmodal').modal('show'); + +}) + +$('#modal2savetodb').click(function(){ + + let invnom = document.getElementById('modal2_invnom') + let vednumber = document.getElementById('modal2_vednumber') + let kolvo = document.getElementById('modal2_kolvo') + let balancenumber = document.getElementById('modal2_balance') + let matcen = document.getElementById('modal2_matcenn') + let rasp = document.getElementById('modal2_rapolog') + let nazv = document.getElementById('modal2_nazvanie') + + + + + let changeddata = new Array() + + changeddata[0] = invnom.value; + changeddata[1] = vednumber.value; + changeddata[2] = kolvo.value; + changeddata[3] = balancenumber.value; + changeddata[4] = rasp.value; + changeddata[5] = nazv.value; + + + + let sendData = changeddata.join(',') + console.log(sendData) + + $.ajax({ + + url: "/addoborudasu", + type: "POST", + contentType: "application/json;charset=utf-8", + dataType: "json", + data: sendData, + + success: function(){ + vednumber.value = ''; + invnom.value= ''; + nazvanie.value=''; + kolvo.value = ''; + balancenumber.value = ''; + matcen.value = ''; + rasp.value = ''; + $('#addmodal').modal('hide') + + + }, + + }) + + +}) + +$('#modal2close').click(function(){ + + + let vednumber = document.getElementById('modal2_vednumber') + let invnomer = document.getElementById('modal2_invnom') + let nazvanie = document.getElementById('modal2_nazvanie') + let kolvo = document.getElementById('modal2_kolvo') + let balancenumber = document.getElementById('modal2_balance') + let matcen = document.getElementById('modal2_matcenn') + let rasp = document.getElementById('modal2_rapolog') + + + + vednumber.value = ''; + invnomer.value= ''; + nazvanie.value=''; + kolvo.value = ''; + balancenumber.value = ''; + matcen.value = ''; + rasp.value = ''; + + $('#addmodal').modal('hide') + + + +} ) \ No newline at end of file diff --git a/templates/all.html b/templates/all.html index 260e58d..e0c36de 100644 --- a/templates/all.html +++ b/templates/all.html @@ -44,15 +44,78 @@ + + + + + + +

Все мат. ценности

-
- -
+
+ +
+ +
+
+ +
@@ -72,13 +135,7 @@ - 1 - 2 - 3 - 4 - 5 - 6 - 7 +