diff --git a/.gitignore b/.gitignore index cd420b7..d42868d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ project.db c*.txt +__pycache__/app.cpython-312.pyc +__pycache__/models.cpython-312.pyc diff --git a/app.py b/app.py index 75793c3..4571ff5 100644 --- a/app.py +++ b/app.py @@ -114,20 +114,26 @@ def addoborudtodb(): @app.route('/all') def alloborud(): + return render_template('all.html') - result = db.session.query(Oboruds).order_by(Oboruds.invNumber).all() - res = [] +@app.route('/getall') +def getall(): + oboruds = Oboruds.query.all() + oboruds_json = [{ + 'id': oborud.id, + 'invNumber': oborud.invNumber, + 'nazvanie': oborud.nazvanie, + 'raspologenie': oborud.raspologenie, + 'numberved': oborud.numberved, + 'buhnumberpp': oborud.buhnumberpp, + 'kolichestvo': oborud.kolichestvo, + 'balancenumber': oborud.balancenumber, + 'aud_id': oborud.aud_id + } for oborud in oboruds] - for ob in result: - if ob.aud_id is not None: - aud = db.session.query(Auditory).filter_by(id=ob.aud_id).first() - res.append([ob.invNumber, ob.nazvanie, aud.audnazvanie]) - else: - res.append([ob.invNumber, ob.nazvanie]) - - return render_template('all.html', res=res) + return jsonify(oboruds_json) @app.route('/updateduplicate', methods=['GET', 'POST']) def updateduplicate(): diff --git a/static/css/index.css b/static/css/index.css index 6bc3fb1..72385ec 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -100,6 +100,15 @@ nav{ margin-left: 20px; } +.datatable{ + background-color: whitesmoke; +} + + + + + + @media print { *{ diff --git a/static/js/allmatc.js b/static/js/allmatc.js new file mode 100644 index 0000000..c9e2668 --- /dev/null +++ b/static/js/allmatc.js @@ -0,0 +1,35 @@ +function getAllData(){ + $.ajax({ + + url: "/getall", + type: "get", + contentType: 'application/json', + dataType: 'json', + + success: function(response){ + console.log(response) + let data = response; + $('#datatable tbody').empty(); + $.each(response, function(index, item) { + $('#datatable tbody').append( + '
| № п/п | +№ п/п вед | +Инв. номер | +Название | +Кол-во | +Счёт | +Аудитория | +
|---|