--- /dev/null
+$( document ).ready(function() {
+ console.log( "Iframe "+ location.pathname.substring(location.pathname.lastIndexOf("/")) +" ready!" );
+ mpref.loadconfig();
+ initpage();
+});
+
+var mpref ={
+ cfg: null,
+ getSearchParams: function (k){
+ //alert(location.href);
+ var p={};
+ console.log("params =>" + location.search);
+ location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){p[k]=v});
+ return k?p[k]:p;
+ },
+ loadconfig: function(){
+ this.cfg = this.getSearchParams();
+ //var page = location.pathname.substring(location.pathname.lastIndexOf("/"));
+ //page = page.replace(/\.html/,'');
+ //apppref.getpreference(page);
+ //appdb.dbfile = this.cfg.dbfile;
+ appdb.url = decodeURIComponent(this.cfg.serviceurl) + 'sqlite/' + decodeURIComponent(this.cfg.dbfile);
+ }
+}
\ No newline at end of file
<a class="navbar-brand" href="#">Produkte</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="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="invoice_clone();"><i class="fas fa-clone"></i><br/>Dupl.</button>
</div>
</nav>
- <div class="cotainer-fluid" style="margin-top: 52px;">
+ <div class="cotainer-fluid bg-white" style="margin-top: 52px;">
<table id="tbl_products" class="table table-bordered table-hover table-striped">
<thead class="thead-dark">
<th data-checkbox="true"></th>
- <th data-sortable="true"><i class="fas fa-cash-register"></i></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">Gruppe</th>
- <th data-sortable="true">Netto</th>
- <th data-sortable="true">MwSt.</th>
- <th data-sortable="true">Brutto</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>
+ <th data-sortable="true" data-width="70" data-align="right">Brutto (€)</th>
<tfoot></tfoot>
<tbody></tbody>
</table>
+ <div id="datalists" style="display: hidden;"><datalist id="productgroup"></datalist><datalist id="vatpercent"></datalist></div>
</div>
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="../../node_modules/jquery/dist/jquery.min.js"></script>
+import { on } from "cluster";
+
var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var tblh = winh-54;
function initpage(){
-
+ loaddatalist_productgroup();
+ loaddatalist_vatpercent();
loadtable();
}
-
+$("input,select").on('focusout',function(){
+ console.log($(this).attr("id"));
+});
+
+function loaddatalist_productgroup(){
+ var sql = "select productgroup from products where productgroup is not null group by productgroup;";
+ var data = appdb.dbquery(sql);
+ for (var i in data.sqldata){
+ $("#productgroup").append('<option value="'+ data.sqldata[i].productgroup +'">');
+ }
+}
+
+function loaddatalist_vatpercent(){
+ var sql = 'select replace(printf("%.2f",vatpercent),".",",") as vatpercent from products where vatpercent is not null group by vatpercent;';
+ var data = appdb.dbquery(sql);
+ for (var i in data.sqldata){
+ $("#vatpercent").append('<option value="'+ data.sqldata[i].vatpercent +'">');
+ }
+}
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 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_invoices").append(row);
- // }
+ var sql = 'select id,name,specification,visible,productgroup, replace(printf("%.2f",netamount),".",",") as netamount, replace(printf("%.2f",vatpercent),".",",") as vatpercent, replace(printf("%.2f",grossamount),".",",") as grossamount from products;';
+
+ var data = appdb.dbquery(sql);
+ console.log(data.sqldata);
+ $('#tbl_products').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="visible" name="visible" value="'+data.sqldata[i].visible+ '" '+ ((data.sqldata[i].visible == '1')?"checked":'')+'/></td>' +
+ '<td><input type="text" class="form-control" value="'+((data.sqldata[i].name != null)?data.sqldata[i].name:'')+'"/><br><input class="form-control" type="text" value="' + ((data.sqldata[i].specification != null)?data.sqldata[i].specification:'')+ '" /></td>' +
+ '<td><input type="text" class="form-control" list="productgroup" value="' + (( data.sqldata[i].productgroup!= null)?data.sqldata[i].productgroup:'')+ '"/></td>' +
+ '<td><input type="text" class="form-control right" value="' + data.sqldata[i].netamount+ '" /></td>' +
+ '<td><input type="text" class="form-control right" list="vatpercent" value="' + data.sqldata[i].vatpercent+ '" /></td>' +
+ '<td><input type="text" class="form-control right" value="' + data.sqldata[i].grossamount+ '" /></td>' +
+ '</tr>';
+ $("#tbl_products").append(row);
+ }
$('#tbl_products').bootstrapTable({
pagination: false,
search: false,
height: tblh,
clickToSelect: true
});
-
-
}
+function product_new (){
+ var row = '<tr id=""><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>';
+ $("#tbl_products").prepend(row);
+}
-
-function product_edit(){
- var id= getTableSelectionID();
- if (id){
- parent.browserapp.loadmodulepage('products','product',{"id":id});
+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){
+ //delete
+ var ids= getTableSelectionIDs();
+ console.log(ids);
+ //product.delete(ids);
+ loadtable();
}
}
-
+function product_duplicate(){
+ var ids= getTableSelectionIDs();
+ console.log(ids);
+ //product.duplicate(ids);
+ loadtable();
+}
function getTableSelectionID(){
- var sel = $('#tbl_invoices').bootstrapTable('getSelections');
+ var sel = $('#tbl_products').bootstrapTable('getSelections');
var id = null;
if (sel){ id=sel[0]._id; }
}
function getTableSelectionIDs(){
- var sel = $('#tbl_invoices').bootstrapTable('getSelections');
+ var sel = $('#tbl_products').bootstrapTable('getSelections');
var ids = [];
if (sel){
for (var s in sel){
var product = {
- new: function(){
+ import: function(){
},
- edit: function(){
-
+ export: function(){
+
},
- delete: function(){
-
+ delete: function(ids){
+ var sql="DELETE FROM products WHERE id in ('"+ ids.join("','")+"')";
+ appdb.dbexec(sql);
},
- duplicate: function(){
-
+ duplicate: function(ids){
+ for (var i in ids){
+ var sql = "INSERT into products (id,name,specification,netamount,grossamount,vatpercent,productgroup) SELECT '"+ appdb.generate_uuid()+"' as id, name, specification, netamount, grossamount, vatpercent,productgroup FROM products where id = '"+ i +"';";
+ appdb.dbexec(sql);
+ }
}
}
\ No newline at end of file
</div>
</nav>
<div class="cotainer-fluid" style="margin-top: 52px;">
- <ul class="nav nav-tabs" id="pagetab" role="tablist">
- <li class="nav-item"><a aria-controls="global" aria-selected="true" class="nav-link active" data-toggle="tab" href="#global" id="global-tab" role="tab">Global</a></li>
- <li class="nav-item"><a aria-controls="templates" aria-selected="false" class="nav-link" data-toggle="tab" href="#templates" id="templates-tab" role="tab">Vorlagen & Drucker</a></li>
- </ul>
- <div class="tab-content" id="tabpagecontent">
- <div aria-labelledby="global-tab" class="tab-pane fade show active" id="global" role="tabpanel">
+
<div class="row">
<div class="col-md-12">
<div class="card">
</div>
</div>
</div>
- <div aria-labelledby="templates-tab" class="tab-pane fade" id="templates" role="tabpanel">
- <div class="row">
- <div class="col-md-6" style="padding-right: 0px;">
- <nav class="navbar navbar-expand-md navbar-dark bg-dark">
- <h5 class="text-white">Druck-Vorlagen</h5>
- <div class="ml-auto">
-
- <div class="btn-group" role="group" aria-label="Basic example">
- <button class="btn btn-primary" onclick="printtemplate.new();"><i class="fas fa-plus"></i><br/>Neu</button>
- <button class="btn btn-primary" onclick="printtemplate.edit();"><i class="fas fa-edit"></i><br/>bearb.</button>
- <button class="btn btn-primary" onclick="printtemplate.delete();" ><i class="fas fa-trash"></i><br/>Löschen</button>
- <button class="btn btn-primary" onclick="printtemplate.duplicate();" ><i class="fas fa-copy"></i><br/>Copy</button>
- </div>
- </div>
- </nav>
-
-
- <table id="tbl_invoicetemplates" class="table table-bordered table-hover table-striped">
- <thead class="thead-dark">
- <th data-checkbox="true"></th>
- <th data-sortable="true">Name</th>
- <th data-sortable="true">Typ</th>
- <th data-sortable="true">Standard</th>
- <tfoot></tfoot>
- <tbody></tbody>
- </table>
- </div>
- <div class="col-md-6" >
- <div class="card">
- <div class="card-header">Drucker</div>
- <div class="card-body">
- <div class="form-group">
- <label for="ticketprinter">Kassenzettel-Drucker</label>
- <select id="ticketprinter" name="ticketprinter" class="form-control">
- <option value=""></option>
- </select>
- <button class="btn btn-primary">Drucker-Einstellungen</button>
- </div>
- <div class="form-group">
- <label for="a4printer">A4-Drucker</label>
- <select id="a4printer" name="a4printer" class="form-control">
- <option value=""></option>
- </select>
- <button class="btn btn-primary">Drucker-Einstellungen</button>
- </div>
- </div>
- </div>
-
-
- </div>
- </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>
dts[inp.attr("id")] = inp.val();
});
console.log(dts);
- console.log(mpref);
- if (mpref.cfg.id == ""){
+ //console.log(mpref);
+ if ((!mpref) || (mpref.cfg.id == "")){
var keyname = dts['name'].toLowerCase();
console.log(keyname);
keyname = keyname.replace(/[^a-z0-9-_]/g,"");
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.min.css">
+<link rel="stylesheet" href="../../node_modules/bootstrap-table/dist/bootstrap-table.min.css">
+<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>Vorlagen</title>
+</head>
+<body>
+ <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
+ <a class="navbar-brand" href="#">Vorlagen</a>
+ <div class="ml-auto">
+ <div class="btn-group" role="group" aria-label="Basic example">
+
+ </div>
+ </nav>
+ <div class="cotainer-fluid" style="margin-top: 52px;">
+
+ </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>
+<script src="../../node_modules/bootstrap-table/dist/bootstrap-table.min.js"></script>
+<script src="../../node_modules/@fortawesome/fontawesome-free/js/all.min.js"></script>
+<script src="../../js/moduleglobal.js"></script>
+<script src="../../js/database.js"></script>
+<script src="index.js"></script>
+<script>if (window.module) module = window.module;</script>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+var winh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
+
+function initpage(){
+
+}
return dialog.showOpenDialog({title: dlgtitle,defaultPath: lastpath, filters: filefilters, properties: ['openDirectory'] });
},
showMessage: function(msgTitle,msg,msgdetail,msgtype,msgButtons=["OK"],defautlbtnid=0,cancelbtnid){
- return dialog.showMessageBox({type: msgtype, //
+ return dialog.showMessageBox({type: msgtype, //"none", "info", "error", "question" or "warning"
title: msgTitle,
buttons:msgButtons,
message: msg,