Add paid redelivery of USPS packages (Pick Up and Redeliver)

This commit is contained in:
Skylar Ittner 2021-02-06 03:37:23 -07:00
parent 07d60da69c
commit 579a4d2032
20 changed files with 760 additions and 70 deletions

View File

@ -1066,6 +1066,32 @@ THE SOFTWARE.
-----
The following software may be included in this product: signature_pad. A copy of the source code may be downloaded from https://github.com/szimek/signature_pad.git. This software contains the following license and notice below:
MIT License
Copyright (c) 2018 Szymon Nowak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----
The following software may be included in this product: ssr-window. A copy of the source code may be downloaded from git+https://github.com/nolimits4web/ssr-window.git. This software contains the following license and notice below:
MIT License
@ -3494,6 +3520,32 @@ The Apache Software Foundation (http://www.apache.org/).
-----
The following software may be included in this product: cordova-plugin-document-scanner. A copy of the source code may be downloaded from https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner. This software contains the following license and notice below:
MIT License
Copyright (c) 2018 NeutrinosPlatform
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----
The following software may be included in this product: cordova-plugin-nativestorage. A copy of the source code may be downloaded from https://github.com/TheCocoaProject/cordova-plugin-nativestorage. This software contains the following license and notice below:
Apache License
@ -5701,6 +5753,32 @@ THE SOFTWARE.
-----
The following software may be included in this product: recursive-readdir. A copy of the source code may be downloaded from git://github.com/jergason/recursive-readdir.git. This software contains the following license and notice below:
The MIT License (MIT)
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----
The following software may be included in this product: reusify. A copy of the source code may be downloaded from git+https://github.com/mcollina/reusify.git. This software contains the following license and notice below:
The MIT License (MIT)

108
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "com.netsyms.helenaexpress.app",
"version": "1.0.1",
"version": "1.1.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -326,69 +326,28 @@
"which": "^2.0.1"
}
},
"endent": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/endent/-/endent-1.4.1.tgz",
"integrity": "sha512-buHTb5c8AC9NshtP6dgmNLYkiT+olskbq1z6cEGvfGCF3Qphbu/1zz5Xu+yjTDln8RbxNhPoUyJ5H8MSrp1olQ==",
"dev": true,
"requires": {
"dedent": "^0.7.0",
"fast-json-parse": "^1.0.3",
"objectorarray": "^1.0.4"
}
},
"fs-extra": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz",
"integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==",
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
"dev": true,
"requires": {
"at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^1.0.0"
}
},
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
"universalify": "^2.0.0"
}
},
"jsonfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz",
"integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==",
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6",
"universalify": "^1.0.0"
"universalify": "^2.0.0"
}
},
"nopt": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz",
"integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==",
"dev": true,
"requires": {
"abbrev": "1",
"osenv": "^0.1.4"
}
},
"objectorarray": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/objectorarray/-/objectorarray-1.0.4.tgz",
"integrity": "sha512-91k8bjcldstRz1bG6zJo8lWD7c6QXcB4nTDUqiEvIL1xAsLoZlOOZZG+nd6YPz+V7zY1580J4Xxh1vZtyv4i/w==",
"dev": true
},
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
@ -416,16 +375,10 @@
"integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==",
"dev": true
},
"underscore": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.11.0.tgz",
"integrity": "sha512-xY96SsN3NA461qIRKZ/+qox37YXPtSBswMGfiNptr+wrt6ds4HaMw23TP612fEyGekRE6LNRiLYr/aqbHXNedw==",
"dev": true
},
"universalify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz",
"integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
"dev": true
},
"which": {
@ -642,11 +595,33 @@
}
}
},
"cordova-plugin-androidx": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-androidx/-/cordova-plugin-androidx-3.0.0.tgz",
"integrity": "sha512-niMnhcxKsu4/oKTUbL0jRAnh6/cdoIVxRxJqj3uEyv8CVOlAj1sWhX+9b1XiAo9+bejAM9BbA21YK0mChfbVTA==",
"dev": true
},
"cordova-plugin-androidx-adapter": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-androidx-adapter/-/cordova-plugin-androidx-adapter-1.1.3.tgz",
"integrity": "sha512-W1SImn0cCCvOSTSfWWp5TnanIQrSuh2Bch+dcZXIzEn0km3Qb7VryeAqHhgBQYwwzC5Ollk1DtUAk/AJSojuZA==",
"dev": true,
"requires": {
"q": "^1.5.1",
"recursive-readdir": "^2.2.2"
}
},
"cordova-plugin-device": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.3.tgz",
"integrity": "sha1-wrQbfv0EVd0Jf4k1bYW/3V2t6w8="
},
"cordova-plugin-document-scanner": {
"version": "5.0.0-beta.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-document-scanner/-/cordova-plugin-document-scanner-5.0.0-beta.0.tgz",
"integrity": "sha512-ydBWR06fwAIKah3HQbp+ZwfCsVReebGpBVBKM53ff46rplW4WNK9pLubg02qRmByUdNwalSVZ0ugns8pGhlwRg==",
"dev": true
},
"cordova-plugin-headercolor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-headercolor/-/cordova-plugin-headercolor-1.0.0.tgz",
@ -786,9 +761,9 @@
"dev": true
},
"execa": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/execa/-/execa-4.0.3.tgz",
"integrity": "sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz",
"integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==",
"dev": true,
"requires": {
"cross-spawn": "^7.0.0",
@ -1492,6 +1467,15 @@
"with-open-file": "^0.1.6"
}
},
"recursive-readdir": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
"integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==",
"dev": true,
"requires": {
"minimatch": "3.0.4"
}
},
"reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",

