diff --git a/README.md b/README.md
index 38b6a8e..b9325bf 100644
--- a/README.md
+++ b/README.md
@@ -15,9 +15,9 @@ Instructions:
3. Click the Plus button to create an API key
NOTE: The site was slow for me to make my first API key and I ended up making way too many at once. If you don't see the key right away, try going back to the overview and see if the page loads. You might have to wait a few minutes for the site to catch up with you.
4. Download the ParcelPony release and unzip the files to a folder on your web server
- 4. Copy your API key and paste it into index.php where it asks for the BearerToken
+ 4. Copy your API key and paste it into index.php and outgoing.php files where it asks for the BearerToken
5. (Optional) There's also a page called getjson.php that just pulls the json for a package (for testing). If you want to use this page you will need to paste the API key on that page too.
6. Go to http://localhost/parcelpony and start adding parcels to track
- NOTE: You can enable email notifications on TrackingHive for all parcels you add.
+ NOTE: You can enable email notifications on TrackingHive for all parcels you add, the name of the package in ParcelPony is set to the First Name field on TrackingHive.
diff --git a/android-chrome-192x192.png b/android-chrome-192x192.png
new file mode 100644
index 0000000..6c85da7
Binary files /dev/null and b/android-chrome-192x192.png differ
diff --git a/android-chrome-512x512.png b/android-chrome-512x512.png
new file mode 100644
index 0000000..b6b9568
Binary files /dev/null and b/android-chrome-512x512.png differ
diff --git a/apple-touch-icon.png b/apple-touch-icon.png
new file mode 100644
index 0000000..53ddfb8
Binary files /dev/null and b/apple-touch-icon.png differ
diff --git a/favicon-16x16.png b/favicon-16x16.png
new file mode 100644
index 0000000..b067ea2
Binary files /dev/null and b/favicon-16x16.png differ
diff --git a/favicon-32x32.png b/favicon-32x32.png
new file mode 100644
index 0000000..5551849
Binary files /dev/null and b/favicon-32x32.png differ
diff --git a/favicon.ico b/favicon.ico
new file mode 100644
index 0000000..c309807
Binary files /dev/null and b/favicon.ico differ
diff --git a/getjson.php b/getjson.php
index a8b0c6c..ee78f63 100644
--- a/getjson.php
+++ b/getjson.php
@@ -1,6 +1,5 @@
-r formatting json data
- echo pretty_print($data);
+
+ //print unfiltered json
+ print_r($data);
}
}
diff --git a/index.php b/index.php
index 2b1c423..6acbeec 100644
--- a/index.php
+++ b/index.php
@@ -3,11 +3,18 @@
+
+
+
+
+
+
+
+
diff --git a/outgoing.php b/outgoing.php
new file mode 100644
index 0000000..cac75c6
--- /dev/null
+++ b/outgoing.php
@@ -0,0 +1,563 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
ParcelPony [Outgoing]
+
+
+
+";
+$alertMessage = "";
+
+$comment = "No title";
+
+$now = new DateTime();
+$todayTS = date_timestamp_get($now);
+$today = $now->format('m/d/Y');
+
+
+//----- Functions -----//
+
+
+
+//-- PHP Stuff --//
+
+set_error_handler('exceptions_error_handler');
+
+function exceptions_error_handler($severity, $message, $filename, $lineno) {
+ if (error_reporting() == 0) {
+ return;
+ }
+ if (error_reporting() & $severity) {
+ throw new ErrorException($message, 0, $severity, $filename, $lineno);
+ }
+}
+
+function deleteParcel($_id, $bearerToken){
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL, "https://api.trackinghive.com/trackings/". $_id);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
+
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
+
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+ "Content-Type: application/json",
+ "Authorization: Bearer " . $bearerToken
+ ));
+
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+ //var_dump($response);
+
+ $json = json_decode($response, true);
+ if ($json['meta']['code'] == 200) {
+ //echo '
Package removed! ';
+ $alertMessage = "Removed";
+ //echo $alertMessage;
+ }
+
+ return $alertMessage;
+}
+
+function addSubscription ($_id, $bearerToken) {
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL, "https://api.trackinghive.com/webhook/subscription");
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
+
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
+
+ curl_setopt($ch, CURLOPT_POSTFIELDS, "{
+ \"endpoint_url\": \"https://belowland.com\",
+ \"notify_if_inactive\": true,
+ \"email_alerts\": [
+ \"rory54@gmail.com\"
+ ],
+ \"active\": true,
+ \"id\": \"" . $_id . "\"
+ }");
+
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+ "Content-Type: application/json",
+ "Authorization: Bearer " . $bearerToken
+ ));
+
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+ var_dump($response);
+}
+
+//----- Check for _POST variables -----//
+
+/* Check if a parcel was deleted */
+if(isset($_POST['action']) && isset($_POST['id'])) {
+ if ($_POST['action'] == 'Delete') {
+ $alertMessage = deleteParcel($_POST['id'], $bearerToken);
+ }
+}
+
+/* Check if a parcel was added on page load */
+if (isset($_POST["submit"]) && isset($_POST["tracking"])){
+ if ($_POST["submit"] == "Add") {
+ $trackingNum = trim($_POST["tracking"], " ");
+ $carrier = $_POST["carrier"];
+ $comment = $_POST["comment"];
+
+ //echo $_POST['action'];
+
+
+ //----begin trackhive code to add a parcel to your account
+ try {
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL, "https://api.trackinghive.com/trackings");
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
+
+ curl_setopt($ch, CURLOPT_POST, TRUE);
+
+ curl_setopt($ch, CURLOPT_POSTFIELDS, "{
+ \"tracking_number\": \"" . $trackingNum . "\",
+ \"slug\": \"" . $carrier . "\",
+ \"customer_name\": \"" . $comment . "\",
+ \"custom_fields\": \"direction:outgoing\"
+ }");
+
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+ "Content-Type: application/json",
+ "Authorization: Bearer " . $bearerToken
+ ));
+
+ $response = curl_exec($ch);
+
+ // Check the return value of curl_exec(), too
+ if ($response === false) {
+ throw new Exception(curl_error($ch), curl_errno($ch));
+ }
+
+ curl_close($ch);
+ } catch (Exception $e) {
+ trigger_error(sprintf('Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), E_USER_ERROR);
+ }
+
+ //var_dump($response);
+
+ //----end trackhive code to add a parcel to your account
+
+ $json = json_decode($response, false);
+
+ //print_r($json);
+
+ if ($json->meta->code == 200) {
+ $_id = $json->data->_id;
+
+ //echo '
Package added! ';
+ $alertMessage = "Added";
+ //echo $alertMessage;
+ //addSubscription($_id, $bearerToken);
+ } else if ($json->meta->code == 400) {
+ echo '
Could not add package. ';
+ } else {
+ echo '
Could not add package. ';
+ }
+
+
+ }
+}
+
+?>
+
+
+
+
+
+ Package added!
+
+
+
+
+ Package removed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Date
+ Title
+ Last Update
+ Actions
+
+ {'data'});
+
+ $direction = "";
+
+ try {
+ foreach ($json->data as $mydata) {
+ $custom_fields = explode(':', $mydata->custom_fields);
+ if ($custom_fields[1] == "outgoing") {
+ $direction = $custom_fields[1];
+ $comment = $mydata->customer_name;
+ $infoStatus = $mydata->current_status;
+ $parcelID = $mydata->_id;
+ $carrier_slug = $mydata->slug;
+ $scheduled = false;
+ } else {
+ $direction = "incoming";
+
+ }
+
+
+ //echo $json->meta->code . " ";
+ if ($direction == "outgoing") {
+ if ($mydata->trackings->expected_delivery != null){
+ $expTS = $mydata->trackings->expected_delivery;
+ $expDelivery = date("m/d/Y", strtotime($expTS));
+
+ if ($expDelivery == $today){
+ $expectedDelivery = "Expected Delivery Today";
+ }
+ else {
+ $expectedDelivery = "Expected Delivery is " . date("l, m/d/y", strtotime($expTS));
+ }
+
+ $scheduled = true;
+ } else {
+ if ($mydata->trackings->tag == "Delivered") {
+ $shipTS = $mydata->trackings->shipment_delivery_date;
+ $shipmentDelivery = date("m/d/Y", strtotime($shipTS));
+
+ $shipSecsAgo = $todayTS - strtotime($shipTS);
+ $shipDaysAgo = $shipSecsAgo / 86400;
+
+ if ($shipmentDelivery == $today) {
+ $expectedDelivery = "Today";
+ } else {
+ $expectedDelivery = "About " . ceil($shipDaysAgo) . " Days Ago";
+ }
+ } else {
+ //echo "no update in " . $mydata->trackings->delivery_time . " days";
+ $expectedDelivery = "Last updated about " . $mydata->trackings->delivery_time . " days ago";
+ }
+ }
+
+ if ($scheduled == false){
+ //echo "checkpoints = ". count($mydata->trackings->checkpoints);
+ if (count($mydata->trackings->checkpoints) > 0) {
+ if (end($mydata->trackings->checkpoints)->checkpoint_time) {
+ $timestamp = end($mydata->trackings->checkpoints)->checkpoint_time;
+ $tsMonth = date("F", strtotime($timestamp));
+ $tsDay = date("j", strtotime($timestamp));
+ $tsTime = date("H:i:s", strtotime($timestamp));
+ }
+ else {
+ $tsMonth = "NULL";
+ $tsDay = "NULL";
+ $tsTime = "NULL";
+ }
+ } else {
+ $timestamp = $mydata->created;
+ $tsMonth = date("F", strtotime($timestamp));
+ $tsDay = date("j", strtotime($timestamp));
+ $tsTime = date("H:i:s", strtotime($timestamp));
+ }
+ } else {
+ $tsMonth = date("F", strtotime($expTS));
+ $tsDay = date("j", strtotime($expTS));
+ $tsTime = "Scheduled";
+ }
+
+ if (count($mydata->trackings->checkpoints) > 0) {
+ if (end($mydata->trackings->checkpoints)->location) {
+ $lastLoc = end($mydata->trackings->checkpoints)->location;
+ } else {
+ $lastLoc = "N/A";
+ }
+ } else {
+ $lastLoc = "N/A";
+ }
+
+ if (count($mydata->trackings->checkpoints) > 0) {
+ if (end($mydata->trackings->checkpoints)->message) {
+ $infoMore = end($mydata->trackings->checkpoints)->message;
+ } else {
+ $infoMore = "N/A";
+ }
+ } else {
+ $infoMore = "N/A";
+ }
+
+ foreach ($carrier_json->data as $carriers){
+ if ($carrier_slug == $carriers->slug){
+ $carrier = $carriers->title;
+ }
+ }
+
+ $trackingNum = $mydata->tracking_number;
+
+ $modTS = $mydata->modified;
+ $modTime = strtotime($modTS);
+ $nowTS = $now->getTimestamp();
+ $modifiedTime = "About " . date('g', $nowTS - $modTime) . " hours ago";
+ //echo "About " . date('g', $nowTS - $modTime) . " hours ago";
+
+ ?>
+
+
+
+
+
+
+ track
+
+
+
+
+
+ N/A
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {'data'}) == 1){
+ echo "Error getting parcels. There was a problem connecting to TrackingHive. Please try again in a few minutes.";
+ } else {
+ echo "Error getting parcels. There might be a problem connecting to TrackingHive or you haven't specified your API Token. Exception: " . $e;
+ }
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/site.webmanifest b/site.webmanifest
new file mode 100644
index 0000000..2e3f79b
--- /dev/null
+++ b/site.webmanifest
@@ -0,0 +1,20 @@
+{
+ "name":"ParcelPony",
+ "short_name":"ParcelPony",
+ "icons":[
+ {
+ "src":"android-chrome-192x192.png",
+ "sizes":"192x192",
+ "type":"image/png"
+ },
+ {
+ "src":"android-chrome-512x512.png",
+ "sizes":"512x512",
+ "type":"image/png"
+ }
+ ],
+ "theme_color":"#94b5eb",
+ "background_color":"#94b5eb",
+ "display":"browser",
+ "start_url": "index.php"
+}
\ No newline at end of file
diff --git a/styles.css b/styles.css
index 8a96125..c582b8a 100644
--- a/styles.css
+++ b/styles.css
@@ -16,6 +16,10 @@ a {
text-decoration: none;
}
+td {
+ border: 1px solid black;
+}
+
.hidden-ux {
visibility: hidden;
}
@@ -98,6 +102,10 @@ a {
text-align: center;
}
+.nav {
+ text-align: center;
+}
+
.tracking {
padding: 20px 0 0 10px;
}
@@ -106,6 +114,17 @@ a {
padding: 10px;
}
+.parcel-header {
+ padding-top: 10px;
+ padding-bottom: 15px;
+ min-height: 170px;
+ box-sizing: border-box;
+}
+
+.parcel-table {
+
+}
+
.parcel-item {
padding-top: 10px;
padding-bottom: 15px;
@@ -137,7 +156,6 @@ a {
position: relative;
min-height: 1px;
box-sizing: border-box;
- cursor: pointer;
}
.media-right {
@@ -211,13 +229,14 @@ input[type=button], input[type=submit] {
display: table-cell;
vertical-align: top;
box-sizing: border-box;
-
overflow: hidden;
+ width: 100%;
+ cursor: pointer;
}
/*Date Time*/
.datetime-info {
- width: 75px;
+ width: 100px;
text-align: center;
margin-top: 5px;
box-sizing: border-box;
@@ -319,6 +338,7 @@ input[type=button], input[type=submit] {
text-transform: uppercase;
border: 1px solid #888 !important;
color: #666 !important;
+ width: max-content;
}
.info-more {
@@ -625,7 +645,7 @@ a {
/*Date Time*/
.datetime-info {
- width: 60px;
+ width: 80px;
text-align: center;
margin-top: 0px;
box-sizing: border-box;