-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.htm
691 lines (529 loc) · 20.6 KB
/
index.htm
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
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
<!DOCTYPE html>
<html lang="en" moznomarginboxes mozdisallowselectionprint prefix="og: http://ogp.me/ns#">
<head>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-108493876-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "UA-108493876-1");
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Editable Invoice</title>
<link id="pagestyle" rel='stylesheet' type='text/css' href='/assets/css/main.css' media="all" />
<link rel='stylesheet' type='text/css' href='/assets/css/print.css' media="print" />
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#000000">
<meta name="apple-mobile-web-app-title" content="Send Bill!">
<meta name="application-name" content="Send Bill!">
<meta name="msapplication-TileColor" content="#000000">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<meta name="theme-color" content="#000000">
<!-- <script type='text/javascript' src='js/jquery-1.3.2.min.js'></script> -->
<script type='text/javascript' src='js/jquery.min.js'></script>
</head>
<body id="body">
<div class="help" id="help">
<a id="help_button" class="" onclick="startHelp()" href="#">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M0 0h24v24h-24z" fill="none"/>
<path fill="white" d="M12 2c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92c-.72.73-1.17 1.33-1.17 2.83h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2h-2c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"/>
</svg>
<div class="small_screen_text">
Help
</div>
</a>
<a id="reload_button" class="hide" href="/">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="white" d="M17.65 6.35c-1.45-1.45-3.44-2.35-5.65-2.35-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78l-3.22 3.22h7v-7l-2.35 2.35z"/>
<path d="M0 0h24v24h-24z" fill="none"/>
</svg>
<div class="small_screen_text after_download">
Make a new invoice
</div>
</a>
</div>
<div id="download_invoice_block" class="group">
<div class="header_wrap">
<textarea rows="1" class="header">INVOICE</textarea>
</div>
<div id="identity">
<textarea class="own_data">
YourCompany
Street Address
Zipcode City State Country
Tel: (+44) 123-456-7890
</textarea>
<div id="logo">
<div id="logoctr">
<!-- <a href="javascript:;" id="change-logo" title="Change logo">Change Logo</a> -->
<a href="javascript:;" id="save-logo" title="Save changes">Save</a>
<a href="javascript:;" id="delete-logo" title="Delete logo">Delete Logo</a>
<a href="javascript:;" id="cancel-logo" title="Cancel changes">Cancel</a>
</div>
<div id="logohelp">
<input id="imageloc" type="text" size="50" value="" /><br /> (max width: 540px, max height: 100px)
</div>
<div class="invoice_logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800">
<path fill="#FFF" d="M763.55 338.662l-119.265-51.11V128.57c0-29.982-24.303-54.286-54.285-54.286H210c-29.98 0-54.286 24.304-54.286 54.285v158.98L36.45 338.663C26.47 342.94 20 352.752 20 363.612v307.815c0 29.982 24.304 54.287 54.286 54.287h651.43c29.98 0 54.284-24.305 54.284-54.287V363.61c0-10.858-6.47-20.67-16.45-24.948z"/>
<path fill="#000" d="M763.55 338.662l-119.265-51.11V128.57c0-29.982-24.303-54.286-54.285-54.286H210c-29.98 0-54.286 24.304-54.286 54.285v158.98L36.45 338.663C26.47 342.94 20 352.752 20 363.612v307.815c0 29.982 24.304 54.287 54.286 54.287h651.43c29.98 0 54.284-24.305 54.284-54.287V363.61c0-10.858-6.47-20.67-16.45-24.948zm-13.08 23.924l-106.185 60.68V317.082l106.184 45.504zM182.856 128.57c.017-14.98 12.16-27.124 27.143-27.142h380c14.982.018 27.127 12.16 27.143 27.143v310.204L400 562.857 182.857 438.773V128.57zm-27.143 188.51v106.182L49.53 362.586l106.184-45.506zm597.143 354.348c-.016 14.982-12.158 27.127-27.143 27.145H74.286c-14.983-.018-27.126-12.162-27.144-27.145V392.484l339.39 193.938c8.346 4.77 18.59 4.77 26.933 0l339.393-193.938v278.944z"/>
<path fill="#000" d="M421.324 237.152c10.457-.678 20.625 3.592 27.46 11.53 3.65 4.376 5.603 9.917 5.5 15.612 0 7.496 6.077 13.572 13.573 13.572s13.57-6.076 13.57-13.572c.13-11.66-3.795-23.004-11.092-32.1-11.89-14.752-30.078-22.986-49.012-22.186-30.606 0-65.68 21.93-73.83 81.43h-15.352c-7.493 0-13.57 6.074-13.57 13.57s6.077 13.572 13.57 13.572h13.572c-.023 9.076.573 18.146 1.783 27.143H332.14c-7.493 0-13.57 6.074-13.57 13.57s6.077 13.572 13.57 13.572h21.94c7.92 30.99 35.28 53.078 67.242 54.287 18.934.8 37.12-7.434 49.012-22.188 7.297-9.096 11.22-20.44 11.092-32.1 0-7.496-6.074-13.572-13.57-13.572s-13.572 6.076-13.572 13.572c.102 5.695-1.85 11.238-5.5 15.613-6.836 7.938-17.004 12.207-27.46 11.53-16.84-.733-31.637-11.4-37.654-27.144h29.9c7.497 0 13.57-6.076 13.57-13.572s-6.073-13.57-13.57-13.57h-38.318c-1.58-8.962-2.38-18.042-2.396-27.142h40.715c7.497 0 13.57-6.076 13.57-13.572s-6.073-13.57-13.57-13.57h-38.318c5.797-33.56 22.492-54.284 46.072-54.284z"/>
</svg>
</div>
</div>
</div>
<div style="clear:both"></div>
<div id="customer">
<textarea rows="5" class="customer_data">
YourClientCompany
Street Address
Zipcode City State Country
Tel: (+44) 123-456-7890
</textarea>
<div class="table meta" id="meta">
<div class="row">
<div class="col meta_head editable_indicator">Invoice #</div>
<div class="col">
<textarea rows="1" class="alignright full_width">000123</textarea>
</div>
</div>
<div class="row">
<div class="col meta_head editable_indicator">Date</div>
<div class="col ">
<textarea rows="1" id="date" class="alignright full_width">September 19, 2017</textarea>
</div>
</div>
<div class="row">
<div class="col meta_head">Amount Due</div>
<div class="col">
<div class="due alignright full_width currency_prefix">2500.00</div>
</div>
</div>
</div>
</div>
<div id="items" class="table five_col responsive_table">
<div class="row header_row ">
<div class="col editable_indicator item">Item</div>
<div class="col editable_indicator description">Description</div>
<div class="col editable_indicator unitcost">Unit Cost</div>
<div class="col editable_indicator quantity">Qty</div>
<div class="col totalprice">Price</div>
</div>
<div class="row item-row">
<div class="col item" id="what1">
<textarea rows="3">Web Updates</textarea>
</div>
<div class="col description" id="what1details">
<textarea rows="3">Monthly web updates for paradiseholiday.com (Nov. 1 - Nov. 30, 2018)</textarea>
</div>
<div class="col unitcost" id="what1price">
<textarea rows="1" class="cost currency_prefix">1000.00</textarea>
</div>
<div class="col quantity" id="what1qty">
<textarea rows="1" class="qty">1</textarea>
</div>
<div class="col totalprice">
<span class="price currency_prefix">1000.00</span>
<div class="delete_wrap guide_delete">
<a class="delete" href="javascript:;" title="Remove item">X</a>
</div>
</div>
</div>
<div class="row item-row">
<div class="col item">
<textarea rows="3">SSL Renewals</textarea>
</div>
<div class="col description">
<textarea rows="3">Yearly renewals of SSL certificates on main domain and several subdomains</textarea>
</div>
<div class="col unitcost">
<textarea rows="1" class="cost currency_prefix">1100.00</textarea>
</div>
<div class="col quantity">
<textarea rows="1" class="qty">3</textarea>
</div>
<div class="col totalprice">
<span class="price currency_prefix">3300.00</span>
<div class="delete_wrap">
<a class="delete" href="javascript:;" title="Remove item">X</a>
</div>
</div>
</div>
</div>
<div id="hiderow" class="hiderow">
<div class="no_tag">
<a id="addrow" class="addrow" href="javascript:;" title="Add a row">Add a row</a>
</div>
</div>
<div class="table five_col sums">
<!-- <div class="row">
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col total-line">Subtotal</div>
<div class="col total-value">
<div id="subtotal" class="alignright currency_prefix">555.00</div>
</div>
</div> -->
<div class="row">
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col total-line">Total</div>
<div class="col total-value">
<div id="total" class="alignright currency_prefix">2500.00</div>
</div>
</div>
<div class="row amount_paid">
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col total-line">Amount Paid</div>
<div class="col total-value alignright">
<textarea rows="1" id="paid" class="paid currency_prefix">0.00</textarea>
</div>
</div>
<div class="row">
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col blank no_tag"> </div>
<div class="col total-line balance">Balance Due</div>
<div class="col total-value balance">
<div class="due alignright currency_prefix">2500.00</div>
</div>
</div>
</div>
<div class="notes">
<div class="header">Notes</div>
<textarea>NET 30 Days. Finance Charge of 3% will be made on unpaid balances after 30 days.</textarea>
</div>
</div>
<div class="bottom_nav ">
<a id="print_button" class="" onclick="downloadPdf()" href="#">Download Invoice PDF</a>
<a id="print_message" class="hide" onclick="downloadPdf()" href="#">You just downloaded the invoice PDF. This is how it looks. Click here to download it again.</a>
</div>
<script src="/js/intro.js"></script>
<script type="text/javascript">
function startHelp() {
var intro = introJs().setOption("keyboardNavigation", " true ");
intro.setOptions({
steps: [{
element: ".own_data",
intro: "Fill <strong>your company</strong> details!",
position: "bottom",
highlightClass: "step1"
},
{
element: ".customer_data",
intro: "Next, <strong>Client</strong> details...",
highlightClass: "step2"
},
{
element: "#what1",
intro: "<strong>Type</strong> of job/product...",
highlightClass: "step3"
},
{
element: "#what1details",
intro: "<strong>Job/product</strong> details...",
highlightClass: "step4"
},
{
element: "#what1price",
intro: "<strong>Price</strong> per unit.",
highlightClass: "step5"
},
{
element: "#what1qty",
intro: "<strong>How many</strong> units?",
highlightClass: "step6"
},
{
element: ".guide_delete",
intro: "<strong>Delete</strong> this row.",
highlightClass: "step7"
},
{
element: "#addrow",
intro: "<strong>Add rows</strong> as needed",
highlightClass: "step8"
},
{
element: "#paid",
intro: "<strong>Upfront payment</strong> goes here!",
highlightClass: "step9"
},
{
element: ".notes textarea",
intro: "Edit the <strong>details</strong> here...",
position: "top",
highlightClass: "step10"
},
{
element: ".header_wrap .header",
intro: "This title is editable too!",
position: "bottom",
highlightClass: "step11"
},
{
element: ".bottom_nav",
intro: "Click to <strong>download your Invoice<strong>!",
position: "top",
highlightClass: "step12"
},
{
element: ".notes .header",
intro: "Get it on your phone and share this webapp! <br><div class='qr_wrap group'><div class='qr'></div><div class='url'>https://indobill.junglestar.org</div></div>",
position: "top",
highlightClass: "step13"
}
]
});
intro.start();
}
</script>
<script type="text/javascript">
function print_today() {
var now = new Date();
var months = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);
var date = (now.getDate() < 10 ? "0" : "") + now.getDate();
function fourdigits(number) {
return number < 1000 ? number + 1900 : number;
}
var today =
months[now.getMonth()] + " " + date + ", " + fourdigits(now.getYear());
return today;
}
// from http://www.mediacollege.com/internet/javascript/number/round.html
function roundNumber(number, decimals) {
var newString; // The new rounded number
decimals = Number(decimals);
if (decimals < 1) {
newString = Math.round(number).toString();
} else {
var numString = number.toString();
if (numString.lastIndexOf(".") == -1) {
// If there is no decimal point
numString += "."; // give it one at the end
}
var cutoff = numString.lastIndexOf(".") + decimals; // The point at which to truncate the number
var d1 = Number(numString.substring(cutoff, cutoff + 1)); // The value of the last decimal place that we'll end up with
var d2 = Number(numString.substring(cutoff + 1, cutoff + 2)); // The next decimal, after the last one we want
if (d2 >= 5) {
// Do we need to round up at all? If not, the string will just be truncated
if (d1 == 9 && cutoff > 0) {
// If the last digit is 9, find a new cutoff point
while (cutoff > 0 && (d1 == 9 || isNaN(d1))) {
if (d1 != ".") {
cutoff -= 1;
d1 = Number(numString.substring(cutoff, cutoff + 1));
} else {
cutoff -= 1;
}
}
}
d1 += 1;
}
if (d1 == 10) {
numString = numString.substring(0, numString.lastIndexOf("."));
var roundedNum = Number(numString) + 1;
newString = roundedNum.toString() + ".";
} else {
newString = numString.substring(0, cutoff) + d1.toString();
}
}
if (newString.lastIndexOf(".") == -1) {
// Do this again, to the new string
newString += ".";
}
var decs = newString.substring(newString.lastIndexOf(".") + 1).length;
for (var i = 0; i < decimals - decs; i++) newString += "0";
//var newNumber = Number(newString);// make it a number if you like
return newString; // Output the result to the form field (change for your purposes)
}
function update_total() {
var total = 0;
$(".price").each(function(i) {
price = $(this)
.html()
.replace(",", "");
if (!isNaN(price)) total += Number(price);
});
total = roundNumber(total, 2);
$("#subtotal").html(total);
$("#total").html(total);
$(".currency_prefix").each(function() {
var num = $(this).html();
var commaNum = numberWithCommas(num);
$(this).html(commaNum);
});
update_balance();
}
function update_balance() {
var due =
$("#total")
.html()
.replace(",", "") -
$("#paid")
.val()
.replace(",", "");
due = roundNumber(due, 2);
$(".due").html(due);
$(".currency_prefix").each(function() {
var num = $(this).html();
var commaNum = numberWithCommas(num);
$(this).html(commaNum);
});
}
function update_price() {
var row = $(this).parents(".item-row");
var price =
row
.find(".cost")
.val()
.replace(",", "") * row.find(".qty").val();
price = roundNumber(price, 2);
isNaN(price) ?
row.find(".price").html("N/A") :
row.find(".price").html(price);
update_total();
}
function bind() {
$(".cost").blur(update_price);
$(".qty").blur(update_price);
}
$(document).ready(function() {
$("input").click(function() {
$(this).select();
});
$("#paid").blur(update_balance);
$("#addrow").click(function() {
$(".item-row:last").after(
'<div class="row item-row"><div class="col item"><textarea rows="3">Item Name</textarea></div><div class="col description"><textarea rows="3" >Description</textarea></div><div class="col unitcost"><textarea rows="1" class="cost currency_prefix" >0</textarea></div><div class="col quantity"><textarea rows="1" class="qty" >0</textarea></div><div class="col totalprice"><span class="price currency_prefix">0</span><div class="delete_wrap"><a class="delete" href="javascript:;" title="Remove item">X</a></div></div></div>'
);
if ($(".delete").length > 0) $(".delete").show();
bind();
});
bind();
$(".delete").on("click", function() {
$(this)
.parents(".item-row")
.remove();
update_total();
if ($(".delete").length < 2) $(".delete").hide();
});
$("#cancel-logo").click(function() {
$("#logo").removeClass("edit");
});
$("#delete-logo").click(function() {
$("#logo").remove();
});
$("#change-logo").click(function() {
$("#logo").addClass("edit");
$("#imageloc").val($("#image").attr("src"));
$("#image").select();
});
$("#save-logo").click(function() {
$("#image").attr("src", $("#imageloc").val());
$("#logo").removeClass("edit");
});
$("#date").val(print_today());
});
</script>
<script type="text/javascript">
// takes care of adding thousands separator on load
function numberWithCommas(number) {
var parts = number.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
$(document).ready(function() {
$(".currency_prefix").each(function() {
var num = $(this).html();
var commaNum = numberWithCommas(num);
$(this).html(commaNum);
});
//NOT YET WORKING
$("#paid").blur(function() {
var num = $(this).html();
var commaNum = numberWithCommas(num);
$(this).html(commaNum);
//temp test
$(this).css("background-color", "#cccccc");
});
});
$("#paid").blur(update_balance);
</script>
<script src="/js/jspdf.min.js"></script>
<script src="/js/html2canvas.min.js"></script>
<script src="/js/html2pdf.js"></script>
<script>
var invoice = document.getElementById("download_invoice_block");
function swapStyleSheet(sheet) {
document.getElementById("pagestyle").setAttribute("href", sheet);
}
function formatPageForDownload() {
var changeStyle = document.getElementById("print_button");
changeStyle.onclick = swapStyleSheet("/assets/css/download.css");
//change the foter message
$( "#print_button" ).toggleClass( "hide" );
$( "#print_message" ).toggleClass( "hide" );
$( ".bottom_nav" ).toggleClass( "blue_bg" );
//change the hep button and display reload instead
$( "#help_button" ).toggleClass( "hide" );
$( "#reload_button" ).toggleClass( "hide" );
}
function downloadPdf() {
formatPageForDownload();
html2pdf(invoice, {
filename:'invoice.pdf',
//margin: 2,
image: {
type: "jpeg",
quality: 0.98
},
html2canvas: {
dpi: 300,
letterRendering: true
},
jsPDF: {
unit: "cm",
format: "a4",
orientation: "portrait"
}
});
}
</script>
</body>
</html>