changed behaviour

This commit is contained in:
TLRZ Seyfferth 2018-01-25 11:29:48 +01:00
parent e379ef8c29
commit cc4201f2b5
6 changed files with 115 additions and 19 deletions

View File

@ -20,3 +20,35 @@ if ($_GET['controller'] == "Article"){
echo "Artikel wurden gespeichert.";
}
}
if ($_GET['controller'] == "Inventur"){
if ($_GET['action'] == "export") {
$json = file_get_contents('php://input');
$list = json_decode($json, true);
$fp = fopen('data/inventur_'.date('Y-m-d').'.csv', 'w');
fputcsv($fp,array_keys(flatten($list[0])));
foreach ($list as $obj) {
$fields = flatten($obj);
//array_walk_recursive($obj, function($a)use (&$fields) { $fields[] = $a;});
//print_r($fields);
fputcsv($fp,$fields);
}
echo "Inventur wurde gespeichert.";
fclose($fp);
}
}
function flatten($array, $prefix = '') {
$result = array();
foreach($array as $key=>$value) {
if(is_array($value)) {
$result = $result + flatten($value, $prefix . $key . '_');
}
else {
$result[$prefix . $key] = $value;
}
}
return $result;
}

View File

@ -1,5 +1,6 @@
[{
"name": "Edelpils",
"short": "Pils",
"dimension": "l",
"content": {
"size": 0.33,
@ -12,6 +13,7 @@
}
}, {
"name": "Schwarzbier",
"short": "Sb",
"dimension": "l",
"content": {
"size": 0.33,
@ -24,6 +26,7 @@
}
}, {
"name": "Schöfferhofer",
"short": "Schö",
"dimension": "l",
"content": {
"size": 0.33,
@ -36,6 +39,7 @@
}
}, {
"name": "Bitburger af.",
"short": "0%",
"dimension": "l",
"content": {
"size": 0.33,
@ -48,6 +52,7 @@
}
}, {
"name": "Weiswein",
"short": "WW",
"dimension": "l",
"content": {
"size": 1,
@ -60,6 +65,7 @@
}
}, {
"name": "Rotwein",
"short": "RW",
"dimension": "l",
"content": {
"size": 0.75,
@ -72,6 +78,7 @@
}
}, {
"name": "Secco",
"short": "Sekt",
"dimension": "l",
"content": {
"size": 0.75,
@ -84,6 +91,7 @@
}
}, {
"name": "B-Saft",
"short": "BS",
"dimension": "l",
"content": {
"size": 1,
@ -96,6 +104,7 @@
}
}, {
"name": "K-Saft",
"short": "KS",
"dimension": "l",
"content": {
"size": 1,
@ -108,6 +117,7 @@
}
}, {
"name": "O-Saft",
"short": "OS",
"dimension": "l",
"content": {
"size": 1,
@ -120,6 +130,7 @@
}
}, {
"name": "G-Saft",
"short": "GS",
"dimension": "l",
"content": {
"size": 1,
@ -132,6 +143,7 @@
}
}, {
"name": "Vita Cola",
"short": "Co",
"dimension": "l",
"content": {
"size": 1,
@ -144,6 +156,7 @@
}
}, {
"name": "Vita Orange",
"short": "Fa",
"dimension": "l",
"content": {
"size": 1,
@ -156,6 +169,7 @@
}
}, {
"name": "Vita Zitrone",
"short": "Spr",
"dimension": "l",
"content": {
"size": 1,
@ -168,6 +182,7 @@
}
}, {
"name": "Tonic",
"short": "To",
"dimension": "l",
"content": {
"size": 0.25,
@ -180,6 +195,7 @@
}
}, {
"name": "Bitter Lemon",
"short": "BL",
"dimension": "l",
"content": {
"size": 0.25,
@ -192,6 +208,7 @@
}
}, {
"name": "Ginger Ale",
"short": "GA",
"dimension": "l",
"content": {
"size": 0.25,
@ -204,6 +221,7 @@
}
}, {
"name": "Apfelschorle",
"short": "AS",
"dimension": "l",
"content": {
"size": 0.25,
@ -216,6 +234,7 @@
}
}, {
"name": "TWQ naturell",
"short": "W-",
"dimension": "l",
"content": {
"size": 0.25,
@ -228,6 +247,7 @@
}
}, {
"name": "TWQ medium",
"short": "W",
"dimension": "l",
"content": {
"size": 0.25,
@ -240,6 +260,7 @@
}
}, {
"name": "TWQ classic",
"short": "W+",
"dimension": "l",
"content": {
"size": 0.25,
@ -252,6 +273,7 @@
}
}, {
"name": "Kaffee",
"short": "TK",
"dimension": "Tasse",
"content": {
"size": 1,
@ -264,6 +286,7 @@
}
}, {
"name": "Latte Macchiato",
"short": "LM",
"dimension": "Glas",
"content": {
"size": 1,
@ -276,6 +299,7 @@
}
}, {
"name": "dopp. Esp.",
"short": "dEsp",
"dimension": "Tasse",
"content": {
"size": 1,
@ -288,6 +312,7 @@
}
}, {
"name": "Brezel",
"short": "Br",
"dimension": "Stück",
"content": {
"size": 1,
@ -300,6 +325,7 @@
}
}, {
"name": "Schokoriegel",
"short": "Schoko",
"dimension": "Stück",
"content": {
"size": 1,

View File

@ -0,0 +1,27 @@
article_name,article_short,article_dimension,article_content_size,article_content_price,article_portion_size,article_portion_price,article_portion_type,end,start,fetched,lost
Edelpils,Pils,l,0.33,0,0.33,3.5,Fl.,0,0,0,0
Schwarzbier,Sb,l,0.33,0,0.33,3.5,Fl.,0,0,0,0
Schöfferhofer,Schö,l,0.33,0,0.33,3.5,Fl.,0,0,0,0
"Bitburger af.",0%,l,0.33,0,0.33,3.5,Fl.,0,0,0,0
Weiswein,WW,l,1,0,0.2,6,Gl.,0,0,0,0
Rotwein,RW,l,0.75,0,0.2,6.5,Gl.,0,0,0,0
Secco,Sekt,l,0.75,0,0.1,6,Gl.,0,0,0,0
B-Saft,BS,l,1,0,0.2,3.5,Gl.,0,0,0,0
K-Saft,KS,l,1,0,0.2,3.5,Gl.,0,0,0,0
O-Saft,OS,l,1,0,0.2,3.5,Gl.,0,0,0,0
G-Saft,GS,l,1,0,0.2,3.5,Gl.,0,0,0,0
"Vita Cola",Co,l,1,0,0.2,2.5,Gl.,0,0,0,0
"Vita Orange",Fa,l,1,0,0.2,2.5,Gl.,0,0,0,0
"Vita Zitrone",Spr,l,1,0,0.2,2.5,Gl.,0,0,0,0
Tonic,To,l,0.25,0,0.25,3,Fl.,0,0,0,0
"Bitter Lemon",BL,l,0.25,0,0.25,3,Fl.,0,0,0,0
"Ginger Ale",GA,l,0.25,0,0.25,3,Fl.,0,0,0,0
Apfelschorle,AS,l,0.25,0,0.25,3,Fl.,0,0,0,0
"TWQ naturell",W-,l,0.25,0,0.25,2.5,Fl.,0,0,0,0
"TWQ medium",W,l,0.25,0,0.25,2.5,Fl.,0,0,0,0
"TWQ classic",W+,l,0.25,0,0.25,2.5,Fl.,0,0,0,0
Kaffee,TK,Tasse,1,0,1,2.5,T,0,0,0,0
"Latte Macchiato",LM,Glas,1,0,1,3.5,Gl.,0,0,0,0
"dopp. Esp.",dEsp,Tasse,1,0,1,3.5,T,0,0,0,0
Brezel,Br,Stück,1,0,1,2.5,Stk.,0,0,0,0
Schokoriegel,Schoko,Stück,1,0,1,2,Stk.,0,0,0,0
1 article_name article_short article_dimension article_content_size article_content_price article_portion_size article_portion_price article_portion_type end start fetched lost
2 Edelpils Pils l 0.33 0 0.33 3.5 Fl. 0 0 0 0
3 Schwarzbier Sb l 0.33 0 0.33 3.5 Fl. 0 0 0 0
4 Schöfferhofer Schö l 0.33 0 0.33 3.5 Fl. 0 0 0 0
5 Bitburger af. 0% l 0.33 0 0.33 3.5 Fl. 0 0 0 0
6 Weiswein WW l 1 0 0.2 6 Gl. 0 0 0 0
7 Rotwein RW l 0.75 0 0.2 6.5 Gl. 0 0 0 0
8 Secco Sekt l 0.75 0 0.1 6 Gl. 0 0 0 0
9 B-Saft BS l 1 0 0.2 3.5 Gl. 0 0 0 0
10 K-Saft KS l 1 0 0.2 3.5 Gl. 0 0 0 0
11 O-Saft OS l 1 0 0.2 3.5 Gl. 0 0 0 0
12 G-Saft GS l 1 0 0.2 3.5 Gl. 0 0 0 0
13 Vita Cola Co l 1 0 0.2 2.5 Gl. 0 0 0 0
14 Vita Orange Fa l 1 0 0.2 2.5 Gl. 0 0 0 0
15 Vita Zitrone Spr l 1 0 0.2 2.5 Gl. 0 0 0 0
16 Tonic To l 0.25 0 0.25 3 Fl. 0 0 0 0
17 Bitter Lemon BL l 0.25 0 0.25 3 Fl. 0 0 0 0
18 Ginger Ale GA l 0.25 0 0.25 3 Fl. 0 0 0 0
19 Apfelschorle AS l 0.25 0 0.25 3 Fl. 0 0 0 0
20 TWQ naturell W- l 0.25 0 0.25 2.5 Fl. 0 0 0 0
21 TWQ medium W l 0.25 0 0.25 2.5 Fl. 0 0 0 0
22 TWQ classic W+ l 0.25 0 0.25 2.5 Fl. 0 0 0 0
23 Kaffee TK Tasse 1 0 1 2.5 T 0 0 0 0
24 Latte Macchiato LM Glas 1 0 1 3.5 Gl. 0 0 0 0
25 dopp. Esp. dEsp Tasse 1 0 1 3.5 T 0 0 0 0
26 Brezel Br Stück 1 0 1 2.5 Stk. 0 0 0 0
27 Schokoriegel Schoko Stück 1 0 1 2 Stk. 0 0 0 0

View File

@ -11,7 +11,7 @@
<link rel="manifest" href="manifest.json">
<link rel="icon" sizes="192x192" href="/favicons/android-chrome-192x192.png">
<link rel="apple-touch-icon" href="/favicons/android-chrome-192x192.png">
</head>
<body>
@ -38,10 +38,14 @@
<div v-for="(a, index) in articles" class="card">
<div class="card-content row">
<span class="card-title">{{ a.name }}</span>
<div class="input-field inline col s12">
<div class="input-field inline col s8">
<input v-model="a.name" placeholder="Artikelname" class="validate" :id="'a_name_'+index">
<label :for="'a_name_'+index" class="active">Name</label>
</div>
<div class="input-field inline col s4">
<input v-model="a.short" placeholder="Kurzname" class="validate" :id="'a_short_'+index">
<label :for="'a_short_'+index" class="active">Kürzel</label>
</div>
<div class="input-field col s8">
<input v-model.number="a.content.size" placeholder="Gesamtinhalt" type="number" class="validate" step="0.01" :id="'a_csize_'+index">
<label :for="'a_csize_'+index" class="active">Gesamtinhalt</label>
@ -74,9 +78,6 @@
<a class="" href="#">Artikel löschen</a>
</div>
</div>
<div slot="footer">
</div>
</div>
<div class="col s12" id="inventory" v-if="ready">
<div v-for="(a, index) in inventory.ug" class="card hoverable">
@ -109,7 +110,7 @@
</div>
</div>
<div class="col s12" id="calc" v-if="ready">
<div class="row">
<div class="row pin-top">
<div class="col s12 m4 card darken-4 grey grey-text text-lighten-2">
<table class="card-content">
<tr v-for="item in bonned(bon)">
@ -126,12 +127,12 @@
</div>
<div class="col s12 m8">
<div class="row">
<div class="col s4" v-for="a in bon">
<button class="waves-effect waves-light btn-large btn-flat col s12" @click="a.count++;">{{ a.name }}</button>
<div class="col s3" v-for="a in bon">
<button class="waves-effect waves-light btn-large btn-flat col s12" @click="a.count++;">{{ a.short }}</button>
</div>
</div>
<div class="row">
<div class="col s4">
<div class="col s3">
<button class="waves-effect waves-light btn-large orange col s12" @click="resetBon">Reset</button>
</div>
</div>
@ -152,10 +153,10 @@
<a href="#" class="btn-floating tooltipped" data-position="left" @click="addArticle" data-tooltip="Artikel hinzufügen"><i class="material-icons">add</i></a>
</li>
<li v-if="view == 'inventur'">
<a href="#" class="btn-floating tooltipped" data-position="left" @click="storeArticles" data-tooltip="Artikelliste speichern"><i class="material-icons">save</i></a>
<a href="#" class="btn-floating tooltipped" data-position="left" @click="resetInventur" data-tooltip="Inventur zurücksetzen"><i class="material-icons">reset</i></a>
</li>
<li v-if="view == 'inventur'">
<a href="#" class="btn-floating tooltipped" data-position="left" @click="addArticle" data-tooltip="Artikel hinzufügen"><i class="material-icons">add</i></a>
<a href="#" class="btn-floating tooltipped" data-position="left" @click="exportInventur" data-tooltip="Inventur exportieren"><i class="material-icons">export</i></a>
</li>
</ul>
</div>

View File

@ -9,13 +9,6 @@ Vue.filter('number', function(number, precision = 2){
var app = new Vue({
el: "#app",
data : {
dimensions: [
'l',
'Stk.',
'Gl.',
'Fl.',
'T.',
],
articles : [],
inventory : {
ug : [],
@ -70,13 +63,22 @@ var app = new Vue({
ia = new InventoryArticle();
ia.article = a;
this.inventory.ug.push(ia);
this.bon.push({count: 0, name: a.name, price: a.portion.price});
this.bon.push({count: 0, name: a.name, short: a.short, price: a.portion.price});
});
}).then( x => {
M.updateTextFields();
this.ready = true;
});
},
resetInventur: function() {
},
exportInventur: function() {
this.$http.post('./backend?controller=Inventur&action=export', JSON.stringify(this.inventory.ug))
.then(response => {
M.toast({html: response.body});
})
},
resetBon: function(article) {
this.bon.forEach(function (item){
item.count = 0;

View File

@ -1,5 +1,6 @@
function Article() {
this.name = "";
this.short = "";
this.dimension = "";
this.content = {
size : 0,
@ -19,6 +20,12 @@ Article.prototype = {
set Name(value) {
this.name = value;
},
get Short() {
return this.short;
},
set Short(value) {
this.short = value;
},
get ContentSize() {
return this.content.size;
},
@ -61,6 +68,7 @@ Article.thaw = function (json) {
var article = new Article();
article.id = json.id;
article.Name = json.name;
article.Short = json.short;
article.Dimension = json.dimension;
article.ContentSize = json.content.size;
article.PortionPrice = json.portion.price;