View File

@ -27,12 +27,18 @@
"cordova-plugin-statusbar": {},
"cordova-plugin-headercolor": {},
"cordova-plugin-theme-detection": {},
"cordova-plugin-nativestorage": {}
"cordova-plugin-nativestorage": {},
"cordova-plugin-document-scanner": {
"CAMERA_USAGE_DESCRIPTION": "This app needs camera access",
"PHOTOLIBRARY_USAGE_DESCRIPTION": "This app needs read/write-access photo library access"
},
"cordova-plugin-androidx": {},
"cordova-plugin-androidx-adapter": {}
},
"platforms": [
"android",
"browser",
"ios"
"ios",
"android"
]
},
"dependencies": {
@ -47,6 +53,9 @@
"cordova-browser": "^6.0.0",
"cordova-ios": "^6.1.1",
"cordova-plugin-add-swift-support": "^2.0.2",
"cordova-plugin-androidx": "^3.0.0",
"cordova-plugin-androidx-adapter": "^1.1.3",
"cordova-plugin-document-scanner": "^5.0.0-beta.0",
"cordova-plugin-nativestorage": "^2.3.2"
}
}

View File

@ -75,4 +75,11 @@ find dist -type f -not -name 'mapbox-gl.css' -not -name 'mapbox-gl.js' -delete
rm -rf dist/style-spec
cd $DIR
cd signature_pad
rm -rf {docs,src}
rm README.md
rm -rf dist/types
find dist -type f -not -name 'signature_pad.umd.min.js' -delete
cd $DIR
echo "Cleanup finished"

View File

@ -126,4 +126,46 @@ Framework7 and FontAwesome both have a .fab class
.clicktext {
display: initial;
}
}
.signature-wrapper {
background-color: white;
border-radius: 10px;
position: relative;
width: 400px;
max-width: 100%;
height: 200px;
margin: 0 auto;
border: 1px solid rgba(0,0,0,0.5);
}
.signature-wrapper img {
position: absolute;
bottom: 0;
left: 0;
}
.signature-wrapper canvas {
position: absolute;
left: 0;
top: 0;
width: 400px;
max-width: 95vw;
height: 200px;
}
.signature-wrapper #signatureClearBtn {
display: block;
position: absolute;
right: 0;
top: 0;
padding: 10px;
}
.signature-wrapper #signatureUndoBtn {
display: block;
position: absolute;
right: 40px;
top: 0;
padding: 10px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="400"
height="200"
viewBox="0 0 105.83333 52.916669"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="signature-line.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="-82.70874"
inkscape:cy="65.096693"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
fit-margin-top="50"
fit-margin-left="30"
fit-margin-right="30"
fit-margin-bottom="50"
inkscape:window-width="1920"
inkscape:window-height="1015"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-25.421766,-74.750004)">
<g
aria-label="X"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:100%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;letter-spacing:3.34962487px;word-spacing:0px;fill:#000000;fill-opacity:0.39303482;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="text817"
transform="matrix(4.2854051,0,0,4.2854051,-189.27268,-367.87464)">
<path
d="m 53.529892,112.54762 q -0.0635,-0.127 -0.1524,-0.2794 -0.0889,-0.15663 -0.194734,-0.32173 -0.105833,-0.16933 -0.220133,-0.33443 -0.1143,-0.16934 -0.220133,-0.3175 -0.105834,0.14816 -0.220134,0.3175 -0.1143,0.1651 -0.220133,0.33443 -0.1016,0.1651 -0.194733,0.32173 -0.0889,0.1524 -0.1524,0.2794 h -0.452967 q 0.1905,-0.37253 0.440267,-0.75776 0.254,-0.38524 0.537633,-0.79164 l -0.9398,-1.3843 h 0.474133 l 0.7239,1.0922 0.715434,-1.0922 h 0.4699 l -0.922867,1.36737 q 0.287867,0.41063 0.541867,0.8001 0.254,0.38947 0.448733,0.76623 z"
style="stroke-width:0.26458332px;fill:#000000;fill-opacity:0.39303482"
id="path819"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

