2020-02-20 13:45:47 +00:00
|
|
|
|
2020-02-25 08:07:29 +00:00
|
|
|
var currentRowId=1;
|
2020-02-28 15:04:43 +00:00
|
|
|
var banktype = "bank-eu";
|
2020-02-25 00:23:43 +00:00
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
function renumberTableRows(){
|
|
|
|
var row_no=1;
|
|
|
|
var table = document.getElementById("tabbody");
|
|
|
|
for (var i = 0, row; row = table.rows[i]; i++) {
|
2020-02-25 00:23:43 +00:00
|
|
|
// row.cells[0].innerHTML=row_no++;
|
2020-02-20 13:45:47 +00:00
|
|
|
}
|
2020-03-06 16:00:52 +00:00
|
|
|
return i;
|
2020-02-20 13:45:47 +00:00
|
|
|
}
|
|
|
|
|
2020-02-25 08:07:29 +00:00
|
|
|
|
|
|
|
function isFloat(val) {
|
|
|
|
var floatRegex = /^-?\d+(?:[.,]\d*?)?$/;
|
|
|
|
if (!floatRegex.test(val))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
val = parseFloat(val);
|
|
|
|
if (isNaN(val))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-06 16:00:52 +00:00
|
|
|
function disableCurrency()
|
|
|
|
{
|
|
|
|
if (countRows()>0){
|
|
|
|
document.getElementById("a_currency").disabled=true;
|
|
|
|
}
|
|
|
|
else {
|
2020-03-09 15:18:28 +00:00
|
|
|
document.getElementById("a_currency").disabled=true;
|
2020-03-06 16:00:52 +00:00
|
|
|
}
|
2020-02-25 08:07:29 +00:00
|
|
|
|
2020-03-06 16:00:52 +00:00
|
|
|
}
|
2020-02-25 08:07:29 +00:00
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
function deleteTableRow(rowId){
|
2020-02-25 00:23:43 +00:00
|
|
|
|
2020-03-06 16:00:52 +00:00
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
var target = document.getElementById("upload-target"+rowId);
|
2020-02-25 08:07:29 +00:00
|
|
|
// this.message = app.message;
|
2020-02-25 08:53:52 +00:00
|
|
|
// var children = target.children;
|
2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
// delete all uploaded elements
|
2020-02-25 08:07:29 +00:00
|
|
|
/* for (var i = 0; i < children.length; i++) {
|
2020-02-20 13:45:47 +00:00
|
|
|
var tmp = children[i].getAttribute("data-id");
|
2020-02-25 08:07:29 +00:00
|
|
|
alert ("DEL");
|
|
|
|
alert (tmp);
|
2020-02-20 13:45:47 +00:00
|
|
|
$K.ajax.post({
|
|
|
|
url: 'delete.php',
|
|
|
|
data: 'id='+tmp,
|
|
|
|
before: function(xhr) {},
|
|
|
|
success: function(response) {},
|
|
|
|
error: function(response) {}
|
|
|
|
});
|
|
|
|
}
|
2020-02-25 08:07:29 +00:00
|
|
|
*/
|
2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
// delete the row from table
|
|
|
|
var element = document.getElementById("trow"+rowId);
|
2020-02-25 08:07:29 +00:00
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
element.parentNode.removeChild(element);
|
2020-03-06 16:00:52 +00:00
|
|
|
disableCurrency();
|
2020-02-20 13:45:47 +00:00
|
|
|
renumberTableRows();
|
|
|
|
// alert(rowId);
|
2020-03-06 16:00:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
}
|
|
|
|
|
2020-02-25 08:07:29 +00:00
|
|
|
|
2020-02-25 08:53:52 +00:00
|
|
|
function countRows(){
|
|
|
|
var ctr=0;
|
|
|
|
for (i=0; i<currentRowId; i++){
|
|
|
|
var element = document.getElementById("trow"+i);
|
|
|
|
if (element)
|
|
|
|
ctr++
|
|
|
|
}
|
|
|
|
return ctr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-25 08:07:29 +00:00
|
|
|
function showAlert(text) {
|
|
|
|
|
|
|
|
$K.app.message.show( { message: `${text}`, position: 'centered', type: 'is-error' });
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function reset2()
|
|
|
|
{
|
2020-03-04 11:01:42 +00:00
|
|
|
// document.getElementById("a_type").value="";
|
2020-02-25 08:07:29 +00:00
|
|
|
document.getElementById("a_description").value="";
|
|
|
|
document.getElementById("a_amount").value="";
|
|
|
|
setUploadField();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
function addTableRow(){
|
|
|
|
|
2020-02-25 08:07:29 +00:00
|
|
|
var $node = $K.dom('#tabbody');
|
|
|
|
// create a new table row with id
|
|
|
|
var element = document.createElement('tr');
|
|
|
|
element.setAttribute("id", "trow"+currentRowId);
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
|
2020-03-04 11:01:42 +00:00
|
|
|
/* var a_type = document.getElementById("a_type").value;
|
2020-02-25 08:07:29 +00:00
|
|
|
if (!a_type.trim().length ) {
|
|
|
|
document.getElementById("a_type").focus();
|
|
|
|
showAlert("Bitte gib eine Auslagenart an!");
|
|
|
|
return;
|
|
|
|
}
|
2020-03-04 11:01:42 +00:00
|
|
|
*/
|
2020-03-06 16:46:15 +00:00
|
|
|
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
var a_date = document.getElementById("a_date").value;
|
2020-02-25 08:07:29 +00:00
|
|
|
if (!a_date.trim().length){
|
|
|
|
document.getElementById("a_date").focus();
|
|
|
|
showAlert("Bitte gib ein gültiges Datum an!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
var a_description = document.getElementById("a_description").value;
|
2020-02-25 08:07:29 +00:00
|
|
|
if (!a_description.trim().length){
|
|
|
|
document.getElementById("a_description").focus();
|
|
|
|
showAlert("Bitte gib eine Beschreibung ein!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
var a_amount = document.getElementById("a_amount").value;
|
2020-02-25 08:07:29 +00:00
|
|
|
if (!isFloat(a_amount)){
|
|
|
|
document.getElementById("a_amount").focus();
|
|
|
|
showAlert("Bitte gib einen gültigen Betrag ein!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
var a_currency = document.getElementById("a_currency").value;
|
2020-02-25 08:07:29 +00:00
|
|
|
if (!a_currency.trim().length){
|
|
|
|
document.getElementById("a_currency").focus();
|
|
|
|
showAlert("Bitte gib eine Währung an!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var target = document.getElementById("upload-target"+currentRowId);
|
|
|
|
var children = target.children;
|
|
|
|
|
|
|
|
if (!children.length){
|
|
|
|
showAlert("Bitte lade mindestens einen Beleg hoch!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
|
|
|
|
/* a_type = "Hello";*/
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
var e="";
|
|
|
|
|
|
|
|
// add column for position no
|
2020-03-04 11:01:42 +00:00
|
|
|
// e += `<td>${a_type}
|
|
|
|
// <input type="hidden" name="type[${currentRowId}]" value="${a_type}" /></td>`;
|
2020-02-20 13:45:47 +00:00
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
// add coluemn for a_type (Auslagenart)
|
|
|
|
// e += `<td><textarea name="desc[${nextRowId}]" rows="2"></textarea> </td>`;
|
2020-02-25 10:59:24 +00:00
|
|
|
e += `<td>${a_date}
|
|
|
|
<input type="hidden" name="date[${currentRowId}]" value="${a_date}" /></td>`;
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
// add column for date
|
2020-02-25 00:23:43 +00:00
|
|
|
// e += `<td><input name="date[${nextRowId}]" type="date"/></td>`;
|
2020-02-25 10:59:24 +00:00
|
|
|
e += `<td>${a_description}
|
|
|
|
<input type="hidden" name="description[${currentRowId}]" value="${a_description}" /></td>`;
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
// add column for num
|
2020-02-25 10:59:24 +00:00
|
|
|
e += `<td>${a_amount}
|
|
|
|
<input type="hidden" name="amount[${currentRowId}]" value="${a_amount}" /></td>`;
|
|
|
|
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
// add column for file upload
|
2020-02-25 00:23:43 +00:00
|
|
|
/* e+= `
|
2020-02-20 13:45:47 +00:00
|
|
|
<td data-kube="">
|
|
|
|
<div class="form-item">
|
|
|
|
<div class="upload"
|
|
|
|
data-kube="upload"
|
|
|
|
data-type="file" data-multiple="true"
|
|
|
|
data-target="#upload-target${nextRowId}"
|
|
|
|
data-url="upload.php?row=${nextRowId}" data-url-remove="delete.php"
|
|
|
|
data-progress="true">
|
|
|
|
</div>
|
|
|
|
<div id="upload-target${nextRowId}" class="upload-target"></div>
|
|
|
|
</div>
|
|
|
|
</td>
|
2020-02-25 00:23:43 +00:00
|
|
|
*/
|
2020-03-06 12:32:24 +00:00
|
|
|
e += `<td>${a_currency}
|
|
|
|
<input type="hidden" name="currency[${currentRowId}]" value="${a_currency}" /></td>
|
|
|
|
</td>`;
|
2020-02-25 00:23:43 +00:00
|
|
|
|
|
|
|
// `;
|
2020-02-20 13:45:47 +00:00
|
|
|
// add delete bnutton
|
|
|
|
e +=
|
|
|
|
`<td><span
|
2020-02-25 08:07:29 +00:00
|
|
|
onclick="deleteTableRow(${currentRowId})"
|
2020-02-20 13:45:47 +00:00
|
|
|
class="close is-large">
|
|
|
|
</span></td>`;
|
|
|
|
|
|
|
|
|
|
|
|
$node.append(element);
|
|
|
|
element.innerHTML=(e);
|
2020-02-25 08:07:29 +00:00
|
|
|
// renumberTableRows();
|
|
|
|
currentRowId++;
|
|
|
|
reset2();
|
2020-03-06 16:00:52 +00:00
|
|
|
disableCurrency();
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
function setUploadField()
|
|
|
|
{
|
|
|
|
var e = $K.dom('#uploadfield');
|
|
|
|
var uf =`<div class="upload"
|
|
|
|
data-kube="upload"
|
|
|
|
data-type="file" data-multiple="true"
|
2020-02-25 08:07:29 +00:00
|
|
|
data-target="#upload-target${currentRowId}"
|
|
|
|
data-url="upload.php?row=${currentRowId}" data-url-remove="delete.php"
|
2020-02-25 00:23:43 +00:00
|
|
|
data-progress="true">Beleg hochladen
|
|
|
|
</div>
|
2020-02-25 08:07:29 +00:00
|
|
|
<div id="upload-target${currentRowId}" class="upload-target small"></div>
|
2020-02-25 00:23:43 +00:00
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
document.getElementById("uploadfield").innerHTML=uf;
|
|
|
|
}
|
2020-02-20 13:45:47 +00:00
|
|
|
|
2020-02-24 15:54:42 +00:00
|
|
|
$K.add('module', 'kaform', {
|
|
|
|
init: function(app, context)
|
|
|
|
{
|
|
|
|
this.app = app;
|
2020-02-25 08:07:29 +00:00
|
|
|
this.message = app.message;
|
2020-02-24 15:54:42 +00:00
|
|
|
},
|
|
|
|
// catch event
|
|
|
|
onmessage: {
|
|
|
|
tabs: {
|
|
|
|
opened: function(sender)
|
|
|
|
{
|
2020-02-28 15:04:43 +00:00
|
|
|
console.log('Tab box is ',sender.getActiveBox().nodes[0]);
|
|
|
|
|
|
|
|
banktype = sender.getActiveBox().nodes[0].attributes.id.value;
|
|
|
|
|
|
|
|
console.log(banktype);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(sender);
|
2020-02-25 08:53:52 +00:00
|
|
|
// this.message.show({ message: 'My message' });
|
2020-02-25 08:07:29 +00:00
|
|
|
}
|
2020-02-24 15:54:42 +00:00
|
|
|
}
|
|
|
|
},
|
2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
|
2020-02-24 15:54:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$K.init({
|
|
|
|
observer: true
|
2020-02-20 13:45:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// startup is here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// on startup clear session on server
|
|
|
|
$K.ajax.get({
|
|
|
|
url: 'clear.php',
|
|
|
|
data: '', // or key=value object
|
|
|
|
before: function(xhr) {},
|
|
|
|
success: function(response) {},
|
|
|
|
error: function(response) {}
|
|
|
|
});
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
setUploadField();
|
|
|
|
|
|
|
|
|
2020-02-25 08:53:52 +00:00
|
|
|
function check_field(fieldid,message){
|
|
|
|
var f = document.getElementById(fieldid).value;
|
|
|
|
if (! f.trim().length ) {
|
|
|
|
document.getElementById(fieldid).focus();
|
|
|
|
showAlert(message)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2020-02-25 08:07:29 +00:00
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
// add on table row
|
2020-02-24 15:54:42 +00:00
|
|
|
//addTableRow();
|
2020-02-25 08:53:52 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2020-03-09 15:18:28 +00:00
|
|
|
//
|
|
|
|
function downloadDocument2(){
|
|
|
|
downloadDocument(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function downloadDocument1(){
|
|
|
|
downloadDocument(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function downloadDocument(mail)
|
2020-02-25 08:53:52 +00:00
|
|
|
{
|
2020-03-06 09:03:43 +00:00
|
|
|
/* if (!check_field("nickname", "Bitte gib deinen Nicknamen an!"))
|
2020-02-25 08:53:52 +00:00
|
|
|
return;
|
2020-03-06 09:03:43 +00:00
|
|
|
*/ if (!check_field("realname", "Bitte gib deinen Realnamen an!"))
|
2020-02-25 08:53:52 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!check_field("email", "Bitte gib deinen E-Mail-Adresse an!"))
|
|
|
|
return;
|
|
|
|
if (!check_field("projectid", "Bitte gib idie Projekt-ID an!"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (countRows()==0){
|
2020-03-06 10:01:40 +00:00
|
|
|
document.getElementById("a_description").focus();
|
2020-02-25 08:53:52 +00:00
|
|
|
showAlert("Bitte füge mind. eine Auslage hinzu!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-28 15:04:43 +00:00
|
|
|
if (banktype == "bank-eu"){
|
|
|
|
iban = document.getElementById('iban');
|
|
|
|
if (!IBAN.isValid(iban.value)){
|
|
|
|
document.getElementById("iban").focus();
|
2020-03-04 11:01:42 +00:00
|
|
|
showAlert("Bitte gib eine korrekte IBAN ein!");
|
|
|
|
return;
|
|
|
|
}
|
2020-04-16 06:09:45 +00:00
|
|
|
/* if (!document.getElementById('bic').value.trim().length){
|
2020-03-04 11:01:42 +00:00
|
|
|
document.getElementById("bic").focus();
|
2020-04-16 06:09:45 +00:00
|
|
|
showAlert("Bitte gib einen korrekte BIC an!");
|
2020-02-28 15:04:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-03-04 11:01:42 +00:00
|
|
|
|
2020-04-16 06:09:45 +00:00
|
|
|
*/
|
2020-02-28 15:04:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (banktype == "bank-paypal"){
|
|
|
|
ii = document.getElementById('paypal');
|
|
|
|
if (!document.getElementById('paypal').value.trim().length){
|
|
|
|
document.getElementById("paypal").focus();
|
|
|
|
showAlert("Bitte gib einen PayPal Account an!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-06 16:46:15 +00:00
|
|
|
if (!document.getElementById("agree").checked){
|
|
|
|
document.getElementById("agree").focus();
|
|
|
|
showAlert("Bitte bestätige, dass du alle Angaben nach bestem Wissen und Gewissen gemacht hast!");
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
2020-03-09 15:18:28 +00:00
|
|
|
if (mail){
|
|
|
|
document.getElementById('sendmail').value="yes";
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
document.getElementById('sendmail').value="no";
|
|
|
|
|
|
|
|
}
|
2020-02-28 15:04:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('banktype').value=banktype;
|
2020-02-25 08:53:52 +00:00
|
|
|
document.getElementById("theform").submit();
|
|
|
|
}
|
2020-02-28 15:04:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
function checkIban()
|
|
|
|
{
|
|
|
|
iban = document.getElementById('iban');
|
|
|
|
if(IBAN.isValid(iban.value))
|
|
|
|
|
|
|
|
if( document.getElementById('eu').checked ) {
|
|
|
|
|
|
|
|
if(IBAN.isValid(iban.value))
|
|
|
|
{
|
|
|
|
if(iban.classList.contains('invalid')) iban.classList.remove('invalid');
|
|
|
|
iban.classList.add('valid');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(iban.classList.contains('valid')) iban.classList.remove('valid');
|
|
|
|
iban.classList.add('invalid');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(iban.classList.contains('invalid')) iban.classList.remove('invalid');
|
|
|
|
if(iban.classList.contains('valid')) iban.classList.remove('valid');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2020-03-06 16:00:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|