| 2 |
- |
1 |
<!DOCTYPE html>
|
|
|
2 |
<html lang="en">
|
|
|
3 |
|
|
|
4 |
<head>
|
|
|
5 |
<title>Order Reports</title>
|
|
|
6 |
<meta charset="UTF-8">
|
|
|
7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
8 |
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
|
|
|
9 |
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
|
|
10 |
|
|
|
11 |
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
|
|
12 |
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
|
|
|
13 |
<link rel="stylesheet" href="css/style.css">
|
|
|
14 |
<script src="js/XMLWriter.js"></script>
|
|
|
15 |
<script src="js/lodash.min.js"></script>
|
|
|
16 |
<script src="js/datetimepicker_css.js"></script>
|
|
|
17 |
<script src="js/moment.js"></script>
|
| 12 |
- |
18 |
<script src="js/moment-timezone-with-data-2012-2022.min.js"></script>
|
| 2 |
- |
19 |
<script src="js/muna-tools.js"></script>
|
|
|
20 |
</head>
|
|
|
21 |
|
|
|
22 |
<body onload="return initConfig();">
|
|
|
23 |
<div class="w3-main">
|
|
|
24 |
<div class="w3-container w3-padding w3-margin w3-card-4">
|
|
|
25 |
<div class="w3-container w3-gray" style="height:100px">
|
|
|
26 |
<img class="w3-image" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" style="height:100px">
|
|
|
27 |
<p id="connected" class="w3-xxlarge w3-right">Order Reports
|
|
|
28 |
<input id="login" type="button" class="w3-btn w3-large w3-green w3-margin w3-round-large w3-ripple w3-right w3-hide" onclick="eBayLogin();" value="Login" />
|
|
|
29 |
</p>
|
|
|
30 |
</div>
|
|
|
31 |
|
|
|
32 |
<div class="w3-row">
|
| 7 |
- |
33 |
<form id="searchForm" class="w3-container w3-light-grey w3-padding w3-small" onsubmit="return getOrders();">
|
|
|
34 |
<div class="w3-container w3-card-2 w3-cell w3-padding">
|
|
|
35 |
<h4>Report Range</h4>
|
|
|
36 |
<div class="w3-row">
|
|
|
37 |
<div class="w3-half w3-padding">
|
|
|
38 |
<label for="startDate" class="w3-small">On or After <img src="images2/cal.gif" alt="Calendar Picker" onclick="javascript:NewCssCal('startDate','yyyyMMdd','arrow',false,'24',false,'past')" style="cursor:pointer" /></label>
|
|
|
39 |
<input id="startDate" name="startDate" class="w3-input w3-border-0" style="height:3em" type="text" required>
|
| 2 |
- |
40 |
</div>
|
| 7 |
- |
41 |
<div class="w3-half w3-padding">
|
|
|
42 |
<label for="endDate" class="w3-small">On or Before <img src="images2/cal.gif" alt="Calendar Picker" onclick="javascript:NewCssCal('endDate','yyyyMMdd','arrow',false,'24',false,'past')" style="cursor:pointer" /></label>
|
|
|
43 |
<input id="endDate" name="endDate" class="w3-input w3-border-0" style="height:3em" type="text" required>
|
|
|
44 |
</div>
|
| 2 |
- |
45 |
</div>
|
| 6 |
- |
46 |
</div>
|
| 7 |
- |
47 |
<div class="w3-container w3-card-2 w3-cell w3-padding">
|
|
|
48 |
<p>
|
|
|
49 |
<input id="shippingList" class="w3-radio" type="radio" style="height:1em" name="rptType" value="shippingList" checked>
|
|
|
50 |
<label for="shippingList">Awaiting Shipment</label></p>
|
|
|
51 |
<p>
|
|
|
52 |
<input id="orderList" class="w3-radio" type="radio" style="height:1em" name="rptType" value="orderList">
|
|
|
53 |
<label for="orderList">Orders</label></p>
|
|
|
54 |
<p>
|
|
|
55 |
<input id="feeList" class="w3-radio" type="radio" style="height:1em" name="rptType" value="feeList">
|
|
|
56 |
<label for="feeList">eBay Fees and Credits</label></p>
|
|
|
57 |
<p>
|
|
|
58 |
<input id="trackingList" class="w3-radio" type="radio" style="height:1em" name="rptType" value="trackingList">
|
|
|
59 |
<label for="trackingList">Tracking Status</label></p>
|
|
|
60 |
<p>
|
|
|
61 |
<input id="customerList" class="w3-radio" type="radio" style="height:1em" name="rptType" value="customerList">
|
|
|
62 |
<label for="customerList">eBay Customer Export</label></p>
|
|
|
63 |
<input id="printButton" type="button" class="w3-btn w3-large w3-black w3-margin w3-round-large w3-ripple w3-right w3-hide" onclick="printData();" value="Print" />
|
|
|
64 |
<input id="dlOrderListButton" type="button" class="w3-btn w3-large w3-black w3-margin w3-round-large w3-ripple w3-right w3-hide" onclick="exportTableToCSV('orderTable', 'orders.csv');" value="CSV" />
|
|
|
65 |
<input id="dlFeeListButton" type="button" class="w3-btn w3-large w3-black w3-margin w3-round-large w3-ripple w3-right w3-hide" onclick="exportTableToCSV('feeTable', 'fees.csv');" value="CSV" />
|
|
|
66 |
<input id="dlCustomerListButton" type="button" class="w3-btn w3-large w3-black w3-margin w3-round-large w3-ripple w3-right w3-hide" onclick="exportTableToCSV('customerTable', 'customers.csv');" value="CSV" />
|
|
|
67 |
<input id="startButton" type="button" class="w3-btn w3-large w3-red w3-margin w3-round-large w3-ripple w3-right" onclick="getOrders();" value="Start" />
|
|
|
68 |
</div>
|
|
|
69 |
<div id="summary" class="w3-container w3-cell w3-padding"></div>
|
|
|
70 |
</form>
|
|
|
71 |
</div>
|
|
|
72 |
<div id="progressBarDiv" class="w3-container w3-padding w3-margin w3-card-4 w3-hide">
|
|
|
73 |
<h2 id="progressBarHeader"></h2>
|
|
|
74 |
<div class="w3-light-grey">
|
|
|
75 |
<div id="progressBar" class="w3-container w3-green w3-center" style="width:0%">0%</div>
|
| 6 |
- |
76 |
</div>
|
| 2 |
- |
77 |
</div>
|
| 7 |
- |
78 |
<div id="results" class="w3-container w3-padding w3-card-4 w3-hide"></div>
|
|
|
79 |
<div id="printTable">
|
|
|
80 |
<div id="logging" class="w3-container w3-padding"></div>
|
|
|
81 |
</div>
|
|
|
82 |
<div id="modals"></div>
|
| 2 |
- |
83 |
</div>
|
|
|
84 |
|
|
|
85 |
<footer class="w3-container w3-center w3-border-top w3-margin">
|
|
|
86 |
Copyright © 2018 MUNA Trading. All rights reserved.
|
|
|
87 |
</footer>
|
|
|
88 |
|
|
|
89 |
</div>
|
|
|
90 |
|
|
|
91 |
<script>
|
|
|
92 |
|
|
|
93 |
// Globals
|
|
|
94 |
var pagesToProcess = 0;
|
| 6 |
- |
95 |
var pagesProcessed = 0;
|
|
|
96 |
var maxPagesToProcess = 0;
|
| 2 |
- |
97 |
var shippingsToProcess = 0;
|
| 6 |
- |
98 |
var shippingsProcessed = 0;
|
| 2 |
- |
99 |
var thumbnailsToProcess = 0;
|
| 6 |
- |
100 |
var thumbnailsProcessed = 0;
|
|
|
101 |
var maxThumbnailsToProcess = 0;
|
| 2 |
- |
102 |
var trackingNumbersToProcess = 0;
|
| 6 |
- |
103 |
var trackingNumbersProcessed = 0;
|
|
|
104 |
var maxTrackingNumbersToProcess = 0;
|
| 2 |
- |
105 |
var html = [];
|
|
|
106 |
var url;
|
|
|
107 |
var trackingList = [];
|
|
|
108 |
var trackingListDedupe = [];
|
|
|
109 |
|
|
|
110 |
var itemsSold;
|
|
|
111 |
var grossSales;
|
|
|
112 |
var shippingRcvd;
|
|
|
113 |
var returnCost;
|
|
|
114 |
var shippingCost;
|
|
|
115 |
var eBayFees;
|
|
|
116 |
var PayPalFees;
|
|
|
117 |
var VATaxGross;
|
|
|
118 |
var VATaxExempt;
|
|
|
119 |
var VATaxAmount;
|
|
|
120 |
var totalAmount;
|
|
|
121 |
|
|
|
122 |
// Initialize Configuration Variables
|
|
|
123 |
function initConfig() {
|
| 6 |
- |
124 |
eBayAuthToken = readCookie();
|
|
|
125 |
if (eBayAuthToken.length > 0) {
|
|
|
126 |
connected();
|
|
|
127 |
}
|
| 2 |
- |
128 |
|
| 6 |
- |
129 |
if (eBayAuthTokenFlag === false) {
|
|
|
130 |
var x = document.getElementById("login");
|
|
|
131 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
132 |
x.className += " w3-show";
|
|
|
133 |
}
|
|
|
134 |
}
|
| 2 |
- |
135 |
|
| 6 |
- |
136 |
var currentDate = moment();
|
| 7 |
- |
137 |
var weekDayName = moment().format('dddd');
|
|
|
138 |
var yesterday = moment().subtract((weekDayName == "Monday" ? 2 : 1), "days");
|
| 2 |
- |
139 |
|
| 7 |
- |
140 |
x = document.getElementById("startDate");
|
|
|
141 |
if (x.value.length < 1) {
|
|
|
142 |
x.value = yesterday.format('YYYY-MM-DD');
|
| 6 |
- |
143 |
}
|
| 7 |
- |
144 |
|
|
|
145 |
x = document.getElementById("endDate");
|
|
|
146 |
if (x.value.length < 1) {
|
|
|
147 |
x.value = currentDate.format('YYYY-MM-DD');
|
| 6 |
- |
148 |
}
|
| 2 |
- |
149 |
}
|
|
|
150 |
|
|
|
151 |
function requireNewLogin() {
|
| 6 |
- |
152 |
// dummy
|
| 2 |
- |
153 |
}
|
|
|
154 |
|
|
|
155 |
function getOrders() {
|
| 6 |
- |
156 |
var x;
|
| 2 |
- |
157 |
|
| 6 |
- |
158 |
itemsSold = 0;
|
|
|
159 |
grossSales = 0.0;
|
|
|
160 |
shippingRcvd = 0.0;
|
|
|
161 |
returnCost = 0.0;
|
|
|
162 |
shippingCost = 0.0;
|
|
|
163 |
eBayFees = 0.0;
|
|
|
164 |
PayPalFees = 0.0;
|
|
|
165 |
VATaxGross = 0.0;
|
|
|
166 |
VATaxExempt = 0.0;
|
|
|
167 |
VATaxAmount = 0.0;
|
| 2 |
- |
168 |
|
| 6 |
- |
169 |
document.getElementById("summary").innerHTML = '';
|
|
|
170 |
document.getElementById("results").innerHTML = '';
|
|
|
171 |
document.getElementById("logging").innerHTML = '';
|
| 2 |
- |
172 |
|
| 6 |
- |
173 |
var sDate = moment(document.getElementById("startDate").value, 'YYYY-MM-DD', true);
|
|
|
174 |
var eDate = moment(document.getElementById("endDate").value, 'YYYY-MM-DD', true);
|
| 2 |
- |
175 |
|
| 6 |
- |
176 |
if (!sDate.isValid()) {
|
|
|
177 |
document.getElementById("startDate").value = '';
|
|
|
178 |
return;
|
|
|
179 |
}
|
| 2 |
- |
180 |
|
| 6 |
- |
181 |
if (!eDate.isValid()) {
|
|
|
182 |
document.getElementById("endDate").value = '';
|
|
|
183 |
return;
|
|
|
184 |
}
|
| 2 |
- |
185 |
|
| 6 |
- |
186 |
if (moment(document.getElementById("startDate").value).isAfter(document.getElementById("endDate").value, 'day')) {
|
|
|
187 |
document.getElementById("endDate").value = '';
|
|
|
188 |
return;
|
|
|
189 |
}
|
| 2 |
- |
190 |
|
| 6 |
- |
191 |
x = document.getElementById("printButton");
|
|
|
192 |
x.className = x.className.replace(" w3-show", "");
|
|
|
193 |
x = document.getElementById("dlOrderListButton");
|
|
|
194 |
x.className = x.className.replace(" w3-show", "");
|
|
|
195 |
x = document.getElementById("dlFeeListButton");
|
|
|
196 |
x.className = x.className.replace(" w3-show", "");
|
|
|
197 |
x = document.getElementById("dlCustomerListButton");
|
|
|
198 |
x.className = x.className.replace(" w3-show", "");
|
| 7 |
- |
199 |
x = document.getElementById("summary");
|
|
|
200 |
x.className = x.className.replace(" w3-card-2", "");
|
| 2 |
- |
201 |
|
| 6 |
- |
202 |
x = document.getElementById("results");
|
|
|
203 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
204 |
x.className += " w3-show";
|
|
|
205 |
}
|
| 2 |
- |
206 |
|
| 6 |
- |
207 |
pagesToProcess = 1;
|
|
|
208 |
pagesProcessed = 0;
|
|
|
209 |
maxPagesToProcess = 1;
|
| 2 |
- |
210 |
|
| 6 |
- |
211 |
if (getRadioValue('rptType') == 'feeList') {
|
|
|
212 |
document.getElementById("results").innerHTML = '<p><strong>Retrieving Fees and Credits...</strong></p>';
|
|
|
213 |
initProgressBar("Retrieving eBay Fees and Credits...");
|
| 2 |
- |
214 |
|
| 6 |
- |
215 |
retrieveFees(1);
|
|
|
216 |
} else {
|
|
|
217 |
document.getElementById("results").innerHTML = '<p><strong>Retrieving Orders...</strong></p>';
|
|
|
218 |
document.getElementById("modals").innerHTML = '';
|
| 2 |
- |
219 |
|
| 6 |
- |
220 |
retrieveeBayOrders(1);
|
|
|
221 |
initProgressBar("Retrieving Orders...");
|
| 2 |
- |
222 |
|
| 6 |
- |
223 |
function checkpagesToProcess() {
|
|
|
224 |
if (pagesToProcess > 0) {
|
|
|
225 |
window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds
|
|
|
226 |
} else {
|
|
|
227 |
endProgressBar();
|
| 2 |
- |
228 |
|
| 6 |
- |
229 |
if (getRadioValue('rptType') == 'shippingList') {
|
|
|
230 |
retrieveShopifyShippings(1);
|
|
|
231 |
} else if (getRadioValue('rptType') == 'trackingList') {
|
|
|
232 |
retrieveShopifyTrackings(1);
|
|
|
233 |
} else if (getRadioValue('rptType') == 'customerList') {
|
|
|
234 |
sortTable("customerTable", 1);
|
|
|
235 |
x = document.getElementById("results");
|
|
|
236 |
x.innerHTML = '<p><strong>Report Finished!</strong></p>';
|
|
|
237 |
if (!x.className.includes("process-errors")) {
|
|
|
238 |
setTimeout(function() {
|
|
|
239 |
x.className = x.className.replace(" w3-show", "");
|
|
|
240 |
}, 3000);
|
|
|
241 |
}
|
|
|
242 |
} else {
|
|
|
243 |
retrieveShopifyOrders(1);
|
|
|
244 |
}
|
|
|
245 |
}
|
|
|
246 |
}
|
| 2 |
- |
247 |
|
| 6 |
- |
248 |
checkpagesToProcess();
|
|
|
249 |
|
|
|
250 |
if (getRadioValue('rptType') == 'shippingList') {
|
|
|
251 |
x = document.getElementById("printButton");
|
|
|
252 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
253 |
x.className += " w3-show";
|
|
|
254 |
}
|
|
|
255 |
} else if (getRadioValue('rptType') == 'orderList') {
|
|
|
256 |
x = document.getElementById("dlOrderListButton");
|
|
|
257 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
258 |
x.className += " w3-show";
|
|
|
259 |
}
|
|
|
260 |
} else if (getRadioValue('rptType') == 'customerList') {
|
|
|
261 |
x = document.getElementById("dlCustomerListButton");
|
|
|
262 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
263 |
x.className += " w3-show";
|
|
|
264 |
}
|
|
|
265 |
}
|
|
|
266 |
}
|
| 2 |
- |
267 |
}
|
|
|
268 |
|
|
|
269 |
function retrieveeBayOrders(pageNumber) {
|
| 6 |
- |
270 |
var i;
|
|
|
271 |
var xml;
|
|
|
272 |
var authErrorFlag = false;
|
| 2 |
- |
273 |
|
| 6 |
- |
274 |
if (eBayAuthTokenFlag === false) {
|
|
|
275 |
return;
|
|
|
276 |
}
|
| 2 |
- |
277 |
|
| 6 |
- |
278 |
var valueStartDate = moment(document.getElementById('startDate').value + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
|
|
|
279 |
var valueEndDate = moment(document.getElementById('endDate').value + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
|
| 2 |
- |
280 |
|
| 6 |
- |
281 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
282 |
var xhr = new XMLHttpRequest();
|
| 2 |
- |
283 |
|
| 6 |
- |
284 |
xw.writeStartDocument();
|
|
|
285 |
xw.writeStartElement("GetOrdersRequest");
|
|
|
286 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
| 2 |
- |
287 |
|
| 6 |
- |
288 |
xw.writeStartElement('RequesterCredentials');
|
|
|
289 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
290 |
xw.writeEndElement(); /* RequesterCredentials */
|
| 2 |
- |
291 |
|
| 6 |
- |
292 |
xw.writeElementString('CreateTimeFrom', valueStartDate);
|
|
|
293 |
xw.writeElementString('CreateTimeTo', valueEndDate);
|
| 2 |
- |
294 |
|
| 6 |
- |
295 |
xw.writeElementString('IncludeFinalValueFee', 'true');
|
|
|
296 |
xw.writeElementString('OrderRole', 'Seller');
|
|
|
297 |
xw.writeElementString('OrderStatus', 'All');
|
| 2 |
- |
298 |
|
| 6 |
- |
299 |
xw.writeStartElement('Pagination');
|
|
|
300 |
xw.writeElementString('EntriesPerPage', configXmlRequestEntriesPerPage);
|
|
|
301 |
xw.writeElementString('PageNumber', pageNumber.toString());
|
|
|
302 |
xw.writeEndElement(); /* Pagination */
|
| 2 |
- |
303 |
|
| 6 |
- |
304 |
xw.writeElementString('DetailLevel', 'ReturnAll');
|
| 2 |
- |
305 |
|
| 6 |
- |
306 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
307 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
308 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
| 2 |
- |
309 |
|
| 6 |
- |
310 |
xw.writeEndElement(); /* GetOrdersRequest */
|
|
|
311 |
xw.writeEndDocument();
|
| 2 |
- |
312 |
|
| 6 |
- |
313 |
xhr.open('POST', configProxyUrl, true);
|
|
|
314 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
315 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
316 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
317 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', 'GetOrders');
|
|
|
318 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
319 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
320 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
321 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
| 2 |
- |
322 |
|
| 6 |
- |
323 |
xml = xw.flush();
|
|
|
324 |
xw.close();
|
| 2 |
- |
325 |
|
| 6 |
- |
326 |
xhr.onload = () => {
|
| 12 |
- |
327 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
328 |
var obj = jsonObj.GetOrdersResponse;
|
| 6 |
- |
329 |
var returnCode = obj.Ack;
|
| 2 |
- |
330 |
|
| 6 |
- |
331 |
var x = document.getElementById("results");
|
|
|
332 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
333 |
x.className += " w3-show";
|
|
|
334 |
}
|
| 2 |
- |
335 |
|
| 6 |
- |
336 |
if (obj.Message) {
|
|
|
337 |
x.innerHTML += "<p>" + obj.Message + "</p>";
|
|
|
338 |
}
|
| 2 |
- |
339 |
|
| 6 |
- |
340 |
if (returnCode == 'Success' || (returnCode == 'Warning' && obj.Errors.ErrorCode == '21917182')) {
|
|
|
341 |
if (getRadioValue('rptType') == 'shippingList') {
|
|
|
342 |
createShipmentTable(obj, pageNumber);
|
|
|
343 |
} else if (getRadioValue('rptType') == 'trackingList') {
|
|
|
344 |
createTrackingTable(obj, pageNumber);
|
|
|
345 |
} else if (getRadioValue('rptType') == 'customerList') {
|
|
|
346 |
createCustomerTable(obj, pageNumber);
|
|
|
347 |
} else {
|
|
|
348 |
createOrderTable(obj, pageNumber);
|
|
|
349 |
}
|
| 2 |
- |
350 |
|
| 6 |
- |
351 |
x.innerHTML += '<p><strong>' + returnCode + ' (Orders ' + pageNumber + ' / ' + obj.PaginationResult.TotalNumberOfPages + ')</strong></p>';
|
| 2 |
- |
352 |
|
| 6 |
- |
353 |
if (getRadioValue('rptType') == 'orderList') {
|
|
|
354 |
printSummary();
|
|
|
355 |
}
|
| 2 |
- |
356 |
|
| 6 |
- |
357 |
if (obj.HasMoreOrders == 'true') {
|
|
|
358 |
++pagesToProcess;
|
|
|
359 |
++maxPagesToProcess;
|
|
|
360 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
361 |
retrieveeBayOrders(pageNumber + 1);
|
|
|
362 |
}
|
| 2 |
- |
363 |
|
| 6 |
- |
364 |
document.getElementById("logging").innerHTML = html.join('');
|
|
|
365 |
--pagesToProcess;
|
|
|
366 |
++pagesProcessed;
|
|
|
367 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
368 |
} else {
|
|
|
369 |
x.className += " process-errors";
|
|
|
370 |
x.innerHTML += "<p><strong>" + returnCode + ":</strong></p>";
|
| 2 |
- |
371 |
|
| 6 |
- |
372 |
var errors = getJsonArray(obj.Errors);
|
|
|
373 |
x.innerHTML += "<p>";
|
|
|
374 |
for (i = 0; i < errors.length; i++) {
|
|
|
375 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
|
|
376 |
if (errors[i].LongMessage.includes('Auth')) {
|
|
|
377 |
authErrorFlag = true;
|
|
|
378 |
}
|
|
|
379 |
}
|
|
|
380 |
x.innerHTML += "</p>";
|
| 2 |
- |
381 |
|
| 6 |
- |
382 |
if (authErrorFlag === true) {
|
|
|
383 |
eBayAuthTokenFlag = false;
|
|
|
384 |
x = document.getElementById("login");
|
|
|
385 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
386 |
x.className += " w3-show";
|
|
|
387 |
}
|
|
|
388 |
}
|
|
|
389 |
}
|
|
|
390 |
};
|
| 2 |
- |
391 |
|
| 6 |
- |
392 |
xhr.send(xml);
|
| 2 |
- |
393 |
}
|
|
|
394 |
|
|
|
395 |
function retrieveShopifyOrders(page) {
|
| 6 |
- |
396 |
var sDate = moment(document.getElementById("startDate").value + " 00:00:00").format("YYYY-MM-DDTHH:mm:ssZ");
|
|
|
397 |
var eDate = moment(document.getElementById("endDate").value + " 23:59:59").format("YYYY-MM-DDTHH:mm:ssZ");
|
| 2 |
- |
398 |
|
| 6 |
- |
399 |
var xhttp = new XMLHttpRequest();
|
|
|
400 |
xhttp.onreadystatechange = function() {
|
|
|
401 |
if (this.readyState == 4 && this.status == 200) {
|
|
|
402 |
var json = JSON.parse(this.responseText);
|
|
|
403 |
if (json.orders.length > 0) {
|
|
|
404 |
retrieveShopifyOrder(json);
|
|
|
405 |
} else {
|
| 12 |
- |
406 |
// xxxxx last steps in the chain
|
|
|
407 |
printOrderTotals();
|
|
|
408 |
document.getElementById("logging").innerHTML = html.join('');
|
|
|
409 |
|
|
|
410 |
sortTable("orderTable", 1);
|
|
|
411 |
document.getElementById("results").innerHTML += '<p><strong>Retrieving Shipping Costs...</strong></p>';
|
|
|
412 |
findShippingCosts();
|
| 6 |
- |
413 |
}
|
|
|
414 |
}
|
|
|
415 |
};
|
| 2 |
- |
416 |
|
| 6 |
- |
417 |
xhttp.open("GET", configProxyUrl, true);
|
|
|
418 |
xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + configShopifyOrdersUrl + '?page=' + ((page - 1) * configShopifyOrderLimit) + '&limit=' + configShopifyOrderLimit + '&status=any&created_at_min=' + sDate + '&created_at_max=' + eDate));
|
|
|
419 |
xhttp.send();
|
| 2 |
- |
420 |
}
|
|
|
421 |
|
|
|
422 |
function retrieveShopifyOrder(json) {
|
| 6 |
- |
423 |
var i, j;
|
|
|
424 |
var title;
|
|
|
425 |
var quantity;
|
|
|
426 |
var itemId;
|
|
|
427 |
var trackingNumber;
|
|
|
428 |
var trackingStatus;
|
|
|
429 |
var shipmentState;
|
|
|
430 |
var shipmentDate;
|
| 2 |
- |
431 |
|
| 6 |
- |
432 |
for (i = 0; i < json.orders.length; i++) {
|
|
|
433 |
html.push('<tr>');
|
|
|
434 |
html.push(tableCell(json.orders[i].created_at.substr(0, 10)));
|
|
|
435 |
if (json.orders[i].fulfillment_status !== null) {
|
|
|
436 |
html.push(tableCell(json.orders[i].fulfillment_status));
|
|
|
437 |
} else {
|
|
|
438 |
html.push(tableCell('created'));
|
|
|
439 |
}
|
|
|
440 |
html.push(tableCell(json.orders[i].id + ' (' + json.orders[i].name + ')'));
|
| 2 |
- |
441 |
|
| 6 |
- |
442 |
title = '';
|
|
|
443 |
quantity = '';
|
|
|
444 |
itemId = '';
|
|
|
445 |
for (j = 0; j < json.orders[i].line_items.length; j++) {
|
|
|
446 |
itemsSold++;
|
|
|
447 |
if (j > 0) {
|
|
|
448 |
title += '<br/>';
|
|
|
449 |
quantity += '<br/>';
|
|
|
450 |
itemId += '<br/>';
|
|
|
451 |
}
|
|
|
452 |
title += json.orders[i].line_items[j].title;
|
|
|
453 |
quantity += json.orders[i].line_items[j].quantity;
|
|
|
454 |
itemId += json.orders[i].line_items[j].product_id === null ? '' : json.orders[i].line_items[j].product_id;
|
|
|
455 |
}
|
| 2 |
- |
456 |
|
| 6 |
- |
457 |
html.push(tableCell(title));
|
|
|
458 |
html.push(tableCell(itemId));
|
|
|
459 |
html.push(tableCell('Shopify'));
|
|
|
460 |
html.push(tableCell(quantity));
|
|
|
461 |
html.push(tableCell('$' + json.orders[i].total_price_usd));
|
|
|
462 |
html.push(tableCell('$0.00'));
|
|
|
463 |
html.push(tableCell('N/A'));
|
|
|
464 |
html.push(tableCell('$0.00'));
|
|
|
465 |
html.push(tableCellLabel('Fee' + json.orders[i].id));
|
|
|
466 |
html.push(tableCell(json.orders[i].total_tax));
|
| 2 |
- |
467 |
|
| 6 |
- |
468 |
if (json.orders[i].shipping_address !== undefined) {
|
|
|
469 |
shipmentState = json.orders[i].shipping_address.province_code;
|
|
|
470 |
} else {
|
|
|
471 |
shipmentState = configTaxStateId;
|
|
|
472 |
}
|
|
|
473 |
html.push(tableCell(shipmentState));
|
|
|
474 |
html.push(tableCellLabel('PaidDate' + json.orders[i].id));
|
|
|
475 |
html.push(tableCell(json.orders[i].payment_gateway_names !== undefined ? json.orders[i].payment_gateway_names.join(', ') : ''));
|
|
|
476 |
html.push(tableCellLabel('TransactionId' + json.orders[i].id));
|
| 2 |
- |
477 |
|
| 6 |
- |
478 |
shipmentDate = '';
|
|
|
479 |
trackingNumber = '';
|
|
|
480 |
trackingStatus = '';
|
|
|
481 |
for (j = 0; j < json.orders[i].fulfillments.length; j++) {
|
|
|
482 |
if (j > 0) {
|
|
|
483 |
trackingNumber += '<br/>';
|
|
|
484 |
trackingStatus += '<br/>';
|
|
|
485 |
shipmentDate += '<br/>';
|
|
|
486 |
}
|
| 2 |
- |
487 |
|
| 6 |
- |
488 |
if (json.orders[i].fulfillments[j].tracking_number !== null) {
|
|
|
489 |
trackingNumber = json.orders[i].fulfillments[j].tracking_company + ' ' + json.orders[i].fulfillments[j].tracking_number;
|
|
|
490 |
trackingStatus = json.orders[i].fulfillments[j].shipment_status;
|
|
|
491 |
shipmentDate += json.orders[i].fulfillments[j].created_at.substr(0, 10);
|
|
|
492 |
}
|
|
|
493 |
}
|
| 2 |
- |
494 |
|
| 6 |
- |
495 |
html.push(tableCell(shipmentDate));
|
|
|
496 |
html.push(tableCell(trackingNumber));
|
|
|
497 |
html.push(tableCell(trackingStatus));
|
|
|
498 |
html.push('</tr>');
|
| 2 |
- |
499 |
|
| 6 |
- |
500 |
grossSales += Number(json.orders[i].total_price_usd);
|
|
|
501 |
VATaxAmount += Number(json.orders[i].total_tax);
|
|
|
502 |
}
|
| 2 |
- |
503 |
|
| 6 |
- |
504 |
// xxxxx last steps in the chain
|
|
|
505 |
printOrderTotals();
|
|
|
506 |
document.getElementById("logging").innerHTML = html.join('');
|
| 2 |
- |
507 |
|
| 6 |
- |
508 |
sortTable("orderTable", 1);
|
|
|
509 |
document.getElementById("results").innerHTML += '<p><strong>Retrieving Shipping Costs...</strong></p>';
|
|
|
510 |
findShippingCosts();
|
| 2 |
- |
511 |
}
|
|
|
512 |
|
|
|
513 |
function retrieveShopifyShippings(page) {
|
| 6 |
- |
514 |
var xhttp = new XMLHttpRequest();
|
|
|
515 |
xhttp.onreadystatechange = function() {
|
|
|
516 |
if (this.readyState == 4 && this.status == 200) {
|
|
|
517 |
//window.alert(this.responseText);
|
|
|
518 |
var json = JSON.parse(this.responseText);
|
|
|
519 |
if (json.orders[0] !== undefined) {
|
|
|
520 |
retrieveShopifyShipping(json);
|
|
|
521 |
}
|
| 2 |
- |
522 |
|
| 6 |
- |
523 |
// xxxxx last steps in the chain
|
|
|
524 |
printShipmentTotals();
|
|
|
525 |
document.getElementById("logging").innerHTML = html.join('');
|
| 2 |
- |
526 |
|
| 6 |
- |
527 |
sortTable("shippingTable", 1);
|
|
|
528 |
findThumbNails();
|
|
|
529 |
}
|
|
|
530 |
};
|
| 2 |
- |
531 |
|
| 6 |
- |
532 |
xhttp.open("GET", configProxyUrl, true);
|
|
|
533 |
xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + configShopifyOrdersUrl + '?page=' + ((page - 1) * configShopifyOrderLimit) + '&limit=' + configShopifyOrderLimit + '&fulfillment_status=unshipped'));
|
|
|
534 |
xhttp.send();
|
| 2 |
- |
535 |
}
|
|
|
536 |
|
|
|
537 |
function retrieveShopifyShipping(json) {
|
| 6 |
- |
538 |
var i;
|
| 2 |
- |
539 |
|
| 6 |
- |
540 |
for (i = 0; i < json.orders.length; i++) {
|
|
|
541 |
totalAmount += parseFloat(json.orders[i].total_price);
|
| 2 |
- |
542 |
|
| 6 |
- |
543 |
for (j = 0; j < json.orders[i].line_items.length; j++) {
|
|
|
544 |
html.push('<tr>');
|
| 2 |
- |
545 |
|
| 6 |
- |
546 |
html.push(tableCellSKU(json.orders[i].line_items[j].sku, json.orders[i].line_items[j].title));
|
|
|
547 |
html.push(tableCell(json.orders[i].line_items[j].quantity));
|
|
|
548 |
if (json.orders[i].line_items[j].product_id !== null) {
|
|
|
549 |
html.push(tableCellAndLabel(json.orders[i].line_items[j].product_id, 'PictureURL' + json.orders[i].line_items[j].product_id));
|
|
|
550 |
} else {
|
|
|
551 |
html.push(tableCell(''));
|
|
|
552 |
}
|
|
|
553 |
html.push(tableCell(json.orders[i].line_items[j].title));
|
|
|
554 |
html.push(tableCell(json.orders[i].name));
|
|
|
555 |
html.push(tableCellDate(json.orders[i].created_at.substr(0, 10)));
|
|
|
556 |
html.push(tableCell('$' + parseFloat(json.orders[i].line_items[j].price).toFixed(2)));
|
|
|
557 |
html.push(tableCellHidden('Shopify'));
|
| 2 |
- |
558 |
|
| 6 |
- |
559 |
itemsSold += Number(json.orders[i].line_items[j].quantity);
|
| 2 |
- |
560 |
|
| 6 |
- |
561 |
html.push('</tr>');
|
|
|
562 |
}
|
|
|
563 |
}
|
| 2 |
- |
564 |
}
|
|
|
565 |
|
|
|
566 |
function retrieveShopifyTrackings(page) {
|
| 6 |
- |
567 |
var sDate = moment(document.getElementById("startDate").value + " 00:00:00").format("YYYY-MM-DDTHH:mm:ssZ");
|
|
|
568 |
var eDate = moment(document.getElementById("endDate").value + " 23:59:59").format("YYYY-MM-DDTHH:mm:ssZ");
|
| 2 |
- |
569 |
|
| 6 |
- |
570 |
var xhttp = new XMLHttpRequest();
|
|
|
571 |
xhttp.onreadystatechange = function() {
|
|
|
572 |
if (this.readyState == 4 && this.status == 200) {
|
|
|
573 |
//window.alert(this.responseText);
|
|
|
574 |
var json = JSON.parse(this.responseText);
|
|
|
575 |
if (json.orders[0] !== undefined) {
|
|
|
576 |
retrieveShopifyTracking(json);
|
|
|
577 |
}
|
| 2 |
- |
578 |
|
| 6 |
- |
579 |
// xxxxx last in the chain
|
|
|
580 |
printTrackingTotals();
|
|
|
581 |
document.getElementById("logging").innerHTML = html.join('');
|
|
|
582 |
sortTable("trackingTable", 1);
|
|
|
583 |
document.getElementById("results").innerHTML += '<p><strong>Retrieving Shipping Costs...</strong></p>';
|
|
|
584 |
findShippingCosts();
|
|
|
585 |
}
|
|
|
586 |
};
|
| 2 |
- |
587 |
|
| 6 |
- |
588 |
xhttp.open("GET", configProxyUrl, true);
|
|
|
589 |
xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + configShopifyOrdersUrl + '?page=' + ((page - 1) * configShopifyOrderLimit) + '&limit=' + configShopifyOrderLimit + '&fulfillment_status=shipped&status=closed&created_at_min=' + sDate + '&created_at_max=' + eDate));
|
|
|
590 |
xhttp.send();
|
| 2 |
- |
591 |
}
|
|
|
592 |
|
|
|
593 |
function retrieveShopifyTracking(json) {
|
| 6 |
- |
594 |
var i, j;
|
|
|
595 |
var title;
|
| 2 |
- |
596 |
|
| 6 |
- |
597 |
for (i = 0; i < json.orders.length; i++) {
|
|
|
598 |
if (json.orders[i].shipping_lines[0] === undefined) {
|
|
|
599 |
continue;
|
|
|
600 |
}
|
| 2 |
- |
601 |
|
| 6 |
- |
602 |
html.push('<tr>');
|
|
|
603 |
html.push(tableCell(json.orders[i].created_at.substr(0, 10)));
|
| 2 |
- |
604 |
|
| 6 |
- |
605 |
title = '';
|
|
|
606 |
for (j = 0; j < json.orders[i].line_items.length; j++) {
|
|
|
607 |
if (j > 0) {
|
|
|
608 |
title += '<br/>';
|
|
|
609 |
}
|
|
|
610 |
title += json.orders[i].line_items[j].title;
|
|
|
611 |
}
|
| 2 |
- |
612 |
|
| 6 |
- |
613 |
html.push(tableCell(title));
|
|
|
614 |
html.push(tableCell('N/A'));
|
|
|
615 |
html.push(tableCellAndLabel(json.orders[i].shipping_address.city + ', ' + json.orders[i].shipping_address.province_code + ' ' + json.orders[i].shipping_address.zip, 'DeliveryAddress' + json.orders[i].fulfillments[0].tracking_number));
|
|
|
616 |
html.push(tableCell(json.orders[i].fulfillments[0].created_at.substr(0, 10))); // best guess
|
|
|
617 |
html.push(tableCell(json.orders[i].fulfillments[0].created_at.substr(0, 10)));
|
|
|
618 |
html.push(tableCellAndLabel(json.orders[i].fulfillments[0].tracking_company + ' ' + json.orders[i].fulfillments[0].tracking_number, json.orders[i].fulfillments[0].tracking_number));
|
|
|
619 |
html.push(tableCell(getCarrierService(json.orders[i].fulfillments[0].tracking_company, json.orders[i].fulfillments[0].tracking_number, true)));
|
|
|
620 |
html.push(tableCellLabel('DeliveryDate' + json.orders[i].fulfillments[0].tracking_number));
|
|
|
621 |
html.push(tableCellLabel('DeliveryDays' + json.orders[i].fulfillments[0].tracking_number));
|
|
|
622 |
html.push(tableCellLabel('DeliveryStatus' + json.orders[i].fulfillments[0].tracking_number));
|
| 2 |
- |
623 |
|
| 6 |
- |
624 |
html.push('</tr>');
|
|
|
625 |
}
|
| 2 |
- |
626 |
}
|
|
|
627 |
|
|
|
628 |
function createOrderTable(obj, pageNumber) {
|
| 6 |
- |
629 |
var i;
|
|
|
630 |
var title;
|
|
|
631 |
var trackingNumber;
|
|
|
632 |
var quantity;
|
|
|
633 |
var finalValueFee;
|
|
|
634 |
var finalValueFeeAmount;
|
|
|
635 |
var itemId;
|
|
|
636 |
var taxAmount;
|
|
|
637 |
var payAmount;
|
| 2 |
- |
638 |
|
| 6 |
- |
639 |
if (pageNumber == 1) {
|
|
|
640 |
document.getElementById("logging").innerHTML = '';
|
|
|
641 |
html = [];
|
| 2 |
- |
642 |
|
| 6 |
- |
643 |
html.push('<h3>Order List from ' + document.getElementById("startDate").value + ' to ' + document.getElementById("endDate").value + '</h3>');
|
|
|
644 |
html.push('<div class="w3-responsive">');
|
|
|
645 |
html.push('<table id="orderTable" class="w3-table-all w3-tiny w3-hoverable">');
|
|
|
646 |
html.push('<thead>');
|
|
|
647 |
html.push('<tr>');
|
| 2 |
- |
648 |
|
| 6 |
- |
649 |
html.push(tableHeader('Order Date'));
|
|
|
650 |
html.push(tableHeader('Order Status'));
|
|
|
651 |
html.push(tableHeader('Order Id'));
|
|
|
652 |
html.push(tableHeader('Ttitle'));
|
|
|
653 |
html.push(tableHeader('Item Id'));
|
|
|
654 |
html.push(tableHeader('Sales Channel'));
|
|
|
655 |
html.push(tableHeader('Quantity Purchased'));
|
|
|
656 |
html.push(tableHeader('Payment Amount'));
|
|
|
657 |
html.push(tableHeader('Shipping Received'));
|
|
|
658 |
html.push(tableHeader('Shipping Cost'));
|
|
|
659 |
html.push(tableHeader('eBay Final Value Fee'));
|
|
|
660 |
html.push(tableHeader('Payment Processor Fee'));
|
|
|
661 |
html.push(tableHeader('Sales Tax Amount'));
|
|
|
662 |
html.push(tableHeader('Ship To State'));
|
|
|
663 |
html.push(tableHeader('Paid Date'));
|
|
|
664 |
html.push(tableHeader('Payment Methods'));
|
| 2 |
- |
665 |
|
| 6 |
- |
666 |
html.push(tableHeader('Payment Transaction ID'));
|
|
|
667 |
html.push(tableHeader('Shipped Date'));
|
|
|
668 |
html.push(tableHeader('Shipping Tracking Number'));
|
|
|
669 |
html.push(tableHeader('Delivery Status'));
|
| 2 |
- |
670 |
|
| 6 |
- |
671 |
html.push('</tr>');
|
|
|
672 |
html.push('</thead>');
|
|
|
673 |
html.push('<tbody>');
|
|
|
674 |
}
|
| 2 |
- |
675 |
|
| 6 |
- |
676 |
var orders = getJsonArray(obj.OrderArray);
|
| 12 |
- |
677 |
for (var entry = 0; entry < orders[0].Order.length; entry++) {
|
|
|
678 |
var order = orders[0].Order[entry];
|
|
|
679 |
|
| 6 |
- |
680 |
html.push('<tr>');
|
| 2 |
- |
681 |
|
| 12 |
- |
682 |
html.push(tableCellDate(order.CreatedTime));
|
|
|
683 |
html.push(tableCell(order.OrderStatus));
|
|
|
684 |
html.push(tableCell(order.OrderID));
|
| 2 |
- |
685 |
|
| 6 |
- |
686 |
title = '';
|
|
|
687 |
trackingNumber = '';
|
|
|
688 |
quantity = '';
|
|
|
689 |
finalValueFee = '';
|
|
|
690 |
finalValueFeeAmount = 0.0;
|
|
|
691 |
itemId = '';
|
| 2 |
- |
692 |
|
| 12 |
- |
693 |
var transactions = getJsonArray(orders[0].Order[entry].TransactionArray.Transaction);
|
| 6 |
- |
694 |
for (i = 0; i < transactions.length; i++) {
|
|
|
695 |
itemsSold++;
|
|
|
696 |
if (i > 0) {
|
|
|
697 |
title += '<br/>';
|
|
|
698 |
quantity += '<br/>';
|
|
|
699 |
itemId += '<br/>';
|
|
|
700 |
}
|
|
|
701 |
title += transactions[i].Item.Title;
|
|
|
702 |
quantity += transactions[i].QuantityPurchased;
|
|
|
703 |
finalValueFeeAmount += parseFloat(transactions[i].FinalValueFee.text);
|
|
|
704 |
eBayFees += parseFloat(transactions[i].FinalValueFee.text);
|
|
|
705 |
itemId += transactions[i].Item.ItemID;
|
|
|
706 |
}
|
|
|
707 |
html.push(tableCell(title));
|
|
|
708 |
html.push(tableCell(itemId));
|
|
|
709 |
finalValueFee = '$' + finalValueFeeAmount.toFixed(2);
|
| 2 |
- |
710 |
|
| 6 |
- |
711 |
var trackingDetails = getJsonArray(transactions[0].ShippingDetails.ShipmentTrackingDetails);
|
|
|
712 |
for (i = 0; i < trackingDetails.length; i++) {
|
|
|
713 |
trackingNumber += (i > 0 ? '<br/>' : '') + trackingDetails[i].ShippingCarrierUsed + ' ' + trackingDetails[i].ShipmentTrackingNumber;
|
|
|
714 |
}
|
| 2 |
- |
715 |
|
| 6 |
- |
716 |
html.push(tableCell('eBay'));
|
|
|
717 |
html.push(tableCell(quantity));
|
| 12 |
- |
718 |
html.push(tableCell('$' + parseFloat(order.AmountPaid.text).toFixed(2)));
|
|
|
719 |
grossSales += parseFloat(order.AmountPaid.text);
|
| 2 |
- |
720 |
|
| 12 |
- |
721 |
html.push(tableCell('$' + parseFloat(order.ShippingServiceSelected.ShippingServiceCost.text).toFixed(2)));
|
|
|
722 |
shippingRcvd += parseFloat(order.ShippingServiceSelected.ShippingServiceCost.text);
|
| 2 |
- |
723 |
|
| 12 |
- |
724 |
html.push(tableCellLabel('ShippingCost' + order.OrderID));
|
| 6 |
- |
725 |
html.push(tableCell(finalValueFee));
|
| 2 |
- |
726 |
|
| 12 |
- |
727 |
if (order.ExternalTransaction !== undefined && order.ExternalTransaction.FeeOrCreditAmount !== undefined) {
|
|
|
728 |
html.push(tableCell('$' + parseFloat(order.ExternalTransaction.FeeOrCreditAmount.text).toFixed(2)));
|
|
|
729 |
PayPalFees += parseFloat(order.ExternalTransaction.FeeOrCreditAmount.text);
|
| 6 |
- |
730 |
} else {
|
|
|
731 |
html.push(tableCell(''));
|
|
|
732 |
}
|
| 2 |
- |
733 |
|
| 12 |
- |
734 |
if (order.ShippingAddress.StateOrProvince == configTaxStateId && order.ShippingDetails.SalesTax.SalesTaxAmount.text == "0.0") {
|
|
|
735 |
payAmount = parseFloat(order.AmountPaid.text);
|
| 6 |
- |
736 |
taxAmount = payAmount - (payAmount / (1.00 + (configTaxRate / 100)));
|
|
|
737 |
html.push(tableCell('$' + taxAmount.toFixed(2)));
|
|
|
738 |
VATaxAmount += taxAmount;
|
|
|
739 |
} else {
|
| 12 |
- |
740 |
html.push(tableCell('$' + parseFloat(order.ShippingDetails.SalesTax.SalesTaxAmount.text).toFixed(2)));
|
|
|
741 |
VATaxAmount += parseFloat(order.ShippingDetails.SalesTax.SalesTaxAmount.text);
|
| 6 |
- |
742 |
}
|
| 12 |
- |
743 |
html.push(tableCell(order.ShippingAddress.StateOrProvince));
|
|
|
744 |
VATaxGross += (parseFloat(order.AmountPaid.text) - parseFloat(order.ShippingDetails.SalesTax.SalesTaxAmount.text));
|
|
|
745 |
if (order.ShippingAddress.StateOrProvince != configTaxStateId) {
|
|
|
746 |
VATaxExempt += parseFloat(order.AmountPaid.text);
|
| 6 |
- |
747 |
}
|
| 2 |
- |
748 |
|
| 12 |
- |
749 |
if (order.PaidTime !== undefined) {
|
|
|
750 |
html.push(tableCellDate(order.PaidTime));
|
| 6 |
- |
751 |
} else {
|
|
|
752 |
html.push(tableCell(''));
|
|
|
753 |
}
|
| 12 |
- |
754 |
html.push(tableCell(order.PaymentMethods));
|
| 2 |
- |
755 |
|
| 12 |
- |
756 |
if (order.ExternalTransaction !== undefined && order.ExternalTransaction.ExternalTransactionID !== undefined) {
|
|
|
757 |
html.push(tableCell(order.ExternalTransaction.ExternalTransactionID));
|
| 6 |
- |
758 |
} else {
|
|
|
759 |
html.push(tableCell(''));
|
|
|
760 |
}
|
| 2 |
- |
761 |
|
| 12 |
- |
762 |
if (order.ShippedTime === undefined) {
|
| 6 |
- |
763 |
html.push(tableCell(''));
|
|
|
764 |
} else {
|
| 12 |
- |
765 |
html.push(tableCellDate(order.ShippedTime));
|
| 6 |
- |
766 |
}
|
|
|
767 |
html.push(tableCell(trackingNumber));
|
| 12 |
- |
768 |
html.push(tableCellLabel('Delivery' + order.OrderID));
|
| 6 |
- |
769 |
|
|
|
770 |
html.push('</tr>');
|
|
|
771 |
}
|
| 2 |
- |
772 |
}
|
|
|
773 |
|
|
|
774 |
function printOrderTotals() {
|
| 6 |
- |
775 |
html.push('</tbody>');
|
|
|
776 |
html.push('<tfoot>');
|
|
|
777 |
html.push('<tr>');
|
|
|
778 |
html.push(tableCell('<strong>Totals</strong>'));
|
|
|
779 |
html.push(tableCell(''));
|
|
|
780 |
html.push(tableCell(''));
|
|
|
781 |
html.push(tableCell(''));
|
|
|
782 |
html.push(tableCell(''));
|
|
|
783 |
html.push(tableCell(''));
|
|
|
784 |
html.push(tableCell('<strong>' + itemsSold + '</strong>'));
|
|
|
785 |
html.push(tableCell('<strong>$' + grossSales.toFixed(2) + '</strong>'));
|
|
|
786 |
html.push(tableCell('<strong>$' + shippingRcvd.toFixed(2) + '</strong>'));
|
|
|
787 |
html.push(tableCellLabel('ShippingTotal'));
|
|
|
788 |
html.push(tableCell('<strong>$' + eBayFees.toFixed(2) + '</strong>'));
|
|
|
789 |
html.push(tableCell('<strong>$' + PayPalFees.toFixed(2) + '</strong>'));
|
|
|
790 |
html.push(tableCell('<strong>$' + VATaxAmount.toFixed(2) + '</strong>'));
|
|
|
791 |
html.push(tableCell(''));
|
|
|
792 |
html.push(tableCell(''));
|
|
|
793 |
html.push(tableCell(''));
|
|
|
794 |
html.push(tableCell(''));
|
|
|
795 |
html.push(tableCell(''));
|
|
|
796 |
html.push(tableCell(''));
|
|
|
797 |
html.push(tableCell(''));
|
|
|
798 |
html.push('</tr>');
|
|
|
799 |
html.push('</tfoot>');
|
|
|
800 |
html.push('</table>');
|
|
|
801 |
html.push('</div>');
|
| 2 |
- |
802 |
}
|
|
|
803 |
|
|
|
804 |
function createCustomerTable(obj, pageNumber) {
|
| 6 |
- |
805 |
var i;
|
|
|
806 |
var firstName;
|
|
|
807 |
var lastName;
|
|
|
808 |
var emailAddress;
|
| 2 |
- |
809 |
|
| 6 |
- |
810 |
if (pageNumber == 1) {
|
|
|
811 |
document.getElementById("logging").innerHTML = '';
|
|
|
812 |
html = [];
|
| 2 |
- |
813 |
|
| 6 |
- |
814 |
html.push('<h3>Customer List from ' + document.getElementById("startDate").value + ' to ' + document.getElementById("endDate").value + '</h3>');
|
|
|
815 |
html.push('<div class="w3-responsive">');
|
|
|
816 |
html.push('<table id="customerTable" class="w3-table-all w3-tiny w3-hoverable">');
|
|
|
817 |
html.push('<thead>');
|
|
|
818 |
html.push('<tr>');
|
| 2 |
- |
819 |
|
| 6 |
- |
820 |
html.push(tableHeader('First Name'));
|
|
|
821 |
html.push(tableHeader('Last Name'));
|
|
|
822 |
html.push(tableHeader('Email'));
|
|
|
823 |
html.push(tableHeader('Company'));
|
|
|
824 |
html.push(tableHeader('Address1'));
|
|
|
825 |
html.push(tableHeader('Address2'));
|
|
|
826 |
html.push(tableHeader('City'));
|
|
|
827 |
html.push(tableHeader('Province'));
|
|
|
828 |
html.push(tableHeader('Province Code'));
|
|
|
829 |
html.push(tableHeader('Country'));
|
|
|
830 |
html.push(tableHeader('Country Code'));
|
|
|
831 |
html.push(tableHeader('Zip'));
|
|
|
832 |
html.push(tableHeader('Phone'));
|
|
|
833 |
html.push(tableHeader('Accepts Marketing'));
|
|
|
834 |
html.push(tableHeader('Total Spent'));
|
|
|
835 |
html.push(tableHeader('Total Orders'));
|
|
|
836 |
html.push(tableHeader('Tags'));
|
|
|
837 |
html.push(tableHeader('Note'));
|
|
|
838 |
html.push(tableHeader('Tax Exempt'));
|
| 2 |
- |
839 |
|
| 6 |
- |
840 |
html.push('</tr>');
|
|
|
841 |
html.push('</thead>');
|
|
|
842 |
html.push('<tbody>');
|
|
|
843 |
}
|
| 2 |
- |
844 |
|
| 12 |
- |
845 |
var orders = getJsonArray(obj.OrderArray.Order);
|
| 6 |
- |
846 |
for (var entry = 0; entry < orders.length; entry++) {
|
| 12 |
- |
847 |
var order = obj.OrderArray.Order[entry];
|
|
|
848 |
|
| 6 |
- |
849 |
html.push('<tr>');
|
| 2 |
- |
850 |
|
| 6 |
- |
851 |
firstName = '';
|
|
|
852 |
lastName = '';
|
|
|
853 |
emailAddress = '';
|
| 2 |
- |
854 |
|
| 12 |
- |
855 |
var transactions = getJsonArray(order.TransactionArray.Transaction);
|
| 6 |
- |
856 |
for (i = 0; i < transactions.length; i++) {
|
|
|
857 |
firstName = transactions[i].Buyer.UserFirstName;
|
|
|
858 |
lastName = transactions[i].Buyer.UserLastName;
|
|
|
859 |
emailAddress = transactions[i].Buyer.Email;
|
|
|
860 |
}
|
| 2 |
- |
861 |
|
| 6 |
- |
862 |
html.push(tableCell(firstName.toProperCase()));
|
|
|
863 |
html.push(tableCell(lastName.toProperCase()));
|
|
|
864 |
html.push(tableCell(emailAddress != 'Invalid Request' ? emailAddress : ""));
|
|
|
865 |
html.push(tableCell(''));
|
| 12 |
- |
866 |
html.push(tableCell(order.ShippingAddress.Street1.toProperCase()));
|
|
|
867 |
html.push(tableCell(order.ShippingAddress.Street2.toProperCase()));
|
| 6 |
- |
868 |
html.push(tableCell(orders[entry].ShippingAddress.CityName.toProperCase()));
|
|
|
869 |
html.push(tableCell(''));
|
| 12 |
- |
870 |
html.push(tableCell(order.ShippingAddress.StateOrProvince));
|
|
|
871 |
html.push(tableCell(order.ShippingAddress.CountryName.toProperCase()));
|
|
|
872 |
html.push(tableCell(order.ShippingAddress.Country));
|
|
|
873 |
html.push(tableCell(order.ShippingAddress.PostalCode));
|
|
|
874 |
html.push(tableCell(order.ShippingAddress.Phone));
|
| 6 |
- |
875 |
html.push(tableCell('no'));
|
|
|
876 |
html.push(tableCell(''));
|
|
|
877 |
html.push(tableCell(''));
|
|
|
878 |
html.push(tableCell('ebay'));
|
| 12 |
- |
879 |
html.push(tableCell(order.BuyerUserID));
|
| 6 |
- |
880 |
html.push(tableCell('no'));
|
| 2 |
- |
881 |
|
| 6 |
- |
882 |
html.push('</tr>');
|
|
|
883 |
}
|
| 2 |
- |
884 |
|
|
|
885 |
|
| 6 |
- |
886 |
if (obj.HasMoreOrders != 'true') {
|
|
|
887 |
html.push('</tbody>');
|
|
|
888 |
html.push('<tfoot>');
|
|
|
889 |
html.push('<tr>');
|
|
|
890 |
html.push(tableCell(''));
|
|
|
891 |
html.push('</tr>');
|
|
|
892 |
html.push('</tfoot>');
|
|
|
893 |
html.push('</table>');
|
|
|
894 |
html.push('</div>');
|
|
|
895 |
}
|
| 2 |
- |
896 |
}
|
|
|
897 |
|
|
|
898 |
function createShipmentTable(obj, pageNumber) {
|
| 6 |
- |
899 |
var i;
|
| 2 |
- |
900 |
|
| 6 |
- |
901 |
if (pageNumber == 1) {
|
|
|
902 |
totalAmount = 0.00;
|
|
|
903 |
itemsSold = 0;
|
| 2 |
- |
904 |
|
| 6 |
- |
905 |
document.getElementById("logging").innerHTML = '';
|
|
|
906 |
html = [];
|
| 2 |
- |
907 |
|
| 6 |
- |
908 |
html.push('<h3>Awaiting Shipment List</h3>');
|
|
|
909 |
html.push('<table id="shippingTable" class="w3-table-all w3-small">');
|
|
|
910 |
html.push('<thead>');
|
|
|
911 |
html.push('<tr>');
|
| 2 |
- |
912 |
|
| 6 |
- |
913 |
html.push(tableHeader('SKU'));
|
|
|
914 |
html.push(tableHeader('Quantity'));
|
|
|
915 |
html.push(tableHeader('Thumbnail'));
|
|
|
916 |
html.push(tableHeader('Ttitle'));
|
|
|
917 |
html.push(tableHeader('Item Id'));
|
|
|
918 |
html.push(tableHeader('Date'));
|
|
|
919 |
html.push(tableHeader('Payment Amount'));
|
|
|
920 |
html.push(tableHeaderHidden('Sales Channel'));
|
| 2 |
- |
921 |
|
| 6 |
- |
922 |
html.push('</tr>');
|
|
|
923 |
html.push('</thead>');
|
|
|
924 |
html.push('<tbody>');
|
|
|
925 |
}
|
| 2 |
- |
926 |
|
| 12 |
- |
927 |
var orders = getJsonArray(obj.OrderArray.Order);
|
| 6 |
- |
928 |
for (var entry = 0; entry < orders.length; entry++) {
|
|
|
929 |
if (orders[entry].OrderStatus == 'Completed' && orders[entry].ShippedTime === undefined && orders[entry].PaidTime !== undefined) {
|
| 12 |
- |
930 |
var transactions = getJsonArray(orders[entry].TransactionArray.Transaction);
|
| 6 |
- |
931 |
for (i = 0; i < transactions.length; i++) {
|
|
|
932 |
itemsSold++;
|
| 2 |
- |
933 |
|
| 10 |
- |
934 |
var title = getJsonValue(transactions[i].Item.Title);
|
|
|
935 |
var buyerMessage = getJsonValue(orders[entry].BuyerCheckoutMessage);
|
|
|
936 |
if (buyerMessage.length > 0) {
|
|
|
937 |
title += '<br/><br/>Buyer Message: ' + buyerMessage;
|
|
|
938 |
}
|
|
|
939 |
|
| 6 |
- |
940 |
html.push('<tr>');
|
| 2 |
- |
941 |
|
| 6 |
- |
942 |
html.push(tableCellSKU(transactions[i].Item.SKU, transactions[i].Item.Title));
|
|
|
943 |
html.push(tableCell(transactions[i].QuantityPurchased));
|
|
|
944 |
html.push(tableCellLabel('PictureURL' + transactions[i].Item.ItemID));
|
| 10 |
- |
945 |
html.push(tableCell(title));
|
| 6 |
- |
946 |
html.push(tableCell(transactions[i].Item.ItemID));
|
|
|
947 |
html.push(tableCellDate(orders[entry].CreatedTime));
|
| 10 |
- |
948 |
html.push(tableCell('$' + parseFloat(orders[entry].AmountPaid.text).toFixed(2) + (transactions.length > 1 ?'*' : '')));
|
| 6 |
- |
949 |
if (i === 0) {
|
|
|
950 |
totalAmount += parseFloat(orders[entry].AmountPaid.text);
|
|
|
951 |
}
|
|
|
952 |
html.push(tableCellHidden('eBay'));
|
| 2 |
- |
953 |
|
| 6 |
- |
954 |
html.push('</tr>');
|
|
|
955 |
}
|
|
|
956 |
}
|
|
|
957 |
}
|
| 2 |
- |
958 |
}
|
|
|
959 |
|
|
|
960 |
function printShipmentTotals() {
|
| 6 |
- |
961 |
html.push('</tbody>');
|
|
|
962 |
html.push('<tfoot>');
|
|
|
963 |
html.push('<tr>');
|
|
|
964 |
html.push(tableCell('<strong>Totals</strong>'));
|
|
|
965 |
html.push(tableCell(''));
|
|
|
966 |
html.push(tableCell(''));
|
|
|
967 |
html.push(tableCell(''));
|
|
|
968 |
html.push(tableCell(''));
|
|
|
969 |
html.push(tableCell('<strong>' + itemsSold + '</strong>'));
|
|
|
970 |
html.push(tableCell('<strong>$' + totalAmount.toFixed(2) + '</strong>'));
|
|
|
971 |
html.push(tableCellHidden(''));
|
|
|
972 |
html.push('</tr>');
|
|
|
973 |
html.push('</tfoot>');
|
|
|
974 |
html.push('</table>');
|
| 2 |
- |
975 |
}
|
|
|
976 |
|
|
|
977 |
function createTrackingTable(obj, pageNumber) {
|
| 6 |
- |
978 |
var i;
|
|
|
979 |
var title;
|
|
|
980 |
var trackingNumber;
|
|
|
981 |
var service;
|
|
|
982 |
var quantity;
|
|
|
983 |
var html_temp;
|
|
|
984 |
var finalValueFee;
|
|
|
985 |
var finalValueFeeAmount;
|
|
|
986 |
var itemId;
|
| 2 |
- |
987 |
|
| 6 |
- |
988 |
if (pageNumber == 1) {
|
|
|
989 |
document.getElementById("logging").innerHTML = '';
|
|
|
990 |
html = [];
|
|
|
991 |
trackingList = [];
|
|
|
992 |
trackingListDedupe = [];
|
| 2 |
- |
993 |
|
| 6 |
- |
994 |
html.push('<h3>Tracking Number Status from ' + document.getElementById("startDate").value + ' to ' + document.getElementById("endDate").value + '</h3>');
|
|
|
995 |
html.push('<div class="w3-responsive">');
|
|
|
996 |
html.push('<table id="trackingTable" class="w3-table-all w3-tiny w3-hoverable">');
|
|
|
997 |
html.push('<thead>');
|
|
|
998 |
html.push('<tr>');
|
| 2 |
- |
999 |
|
| 6 |
- |
1000 |
html.push(tableHeader('Order Date'));
|
|
|
1001 |
html.push(tableHeader('Ttitle'));
|
|
|
1002 |
html.push(tableHeaderHidden('Order Id'));
|
|
|
1003 |
html.push(tableHeader('Shipping Cost'));
|
|
|
1004 |
html.push(tableHeader('Shipping Address'));
|
|
|
1005 |
html.push(tableHeader('Paid Date'));
|
|
|
1006 |
html.push(tableHeader('Shipped Date'));
|
|
|
1007 |
html.push(tableHeader('Shipping Tracking Number'));
|
|
|
1008 |
html.push(tableHeader('Service'));
|
|
|
1009 |
html.push(tableHeader('Delivery Date'));
|
|
|
1010 |
html.push(tableHeader('Duration (Days)'));
|
|
|
1011 |
html.push(tableHeader('Delivery Status'));
|
| 2 |
- |
1012 |
|
| 6 |
- |
1013 |
html.push('</tr>');
|
|
|
1014 |
html.push('</thead>');
|
|
|
1015 |
html.push('<tbody>');
|
|
|
1016 |
}
|
| 2 |
- |
1017 |
|
| 12 |
- |
1018 |
var orders = getJsonArray(obj.OrderArray.Order);
|
| 6 |
- |
1019 |
for (var entry = 0; entry < orders.length; entry++) {
|
|
|
1020 |
html_temp = [];
|
| 12 |
- |
1021 |
var order = obj.OrderArray.Order[entry];
|
| 2 |
- |
1022 |
|
| 6 |
- |
1023 |
html_temp.push('<tr>');
|
| 2 |
- |
1024 |
|
| 12 |
- |
1025 |
html_temp.push(tableCellDate(order.CreatedTime));
|
| 2 |
- |
1026 |
|
| 6 |
- |
1027 |
title = '';
|
|
|
1028 |
trackingNumber = '';
|
|
|
1029 |
service = '';
|
|
|
1030 |
quantity = '';
|
|
|
1031 |
finalValueFee = '';
|
|
|
1032 |
finalValueFeeAmount = 0.0;
|
|
|
1033 |
itemId = '';
|
| 2 |
- |
1034 |
|
| 12 |
- |
1035 |
var transactions = getJsonArray(order.TransactionArray.Transaction);
|
| 6 |
- |
1036 |
for (title = '', i = 0; i < transactions.length; i++) {
|
|
|
1037 |
if (i > 0) {
|
|
|
1038 |
title += '<br/>';
|
|
|
1039 |
quantity += '<br/>';
|
|
|
1040 |
itemId += '<br/>';
|
|
|
1041 |
}
|
|
|
1042 |
title += transactions[i].Item.Title;
|
|
|
1043 |
}
|
|
|
1044 |
html_temp.push(tableCell(title));
|
| 2 |
- |
1045 |
|
| 6 |
- |
1046 |
var trackingDetails = getJsonArray(transactions[0].ShippingDetails.ShipmentTrackingDetails);
|
|
|
1047 |
// only last 1
|
|
|
1048 |
for (i = 0; i < trackingDetails.length; i++) {
|
|
|
1049 |
trackingNumber = trackingDetails[i].ShippingCarrierUsed + ' ' + trackingDetails[i].ShipmentTrackingNumber;
|
|
|
1050 |
service = getCarrierService(trackingDetails[i].ShippingCarrierUsed, trackingDetails[i].ShipmentTrackingNumber, true);
|
|
|
1051 |
}
|
| 2 |
- |
1052 |
|
| 12 |
- |
1053 |
html_temp.push(tableCellHidden(order.OrderID));
|
|
|
1054 |
html_temp.push(tableCellLabel('ShippingCost' + order.OrderID));
|
|
|
1055 |
html_temp.push(tableCellAndLabel(order.ShippingAddress.CityName + ', ' + order.ShippingAddress.StateOrProvince + ' ' + order.ShippingAddress.PostalCode, 'DeliveryAddress' + trackingNumber.substr(trackingNumber.indexOf(' ') + 1)));
|
| 2 |
- |
1056 |
|
| 12 |
- |
1057 |
if (order.PaidTime !== undefined) {
|
|
|
1058 |
html_temp.push(tableCellDate(order.PaidTime));
|
| 6 |
- |
1059 |
} else {
|
|
|
1060 |
html_temp.push(tableCell(''));
|
|
|
1061 |
}
|
| 2 |
- |
1062 |
|
| 12 |
- |
1063 |
if (order.ShippedTime === undefined) {
|
| 6 |
- |
1064 |
html_temp.push(tableCellLabel('ShippedDate' + trackingNumber.substr(trackingNumber.indexOf(' ') + 1)));
|
|
|
1065 |
} else {
|
| 12 |
- |
1066 |
html_temp.push(tableCellDate(order.ShippedTime));
|
| 6 |
- |
1067 |
}
|
| 2 |
- |
1068 |
|
| 6 |
- |
1069 |
html_temp.push(tableCellAndLabel(trackingNumber, trackingNumber.substr(trackingNumber.indexOf(' ') + 1)));
|
|
|
1070 |
html_temp.push(tableCell(service));
|
|
|
1071 |
html_temp.push(tableCellLabel('DeliveryDate' + trackingNumber.substr(trackingNumber.indexOf(' ') + 1)));
|
|
|
1072 |
html_temp.push(tableCellLabel('DeliveryDays' + trackingNumber.substr(trackingNumber.indexOf(' ') + 1)));
|
|
|
1073 |
html_temp.push(tableCellLabel('DeliveryStatus' + trackingNumber.substr(trackingNumber.indexOf(' ') + 1)));
|
| 2 |
- |
1074 |
|
| 6 |
- |
1075 |
html_temp.push('</tr>');
|
|
|
1076 |
|
|
|
1077 |
if (trackingListDedupe.indexOf(trackingNumber.substr(trackingNumber.indexOf(' ') + 1)) == -1) {
|
|
|
1078 |
html.push(html_temp.join(''));
|
|
|
1079 |
trackingListDedupe.push(trackingNumber.substr(trackingNumber.indexOf(' ') + 1));
|
|
|
1080 |
}
|
|
|
1081 |
}
|
| 2 |
- |
1082 |
}
|
|
|
1083 |
|
|
|
1084 |
function printTrackingTotals() {
|
| 6 |
- |
1085 |
html.push('</tbody>');
|
|
|
1086 |
html.push('<tfoot class="w3-hide">');
|
|
|
1087 |
html.push('<tr>');
|
|
|
1088 |
html.push(tableCell(''));
|
|
|
1089 |
html.push('</tr>');
|
|
|
1090 |
html.push('</tfoot>');
|
|
|
1091 |
html.push('</table>');
|
|
|
1092 |
html.push('</div>');
|
| 2 |
- |
1093 |
}
|
|
|
1094 |
|
|
|
1095 |
function getCarrierService(carrier, trackingNumber, flag) {
|
| 6 |
- |
1096 |
if (flag && trackingList.indexOf(trackingNumber) == -1) {
|
|
|
1097 |
trackingList.push(trackingNumber);
|
|
|
1098 |
}
|
| 2 |
- |
1099 |
|
| 6 |
- |
1100 |
if (carrier == "USPS") {
|
|
|
1101 |
if (trackingNumber.startsWith("9449")) {
|
|
|
1102 |
return ("Media Mail");
|
|
|
1103 |
} else if (trackingNumber.startsWith("9450")) {
|
|
|
1104 |
return ("Media Mail, Insured");
|
|
|
1105 |
} else if (trackingNumber.startsWith("94001")) {
|
|
|
1106 |
return ("First Class");
|
|
|
1107 |
} else if (trackingNumber.startsWith("9416")) {
|
|
|
1108 |
return ("First Class, Insured");
|
|
|
1109 |
} else if (trackingNumber.startsWith("92055")) {
|
|
|
1110 |
return ("Priority Mail");
|
|
|
1111 |
} else if (trackingNumber.startsWith("94073")) {
|
|
|
1112 |
return ("Certified Mail");
|
|
|
1113 |
} else if (trackingNumber.startsWith("93033")) {
|
|
|
1114 |
return ("Collect on Delivery");
|
|
|
1115 |
} else if (trackingNumber.startsWith("82")) {
|
|
|
1116 |
return ("Global Express");
|
|
|
1117 |
} else if (trackingNumber.startsWith("EC")) {
|
|
|
1118 |
return ("Priority Mail Express International");
|
|
|
1119 |
} else if (trackingNumber.startsWith("92701") || trackingNumber.startsWith("EA")) {
|
|
|
1120 |
return ("Priority Mail Express");
|
|
|
1121 |
} else if (trackingNumber.startsWith("CP")) {
|
|
|
1122 |
return ("Priority Mail International");
|
|
|
1123 |
} else if (trackingNumber.startsWith("92088")) {
|
|
|
1124 |
return ("Registered Mail");
|
|
|
1125 |
} else if (trackingNumber.startsWith("92021")) {
|
|
|
1126 |
return ("Signature Confirmation");
|
|
|
1127 |
} else if (trackingNumber.startsWith("9461") || trackingNumber.startsWith("9462")) {
|
|
|
1128 |
return ("Parcel Select Ground");
|
|
|
1129 |
} else if (trackingNumber.startsWith("92021")) {
|
|
|
1130 |
return ("Signature Confirmation");
|
|
|
1131 |
}
|
|
|
1132 |
} else if (carrier == "UPS") {
|
|
|
1133 |
if (trackingNumber.startsWith("1Z")) {
|
|
|
1134 |
var service = trackingNumber.substr(8, 2);
|
| 2 |
- |
1135 |
|
| 6 |
- |
1136 |
if (service == '01') {
|
|
|
1137 |
return ('Next Day Air ("Red")');
|
|
|
1138 |
} else if (service == '02') {
|
|
|
1139 |
return ('UPS United States Second Day Air ("Blue")');
|
|
|
1140 |
} else if (service == '03') {
|
|
|
1141 |
return ('Ground');
|
|
|
1142 |
} else if (service == '12') {
|
|
|
1143 |
return ('Third Day Select');
|
|
|
1144 |
} else if (service == '13') {
|
|
|
1145 |
return ('Next Day Air Saver ("Red Saver")');
|
|
|
1146 |
} else if (service == '15') {
|
|
|
1147 |
return ('Next Day Air Early A.M.');
|
|
|
1148 |
} else if (service == '22') {
|
|
|
1149 |
return ('Ground - Returns Plus - Three Pickup Attempts');
|
|
|
1150 |
} else if (service == '32') {
|
|
|
1151 |
return ('Next Day Air Early A.M. - COD');
|
|
|
1152 |
} else if (service == '33') {
|
|
|
1153 |
return ('Next Day Air Early A.M. - Saturday Delivery, COD');
|
|
|
1154 |
} else if (service == '41') {
|
|
|
1155 |
return ('Next Day Air Early A.M. - Saturday Delivery');
|
|
|
1156 |
} else if (service == '42') {
|
|
|
1157 |
return ('Ground - Signature Required');
|
|
|
1158 |
} else if (service == '44') {
|
|
|
1159 |
return ('Next Day Air - Saturday Delivery');
|
|
|
1160 |
} else if (service == '66') {
|
|
|
1161 |
return ('Worldwide Express');
|
|
|
1162 |
} else if (service == '72') {
|
|
|
1163 |
return ('Ground - Collect on Delivery');
|
|
|
1164 |
} else if (service == '78') {
|
|
|
1165 |
return ('Ground - Returns Plus - One Pickup Attempt');
|
|
|
1166 |
} else if (service == '90') {
|
|
|
1167 |
return ('Ground - Returns - UPS Prints and Mails Label');
|
|
|
1168 |
} else if (service == 'A0') {
|
|
|
1169 |
return ('Next Day Air Early A.M. - Adult Signature Required');
|
|
|
1170 |
} else if (service == 'A1') {
|
|
|
1171 |
return ('Next Day Air Early A.M. - Saturday Delivery, Adult Signature Required');
|
|
|
1172 |
} else if (service == 'A2') {
|
|
|
1173 |
return ('Next Day Air - Adult Signature Required');
|
|
|
1174 |
} else if (service == 'A8') {
|
|
|
1175 |
return ('Ground - Adult Signature Required');
|
|
|
1176 |
} else if (service == 'A9') {
|
|
|
1177 |
return ('Next Day Air Early A.M. - Adult Signature Required, COD');
|
|
|
1178 |
} else if (service == 'AA') {
|
|
|
1179 |
return ('Next Day Air Early A.M. - Saturday Delivery, Adult Signature Required, COD');
|
|
|
1180 |
}
|
|
|
1181 |
}
|
|
|
1182 |
}
|
| 2 |
- |
1183 |
|
| 6 |
- |
1184 |
return ("");
|
| 2 |
- |
1185 |
}
|
|
|
1186 |
|
|
|
1187 |
function retrieveFees(pageNumber) {
|
| 6 |
- |
1188 |
var i;
|
|
|
1189 |
var xml;
|
|
|
1190 |
var authErrorFlag = false;
|
| 2 |
- |
1191 |
|
| 6 |
- |
1192 |
if (eBayAuthTokenFlag === false) {
|
|
|
1193 |
return;
|
|
|
1194 |
}
|
| 2 |
- |
1195 |
|
| 6 |
- |
1196 |
var valueStartDate = document.getElementById('startDate').value + "T00:00:00.000Z";
|
|
|
1197 |
var valueEndDate = document.getElementById('endDate').value + "T23:59:59.999Z";
|
| 2 |
- |
1198 |
|
| 6 |
- |
1199 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
1200 |
var xhr = new XMLHttpRequest();
|
| 2 |
- |
1201 |
|
| 6 |
- |
1202 |
xw.writeStartDocument();
|
|
|
1203 |
xw.writeStartElement("GetAccountRequest");
|
|
|
1204 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
| 2 |
- |
1205 |
|
| 6 |
- |
1206 |
xw.writeStartElement('RequesterCredentials');
|
|
|
1207 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
1208 |
xw.writeEndElement(); /* RequesterCredentials */
|
| 2 |
- |
1209 |
|
| 6 |
- |
1210 |
xw.writeElementString('AccountEntrySortType', 'AccountEntryCreatedTimeAscending');
|
|
|
1211 |
xw.writeElementString('AccountHistorySelection', 'BetweenSpecifiedDates');
|
|
|
1212 |
xw.writeElementString('BeginDate', valueStartDate);
|
|
|
1213 |
xw.writeElementString('EndDate', valueEndDate);
|
|
|
1214 |
xw.writeElementString('ExcludeBalance', 'true');
|
|
|
1215 |
xw.writeElementString('ExcludeSummary', 'true');
|
| 2 |
- |
1216 |
|
| 6 |
- |
1217 |
xw.writeStartElement('Pagination');
|
|
|
1218 |
xw.writeElementString('EntriesPerPage', configXmlRequestEntriesPerPage);
|
|
|
1219 |
xw.writeElementString('PageNumber', pageNumber.toString());
|
|
|
1220 |
xw.writeEndElement(); /* Pagination */
|
| 2 |
- |
1221 |
|
| 6 |
- |
1222 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
1223 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
1224 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
| 2 |
- |
1225 |
|
| 6 |
- |
1226 |
xw.writeEndElement(); /* GetAccountRequest */
|
|
|
1227 |
xw.writeEndDocument();
|
| 2 |
- |
1228 |
|
| 6 |
- |
1229 |
xhr.open('POST', configProxyUrl, true);
|
|
|
1230 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
1231 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
1232 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
1233 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', 'GetAccount');
|
|
|
1234 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
1235 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
1236 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
1237 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
| 2 |
- |
1238 |
|
| 6 |
- |
1239 |
xml = xw.flush();
|
|
|
1240 |
xw.close();
|
| 2 |
- |
1241 |
|
| 6 |
- |
1242 |
xhr.onload = () => {
|
| 12 |
- |
1243 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
1244 |
var obj = jsonObj.GetAccountResponse;
|
| 6 |
- |
1245 |
var returnCode = obj.Ack;
|
| 2 |
- |
1246 |
|
| 6 |
- |
1247 |
var x = document.getElementById("results");
|
|
|
1248 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
1249 |
x.className += " w3-show";
|
|
|
1250 |
}
|
| 2 |
- |
1251 |
|
| 6 |
- |
1252 |
if (obj.Message) {
|
|
|
1253 |
x.innerHTML += "<p>" + obj.Message + "</p>";
|
|
|
1254 |
}
|
| 2 |
- |
1255 |
|
| 6 |
- |
1256 |
if (returnCode == 'Success' || (returnCode == 'Warning' && obj.Errors.ErrorCode == '21917182')) {
|
|
|
1257 |
createFeeTable(obj, pageNumber);
|
| 2 |
- |
1258 |
|
| 12 |
- |
1259 |
x.innerHTML += '<p><strong>' + returnCode + ' (Fees/Credits ' + pageNumber + ' / ' + obj.PaginationResult.TotalNumberOfPages + ')</strong></p>';
|
| 2 |
- |
1260 |
|
| 6 |
- |
1261 |
if (obj.HasMoreEntries == 'true') {
|
|
|
1262 |
++pagesToProcess;
|
|
|
1263 |
++maxPagesToProcess;
|
|
|
1264 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
1265 |
retrieveFees(pageNumber + 1);
|
|
|
1266 |
}
|
| 2 |
- |
1267 |
|
| 6 |
- |
1268 |
document.getElementById("logging").innerHTML = html.join('');
|
| 2 |
- |
1269 |
|
| 6 |
- |
1270 |
--pagesToProcess;
|
|
|
1271 |
++pagesProcessed;
|
|
|
1272 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
1273 |
} else {
|
|
|
1274 |
x.className += " process-errors";
|
|
|
1275 |
x.innerHTML += "<p><strong>" + returnCode + ":</strong></p>";
|
| 2 |
- |
1276 |
|
| 6 |
- |
1277 |
var errors = getJsonArray(obj.Errors);
|
|
|
1278 |
x.innerHTML += "<p>";
|
|
|
1279 |
for (i = 0; i < errors.length; i++) {
|
|
|
1280 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
|
|
1281 |
if (errors[i].LongMessage.includes('Auth')) {
|
|
|
1282 |
authErrorFlag = true;
|
|
|
1283 |
}
|
|
|
1284 |
}
|
|
|
1285 |
x.innerHTML += "</p>";
|
| 2 |
- |
1286 |
|
| 6 |
- |
1287 |
if (authErrorFlag === true) {
|
|
|
1288 |
eBayAuthTokenFlag = false;
|
|
|
1289 |
x = document.getElementById("login");
|
|
|
1290 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
1291 |
x.className += " w3-show";
|
|
|
1292 |
}
|
|
|
1293 |
}
|
| 2 |
- |
1294 |
|
| 6 |
- |
1295 |
--pagesToProcess;
|
|
|
1296 |
++pagesProcessed;
|
|
|
1297 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
1298 |
}
|
|
|
1299 |
};
|
| 2 |
- |
1300 |
|
| 6 |
- |
1301 |
xhr.send(xml);
|
| 2 |
- |
1302 |
|
| 6 |
- |
1303 |
function checkpagesToProcess() {
|
|
|
1304 |
if (pagesToProcess > 0) {
|
|
|
1305 |
window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds
|
|
|
1306 |
} else {
|
|
|
1307 |
sortTable("feeTable", 1);
|
|
|
1308 |
x = document.getElementById("results");
|
|
|
1309 |
x.innerHTML += '<p><strong>Report Finished!</strong></p>';
|
| 2 |
- |
1310 |
|
| 6 |
- |
1311 |
endProgressBar();
|
|
|
1312 |
|
|
|
1313 |
var y = document.getElementById("dlFeeListButton");
|
|
|
1314 |
if (y.className.indexOf("w3-show") == -1) {
|
|
|
1315 |
y.className += " w3-show";
|
|
|
1316 |
}
|
|
|
1317 |
|
|
|
1318 |
if (!x.className.includes("process-errors")) {
|
|
|
1319 |
setTimeout(function() {
|
|
|
1320 |
x.className = x.className.replace(" w3-show", "");
|
|
|
1321 |
}, 3000);
|
|
|
1322 |
}
|
|
|
1323 |
}
|
|
|
1324 |
}
|
|
|
1325 |
|
|
|
1326 |
if (pageNumber == 1) {
|
|
|
1327 |
checkpagesToProcess();
|
|
|
1328 |
}
|
| 2 |
- |
1329 |
}
|
|
|
1330 |
|
|
|
1331 |
function createFeeTable(obj, pageNumber) {
|
| 6 |
- |
1332 |
var i;
|
| 2 |
- |
1333 |
|
| 6 |
- |
1334 |
if (pageNumber == 1) {
|
|
|
1335 |
totalAmount = 0;
|
| 2 |
- |
1336 |
|
| 6 |
- |
1337 |
document.getElementById("logging").innerHTML = '';
|
|
|
1338 |
html = [];
|
| 2 |
- |
1339 |
|
| 6 |
- |
1340 |
html.push('<h3>Fees and Credits List from ' + document.getElementById("startDate").value + ' to ' + document.getElementById("endDate").value + '</h3>');
|
|
|
1341 |
html.push('<table id="feeTable" class="w3-table-all w3-small">');
|
|
|
1342 |
html.push('<thead>');
|
|
|
1343 |
html.push('<tr>');
|
| 2 |
- |
1344 |
|
| 6 |
- |
1345 |
html.push(tableHeader('Item ID'));
|
|
|
1346 |
html.push(tableHeader('Title'));
|
|
|
1347 |
html.push(tableHeader('Date'));
|
|
|
1348 |
html.push(tableHeader('Fee Type'));
|
|
|
1349 |
html.push(tableHeader('Amount'));
|
| 2 |
- |
1350 |
|
| 6 |
- |
1351 |
html.push('</tr>');
|
|
|
1352 |
html.push('</thead>');
|
|
|
1353 |
html.push('<tbody>');
|
|
|
1354 |
}
|
| 2 |
- |
1355 |
|
| 12 |
- |
1356 |
for (i = 0; i < obj.AccountEntries.AccountEntry.length; i++) {
|
|
|
1357 |
var AccountEntry = obj.AccountEntries.AccountEntry[i];
|
|
|
1358 |
if ((!AccountEntry.Description.includes('Payment') && !AccountEntry.Description.includes('Final Value Fee') && AccountEntry.GrossDetailAmount.text != '0.0' && AccountEntry.NetDetailAmount.text != '0.0') ||
|
|
|
1359 |
(AccountEntry.Description.includes('Final Value Fee') && AccountEntry.NetDetailAmount.text.substr(0, 1) == '-')) {
|
| 6 |
- |
1360 |
html.push('<tr>');
|
| 2 |
- |
1361 |
|
| 12 |
- |
1362 |
html.push(tableCell(AccountEntry.ItemID));
|
|
|
1363 |
html.push(tableCell(AccountEntry.Title));
|
|
|
1364 |
html.push(tableCellDate(AccountEntry.Date));
|
|
|
1365 |
html.push(tableCell(AccountEntry.Description));
|
|
|
1366 |
html.push(tableCell('$' + parseFloat(AccountEntry.GrossDetailAmount.text).toFixed(2)));
|
|
|
1367 |
totalAmount += parseFloat(AccountEntry.GrossDetailAmount.text);
|
| 2 |
- |
1368 |
|
| 6 |
- |
1369 |
html.push('</tr>');
|
|
|
1370 |
}
|
|
|
1371 |
}
|
| 2 |
- |
1372 |
|
| 6 |
- |
1373 |
if (obj.HasMoreEntries != 'true') {
|
|
|
1374 |
html.push('</tbody>');
|
|
|
1375 |
html.push('<tfoot>');
|
|
|
1376 |
html.push('<tr>');
|
|
|
1377 |
html.push(tableCell('<strong>Totals</strong>'));
|
|
|
1378 |
html.push(tableCell(''));
|
|
|
1379 |
html.push(tableCell(''));
|
|
|
1380 |
html.push(tableCell(''));
|
|
|
1381 |
html.push(tableCell('<strong>$' + totalAmount.toFixed(2) + '</strong>'));
|
|
|
1382 |
html.push('</tr>');
|
|
|
1383 |
html.push('</tfoot>');
|
|
|
1384 |
html.push('</table>');
|
|
|
1385 |
}
|
| 2 |
- |
1386 |
}
|
|
|
1387 |
|
|
|
1388 |
|
|
|
1389 |
function tableCellDate(utcDate) {
|
| 6 |
- |
1390 |
var localDate = new Date(utcDate);
|
|
|
1391 |
return ('<td>' + localDate.yyyymmdd() + '</td>');
|
| 2 |
- |
1392 |
}
|
|
|
1393 |
|
|
|
1394 |
function tableCellSKU(str, title) {
|
| 6 |
- |
1395 |
if (str === undefined) {
|
|
|
1396 |
str = '';
|
|
|
1397 |
}
|
| 2 |
- |
1398 |
|
| 6 |
- |
1399 |
if (str.indexOf(" - ") > 0) {
|
|
|
1400 |
str = str.substr(0, str.indexOf(" - "));
|
|
|
1401 |
}
|
| 2 |
- |
1402 |
|
| 6 |
- |
1403 |
if (str.startsWith("Batch")) {
|
|
|
1404 |
var batchNo = Number(str.substr(6));
|
|
|
1405 |
str = "Batch " + pad(batchNo, 2);
|
|
|
1406 |
}
|
| 2 |
- |
1407 |
|
| 6 |
- |
1408 |
if (title.includes('(DVD') || title.includes('(HD') || title.includes('(Blu')) {
|
|
|
1409 |
str = 'DVD ' + str;
|
|
|
1410 |
} else if (title.includes('(CD')) {
|
|
|
1411 |
str = 'CD ' + str;
|
|
|
1412 |
} else if (title.includes('Hardcover') || title.includes('Paperback')) {
|
|
|
1413 |
str = 'Book ' + str;
|
|
|
1414 |
}
|
| 2 |
- |
1415 |
|
| 6 |
- |
1416 |
return ('<td>' + str + '</td>');
|
| 2 |
- |
1417 |
}
|
|
|
1418 |
|
|
|
1419 |
function sortTable(tableName, column) {
|
| 6 |
- |
1420 |
var table, rows, switching, i, x, y, shouldSwitch;
|
|
|
1421 |
--column; // column parameter starts with 1
|
|
|
1422 |
table = document.getElementById(tableName);
|
|
|
1423 |
switching = true;
|
|
|
1424 |
/*Make a loop that will continue until
|
|
|
1425 |
no switching has been done:*/
|
|
|
1426 |
while (switching) {
|
|
|
1427 |
//start by saying: no switching is done:
|
|
|
1428 |
switching = false;
|
|
|
1429 |
rows = table.getElementsByTagName("TR");
|
|
|
1430 |
/*Loop through all table rows (except the
|
|
|
1431 |
first, which contains table headers, and the last
|
|
|
1432 |
which contains the table footers):*/
|
|
|
1433 |
for (i = 1; i < (rows.length - 2); i++) {
|
|
|
1434 |
//start by saying there should be no switching:
|
|
|
1435 |
shouldSwitch = false;
|
|
|
1436 |
/*Get the two elements you want to compare,
|
|
|
1437 |
one from current row and one from the next:*/
|
|
|
1438 |
x = rows[i].getElementsByTagName("TD")[column];
|
|
|
1439 |
y = rows[i + 1].getElementsByTagName("TD")[column];
|
|
|
1440 |
//check if the two rows should switch place:
|
|
|
1441 |
if (x !== undefined && x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
|
|
|
1442 |
//if so, mark as a switch and break the loop:
|
|
|
1443 |
shouldSwitch = true;
|
|
|
1444 |
break;
|
|
|
1445 |
}
|
|
|
1446 |
}
|
|
|
1447 |
if (shouldSwitch) {
|
|
|
1448 |
/*If a switch has been marked, make the switch
|
|
|
1449 |
and mark that a switch has been done:*/
|
|
|
1450 |
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
|
|
1451 |
switching = true;
|
|
|
1452 |
}
|
|
|
1453 |
}
|
| 2 |
- |
1454 |
}
|
|
|
1455 |
|
|
|
1456 |
function printData() {
|
| 6 |
- |
1457 |
var printContent = document.getElementById("printTable");
|
| 2 |
- |
1458 |
|
| 6 |
- |
1459 |
var num;
|
|
|
1460 |
var cssReference = [];
|
|
|
1461 |
var uniqueName = new Date();
|
| 2 |
- |
1462 |
|
| 6 |
- |
1463 |
var windowName = 'Print' + uniqueName.getTime();
|
|
|
1464 |
var printWindow = window.open(num, windowName, 'left=50000,top=50000,width=0,height=0');
|
|
|
1465 |
cssReference[0] = printWindow.document.createElement("link");
|
|
|
1466 |
cssReference[0].href = "https://www.w3schools.com/w3css/4/w3.css";
|
|
|
1467 |
cssReference[0].rel = "stylesheet";
|
|
|
1468 |
cssReference[0].type = "text/css";
|
|
|
1469 |
cssReference[1] = printWindow.document.createElement("link");
|
|
|
1470 |
cssReference[1].href = "css/style.css";
|
|
|
1471 |
cssReference[1].rel = "stylesheet";
|
|
|
1472 |
cssReference[1].type = "text/css";
|
| 2 |
- |
1473 |
|
| 6 |
- |
1474 |
printWindow.document.write(printContent.outerHTML);
|
|
|
1475 |
printWindow.document.getElementsByTagName('head')[0].appendChild(cssReference[0]);
|
|
|
1476 |
printWindow.document.getElementsByTagName('head')[0].appendChild(cssReference[1]);
|
| 2 |
- |
1477 |
|
| 6 |
- |
1478 |
printWindow.document.close();
|
|
|
1479 |
printWindow.focus();
|
|
|
1480 |
printWindow.print();
|
|
|
1481 |
printWindow.close();
|
| 2 |
- |
1482 |
}
|
|
|
1483 |
|
|
|
1484 |
function printSummary() {
|
| 6 |
- |
1485 |
var profit = grossSales + shippingRcvd - shippingCost - eBayFees - PayPalFees - VATaxAmount;
|
| 2 |
- |
1486 |
|
| 7 |
- |
1487 |
var x = document.getElementById("summary");
|
|
|
1488 |
if (x.className.indexOf(" w3-card-2") == -1) {
|
|
|
1489 |
x.className += " w3-card-2";
|
|
|
1490 |
}
|
|
|
1491 |
|
|
|
1492 |
x.innerHTML = '<h2>Profit: ' + profit.toFixed(2) + '</h3>';
|
| 2 |
- |
1493 |
}
|
|
|
1494 |
|
|
|
1495 |
function findThumbNails() {
|
| 6 |
- |
1496 |
var i;
|
|
|
1497 |
var x = document.getElementById("shippingTable");
|
| 2 |
- |
1498 |
|
| 6 |
- |
1499 |
thumbnailsToProcess = 0;
|
|
|
1500 |
thumbnailsProcessed = 0;
|
|
|
1501 |
maxThumbnailsToProcess = 0;
|
|
|
1502 |
initProgressBar("");
|
| 2 |
- |
1503 |
|
| 6 |
- |
1504 |
for (i = 1; i < (x.rows.length - 1); i++) {
|
|
|
1505 |
if (x.rows[i].cells[7].innerHTML == 'eBay' && x.rows[i].cells[2] !== undefined && x.rows[i].cells[2].innerHTML.length < 1) {
|
|
|
1506 |
++thumbnailsToProcess;
|
|
|
1507 |
++maxThumbnailsToProcess;
|
|
|
1508 |
updateProgressBar(maxThumbnailsToProcess, thumbnailsProcessed);
|
|
|
1509 |
getThumbNail(x.rows[i].cells[4].innerHTML);
|
|
|
1510 |
} else if (x.rows[i].cells[7].innerHTML == 'Shopify' && x.rows[i].cells[2] !== undefined && x.rows[i].cells[2].innerHTML.length > 0) {
|
|
|
1511 |
++thumbnailsToProcess;
|
|
|
1512 |
++maxThumbnailsToProcess;
|
|
|
1513 |
updateProgressBar(maxThumbnailsToProcess, thumbnailsProcessed);
|
|
|
1514 |
getShopifyThumbNail(x.rows[i].cells[2].innerHTML);
|
|
|
1515 |
}
|
|
|
1516 |
}
|
| 2 |
- |
1517 |
|
| 6 |
- |
1518 |
function checkthumbnailsToProcess() {
|
|
|
1519 |
if (thumbnailsToProcess > 0) {
|
|
|
1520 |
window.setTimeout(checkthumbnailsToProcess, 100); // wait 100 milliseconds
|
|
|
1521 |
} else {
|
|
|
1522 |
endProgressBar();
|
|
|
1523 |
x = document.getElementById("results");
|
|
|
1524 |
x.innerHTML += '<p><strong>Report Finished!</strong></p>';
|
|
|
1525 |
if (!x.className.includes("process-errors")) {
|
|
|
1526 |
setTimeout(function() {
|
|
|
1527 |
x.className = x.className.replace(" w3-show", "");
|
|
|
1528 |
}, 3000);
|
|
|
1529 |
}
|
|
|
1530 |
}
|
|
|
1531 |
}
|
| 2 |
- |
1532 |
|
| 6 |
- |
1533 |
checkthumbnailsToProcess();
|
| 2 |
- |
1534 |
}
|
|
|
1535 |
|
|
|
1536 |
function getThumbNail(itemId) {
|
| 6 |
- |
1537 |
// Construct the getSingleItem request
|
|
|
1538 |
url = configeBayShopping + "?";
|
|
|
1539 |
url += "callname=GetSingleItem";
|
|
|
1540 |
url += "&responseencoding=JSON";
|
|
|
1541 |
url += "&appid=" + configAppid;
|
|
|
1542 |
url += "&version=" + configeBayShoppingVersion;
|
|
|
1543 |
url += "&ItemID=";
|
|
|
1544 |
url += itemId;
|
| 2 |
- |
1545 |
|
| 6 |
- |
1546 |
var xhttp = new XMLHttpRequest();
|
| 2 |
- |
1547 |
|
| 6 |
- |
1548 |
xhttp.onreadystatechange = function() {
|
|
|
1549 |
if (this.readyState == 4) {
|
|
|
1550 |
_cb_getThumbNail(JSON.parse(this.responseText));
|
|
|
1551 |
}
|
|
|
1552 |
};
|
| 2 |
- |
1553 |
|
| 6 |
- |
1554 |
xhttp.open("GET", configProxyUrl, true);
|
|
|
1555 |
xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
|
|
|
1556 |
xhttp.send();
|
| 2 |
- |
1557 |
}
|
|
|
1558 |
|
|
|
1559 |
function _cb_getThumbNail(root) {
|
| 6 |
- |
1560 |
var ack = root.Ack;
|
| 2 |
- |
1561 |
|
| 6 |
- |
1562 |
if (ack == 'Failure' || ack == 'PartialFailure') {
|
|
|
1563 |
return;
|
|
|
1564 |
}
|
| 2 |
- |
1565 |
|
| 6 |
- |
1566 |
var JsonObj = typeof root.Item != 'object' ? JSON.parse(root.Item) : root.Item;
|
|
|
1567 |
var ItemID = JsonObj.ItemID;
|
|
|
1568 |
var PictureURL = getJsonArray(JsonObj.PictureURL);
|
| 2 |
- |
1569 |
|
| 6 |
- |
1570 |
document.getElementById('PictureURL' + ItemID).innerHTML = '<img src="' + PictureURL[0] + '" style="max-height:100px">';
|
|
|
1571 |
--thumbnailsToProcess;
|
|
|
1572 |
++thumbnailsProcessed;
|
|
|
1573 |
updateProgressBar(maxThumbnailsToProcess, thumbnailsProcessed);
|
| 2 |
- |
1574 |
}
|
|
|
1575 |
|
|
|
1576 |
function getShopifyThumbNail(productId) {
|
| 6 |
- |
1577 |
var xhttp = new XMLHttpRequest();
|
|
|
1578 |
xhttp.onreadystatechange = function() {
|
|
|
1579 |
if (this.readyState == 4 && this.status == 200) {
|
|
|
1580 |
//window.alert(this.responseText);
|
|
|
1581 |
var json = JSON.parse(this.responseText);
|
|
|
1582 |
if (json.product !== undefined) {
|
|
|
1583 |
document.getElementById('PictureURL' + productId).innerHTML = '<img src="' + json.product.image.src + '" style="max-height:100px">';
|
|
|
1584 |
}
|
|
|
1585 |
--thumbnailsToProcess;
|
|
|
1586 |
++thumbnailsProcessed;
|
|
|
1587 |
updateProgressBar(maxThumbnailsToProcess, thumbnailsProcessed);
|
|
|
1588 |
}
|
|
|
1589 |
};
|
| 2 |
- |
1590 |
|
| 6 |
- |
1591 |
xhttp.open("GET", configProxyUrl, true);
|
|
|
1592 |
xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + 'products/' + productId + '.json?fields=image'));
|
|
|
1593 |
xhttp.send();
|
| 2 |
- |
1594 |
}
|
|
|
1595 |
|
|
|
1596 |
function findShippingCosts() {
|
| 6 |
- |
1597 |
var i;
|
|
|
1598 |
var x;
|
| 2 |
- |
1599 |
|
| 6 |
- |
1600 |
shippingsToProcess = 0;
|
|
|
1601 |
shippingsProcessed = 0;
|
|
|
1602 |
maxShippingsToProcess = 0;
|
|
|
1603 |
initProgressBar("Retrieving Shipping Costs...");
|
| 2 |
- |
1604 |
|
| 6 |
- |
1605 |
if (getRadioValue('rptType') == 'trackingList') {
|
|
|
1606 |
x = document.getElementById("trackingTable");
|
|
|
1607 |
} else {
|
|
|
1608 |
x = document.getElementById("orderTable");
|
|
|
1609 |
}
|
| 2 |
- |
1610 |
|
| 6 |
- |
1611 |
for (i = (x.rows.length - 1); i > 0; i--) {
|
|
|
1612 |
if (getRadioValue('rptType') == 'trackingList') {
|
|
|
1613 |
if (x.rows[i].cells[3] !== undefined && x.rows[i].cells[3].innerHTML.length < 1) {
|
|
|
1614 |
if (x.rows[i].cells[7] !== undefined && x.rows[i].cells[7].innerHTML.length < 1) {
|
|
|
1615 |
document.getElementById("trackingTable").deleteRow(i);
|
|
|
1616 |
} else {
|
|
|
1617 |
++shippingsToProcess;
|
|
|
1618 |
++maxShippingsToProcess;
|
|
|
1619 |
updateProgressBar(maxShippingsToProcess, shippingsProcessed);
|
|
|
1620 |
getShippingCost(x.rows[i].cells[2].innerHTML);
|
|
|
1621 |
}
|
|
|
1622 |
}
|
|
|
1623 |
} else {
|
|
|
1624 |
if (x.rows[i].cells[5].innerHTML == 'eBay' && x.rows[i].cells[9] !== undefined && x.rows[i].cells[9].innerHTML.length < 1) {
|
|
|
1625 |
++shippingsToProcess;
|
|
|
1626 |
++maxShippingsToProcess;
|
|
|
1627 |
updateProgressBar(maxShippingsToProcess, shippingsProcessed);
|
|
|
1628 |
getShippingCost(x.rows[i].cells[2].innerHTML);
|
|
|
1629 |
} else if (x.rows[i].cells[5].innerHTML == 'Shopify') {
|
|
|
1630 |
++shippingsToProcess;
|
|
|
1631 |
++maxShippingsToProcess;
|
|
|
1632 |
updateProgressBar(maxShippingsToProcess, shippingsProcessed);
|
|
|
1633 |
getPaymentTransaction(x.rows[i].cells[2].innerHTML);
|
|
|
1634 |
}
|
|
|
1635 |
}
|
|
|
1636 |
}
|
| 2 |
- |
1637 |
|
| 6 |
- |
1638 |
function checkshippingsToProcess() {
|
|
|
1639 |
if (shippingsToProcess > 0) {
|
|
|
1640 |
window.setTimeout(checkshippingsToProcess, 100); // wait 100 milliseconds
|
|
|
1641 |
} else {
|
|
|
1642 |
endProgressBar();
|
|
|
1643 |
x = document.getElementById("results");
|
|
|
1644 |
if (getRadioValue('rptType') != 'trackingList') {
|
|
|
1645 |
document.getElementById("ShippingTotal").innerHTML = '<strong>$' + shippingCost.toFixed(2) + '</strong>';
|
|
|
1646 |
x.innerHTML += '<p><strong>Report Finished!</strong></p>';
|
|
|
1647 |
if (!x.className.includes("process-errors")) {
|
|
|
1648 |
setTimeout(function() {
|
|
|
1649 |
x.className = x.className.replace(" w3-show", "");
|
|
|
1650 |
}, 3000);
|
|
|
1651 |
}
|
|
|
1652 |
} else {
|
|
|
1653 |
x.innerHTML += '<p><strong>Retrieving Carrier Tracking...</strong></p>';
|
|
|
1654 |
getTrackingDetails();
|
|
|
1655 |
}
|
|
|
1656 |
}
|
|
|
1657 |
}
|
|
|
1658 |
|
|
|
1659 |
checkshippingsToProcess();
|
| 2 |
- |
1660 |
}
|
|
|
1661 |
|
|
|
1662 |
function getShippingCost(OrderId) {
|
| 6 |
- |
1663 |
var i;
|
|
|
1664 |
var xml;
|
|
|
1665 |
var correlationId;
|
|
|
1666 |
var shippingCostStr;
|
|
|
1667 |
var deliveryStatus;
|
|
|
1668 |
var authErrorFlag = false;
|
| 2 |
- |
1669 |
|
| 6 |
- |
1670 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
1671 |
var xhr = new XMLHttpRequest();
|
| 2 |
- |
1672 |
|
| 6 |
- |
1673 |
xw.writeStartDocument();
|
|
|
1674 |
xw.writeStartElement("GetSellingManagerSaleRecordRequest");
|
|
|
1675 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
| 2 |
- |
1676 |
|
| 6 |
- |
1677 |
xw.writeStartElement('RequesterCredentials');
|
|
|
1678 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
1679 |
xw.writeEndElement(); /* RequesterCredentials */
|
| 2 |
- |
1680 |
|
| 6 |
- |
1681 |
xw.writeElementString('OrderID', OrderId);
|
|
|
1682 |
xw.writeElementString('MessageID', OrderId);
|
| 2 |
- |
1683 |
|
| 6 |
- |
1684 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
1685 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
1686 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
| 2 |
- |
1687 |
|
| 6 |
- |
1688 |
xw.writeEndElement(); /* GetSellingManagerSaleRecordRequest */
|
|
|
1689 |
xw.writeEndDocument();
|
| 2 |
- |
1690 |
|
| 6 |
- |
1691 |
xhr.open('POST', configProxyUrl, true);
|
|
|
1692 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
1693 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
1694 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
1695 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', 'GetSellingManagerSaleRecord');
|
|
|
1696 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
1697 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
1698 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
1699 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
| 2 |
- |
1700 |
|
| 6 |
- |
1701 |
xml = xw.flush();
|
|
|
1702 |
xw.close();
|
| 2 |
- |
1703 |
|
| 6 |
- |
1704 |
xhr.onload = () => {
|
| 12 |
- |
1705 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
1706 |
var obj = jsonObj.GetSellingManagerSaleRecordResponse;
|
| 6 |
- |
1707 |
var returnCode = obj.Ack;
|
| 2 |
- |
1708 |
|
| 6 |
- |
1709 |
var x = document.getElementById("results");
|
|
|
1710 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
1711 |
x.className += " w3-show";
|
|
|
1712 |
}
|
| 2 |
- |
1713 |
|
| 6 |
- |
1714 |
if (obj.Message) {
|
|
|
1715 |
x.innerHTML += "<p>" + obj.Message + "</p>";
|
|
|
1716 |
}
|
| 2 |
- |
1717 |
|
| 6 |
- |
1718 |
if (returnCode == 'Success' || (returnCode == 'Warning' && obj.Errors.ErrorCode == '21917182')) {
|
|
|
1719 |
correlationId = obj.CorrelationID;
|
|
|
1720 |
deliveryStatus = '';
|
|
|
1721 |
shippingCostStr = '';
|
| 2 |
- |
1722 |
|
| 6 |
- |
1723 |
if (obj.SellingManagerSoldOrder.ActualShippingCost !== undefined &&
|
|
|
1724 |
obj.SellingManagerSoldOrder.ActualShippingCost.text != '0.0' &&
|
|
|
1725 |
document.getElementById('ShippingCost' + correlationId).innerHTML.length < 1) {
|
|
|
1726 |
shippingCostStr = '$' + parseFloat(obj.SellingManagerSoldOrder.ActualShippingCost.text).toFixed(2);
|
|
|
1727 |
shippingCost += parseFloat(obj.SellingManagerSoldOrder.ActualShippingCost.text);
|
|
|
1728 |
document.getElementById('ShippingCost' + correlationId).innerHTML = shippingCostStr;
|
|
|
1729 |
if (getRadioValue('rptType') == 'orderList') {
|
|
|
1730 |
printSummary();
|
|
|
1731 |
}
|
|
|
1732 |
}
|
| 2 |
- |
1733 |
|
| 6 |
- |
1734 |
if (getRadioValue('rptType') != 'trackingList') {
|
|
|
1735 |
var soldTransactions = getJsonArray(obj.SellingManagerSoldOrder.SellingManagerSoldTransaction);
|
|
|
1736 |
for (i = 0; i < soldTransactions.length; i++) {
|
|
|
1737 |
if (soldTransactions[i].Shipment.DeliveryStatus !== undefined) {
|
|
|
1738 |
deliveryStatus += (i > 0 ? '<br/>' : '') + soldTransactions[i].Shipment.DeliveryStatus;
|
|
|
1739 |
}
|
|
|
1740 |
}
|
|
|
1741 |
document.getElementById('Delivery' + correlationId).innerHTML = deliveryStatus;
|
|
|
1742 |
}
|
|
|
1743 |
} else {
|
|
|
1744 |
x.className += " process-errors";
|
|
|
1745 |
x.innerHTML += "<p><strong>" + returnCode + ":</strong></p>";
|
| 2 |
- |
1746 |
|
| 6 |
- |
1747 |
var errors = getJsonArray(obj.Errors);
|
|
|
1748 |
x.innerHTML += "<p>";
|
|
|
1749 |
for (i = 0; i < errors.length; i++) {
|
|
|
1750 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
|
|
1751 |
if (errors[i].LongMessage.includes('Auth')) {
|
|
|
1752 |
authErrorFlag = true;
|
|
|
1753 |
}
|
|
|
1754 |
}
|
|
|
1755 |
x.innerHTML += "</p>";
|
| 2 |
- |
1756 |
|
| 6 |
- |
1757 |
if (authErrorFlag === true) {
|
|
|
1758 |
eBayAuthTokenFlag = false;
|
|
|
1759 |
x = document.getElementById("login");
|
|
|
1760 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
1761 |
x.className += " w3-show";
|
|
|
1762 |
}
|
|
|
1763 |
}
|
|
|
1764 |
}
|
| 2 |
- |
1765 |
|
| 6 |
- |
1766 |
--shippingsToProcess;
|
|
|
1767 |
++shippingsProcessed;
|
|
|
1768 |
updateProgressBar(maxShippingsToProcess, shippingsProcessed);
|
|
|
1769 |
};
|
| 2 |
- |
1770 |
|
| 6 |
- |
1771 |
xhr.send(xml);
|
| 2 |
- |
1772 |
}
|
|
|
1773 |
|
|
|
1774 |
function getPaymentTransaction(fullId) {
|
| 6 |
- |
1775 |
var id = fullId.substr(0, fullId.indexOf(' '));
|
|
|
1776 |
var i;
|
|
|
1777 |
var transFee = 0.00;
|
|
|
1778 |
var transFeeStr = '';
|
|
|
1779 |
var transDate = '';
|
|
|
1780 |
var transId = '';
|
| 2 |
- |
1781 |
|
| 6 |
- |
1782 |
var xhttp = new XMLHttpRequest();
|
|
|
1783 |
xhttp.onreadystatechange = function() {
|
|
|
1784 |
if (this.readyState == 4 && this.status == 200) {
|
|
|
1785 |
//window.alert(this.responseText);
|
|
|
1786 |
var json = JSON.parse(this.responseText);
|
| 10 |
- |
1787 |
var transactions = getJsonArray(json.transactions);
|
|
|
1788 |
for (i = 0; i < transactions.length; i++) {
|
|
|
1789 |
transDate = getJsonValue(transactions[i].created_at).substr(0, 10);
|
|
|
1790 |
document.getElementById('PaidDate' + id).innerHTML = transDate;
|
| 2 |
- |
1791 |
|
| 10 |
- |
1792 |
var gateway = getJsonValue(transactions[i].gateway);
|
|
|
1793 |
if (gateway == 'shopify_payments') {
|
|
|
1794 |
transId = getJsonValue(transactions[i].id);
|
|
|
1795 |
transFee = Number(getJsonValue(transactions[i].receipt.fee_amount)) / 100;
|
|
|
1796 |
} else if (gateway == 'paypal') {
|
|
|
1797 |
transId = getJsonValue(transactions[i].authorization);
|
|
|
1798 |
transFee = Number(getJsonValue(transactions[i].receipt.fee_amount));
|
|
|
1799 |
} else if (gateway == 'manual') {
|
|
|
1800 |
transId = getJsonValue(json.transactions[i].id);
|
|
|
1801 |
}
|
| 2 |
- |
1802 |
|
| 10 |
- |
1803 |
document.getElementById('TransactionId' + id).innerHTML = transId;
|
| 2 |
- |
1804 |
|
| 10 |
- |
1805 |
transFeeStr = '$' + parseFloat(transFee).toFixed(2);
|
|
|
1806 |
PayPalFees += transFee;
|
|
|
1807 |
document.getElementById('Fee' + id).innerHTML = transFeeStr;
|
| 6 |
- |
1808 |
}
|
| 2 |
- |
1809 |
|
| 6 |
- |
1810 |
--shippingsToProcess;
|
|
|
1811 |
++shippingsProcessed;
|
|
|
1812 |
updateProgressBar(maxShippingsToProcess, shippingsProcessed);
|
|
|
1813 |
}
|
|
|
1814 |
};
|
| 2 |
- |
1815 |
|
| 6 |
- |
1816 |
xhttp.open("GET", configProxyUrl, true);
|
|
|
1817 |
xhttp.setRequestHeader("X-Proxy-Url", encodeURI(configShopifyUrl + configShopifyTransactionsUrl1 + id + configShopifyTransactionsUrl2));
|
|
|
1818 |
xhttp.send();
|
| 2 |
- |
1819 |
}
|
|
|
1820 |
|
|
|
1821 |
function getTrackingDetails() {
|
| 6 |
- |
1822 |
var i;
|
|
|
1823 |
var x;
|
| 2 |
- |
1824 |
|
| 6 |
- |
1825 |
trackingNumbersToProcess = 0;
|
|
|
1826 |
trackingNumbersProcessed = 0;
|
|
|
1827 |
maxTrackingNumbersToProcess = 0;
|
|
|
1828 |
initProgressBar("Retrieving Carrier Tracking...");
|
| 2 |
- |
1829 |
|
| 6 |
- |
1830 |
for (i = 0; i < trackingList.length; i++) {
|
|
|
1831 |
++trackingNumbersToProcess;
|
|
|
1832 |
++maxTrackingNumbersToProcess;
|
|
|
1833 |
if (trackingList[i].substr(0, 2) == '1Z') {
|
|
|
1834 |
getUPSTracking(trackingList[i]);
|
|
|
1835 |
} else {
|
|
|
1836 |
getUSPSTracking(trackingList[i]);
|
|
|
1837 |
}
|
|
|
1838 |
}
|
| 2 |
- |
1839 |
|
| 6 |
- |
1840 |
function checkTrackingsToProcess() {
|
|
|
1841 |
if (trackingNumbersToProcess > 0) {
|
|
|
1842 |
window.setTimeout(checkTrackingsToProcess, 100); // wait 100 milliseconds
|
|
|
1843 |
} else {
|
|
|
1844 |
endProgressBar();
|
|
|
1845 |
x = document.getElementById("results");
|
|
|
1846 |
x.innerHTML += '<p><strong>Report Finished!</strong></p>';
|
|
|
1847 |
if (!x.className.includes("process-errors")) {
|
|
|
1848 |
setTimeout(function() {
|
|
|
1849 |
x.className = x.className.replace(" w3-show", "");
|
|
|
1850 |
}, 3000);
|
|
|
1851 |
}
|
|
|
1852 |
}
|
|
|
1853 |
}
|
| 2 |
- |
1854 |
|
| 6 |
- |
1855 |
checkTrackingsToProcess();
|
| 2 |
- |
1856 |
}
|
|
|
1857 |
|
|
|
1858 |
function getUSPSTracking(searchNumber) {
|
| 6 |
- |
1859 |
var j;
|
|
|
1860 |
var str;
|
|
|
1861 |
var url;
|
|
|
1862 |
var trackingNumber;
|
|
|
1863 |
var summary;
|
|
|
1864 |
var detail;
|
|
|
1865 |
var deliveryDate;
|
|
|
1866 |
var createDate;
|
|
|
1867 |
var duration;
|
|
|
1868 |
var lastUpdate;
|
|
|
1869 |
var lastEvent;
|
|
|
1870 |
var footer;
|
| 2 |
- |
1871 |
|
| 6 |
- |
1872 |
var xhttp = new XMLHttpRequest();
|
|
|
1873 |
xhttp.onreadystatechange = function() {
|
|
|
1874 |
if (this.readyState == 4 && this.status == 200) {
|
| 12 |
- |
1875 |
var obj = XMLparse(this.responseXML, false);
|
| 2 |
- |
1876 |
|
| 12 |
- |
1877 |
if (obj.TrackResponse.TrackInfo.TrackSummary === undefined) {
|
| 6 |
- |
1878 |
--trackingNumbersToProcess;
|
|
|
1879 |
++trackingNumbersProcessed;
|
|
|
1880 |
updateProgressBar(maxTrackingNumbersToProcess, trackingNumbersProcessed);
|
|
|
1881 |
return;
|
|
|
1882 |
}
|
| 2 |
- |
1883 |
|
| 12 |
- |
1884 |
var trackingInfo = obj.TrackResponse.TrackInfo;
|
|
|
1885 |
|
|
|
1886 |
trackingNumber = trackingInfo.ID;
|
|
|
1887 |
summary = formatUSPSTrackingLine(trackingInfo.TrackSummary);
|
| 6 |
- |
1888 |
detail = '';
|
|
|
1889 |
footer = '';
|
|
|
1890 |
deliveryDate = '';
|
|
|
1891 |
duration = '';
|
|
|
1892 |
lastUpdate = summary.substr(8, 10);
|
| 12 |
- |
1893 |
lastEvent = trackingInfo.TrackSummary.Event;
|
| 2 |
- |
1894 |
|
| 6 |
- |
1895 |
if (document.getElementById('DeliveryStatus' + trackingNumber) === null) {
|
|
|
1896 |
--trackingNumbersToProcess;
|
|
|
1897 |
++trackingNumbersProcessed;
|
|
|
1898 |
updateProgressBar(maxTrackingNumbersToProcess, trackingNumbersProcessed);
|
|
|
1899 |
return;
|
|
|
1900 |
}
|
| 2 |
- |
1901 |
|
| 12 |
- |
1902 |
if (trackingInfo.TrackDetail !== undefined && trackingInfo.TrackDetail.length > 0) {
|
|
|
1903 |
for (j = 0; j < trackingInfo.TrackDetail.length; j++) {
|
|
|
1904 |
detail += formatUSPSTrackingLine(trackingInfo.TrackDetail[j]);
|
| 6 |
- |
1905 |
}
|
| 2 |
- |
1906 |
|
| 12 |
- |
1907 |
createDate = moment(trackingInfo.TrackDetail[(trackingInfo.TrackDetail.length - 1)].EventDate, "MMMM DD, YYYY").format('YYYY-MM-DD');
|
| 6 |
- |
1908 |
footer = 'Enroute since ' + createDate + ' (' + moment().diff(createDate, 'days') + ' days)';
|
| 2 |
- |
1909 |
|
| 6 |
- |
1910 |
if (summary.includes("Delivered")) {
|
|
|
1911 |
deliveryDate = summary.substr(8, 10);
|
|
|
1912 |
duration = moment(deliveryDate).diff(createDate, 'days');
|
|
|
1913 |
document.getElementById('DeliveryStatus' + trackingNumber).style.color = "green";
|
|
|
1914 |
footer = 'Delivered in ' + moment(deliveryDate).to(createDate, 'days');
|
|
|
1915 |
} else if (moment().diff(lastUpdate, 'days') > 3) {
|
|
|
1916 |
document.getElementById('DeliveryStatus' + trackingNumber).style.color = "red";
|
|
|
1917 |
}
|
|
|
1918 |
}
|
| 2 |
- |
1919 |
|
| 6 |
- |
1920 |
document.getElementById('DeliveryStatus' + trackingNumber).innerHTML = lastEvent;
|
|
|
1921 |
document.getElementById('DeliveryDays' + trackingNumber).innerHTML = duration;
|
|
|
1922 |
document.getElementById('DeliveryDate' + trackingNumber).innerHTML = deliveryDate;
|
| 2 |
- |
1923 |
|
| 6 |
- |
1924 |
str = document.getElementById(trackingNumber).innerHTML;
|
|
|
1925 |
if (!str.startsWith('<button')) {
|
|
|
1926 |
document.getElementById(trackingNumber).innerHTML = '<button onclick="document.getElementById(\'mod' + trackingNumber + '\').style.display=\'block\'" class="w3-button w3-black">' + str + '</button>';
|
| 2 |
- |
1927 |
|
| 6 |
- |
1928 |
str = ' <div id="mod' + trackingNumber + '" class="w3-modal">';
|
|
|
1929 |
str += ' <div class="w3-modal-content w3-card-4">';
|
|
|
1930 |
str += ' <header class="w3-container w3-black"> ';
|
|
|
1931 |
str += ' <span onclick="document.getElementById(\'mod' + trackingNumber + '\').style.display=\'none\'"';
|
|
|
1932 |
str += ' class="w3-button w3-display-topright">×</span>';
|
|
|
1933 |
str += ' <h3>' + trackingNumber + ' (USPS ' + getCarrierService("USPS", trackingNumber, false) + ')</h3>';
|
|
|
1934 |
str += ' </header>';
|
|
|
1935 |
str += ' <div class="w3-container">';
|
|
|
1936 |
str += ' <table class="w3-table-all w3-small">';
|
|
|
1937 |
str += ' <tr>';
|
|
|
1938 |
str += ' <th>DATE</th>';
|
|
|
1939 |
str += ' <th>TIME</th>';
|
|
|
1940 |
str += ' <th>STATUS</th>';
|
|
|
1941 |
str += ' <th>LOCATION</th>';
|
|
|
1942 |
str += ' </tr>';
|
|
|
1943 |
str += summary;
|
|
|
1944 |
str += detail;
|
|
|
1945 |
str += ' </table>';
|
|
|
1946 |
str += ' </div>';
|
|
|
1947 |
str += ' <footer class="w3-container w3-black">';
|
|
|
1948 |
str += ' <p>' + document.getElementById('DeliveryAddress' + trackingNumber).innerHTML + ' - ' + footer + '</p>';
|
|
|
1949 |
str += ' </footer>';
|
|
|
1950 |
str += ' </div>';
|
|
|
1951 |
str += ' </div>';
|
| 2 |
- |
1952 |
|
| 6 |
- |
1953 |
document.getElementById("modals").innerHTML += str;
|
|
|
1954 |
}
|
| 2 |
- |
1955 |
|
| 6 |
- |
1956 |
--trackingNumbersToProcess;
|
|
|
1957 |
++trackingNumbersProcessed;
|
|
|
1958 |
updateProgressBar(maxTrackingNumbersToProcess, trackingNumbersProcessed);
|
|
|
1959 |
}
|
|
|
1960 |
};
|
| 2 |
- |
1961 |
|
| 6 |
- |
1962 |
url = configUSPSUrl + '?API=TrackV2&XML=';
|
|
|
1963 |
url += '<TrackFieldRequest USERID="';
|
|
|
1964 |
url += configUSPSUserId;
|
|
|
1965 |
url += '">';
|
|
|
1966 |
url += '<TrackID ID="' + searchNumber + '"></TrackID>';
|
|
|
1967 |
url += '</TrackFieldRequest>';
|
|
|
1968 |
url = url.replace(/ /g, '%20');
|
| 2 |
- |
1969 |
|
| 6 |
- |
1970 |
xhttp.open("GET", configProxyUrl, true);
|
|
|
1971 |
xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
|
|
|
1972 |
xhttp.send();
|
| 2 |
- |
1973 |
}
|
|
|
1974 |
|
|
|
1975 |
function formatUSPSTrackingLine(t) {
|
| 6 |
- |
1976 |
var str = '';
|
| 2 |
- |
1977 |
|
| 6 |
- |
1978 |
if (t !== undefined) {
|
|
|
1979 |
str = '<tr>';
|
| 2 |
- |
1980 |
|
| 6 |
- |
1981 |
str += '<td>' + moment(t.EventDate, "MMMM DD, YYYY").format('YYYY-MM-DD') + '</td>';
|
| 2 |
- |
1982 |
|
| 6 |
- |
1983 |
str += '<td>';
|
|
|
1984 |
if (t.EventTime.length > 0) {
|
|
|
1985 |
str += ' ' + moment(t.EventTime, "hh:mm a").format('HH:mm');
|
|
|
1986 |
}
|
|
|
1987 |
str += '</td>';
|
| 2 |
- |
1988 |
|
| 6 |
- |
1989 |
str += '<td>' + t.Event + '</td>';
|
| 2 |
- |
1990 |
|
| 6 |
- |
1991 |
str += '<td>';
|
|
|
1992 |
if (t.EventCity.length > 0) {
|
|
|
1993 |
str += t.EventCity;
|
|
|
1994 |
if (t.EventState.length > 0) {
|
|
|
1995 |
str += ", " + t.EventState + ' ' + t.EventZIPCode;
|
|
|
1996 |
}
|
|
|
1997 |
}
|
|
|
1998 |
str += '</td>';
|
| 2 |
- |
1999 |
|
| 6 |
- |
2000 |
str += '</tr>';
|
|
|
2001 |
}
|
| 2 |
- |
2002 |
|
| 6 |
- |
2003 |
return (str);
|
| 2 |
- |
2004 |
}
|
|
|
2005 |
|
|
|
2006 |
function getUPSTracking(trackingNumber) {
|
| 6 |
- |
2007 |
var xhr = new XMLHttpRequest();
|
| 2 |
- |
2008 |
|
| 6 |
- |
2009 |
var xml = '<?xml version="1.0"?>';
|
|
|
2010 |
xml += '<AccessRequest xml:lang="en-US">';
|
|
|
2011 |
xml += '<AccessLicenseNumber>' + configUPSAccessKey + '</AccessLicenseNumber>';
|
|
|
2012 |
xml += '<UserId>' + configUPSUsername + '</UserId>';
|
|
|
2013 |
xml += '<Password>' + configUPSPassword + '</Password>';
|
|
|
2014 |
xml += '</AccessRequest>';
|
|
|
2015 |
xml += '<?xml version="1.0"?>';
|
|
|
2016 |
xml += '<TrackRequest xml:lang="en-US">';
|
|
|
2017 |
xml += '<Request>';
|
|
|
2018 |
xml += '<TransactionReference>';
|
|
|
2019 |
xml += '<CustomerContext>' + 'MUNA Trading' + '</CustomerContext>';
|
|
|
2020 |
xml += '</TransactionReference>';
|
|
|
2021 |
xml += '<RequestAction>Track</RequestAction>';
|
|
|
2022 |
xml += '<RequestOption>1</RequestOption>';
|
|
|
2023 |
xml += '</Request>';
|
|
|
2024 |
xml += '<TrackingNumber>' + trackingNumber + '</TrackingNumber>';
|
|
|
2025 |
xml += '</TrackRequest>';
|
| 2 |
- |
2026 |
|
| 6 |
- |
2027 |
xhr.onload = () => {
|
| 12 |
- |
2028 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
2029 |
var obj = jsonObj.TrackResponse;
|
| 2 |
- |
2030 |
|
| 6 |
- |
2031 |
if (obj.Response.ResponseStatusDescription != 'Success') {
|
|
|
2032 |
--trackingNumbersToProcess;
|
|
|
2033 |
++trackingNumbersProcessed;
|
|
|
2034 |
updateProgressBar(maxTrackingNumbersToProcess, trackingNumbersProcessed);
|
|
|
2035 |
return;
|
|
|
2036 |
}
|
| 2 |
- |
2037 |
|
| 6 |
- |
2038 |
trackingNumber = obj.Shipment.ShipmentIdentificationNumber;
|
|
|
2039 |
summary = formatUPSTrackingLine(obj.Shipment.Package.Activity[0]);
|
|
|
2040 |
detail = '';
|
|
|
2041 |
footer = '';
|
|
|
2042 |
deliveryDate = '';
|
|
|
2043 |
duration = '';
|
|
|
2044 |
lastUpdate = moment(obj.Shipment.Package.Activity[0].Status.Date, "YYYYMMDD").format('YYYY-MM-DD');
|
|
|
2045 |
lastEvent = obj.Shipment.Package.Activity[0].Status.StatusType.Description;
|
| 2 |
- |
2046 |
|
| 6 |
- |
2047 |
if (document.getElementById('DeliveryStatus' + trackingNumber) === null) {
|
|
|
2048 |
--trackingNumbersToProcess;
|
|
|
2049 |
++trackingNumbersProcessed;
|
|
|
2050 |
updateProgressBar(maxTrackingNumbersToProcess, trackingNumbersProcessed);
|
|
|
2051 |
return;
|
|
|
2052 |
}
|
| 2 |
- |
2053 |
|
| 6 |
- |
2054 |
if (obj.Shipment.Package.Activity !== undefined && obj.Shipment.Package.Activity.length > 0) {
|
|
|
2055 |
for (j = 0; j < obj.Shipment.Package.Activity.length; j++) {
|
|
|
2056 |
detail += formatUPSTrackingLine(obj.Shipment.Package.Activity[j]);
|
|
|
2057 |
}
|
| 2 |
- |
2058 |
|
| 6 |
- |
2059 |
createDate = moment(obj.Shipment.PickupDate, "YYYYMMDD").format('YYYY-MM-DD');
|
|
|
2060 |
footer = 'Enroute since ' + createDate + ' (' + moment().diff(createDate, 'days') + ' days)';
|
| 2 |
- |
2061 |
|
| 6 |
- |
2062 |
if (obj.Shipment.Package.DeliveryIndicator == 'Y') {
|
|
|
2063 |
deliveryDate = moment(obj.Shipment.Package.DeliveryDate, "YYYYMMDD").format('YYYY-MM-DD');
|
|
|
2064 |
duration = moment(deliveryDate).diff(createDate, 'days');
|
|
|
2065 |
document.getElementById('DeliveryStatus' + trackingNumber).style.color = "green";
|
|
|
2066 |
footer = 'Delivered in ' + moment(deliveryDate).to(createDate, 'days');
|
|
|
2067 |
} else if (moment().diff(lastUpdate, 'days') > 3) {
|
|
|
2068 |
document.getElementById('DeliveryStatus' + trackingNumber).style.color = "red";
|
|
|
2069 |
}
|
|
|
2070 |
}
|
| 2 |
- |
2071 |
|
| 6 |
- |
2072 |
document.getElementById('ShippedDate' + trackingNumber).innerHTML = createDate;
|
|
|
2073 |
document.getElementById('DeliveryStatus' + trackingNumber).innerHTML = lastEvent;
|
|
|
2074 |
document.getElementById('DeliveryDays' + trackingNumber).innerHTML = duration;
|
|
|
2075 |
document.getElementById('DeliveryDate' + trackingNumber).innerHTML = deliveryDate;
|
| 2 |
- |
2076 |
|
| 6 |
- |
2077 |
str = document.getElementById(trackingNumber).innerHTML;
|
|
|
2078 |
if (!str.startsWith('<button')) {
|
|
|
2079 |
document.getElementById(trackingNumber).innerHTML = '<button onclick="document.getElementById(\'mod' + trackingNumber + '\').style.display=\'block\'" class="w3-button w3-black">' + str + '</button>';
|
| 2 |
- |
2080 |
|
| 6 |
- |
2081 |
str = ' <div id="mod' + trackingNumber + '" class="w3-modal">';
|
|
|
2082 |
str += ' <div class="w3-modal-content w3-card-4">';
|
|
|
2083 |
str += ' <header class="w3-container w3-black"> ';
|
|
|
2084 |
str += ' <span onclick="document.getElementById(\'mod' + trackingNumber + '\').style.display=\'none\'"';
|
|
|
2085 |
str += ' class="w3-button w3-display-topright">×</span>';
|
|
|
2086 |
str += ' <h3>' + trackingNumber + ' (UPS ' + getCarrierService("UPS", trackingNumber, false) + ')</h3>';
|
|
|
2087 |
str += ' </header>';
|
|
|
2088 |
str += ' <div class="w3-container">';
|
|
|
2089 |
str += ' <table class="w3-table-all w3-small">';
|
|
|
2090 |
str += ' <tr>';
|
|
|
2091 |
str += ' <th>DATE</th>';
|
|
|
2092 |
str += ' <th>TIME</th>';
|
|
|
2093 |
str += ' <th>STATUS</th>';
|
|
|
2094 |
str += ' <th>LOCATION</th>';
|
|
|
2095 |
str += ' </tr>';
|
|
|
2096 |
str += summary;
|
|
|
2097 |
str += detail;
|
|
|
2098 |
str += ' </table>';
|
|
|
2099 |
str += ' </div>';
|
|
|
2100 |
str += ' <footer class="w3-container w3-black">';
|
|
|
2101 |
str += ' <p>' + document.getElementById('DeliveryAddress' + trackingNumber).innerHTML + ' - ' + footer + '</p>';
|
|
|
2102 |
str += ' </footer>';
|
|
|
2103 |
str += ' </div>';
|
|
|
2104 |
str += ' </div>';
|
| 2 |
- |
2105 |
|
| 6 |
- |
2106 |
document.getElementById("modals").innerHTML += str;
|
|
|
2107 |
}
|
| 2 |
- |
2108 |
|
| 6 |
- |
2109 |
--trackingNumbersToProcess;
|
|
|
2110 |
++trackingNumbersProcessed;
|
|
|
2111 |
updateProgressBar(maxTrackingNumbersToProcess, trackingNumbersProcessed);
|
|
|
2112 |
};
|
| 2 |
- |
2113 |
|
| 6 |
- |
2114 |
xhr.open('POST', configProxyUrl, true);
|
|
|
2115 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
2116 |
xhr.setRequestHeader('X-Proxy-URL', configUPSUrl);
|
|
|
2117 |
xhr.send(xml);
|
| 2 |
- |
2118 |
}
|
|
|
2119 |
|
|
|
2120 |
function formatUPSTrackingLine(t) {
|
| 6 |
- |
2121 |
var str = '';
|
| 2 |
- |
2122 |
|
| 6 |
- |
2123 |
if (t !== undefined) {
|
|
|
2124 |
str = '<tr>';
|
| 2 |
- |
2125 |
|
| 6 |
- |
2126 |
str += '<td>' + moment(t.Date, "YYYYMMDD").format('YYYY-MM-DD') + '</td>';
|
| 2 |
- |
2127 |
|
| 6 |
- |
2128 |
str += '<td>';
|
|
|
2129 |
if (t.Time.length > 0) {
|
|
|
2130 |
str += ' ' + moment(t.Time, "HHmmss").format('HH:mm');
|
|
|
2131 |
}
|
|
|
2132 |
str += '</td>';
|
| 2 |
- |
2133 |
|
| 6 |
- |
2134 |
str += '<td>' + t.Status.StatusType.Description + '</td>';
|
| 2 |
- |
2135 |
|
| 6 |
- |
2136 |
str += '<td>';
|
|
|
2137 |
if (t.ActivityLocation.Address.City !== undefined) {
|
|
|
2138 |
str += t.ActivityLocation.Address.City;
|
|
|
2139 |
if (t.ActivityLocation.Address.StateProvinceCode !== undefined) {
|
|
|
2140 |
str += ", " + t.ActivityLocation.Address.StateProvinceCode;
|
|
|
2141 |
}
|
|
|
2142 |
}
|
|
|
2143 |
str += '</td>';
|
| 2 |
- |
2144 |
|
| 6 |
- |
2145 |
str += '</tr>';
|
|
|
2146 |
}
|
| 2 |
- |
2147 |
|
| 6 |
- |
2148 |
return (str);
|
| 2 |
- |
2149 |
}
|
|
|
2150 |
|
|
|
2151 |
|
|
|
2152 |
function connected() {
|
| 6 |
- |
2153 |
var x;
|
| 2 |
- |
2154 |
|
| 6 |
- |
2155 |
eBayAuthTokenFlag = true;
|
|
|
2156 |
document.getElementById("connected").innerHTML += " (Connected)";
|
| 2 |
- |
2157 |
|
| 6 |
- |
2158 |
x = document.getElementById("startButton");
|
|
|
2159 |
x.className = x.className.replace(" w3-red", " w3-black");
|
| 2 |
- |
2160 |
|
| 6 |
- |
2161 |
x = document.getElementById("login");
|
|
|
2162 |
x.className = x.className.replace(" w3-show", "");
|
| 2 |
- |
2163 |
|
| 6 |
- |
2164 |
x = document.getElementById("results");
|
|
|
2165 |
x.innerHTML = "";
|
|
|
2166 |
x.className = x.className.replace(" w3-show", "");
|
| 2 |
- |
2167 |
}
|
|
|
2168 |
|
|
|
2169 |
</script>
|
|
|
2170 |
|
|
|
2171 |
</body>
|
|
|
2172 |
</html>
|