|
|
@ -11,6 +11,49 @@ function renumberTableRows(){ |
|
|
|
return i; |
|
|
|
} |
|
|
|
|
|
|
|
function checkAllRows(){ |
|
|
|
var row_no=1; |
|
|
|
var table = document.getElementById("tabbody"); |
|
|
|
for (var i = 0, row; row = table.rows[i]; i++) { |
|
|
|
// row.cells[0].innerHTML=row_no++;
|
|
|
|
//
|
|
|
|
var f=1 |
|
|
|
var v =row.cells[f].firstElementChild.value; |
|
|
|
if ( !v ){ // Datum
|
|
|
|
row.cells[f].firstElementChild.focus(); |
|
|
|
showAlert("Bitte gib ein gültiges Datum an!"); |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
f=2; |
|
|
|
v =row.cells[f].firstElementChild.value; |
|
|
|
if ( !v ){ // Datum
|
|
|
|
row.cells[f].firstElementChild.focus(); |
|
|
|
showAlert("Bitte gib ein Beschreibung ein!"); |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
f=3; |
|
|
|
v =row.cells[f].firstElementChild.value; |
|
|
|
if ( !v ){ // Datum
|
|
|
|
row.cells[f].firstElementChild.focus(); |
|
|
|
showAlert("Bitte gib einen gültigen Betrag ein!"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isMailable(){ |
|
|
|
var row_no=1; |
|
|
|
var table = document.getElementById("tabbody"); |
|
|
@ -23,6 +66,7 @@ function isMailable(){ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isFloat(val) { |
|
|
|
var floatRegex = /^-?\d+(?:[.,]\d*?)?$/; |
|
|
|
if (!floatRegex.test(val)) |
|
|
@ -35,6 +79,7 @@ function isFloat(val) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* grey-out currency iselection if there is at least one document is atatched. |
|
|
|
*/ |
|
|
@ -51,7 +96,6 @@ function disableCurrency() |
|
|
|
|
|
|
|
function deleteTableRow(rowId){ |
|
|
|
|
|
|
|
|
|
|
|
var target = document.getElementById("upload-target"+rowId); |
|
|
|
// this.message = app.message;
|
|
|
|
// var children = target.children;
|
|
|
@ -75,7 +119,6 @@ function deleteTableRow(rowId){ |
|
|
|
var element = document.getElementById("trow"+rowId); |
|
|
|
|
|
|
|
element.parentNode.removeChild(element); |
|
|
|
disableCurrency(); |
|
|
|
renumberTableRows(); |
|
|
|
// alert(rowId);
|
|
|
|
|
|
|
@ -85,13 +128,7 @@ function deleteTableRow(rowId){ |
|
|
|
|
|
|
|
|
|
|
|
function countRows(){ |
|
|
|
var ctr=0; |
|
|
|
for (i=0; i<currentRowId; i++){ |
|
|
|
var element = document.getElementById("trow"+i); |
|
|
|
if (element) |
|
|
|
ctr++ |
|
|
|
} |
|
|
|
return ctr; |
|
|
|
return renumberTableRows(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -112,7 +149,96 @@ function reset2() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function addTableRow(){ |
|
|
|
|
|
|
|
function setTableRow(id) |
|
|
|
{ |
|
|
|
var $node = $K.dom('#tabbody'); |
|
|
|
var element = document.createElement('tr'); |
|
|
|
element.setAttribute("id", "trow"+id); |
|
|
|
|
|
|
|
var e |
|
|
|
e = `<td>${a_date}
|
|
|
|
<input type="hidden" name="date[${currentRowId}]" value="${a_date}" /></td>`; |
|
|
|
|
|
|
|
$node.append(element); |
|
|
|
element.innerHTML=(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getUploadField(rid) |
|
|
|
{ |
|
|
|
var e = $K.dom('#uploadfield'); |
|
|
|
var uf =`<div class="upload"
|
|
|
|
data-kube="upload" |
|
|
|
data-type="file" |
|
|
|
data-multiple="true" |
|
|
|
data-target="#upload-target${rid}" |
|
|
|
data-url="upload.php?row=${rid}" data-url-remove="delete.php" |
|
|
|
data-progress="true" |
|
|
|
data-size="40" |
|
|
|
data-placeholder="drag!"> |
|
|
|
</div> |
|
|
|
<div id="upload-target${rid}" class="upload-target small"></div> |
|
|
|
</div> |
|
|
|
`;
|
|
|
|
return uf; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getRow(rid,num) { |
|
|
|
return "" |
|
|
|
+ "<td>" |
|
|
|
+ `${num}` |
|
|
|
+"</td>" |
|
|
|
+ "<td>" |
|
|
|
+ `<input name="date[${rid}]" value="" type="date" placeholder="Datum*"/>` |
|
|
|
+ "</td>" |
|
|
|
+ "<td>" |
|
|
|
+ `<input name="desc[${rid}]" type="text" placeholder="Beschreibung"/>` |
|
|
|
+ "</td>" |
|
|
|
+ "<td>" |
|
|
|
+ '<input type="text" placeholder="0.00"/>' |
|
|
|
+ "</td>" |
|
|
|
+ "<td>" |
|
|
|
+ |
|
|
|
`<select id="a_currency" name="currency" >
|
|
|
|
<option value="EUR">EUR</option> |
|
|
|
<option value="USD">USD</option> |
|
|
|
<option value="CHF">CHF</option> |
|
|
|
<option value="XBT">XBT</option> |
|
|
|
</select>` |
|
|
|
|
|
|
|
+ "</td>" |
|
|
|
+ "<td>" |
|
|
|
+ getUploadField(rid) |
|
|
|
+ "</td>" |
|
|
|
+ |
|
|
|
`<td><span
|
|
|
|
onclick="deleteTableRow(${rid})" |
|
|
|
class="close is-large"> |
|
|
|
</span></td>`; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var nextRid = 1 |
|
|
|
|
|
|
|
function addRow() { |
|
|
|
var $node = $K.dom('#tabbody'); |
|
|
|
var e = getRow(nextRid,1); |
|
|
|
var element = document.createElement('tr'); |
|
|
|
element.setAttribute("id", "trow"+nextRid); |
|
|
|
$node.append(element); |
|
|
|
element.innerHTML=(e); |
|
|
|
renumberTableRows(); |
|
|
|
nextRid++; |
|
|
|
} |
|
|
|
|
|
|
|
function xaddTableRow(){ |
|
|
|
|
|
|
|
var $node = $K.dom('#tabbody'); |
|
|
|
// create a new table row with id
|
|
|
@ -230,11 +356,11 @@ function addTableRow(){ |
|
|
|
renumberTableRows(); |
|
|
|
currentRowId++; |
|
|
|
reset2(); |
|
|
|
disableCurrency(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setUploadField() |
|
|
|
{ |
|
|
|
var e = $K.dom('#uploadfield'); |
|
|
@ -327,6 +453,12 @@ function downloadDocument1(){ |
|
|
|
|
|
|
|
function downloadDocument(mail) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (!checkAllRows()) |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (!check_field("projectid", "Bitte gib einen Projektnamen/Zweck der Reise an!")) |
|
|
|
return; |
|
|
|
|
|
|
@ -363,7 +495,7 @@ function downloadDocument(mail) |
|
|
|
|
|
|
|
|
|
|
|
if (countRows()==0){ |
|
|
|
document.getElementById("a_description").focus(); |
|
|
|
document.getElementById("add_issue").focus(); |
|
|
|
showAlert("Bitte füge mind. eine Auslage hinzu!"); |
|
|
|
return; |
|
|
|
} |
|
|
|