New (old) layout implmented

This commit is contained in:
Tobias Herre 2021-06-12 19:43:05 +02:00
parent 769eada180
commit 8478eb1f94
4 changed files with 166 additions and 58 deletions

50
ka.php
View File

@ -201,64 +201,26 @@ Grund für abweichende kontoinhabende Person"></textarea>
<fieldset id="fieldset2">
<legend>2. Erfasse deine Ausgaben</legend>
<div class="is-row">
<div class="is-col is-70">
<div class="is-row">
<div class="is-col is-60">
<input id="a_date" type="date" name="a_date" placeholder="Datum*"/>
<!-- <input id="a_type" type="text" name="type" placeholder="Auslagenart*"/> -->
</div>
<div class="is-col is-40">
</div>
</div>
<br>
<input id="a_description" type="text" name="description" placeholder="Beschreibung*"/>
<br>
<div class="is-row">
<div class="is-col">
<input id="a_amount" type="text" name="amount" placeholder="Betrag*"/>
</div>
<div class="is-col">
<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>
<!-- <input id="a_currency" type="text" name="curreny" placeholder="Waehrung*"/> -->
</div>
<div class="is-col">
<button type="button" onclick="addTableRow();"
class="button is-green">Ausgabe hinzuf&uuml;gen</button>
</div>
</div>
</div>
<div class="is-col is-30">
<div id="uploadfield" class="form-item">
</div>
</div>
</div>
<br>
<table id="tabtab" class="is-bordered is-striped">
<thead>
<tr>
<!-- <th>Auslagenart</th>-->
<th>Pos.</th>
<th>Datum</th>
<th>Beschreibung</th>
<th>Betrag</th>
<th>Währung</th>
<th>Belege</th>
<th>L&ouml;schen</th>
</tr>
</thead>
<tbody id="tabbody">
</tbody>
</table>
<div class="is-col">
<button id="add_issue" type="button" onclick="addRow();"
class="button is-green">Ausgabe hinzuf&uuml;gen</button>
</div>
</fieldset>
<br>
<fieldset>

156
kaform.js
View File

@ -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&uuml;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&uuml;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&uuml;ge mind. eine Auslage hinzu!");
return;
}

View File

@ -6,6 +6,10 @@ require "PHPMailer/PHPMailer.php";
require "PHPMailer/SMTP.php";
require "PHPMailer/Exception.php";
var_dump($_POST);
die;
#$CONVERT_CMD = "/usr/bin/pdftk";
require_once('TCPDF/tcpdf.php');

View File

@ -1,6 +1,10 @@
<?php
session_start();
#error_log("Here is upload.php");
file_put_contents("/tmp/log.txt", "uploadder\n", FILE_APPEND | LOCK_EX);
function xvar_dump ($x) {
ob_start();
var_dump($x);
@ -28,10 +32,13 @@ foreach ($_FILES as $key=>$files){
"id" => $tmpname,
"size" => sprintf("%0.1fK",$files['size'][$i]/1024.0)
);
file_put_contents("/tmp/log.txt", "file-$key-$i\n", FILE_APPEND | LOCK_EX);
file_put_contents("/tmp/log.txt", $files['name'][$i], FILE_APPEND | LOCK_EX);
}
$_SESSION['files'][$tmpname]['content']=
file_get_contents($tmpname);
$_SESSION['files'][$tmpname]['content']=file_get_contents($tmpname);
$_SESSION['files'][$tmpname]['row']=$_GET['row'];
@ -48,6 +55,9 @@ foreach ($_SESSION['files'] as $key => $val) {
$j = json_encode ($jo);
echo $j;
file_put_contents("/tmp/log.txt", $j, FILE_APPEND | LOCK_EX);
#error_log("\n\n ----- files ----- \n\n$files\n\n\n");
#$xp = xvar_dump($_FILES);
#error_log("\n\n ----- FILES ----- \n\n$$xp\n\n\n");