<link rel="stylesheet" href="../../node_modules/@fortawesome/fontawesome-free/css/fontawesome.min.css">
<link rel="stylesheet" href="../../css/cashbox.epic.css">
<link rel="stylesheet" href="../../css/app.css">
-<title>Kunden</title>
+<title>Konten</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<div class="ml-auto">
<div class="btn-group" role="group" aria-label="Basic example">
<button class="btn btn-primary" onclick="account_new();"><i class="fas fa-plus"></i><br/>New</button>
- <button class="btn btn-primary" onclick="account_edit();"><i class="fas fa-edit"></i><br/>Edit</button>
+ <!-- <button class="btn btn-primary" onclick="account_edit();"><i class="fas fa-edit"></i><br/>Edit</button> -->
<button class="btn btn-primary" onclick="account_delete();"><i class="fas fa-trash"></i><br/>Delete</button>
</div>
</nav>
- <div class="cotainer-fluid" style="margin-top: 52px;">
+ <div class="cotainer-fluid bg-white" style="margin-top: 52px;">
<table id="tbl_accounts" class="table table-bordered table-hover table-striped">
<thead class="thead-dark">
<th data-checkbox="true"></th>
var data = appdb.dbquery(sql);
console.log("load accounts table " + sql);
console.log(data.sqldata);
+ $('#tbl_accounts').bootstrapTable('destroy');
$('#tbl_accounts > tbody').html("");
for (var i in data.sqldata){
var row = '<tr id="' +data.sqldata[i].id + '"><td></td>'+
'<td><input type="checkbox" class="form-control" id="accounts-visible" name="accounts-visible" onfocusout="account.savevalue(this);" value="'+data.sqldata[i].visible+ '" '+ ((data.sqldata[i].visible == '1')?"checked":'')+'/></td>' +
'<td><input type="text" class="form-control font-weight-bold" id="accounts-name" name="accounts-name" onfocusout="account.savevalue(this);" value="'+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+'"/></td>' +
'<td><input type="text" class="form-control" list="accounttypes" id="accounts-type" name="accounts-type" onfocusout="account.savevalue(this);" value="' + (( data.sqldata[i].type!= null)?data.sqldata[i].type:'')+ '"/></td>' +
- '<td><textarea rows="3" class="form-control" id="accounts-info" name="accounts-info" onfocusout="account.savevalue(this);" >' + (( data.sqldata[i].info!= null)?data.sqldata[i].info:'')+ '</textarea></td>' +
+ '<td><input type="text" class="form-control" id="accounts-info" name="accounts-info" onfocusout="account.savevalue(this);" value="' + (( data.sqldata[i].info!= null)?data.sqldata[i].info:'')+ '"/></td>' +
'</tr>';
$("#tbl_accounts").append(row);
}
'<td><input type="checkbox" class="form-control" id="accounts-visible" name="accounts-visible" onfocusout="account.savevalue(this);" value=""/></td>' +
'<td><input type="text" class="form-control font-weight-bold" id="accounts-name" name="accounts-name" onfocusout="account.savevalue(this);" value=""/></td>' +
'<td><input type="text" class="form-control" list="accounttypes" id="accounts-type" name="accounts-type" onfocusout="account.savevalue(this);" value=""/></td>' +
- '<td><textarea rows="3" class="form-control" id="accounts-info" name="accounts-info" onfocusout="account.savevalue(this);" ></textarea></td>' +
+ '<td><input type="text" class="form-control" id="accounts-info" name="accounts-info" onfocusout="account.savevalue(this);" value=""/></td>' +
'</tr>';
$("#tbl_accounts").prepend(row);
}
function account_delete(){
- var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Konten löschen?",null,"question",msgButtons=["JA","NEIN"],0,1);
- console.log("Delete return:" + ret);
- if (ret == 0){
+ // var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Konten löschen?",null,"question",msgButtons=["JA","NEIN"],0,1);
+ // console.log("Delete return:" + ret);
+ // if (ret == 0){
//delete
var ids= getTableSelectionIDs();
console.log(ids);
account.delete(ids);
- loadtable();
- }
+ for (var i in ids){
+ $("#tbl_accounts tr#" + ids[i]).remove();
+ }
+ // }
}
function loaddatalist_accounttypes(){
var ids = [];
if (sel){
for (var s in sel){
- ids.push(s._id);
+ ids.push(sel[s]._id);
}
}
return ids;
var listval = $("#grouplist" + listnum + " :selected").val();
//console.log(listval);
$('#producttable' + listnum + " > tbody").html("");
- var sql ="select id,name,specification,replace(printf(\"%.2f\",grossamount),'.',',') as grossamount from products where productgroup='"+appdb.secvalue(listval)+"';";
+ var sql ="select id,name,specification,replace(printf(\"%.2f\",grossamount),'.',',') as grossamount from products where productgroup='"+appdb.secvalue(listval)+"' order by name, specification;";
var products = appdb.dbquery(sql);
for (var i in products.sqldata){
function addproduct(idproduct){
//console.log(idproduct);
- var sql = "select id,name,specification,grossamount,netamount,vatpercent,replace(printf(\"%.2f\",grossamount),'.',',') as dsp_grossamount from products where id='"+idproduct+"';";
+ var sql = "select id,name,specification,productgroup,grossamount,netamount,vatpercent,replace(printf(\"%.2f\",grossamount),'.',',') as dsp_grossamount from products where id='"+idproduct+"';";
//console.log(sql);
var product = appdb.dbquery(sql);
var trow = "";
$("#checkout > tbody").append(trow);
//console.log(sc_idprod);
- shoppingcart['products'][sc_idprod] = {quantity:1,id_product:idprod,grossamount: product.sqldata[0].grossamount,vatamount: product.sqldata[0].vatamount,netamount: product.sqldata[0].netamount};
+ shoppingcart['products'][sc_idprod] = {quantity:1,id_product:idprod,productname:product.sqldata[0].name,productgroup:product.sqldata[0].productgroup,grossamount: product.sqldata[0].grossamount,vatamount: product.sqldata[0].vatamount,netamount: product.sqldata[0].netamount};
}
}
calctotal();
var sql = "select tr.id,strftime('%d.%m.%Y %H:%M:%S',tr.created) as created,acc.name,printf('%.2f€',sum(td.grossamount * td.quantity)) as totalamount, sum(td.quantity) as products_nbr from transactions tr left join accounts acc on (tr.id_account=acc.id) left join transactiondata td on (tr.id=td.id_transaction) where tr.status='command' group by tr.id order by tr.created asc;";
$('#tbl_commands > tbody').html("");
var data = appdb.dbquery(sql);
- console.log("commands table list")
+ console.log("commands table list");
console.log(data);
for (var i in data.sqldata){
var row = '<tr>'+
}
function save_shoppingcart(){
- console.log(shoppingcart['products'].length);
+ console.log(shoppingcart['transaction']['status']);
+ if (shoppingcart['transaction']['status'] === undefined){
+
+ shoppingcart['transaction']['status'] = 'unknown';
+ }
+ console.log(shoppingcart['transaction']);
+
if (Object.keys(shoppingcart['products']) == 0){
return;
}
if ($("#sumtotalcashamount").html() != ""){
shoppingcart['transaction']['cashamount'] = parseFloat($("#sumtotalcashamount").html().replace(',','.'));
}
- if (shoppingcart['transaction']['payedamount'] && shoppingcart['transaction']['payedamount'] != null){
- shoppingcart['transaction']['status'] = "payed";
-
+ if (shoppingcart['transaction']['payedamount'] >= 0.0){
+ shoppingcart['transaction']['status'] = "payed";
} else {
- shoppingcart['transaction']['status'] = "command";
+ shoppingcart['transaction']['status'] = "command";
}
console.log('save shoppingcard');
if (newtrans == true){
var updsql = "UPDATE transactions SET payementtype="+((shoppingcart['transaction']['paymenttype'])?"'"+shoppingcart['transaction']['paymenttype']+"'":'null')+", id_account="+((shoppingcart['transaction']['account'] && shoppingcart['transaction']['account']['id'])?"'"+shoppingcart['transaction']['account']['id']+"'":'null')+", payedamount="+((shoppingcart['transaction']['payedamount'])?shoppingcart['transaction']['payedamount']:'null')+", cashbackamount="+((shoppingcart['transaction']['cashbackamount'])?shoppingcart['transaction']['cashbackamount']:'null')+", cashamount="+((shoppingcart['transaction']['cashamount'])?shoppingcart['transaction']['cashamount']:'null')+", status='"+shoppingcart['transaction']['status']+"', statusdate=date('now') WHERE id='"+shoppingcart['transaction']['id']+"';";
appdb.dbexec(updsql);
}
- console.log(tsql);
+ //console.log(tsql);
for (var i in shoppingcart["products"]){
- var tdsql = "INSERT INTO transactiondata (id, id_transaction, id_product, id_account, netamount, vatamount, grossamount, quantity) VALUES('" +appdb.generate_uuid()+"', '"+shoppingcart['transaction']['id']+"', '"+shoppingcart["products"][i]['id_product']+"', "+((shoppingcart['transaction']['account'] && shoppingcart['transaction']['account']['id'])?"'"+shoppingcart['transaction']['account']['id']+"'":'null')+", "+((shoppingcart["products"][i]['netamount'])?shoppingcart["products"][i]['netamount']:'null')+", "+((shoppingcart["products"][i]['vatamount'])?shoppingcart["products"][i]['vatamount']:'null')+", "+((shoppingcart["products"][i]['grossamount'])?shoppingcart["products"][i]['grossamount']:'null')+", "+shoppingcart["products"][i]['quantity']+");";
- console.log(tdsql);
+ var tdsql = "INSERT INTO transactiondata (id, id_transaction, id_product, id_account, netamount, vatamount, grossamount, quantity,productname,productgroup) VALUES('" +appdb.generate_uuid()+"', '"+shoppingcart['transaction']['id']+"', '"+shoppingcart["products"][i]['id_product']+"', "+((shoppingcart['transaction']['account'] && shoppingcart['transaction']['account']['id'])?"'"+shoppingcart['transaction']['account']['id']+"'":'null')+", "+((shoppingcart["products"][i]['netamount'])?shoppingcart["products"][i]['netamount']:'null')+", "+((shoppingcart["products"][i]['vatamount'])?shoppingcart["products"][i]['vatamount']:'null')+", "+((shoppingcart["products"][i]['grossamount'])?shoppingcart["products"][i]['grossamount']:'null')+", "+shoppingcart["products"][i]['quantity']+","+((shoppingcart['products'][i]['productname'])?"'"+shoppingcart['products'][i]['productname']+"'":'null')+","+((shoppingcart['products'][i]['productgroup'])?"'"+shoppingcart['products'][i]['productgroup']+"'":'null')+");";
+ // console.log(tdsql);
appdb.dbexec(tdsql);
}
console.log(shoppingcart);
$("#sumtotalchangeamount").html("");
$('#'+ptype).attr('checked', 'checked');
setpayementtype(ptype);
+ //console.log(shoppingcart['transaction']);
$('#dlgPayement').modal('show');
}
shoppingcart['transaction']['cashbackamount'] = null;
}
if ($("#"+ptype).prop('checked')){
- shoppingcart['transaction']['payementtype'] =ptype;
+ shoppingcart['transaction']['paymenttype'] =ptype;
}
}
if (ncash >= ntotal){
shoppingcart['transaction']['payedamount'] = shoppingcart['transaction']['grossamount'];
}
-
- // if (ncash >= ntotal){
- // $("#sumtotalpayedamount").html($("#sumtotalcashamount").html());
- // } else {
- // $("#sumtotalpayedamount").html($("#pay_sumtotal").html());
- // }
+ //console.log(shoppingcart['transaction']);
}
\ No newline at end of file
<div class="ml-auto">
<div class="btn-group" role="group" aria-label="Basic example">
<button class="btn btn-primary" onclick="product_new();"><i class="fas fa-plus"></i><br/>New</button>
- <button class="btn btn-primary" onclick="product_edit();"><i class="fas fa-edit"></i><br/>Edit</button>
<button class="btn btn-primary" onclick="product_delete();"><i class="fas fa-trash"></i><br/>Delete</button>
- <button class="btn btn-primary" onclick="product_duplicate();"><i class="fas fa-clone"></i><br/>Dupl.</button>
+ <!-- <button class="btn btn-primary" onclick="product_duplicate();"><i class="fas fa-clone"></i><br/>Dupl.</button> -->
</div>
</nav>
<th data-checkbox="true"></th>
<th data-sortable="true" data-width="20"><i class="fas fa-cash-register"></i></th>
<th data-sortable="true">Produkt</th>
+ <th data-sortable="true"data-width="250">Specifikation</th>
<th data-sortable="true" data-width="200">Gruppe</th>
<th data-sortable="true" data-width="70" data-align="right">Netto (€)</th>
<th data-sortable="true" data-width="30" data-align="right">MwSt. (%)</th>
var data = appdb.dbquery(sql);
console.log(data.sqldata);
+ $('#tbl_products').bootstrapTable('destroy');
$('#tbl_products > tbody').html("");
for (var i in data.sqldata){
var row = '<tr id="' +data.sqldata[i].id + '"><td></td>'+
'<td><input type="checkbox" class="form-control" id="products-visible" name="products-visible" onfocusout="product.savevalue(this);" value="'+data.sqldata[i].visible+ '" '+ ((data.sqldata[i].visible == '1')?"checked":'')+'/></td>' +
- '<td><input type="text" class="form-control font-weight-bold" id="products-name" name="products-name" onfocusout="product.savevalue(this);" value="'+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+'"/><br><input class="form-control" type="text" onfocusout="product.savevalue(this);" id="products-specification" name="products-specification" value="' + ((data.sqldata[i].specification != null)?data.sqldata[i].specification:'')+ '" /></td>' +
+ '<td><input type="text" class="form-control font-weight-bold" id="products-name" name="products-name" onfocusout="product.savevalue(this);" value="'+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+'"/></td>'+
+ '<td><input class="form-control" type="text" onfocusout="product.savevalue(this);" id="products-specification" name="products-specification" value="' + ((data.sqldata[i].specification != null)?data.sqldata[i].specification:'')+ '" /></td>' +
'<td><input type="text" class="form-control" list="productgroup" id="products-productgroup" name="products-productgroup" onfocusout="product.savevalue(this);" value="' + (( data.sqldata[i].productgroup!= null)?data.sqldata[i].productgroup:'')+ '"/></td>' +
'<td><input type="text" class="form-control right" id="products-netamount" name="products-netamount" onfocusout="product.savevalue(this);" value="' + data.sqldata[i].netamount+ '" /></td>' +
'<td><input type="text" class="form-control right" list="vatpercent" id="products-vatpercent" name="products-vatpercent" onfocusout="product.savevalue(this);" value="' + data.sqldata[i].vatpercent+ '" /></td>' +
}
function product_new (){
- var prid = products.new();
- var row = '<tr id="'+ prid+'"><td></td>'+
- '<td><input type="checkbox" class="form-control" id="visible" name="visible" value="1"/></td>' +
- '<td><input type="text" class="form-control" value=""/><br><input class="form-control" type="text" value="" /></td>' +
- '<td><input type="text" class="form-control" list="productgroup" value=""/></td>' +
- '<td><input type="text" class="form-control right" value="0,00" /></td>' +
- '<td><input type="text" class="form-control right" list="vatpercent" value="0,17" /></td>' +
- '<td><input type="text" class="form-control right" value="0,00" /></td>' +
- '</tr>';
+ var prid = product.new();
+ console.log(prid)
+ var row = '<tr id="'+prid+'"><td></td>'+
+ '<td><input type="checkbox" class="form-control" id="products-visible" name="products-visible" onfocusout="product.savevalue(this);" value="" /></td>' +
+ '<td><input type="text" class="form-control font-weight-bold" id="products-name" name="products-name" onfocusout="product.savevalue(this);" value=""/></td>' +
+ '<td><input class="form-control" type="text" onfocusout="product.savevalue(this);" id="products-specification" name="products-specification" value="" /></td>' +
+ '<td><input type="text" class="form-control" list="productgroup" id="products-productgroup" name="products-productgroup" onfocusout="product.savevalue(this);" value=""/></td>' +
+ '<td><input type="text" class="form-control right" id="products-netamount" name="products-netamount" onfocusout="product.savevalue(this);" value="0,00" /></td>' +
+ '<td><input type="text" class="form-control right" list="vatpercent" id="products-vatpercent" name="products-vatpercent" onfocusout="product.savevalue(this);" value="0,00" /></td>' +
+ '<td><input type="text" class="form-control right" id="products-grossamount" name="products-grossamount" onfocusout="product.savevalue(this);" value="0,00" /></td>' +
+ '</tr>';
$("#tbl_products").prepend(row);
+ $('#tbl_products').bootstrapTable('refresh');
}
function product_delete(){
- var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Produkte löschen?",null,"question",msgButtons=["JA","NEIN"],0,1);
- console.log("Delete return:" + ret);
- if (ret == 0){
+ // var ret = parent.usersystem.showMessage("Bestätigung erforderlich","Ausgewählte Produkte löschen?",null,"question",msgButtons=["JA","NEIN"],0,1);
+ // console.log("Delete return:" + ret);
+ // if (ret == 0){
//delete
var ids= getTableSelectionIDs();
console.log(ids);
- //product.delete(ids);
- loadtable();
- }
+ product.delete(ids);
+ for (var i in ids){
+ $("#tbl_products tr#" + ids[i]).remove();
+ }
+ // }
}
-function product_duplicate(){
- var ids= getTableSelectionIDs();
- console.log(ids);
- product.duplicate(ids);
- loadtable();
-}
+// function product_duplicate(){
+// var ids= getTableSelectionIDs();
+// console.log(ids);
+// // product.duplicate(ids);
+// loadtable();
+// }
function getTableSelectionID(){
var sel = $('#tbl_products').bootstrapTable('getSelections');
function getTableSelectionIDs(){
var sel = $('#tbl_products').bootstrapTable('getSelections');
var ids = [];
+ console.log(sel);
if (sel){
for (var s in sel){
- ids.push(s._id);
+ ids.push(sel[s]._id);
}
}
return ids;
savevalue="'"+ savevalue+"'";
}
var ds = obj.id.split("-");
+
var sql = "update " + ds[0]+" set "+ds[1]+ "="+savevalue+" where id='"+obj.parentNode.parentNode.id+"';";
console.log(sql);
appdb.dbexec(sql);
+
+ if ((ds[1]) == 'grossamount'){
+ savevalue=parseFloat(savevalue.replace("'",''));
+ var tmpvat =parseFloat($("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-vatpercent').val().replace(',','.'))/100;
+ //console.log("VAT:" + tmpvat);
+ var netamount = savevalue - ((savevalue / 1 +tmpvat) * tmpvat);
+ var sql2 = "update " + ds[0]+" set netamount="+netamount+" where id='"+obj.parentNode.parentNode.id+"';";
+ console.log(sql2);
+ appdb.dbexec(sql2);
+ $("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-netamount').val(netamount.toFixed(2).toString().replace('.',','));
+ }
+
+ if ((ds[1]) == 'vatpercent'){
+ savevalue=parseFloat(savevalue.replace("'",''));
+ savevalue = savevalue/100;
+ var tmpgross = parseFloat($("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-grossamount').val().replace(',','.'));
+ console.log("VAT:" + savevalue + " Gross:" + tmpgross);
+ var netamount = tmpgross - ((tmpgross / (1 +savevalue)) * savevalue);
+ var sql2 = "update " + ds[0]+" set netamount="+netamount+" where id='"+obj.parentNode.parentNode.id+"';";
+ console.log(sql2);
+ appdb.dbexec(sql2);
+ $("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-netamount').val(netamount.toFixed(2).toString().replace('.',','));
+ }
+ if ((ds[1]) == 'netamount'){
+ savevalue=parseFloat(savevalue.replace("'",''));
+ var tmpvat =parseFloat($("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-vatpercent').val().replace(',','.'))/100;
+ //console.log("VAT:" + tmpvat);
+ var grossamount = savevalue + (savevalue * tmpvat);
+ var sql2 = "update " + ds[0]+" set grossamount="+grossamount+" where id='"+obj.parentNode.parentNode.id+"';";
+ //console.log(sql2);
+ appdb.dbexec(sql2);
+ $("#" +obj.parentNode.parentNode.id).find("#"+ds[0] + '-grossamount').val(grossamount.toFixed(2).toString().replace('.',','));
+ }
+
},
import: function(){
appdb.dbexec(sql);
},
new: function(){
- var prid = appdb.generate_uuid;
- appdb.dbexec("insert into products (id) VALUES ('"+ prid+"');");
+ var prid = appdb.generate_uuid();
+ appdb.dbexec("insert into products (id,netamount,vatpercent,grossamount) VALUES ('"+ prid+"',0.0,0.0,0.0);");
return prid;
},
duplicate: function(ids){
<a class="navbar-brand" href="#">Verkäufe</a>
<div class="ml-auto">
<div class="btn-group" role="group" aria-label="Basic example">
- <div class="btn-group">
+ <!-- <div class="btn-group">
<button type="button" class="btn btn-primary" id="seltimerange">TimeRange</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
<div class="dropdown-menu" id="timerange">
</div>
- </div>
+ </div> -->
</div>
</div>
</nav>
- <div class="cotainer-fluid" style="margin-top: 52px;">
+ <div class="cotainer-fluid bg-white" style="margin-top: 52px;">
<table id="tbl_sales" class="table table-bordered table-hover table-striped">
<thead class="thead-dark">
- <th data-checkbox="true"></th>
- <th data-sortable="true">Product</th>
+ <tr>
+ <th data-sortable="true">Produkt</th>
<th data-sortable="true" data-align="right">Anz.</th>
- <th data-sortable="true" data-align="right">Netto</th>
- <th data-sortable="true" data-align="right">Brutto</th>
- <th data-sortable="true" data-width="100">Betrag</th>
- <tfoot></tfoot>
+ <th data-sortable="true" data-align="right">Betrag</th>
+ </tr>
+ <tfoot class="thead-dark">
+ <tr>
+ <th >Total</th>
+ <th class="text-right" id="sumquantity">0</th>
+ <th class="text-right" id="sumgross">0,00€</th>
+ </tr>
+ </tfoot>
<tbody></tbody>
</table>
</div>
function loadtable(){
- // var sql = 'select ij.id,ij.byear,ij.date as datesortable, STRFTIME("%d.%m.%Y",ij.date) as date,ij.id,rec.company as recepient, sen.company as sender,ij.reference, ' +
- // 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) as real)) as netamount, ' +
- // 'printf("%.2f",CAST(case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS REAL)) as taxamount, ' +
- // 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) + case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS real)) as totalamount, ' +
- // 'printf("%.2f",COALESCE(ij.payedamount,0.0)) as payedamount, ' +
- // 'ij.status ' +
- // 'from salesjournal ij ' +
- // 'left join salespositions pos on (ij.id=pos.id_sales) ' +
- // 'left join accounts rec on (ij.id_receipient = rec.id) ' +
- // 'left join accounts sen on (ij.id_sender = sen.id) where ij.byear=' + cfg.byear +' group by pos.id_sales order by date desc;';
- // var data = appdb.dbquery(sql);
- // //console.log(data.sqldata);
- // for (var i in data.sqldata){
- // var cstatus = "secondary";
- // if (data.sqldata[i].status== "bezahlt"){ cstatus = "success"; }
- // if (data.sqldata[i].status== "überfällig"){ cstatus = "danger"; }
- // if (data.sqldata[i].status== "verschickt"){ cstatus = "warning"; }
- // var acolor = "";
- // if (data.sqldata[i].totalamount.startsWith("-")){ acolor = "text-danger"; }
- // var row = '<tr id="' +data.sqldata[i].id + '">'+
- // '<td></td>' +
- // '<td><span class="d-none">'+data.sqldata[i].datesortable+'</span> ' + data.sqldata[i].date+ '</td>' +
- // '<td>' + data.sqldata[i].recepient+ '</td>' +
- // '<td>' + data.sqldata[i].sender+ '</td>' +
- // '<td>' + data.sqldata[i].reference+ '</td>' +
- // '<td class="btn-'+ cstatus+'">' + data.sqldata[i].status+ '</td>' +
- // '<td class="'+ acolor +'">' + data.sqldata[i].totalamount+ ' €</td>' +
-
- // '</tr>';
- // $("#tbl_saless").append(row);
- // }
+ var sql = "select td.productname,sum(td.quantity) as quantity,replace(printf('%.2f€',sum(td.quantity *td.grossamount)),'.',',') as grossamount,sum(td.quantity *td.grossamount) as grossamount_calc from transactiondata td left join transactions tr on (td.id_transaction=tr.id) where tr.status='payed' group by td.productname;";
+ var data = appdb.dbquery(sql);
+ $('#tbl_accounts').bootstrapTable('destroy');
+ $('#tbl_accounts > tbody').html("");
+ var sumquantity = 0;
+ var sumgross = 0.00;
+ for (var i in data.sqldata){
+ var row = '<tr id="' +data.sqldata[i].id + '">'+
+ '<td>'+ data.sqldata[i].productname +'</td>' +
+ '<td>'+ data.sqldata[i].quantity +'</td>' +
+ '<td>'+ data.sqldata[i].grossamount +'</td>' +
+ '</tr>';
+ $("#tbl_sales").append(row);
+ sumquantity = sumquantity + parseInt(data.sqldata[i].quantity);
+ sumgross = sumgross + parseFloat(data.sqldata[i].grossamount_calc);
+ }
+ $("#sumquantity").html(sumquantity);
+ $("#sumgross").html(sumgross.toFixed(2).replace('.',',') + "€");
$('#tbl_sales').bootstrapTable({
pagination: false,
search: false,
- height: tblh,
- clickToSelect: true
+ height: tblh
});
<a class="navbar-brand" href="#">Transaktionen</a>
<div class="ml-auto">
<div class="btn-group" role="group" aria-label="Basic example">
- <button class="btn btn-primary" onclick="invoice_new();"><i class="fas fa-plus"></i><br/>New</button>
- <button class="btn btn-primary" onclick="invoice_edit();"><i class="fas fa-edit"></i><br/>Edit</button>
- <button class="btn btn-primary" onclick="invoice_delete();"><i class="fas fa-trash"></i><br/>Delete</button>
- <button class="btn btn-primary" onclick="invoice_clone();"><i class="fas fa-clone"></i><br/>Dupl.</button>
- <div class="btn-group">
- <button type="button" class="btn btn-primary" id="seltimerange">TimeRange</button>
+ <button class="btn btn-primary" onclick="view_details();"><i class="fas fa-eye"></i><br/>Details</button>
+ <button class="btn btn-primary" onclick="cancel_transactions();"><i class="fas fa-ban"></i><br/>Stornieren</button>
+ <button class="btn btn-primary" onclick="delete_transaction();"><i class="fas fa-trash"></i><br/>Löschen</button>
+ <!-- <button class="btn btn-primary" onclick="edit_transaction();"><i class="fas fa-edit"></i><br/>Bearbeiten</button> -->
+ <!-- <div class="btn-group">
+ <button type="button" class="btn btn-primary" id="seltimerange">Zeitraum</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu" id="timerange">
-
+ <a class="dropdown-item" href="javascript:change_timerange('today');">Heute</a>
+ <a class="dropdown-item" href="javascript:change_timerange('yesterday');">Gesten</a>
+ <a class="dropdown-item" href="javascript:change_timerange('last7days');">Letzten 7 Tabge</a>
+ <a class="dropdown-item" href="javascript:change_timerange('thisweek');">Diese Woche</a>
+ <a class="dropdown-item" href="javascript:change_timerange('lastweek');">Letzte Woche</a>
+ <a class="dropdown-item" href="javascript:change_timerange('thismonth');">Dieser Monat</a>
+ <a class="dropdown-item" href="javascript:change_timerange('lastmonth');">Letzter Monat</a>
+ <a class="dropdown-item" href="javascript:change_timerange('thisyear');">Dieses Jahr</a>
+ <a class="dropdown-item" href="javascript:change_timerange('lastyear');">Letztes Jahr</a>
</div>
- </div>
+ </div> -->
</div>
</div>
</nav>
- <div class="cotainer-fluid" style="margin-top: 52px;">
- <table id="tbl_invoices" class="table table-bordered table-hover table-striped">
+ <div class="cotainer-fluid bg-white" style="margin-top: 52px;">
+ <table id="tbl_transactions" class="table table-bordered table-hover table-striped">
<thead class="thead-dark">
<th data-checkbox="true"></th>
<th data-sortable="true">Zeitpunkt</th>
+ <th data-sortable="true">Konto</th>
+ <th data-sortable="true" data-align="right">Betrag</th>
+ <th data-sortable="true" data-align="right">Bezahlt</th>
+ <th data-sortable="true" data-align="right">Cash / Wechselgeld</th>
<th data-sortable="true">Bezahlart</th>
- <th data-sortable="true">Kunde</th>
- <th data-sortable="true">Tisch</th>
+ <th data-sortable="true" data-align="right">Anz. Produkte</th>
<th data-sortable="true">Status</th>
- <th data-sortable="true" data-align="right" data-width="100">Betrag</th>
<tfoot></tfoot>
<tbody></tbody>
</table>
</div>
+ <div class="modal fade" id="dlgTransdata" tabindex="-1" role="dialog" aria-labelledby="dlgTransdataLabel" aria-hidden="true">
+ <div class="modal-dialog modal-lg" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title" id="dlgTransdataLabel">Details</h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">×</span>
+ </button>
+ </div>
+ <div class="modal-body" style="max-height: 500px;overflow-y: scroll;">
+ <table id="tbl_transdata" class="table table-bordered table-hover table-striped">
+ <thead class="thead-dark">
+ <th data-sortable="true">Anz.</th>
+ <th data-sortable="true">Produkt</th>
+ <th data-sortable="true">Betrag</th>
+ <th > </th>
+ <tfoot></tfoot>
+ <tbody></tbody>
+ </table>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">Schliessen</button>
+ </div>
+ </div>
+ </div>
+ </div>
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="../../node_modules/jquery/dist/jquery.min.js"></script>
<script src="../../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var tblh = winh-54;
-var cfg = {
- byear: 2018
-}
+// var cfg = {
+// byear: 2018
+// }
function initpage(){
console.log(appdb.url);
- loadyears();
+ // loadyears();
loadtable();
}
function loadtable(){
- var sql = 'select ij.id,ij.byear,ij.date as datesortable, STRFTIME("%d.%m.%Y",ij.date) as date,ij.id,rec.company as recepient, sen.company as sender,ij.reference, ' +
- 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) as real)) as netamount, ' +
- 'printf("%.2f",CAST(case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS REAL)) as taxamount, ' +
- 'printf("%.2f",CAST(sum(pos.quantity * pos.unitamount) + case when pos.taxpercent > 0 then sum(pos.taxpercent * pos.quantity * pos.unitamount) else 0.0 end AS real)) as totalamount, ' +
- 'printf("%.2f",COALESCE(ij.payedamount,0.0)) as payedamount, ' +
- 'ij.status ' +
- 'from cashbox ij ' +
- 'left join invoicepositions pos on (ij.id=pos.id_invoice) ' +
- 'left join accounts rec on (ij.id_receipient = rec.id) ' +
- 'left join accounts sen on (ij.id_sender = sen.id) where ij.byear=' + cfg.byear +' group by pos.id_invoice order by date desc;';
+ var sql = "select tr.id,strftime('%d.%m.%Y %H:%M:%S',tr.created) as created ,tr.created as datesort,acc.name,replace(printf('%.2f€',sum(td.grossamount * td.quantity)),'.',',') as totalamount,replace(printf('%.2f€',payedamount),'.',',') as payedamount,payementtype, replace(printf('%.2f€',cashamount),'.',',') as cashamount,replace(printf('%.2f€',cashbackamount),'.',',') as cashbackamount, sum(td.quantity) as products_nbr,status from transactions tr left join accounts acc on (tr.id_account=acc.id) left join transactiondata td on (tr.id=td.id_transaction) group by tr.id order by tr.created desc;";
+ $('#tbl_transactions').bootstrapTable('destroy');
+ $("#tbl_transactions > tbody").html("");
var data = appdb.dbquery(sql);
//console.log(data.sqldata);
for (var i in data.sqldata){
var cstatus = "secondary";
- if (data.sqldata[i].status== "bezahlt"){ cstatus = "success"; }
- if (data.sqldata[i].status== "überfällig"){ cstatus = "danger"; }
- if (data.sqldata[i].status== "verschickt"){ cstatus = "warning"; }
- var acolor = "";
- if (data.sqldata[i].totalamount.startsWith("-")){ acolor = "text-danger"; }
+ if (data.sqldata[i].status== "command"){ cstatus = "warning"; }
+ if (data.sqldata[i].status== "payed"){ cstatus = "success"; }
+ if (data.sqldata[i].status== "canceled"){ cstatus = "danger"; }
+ if (data.sqldata[i].status== "payed") { data.sqldata[i].status= "bezahlt";}
+ if (data.sqldata[i].status== "canceled") { data.sqldata[i].status= "storniert";}
+ if (data.sqldata[i].status== "command") { data.sqldata[i].status= "bestellt";}
var row = '<tr id="' +data.sqldata[i].id + '">'+
'<td></td>' +
- '<td><span class="d-none">'+data.sqldata[i].datesortable+'</span> ' + data.sqldata[i].date+ '</td>' +
- '<td>' + data.sqldata[i].recepient+ '</td>' +
- '<td>' + data.sqldata[i].sender+ '</td>' +
- '<td>' + data.sqldata[i].reference+ '</td>' +
- '<td class="btn-'+ cstatus+'">' + data.sqldata[i].status+ '</td>' +
- '<td class="'+ acolor +'">' + data.sqldata[i].totalamount+ ' €</td>' +
+ '<td><span class="d-none">'+data.sqldata[i].datesort+'</span> ' + data.sqldata[i].created+ '</td>' +
+ '<td>' + ((data.sqldata[i].name == null)?'':data.sqldata[i].name)+ '</td>' +
+ '<td class="align-right">' + data.sqldata[i].totalamount+ '</td>' +
+ '<td>' + data.sqldata[i].payedamount+ '</td>' +
+ '<td>' + data.sqldata[i].cashamount+ '/'+ data.sqldata[i].cashbackamount+ '</td>' +
+ '<td>' + ((data.sqldata[i].payementtype == null)?'':data.sqldata[i].payementtype)+ '</td>' +
+ '<td>' + ((data.sqldata[i].products_nbr == null)?'':data.sqldata[i].products_nbr)+ '</td>' +
+ '<td class="status btn-'+ cstatus+'">' + data.sqldata[i].status+ '</td>' +
'</tr>';
- $("#tbl_invoices").append(row);
+ $("#tbl_transactions").append(row);
}
- $('#tbl_invoices').bootstrapTable({
+ $('#tbl_transactions').bootstrapTable({
pagination: false,
search: false,
height: tblh,
}
-function loadyears(){
- sql = "select byear from cashbox group by byear order by byear asc;";
+
+function view_details(){
+ var trid= getTableSelectionID();
+ //console.log(trid);
+ var sql = "select tr.id,tr.quantity,pr.name, pr.productgroup,replace(printf('%.2f€',tr.grossamount),'.',',') as grossamount from transactiondata tr join products pr on (tr.id_product=pr.id) where tr.id_transaction='"+trid+"'";
+ $('#tbl_transdata > tbody').html("");
var data = appdb.dbquery(sql);
- //onsole.log(data.sqldata);
+ //console.log("commands table list")
+ //console.log(data);
for (var i in data.sqldata){
- $("#timerange").append('<a class="dropdown-item" href="javascript:change_timerange({"byear":"'+data.sqldata[i].byear+'"});">' + data.sqldata[i].byear+'</a>');
+ var row = '<tr id='+data.sqldata[i].id+ '>'+
+ '<td>'+data.sqldata[i].quantity+ '</td>' +
+ '<td>'+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+ '</td>' +
+ '<td>'+data.sqldata[i].grossamount+ '</td>' +
+ '<td><button class="btn btn-danger" onclick="deletetransdata(\''+data.sqldata[i].id+'\');"><i class="fas fa-trash"></i></button></td>' +
+ '</tr>';
+ $("#tbl_transdata").append(row);
}
-
+ $('#tbl_transdata').bootstrapTable({
+ pagination: false,
+ search: false,
+ });
+ $('#dlgTransdata').modal('show');
}
-function invoice_edit(){
- var inv_id= getTableSelectionID();
- if (inv_id){
- parent.browserapp.loadmodulepage('invoices','invoice',{"id":inv_id});
+function delete_transaction(){
+ var ids = getTableSelectionIDs();
+ console.log(ids);
+ var sql="DELETE FROM transactiondata WHERE id_transaction in ('"+ ids.join("','")+"')";
+ appdb.dbexec(sql);
+ var sql2="DELETE FROM transactions WHERE id in ('"+ ids.join("','")+"')";
+ appdb.dbexec(sql2);
+ for ( i in ids){
+ $("#tbl_transactions tr#" + ids[i]).remove();
}
-
+ //$('#tbl_transactions').bootstrapTable('refresh');
}
-function invoice_delete(){
-
+function deletetransdata(id){
+ var sql="DELETE FROM transactiondata WHERE id='"+ id+"';";
+ appdb.dbexec(sql);
+ $('#tbl_transdata tr#' + id).remove();
+ loadtable();
+ //$('#tbl_transactions').bootstrapTable('refresh');
}
-function invoice_duplicate(){
-
+
+function cancel_transactions(){
+ var ids = getTableSelectionIDs();
+ var sql="UPDATE transactions set status='canceled',statusdate=date('now') WHERE in ('"+ ids.join("','")+"');";
+ appdb.dbexec(sql);
+ for ( i in ids){
+ $("#tbl_transactions tr#" + ids[i] + " > td.status").attr("class",'status btn-danger');
+ $("#tbl_transactions tr#" + ids[i] + " > td.status").html("storniert");
+ }
}
function change_timerange(){
}
function getTableSelectionID(){
- var sel = $('#tbl_invoices').bootstrapTable('getSelections');
+ var sel = $('#tbl_transactions').bootstrapTable('getSelections');
var id = null;
if (sel){ id=sel[0]._id; }
}
function getTableSelectionIDs(){
- var sel = $('#tbl_invoices').bootstrapTable('getSelections');
+
+ var sel = $('#tbl_transactions').bootstrapTable('getSelections');
+ //console.log("selections");
+ //console.log(sel);
var ids = [];
if (sel){
for (var s in sel){
- ids.push(s._id);
+ //console.log(sel[s]._id);
+ ids.push(sel[s]._id);
}
}
return ids;