123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 'use strict';
- angular.module('fehlerberichtApp').filter("euro", function () {
- return function (num) {
- if (num !== null) {
- return num.toFixed(2).toString().replace(".", ",");
- }
- return "0,00";
- };
- });
- /**
- * @ngdoc function
- * @name kasseApp.controller:MainCtrl
- * @description
- * # MainCtrl
- * Controller of the kasseApp
- */
- angular.module('fehlerberichtApp')
- .controller('MainCtrl', function ($scope) {
- $scope.Produkte = [
- {
- "Produkt": 0,
- "Anzahl": 1,
- "Bezeichnung": "Steak mit Pommes",
- "Extras": {
- "Jaeger": true,
- "Zwiebel": false
- },
- "EP": 5.5
- },
- {
- "Produkt": 1,
- "Anzahl": 1,
- "Bezeichnung": "Steak mit Brot",
- "Extras": {
- "Jaeger": true,
- "Zwiebel": false
- },
- "EP": 4.5
- },
- {
- "Produkt": 2,
- "Anzahl": 1,
- "Bezeichnung": "Hackbraten mit Pommes",
- "Extras": {
- "Jaeger": false,
- "Zwiebel": true
- },
- "EP": 5.5
- },
- {
- "Produkt": 3,
- "Anzahl": 1,
- "Bezeichnung": "Hackbraten mit Brot",
- "Extras": {
- "Jaeger": false,
- "Zwiebel": true
- },
- "EP": 4.5
- },
- {
- "Produkt": 4,
- "Anzahl": 1,
- "Bezeichnung": "Portion Pommes",
- "EP": 3.0
- }
- ];
- $scope.Rechnung = window.localStorage.getItem("Rechnung");
- $scope.OffeneBestellungen = window.localStorage.getItem("OffeneBestellungen");
- $scope.Bestellung = [];
- $scope.Anzahl = function () {
- return _.reduce($scope.Bestellung, function (sum, b) { return sum + b.Anzahl; }, 0);
- };
- $scope.Summe = function () {
- return _.reduce($scope.Bestellung, function (sum, b) { return sum + b.Anzahl * b.EP; }, 0);
- };
- $scope.addItem = function (num) {
- $scope.Bestellung.push($.extend(true, {}, $scope.Produkte[num]));
- };
- $scope.removeItem = function (item) {
- $scope.Bestellung = _.without($scope.Bestellung, item);
- };
- $scope.checkOut = function () {
- $scope.OffeneBestellungen.push({ "Rechnung": $scope.Rechnung, "Bestellung": $scope.Bestellung });
- $scope.Bestellung = [];
- $scope.Rechnung = parseInt($scope.Rechnung, 10) + 1;
- window.localStorage.setItem("Rechnung", $scope.Rechnung);
- window.localStorage.setItem("OffeneBestellungen", JSON.stringify($scope.OffeneBestellungen));
- };
- if ($scope.OffeneBestellungen === null) {
- $scope.Rechnung = 1;
- $scope.OffeneBestellungen = [];
- } else {
- $scope.OffeneBestellungen = JSON.parse($scope.OffeneBestellungen);
- }
- });
|