Commit af999a9fec940ae24086a738feb93887313af597

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

See merge request !17
1 { 1 {
2 "name": "foca-hoja-ruta", 2 "name": "foca-hoja-ruta",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "foca-hoja-ruta", 4 "description": "foca-hoja-ruta",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "refresh" : "gulp uglify && cp tmp/foca-hoja-ruta.js ../wrapper-demo/node_modules/foca-hoja-ruta/dist/foca-hoja-ruta.min.js",
7 "test": "echo \"Error: no test specified\" && exit 1", 8 "test": "echo \"Error: no test specified\" && exit 1",
8 "compile": "gulp uglify", 9 "compile": "gulp uglify",
9 "gulp-pre-commit": "gulp pre-commit", 10 "gulp-pre-commit": "gulp pre-commit",
10 "postinstall": "npm run compile && gulp clean-post-install", 11 "postinstall": "npm run compile && gulp clean-post-install",
11 "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-remito.git" 12 "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-remito.git"
12 }, 13 },
13 "pre-commit": [ 14 "pre-commit": [
14 "gulp-pre-commit" 15 "gulp-pre-commit"
15 ], 16 ],
16 "repository": { 17 "repository": {
17 "type": "git", 18 "type": "git",
18 "url": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git" 19 "url": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git"
19 }, 20 },
20 "author": "Foca Software", 21 "author": "Foca Software",
21 "license": "ISC", 22 "license": "ISC",
22 "devDependencies": { 23 "devDependencies": {
23 "angular": "^1.7.5", 24 "angular": "^1.7.5",
24 "angular-ladda": "^0.4.3", 25 "angular-ladda": "^0.4.3",
25 "angular-route": "^1.7.5", 26 "angular-route": "^1.7.5",
26 "bootstrap": "^4.1.3", 27 "bootstrap": "^4.1.3",
27 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", 28 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
28 "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", 29 "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git",
29 "font-awesome": "^4.7.0", 30 "font-awesome": "^4.7.0",
30 "gulp": "^3.9.1", 31 "gulp": "^3.9.1",
31 "gulp-angular-templatecache": "^2.2.5", 32 "gulp-angular-templatecache": "^2.2.5",
32 "gulp-clean": "^0.4.0", 33 "gulp-clean": "^0.4.0",
33 "gulp-concat": "^2.6.1", 34 "gulp-concat": "^2.6.1",
34 "gulp-connect": "^5.6.1", 35 "gulp-connect": "^5.6.1",
35 "gulp-htmlmin": "^5.0.1", 36 "gulp-htmlmin": "^5.0.1",
36 "gulp-jshint": "^2.1.0", 37 "gulp-jshint": "^2.1.0",
37 "gulp-rename": "^1.4.0", 38 "gulp-rename": "^1.4.0",
38 "gulp-replace": "^1.0.0", 39 "gulp-replace": "^1.0.0",
39 "gulp-sequence": "^1.0.0", 40 "gulp-sequence": "^1.0.0",
40 "gulp-uglify": "^3.0.1", 41 "gulp-uglify": "^3.0.1",
41 "gulp-uglify-es": "^1.0.4", 42 "gulp-uglify-es": "^1.0.4",
42 "jasmine-core": "^3.3.0", 43 "jasmine-core": "^3.3.0",
43 "jquery": "^3.3.1", 44 "jquery": "^3.3.1",
44 "jshint": "^2.9.6", 45 "jshint": "^2.9.6",
45 "ladda": "^1.0.6", 46 "ladda": "^1.0.6",
46 "pre-commit": "^1.2.2", 47 "pre-commit": "^1.2.2",
47 "pump": "^3.0.0", 48 "pump": "^3.0.0",
48 "ui-bootstrap4": "^3.0.5" 49 "ui-bootstrap4": "^3.0.5"
49 } 50 }
50 } 51 }
51 52
src/js/controller.js
1 angular.module('focaHojaRuta') 1 angular.module('focaHojaRuta')
2 .controller('listaHojaRutaCtrl', 2 .controller('listaHojaRutaCtrl',
3 [ 3 [
4 '$scope', 4 '$scope',
5 '$location', 5 '$location',
6 '$filter', 6 '$filter',
7 '$uibModal', 7 '$uibModal',
8 'hojaRutaService', 8 'hojaRutaService',
9 'focaLoginService', 9 'focaLoginService',
10 'focaModalService', 10 'focaModalService',
11 '$rootScope', 11 '$rootScope',
12 '$localStorage', 12 '$localStorage',
13 function( 13 function (
14 $scope, 14 $scope,
15 $location, 15 $location,
16 $filter, 16 $filter,
17 $uibModal, 17 $uibModal,
18 hojaRutaService, 18 hojaRutaService,
19 focaLoginService, 19 focaLoginService,
20 focaModalService, 20 focaModalService,
21 $rootScope, 21 $rootScope,
22 $localStorage 22 $localStorage
23 ) { 23 ) {
24 24
25 var loginData = focaLoginService.getLoginData(); 25 var loginData = focaLoginService.getLoginData();
26 26
27 config(); 27 config();
28 28
29 function config() { 29 function config() {
30 30
31 $scope.cabecera = []; 31 $scope.cabecera = [];
32 $scope.showCabecera = true; 32 $scope.showCabecera = true;
33 $scope.now = new Date(); 33 $scope.now = new Date();
34 $scope.puntoVenta = '0000'; 34 $scope.puntoVenta = '0000';
35 $scope.comprobante = '00000000'; 35 $scope.comprobante = '00000000';
36 } 36 }
37 37
38 hojaRutaService.getHojaRuta(loginData.chofer).then(function(res) { 38 hojaRutaService.getHojaRuta(loginData.chofer).then(function (res) {
39 39
40 if (res.data) { 40 if (res.data) {
41 var hojaRuta = res.data; 41 var hojaRuta = res.data;
42 $scope.hojaRuta = hojaRuta; 42 $scope.hojaRuta = hojaRuta;
43 $scope.hojaRuta.abierta = true;
44 $scope.puntoVenta = hojaRuta.sucursal; 43 $scope.puntoVenta = hojaRuta.sucursal;
45 $scope.comprobante = hojaRuta.numeroHojaRuta; 44 $scope.comprobante = hojaRuta.numeroHojaRuta;
46 addCabecera('Transportista:', hojaRuta.transportista.NOM); 45 addCabecera('Transportista:', hojaRuta.transportista.NOM);
47 addCabecera('Chofer:', hojaRuta.chofer.nombre); 46 addCabecera('Chofer:', hojaRuta.chofer.nombre);
48 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); 47 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor);
49 } else { 48 } else {
50 focaModalService.alert('Sin hoja de ruta asignada'); 49 focaModalService.alert('Sin hoja de ruta asignada');
51 $location.path('/'); 50 $location.path('/');
52 } 51 }
53 52
54 watch(); 53 watch();
55 54
56 if (!$scope.esatadoRed) { 55 if (!$scope.esatadoRed) {
57 getLSHojaRuta(); 56 getLSHojaRuta();
58 } 57 }
59 58
60 }); 59 });
61 60
62 function watch() { 61 function watch() {
63 62
64 $scope.$watch('hojaRuta', function(nuevoValor) { 63 $scope.$watch('hojaRuta', function (nuevoValor) {
65 $localStorage.hojaRuta = JSON.stringify(nuevoValor); 64 $localStorage.hojaRuta = JSON.stringify(nuevoValor);
66 }, true); 65 }, true);
67 } 66 }
68 67
69 $scope.verDetalle = function(remito) { 68 $scope.verDetalle = function (remito) {
70 var modalInstance = $uibModal.open( 69 var modalInstance = $uibModal.open(
71 { 70 {
72 ariaLabelledBy: 'Detalle hoja ruta', 71 ariaLabelledBy: 'Detalle hoja ruta',
73 templateUrl: 'modal-detalle-hoja-ruta.html', 72 templateUrl: 'modal-detalle-hoja-ruta.html',
74 controller: 'focaModalDetalleHojaRutaController', 73 controller: 'focaModalDetalleHojaRutaController',
75 resolve: { 74 resolve: {
76 parametros: { 75 parametros: {
77 remito: remito, 76 remito: remito,
78 } 77 }
79 }, 78 },
80 size: 'lg' 79 size: 'lg'
81 } 80 }
82 ); 81 );
83 modalInstance.result.then(function() { 82 modalInstance.result.then(function () {
84 //funcion se ejecuta cuando se carga pantalla 83 //funcion se ejecuta cuando se carga pantalla
85 }); 84 });
86 }; 85 };
87 86
88 function addCabecera(label, valor) { 87 function addCabecera(label, valor) {
89 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 88 var propiedad = $filter('filter')($scope.cabecera, { label: label }, true);
90 if(propiedad.length === 1) { 89 if (propiedad.length === 1) {
91 propiedad[0].valor = valor; 90 propiedad[0].valor = valor;
92 } else { 91 } else {
93 $scope.cabecera.push({label: label, valor: valor}); 92 $scope.cabecera.push({ label: label, valor: valor });
94 } 93 }
95 } 94 }
96 95
97 $scope.rellenar = function(relleno, longitud) { 96 $scope.rellenar = function (relleno, longitud) {
98 relleno = '' + relleno; 97 relleno = '' + relleno;
99 while (relleno.length < longitud) { 98 while (relleno.length < longitud) {
100 relleno = '0' + relleno; 99 relleno = '0' + relleno;
101 } 100 }
102 101
103 return relleno; 102 return relleno;
104 }; 103 };
105 104
106 $scope.salir = function() { 105 $scope.salir = function () {
107 $location.path('/'); 106 $location.path('/');
108 }; 107 };
109 108
110 $scope.terminarHojaRuta = function() { 109 $scope.terminarHojaRuta = function () {
111 focaModalService 110 focaModalService
112 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + 111 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' +
113 'otra descarga ni modificación') 112 'otra descarga ni modificación')
114 .then(function() {$scope.datosExtraCierre(terminar);}); 113 .then(function () { $scope.datosExtraCierre(terminar); });
115 function terminar(datosExtraCierre) { 114 function terminar(datosExtraCierre) {
116 $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre); 115 $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre);
117 //limpio objeto para guardar 116 //limpio objeto para guardar
118 delete $scope.hojaRuta.chofer; 117 delete $scope.hojaRuta.chofer;
119 delete $scope.hojaRuta.remitos; 118 delete $scope.hojaRuta.remitos;
120 delete $scope.hojaRuta.transportista; 119 delete $scope.hojaRuta.transportista;
121 delete $scope.hojaRuta.vehiculo; 120 delete $scope.hojaRuta.vehiculo;
122 121
123 $scope.hojaRuta.fechaCreacion = 122 $scope.hojaRuta.fechaCreacion =
124 $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' '); 123 $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' ');
125 $scope.hojaRuta.fechaReparto = 124 $scope.hojaRuta.fechaReparto =
126 $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' '); 125 $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' ');
127 $scope.hojaRuta.estado = 2; 126 $scope.hojaRuta.estado = 2;
128 hojaRutaService.terminarHojaRuta($scope.hojaRuta).then( 127 hojaRutaService.terminarHojaRuta($scope.hojaRuta).then(
129 function() { 128 function () {
130 focaModalService.alert( 129 focaModalService.alert(
131 'Hoja de ruta ' + 130 'Hoja de ruta ' +
132 $filter('comprobante')([$scope.puntoVenta, 131 $filter('comprobante')([$scope.puntoVenta,
133 $scope.comprobante]) + ' cerrada con éxito'); 132 $scope.comprobante]) + ' cerrada con éxito');
134 $location.path('/'); 133 $location.path('/');
135 } 134 }
136 ); 135 );
137 } 136 }
138 }; 137 };
139 138
140 $scope.datosExtraCierre = function(terminar) { 139 $scope.datosExtraCierre = function (terminar) {
141 var modalInstance = $uibModal.open( 140 var modalInstance = $uibModal.open(
142 { 141 {
143 templateUrl: 'focaDatosExtra.html', 142 templateUrl: 'focaDatosExtra.html',
144 controller: 'focaModalDatosExtraCierre', 143 controller: 'focaModalDatosExtraCierre',
145 } 144 }
146 ); 145 );
147 modalInstance.result.then(terminar); 146 modalInstance.result.then(terminar);
148 }; 147 };
149 148
150 $scope.modalDescargas = function() { 149 $scope.modalDescargas = function () {
151 150 delete $scope.hojaRuta.remitos[0].cliente;
152 var modalInstance = $uibModal.open( 151 var modalInstance = $uibModal.open(
153 { 152 {
154 templateUrl: 'foca-modal-descarga.html', 153 templateUrl: 'foca-modal-descarga.html',
155 controller: 'focaModalDescargaCtrl' 154 controller: 'focaModalDescargaCtrl',
155 resolve: {
156 remito: function () { return $scope.hojaRuta.remitos[0]; }
157 },
156 } 158 }
157 ); 159 );
158 160
159 modalInstance.result.then(function(data) { 161 modalInstance.result.then(function (data) {
160 162
161 console.log(data); 163 console.log(data);
162 }); 164 });
163 }; 165 };
164 166
165 $rootScope.$on('estadoRed', function(event, value) { 167 $rootScope.$on('estadoRed', function (event, value) {
166 $scope.esatadoRed = value; 168 $scope.esatadoRed = value;
167 }); 169 });
168 170
169 function getLSHojaRuta() { 171 function getLSHojaRuta() {
170 172
171 var hojaRuta = JSON.parse($localStorage.hojaRuta || null); 173 var hojaRuta = JSON.parse($localStorage.hojaRuta || null);
172 174
173 if (hojaRuta) { 175 if (hojaRuta) {
174 $scope.hojaRuta = hojaRuta; 176 $scope.hojaRuta = hojaRuta;
175 delete $localStorage.hojaRuta; 177 delete $localStorage.hojaRuta;
176 } 178 }
177 } 179 }
178 180
179 } 181 }
180 ]); 182 ]);