laskutustiedot kans
This commit is contained in:
54
index.html
54
index.html
@@ -117,8 +117,14 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/barcodes/JsBarcode.code128.min.js"></script>
|
||||
|
||||
<script>
|
||||
let state = {
|
||||
'iban': null,
|
||||
'paiva': null,
|
||||
'summa': null,
|
||||
'viite': null
|
||||
}
|
||||
|
||||
function clear_barcode() {
|
||||
//document.getElementById('barcode').innerHTML = "";
|
||||
document.getElementById('barcodes').classList.add("fade");
|
||||
setTimeout(function() {
|
||||
document.getElementById('barcode').innerHTML = "";
|
||||
@@ -170,7 +176,10 @@ function clear_error() {
|
||||
}
|
||||
function modify_request(iban,summa,viite,paiva) {
|
||||
let URL = window.location.href.split('?')[0]
|
||||
const nextURL = `${URL}?FI${iban},${summa},${viite},${paiva}`;
|
||||
let saaja_s = encodeURIComponent(document.getElementById('saaja').value);
|
||||
let maksaja_s = encodeURIComponent(document.getElementById('maksaja').value);
|
||||
let lasku_s = encodeURIComponent(document.getElementById('laskun_tiedot').value);
|
||||
const nextURL = `${URL}?FI${state['iban']},${state['summa']},${state['viite']},${state['paiva']},${saaja_s},${maksaja_s},${lasku_s}`;
|
||||
window.history.replaceState({}, document.title, nextURL);
|
||||
}
|
||||
function calculate_viite_tarkiste(ilman_tarkiste) {
|
||||
@@ -240,7 +249,11 @@ function validate(final = true) {
|
||||
document.getElementById('summa').value = summa.toFixed(2);
|
||||
document.getElementById('viite').value = reversed(reversed(viite).match(/.{1,5}/g).join(" "));
|
||||
document.getElementById('paiva').value = oikea_paiva;
|
||||
modify_request(iban,document.getElementById('summa').value,viite, oikea_paiva);
|
||||
state['iban'] = iban;
|
||||
state['summa'] = document.getElementById('summa').value;
|
||||
state['viite'] = viite;
|
||||
state['paiva'] = oikea_paiva;
|
||||
modify_request();
|
||||
}
|
||||
|
||||
|
||||
@@ -276,37 +289,12 @@ function parse_virtual() {
|
||||
}
|
||||
|
||||
function convertSVGAsPNG(e){
|
||||
//const canvas = document.createElement("canvas");
|
||||
//const svg = document.querySelector('svg');
|
||||
const svg = document.getElementById('barcodeBW');
|
||||
const base64doc = btoa(unescape(encodeURIComponent(svg.outerHTML)));
|
||||
const w = parseInt(svg.getAttribute('width'));
|
||||
const h = parseInt(svg.getAttribute('height'));
|
||||
/*const img_to_download = document.createElement('img');*/
|
||||
const img_to_download = document.getElementById('barcodePNG');
|
||||
img_to_download.src = 'data:image/svg+xml;base64,' + base64doc;
|
||||
/*img_to_download.onload = function () {
|
||||
console.log('img loaded');
|
||||
canvas.setAttribute('width', w);
|
||||
canvas.setAttribute('height', h);
|
||||
const context = canvas.getContext("2d");
|
||||
//context.clearRect(0, 0, w, h);
|
||||
context.drawImage(img_to_download,0,0,w,h);
|
||||
const dataURL = canvas.toDataURL('image/png');
|
||||
|
||||
const filename = 'maksu-' + document.getElementById('paiva').value + '.png';
|
||||
if (window.navigator.msSaveBlob) {
|
||||
window.navigator.msSaveBlob(canvas.msToBlob(), filename);
|
||||
e.preventDefault();
|
||||
} else {
|
||||
const a = document.createElement('a');
|
||||
const my_evt = new MouseEvent('click');
|
||||
a.download = filename;
|
||||
a.href = dataURL;
|
||||
a.dispatchEvent(my_evt);
|
||||
}
|
||||
//canvas.parentNode.removeChild(canvas);
|
||||
}*/
|
||||
}
|
||||
|
||||
function print_help() {
|
||||
@@ -316,6 +304,7 @@ function print_help() {
|
||||
let target = document.getElementById('print_' + fields[i]);
|
||||
target.innerHTML = source.value;
|
||||
}
|
||||
modify_request();
|
||||
}
|
||||
function modify_lasku() {
|
||||
let fields = ['iban','summa','viite','paiva'];
|
||||
@@ -347,6 +336,9 @@ function init() {
|
||||
if (i==1) document.getElementById('summa').value = vars[i];
|
||||
if (i==2) document.getElementById('viite').value = vars[i];
|
||||
if (i==3) document.getElementById('paiva').value = vars[i];
|
||||
if (i==4) document.getElementById('saaja').value = decodeURIComponent(vars[i]);
|
||||
if (i==5) document.getElementById('maksaja').value = decodeURIComponent(vars[i]);
|
||||
if (i==6) document.getElementById('laskun_tiedot').value = decodeURIComponent(vars[i]);
|
||||
}
|
||||
flash_generate();
|
||||
}
|
||||
@@ -364,11 +356,11 @@ function reversed(str) {
|
||||
|
||||
<label>IBAN: </label><br><input id="iban" size=18 value="FI12 3456 7890 1234 56" onblur="generate()" onkeyup="generate(false)" /><br>
|
||||
<label> </label><span id="iban_error" class="error" ></span><br>
|
||||
<label>Summa: </label><br><input id="summa" size=10 value=10 onblur="generate()" onkeyup="generate(false)" />€<br>
|
||||
<label>Summa: </label><br><input type="number" id="summa" size=10 value=10 onblur="generate()" onkeyup="generate(false)" />€<br>
|
||||
<label> </label><span id="summa_error" class="error" ></span><br>
|
||||
<label>Viite: </label><br><input id="viite" size=20 value=1054 onblur="generate()" onkeyup="generate(false)" /> Viite pakollinen, esim 1054 jos et keksi<br>
|
||||
<label>Viite: </label><br><input pattern="[0-9 ]+" id="viite" size=20 value=1054 onblur="generate()" onkeyup="generate(false)" /> Viite pakollinen, esim 1054 jos et keksi<br>
|
||||
<label> </label><span id="viite_error" class="error" ></span><br>
|
||||
<label>Eräpäivä: </label><br><input id="paiva" size=10 onblur="generate()" onkeyup="generate(false)" /><br>
|
||||
<label>Eräpäivä: </label><br><input type="text" pattern="[0-9\-]+" id="paiva" size=10 onblur="generate()" onkeyup="generate(false)" placeholder="VVVV-KK-PP"/><br>
|
||||
<label> </label><span id="paiva_error" class="error" ></span><br>
|
||||
<input type="submit" onclick="flash_generate()" value="Generoi"/>
|
||||
<br>
|
||||
|
||||
Reference in New Issue
Block a user