-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAll Receipts.html
658 lines (457 loc) · 21.6 KB
/
All Receipts.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<html>
<head><title>DC Receipts</title></head>
<body>
<!-- external libs from cdnjs -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script type ="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.33.1/plotly-basic.min.js"></script>
<!-- script type="text/javascript" src="https://cdn.plot.ly/plotly-basic-latest.min.js"></script -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.1.2/papaparse.min.js"></script>
<!-- script type="text/javascript" src="/contributionspaid/scripts/jquery.floatTHead.min.js"></script -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.2.1/jquery.floatThead.min.js"></script>
<!-- PivotTable.js libs from ../dist -->
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/pivot.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/pivot.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/d3_renderers.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/plotly_renderers.min.js"></script>
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/export_renderers.min.js'></script>
<!-- subtotal.js libs from ../dist -->
<!-- base href= "/flowerbot/contributionspaid/blob/main/" -->
<!-- base href= "/" -->
<script type="text/javascript" src="/contributionspaid/scripts/PivotJS-subtotal/subtotal.js"></script>
<link rel="stylesheet" type="text/css" href="/contributionspaid/scripts/PivotJS-subtotal/subtotal.css">
<style>
body {font-family: Verdana;}
th.pvtRowLabel {
white-space: nowrap;
}
.ms-webpartPage-root {
border-spacing: 0px;
}
.desc {
padding-bottom: 10px;
width: 80vw;
}
.rotate {
/* height: 90px; */ /* fixed height . set fixed width to rotated elements */
/* width: 110px !important;/* a liitle less than parents height */
/* -webkit-transform: rotate(310deg);
-moz-transform: rotate(310deg);
-ms-transform: rotate(310deg);
-o-transform: rotate(310deg);
transform: rotate(310deg) translatex(-64%) translatey(56%);
transform-origin: top left;
margin-right: -73px;*/
font-size: 14px;
}
#inclusions strong {
font-weight: 500;
color:lightseagreen;
}
p, .pvtVal, .pvtTotal, .pvtRowLabel, .pvtGrandTotal {
font-size: 10pt;
}
.pvtTotal {
background-color: WhiteSmoke !important;
font-weight: 500 !important;
}
th.pvtRowLabel {
font-size: 10pt !important;
font-weight: 500 !important;
}
.colTotal {
border-top: 2px solid #C8C8C8 !important;
border-bottom: 4px double gray !important;
}
.rowTotal {
border-left: 2px solid #C8C8C8 !important;
}
.pvtGrandTotal {
border-top: 2px solid #C8C8C8 !important;
border-left: 2px solid #C8C8C8 !important;
border-bottom: 4px double gray !important;
}
/* extras for floating headers */
.floatThead-container {
overflow: hidden;
}
.pvtFilterBox {
z-index: 2001;
}
/* ************************* */
#notes {
font-size:12px;
}
.noteRed {
font-weight:bold;
color: black;
background-color: red;
border-color: black;
border-width: 1px;
}
</style>
<script type="text/javascript">
debug = false;
var dataObj;
var config = {};
// var amt = function(data,)
///prac/infrastructure/charts/Expected Contributions.csv
function fetchHeader(url, wch) {
try {
var req=new XMLHttpRequest();
req.open("HEAD", url, false);
req.send(null);
if(req.status== 200){
return req.getResponseHeader(wch);
}
else return false;
} catch(er) {
return er.message;
}
}
//var fileNameAndPath = "/contributionspaid/data/DC ReceiptsClean.csv";
var fromXlOne = false;
var curPath = window.location.href;
var fileNameAndPath = "data/DC ReceiptsClean.csv";
var gitHubPath = "https://api.github.com/repos/flowerbot/contributionspaid/commits?path=data/DC ReceiptsClean.csv&page=1&per_page=1"
const options = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
};
var client = new XMLHttpRequest();
if(curPath.indexOf("github")>=0) {
client.open("HEAD", gitHubPath, true);
} else {
client.open("HEAD", fileNameAndPath);
}
client.onreadystatechange = function() {
if(this.readyState == 2) {
// console.log(client.getAllResponseHeaders());
//console.log(client.getResponseHeader("Last-Modified"));
var newDate = new Date(client.getResponseHeader("Last-Modified")).toLocaleDateString("en-AU", options);
var newTime = new Date(client.getResponseHeader("Last-Modified")).toLocaleTimeString("en-AU");
var dtString = newDate + " " + newTime;
console.log("NEW daTE:", newDate, "; NEW TIME:", newTime);
document.getElementById("fileDate").innerHTML = dtString;
}
}
client.send();
/*function ExcelDateToJSDate(serial) {
var utc_days = Math.floor(serial - 25569);
var utc_value = utc_days * 86400;
var date_info = new Date(utc_value * 1000);
var fractional_day = serial - Math.floor(serial) + 0.0000001;
var total_seconds = Math.floor(86400 * fractional_day);
var seconds = total_seconds % 60;
total_seconds -= seconds;
var hours = Math.floor(total_seconds / (60 * 60));
var minutes = Math.floor(total_seconds / 60) % 60;
return new Date(date_info.getFullYear(), date_info.getMonth(), date_info.getDate(), hours, minutes, seconds);
} */
$(function(){
// CATCH THE SCROLL EVENT
// would normally be 'document' but this is especially for SharePoint:
/* var docBody = document.getElementById('s4-workspace');
docBody.addEventListener('scroll', function(e) {
// document.getElementById('showScroll').innerHTML = window.pageYOffset + 'px';
var $table = $('table.pvtTable');
$table.trigger('reflow');
}); */
// for subototals
var dataClass = $.pivotUtilities.SubtotalPivotData;
var renderers = $.extend($.pivotUtilities.renderers, $.pivotUtilities.plotly_renderers, $.pivotUtilities.export_renderers, $.pivotUtilities.subtotal_renderers);
var sum = $.pivotUtilities.aggregatorTemplates.sum;
var numberFormat = $.pivotUtilities.numberFormat;
var intFormat = numberFormat({digitsAfterDecimal: 0});
/* var aggregators = {
"Amount": function() {
return sum(intFormat)(["Amount"]);
} */
var amtSum = function() {
return sum(intFormat)(["Amount"]);
};
// "Balance": function() {return sum(["Balance"])},
// "Expected": function() { return sum(intFormat)(["Expected"])},
//}
var rendererOptions = {
//rendererOptions: {
table : {
/* clickCallback: function(e, value, filters, pivotData) {
var links = [];
pivotData.forEachMatchingRecord(filters,
function(record) { links.push(record.ProjectLink); });
if (window.confirm("Visit the project site at: "+ links[0] + " ?"))
{
var win = window.open(links[0], '_blank');
win.focus();
}
} */
},
//config["heatmap"] = {
heatmap: {
colorScaleGenerator: function(values) {
return d3.scale.linear()
// .domain(["1", "100000", "4000000", "9000000"])
// .domain([600000, 6000000])
.domain([-900000, 0, 40000])
// .range(["#FFF", "#FF3D5A"])
// .range(["#FFF", "#9AFF3D", "#F7FF3D", "#FF3D5A"])
.range(["#9AFF3D", "#FFFFFF", "#FF0000"])
//}
}
},//;//,
};
savedConfig = localStorage.getItem('pivotdatakey');
//var config
if (savedConfig) { // If a saved state found in LocalStorage, then load it
console.log("found a config object");
var configobject = JSON.parse(savedConfig); // Make it an object
configobject["renderers"] = renderers;
configobject["rendererOptions"] = rendererOptions;
configobject["dataClass"] = dataClass;
// console.log(JSON.stringify(configobject));
console.log(configobject);
configobject.onRefresh = function (config) {
console.log("save state called");
console.log(config);
var config_copy = JSON.parse(JSON.stringify(config));
//delete some values which are functions
delete config_copy["aggregators"];
delete config_copy["renderers"];
//delete some bulky default values
delete config_copy["rendererOptions"];
delete config_copy["localeStrings"];
/// config_copy["renderers"] = renderers;
var params = {};
try {
// params["Inclusions"] = config["inclusionsInfo"];
document.getElementById("inclusions").innerHTML = "<strong>Inclusions:</strong>" + JSON.stringify(configobject["inclusions"]) ;
} catch (ex) {console.log("inclusions not found")};
// try {
hideShowNotes(config["inclusions"]["Ledger"], []);
// } catch(ex2) { $("#")};
//console.log("Ledger:",configobject["inclusions"]["Ledger"]);
// params["Exclusions"] = config_copy["exclusions"];
//console.log(params)
/// config_copy["renderers"] = renderers;
$("#parameters").html(JSON.stringify(params, undefined, 2));
// $(".pvtColLabel").wrapInner("<div class='rotate'></div>");
// console.log(params["Inclusions"]) ;
localStorage.setItem('pivotdatakey', JSON.stringify(config_copy, undefined, 2)); // Add callback function for onRefresh
$(".pvtColLabel").wrapInner("<div class='rotate'></div>");
fixHeader();
btn = document.getElementById("toggleHideUIButton");
toggleHide(btn);
}
} else {
// no config found, make it from scratch
var configobject = {};
// configobject["inclusions"] = {Plan:["19"]};
configobject["exclusions"] ={ Month:[""], Account:[""],
Ledger:["DC01ACT", "DC02ACT","DC03ACT","DC04ACT","DC05ACT","DC06ACT","DC07ACT","DC08ACT","DC09ACT","DC10ACT","DC11ACT", "DC12ACT","DC13ACT", "DC14ACT", "DC15ACT", ""]};
configobject["rows"] = ["Month"];
configobject["cols"] = ["Ledger"];
configobject["vals"] = ["Amount"];
configobject["hiddenAttributes"] = ["Month Num", "Month Text", "Fiscal Month","", "DateYear", "DataDate"];
configobject["aggregatorName"] = "Integer Sum";
// configobject["aggregator"] = ["Amount"];
// configobject["aggregators"] = {"Amount": ["Amount"] };
/* configobject["aggregators"] = {
"Amount": function() {
return sum(intFormat)(["Amount"]);
}
}*/
configobject["rendererName"] = "Row Heatmap";
configobject["renderers"] = renderers;
//configobject["filter"] = filterFun;
configobject["rendererOptions"] = rendererOptions;
configobject["dataClass"] = dataClass;
/* configobject["onRefresh"] = function(config) {
console.log(JSON.parse(JSON.stringify(config)));
console.log(config.cols[0]);
$(".pvtColLabel").wrapInner("<div class='rotate'></div>");
} */
hideShowNotes(["DC21ACT", "DC23ACT"], configobject["exclusions"]["Ledger"]);
try {
// params["Inclusions"] = config["inclusionsInfo"];
document.getElementById("inclusions").innerHTML = "<strong>Inclusions:</strong>" + JSON.stringify(configobject["inclusions"]) + " (Change the included Plan(s) below if required)";
} catch (ex) {console.log("inclusions not found A")};
configobject.onRefresh = function (config) {
console.log("new state called");
var config_copy = JSON.parse(JSON.stringify(config));
//var config_copy = configobject;
//delete some values which are functions
delete config_copy["aggregators"];
delete config_copy["renderers"];
//delete some bulky default values
delete config_copy["rendererOptions"];
delete config_copy["localeStrings"];
var params = {};
try {
// params["Inclusions"] = config["inclusionsInfo"];
document.getElementById("inclusions").innerHTML = "<strong>Inclusions:</strong>" + JSON.stringify(config["inclusions"]) + " (Change the included Plan(s) below if required)";
//hideShowNotes(configobject["inclusions"]["Ledger"]);
} catch (ex) {console.log("inclusions not found B")};
// add exclusions to params if necessary
localStorage.setItem('pivotdatakey', JSON.stringify(config_copy, undefined, 2)); // Add callback function for onRefresh
console.log(config_copy) ;
$(".pvtColLabel").wrapInner("<div class='rotate'></div>");
fixHeader();
btn = document.getElementById("toggleHideUIButton");
toggleHide(btn);
}
}
// var intFormat = numberFormat({digitsAfterDecimal: 0});
//var intFormat = numberFormat();
Papa.parse(fileNameAndPath, {
download: true,
skipEmptyLines: true,
header: true,
complete: function(parsed){
// console.log(parsed.data[1][6]); // THIS SHOULD BE THE FILE DATE
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
//hour: 'numeric',
//minute: 'numeric',
timeZoneName: 'short'
};
var curPath = window.location.href;
var fileDate = "";
var localDate = "";
var fixedData = parsed.data;
//console.log(fixedData);
// fileDate= ExcelDateToJSDate(parseFloat(fixedData[0].DataDate));
/*
if(curPath.indexOf("github")>=0) {
fileDate = "<a href='https://github.com/flowerbot/contributionspaid/blob/main/data/DC%20ReceiptsClean.csv' target='_blank'>See GitHub commit date</a>";
localDate = fileDate;
} else {
fileDate = fetchHeader(fileNameAndPath, "Last-Modified");
localDate = new Date(fileDate).toLocaleDateString('en-au', options);
}
*/
// fileDate = fixedData[0].DataDate;
// localDate = new Date(fileDate).toLocaleDateString('en-au', options);
// console.log(parsed.data[1][6]); // THIS SHOULD BE THE FILE DATE
// var fileDate = parsed.data[1][6];
var dataLen = fixedData.length;
//document.getElementById("fileDate").innerHTML = localDate;
document.getElementById("progress").innerHTML = dataLen;
document.getElementById("progressTotal").innerHTML = dataLen;
dataObj = fixedData;
$("#output").pivotUI(parsed.data, configobject);
$(".pvtColLabel").wrapInner("<div class='rotate'></div>");
}
});
// var jsonData = Papa.parse("/prac/infrastructure/siteassets/scripts/data/AccountBalance.csv");
// console.log(jsonData.data);
});
function dataExport() {
var myWindow = (window.open("", "", "width=600,height=600,scrollbars=1"));
var tableTxt = "";
var exportTableTxt = "";
var tableId = "dataExportTable";
var downloadLink;
var dataType = 'application/vnd.ms-excel';
var msgText = "<H2>JSON FORMAT:</H2><p>Save JSON to a text file, or copy it to a JSON viewer, like the one at <a href='https://jsongrid.com/json-grid'target='_blank'>jsongrid.com</a> </p>";
myWindow.document.title="Export ..";
myWindow.document.write(msgText + "<pre style='border:1px solid #dddddd;'>" + JSON.stringify(dataObj, null, " ")+"</pre>");
}
function fixHeader() {
var $table = $('table.pvtTable');
/*
// to use this flavor, you have to set .pvtRendererArea to a fixed height I think
$table.floatThead({
scrollContainer: function($table){
return $table.closest('.pvtRendererArea');
},
position: 'fixed',
autoReflow: true
});
*/
$table.floatThead({
position: 'fixed',
//autoReflow: true
});
}
function hideShowNotes(incArray, excArray) {
// if(!configobject["inclusions"]["Ledger"].includes("DC21ACT")) {
// if(inc == true) {
if(!incArray.includes("DC21ACT") || (excArray.includes("DC21ACT"))) {
$("#DEC21").hide();
} else {
$("#DEC21").show();
}
if(!incArray.includes("DC23ACT")|| (excArray.includes("DC23ACT"))) {
$("#MAY23").hide();
} else {
$("#MAY23").show();
}
} /*else {
console.log("Exclusions:",excArray);
if(excArray.includes("DC21ACT")) {
}
} */
//}
function revert() {
localStorage.clear();
location.reload();
}
function toggleHide(obj) {
// var mytable = $(".pvtUi");
//show_hide_column(1,true);
console.log(obj);
console.log("uiVisible:" + $(obj).attr("uiVisible"));
var uiVisible = $(obj).attr("uiVisible");
if(uiVisible == "true") {
$(".pvtAxisContainer").hide();
$(".pvtUiCell").hide();
$(obj).attr("uiVisible","false");
$(obj).attr("value","Show Chart Settings");
var $table = $('table.pvtTable');
$table.trigger('reflow');
} else {
$(".pvtAxisContainer").show();
$(".pvtUiCell").show();
$(obj).attr("uiVisible","true");
$(obj).attr("value","Hide Chart Settings");
var $table = $('table.pvtTable');
$table.trigger('reflow');
}
}
//this function stores pivatetable config to LocalStorage .. does it do anything?
function saveState(config) {
console.log("save state called");
var config_copy = JSON.parse(JSON.stringify(config));
//delete some values which are functions
//delete config_copy["aggregators"];
delete config_copy["renderers"];
//delete some bulky default values
// delete config_copy["rendererOptions"];
delete config_copy["localeStrings"];
hideShowNotes(config_copy["inclusions"]["Ledger"], []);
localStorage.setItem('pivotdatakey', JSON.stringify(config_copy, undefined, 2));
}
</script>
<div class="desc"><p>Data Date: <span id='fileDate'></span>. Use the drop down arrow beside each parameter to filter the chart results. <a href="http://tscps/prac/infrastructure/SitePages/DC%20Ledger%20Report%20-%20XLOne.aspx" target="_blank" title="Upload Excel File to update the data in this chart (Excel source: Paul Drew/Bryan Unwin)"><img src="/contributionspaid/images/excel.jpg" height="20" width="20" /></a>
</p>
<p id="progressHeading">Read <span id="progress">x</span> of <span id="progressTotal">xx</span> data rows. <span id="inclusions"></span></p>
<input type="button" value="Export JSON" onClick="dataExport()" />
<input type="button" value="Revert" onClick="revert()" title="click to clear saved settings and revert to defaults"/>
<input type="button" value="Hide Chart Settings" uiVisible="true" onclick="toggleHide(this)" title="Click to toggle hide/show chart settings" id="toggleHideUIButton" />
<a href="https://flowerbot.github.io/contributionspaid/All%20Receipts.html" target="_blank" title="escape SP">Source</a>
</div>
<div id="output"></div>
<div id="notes"><ul>
<li id="DEC21"><span class="noteRed">DEC 21:</span> CP28.15 $99,332 forwarded to Richtech in accordance with Planning Agreement. Total s7.11 developer contributions received for December 2020 $28,040 less $99,332 to Richtech equals $71,292 overdrawn for month.</li>
<li id="MAY23"><span class="noteRed">MAY 23:</span> includes $631,933.02 forwarded from CP28.15 to Richtech in accordance with Planning Agreement.</li>
</ul></div>
</body>
</html>