2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
var nextRowId=1;
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
function getNextRowId() {
|
|
|
|
return nextRowId;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteTableRow(rowId){
|
2020-02-25 00:23:43 +00:00
|
|
|
|
|
|
|
alert (rowId);
|
2020-02-20 13:45:47 +00:00
|
|
|
var target = document.getElementById("upload-target"+rowId);
|
|
|
|
var children = target.children;
|
|
|
|
|
|
|
|
// delete all uploaded elements
|
|
|
|
for (var i = 0; i < children.length; i++) {
|
|
|
|
var tmp = children[i].getAttribute("data-id");
|
|
|
|
$K.ajax.post({
|
|
|
|
url: 'delete.php',
|
|
|
|
data: 'id='+tmp,
|
|
|
|
before: function(xhr) {},
|
|
|
|
success: function(response) {},
|
|
|
|
error: function(response) {}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// delete the row from table
|
|
|
|
var element = document.getElementById("trow"+rowId);
|
|
|
|
element.parentNode.removeChild(element);
|
|
|
|
renumberTableRows();
|
|
|
|
// alert(rowId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function addTableRow(){
|
|
|
|
|
|
|
|
var $node = $K.dom('#tabbody');
|
|
|
|
// create a new table row with id
|
|
|
|
var element = document.createElement('tr');
|
|
|
|
element.setAttribute("id", "trow"+nextRowId);
|
|
|
|
|
2020-02-25 00:23:43 +00:00
|
|
|
|
|
|
|
var a_type = document.getElementById("a_type").value;
|
|
|
|
var a_date = document.getElementById("a_date").value;
|
|
|
|
var a_description = document.getElementById("a_description").value;
|
|
|
|
var a_amount = document.getElementById("a_amount").value;
|
|
|
|
var a_currency = document.getElementById("a_currency").value;
|
|
|
|
|
|
|
|
/* a_type = "Hello";*/
|
|
|
|
|
2020-02-20 13:45:47 +00:00
|
|
|
var e="";
|
|
|
|
|
|
|
|
// add column for position no
|
2020-02-25 00:23:43 +00:00
|
|
|
e += `<td>${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>`;
|
|
|
|
e += `<td>${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>`;
|
|
|
|
e += `<td>${a_description}</td>`;
|
2020-02-20 13:45:47 +00:00
|
|
|
|
|
|
|
// add column for num
|
2020-02-25 00:23:43 +00:00
|
|
|
e += `<td>${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
|
|
|
*/
|
|
|
|
e += `<td>${a_currency}</td>`;
|
|
|
|
|
|
|
|
// `;
|
2020-02-20 13:45:47 +00:00
|
|
|
// add delete bnutton
|
|
|
|
e +=
|
|
|
|
`<td><span
|
|
|
|
onclick="deleteTableRow(${nextRowId})"
|
|
|
|
class="close is-large">
|
|
|
|
</span></td>`;
|
|
|
|
|
|
|
|
|
|
|
|
$node.append(element);
|
|
|
|
element.innerHTML=(e);
|
|
|
|
renumberTableRows();
|
|
|
|
nextRowId++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
data-target="#upload-target${nextRowId}"
|
|
|
|
data-url="upload.php?row=${nextRowId}" data-url-remove="delete.php"
|
|
|
|
data-progress="true">Beleg hochladen
|
|
|
|
</div>
|
|
|
|
<div id="upload-target${nextRowId}" class="upload-target small"></div>
|
|
|
|
</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;
|
|
|
|
},
|
|
|
|
// catch event
|
|
|
|
onmessage: {
|
|
|
|
tabs: {
|
|
|
|
opened: function(sender)
|
|
|
|
{
|
|
|
|
console.log('Tab box is ',sender.getActiveBox());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
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-20 13:45:47 +00:00
|
|
|
// add on table row
|
2020-02-24 15:54:42 +00:00
|
|
|
//addTableRow();
|