{"version":3,"file":"../../js/ClientInformation/qmc.client-information.min.js","sources":["qmc.client-information.min.js"],"sourcesContent":["var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\n(function () {\n angular.module('QMC.ClientInformation', []).config(routes);\n routes.$inject = ['$locationProvider', '$stateProvider', '$urlRouterProvider', 'qmcBase'];\n function routes($locationProvider, $stateProvider, $urlRouterProvider, qmcBase) {\n $locationProvider.html5Mode({\n enabled: false,\n requireBase: false\n });\n $stateProvider\n .state('clientInformation', {\n url: '/clientInformation',\n templateUrl: qmcBase + '/ClientInformation',\n controller: 'ClientInformationController',\n controllerAs: 'vm',\n resolve: {\n data: [function () {\n console.log('Current State: ClientInformation');\n }]\n }\n });\n }\n})();\nvar QMC;\n(function (QMC) {\n var ClientInformation;\n (function (ClientInformation) {\n var HttpProvider = /** @class */ (function () {\n function HttpProvider() {\n }\n HttpProvider.configureHttpProvider = function ($httpProvider) {\n // initialize get if not there\n if (!$httpProvider.defaults.headers.get) {\n $httpProvider.defaults.headers.get = {};\n }\n // disable IE ajax request caching\n $httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';\n // extra\n $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';\n $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';\n };\n return HttpProvider;\n }());\n ClientInformation.HttpProvider = HttpProvider;\n })(ClientInformation = QMC.ClientInformation || (QMC.ClientInformation = {}));\n})(QMC || (QMC = {}));\n(function () {\n angular.module('QMC.ClientInformation')\n .config(['$httpProvider', QMC.ClientInformation.HttpProvider.configureHttpProvider]);\n})();\nvar QMC;\n(function (QMC) {\n var ClientInformation;\n (function (ClientInformation) {\n var ClientInformationService = /** @class */ (function (_super) {\n __extends(ClientInformationService, _super);\n function ClientInformationService($http, $q) {\n var _this = _super.call(this, $http, $q) || this;\n _this.$http = $http;\n _this.$q = $q;\n _this.modulePath = '/ClientInformation';\n return _this;\n }\n ClientInformationService.prototype.getClientInformationWv = function () {\n return _super.prototype.getItem.call(this, this.modulePath + '/WvModel', {}, function (data) {\n return data;\n });\n };\n ClientInformationService.prototype.getCategoryList = function () {\n return _super.prototype.getItem.call(this, this.modulePath + '/CategoryList', {}, function (data) {\n return data;\n });\n };\n ClientInformationService.prototype.getClientInformation = function (form, formatText) {\n if (formatText === void 0) { formatText = false; }\n return _super.prototype.post.call(this, this.modulePath + (\"?formatText=\" + formatText), form).then(function (data) {\n return data;\n });\n };\n ClientInformationService = __decorate([\n QMC.Service('QMC.ClientInformation', 'ClientInformationService'),\n QMC.Inject('$http', '$q')\n ], ClientInformationService);\n return ClientInformationService;\n }(QMC.Common.BaseService));\n ClientInformation.ClientInformationService = ClientInformationService;\n })(ClientInformation = QMC.ClientInformation || (QMC.ClientInformation = {}));\n})(QMC || (QMC = {}));\nvar QMC;\n(function (QMC) {\n var ClientInformation;\n (function (ClientInformation) {\n var QmClientInformationDirective = /** @class */ (function () {\n function QmClientInformationDirective($qui, lng, permissionService, clientInformationService, clientService, employeeService) {\n var _this = this;\n this.$qui = $qui;\n this.lng = lng;\n this.permissionService = permissionService;\n this.clientInformationService = clientInformationService;\n this.clientService = clientService;\n this.employeeService = employeeService;\n this.restrict = 'E';\n this.templateUrl = './clientinformation/ClientInformationDirective';\n this.replace = true;\n this.scope = {\n qmSelectedClients: '=',\n };\n this.groupTags = {\n client: this.lng.translate(0, 'Klient'),\n flsGroup: this.lng.translate(0, 'Fachleistungsgruppe'),\n personslist: this.lng.translate(0, 'Personenliste')\n };\n this.link = function (scope) {\n var storageName = 'ClientInfo_' + $('#session').data().userId;\n scope.form = {\n clients: scope.qmSelectedClients,\n employee: scope.qmSelectedEmployee,\n includeEmployeesThatModified: true,\n markings: [],\n livingAreas: [],\n dateFrom: new Date().setMonth(new Date().getMonth() - 1),\n dateTo: new Date(),\n categoryPreselection: \"a6ce4251-f69e-4f03-b7c0-00d80e53aeaf\",\n searchwords: \"\",\n privateContent: false,\n allCategories: true,\n allLivingAreas: true\n };\n scope.clientInfo = {\n clientInformation: [],\n clientInfoText: \"\",\n orderAsc: false\n };\n var cacheFilter = function () {\n var temp = angular.copy(scope.form);\n delete temp.clients;\n delete temp.employee;\n delete temp.dateFrom;\n delete temp.dateTo;\n temp.orderAsc = scope.clientInfo.orderAsc;\n };\n scope.$watch('qmSelectedEmployee', function (newVal, oldVal) {\n if (newVal === oldVal)\n return;\n scope.form.clients = scope.qmSelectedEmployee;\n });\n scope.$watch('qmSelectedClients', function (newVal, oldVal) {\n if (newVal === oldVal)\n return;\n scope.form.clients = scope.qmSelectedClients;\n });\n scope.$watch('form.clients', function (newVal, oldVal) {\n if (newVal === oldVal)\n return;\n scope.qmSelectedClients = scope.form.clients;\n });\n _this.permissionService.getPermissionsByObjectType(143000).then(function (data) {\n scope.allowExport = data[0].print;\n });\n scope.init = function () {\n var restoreStorage = false;\n scope.$watch('clientInfo.orderAsc', function (newVal, oldVal) {\n if (newVal === oldVal)\n return;\n cacheFilter();\n scope.clientInfo.clientInfoText = _this.createTextFromClientInfo(scope.clientInfo.clientInformation, scope.clientInfo.orderAsc);\n });\n scope.$watch('form.categoryPreselection', function (newVal, oldVal) {\n if (restoreStorage)\n return;\n if (newVal !== oldVal || !scope.form || !scope.form.categoryPreselection)\n // find selected preselection\n for (var _i = 0, _a = scope.categoryPreselectionList; _i < _a.length; _i++) {\n var category = _a[_i];\n if (category.id === scope.form.categoryPreselection) {\n scope.form.categories = category.category;\n scope.form.livingAreas = category.livingArea.filter(function (x) { return x != null; });\n break;\n }\n }\n //if no livingAreas where found for the selected category, fill the livingAreas with the formattedLivingAreas\n if (scope.form.livingAreas.length === 0) {\n scope.form.livingAreas = scope.formattedLivingAreas.map(function (a) { return a.value; });\n }\n });\n if (localStorage.getItem(storageName)) {\n restoreStorage = true;\n var storage = JSON.parse(localStorage.getItem(storageName));\n scope.clientInfo.orderAsc = storage.orderAsc;\n scope.form = __assign(__assign({}, scope.form), storage);\n setTimeout(function () { restoreStorage = false; }, 50);\n }\n scope.$watch('form', function () {\n cacheFilter();\n }, true);\n };\n scope.getData = function () {\n scope.loadingData = true;\n _this.clientInformationService.getCategoryList().then(function (dataCategoryList) {\n scope.categoryPreselectionList = dataCategoryList;\n scope.formattedCategoryPreselections = dataCategoryList.map(function (x) { return ({ value: x.id, text: x.name }); });\n _this.clientInformationService.getClientInformationWv().then(function (dataWv) {\n scope.loadingData = false;\n dataWv.livingAreaWvList.unshift({\n id: QMC.Common.Constants.GUID_EMPTY,\n objectId: QMC.Common.Constants.GUID_EMPTY,\n name: _this.lng.translate(20026009, \"Ohne Lebensbereich\"),\n isFix: true,\n value: 0\n });\n scope.formattedCategories = dataWv.categoryWvList.map(function (x) { return ({ value: x.objectId, text: x.name }); });\n scope.formattedLivingAreas = dataWv.livingAreaWvList.map(function (x) { return ({ value: x.objectId, text: x.name }); });\n scope.formattedMarkings = dataWv.markingWvList.map(function (x) { return ({ value: x.objectId, text: x.name }); });\n _this.clientInformationService.getCategoryList().then(function (dataCategoryList) {\n scope.categoryList = dataCategoryList;\n for (var _i = 0, _a = scope.categoryList; _i < _a.length; _i++) {\n var category = _a[_i];\n if (category.category.length === 0)\n category.category = scope.formattedCategories.map(function (a) { return a.value; });\n if (category.livingArea.length === 0)\n category.livingArea = scope.formattedLivingAreas.map(function (a) { return a.value; });\n }\n scope.init();\n });\n });\n });\n };\n scope.getReferences = function () {\n scope.formattedReferences = [];\n scope.loadingClients = true;\n _this.clientService.getClientPersonList().then(function (data) {\n scope.formattedReferences = scope.formattedReferences.concat(data.map(function (x) { return ({ value: x.objectId, text: _this.$qui.createPersonDisplay(x.lastName, x.firstName, x.shortCaption, x.personNumber) + (\", \" + x.institute), group: _this.groupTags.client }); }));\n scope.loadingClients = false;\n });\n _this.clientService.getFlsGroupList(0, -1).then(function (data) {\n scope.formattedReferences = scope.formattedReferences.concat(data.items.map(function (x) { return ({ value: x.objectId, text: x.name + (\", \" + x.institution), group: _this.groupTags.flsGroup }); }));\n });\n _this.clientService.getAllPersonLists().then(function (data) {\n scope.formattedReferences = scope.formattedReferences.concat(data.map(function (x) { return ({ value: x.objectId, text: x.name, group: _this.groupTags.personslist }); }));\n });\n };\n scope.getEmployee = function () {\n scope.loadingEmployee = true;\n _this.employeeService.getEmployeeList().then(function (data) {\n scope.formattedEmployee = data.map(function (x) { return ({ value: x.objectId, text: _this.$qui.createPersonDisplay(x.name, x.forename, x.shortCaption, x.employeeNr), group: x.institute }); });\n scope.loadingEmployee = false;\n });\n };\n scope.getData();\n scope.getReferences();\n scope.getEmployee();\n scope.print = function () {\n var winPrint = window.open('', '', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0');\n winPrint.document.write(scope.clientInfo.clientInfoText);\n winPrint.document.close();\n winPrint.focus();\n winPrint.print();\n winPrint.close();\n };\n scope.createClientInfo = function () {\n var _a, _b;\n scope.clientInfo.clientInformation = [];\n scope.clientInfo.clientInfoText = '';\n if (scope.form.clients.length === 0) {\n _this.$qui.notify({\n message: _this.lng.translate(20026007, \"Kein Klient angegeben\"),\n title: _this.lng.translate(20002017, \"Warnung\"),\n timer: 5000\n });\n return;\n }\n scope.form.dateFrom = _this.$qui.createDateFromString(scope.form.dateFrom);\n scope.form.dateTo = _this.$qui.createDateFromString(scope.form.dateTo);\n scope.loadingInfo = true;\n var getForm = {\n references: _this.createReferences((_a = scope.form.clients) !== null && _a !== void 0 ? _a : [], (_b = scope.form.employee) !== null && _b !== void 0 ? _b : [], scope.formattedReferences),\n //ReferenceClientIds: scope.form.clients,\n //ReferenceEmployeeIds: scope.form.employee,\n includeEmployeesThatModified: scope.form.includeEmployeesThatModified,\n categoryIds: scope.form.categories,\n livingAreaIds: scope.form.livingAreas,\n markingIds: scope.form.markings,\n searchterms: scope.form.searchwords.split(\";\"),\n dateFrom: scope.form.dateFrom,\n dateTo: scope.form.dateTo,\n privateContent: scope.form.privateContent\n };\n _this.clientInformationService.getClientInformation(getForm, scope.form.formatText).then(function (data) {\n scope.clientInfo.clientInformation = data.sort(function (a, b) { return a.reference.localeCompare(b.reference); });\n scope.clientInfo.clientInfoText = _this.createTextFromClientInfo(scope.clientInfo.clientInformation, scope.clientInfo.orderAsc);\n scope.loadingInfo = false;\n });\n };\n };\n }\n QmClientInformationDirective.prototype.createTextFromClientInfo = function (clientInfo, orderAsc) {\n var result = \"\";\n // items are arrangend for client so we create text for client\n for (var i = 0; i < clientInfo.length; i++) {\n var client = clientInfo[i];\n if (i !== 0)\n result += \"
\";\n result += this.createBoldText(item.category + \" \" + client.reference + ', ' + item.title + \"
\");\n if (item.dateFrom)\n result += moment(item.dateFrom).format(\"DD.MM.YYYY HH:mm\") + \" \";\n if (item.dateTo)\n result += \"- \" + moment(item.dateTo).format(\"DD.MM.YYYY HH:mm\") + \" \";\n if (item.author && item.author.length > 0)\n result += this.lng.translate(20000062, \"Autor\") + \": \" + item.author;\n for (var k = 0; k < item.content.length; k++) {\n var content = item.content[k];\n result += \"
\";\n var header = item.content[k].title && item.content[k].title.length > 0 ? this.createBoldText(item.content[k].title) + ' ' : '';\n if (content.date && k > 0)\n header += moment(content.date).format(\"DD.MM.YYYY HH:mm\");\n if (content.author && content.author.trim() !== \"\" && k > 0)\n header += \" \" + this.lng.translate(20000062, \"Autor\") + \": \" + content.author + \" \";\n if (content.livingArea && content.livingArea.trim() !== \"\")\n header += this.createBoldText(this.lng.translate(20000074, \"Lebensbereich\") + \": \" + content.livingArea);\n result += header.trim().length > 0 ? header.trim() + '
' : '';\n result += content.comment.length > 0 ? content.comment + \"
\" : \"\";\n }\n result += \"