add sorting func
This commit is contained in:
154
app.py
154
app.py
@@ -9,12 +9,14 @@ import random
|
||||
from urllib.parse import unquote
|
||||
from flask_httpauth import HTTPBasicAuth
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from openpyxl import load_workbook
|
||||
|
||||
import xlrd
|
||||
import xlwt
|
||||
import xlsxwriter
|
||||
from xlutils.copy import copy
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db"
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///PRODproject.db"
|
||||
app.jinja_env.auto_reload = True
|
||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||
|
||||
@@ -25,14 +27,12 @@ db.init_app(app)
|
||||
migrate = Migrate(app, db)
|
||||
|
||||
|
||||
|
||||
@app.route("/login", methods=['GET', 'POST'])
|
||||
@app.route("/login", methods=['GET', 'POST'])
|
||||
def login():
|
||||
return render_template('login.html')
|
||||
|
||||
|
||||
|
||||
@app.route("/", methods=['GET', 'POST'])
|
||||
@app.route("/", methods=['GET', 'POST'])
|
||||
def index():
|
||||
results = []
|
||||
results1 = []
|
||||
@@ -56,7 +56,7 @@ def index():
|
||||
results1.append(s.nazvanie)
|
||||
aud = db.session.get(Auditory, s.aud_id)
|
||||
results1.append(aud.audnazvanie)
|
||||
return render_template('index.html', aud=all_aud, results=results, res1=results1)
|
||||
return render_template('index.html', aud=all_aud, results=results, res1=results1)
|
||||
return render_template('index.html', aud=all_aud, results=results, res1=results1)
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ def searchonaud():
|
||||
return render_template('searchonaud.html', aud=all_aud, res=res)
|
||||
|
||||
|
||||
@app.route("/addaudtodb", methods=['GET', 'POST'])
|
||||
@app.route("/addaudtodb", methods=['GET', 'POST'])
|
||||
def addaudtodb():
|
||||
if request.method == 'POST':
|
||||
aud = request.form.get('auditory')
|
||||
@@ -132,30 +132,28 @@ def getall():
|
||||
oborud = db.session.query(Oboruds).order_by(Oboruds.invNumber).all()
|
||||
|
||||
results = []
|
||||
for oboruds in oborud :
|
||||
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': "" })
|
||||
'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 })
|
||||
|
||||
|
||||
'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)
|
||||
|
||||
@@ -173,7 +171,7 @@ def vneaud():
|
||||
return render_template('vneaud.html', res=res, kolvo=len(data), all_kol=len(ak))
|
||||
|
||||
|
||||
@app.route('/zametki', methods=['GET', 'POST'])
|
||||
@app.route('/zametki', methods=['GET', 'POST'])
|
||||
def zametki():
|
||||
zam = db.session.query(Zametki).filter(Zametki.rmdt == None).all()
|
||||
if request.method == 'POST':
|
||||
@@ -196,7 +194,7 @@ def js2():
|
||||
return jsonify({'success': True}), 200, {'ContentType': 'application/json'}
|
||||
|
||||
|
||||
@app.route('/zamsearch', methods=['GET', 'POST'])
|
||||
@app.route('/zamsearch', methods=['GET', 'POST'])
|
||||
def zamsearch():
|
||||
p = request.form.get('srch')
|
||||
|
||||
@@ -204,66 +202,61 @@ def zamsearch():
|
||||
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('/addraspved', methods=['GET', 'POST'])
|
||||
def addraspved():
|
||||
if request.method == 'POST':
|
||||
|
||||
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()
|
||||
|
||||
ob.numberved=un_query_string[1]
|
||||
ob.numberved = un_query_string[1]
|
||||
ob.kolichestvo = un_query_string[2]
|
||||
ob.balancenumber = un_query_string[3]
|
||||
ob.raspologenie=un_query_string[4]
|
||||
|
||||
ob.raspologenie = un_query_string[4]
|
||||
|
||||
db.session.commit()
|
||||
db.session.close()
|
||||
|
||||
|
||||
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(',')
|
||||
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]
|
||||
)
|
||||
)
|
||||
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'})
|
||||
|
||||
|
||||
# ==================================================================================
|
||||
|
||||
|
||||
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()
|
||||
with app.app_context():
|
||||
while len(db.session.query(Oboruds).filter(Oboruds.aud_id is None).all()) > 0:
|
||||
audid = random.choice(db.session.query(Auditory).all())
|
||||
oborud = random.choice(db.session.query(Oboruds).filter(Oboruds.aud_id is None).all())
|
||||
oborud.aud_id = audid.id
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def createdb():
|
||||
@@ -308,32 +301,49 @@ def createdb():
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def write2excell():
|
||||
wb = load_workbook("VedomostMOL.xlsx")
|
||||
sheet = wb.worksheets[0]
|
||||
wb = xlrd.open_workbook("VedIsh.xls")
|
||||
sheet = wb.sheet_by_index(0)
|
||||
|
||||
x=19314
|
||||
|
||||
with app.app_context():
|
||||
joinQuery = db.session.query(Oboruds, Auditory).filter(
|
||||
Oboruds.aud_id == Auditory.id).filter(
|
||||
Oboruds.invNumber==x)
|
||||
|
||||
print(joinQuery.all())
|
||||
|
||||
|
||||
|
||||
for i in range(10):
|
||||
cell = 'B'+str(i+6)
|
||||
newFile = copy(wb)
|
||||
newSheet = newFile.get_sheet(0)
|
||||
invNomerColum = 6
|
||||
|
||||
column_index = 1
|
||||
for row_idx in range(sheet.nrows):
|
||||
cell_value = sheet.cell(row_idx, column_index)
|
||||
|
||||
if cell_value:
|
||||
|
||||
tmp_inv_number = str(cell_value).split(':')[1]
|
||||
|
||||
try:
|
||||
a = tmp_inv_number[1:-1]
|
||||
|
||||
inv_number = int(tmp_inv_number[1:-1])
|
||||
|
||||
with app.app_context():
|
||||
auditory_obj = db.session.query(Auditory).join(Oboruds, Oboruds.aud_id == Auditory.id).filter(
|
||||
Oboruds.invNumber == inv_number).first()
|
||||
|
||||
print(auditory_obj.audnazvanie)
|
||||
|
||||
# cur.execute("SELECT aud.audnazvanie FROM oboruds AS ob JOIN auditory AS aud ON ob.aud_id = aud.id WHERE ob.invNumber = ?", (inv_number,))
|
||||
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
"""
|
||||
else:
|
||||
#newSheet.write(row_idx, invNomerColum, "Нет инв номера")
|
||||
pass
|
||||
newFile.save("Ved31.xls")
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#write2excell()
|
||||
#ranomraspr()
|
||||
#createdb()
|
||||
app.run(debug=True, host='0.0.0.0', port='3800')
|
||||
#write2excell()
|
||||
|
||||
app.run(debug=True, host='0.0.0.0', port='3800')
|
||||
|
||||
@@ -1,101 +1,101 @@
|
||||
function clearTable() {
|
||||
var table = document.getElementById("alldatatable");
|
||||
var rowCount = table.rows.length;
|
||||
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);
|
||||
}
|
||||
// Iterate through each row and remove it
|
||||
for (var i = rowCount - 1; i > 0; i--) {
|
||||
table.deleteRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getAllData(){
|
||||
console.log('12321321')
|
||||
clearTable();
|
||||
function getAllData() {
|
||||
console.log('12321321')
|
||||
clearTable();
|
||||
|
||||
let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0];
|
||||
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);
|
||||
let cell8 = newRow.insertCell(7);
|
||||
let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0];
|
||||
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);
|
||||
let cell8 = newRow.insertCell(7);
|
||||
|
||||
i++;
|
||||
i++;
|
||||
|
||||
cell1.innerText = i;
|
||||
cell2.innerText = item.numberved;
|
||||
cell3.innerText = item.invNumber;
|
||||
cell4.innerText = item.nazvanie;
|
||||
cell5.innerText = item.kolichestvo;
|
||||
cell6.innerText = item.balancenumber;
|
||||
cell7.innerText= item.aud;
|
||||
cell8.innerText = item.raspologenie;
|
||||
cell1.innerText = i;
|
||||
cell2.innerText = item.numberved;
|
||||
cell3.innerText = item.invNumber;
|
||||
cell4.innerText = item.nazvanie;
|
||||
cell5.innerText = item.kolichestvo;
|
||||
cell6.innerText = item.balancenumber;
|
||||
cell7.innerText = item.aud;
|
||||
cell8.innerText = item.raspologenie;
|
||||
|
||||
|
||||
$(newRow).data('itemData', i);
|
||||
$(newRow).data('itemData', i);
|
||||
|
||||
|
||||
$(newRow).on("click", function() {
|
||||
$(newRow).on("click", function () {
|
||||
|
||||
let vednumbertxt = newRow.cells[1].innerText;
|
||||
let invnomertxt = newRow.cells[2].innerText;
|
||||
let nazvanietxt = newRow.cells[3].innerText;
|
||||
let kolvotxt = newRow.cells[4].innerText;
|
||||
let schettxt = newRow.cells[5].innerText;
|
||||
let raspologtxt = newRow.cells[7].innerText;
|
||||
let vednumbertxt = newRow.cells[1].innerText;
|
||||
let invnomertxt = newRow.cells[2].innerText;
|
||||
let nazvanietxt = newRow.cells[3].innerText;
|
||||
let kolvotxt = newRow.cells[4].innerText;
|
||||
let schettxt = newRow.cells[5].innerText;
|
||||
let raspologtxt = newRow.cells[7].innerText;
|
||||
|
||||
|
||||
$('#getmodal').modal('show');
|
||||
$('#getmodal').modal('show');
|
||||
|
||||
|
||||
let vedomost = document.getElementById('modal_vednumber')
|
||||
let invnom = document.getElementById('modal_invnom')
|
||||
let matcen = document.getElementById('modal_matcenn')
|
||||
let kolvo = document.getElementById('modal_kolvo')
|
||||
let balancenumber = document.getElementById('modal_balance')
|
||||
let rasp = document.getElementById('modal_rapolog')
|
||||
let vedomost = document.getElementById('modal_vednumber')
|
||||
let invnom = document.getElementById('modal_invnom')
|
||||
let matcen = document.getElementById('modal_matcenn')
|
||||
let kolvo = document.getElementById('modal_kolvo')
|
||||
let balancenumber = document.getElementById('modal_balance')
|
||||
let rasp = document.getElementById('modal_rapolog')
|
||||
|
||||
invnom.innerText = invnomertxt
|
||||
matcen.innerText = nazvanietxt.substring(0,20)
|
||||
invnom.innerText = invnomertxt
|
||||
matcen.innerText = nazvanietxt.substring(0, 20)
|
||||
|
||||
if (vednumbertxt.length>0){
|
||||
vedomost.value = vednumbertxt;
|
||||
}
|
||||
if (vednumbertxt.length > 0) {
|
||||
vedomost.value = vednumbertxt;
|
||||
}
|
||||
|
||||
if (kolvotxt.length>0){
|
||||
kolvo.value = kolvotxt;
|
||||
}
|
||||
if (kolvotxt.length > 0) {
|
||||
kolvo.value = kolvotxt;
|
||||
}
|
||||
|
||||
if (schettxt.length>0){
|
||||
balancenumber.value = schettxt;
|
||||
}
|
||||
if (schettxt.length > 0) {
|
||||
balancenumber.value = schettxt;
|
||||
}
|
||||
|
||||
if (raspologtxt.length>0){
|
||||
rasp.value = raspologtxt;
|
||||
}
|
||||
if (raspologtxt.length > 0) {
|
||||
rasp.value = raspologtxt;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
getAllData();
|
||||
getAllData();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#modalclose').click(function(){
|
||||
$('#modalclose').click(function () {
|
||||
|
||||
|
||||
let vednumber = document.getElementById('modal_vednumber')
|
||||
@@ -105,7 +105,6 @@ $('#modalclose').click(function(){
|
||||
let rasp = document.getElementById('modal_rapolog')
|
||||
|
||||
|
||||
|
||||
vednumber.value = '';
|
||||
kolvo.value = '';
|
||||
balancenumber.value = '';
|
||||
@@ -114,10 +113,9 @@ $('#modalclose').click(function(){
|
||||
$('#getmodal').modal('hide')
|
||||
|
||||
|
||||
})
|
||||
|
||||
} )
|
||||
|
||||
$('#modalsavetodb').click(function(){
|
||||
$('#modalsavetodb').click(function () {
|
||||
|
||||
let invnom = document.getElementById('modal_invnom')
|
||||
let vednumber = document.getElementById('modal_vednumber')
|
||||
@@ -128,8 +126,6 @@ $('#modalsavetodb').click(function(){
|
||||
let nazv = document.getElementById('modal_nazvanie')
|
||||
|
||||
|
||||
|
||||
|
||||
let changeddata = new Array()
|
||||
|
||||
changeddata[0] = invnom.text;
|
||||
@@ -139,122 +135,148 @@ $('#modalsavetodb').click(function(){
|
||||
changeddata[4] = rasp.value;
|
||||
|
||||
|
||||
let sendData = changeddata.join(',')
|
||||
console.log(sendData)
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: "/addraspved",
|
||||
type: "POST",
|
||||
contentType: "application/json;charset=utf-8",
|
||||
dataType: "json",
|
||||
data: sendData,
|
||||
|
||||
success: function () {
|
||||
$('#getmodal').modal('hide')
|
||||
|
||||
vednumber.value = '';
|
||||
kolvo.value = '';
|
||||
balancenumber.value = '';
|
||||
matcen.value = '';
|
||||
rasp.value = '';
|
||||
changeddata = [];
|
||||
window.location.reload();
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
$('#addoborud').click(function () {
|
||||
|
||||
$('#addmodal').modal('show');
|
||||
|
||||
})
|
||||
|
||||
$('#modal2savetodb').click(function () {
|
||||
|
||||
let invnomer = 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] = invnomer.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({
|
||||
$.ajax({
|
||||
|
||||
url: "/addraspved",
|
||||
type: "POST",
|
||||
contentType: "application/json;charset=utf-8",
|
||||
dataType: "json",
|
||||
data: sendData,
|
||||
url: "/addoborudasu",
|
||||
type: "POST",
|
||||
contentType: "application/json;charset=utf-8",
|
||||
dataType: "json",
|
||||
data: sendData,
|
||||
|
||||
success: function(){
|
||||
$('#getmodal').modal('hide')
|
||||
success: function () {
|
||||
vednumber.value = '';
|
||||
invnomer.value = '';
|
||||
nazvanie.value = '';
|
||||
kolvo.value = '';
|
||||
balancenumber.value = '';
|
||||
matcen.value = '';
|
||||
rasp.value = '';
|
||||
|
||||
vednumber.value = '';
|
||||
kolvo.value = '';
|
||||
balancenumber.value = '';
|
||||
matcen.value = '';
|
||||
rasp.value = '';
|
||||
changeddata = [];
|
||||
window.location.reload();
|
||||
},
|
||||
})
|
||||
$('#addmodal').modal('hide')
|
||||
window.location.reload()
|
||||
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
$('#addoborud').click(function(){
|
||||
|
||||
$('#addmodal').modal('show');
|
||||
|
||||
})
|
||||
|
||||
$('#modal2savetodb').click(function(){
|
||||
|
||||
let invnomer = 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')
|
||||
$('#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')
|
||||
|
||||
|
||||
let changeddata = new Array()
|
||||
vednumber.value = '';
|
||||
invnomer.value = '';
|
||||
nazvanie.value = '';
|
||||
kolvo.value = '';
|
||||
balancenumber.value = '';
|
||||
matcen.value = '';
|
||||
rasp.value = '';
|
||||
|
||||
changeddata[0] = invnomer.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 = '';
|
||||
invnomer.value= '';
|
||||
nazvanie.value='';
|
||||
kolvo.value = '';
|
||||
balancenumber.value = '';
|
||||
matcen.value = '';
|
||||
rasp.value = '';
|
||||
|
||||
$('#addmodal').modal('hide')
|
||||
window.location.reload()
|
||||
|
||||
},
|
||||
|
||||
})
|
||||
$('#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')
|
||||
|
||||
|
||||
|
||||
} )
|
||||
|
||||
$('#modal2').on('hidden.bs.modal', function () {
|
||||
location.reload();
|
||||
})
|
||||
location.reload();
|
||||
})
|
||||
|
||||
$(document).ready(function () {
|
||||
// Слушаем событие клика по заголовкам таблицы
|
||||
$('#alldatatable thead th').on('click', function () {
|
||||
var columnIndex = $(this).index(); // Индекс колонки
|
||||
var sortColumn = $(this).text().toLowerCase(); // Текст заголовка колонки
|
||||
|
||||
// Сортируем таблицу по выбранной колонке
|
||||
$('#alldatatable tbody tr').sort(function (a, b) {
|
||||
var valA;
|
||||
var valB;
|
||||
|
||||
if (isNaN(parseFloat($(a).find('td:eq(' + columnIndex + ')').text()))) {
|
||||
// если это текстовая колонка, то сортируем по алфавиту
|
||||
valA = $(a).find('td:eq(' + columnIndex + ')').text().toLowerCase();
|
||||
valB = $(b).find('td:eq(' + columnIndex + ')').text().toLowerCase();
|
||||
} else {
|
||||
// если это числовая колонка, то сортируем по числовому значению
|
||||
valA = parseFloat($(a).find('td:eq(' + columnIndex + ')').text());
|
||||
valB = parseFloat($(b).find('td:eq(' + columnIndex + ')').text());
|
||||
}
|
||||
|
||||
if (valA < valB) return -1;
|
||||
if (valA > valB) return 1;
|
||||
return 0;
|
||||
}).appendTo('#alldatatable tbody');
|
||||
|
||||
// Обновляем классы для активной колонки
|
||||
$('#alldatatable thead th').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user