changelog.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. (function () {
  2. 'use strict';
  3. angular.module('fehlerberichtApp')
  4. .controller('ChangelogCtrl', function ($scope, $http) {
  5. var webservice = 'http://rbs06/fehlerbericht/db.php?';
  6. $scope.Typen = ["neu", "akt", "entf"];
  7. $scope.Status = {
  8. "Historie": [],
  9. "Liste": []
  10. };
  11. $scope.Filter = {
  12. "Konto_Nr": "",
  13. "Konto_Bezeichnung": "",
  14. "Konto_Art": "",
  15. "Datum": "",
  16. "Status": "",
  17. "Quelle": ""
  18. };
  19. $scope.Domaene = {
  20. "Konto_Nr": [],
  21. "Konto_Bezeichnung": [],
  22. "Konto_Art": ["GuV", "Bilanz"],
  23. "Datum": [],
  24. "Status": $scope.Typen,
  25. "Quelle": []
  26. };
  27. $scope.selectedDate = {"datum": "heute"};
  28. $http.get(webservice + "a=changelog&kunde=").success(function (data) {
  29. $scope.Status = data;
  30. $scope.selectedDate = $scope.Status.Historie[$scope.Status.Historie.length - 1];
  31. $scope.Status.Liste = _.sortBy($scope.Status.Liste, function (entry) {
  32. return entry.Konto_Nr;
  33. });
  34. $scope.Domaene.Datum = _.chain($scope.Status.Liste).pluck('Datum').unique().sort().value();
  35. $scope.Domaene.Quelle = _.chain($scope.Status.Liste).pluck('Quelle').unique().sort().value();
  36. });
  37. $scope.badge = function (typ) {
  38. if (typ === "neu") {
  39. return "label-success";
  40. }
  41. if (typ === "akt") {
  42. return "label-warning";
  43. }
  44. return "label-danger";
  45. };
  46. /**
  47. * @return {string}
  48. */
  49. $scope.Kontoart = function (art) {
  50. return (art === "1") ? "Bilanz" : "GuV";
  51. };
  52. /**
  53. * @return {string}
  54. */
  55. $scope.Seit = function (datum) {
  56. if (moment(datum, "DD.MM.YYYY").isSame(moment(), 'day')) {
  57. return "heute";
  58. }
  59. return moment(datum, "DD.MM.YYYY").from(moment().startOf('day'));
  60. };
  61. });
  62. })();