diff --git a/front/salix/components/user-configuration-popover/index.html b/front/salix/components/user-configuration-popover/index.html index 1c771c713..b43ecdf62 100644 --- a/front/salix/components/user-configuration-popover/index.html +++ b/front/salix/components/user-configuration-popover/index.html @@ -41,7 +41,9 @@ data="banksData" select-fields="['id','bank']" show-field="bank" + order="id" value-field="id"> + {{id}}: {{bank}} diff --git a/front/salix/components/user-configuration-popover/index.js b/front/salix/components/user-configuration-popover/index.js index ddade39bb..2ee77485d 100644 --- a/front/salix/components/user-configuration-popover/index.js +++ b/front/salix/components/user-configuration-popover/index.js @@ -43,7 +43,8 @@ class Controller { set warehouseFk(value) { this.warehouse = value; - if (value && !window.localStorage.localWarehouseFk) + if (value && + (!window.localStorage.localWarehouseFk || window.localStorage.localWarehouseFk === 'null')) window.localStorage.defaultWarehouseFk = value; this.setUserConfig('warehouseFk', value); } @@ -54,7 +55,8 @@ class Controller { set companyFk(value) { this.company = value; - if (value && !window.localStorage.localCompanyFk) + if (value && + (!window.localStorage.localCompanyFk || window.localStorage.localCompanyFk === 'null')) window.localStorage.defaultCompanyFk = value; this.setUserConfig('companyFk', value); } @@ -103,8 +105,10 @@ class Controller { } $onInit() { - if (localStorage.getItem('localBankFk')) - window.localStorage.defaultBankFk = localStorage.getItem('localBankFk'); + if (window.localStorage.localBankFk && window.localStorage.localBankFk !== 'null') + window.localStorage.defaultBankFk = window.localStorage.localBankFk; + else + localStorage.removeItem('defaultBankFk'); } } diff --git a/modules/agency/front/descriptor/index.js b/modules/agency/front/descriptor/index.js index c8d6bbc26..3986f6edc 100644 --- a/modules/agency/front/descriptor/index.js +++ b/modules/agency/front/descriptor/index.js @@ -24,6 +24,7 @@ class Controller { this.$state.go('zone.index'); }); } + console.log('res', response); } } diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index 9278713cf..59b51247c 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -6,7 +6,15 @@ - + + @@ -58,3 +66,9 @@ + + \ No newline at end of file diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 993b4331c..ac53e1203 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -1,8 +1,15 @@ import ngModule from '../module'; class Controller { - constructor($state) { + constructor($scope, $state, $http, $translate, vnApp) { + this.$scope = $scope; this.$state = $state; + this.$http = $http; + this.$translate = $translate; + this.vnApp = vnApp; + this.moreOptions = [ + {callback: this.showConfirmDialog, name: 'Pickup order'} + ]; } get claim() { @@ -30,9 +37,28 @@ class Controller { get quicklinks() { return this._quicklinks; } + + onMoreChange(callback) { + callback.call(this); + } + + showConfirmDialog() { + this.$scope.confirmDialog.show(); + } + + returnDialog(response) { + if (response === 'CANCEL') { + let url = `/report/rpt-claim-pickup-order?claimFk=${this.claim.id}`; + window.open(url); + } else if (response === 'ACCEPT') { + this.$http.post(`/email/claim-pickup-order`, {claimFk: this.claim.id}).then( + () => this.vnApp.showMessage(this.$translate.instant('Notification sent!')) + ); + } + } } -Controller.$inject = ['$state']; +Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp']; ngModule.component('vnClaimDescriptor', { template: require('./index.html'), diff --git a/modules/claim/front/locale/es.yml b/modules/claim/front/locale/es.yml index e5266af5d..654f20fa1 100644 --- a/modules/claim/front/locale/es.yml +++ b/modules/claim/front/locale/es.yml @@ -7,6 +7,8 @@ Remove sale: Borrar linea Claim Id: Id reclamación Created: Creado Enter a new search: Introduce una nueva búsqueda +Pickup order: Orden de recogida +Do you want to send it directly?: ¿Quieres enviarlo directamente? #sections Claims: Reclamaciones diff --git a/package-lock.json b/package-lock.json index da05e2a95..a7904cff8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1271,7 +1271,7 @@ }, "ansi-escapes": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", "dev": true }, @@ -1564,7 +1564,7 @@ }, "util": { "version": "0.10.3", - "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -1883,7 +1883,7 @@ "base": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=", "dev": true, "requires": { "cache-base": "^1.0.1", @@ -2685,7 +2685,7 @@ }, "browserify-rsa": { "version": "4.0.1", - "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { @@ -2735,7 +2735,7 @@ }, "buffer": { "version": "4.9.1", - "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "dev": true, "requires": { @@ -2910,7 +2910,7 @@ "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=", "dev": true, "requires": { "collection-visit": "^1.0.0", @@ -2954,7 +2954,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -3157,7 +3157,7 @@ "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=", "dev": true, "requires": { "arr-union": "^3.1.0", @@ -3317,7 +3317,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -3431,7 +3431,7 @@ }, "colors": { "version": "1.1.2", - "resolved": "http://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", "dev": true }, @@ -3624,7 +3624,7 @@ }, "content-disposition": { "version": "0.5.2", - "resolved": "http://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" }, "content-security-policy-builder": { @@ -3825,7 +3825,7 @@ }, "css-loader": { "version": "0.25.0", - "resolved": "http://registry.npmjs.org/css-loader/-/css-loader-0.25.0.tgz", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-0.25.0.tgz", "integrity": "sha1-w/68jOKPTINXa2sTcH9H+Qw5AiM=", "dev": true, "requires": { @@ -4449,7 +4449,7 @@ "dot-prop": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", - "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", + "integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=", "dev": true, "requires": { "is-obj": "^1.0.0" @@ -4482,7 +4482,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -4609,7 +4609,7 @@ "dependencies": { "fs-extra": { "version": "0.30.0", - "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", "dev": true, "requires": { @@ -4622,7 +4622,7 @@ }, "jsonfile": { "version": "2.4.0", - "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "dev": true, "requires": { @@ -5151,7 +5151,7 @@ }, "events": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", "dev": true }, @@ -5654,7 +5654,7 @@ }, "file-loader": { "version": "1.1.11", - "resolved": "http://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz", + "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz", "integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==", "dev": true, "requires": { @@ -5874,7 +5874,7 @@ }, "fs-access": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", "dev": true, "requires": { @@ -5947,7 +5947,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5968,12 +5969,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5988,17 +5991,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -6115,7 +6121,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -6127,6 +6134,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -6141,6 +6149,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -6148,12 +6157,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -6172,6 +6183,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -6252,7 +6264,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -6264,6 +6277,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -6349,7 +6363,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -6385,6 +6400,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -6404,6 +6420,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -6447,12 +6464,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -6654,7 +6673,7 @@ "global-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=", "dev": true, "requires": { "global-prefix": "^1.0.1", @@ -6697,7 +6716,7 @@ }, "globby": { "version": "5.0.0", - "resolved": "http://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true, "requires": { @@ -6742,7 +6761,7 @@ }, "got": { "version": "6.7.1", - "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "dev": true, "requires": { @@ -6919,7 +6938,7 @@ }, "kind-of": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=", "dev": true }, @@ -7103,7 +7122,7 @@ "dependencies": { "es6-promise": { "version": "3.3.1", - "resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", "integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=", "dev": true }, @@ -7885,7 +7904,7 @@ "is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", - "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "integrity": "sha1-OV4a6EsR8mrReV5zwXN45IowFXY=", "dev": true, "requires": { "is-relative": "^1.0.0", @@ -7940,7 +7959,7 @@ }, "is-builtin-module": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { @@ -8087,7 +8106,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -8124,7 +8143,7 @@ "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=", "dev": true, "requires": { "isobject": "^3.0.1" @@ -8160,7 +8179,7 @@ "is-relative": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", - "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "integrity": "sha1-obtpNc6MXboei5dUubLcwCDiJg0=", "dev": true, "requires": { "is-unc-path": "^1.0.0" @@ -8203,7 +8222,7 @@ "is-unc-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", - "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "integrity": "sha1-1zHoiY7QkKEsNSrS6u1Qla0yLJ0=", "dev": true, "requires": { "unc-path-regex": "^0.1.2" @@ -8304,7 +8323,7 @@ }, "jasmine-core": { "version": "2.99.1", - "resolved": "http://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", "dev": true }, @@ -8321,7 +8340,7 @@ "jasmine-spec-reporter": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz", - "integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==", + "integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=", "dev": true, "requires": { "colors": "1.1.2" @@ -8609,7 +8628,7 @@ "karma-chrome-launcher": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", - "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", + "integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=", "dev": true, "requires": { "fs-access": "^1.0.0", @@ -8787,7 +8806,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -10295,7 +10314,7 @@ }, "media-typer": { "version": "0.3.0", - "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, "mem": { @@ -10318,7 +10337,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -10441,7 +10460,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minstache": { @@ -10534,7 +10553,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -10542,7 +10561,7 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } @@ -10694,7 +10713,7 @@ }, "multipipe": { "version": "0.1.2", - "resolved": "http://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", "dev": true, "requires": { @@ -10823,7 +10842,7 @@ }, "named-placeholders": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.1.tgz", "integrity": "sha1-O3oNJiA910s6nfTJz7gnsvuQfmQ=", "dev": true, "requires": { @@ -10832,7 +10851,7 @@ "dependencies": { "lru-cache": { "version": "2.5.0", - "resolved": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz", "integrity": "sha1-2COIrpyWC+y+oMc7uet5tsbOmus=", "dev": true } @@ -10919,7 +10938,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } @@ -11812,7 +11831,7 @@ "dependencies": { "minimist": { "version": "0.0.10", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, @@ -11874,7 +11893,7 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, @@ -11890,7 +11909,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -12078,7 +12097,7 @@ }, "path-browserify": { "version": "0.0.0", - "resolved": "http://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", "dev": true }, @@ -12829,7 +12848,7 @@ }, "pretty-bytes": { "version": "1.0.4", - "resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", "dev": true, "requires": { @@ -12918,7 +12937,7 @@ }, "through2": { "version": "0.2.3", - "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz", "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", "dev": true, "requires": { @@ -13457,7 +13476,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } @@ -13863,7 +13882,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { @@ -13987,7 +14006,7 @@ "dependencies": { "source-map": { "version": "0.4.4", - "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { @@ -14127,7 +14146,7 @@ "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "integrity": "sha1-ca5KiPD+77v1LR6mBPP7MV67YnQ=", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -14314,7 +14333,7 @@ "snapdragon-node": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=", "dev": true, "requires": { "define-property": "^1.0.0", @@ -14365,7 +14384,7 @@ "snapdragon-util": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=", "dev": true, "requires": { "kind-of": "^3.2.0" @@ -14710,7 +14729,7 @@ "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=", "dev": true, "requires": { "extend-shallow": "^3.0.0" @@ -14719,7 +14738,7 @@ "split2": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", + "integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=", "dev": true, "requires": { "through2": "^2.0.2" @@ -14821,7 +14840,7 @@ }, "stream-browserify": { "version": "2.0.1", - "resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "dev": true, "requires": { @@ -14900,7 +14919,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -14992,7 +15011,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -15252,7 +15271,7 @@ }, "style-loader": { "version": "0.20.3", - "resolved": "http://registry.npmjs.org/style-loader/-/style-loader-0.20.3.tgz", + "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.20.3.tgz", "integrity": "sha512-2I7AVP73MvK33U7B9TKlYZAqdROyMXDYSMvHLX43qy3GCOaJNiV6i0v/sv9idWIaQ42Yn2dNv79Q5mKXbKhAZg==", "dev": true, "requires": { @@ -15398,7 +15417,7 @@ }, "tar": { "version": "2.2.1", - "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "dev": true, "requires": { @@ -15568,7 +15587,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { @@ -15751,7 +15770,7 @@ "touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=", "dev": true, "requires": { "nopt": "~1.0.10" @@ -15840,7 +15859,7 @@ }, "tty-browserify": { "version": "0.0.0", - "resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", "dev": true }, @@ -16250,7 +16269,7 @@ "useragent": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", - "integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==", + "integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=", "dev": true, "requires": { "lru-cache": "4.1.x", @@ -16484,7 +16503,7 @@ }, "vm-browserify": { "version": "0.0.4", - "resolved": "http://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", "dev": true, "requires": { @@ -16972,7 +16991,7 @@ }, "globby": { "version": "6.1.0", - "resolved": "http://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { @@ -16985,7 +17004,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -17373,7 +17392,7 @@ "write-file-atomic": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", - "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", + "integrity": "sha1-H/YVdcLipOjlENb6TiQ8zhg5mas=", "dev": true, "requires": { "graceful-fs": "^4.1.11", diff --git a/print/common/css/layout.css b/print/common/css/layout.css index 4a0d4ff22..3f540622e 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -1,3 +1,9 @@ +.container { + font-family: verdana, sans-serif; + font-size: 16px; + zoom: 0.55 +} + .columns { overflow: hidden } @@ -27,46 +33,6 @@ float: left } -.pull-left { - float: left -} - -.pull-right { - float: right -} - -.grid { - border-bottom: 3px solid #888888 -} - -.grid .row { - padding: 5px; - margin-bottom: 0 -} - -.grid .header { - border-bottom: 1px solid #808080; - border-top: 1px solid #808080; - background-color: #c0c0c0; -} - - -.grid .row.inline > div { - float: left; -} - - -.panel { - border: 1px solid #DDD; - margin-bottom: 10px; - position: relative; - padding:10px -} - -.panel .header { - font-weight: bold -} - .row { margin-bottom: 15px; overflow: hidden @@ -139,6 +105,37 @@ overflow: visible } +.grid { + border-bottom: 3px solid #888888 +} + +.grid .row { + padding: 5px; + margin-bottom: 0 +} + +.grid .header { + border-bottom: 1px solid #808080; + border-top: 1px solid #808080; + font-weight: bold +} + + +.grid .row.inline > div { + float: left; +} + +.panel { + border: 1px solid #DDD; + margin-bottom: 10px; + position: relative; + padding:10px +} + +.panel .header { + font-weight: bold +} + .box { border-top: 1px solid #CCC; border-right: 1px solid #CCC; @@ -163,23 +160,4 @@ .pull-right { float: right -} - -.grid { - border-bottom: 3px solid #888888 -} - -.grid .row { - padding: 5px; - margin-bottom: 0 -} - -.grid .header { - border-bottom: 1px solid #808080; - border-top: 1px solid #808080; - background-color: #c0c0c0; -} - -.grid .row.inline > div { - float: left; } \ No newline at end of file diff --git a/print/config/routes.json b/print/config/routes.json index 05d2e85a0..added704e 100644 --- a/print/config/routes.json +++ b/print/config/routes.json @@ -4,9 +4,10 @@ {"type": "email", "name": "payment-update"}, {"type": "email", "name": "letter-debtor-st"}, {"type": "email", "name": "letter-debtor-nd"}, + {"type": "email", "name": "claim-pickup-order"}, {"type": "report", "name": "delivery-note"}, {"type": "report", "name": "invoice"}, - {"type": "report", "name": "claim-pickup"}, + {"type": "report", "name": "rpt-claim-pickup-order"}, {"type": "static", "name": "email-header"}, {"type": "static", "name": "email-footer"}, {"type": "static", "name": "report-header"}, diff --git a/print/lib/emailEngine.js b/print/lib/emailEngine.js index 9b4a0ffdf..86342bb36 100644 --- a/print/lib/emailEngine.js +++ b/print/lib/emailEngine.js @@ -4,18 +4,16 @@ const renderer = require('vue-server-renderer').createRenderer(); const fs = require('fs-extra'); const juice = require('juice'); const smtp = require('./smtp'); -const i18n = new VueI18n({ - locale: 'es', -}); - -Vue.use(VueI18n); +const fallbackLocale = 'es'; if (!process.env.OPENSSL_CONF) process.env.OPENSSL_CONF = '/etc/ssl/'; +Vue.use(VueI18n); + module.exports = { - path: `${appPath}/reports`, + path: `${appPath}/report`, /** * Renders a report component @@ -25,17 +23,18 @@ module.exports = { */ async render(name, ctx) { const component = require(`${this.path}/${name}`); - const prefetchedData = await this.preFetch(component, ctx); - - const app = new Vue({ - i18n, - render: h => h(component), + const result = await this.preFetch(component, ctx); + const i18n = new VueI18n({ + locale: 'es', + fallbackLocale }); + const app = new Vue({i18n, + render: h => h(result.component)}); return renderer.renderToString(app).then(renderedHtml => { return { html: renderedHtml, - data: prefetchedData, + data: result.mergedData, }; }); }, @@ -43,10 +42,11 @@ module.exports = { /** * Prefetch all component data from asyncData method * - * @param {Object} component - Component object + * @param {Object} orgComponent - Component object * @param {Object} ctx - Request context */ - async preFetch(component, ctx) { + async preFetch(orgComponent, ctx) { + let component = Object.create(orgComponent); let mergedData = {attachments: []}; let asyncData = {}; let data = {}; @@ -60,14 +60,18 @@ module.exports = { await this.attachAssets(component); - if (component.hasOwnProperty('data')) - data = component.data(); + if (orgComponent.hasOwnProperty('data')) + data = orgComponent.data(); - if (component.hasOwnProperty('asyncData')) { - asyncData = await component.asyncData(ctx, params); + if (orgComponent.hasOwnProperty('asyncData')) { + asyncData = await orgComponent.asyncData(ctx, params); if (asyncData.locale) { - const locale = component.i18n.messages[asyncData.locale]; + let locale = component.i18n.messages[asyncData.locale]; + + if (!locale) + locale = component.i18n.messages[fallbackLocale]; + mergedData.subject = locale.subject; } } @@ -81,7 +85,7 @@ module.exports = { if (data.hasOwnProperty('files')) { const files = data.files; files.forEach(file => { - const componentPath = `${this.path}/${component.name}`; + const componentPath = `${this.path}/${orgComponent.name}`; let fileSrc = componentPath + file; if (file.slice(0, 4) === 'http' || file.slice(0, 4) === 'https') @@ -96,25 +100,30 @@ module.exports = { }); } - if (component.components) { - const components = component.components; - const promises = []; + const components = orgComponent.components; - Object.keys(components).forEach(component => { - promises.push(this.preFetch(components[component], ctx)); + if (components) { + const promises = []; + const childNames = []; + component.components = {}; + + Object.keys(components).forEach(childName => { + childNames.push(childName); + promises.push(this.preFetch(components[childName], ctx)); }); - return Promise.all(promises).then(results => { - results.forEach(result => { - result.attachments.forEach(atth => { + await Promise.all(promises).then(results => { + results.forEach((result, i) => { + result.mergedData.attachments.forEach(atth => { mergedData.attachments.push(atth); }); + + component.components[childNames[i]] = result.component; }); - return mergedData; }); } - return mergedData; + return {component, mergedData}; }, async attachAssets(component) { diff --git a/print/lib/reportEngine.js b/print/lib/reportEngine.js index af8d93441..b77d88267 100644 --- a/print/lib/reportEngine.js +++ b/print/lib/reportEngine.js @@ -13,7 +13,7 @@ if (!process.env.OPENSSL_CONF) module.exports = { - path: `${appPath}/reports`, + path: `${appPath}/report`, /** * Renders a report component @@ -23,16 +23,13 @@ module.exports = { */ async render(name, ctx) { const component = require(`${this.path}/${name}`); - - await this.preFetch(component, ctx); - + const result = await this.preFetch(component, ctx); const i18n = new VueI18n({ locale: 'es', + fallbackLocale: 'en' }); - const app = new Vue({ - i18n, - render: h => h(component), - }); + const app = new Vue({i18n, + render: h => h(result.component)}); return renderer.renderToString(app); }, @@ -40,10 +37,11 @@ module.exports = { /** * Prefetch all component data from asyncData method * - * @param {Object} component - Component object + * @param {Object} orgComponent - Component object * @param {Object} ctx - Request context */ - async preFetch(component, ctx) { + async preFetch(orgComponent, ctx) { + let component = Object.create(orgComponent); let mergedData = {}; let asyncData = {}; let data = {}; @@ -57,11 +55,11 @@ module.exports = { await this.attachAssets(component); - if (component.hasOwnProperty('data')) - data = component.data(); + if (orgComponent.hasOwnProperty('data')) + data = orgComponent.data(); - if (component.hasOwnProperty('asyncData')) - asyncData = await component.asyncData(ctx, params); + if (orgComponent.hasOwnProperty('asyncData')) + asyncData = await orgComponent.asyncData(ctx, params); mergedData = Object.assign(mergedData, data, asyncData); @@ -69,16 +67,25 @@ module.exports = { return mergedData; }; - if (component.components) { - const components = component.components; + const components = orgComponent.components; + if (components) { const promises = []; + const childNames = []; + component.components = {}; - Object.keys(components).forEach(component => { - promises.push(this.preFetch(components[component], ctx)); + Object.keys(components).forEach(childName => { + childNames.push(childName); + promises.push(this.preFetch(components[childName], ctx)); }); - return Promise.all(promises); + await Promise.all(promises).then(results => { + results.forEach((result, i) => { + component.components[childNames[i]] = result.component; + }); + }); } + + return {component}; }, async attachAssets(component) { diff --git a/print/lib/router.js b/print/lib/router.js index 0418a07d9..30fd0d347 100644 --- a/print/lib/router.js +++ b/print/lib/router.js @@ -4,7 +4,7 @@ const express = require('express'); const routes = require(`../config/routes.json`); module.exports = app => { - this.path = `${appPath}/reports`; + this.path = `${appPath}/report`; /** * Enables a report @@ -15,10 +15,9 @@ module.exports = app => { if (!name) throw new Error('Report name required'); app.get(`/report/${name}`, (request, response, next) => { - response.setHeader('Content-Disposition', `attachment; filename="${name}.pdf"`); - response.setHeader('Content-type', 'application/pdf'); - reportEngine.toPdf(name, request).then(stream => { + response.setHeader('Content-Disposition', `attachment; filename="${name}.pdf"`); + response.setHeader('Content-type', 'application/pdf'); stream.pipe(response); }).catch(e => { next(e); diff --git a/print/reports/claim-pickup/assets/css/index.js b/print/report/claim-pickup-order/assets/css/index.js similarity index 100% rename from print/reports/claim-pickup/assets/css/index.js rename to print/report/claim-pickup-order/assets/css/index.js diff --git a/print/reports/payment-update/assets/css/style.css b/print/report/claim-pickup-order/assets/css/style.css similarity index 88% rename from print/reports/payment-update/assets/css/style.css rename to print/report/claim-pickup-order/assets/css/style.css index 8f5acd032..a197ee5cd 100644 --- a/print/reports/payment-update/assets/css/style.css +++ b/print/report/claim-pickup-order/assets/css/style.css @@ -3,10 +3,8 @@ body { } .container { - font-family: arial, sans-serif; max-width: 600px; min-width: 320px; - font-size: 16px; margin: 0 auto; color: #555 } diff --git a/print/report/claim-pickup-order/index.html b/print/report/claim-pickup-order/index.html new file mode 100644 index 000000000..d598d3261 --- /dev/null +++ b/print/report/claim-pickup-order/index.html @@ -0,0 +1,32 @@ + + + + {{ $t('subject') }} + + + + + + + + {{ $t('title') }} + + + + {{$t('description.dear')}}, + {{$t('description.instructions')}} + + + + + + + \ No newline at end of file diff --git a/print/report/claim-pickup-order/index.js b/print/report/claim-pickup-order/index.js new file mode 100755 index 000000000..95d381d5c --- /dev/null +++ b/print/report/claim-pickup-order/index.js @@ -0,0 +1,52 @@ +const UserException = require(`${appPath}/lib/exceptions/userException`); +const reportEngine = require(`${appPath}/lib/reportEngine`); +const database = require(`${appPath}/lib/database`); +const emailHeader = require('../email-header'); +const emailFooter = require('../email-footer'); + + +module.exports = { + name: 'claim-pickup-order', + async asyncData(ctx, params) { + const promises = []; + const data = { + isPreview: ctx.method === 'GET', + }; + + if (!params.claimFk) + throw new UserException('No claim id specified'); + + promises.push(reportEngine.toPdf('rpt-claim-pickup-order', ctx)); + promises.push(this.methods.fetchClient(params.claimFk)); + + return Promise.all(promises).then(result => { + const stream = result[0]; + const [[client]] = result[1]; + + Object.assign(data, client); + Object.assign(data, {attachments: [{filename: 'claim-pickup-order.pdf', content: stream}]}); + + return data; + }); + }, + created() { + this.$i18n.locale = this.locale; + }, + methods: { + fetchClient(claimFk) { + return database.pool.query(` + SELECT + c.id, + u.lang locale, + c.email recipient + FROM claim cl + JOIN client c ON c.id = cl.clientFk + JOIN account.user u ON u.id = c.id + WHERE cl.id = ?`, [claimFk]); + }, + }, + components: { + emailHeader, + emailFooter, + }, +}; diff --git a/print/report/claim-pickup-order/locale.js b/print/report/claim-pickup-order/locale.js new file mode 100644 index 000000000..343a9f9ab --- /dev/null +++ b/print/report/claim-pickup-order/locale.js @@ -0,0 +1,25 @@ +module.exports = { + messages: { + es: { + subject: 'Orden de recogida', + title: 'Orden de recogida', + description: { + dear: 'Estimado cliente', + instructions: 'Aqui tienes tu orden de recogida.' + }, + sections: { + howToBuy: { + title: 'Cómo hacer un pedido', + description: `Para realizar un pedido en nuestra web, + debes configurarlo indicando:`, + requeriments: [ + 'Si quieres recibir el pedido (por agencia o por nuestro propio reparto) o si lo prefieres recoger en alguno de nuestros almacenes.', + 'La fecha en la que quieres recibir el pedido (se preparará el día anterior).', + 'La dirección de entrega o el almacén donde quieres recoger el pedido.'], + stock: 'En nuestra web y aplicaciones puedes visualizar el stock disponible de flor cortada, verdes, plantas, complementos y artificial. Ten en cuenta que dicho stock puede variar en función de la fecha seleccionada al configurar el pedido. Es importante CONFIRMAR los pedidos para que la mercancía quede reservada.', + delivery: 'El reparto se realiza de lunes a sábado según la zona en la que te encuentres. Por regla general, los pedidos que se entregan por agencia, deben estar confirmados y pagados antes de las 17h del día en que se preparan (el día anterior a recibirlos), aunque esto puede variar si el pedido se envía a través de nuestro reparto y según la zona.', + } + } + }, + }, +}; diff --git a/print/reports/client-welcome/assets/css/index.js b/print/report/client-welcome/assets/css/index.js similarity index 100% rename from print/reports/client-welcome/assets/css/index.js rename to print/report/client-welcome/assets/css/index.js diff --git a/print/reports/printer-setup/assets/css/style.css b/print/report/client-welcome/assets/css/style.css similarity index 88% rename from print/reports/printer-setup/assets/css/style.css rename to print/report/client-welcome/assets/css/style.css index 8f5acd032..a197ee5cd 100644 --- a/print/reports/printer-setup/assets/css/style.css +++ b/print/report/client-welcome/assets/css/style.css @@ -3,10 +3,8 @@ body { } .container { - font-family: arial, sans-serif; max-width: 600px; min-width: 320px; - font-size: 16px; margin: 0 auto; color: #555 } diff --git a/print/reports/client-welcome/index.html b/print/report/client-welcome/index.html similarity index 100% rename from print/reports/client-welcome/index.html rename to print/report/client-welcome/index.html diff --git a/print/reports/client-welcome/index.js b/print/report/client-welcome/index.js similarity index 94% rename from print/reports/client-welcome/index.js rename to print/report/client-welcome/index.js index 852455b6a..d3ac31205 100755 --- a/print/reports/client-welcome/index.js +++ b/print/report/client-welcome/index.js @@ -15,6 +15,8 @@ module.exports = { return this.methods.fetchClient(params.clientFk) .then(([result]) => { + if (!result) + throw new UserException('No client data found'); return Object.assign(data, result[0]); }); }, diff --git a/print/reports/client-welcome/locale.js b/print/report/client-welcome/locale.js similarity index 100% rename from print/reports/client-welcome/locale.js rename to print/report/client-welcome/locale.js diff --git a/print/reports/delivery-note/assets/css/style.css b/print/report/delivery-note/assets/css/style.css similarity index 100% rename from print/reports/delivery-note/assets/css/style.css rename to print/report/delivery-note/assets/css/style.css diff --git a/print/reports/delivery-note/index.html b/print/report/delivery-note/index.html similarity index 100% rename from print/reports/delivery-note/index.html rename to print/report/delivery-note/index.html diff --git a/print/reports/delivery-note/index.js b/print/report/delivery-note/index.js similarity index 100% rename from print/reports/delivery-note/index.js rename to print/report/delivery-note/index.js diff --git a/print/reports/delivery-note/locale.js b/print/report/delivery-note/locale.js similarity index 100% rename from print/reports/delivery-note/locale.js rename to print/report/delivery-note/locale.js diff --git a/print/reports/email-footer/assets/css/index.js b/print/report/email-footer/assets/css/index.js similarity index 100% rename from print/reports/email-footer/assets/css/index.js rename to print/report/email-footer/assets/css/index.js diff --git a/print/reports/email-footer/assets/css/style.css b/print/report/email-footer/assets/css/style.css similarity index 85% rename from print/reports/email-footer/assets/css/style.css rename to print/report/email-footer/assets/css/style.css index c3ad26042..cf0242f36 100644 --- a/print/reports/email-footer/assets/css/style.css +++ b/print/report/email-footer/assets/css/style.css @@ -1,11 +1,3 @@ -footer { - font-family: arial, sans-serif; - max-width: 600px; - min-width: 320px; - font-size: 16px; - margin: 0 auto -} - .buttons { background-color: #FFF; text-align: center; diff --git a/print/reports/email-footer/assets/images/action.png b/print/report/email-footer/assets/images/action.png similarity index 100% rename from print/reports/email-footer/assets/images/action.png rename to print/report/email-footer/assets/images/action.png diff --git a/print/reports/email-footer/assets/images/facebook.png b/print/report/email-footer/assets/images/facebook.png similarity index 100% rename from print/reports/email-footer/assets/images/facebook.png rename to print/report/email-footer/assets/images/facebook.png diff --git a/print/reports/email-footer/assets/images/info.png b/print/report/email-footer/assets/images/info.png similarity index 100% rename from print/reports/email-footer/assets/images/info.png rename to print/report/email-footer/assets/images/info.png diff --git a/print/reports/email-footer/assets/images/instagram.png b/print/report/email-footer/assets/images/instagram.png similarity index 100% rename from print/reports/email-footer/assets/images/instagram.png rename to print/report/email-footer/assets/images/instagram.png diff --git a/print/reports/email-footer/assets/images/linkedin.png b/print/report/email-footer/assets/images/linkedin.png similarity index 100% rename from print/reports/email-footer/assets/images/linkedin.png rename to print/report/email-footer/assets/images/linkedin.png diff --git a/print/reports/email-footer/assets/images/pinterest.png b/print/report/email-footer/assets/images/pinterest.png similarity index 100% rename from print/reports/email-footer/assets/images/pinterest.png rename to print/report/email-footer/assets/images/pinterest.png diff --git a/print/reports/email-footer/assets/images/twitter.png b/print/report/email-footer/assets/images/twitter.png similarity index 100% rename from print/reports/email-footer/assets/images/twitter.png rename to print/report/email-footer/assets/images/twitter.png diff --git a/print/reports/email-footer/assets/images/youtube.png b/print/report/email-footer/assets/images/youtube.png similarity index 100% rename from print/reports/email-footer/assets/images/youtube.png rename to print/report/email-footer/assets/images/youtube.png diff --git a/print/reports/email-footer/index.html b/print/report/email-footer/index.html similarity index 100% rename from print/reports/email-footer/index.html rename to print/report/email-footer/index.html diff --git a/print/reports/email-footer/index.js b/print/report/email-footer/index.js similarity index 100% rename from print/reports/email-footer/index.js rename to print/report/email-footer/index.js diff --git a/print/reports/email-footer/locale.js b/print/report/email-footer/locale.js similarity index 100% rename from print/reports/email-footer/locale.js rename to print/report/email-footer/locale.js diff --git a/print/reports/email-header/assets/css/index.js b/print/report/email-header/assets/css/index.js similarity index 100% rename from print/reports/email-header/assets/css/index.js rename to print/report/email-header/assets/css/index.js diff --git a/print/report/email-header/assets/css/style.css b/print/report/email-header/assets/css/style.css new file mode 100644 index 000000000..957e12f19 --- /dev/null +++ b/print/report/email-header/assets/css/style.css @@ -0,0 +1,7 @@ +header { + color: #555 +} + +header img { + width: 100% +} \ No newline at end of file diff --git a/print/reports/email-header/assets/images/email-logo.png b/print/report/email-header/assets/images/email-logo.png similarity index 100% rename from print/reports/email-header/assets/images/email-logo.png rename to print/report/email-header/assets/images/email-logo.png diff --git a/print/reports/email-header/index.html b/print/report/email-header/index.html similarity index 100% rename from print/reports/email-header/index.html rename to print/report/email-header/index.html diff --git a/print/reports/email-header/index.js b/print/report/email-header/index.js similarity index 100% rename from print/reports/email-header/index.js rename to print/report/email-header/index.js diff --git a/print/reports/email-header/locale.js b/print/report/email-header/locale.js similarity index 100% rename from print/reports/email-header/locale.js rename to print/report/email-header/locale.js diff --git a/print/reports/client-welcome/assets/css/style.css b/print/report/letter-debtor-nd/assets/css/style.css similarity index 100% rename from print/reports/client-welcome/assets/css/style.css rename to print/report/letter-debtor-nd/assets/css/style.css diff --git a/print/reports/letter-debtor-nd/index.html b/print/report/letter-debtor-nd/index.html similarity index 100% rename from print/reports/letter-debtor-nd/index.html rename to print/report/letter-debtor-nd/index.html diff --git a/print/reports/letter-debtor-nd/index.js b/print/report/letter-debtor-nd/index.js similarity index 100% rename from print/reports/letter-debtor-nd/index.js rename to print/report/letter-debtor-nd/index.js diff --git a/print/reports/letter-debtor-nd/locale.js b/print/report/letter-debtor-nd/locale.js similarity index 100% rename from print/reports/letter-debtor-nd/locale.js rename to print/report/letter-debtor-nd/locale.js diff --git a/print/reports/letter-debtor-nd/assets/css/style.css b/print/report/letter-debtor-st/assets/css/style.css similarity index 100% rename from print/reports/letter-debtor-nd/assets/css/style.css rename to print/report/letter-debtor-st/assets/css/style.css diff --git a/print/reports/letter-debtor-st/index.html b/print/report/letter-debtor-st/index.html similarity index 100% rename from print/reports/letter-debtor-st/index.html rename to print/report/letter-debtor-st/index.html diff --git a/print/reports/letter-debtor-st/index.js b/print/report/letter-debtor-st/index.js similarity index 100% rename from print/reports/letter-debtor-st/index.js rename to print/report/letter-debtor-st/index.js diff --git a/print/reports/letter-debtor-st/locale.js b/print/report/letter-debtor-st/locale.js similarity index 100% rename from print/reports/letter-debtor-st/locale.js rename to print/report/letter-debtor-st/locale.js diff --git a/print/report/payment-update/assets/css/index.js b/print/report/payment-update/assets/css/index.js new file mode 100644 index 000000000..c1943eee1 --- /dev/null +++ b/print/report/payment-update/assets/css/index.js @@ -0,0 +1,6 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/report/payment-update/assets/css/style.css b/print/report/payment-update/assets/css/style.css new file mode 100644 index 000000000..f6f42c447 --- /dev/null +++ b/print/report/payment-update/assets/css/style.css @@ -0,0 +1,39 @@ +body { + background-color: #EEE +} + +.container { + max-width: 600px; + min-width: 320px; + margin: 0 auto; + color: #555 +} +.main { + background-color: #FFF; + padding: 20px +} + +.main a { + color: #8dba25 +} + +.main h1 { + color: #999 +} + +.main h3 { + font-size: 16px +} + +.title { + background-color: #95d831; + text-transform: uppercase; + text-align: center; + padding: 35px 0 +} + +.title h1 { + font-size: 32px; + color: #333; + margin: 0 +} \ No newline at end of file diff --git a/print/reports/payment-update/index.html b/print/report/payment-update/index.html similarity index 100% rename from print/reports/payment-update/index.html rename to print/report/payment-update/index.html diff --git a/print/reports/payment-update/index.js b/print/report/payment-update/index.js similarity index 93% rename from print/reports/payment-update/index.js rename to print/report/payment-update/index.js index f6a296298..d5a51d255 100755 --- a/print/reports/payment-update/index.js +++ b/print/report/payment-update/index.js @@ -15,6 +15,8 @@ module.exports = { return this.methods.fetchClientData(params.clientFk) .then(([result]) => { + if (!result) + throw new UserException('No client data found'); return Object.assign(data, result[0]); }); }, diff --git a/print/reports/payment-update/locale.js b/print/report/payment-update/locale.js similarity index 100% rename from print/reports/payment-update/locale.js rename to print/report/payment-update/locale.js diff --git a/print/report/printer-setup/assets/css/index.js b/print/report/printer-setup/assets/css/index.js new file mode 100644 index 000000000..c1943eee1 --- /dev/null +++ b/print/report/printer-setup/assets/css/index.js @@ -0,0 +1,6 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/reports/letter-debtor-st/assets/css/style.css b/print/report/printer-setup/assets/css/style.css similarity index 88% rename from print/reports/letter-debtor-st/assets/css/style.css rename to print/report/printer-setup/assets/css/style.css index 8f5acd032..a197ee5cd 100644 --- a/print/reports/letter-debtor-st/assets/css/style.css +++ b/print/report/printer-setup/assets/css/style.css @@ -3,10 +3,8 @@ body { } .container { - font-family: arial, sans-serif; max-width: 600px; min-width: 320px; - font-size: 16px; margin: 0 auto; color: #555 } diff --git a/print/reports/printer-setup/assets/files/model.ezp b/print/report/printer-setup/assets/files/model.ezp similarity index 100% rename from print/reports/printer-setup/assets/files/model.ezp rename to print/report/printer-setup/assets/files/model.ezp diff --git a/print/reports/printer-setup/index.html b/print/report/printer-setup/index.html similarity index 100% rename from print/reports/printer-setup/index.html rename to print/report/printer-setup/index.html diff --git a/print/reports/printer-setup/index.js b/print/report/printer-setup/index.js similarity index 94% rename from print/reports/printer-setup/index.js rename to print/report/printer-setup/index.js index b15542fe4..5214bbb43 100755 --- a/print/reports/printer-setup/index.js +++ b/print/report/printer-setup/index.js @@ -15,6 +15,8 @@ module.exports = { return this.methods.fetchClientData(params.clientFk) .then(([result]) => { + if (!result) + throw new UserException('No client data found'); return Object.assign(data, result[0]); }); }, diff --git a/print/reports/printer-setup/locale.js b/print/report/printer-setup/locale.js similarity index 100% rename from print/reports/printer-setup/locale.js rename to print/report/printer-setup/locale.js diff --git a/print/reports/report-footer/assets/css/index.js b/print/report/report-footer/assets/css/index.js similarity index 100% rename from print/reports/report-footer/assets/css/index.js rename to print/report/report-footer/assets/css/index.js diff --git a/print/reports/report-footer/assets/css/style.css b/print/report/report-footer/assets/css/style.css similarity index 73% rename from print/reports/report-footer/assets/css/style.css rename to print/report/report-footer/assets/css/style.css index 9e828f879..cb1a69e4c 100644 --- a/print/reports/report-footer/assets/css/style.css +++ b/print/report/report-footer/assets/css/style.css @@ -1,9 +1,6 @@ footer { - font-family: arial, sans-serif; margin-top: 30px; - font-size: 16px; - color: #555; - zoom: 0.55 + color: #555 } footer, footer p { diff --git a/print/reports/report-footer/index.html b/print/report/report-footer/index.html similarity index 100% rename from print/reports/report-footer/index.html rename to print/report/report-footer/index.html diff --git a/print/reports/report-footer/index.js b/print/report/report-footer/index.js similarity index 100% rename from print/reports/report-footer/index.js rename to print/report/report-footer/index.js diff --git a/print/reports/report-footer/locale.js b/print/report/report-footer/locale.js similarity index 100% rename from print/reports/report-footer/locale.js rename to print/report/report-footer/locale.js diff --git a/print/reports/report-header/assets/css/index.js b/print/report/report-header/assets/css/index.js similarity index 100% rename from print/reports/report-header/assets/css/index.js rename to print/report/report-header/assets/css/index.js diff --git a/print/reports/report-header/assets/css/style.css b/print/report/report-header/assets/css/style.css similarity index 100% rename from print/reports/report-header/assets/css/style.css rename to print/report/report-header/assets/css/style.css diff --git a/print/reports/report-header/assets/images/report-logo.png b/print/report/report-header/assets/images/report-logo.png similarity index 100% rename from print/reports/report-header/assets/images/report-logo.png rename to print/report/report-header/assets/images/report-logo.png diff --git a/print/reports/report-header/assets/images/report-logo.svg b/print/report/report-header/assets/images/report-logo.svg similarity index 100% rename from print/reports/report-header/assets/images/report-logo.svg rename to print/report/report-header/assets/images/report-logo.svg diff --git a/print/reports/report-header/index.html b/print/report/report-header/index.html similarity index 100% rename from print/reports/report-header/index.html rename to print/report/report-header/index.html diff --git a/print/reports/report-header/index.js b/print/report/report-header/index.js similarity index 100% rename from print/reports/report-header/index.js rename to print/report/report-header/index.js diff --git a/print/reports/report-header/locale.js b/print/report/report-header/locale.js similarity index 100% rename from print/reports/report-header/locale.js rename to print/report/report-header/locale.js diff --git a/print/report/rpt-claim-pickup-order/assets/css/index.js b/print/report/rpt-claim-pickup-order/assets/css/index.js new file mode 100644 index 000000000..c1943eee1 --- /dev/null +++ b/print/report/rpt-claim-pickup-order/assets/css/index.js @@ -0,0 +1,6 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/report/rpt-claim-pickup-order/assets/css/style.css b/print/report/rpt-claim-pickup-order/assets/css/style.css new file mode 100644 index 000000000..35505aeea --- /dev/null +++ b/print/report/rpt-claim-pickup-order/assets/css/style.css @@ -0,0 +1,3 @@ +.container { + color: #000 +} \ No newline at end of file diff --git a/print/reports/claim-pickup/index.html b/print/report/rpt-claim-pickup-order/index.html similarity index 98% rename from print/reports/claim-pickup/index.html rename to print/report/rpt-claim-pickup-order/index.html index 08964ad6e..d73284a45 100644 --- a/print/reports/claim-pickup/index.html +++ b/print/report/rpt-claim-pickup-order/index.html @@ -7,7 +7,7 @@ - {{$t('title')}} + {{$t('title')}} {{$t('claimId')}}: {{claimId}} diff --git a/print/reports/claim-pickup/index.js b/print/report/rpt-claim-pickup-order/index.js similarity index 94% rename from print/reports/claim-pickup/index.js rename to print/report/rpt-claim-pickup-order/index.js index e8b9ce5a5..686a40cd3 100755 --- a/print/reports/claim-pickup/index.js +++ b/print/report/rpt-claim-pickup-order/index.js @@ -3,7 +3,7 @@ const database = require(`${appPath}/lib/database`); const UserException = require(`${appPath}/lib/exceptions/userException`); module.exports = { - name: 'claim-pickup', + name: 'rpt-claim-pickup-order', async asyncData(ctx, params) { const promises = []; const data = {}; @@ -18,6 +18,9 @@ module.exports = { const [[claim]] = result[0]; const [sales] = result[1]; + if (!claim) + throw new UserException('No claim data found'); + Object.assign(data, claim, {sales}); return data; diff --git a/print/reports/claim-pickup/locale.js b/print/report/rpt-claim-pickup-order/locale.js similarity index 100% rename from print/reports/claim-pickup/locale.js rename to print/report/rpt-claim-pickup-order/locale.js diff --git a/print/reports/claim-pickup/assets/css/style.css b/print/reports/claim-pickup/assets/css/style.css deleted file mode 100644 index ecc403ec0..000000000 --- a/print/reports/claim-pickup/assets/css/style.css +++ /dev/null @@ -1,6 +0,0 @@ -.container { - font-family: arial, sans-serif; - font-size: 16px; - color: #555; - zoom: 0.55 -} \ No newline at end of file diff --git a/print/reports/client-welcome/assets/css/test.css b/print/reports/client-welcome/assets/css/test.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/print/reports/email-header/assets/css/style.css b/print/reports/email-header/assets/css/style.css deleted file mode 100644 index 73dfb8abc..000000000 --- a/print/reports/email-header/assets/css/style.css +++ /dev/null @@ -1,12 +0,0 @@ -header { - font-family: arial, sans-serif; - max-width: 600px; - min-width: 320px; - font-size: 16px; - margin: 0 auto; - color: #555 -} - -header img { - width: 100% -} \ No newline at end of file
{{$t('description.dear')}},
{{$t('description.instructions')}}