add get data func
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -175,44 +175,23 @@ def zamsearch():
|
||||
p = request.form.get('srch')
|
||||
|
||||
searchedZam = db.session.query(Zametki).filter(
|
||||
Zametki.txtzam.contains(p)).all()
|
||||
|
||||
Zametki.txtzam.contains(p)).ll()
|
||||
zam = []
|
||||
|
||||
for item in searchedZam:
|
||||
zam.append([item.txtzam, item.created_date])
|
||||
|
||||
zam.append([item.txtzam, item.created_date])
|
||||
return render_template('zametki.html', zam=zam)
|
||||
|
||||
# ==================================================================================
|
||||
|
||||
# Выгрузка в пдф
|
||||
|
||||
@app.route('/pdfexport')
|
||||
def pdfexport():
|
||||
auds = db.session.query(Auditory).all()
|
||||
print(auds)
|
||||
for aud in auds:
|
||||
q = db.session.query(Auditory, Oboruds).filter(
|
||||
Auditory.id == Oboruds.aud_id
|
||||
).filter(Auditory.id == aud.id
|
||||
).order_by(Oboruds.invNumber).all()
|
||||
print(q)
|
||||
|
||||
results = []
|
||||
for auditory, oboruds in q:
|
||||
results.append({
|
||||
'auditory_id': auditory.id,
|
||||
'auditory_name': auditory.audnazvanie,
|
||||
'inv_number': oboruds.invNumber,
|
||||
'oboruds_id': oboruds.nazvanie,
|
||||
})
|
||||
html = render_template('searchonaud.html', aud=auds, res=results)
|
||||
|
||||
return render_pdf(HTML(string=html))
|
||||
|
||||
def ranomraspr():
|
||||
with app.app_context():
|
||||
while len(db.session.query(Oboruds).filter(Oboruds.aud_id == None).all()) > 0:
|
||||
audid = random.choice(db.session.query(Auditory).all())
|
||||
oborud = random.choice(db.session.query(Oboruds).filter(Oboruds.aud_id == None).all())
|
||||
oborud.aud_id = audid.id
|
||||
db.session.commit()
|
||||
|
||||
|
||||
# ==================================================================================
|
||||
def createdb():
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
@@ -247,66 +226,28 @@ def createdb():
|
||||
|
||||
db.session.commit()
|
||||
|
||||
#with open('inventMavrin.csv', encoding='cp1251') as csv_file:
|
||||
# csv_reader = csv.reader(csv_file, delimiter=';')
|
||||
# for row in csv_reader:
|
||||
# db.session.add(
|
||||
# Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse='баланс'))
|
||||
#db.session.commit()
|
||||
|
||||
|
||||
def updateOborud():
|
||||
with app.app_context():
|
||||
db.session.query(Oboruds).update({Oboruds.typeBalanse: 'баланс'})
|
||||
with open('inventMavrin.csv', encoding='cp1251') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=';')
|
||||
for row in csv_reader:
|
||||
db.session.add(
|
||||
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse='баланс'))
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def addZabalans():
|
||||
with app.app_context():
|
||||
|
||||
"""
|
||||
with open('zabalans.csv', encoding='utf-8') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=';')
|
||||
for row in csv_reader:
|
||||
print(row)
|
||||
db.session.add(
|
||||
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse="забаланс"))
|
||||
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse="забаланс"))
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def randomraspr():
|
||||
with app.app_context():
|
||||
while db.session.query(Oboruds).filter(Oboruds.aud_id == None).all():
|
||||
audid = random.choice(db.session.query(Auditory).all())
|
||||
oborud = random.choice(db.session.query(
|
||||
Oboruds).filter(Oboruds.aud_id == None).all())
|
||||
oborud.aud_id = audid.id
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def randomzam():
|
||||
files = ['cf.txt', 'ci.txt', 'co.txt']
|
||||
|
||||
fio = []
|
||||
for i in range(20):
|
||||
tmp = []
|
||||
for file in files:
|
||||
f = open(file, "r", encoding="utf-8").readlines()
|
||||
tmp.append(random.choice(f))
|
||||
|
||||
fio.append((''.join(tmp)).replace('\n', ' ').replace('\t', ''))
|
||||
|
||||
print(fio)
|
||||
|
||||
for item in fio:
|
||||
timeadd = datetime.now(timezone.utc)
|
||||
with app.app_context():
|
||||
db.session.add(Zametki(txtzam=item, created_date=timeadd))
|
||||
db.session.commit()
|
||||
|
||||
# ==================================
|
||||
db.session.commit()
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
app.run(debug=True, host='0.0.0.0', port='3800')
|
||||
#ranomraspr()
|
||||
#createdb()
|
||||
app.run(debug=True, host='0.0.0.0', port='3800')
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -24,21 +24,29 @@
|
||||
var tr =""
|
||||
|
||||
data.forEach(element => {
|
||||
|
||||
tr += '<tr onclick="tableclick(this)">'
|
||||
tr += '<td>' + element.inv_number + '</td>'
|
||||
tr += '<td>' + element.oboruds_id + '</td>'
|
||||
tr += '<td class="no-print">' + element.auditory_name + '</td>'
|
||||
tr += '<td>' + '\n' + '</td>'
|
||||
|
||||
|
||||
tr += '</tr>'
|
||||
|
||||
});
|
||||
|
||||
table.innerHTML += tr
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
function tableclick(x){
|
||||
let roww = x.rowIndex
|
||||
let data = document.getElementById(x.rowIndex)
|
||||
|
||||
let datas = x.innerText.split('\t')
|
||||
|
||||
console.log(datas[0])
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -8,4 +8,5 @@
|
||||
<script src="{{url_for('static', filename='js/printall.js') }}"></script>
|
||||
<script src="{{url_for('static', filename='js/zametki.js') }}"></script>
|
||||
<script src="{{url_for('static', filename='js/searchonaud.js') }}"></script>
|
||||
<script src="{{url_for('static', filename='js/print.js') }}"></script>
|
||||
<script src="{{url_for('static', filename='js/print.js') }}"></script>
|
||||
<script src="{{url_for('static', filename='js/modal.js') }}"></script>
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="card col-md-10 col-10">
|
||||
<form method="POST" action="/addoborudtodb">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title no-print"> Поаудиторно </h3>
|
||||
|
||||
@@ -39,12 +38,10 @@
|
||||
<td> {{ item[1] }} </td>
|
||||
<td class="no-print"> {{item[2]}} </td>
|
||||
<td id="proverka"> Проверено </td>
|
||||
|
||||
|
||||
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user