Author SHA1 Message Date
marek e21ec9065d bug fixes 2022-11-29 00:26:48 +01:00
marek 4988f0eebd fixed path added javascript 2022-11-29 00:15:26 +01:00
marek aca7505ae9 added backed of missing part reporting 2022-11-28 22:24:24 +01:00
2 changed files with 42 additions and 1 deletions
+16 -1
View File
@@ -164,7 +164,7 @@ def alterUser(userID):
@app.route(baseURL+'/getpartinfo/<partID>')
def get_part_info(partID):
s = 'select p.id,partno,description,notes, c.name || l.name as location_descriptor, location_id, container_id, datasheet from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;'
s = 'select p.id,partno,description,notes,EXTRACT(EPOCH from now()-reported_missing) as missing_for, c.name || l.name as location_descriptor, location_id, container_id, datasheet from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;'
r = db_engine.execute(text(s), id=partID)
l = []
for row in r:
@@ -316,6 +316,21 @@ def alter(partID):
r.close()
return '{"status":"ok", "part_id" : ' + str(new_id) + '}'
@app.route(baseURL+'/report_missing', methods=['POST'])
def report_missing():
if 'partID' not in request.form:
return '{"status":"fail"}'
partID = request.form['partID']
missing = True if request.form['missing']=='missing' else False #must be "missing" or "found"
if missing:
r = db_engine.execute(text('update parts set reported_missing = now() where id=:id;'), id=partID)
r.close()
return '{"status":"ok"}'
else:
r = db_engine.execute(text('update parts set reported_missing = NULL where id=:id;'), id=partID)
r.close()
return '{"status":"ok"}'
@app.route(baseURL+'/delete/<partID>')
@requires_auth
def delete(partID):
+26
View File
@@ -145,6 +145,32 @@ function save(partID) {
perform_query();
}
function report_missing(partID, missing){
var data = new FormData();
data.append('partID', partID);
if(missing){
missing = 'missing'
}else{
missing = 'found'
}
data.append('missing', missing)
$.ajax({
url: rootURL + 'report_missing',
type: 'POST',
data: data,
cache: false,
contentType: false,
processData: false,
success: function(data) {
alert("Thank you for reporting part as " + missing + ".");
},
error: function() {
alert("Couldn't update the part information. Please retry.");
}
});
}
function text_filter(string) {
if (string != null)
return string;