228
www/assets/js/noticeslip.js Normal file
View File

@ -0,0 +1,228 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var signaturePad = null;
var frontSlipImg = null;
var backSlipImg = null;
function initSignaturePad() {
var canvas = document.getElementById("signaturecanvas");
resizeCanvas(canvas);
signaturePad = new SignaturePad(canvas, {
backgroundColor: 'rgba(255, 255, 255, 0.5)'
});
}
function resizeCanvas(canvas) {
var ratio = Math.max(window.devicePixelRatio || 1, 1);
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
if (signaturePad != null) {
signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
}
function initNoticeSlipForm() {
initSignaturePad();
$("#noticeform #name").attr("placeholder", ["John Doe", "Jane Doe", "Dave S. Nothereman", "Sara N. Ignatur"].random());
$("#noticeform #zip").attr("placeholder", ["59601", "59602"].random());
$.getScript("https://js.stripe.com/v3");
}
function takeDocPhoto(side) {
try {
scan.scanDoc(function (img) {
if (side == "front") {
frontSlipImg = "data:image/jpg;base64," + img;
$("#noticefrontimg").attr("src", frontSlipImg);
} else if (side == "back") {
backSlipImg = "data:image/jpg;base64," + img;
$("#noticebackimg").attr("src", backSlipImg);
}
}, function (err) {
}, {
sourceType: 1,
quality: 3,
returnBase64: true
});
} catch (ex) {
app.dialog.alert("Looks like you can't do that with this device.", "Whoops!");
}
}
function checkNoticeSlipForm() {
// make sure everything's filled out
if ($("#noticeform #name").val().length < 5) {
return "Please type your name where provided.";
}
if ($("#noticeform #street").val().length < 5) {
return "Please type your street address (i.e. 1234 Example Rd, Apt 5).";
}
if ($("#noticeform #zip").val().length < 5) {
return "Please type your ZIP Code.";
}
if (signaturePad.isEmpty()) {
return "Please sign with a finger or stylus in the box provided.";
}
if ($("#noticesignform #signature").val().length < 5) {
return "Please type your full name below your signature.";
}
if (frontSlipImg == null) {
return "Take a picture of the front side of your notice slip.";
}
if (backSlipImg == null) {
return "Take a picture of the signed back side of your notice slip.";
}
return true;
}
function getPrice() {
var precheckResult = checkNoticeSlipForm();
if (precheckResult === true) {
app.dialog.preloader("Loading...");
apirequest(SETTINGS.apis.pickuprequest, {
action: "rate",
street: $("#noticeform #street").val(),
zip: $("#noticeform #zip").val()
}, function (resp) {
app.dialog.close();
if (resp.status == "OK") {
// set display text so customer knows what they're paying
$("#noticeslip-pay-amount").text(resp.rate);
// initialize Stripe.js
initStripe();
// open payment popup
app.popup.create({el: document.getElementById("noticeslip-pay-popup")}).open();
} else if (resp.status == "ERROR") {
app.dialog.alert(resp.message, "Error");
} else {
app.dialog.alert("There was a server problem. Try again later.", "Error");
}
}, function (xhr) {
app.dialog.close();
try {
var error = $.parseJSON(xhr.responseText);
if (error && typeof error.msg != 'undefined') {
app.dialog.alert(error.msg, "Error");
} else {
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
}
} catch (ex) {
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
}
}, "GET");
} else if (typeof precheckResult == "string") {
app.dialog.alert(precheckResult, "Whoops!");
} else {
app.dialog.alert("Check that the form is filled out correctly.", "Whoops!");
}
}
function initStripe() {
// Wait for Stripe to be loaded
if (typeof Stripe == 'undefined') {
setTimeout(initStripe, 500);
return;
}
stripe = Stripe(SETTINGS["stripe_pubkey"]);
elements = stripe.elements();
card = elements.create('card', {});
// stop console warning "This Element will be mounted to a DOM element that contains child nodes."
$("#noticeslip-stripe-elements").html("");
card.mount('#noticeslip-stripe-elements');
card.addEventListener('change', function (event) {
var displayError = document.getElementById('noticeslip-card-errors');
if (event.error) {
displayError.textContent = event.error.message;
} else {
displayError.textContent = '';
}
});
}
function noticeSlipPayAndFinish() {
getPrice();
}
function submitNoticeSlip() {
app.preloader.show();
stripe.createPaymentMethod({type: 'card', card: card}).then(function (result) {
if (result.error) {
// Inform the customer that there was an error.
app.preloader.hide();
var errorElement = document.getElementById('noticeslip-card-errors');
errorElement.textContent = result.error.message;
} else {
apirequest(SETTINGS.apis.pickuprequest, {
action: "submit",
name: $("#noticeform #name").val(),
street: $("#noticeform #street").val(),
zip: $("#noticeform #zip").val(),
front: frontSlipImg,
back: backSlipImg,
signature: signaturePad.toDataURL(),
signatureName: $("#noticesignform #signature").val(),
amount: $("#noticeslip-pay-amount").text(),
stripeid: result.paymentMethod.id
}, function (resp) {
app.preloader.hide();
if (resp.status == "OK") {
app.popup.close();
router.navigate("/noticeslip/success");
} else if (resp.status == "ERROR") {
app.dialog.alert(resp.message, "Error");
} else {
app.dialog.alert("There was a server problem. Try again later.", "Error");
}
}, function (xhr) {
app.preloader.hide();
app.popup.close();
try {
var error = $.parseJSON(xhr.responseText);
if (error && typeof error.msg != 'undefined') {
app.dialog.alert(error.msg, "Error");
} else {
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
}
} catch (ex) {
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
}
}, "POST");
}
});
}
$("#app").on("click", "#signatureClearBtn", function () {
//signaturePad.clear();
// clear the signature pad and fix it if it's wrong
resizeCanvas(document.getElementById("signaturecanvas"));
});
$("#app").on("click", "#signatureUndoBtn", function () {
var data = signaturePad.toData();
if (data) {
data.pop(); // remove the last dot or line
signaturePad.fromData(data);
}
});
//$(window).on("resize", function () {
// if (signaturePad != null) {
// resizeCanvas(document.getElementById("signaturecanvas"));
// }
//});

View File

@ -4,6 +4,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// add random() function to arrays that returns a random element
// credit: https://stackoverflow.com/a/24137301
Array.prototype.random = function () {
return this[Math.floor((Math.random()*this.length))];
}
/**
* Generate a UUID.
* From https://stackoverflow.com/a/2117523

View File

@ -38,6 +38,7 @@
<script src="node_modules/jsbarcode/dist/JsBarcode.all.min.js"></script>
<script src="node_modules/bwip-js/dist/bwip-js-min.js"></script>
<script src="node_modules/maplibre-gl/dist/mapbox-gl.js"></script>
<script src="node_modules/signature_pad/dist/signature_pad.umd.min.js"></script>
<script src="settings.js"></script>
@ -51,6 +52,7 @@
<script src="assets/js/track.js"></script>
<script src="assets/js/addresscode.js"></script>
<script src="assets/js/rates.js"></script>
<script src="assets/js/noticeslip.js"></script>
<script src="routes.js"></script>
<script src="assets/js/main.js"></script>

7
www/package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "HelenaExpressApp",
"version": "1.0.1",
"version": "1.1.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -262,6 +262,11 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"signature_pad": {
"version": "3.0.0-beta.4",
"resolved": "https://registry.npmjs.org/signature_pad/-/signature_pad-3.0.0-beta.4.tgz",
"integrity": "sha512-cOf2NhVuTiuNqe2X/ycEmizvCDXk0DoemhsEpnkcGnA4kS5iJYTCqZ9As7tFBbsch45Q1EdX61833+6sjJ8rrw=="
},
"ssr-window": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-1.0.1.tgz",

View File

@ -11,7 +11,8 @@
"jquery": "^3.5.1",
"jsbarcode": "^3.11.0",
"maplibre-gl": "^1.13.0-rc.4",
"material-design-icons": "^3.0.1"
"material-design-icons": "^3.0.1",
"signature_pad": "^3.0.0-beta.4"
},
"devDependencies": {}
}

View File

@ -50,7 +50,7 @@
</div>
</div>
<div class="popup" id="addresscode-popup">
<div class="popup text-color-black" id="addresscode-popup">
<div class="block text-align-center">
<img id="addresscode-barcode" style="max-width: 90%;" />
<p>Present this code to the Helena Express agent.</p>

View File

@ -1096,6 +1096,32 @@ THE SOFTWARE.
-----
The following software may be included in this product: signature_pad. A copy of the source code may be downloaded from https://github.com/szimek/signature_pad.git. This software contains the following license and notice below:
MIT License
Copyright (c) 2018 Szymon Nowak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----
The following software may be included in this product: ssr-window. A copy of the source code may be downloaded from git+https://github.com/nolimits4web/ssr-window.git. This software contains the following license and notice below:
MIT License
@ -3524,6 +3550,32 @@ The Apache Software Foundation (http://www.apache.org/).
-----
The following software may be included in this product: cordova-plugin-document-scanner. A copy of the source code may be downloaded from https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner. This software contains the following license and notice below:
MIT License
Copyright (c) 2018 NeutrinosPlatform
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----
The following software may be included in this product: cordova-plugin-nativestorage. A copy of the source code may be downloaded from https://github.com/TheCocoaProject/cordova-plugin-nativestorage. This software contains the following license and notice below:
Apache License
@ -5731,6 +5783,32 @@ THE SOFTWARE.
-----
The following software may be included in this product: recursive-readdir. A copy of the source code may be downloaded from git://github.com/jergason/recursive-readdir.git. This software contains the following license and notice below:
The MIT License (MIT)
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----
The following software may be included in this product: reusify. A copy of the source code may be downloaded from git+https://github.com/mcollina/reusify.git. This software contains the following license and notice below:
The MIT License (MIT)

View File

@ -21,7 +21,7 @@
<div class="col-100 medium-90 xlarge-75 margin-horizontal">
<div class="row">
{{#each pages}}
<div class="col-100 small-33 large-33 margin-vertical-half">
<div class="col-50 small-50 large-25 margin-vertical-half">
<div class="card" onclick="router.navigate('{{href}}');">
<div class="card-content text-align-center padding-vertical">
<h1 class="no-margin"><i class="{{icon}}"></i></h1>

120
www/pages/noticeslip.html Normal file
View File

@ -0,0 +1,120 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<div class="page" data-name="noticeslip">
<div class="navbar">
<div class="navbar-bg"></div>
<div class="navbar-inner">
<div class="left">
<a class="link back" href="#">
<i class="icon icon-back"></i>
<span class="if-not-md">Back</span>
</a>
</div>
<div class="title">Pick Up and Redeliver</div>
</div>
</div>
<div class="page-content">
<div class="row justify-content-center">
<div class="col-100 medium-90 xlarge-75 margin-horizontal">
<div class="card margin">
<div class="card-content text-align-center">
<div class="block padding-top">
Missed a delivery? For a fee, we'll pick up your oversized package or signature-required item from the Helena Post Office and deliver it to your front door, even if nobody's home.
You just need to fill out this form, sign the back of the pink notice slip, and take a picture of it with this app. Information provided must match the information on the notice slip.
Your item will be delivered within one business day of submitting a request, excluding postal holidays. This service is not available for Restricted Delivery or Registered Mail.
</div>
<div class="list" id="noticeform">
<ul>
<li class="item-content item-input item-input-outline">
<div class="item-inner">
<div class="item-title item-floating-label">Recipient Name</div>
<div class="item-input-wrap">
<input type="text" id="name" placeholder="Jon Doe" />
<span class="input-clear-button"></span>
</div>
</div>
</li>
<li class="item-content item-input item-input-outline">
<div class="item-inner">
<div class="item-title item-floating-label">Street Address</div>
<div class="item-input-wrap">
<input type="text" id="street" placeholder="1234 Example Rd, Apt 1A" />
<span class="input-clear-button"></span>
</div>
</div>
</li>
<li class="item-content item-input item-input-outline">
<div class="item-inner">
<div class="item-title item-floating-label">ZIP Code</div>
<div class="item-input-wrap">
<input type="text" id="zip" placeholder="59602" />
<span class="input-clear-button"></span>
</div>
</div>
</li>
</ul>
</div>
<div class="block">
Press the buttons to take a photo of the front and back of your signed notice slip. You'll be able to adjust the photo to ensure the image is clear.
<div class="row" style="min-height: 100px;">
<div class="col-50">
<div class="button button-outline margin" onclick="takeDocPhoto('front')"><i class="fas fa-camera"></i> Front</div>
<img src="assets/images/3849_front.png" id="noticefrontimg" style="max-width: 100%; max-height: 50vh;" />
</div>
<div class="col-50">
<div class="button button-outline margin" onclick="takeDocPhoto('back')"><i class="fas fa-camera"></i> Back</div>
<img src="assets/images/3849_back.png" id="noticebackimg" style="max-width: 100%; max-height: 50vh;" />
</div>
</div>
</div>
<div class="block margin-vertical">
By signing below, you authorize a Helena Express agent to sign for and take possession of your item from the Helena Post Office and to deliver it to the address entered above.
</div>
<div class="signature-wrapper">
<img src="assets/images/signature-line.svg" />
<canvas id="signaturecanvas"></canvas>
<i class="fas fa-undo text-color-blue" id="signatureUndoBtn"></i>
<i class="fas fa-trash text-color-red" id="signatureClearBtn"></i>
</div>
<div class="list" id="noticesignform">
<ul>
<li class="item-content item-input item-input-outline">
<div class="item-inner">
<div class="item-title item-floating-label">Your Name</div>
<div class="item-input-wrap">
<input type="text" id="signature" />
<span class="input-clear-button"></span>
</div>
</div>
</li>
</ul>
</div>
<div class="card-content-padding">
<div class="button" onclick="noticeSlipPayAndFinish()"><i class="far fa-arrow-right"></i> Finish</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="popup text-color-black" id="noticeslip-pay-popup">
<div class="block text-align-center">
<h2>Finish and pay</h2>
<h3>Total: $<span id="noticeslip-pay-amount"></span></h3>
<div id="noticeslip-stripe-elements">
<i class="fas fa-spin fa-spinner"></i> Loading secure card form...
</div>
<div id="noticeslip-card-errors" style="text-color-red"></div>
<div class="button" onclick="submitNoticeSlip()"><i class="far fa-arrow-right"></i> Pay and Submit</div>
<p><a class="button popup-close" href="#">Cancel</a></p>
</div>
</div>
</div>

View File

@ -0,0 +1,35 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<div class="page" data-name="noticeslipsuccess">
<div class="navbar">
<div class="navbar-bg"></div>
<div class="navbar-inner">
<div class="left">
<a class="link" onclick="router.navigate('/home')">
<i class="icon icon-back"></i>
<span class="if-not-md">Back</span>
</a>
</div>
<div class="title">Pick Up and Redeliver</div>
</div>
</div>
<div class="page-content noselect">
<div class="row justify-content-center margin-top">
<div class="col-100 medium-90 xlarge-75 margin-horizontal">
<div class="card">
<div class="card-content text-align-center padding-vertical">
<h1><i class="fad fa-check-circle fa-4x text-color-green"></i></h1>
<br />
<h2>Request received!</h2>
<p>Your item will be delivered within one business day.</p>
<div class="button" onclick="router.navigate('/home')">Close</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -28,6 +28,11 @@ var routes = [
title: "Get Rates",
href: "/rates",
icon: "fad fa-calculator"
},
{
title: "Pick Up and Redeliver",
href: "/noticeslip",
icon: "fad fa-sticky-note"
}
]
}
@ -79,6 +84,21 @@ var routes = [
name: 'rateresult',
templateUrl: './pages/rateresult.html'
},
{
path: '/noticeslip',
url: './pages/noticeslip.html',
name: 'noticeslip',
on: {
pageAfterIn: function () {
initNoticeSlipForm();
}
}
},
{
path: '/noticeslip/success',
name: 'noticeslipsuccess',
templateUrl: './pages/noticeslipsuccess.html'
},
{
path: '/addresscode',
name: 'addresscode',

View File

@ -7,8 +7,10 @@
var SETTINGS = {
apis: {
track: "https://helena.express/tracker/api.php",
rates: "https://helena.express/rateapi.php"
rates: "https://helena.express/rateapi.php",
pickuprequest: "https://helena.express/pspickup.php"
},
stripe_pubkey: "pk_test_ySIw1bP4fUQtIxMOUOqOCzjK",
appointmenturl: "https://appointments.netsyms.com/index.php?service=19&hlnexp=1&embed=1&only=1",
appointmenturl_darkmode: "https://appointments.netsyms.com/index.php?service=19&hlnexp=1&embed=1&only=1&theme=darkly",
branding: {