|
|
|
@ -607,6 +607,122 @@ function addPackageByAddress(number, unit, street, citystate, zip, type, callbac
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addPackageByBarcode(barcode, type, callback) {
|
|
|
|
|
var requestfinished = false;
|
|
|
|
|
var searchingdialogopen = false;
|
|
|
|
|
var deadline = false;
|
|
|
|
|
|
|
|
|
|
var ajaxlookup = function () {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: SETTINGS.geocodebarcodeapi,
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
data: {
|
|
|
|
|
code: barcode,
|
|
|
|
|
type: SETTINGS.itemtypes[type].allowedlocationtypes
|
|
|
|
|
},
|
|
|
|
|
timeout: 15 * 1000,
|
|
|
|
|
success: function (resp) {
|
|
|
|
|
if (searchingdialogopen) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
searchingdialogopen = false;
|
|
|
|
|
}
|
|
|
|
|
requestfinished = true;
|
|
|
|
|
if (resp.status == "OK") {
|
|
|
|
|
if (resp.accuracy.ok) {
|
|
|
|
|
addPackage(resp.address.street, resp.coords[0], resp.coords[1], type, callback, deadline);
|
|
|
|
|
} else {
|
|
|
|
|
playSound("error");
|
|
|
|
|
app.dialog.alert("The scanned address couldn't be reliably located.", "Error");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
playSound("error");
|
|
|
|
|
app.dialog.alert(resp.message, "Error");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function (jqXHR, status, errorThrown) {
|
|
|
|
|
if (searchingdialogopen) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
searchingdialogopen = false;
|
|
|
|
|
}
|
|
|
|
|
requestfinished = true;
|
|
|
|
|
playSound("error");
|
|
|
|
|
app.dialog.alert("There was a network issue while looking up the barcode. Please try again.", "Error");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Open a loading message if there's a delay finding the address
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
if (!requestfinished) {
|
|
|
|
|
app.dialog.preloader("Looking up barcode...");
|
|
|
|
|
searchingdialogopen = true;
|
|
|
|
|
}
|
|
|
|
|
}, 750);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var prelookup = function () {
|
|
|
|
|
if (type == "express") {
|
|
|
|
|
if (getStorage("deadlinealarm_minutes") == null) {
|
|
|
|
|
setStorage("deadlinealarm_minutes", 20);
|
|
|
|
|
}
|
|
|
|
|
var minutes = getStorage("deadlinealarm_minutes");
|
|
|
|
|
app.dialog.create({
|
|
|
|
|
title: 'Express Item',
|
|
|
|
|
text: 'Set a reminder for ' + minutes + ' minutes before:',
|
|
|
|
|
buttons: [
|
|
|
|
|
{
|
|
|
|
|
text: '10:30 AM',
|
|
|
|
|
close: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: '12:00 PM',
|
|
|
|
|
close: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: '3:00 PM',
|
|
|
|
|
close: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: "No reminder",
|
|
|
|
|
color: "red",
|
|
|
|
|
close: true
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
verticalButtons: true,
|
|
|
|
|
onClick: function (dialog, index) {
|
|
|
|
|
deadline = new Date();
|
|
|
|
|
switch (index) {
|
|
|
|
|
case 0:
|
|
|
|
|
deadline.setMinutes(30);
|
|
|
|
|
deadline.setHours(10);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
deadline.setMinutes(00);
|
|
|
|
|
deadline.setHours(12);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
deadline.setMinutes(00);
|
|
|
|
|
deadline.setHours(12 + 3);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
default:
|
|
|
|
|
deadline = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (deadline != false) {
|
|
|
|
|
deadline = deadline.getTime() / 1000;
|
|
|
|
|
}
|
|
|
|
|
ajaxlookup();
|
|
|
|
|
}
|
|
|
|
|
}).open();
|
|
|
|
|
} else {
|
|
|
|
|
ajaxlookup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prelookup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkDeadlines() {
|
|
|
|
|
if (getStorage("deadlinealarm_minutes") == null) {
|
|
|
|
|
setStorage("deadlinealarm_minutes", 20);
|
|
|
|
|