diff --git a/app.py b/app.py index cb89f7a..23b2c07 100644 --- a/app.py +++ b/app.py @@ -119,20 +119,26 @@ def alloborud(): @app.route('/getall') def getall(): - oboruds = Oboruds.query.all() - oboruds_json = [{ - - 'invNumber': oborud.invNumber, - 'nazvanie': oborud.nazvanie, - 'raspologenie': oborud.raspologenie, - 'balancenumber': oborud.balancenumber, - 'kolichestvo': oborud.kolichestvo, - 'balancenumber': oborud.balancenumber, - 'aud_id': oborud.aud_id - } for oborud in oboruds] + oborud = db.session.query(Auditory, Oboruds).filter( + Oboruds.aud_id==Auditory.id + ).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 + + }) + - return jsonify(oboruds_json) + return jsonify(results) @app.route('/updateduplicate', methods=['GET', 'POST']) def updateduplicate(): diff --git a/static/js/allmatc.js b/static/js/allmatc.js index bd27654..ff2c8e2 100644 --- a/static/js/allmatc.js +++ b/static/js/allmatc.js @@ -1,36 +1,43 @@ -function getAllData(){ - $.ajax({ - url: "/getall", - type: "get", - contentType: 'application/json', - dataType: 'json', +$(document).ready(function() { - success: function(response){ - console.log("1111") - let data = response; - var table = document.getElementById('alldatable'); - var tbody = table.getElementsByTagName('tbody')[0]; + let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0]; + tableBody.innerHTML = ''; + i = 0; + + $.getJSON("/getall", function(data) { + $.each(data, function(index, item) { + let newRow = tableBody.insertRow(tableBody.rows.length); + let cell1 = newRow.insertCell(0); + let cell2 = newRow.insertCell(1); + let cell3 = newRow.insertCell(2); + let cell4 = newRow.insertCell(3); + let cell5 = newRow.insertCell(4); + let cell6 = newRow.insertCell(5); + let cell7 = newRow.insertCell(6); + i++; + + cell1.innerText = i; + cell2.innerText = item.invNumber; + cell4.innerText = item.nazvanie; + cell3.innerText = item.kolichestvo; + cell5.innerText = item.numberved; + cell6.innerText = item.raspologenie; + cell7.innerText = item.aud; - // Clear existing data - tbody.innerHTML = ''; - - // Loop through the data and create table rows - data.forEach(function(item) { - var row = document.createElement('tr'); - Object.values(item).forEach(function(value) { - var cell = document.createElement('td'); - cell.textContent = value; - row.appendChild(cell); - }); - tbody.appendChild(row); - }); - - - }, - - }) -} + $(newRow).data('itemData', i); -getAllData() + $(newRow).on("click", function() { + let ind = newRow.cells[0].innerText; + let invNumber = newRow.cells[1].innerText; + + $('#getmodal').modal('show') + }); + + }); + }); + + }); + + diff --git a/templates/all.html b/templates/all.html index 62b54bf..0729e6d 100644 --- a/templates/all.html +++ b/templates/all.html @@ -2,10 +2,53 @@ {% block content %} + + +
+| № п/п | @@ -27,6 +70,16 @@Аудитория | |||||
|---|---|---|---|---|---|---|
| 1 | +2 | +3 | +4 | +5 | +6 | +7 | + +