Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e21ec9065d | ||
|
|
4988f0eebd | ||
|
|
aca7505ae9 |
+16
-1
@@ -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):
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user