Commit 772ec922f8a5469c7cbef116312ea9f40f689a0f

Authored by Jose Pinto
1 parent aa638f1d70
Exists in master and in 1 other branch develop

codigo transportista con ceros

src/js/controller.js
1 angular.module('focaAbmVehiculo') 1 angular.module('focaAbmVehiculo')
2 .controller('focaAbmVehiculosController', [ 2 .controller('focaAbmVehiculosController', [
3 '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', 3 '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService',
4 '$uibModal', 'focaBotoneraLateralService', '$timeout', 4 '$uibModal', 'focaBotoneraLateralService', '$timeout',
5 function($scope, focaAbmVehiculoService, $location, focaModalService, 5 function($scope, focaAbmVehiculoService, $location, focaModalService,
6 $uibModal, focaBotoneraLateralService, $timeout) { 6 $uibModal, focaBotoneraLateralService, $timeout) {
7 7
8 $scope.now = new Date(); 8 $scope.now = new Date();
9 $scope.botonera = ['Transportista']; 9 $scope.botonera = ['Transportista'];
10 10
11 //SETEO BOTONERA LATERAL 11 //SETEO BOTONERA LATERAL
12 focaBotoneraLateralService.showSalir(true); 12 focaBotoneraLateralService.showSalir(true);
13 focaBotoneraLateralService.showPausar(false); 13 focaBotoneraLateralService.showPausar(false);
14 focaBotoneraLateralService.showCancelar(false); 14 focaBotoneraLateralService.showCancelar(false);
15 focaBotoneraLateralService.showGuardar(false); 15 focaBotoneraLateralService.showGuardar(false);
16 16
17 if(focaAbmVehiculoService.transportistaSeleccionado.COD) { 17 if(focaAbmVehiculoService.transportistaSeleccionado.COD) {
18 elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado); 18 elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado);
19 } 19 }
20 20
21 $scope.editar = function(id) { 21 $scope.editar = function(id) {
22 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); 22 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista);
23 }; 23 };
24 $scope.solicitarConfirmacion = function(vehiculo) { 24 $scope.solicitarConfirmacion = function(vehiculo) {
25 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + 25 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
26 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( 26 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
27 function(data) { 27 function(data) {
28 if(data) { 28 if(data) {
29 focaAbmVehiculoService.deleteVehiculo(vehiculo.id); 29 focaAbmVehiculoService.deleteVehiculo(vehiculo.id);
30 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); 30 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
31 } 31 }
32 } 32 }
33 ); 33 );
34 }; 34 };
35 $scope.seleccionarTransportista = function() { 35 $scope.seleccionarTransportista = function() {
36 var modalInstance = $uibModal.open( 36 var modalInstance = $uibModal.open(
37 { 37 {
38 ariaLabelledBy: 'Busqueda de Transportista', 38 ariaLabelledBy: 'Busqueda de Transportista',
39 templateUrl: 'modal-proveedor.html', 39 templateUrl: 'modal-proveedor.html',
40 controller: 'focaModalProveedorCtrl', 40 controller: 'focaModalProveedorCtrl',
41 size: 'lg', 41 size: 'lg',
42 resolve: { 42 resolve: {
43 transportista: function() { 43 transportista: function() {
44 return true; 44 return true;
45 } 45 }
46 } 46 }
47 } 47 }
48 ); 48 );
49 modalInstance.result.then( 49 modalInstance.result.then(
50 function(transportista) { 50 function(transportista) {
51 elegirTransportista(transportista); 51 elegirTransportista(transportista);
52 focaAbmVehiculoService.transportistaSeleccionado = transportista; 52 focaAbmVehiculoService.transportistaSeleccionado = transportista;
53 }, function() { 53 }, function() {
54 54
55 } 55 }
56 ); 56 );
57 }; 57 };
58 58
59 function elegirTransportista(transportista) { 59 function elegirTransportista(transportista) {
60 var codigo = ('00000' + transportista.COD).slice(-5);
60 $scope.idTransportista = transportista.COD; 61 $scope.idTransportista = transportista.COD;
61 $scope.filtros = transportista.NOM.trim(); 62 $scope.filtros = transportista.NOM.trim();
62 $timeout(function() { 63 $timeout(function() {
63 $scope.$broadcast('addCabecera', { 64 $scope.$broadcast('addCabecera', {
64 label: 'Transportista:', 65 label: 'Transportista:',
65 valor: transportista.COD + ' - ' + transportista.NOM 66 valor: codigo + ' - ' + transportista.NOM
66 }); 67 });
67 }); 68 });
68 buscar(transportista.COD); 69 buscar(transportista.COD);
69 } 70 }
70 71
71 function buscar(idTransportista) { 72 function buscar(idTransportista) {
72 focaAbmVehiculoService 73 focaAbmVehiculoService
73 .getVehiculosPorTransportista(idTransportista) 74 .getVehiculosPorTransportista(idTransportista)
74 .then(function(datos) { 75 .then(function(datos) {
75 $scope.vehiculos = datos.data; 76 $scope.vehiculos = datos.data;
76 }); 77 });
77 } 78 }
78 } 79 }
79 ]) 80 ])
80 .controller('focaAbmVehiculoController', [ 81 .controller('focaAbmVehiculoController', [
81 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', 82 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
82 'focaModalService', '$timeout', 'focaBotoneraLateralService', 83 'focaModalService', '$timeout', 'focaBotoneraLateralService',
83 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, 84 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
84 focaModalService, $timeout, focaBotoneraLateralService) { 85 focaModalService, $timeout, focaBotoneraLateralService) {
85 $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false; 86 $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false;
86 $scope.now = new Date(); 87 $scope.now = new Date();
87 $scope.focused = 1; 88 $scope.focused = 1;
88 89
89 $timeout(function() { 90 $timeout(function() {
90 focaBotoneraLateralService.showSalir(false); 91 focaBotoneraLateralService.showSalir(false);
91 focaBotoneraLateralService.showPausar(false); 92 focaBotoneraLateralService.showPausar(false);
92 focaBotoneraLateralService.showCancelar(true); 93 focaBotoneraLateralService.showCancelar(true);
93 focaBotoneraLateralService.showGuardar(true, $scope.guardar); 94 focaBotoneraLateralService.showGuardar(true, $scope.guardar);
94 }); 95 });
95 96
96 if($scope.nuevo) { 97 if($scope.nuevo) {
97 focaAbmVehiculoService 98 focaAbmVehiculoService
98 .getTransportistaPorId($routeParams.idTransportista) 99 .getTransportistaPorId($routeParams.idTransportista)
99 .then(function(res) { 100 .then(function(res) {
101 var codigo = ('00000' + res.data.COD).slice(-5);
100 $scope.vehiculo.idTransportista = res.data.COD; 102 $scope.vehiculo.idTransportista = res.data.COD;
101 $scope.vehiculo.transportista = res.data; 103 $scope.vehiculo.transportista = res.data;
102 $scope.$broadcast('addCabecera', { 104 $scope.$broadcast('addCabecera', {
103 label: 'Transportista:', 105 label: 'Transportista:',
104 valor: res.data.COD + ' - ' + res.data.NOM 106 valor: codigo + ' - ' + res.data.NOM
105 }); 107 });
106 }); 108 });
107 } 109 }
108 $scope.vehiculo = {}; 110 $scope.vehiculo = {};
109 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { 111 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
110 if(res.data) { 112 if(res.data) {
113 var codigo = ('00000' + res.data.transportista.COD).slice(-5);
111 $scope.vehiculo = res.data; 114 $scope.vehiculo = res.data;
112 $scope.$broadcast('addCabecera', { 115 $scope.$broadcast('addCabecera', {
113 label: 'Transportista:', 116 label: 'Transportista:',
114 valor: res.data.transportista.COD + ' - ' + res.data.transportista.NOM 117 valor: codigo + ' - ' + res.data.transportista.NOM
115 }); 118 });
116 $scope.$broadcast('addCabecera', { 119 $scope.$broadcast('addCabecera', {
117 label: 'Unidad:', 120 label: 'Unidad:',
118 valor: res.data.codigo 121 valor: res.data.codigo
119 }); 122 });
120 } 123 }
121 }); 124 });
122 focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) 125 focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo)
123 .then(function(res) { 126 .then(function(res) {
124 $scope.cisternas = res.data; 127 $scope.cisternas = res.data;
125 }); 128 });
126 $scope.next = function(key) { 129 $scope.next = function(key) {
127 if (key === 13) $scope.focused++; 130 if (key === 13) $scope.focused++;
128 }; 131 };
129 $scope.cancelar = function() { 132 $scope.cancelar = function() {
130 $location.path('/vehiculo'); 133 $location.path('/vehiculo');
131 }; 134 };
132 $scope.editar = function(id) { 135 $scope.editar = function(id) {
133 $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); 136 $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id);
134 }; 137 };
135 $scope.guardar = function() { 138 $scope.guardar = function() {
136 if(!$scope.vehiculo.transportista) { 139 if(!$scope.vehiculo.transportista) {
137 focaModalService.alert('Elija Transportista'); 140 focaModalService.alert('Elija Transportista');
138 return; 141 return;
139 } 142 }
140 delete $scope.vehiculo.transportista; 143 delete $scope.vehiculo.transportista;
141 focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { 144 focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) {
142 if($scope.nuevo) { 145 if($scope.nuevo) {
143 $location.path('/vehiculo/' + res.data.id + '/' + res.data.idTransportista); 146 $location.path('/vehiculo/' + res.data.id + '/' + res.data.idTransportista);
144 } else { 147 } else {
145 $location.path('/vehiculo'); 148 $location.path('/vehiculo');
146 } 149 }
147 }); 150 });
148 }; 151 };
149 $scope.solicitarConfirmacionCisterna = function(cisterna) { 152 $scope.solicitarConfirmacionCisterna = function(cisterna) {
150 focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + 153 focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' +
151 cisterna.id + ' ' + cisterna.codigo + ' ?').then( 154 cisterna.id + ' ' + cisterna.codigo + ' ?').then(
152 function(data) { 155 function(data) {
153 if(data) { 156 if(data) {
154 focaAbmVehiculoService.deleteCisterna(cisterna.id); 157 focaAbmVehiculoService.deleteCisterna(cisterna.id);
155 $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); 158 $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1);
156 } 159 }
157 } 160 }
158 ); 161 );
159 }; 162 };
160 $scope.seleccionarTransportista = function() { 163 $scope.seleccionarTransportista = function() {
161 var modalInstance = $uibModal.open( 164 var modalInstance = $uibModal.open(
162 { 165 {
163 ariaLabelledBy: 'Busqueda de Transportista', 166 ariaLabelledBy: 'Busqueda de Transportista',
164 templateUrl: 'modal-proveedor.html', 167 templateUrl: 'modal-proveedor.html',
165 controller: 'focaModalProveedorCtrl', 168 controller: 'focaModalProveedorCtrl',
166 size: 'lg', 169 size: 'lg',
167 resolve: { 170 resolve: {
168 transportista: function() { 171 transportista: function() {
169 return true; 172 return true;
170 } 173 }
171 } 174 }
172 } 175 }
173 ); 176 );
174 modalInstance.result.then( 177 modalInstance.result.then(
175 function(transportista) { 178 function(transportista) {
176 $scope.vehiculo.idTransportista = transportista.COD; 179 $scope.vehiculo.idTransportista = transportista.COD;
177 $scope.vehiculo.transportista = transportista; 180 $scope.vehiculo.transportista = transportista;
178 }, function() { 181 }, function() {
179 182
180 } 183 }
181 ); 184 );
182 }; 185 };
183 } 186 }
184 ]); 187 ]);
185 188
src/js/controllerCisterna.js
1 angular.module('focaAbmVehiculo') 1 angular.module('focaAbmVehiculo')
2 .controller('focaAbmVehiculoCisternaController', [ 2 .controller('focaAbmVehiculoCisternaController', [
3 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', 3 '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
4 'focaModalService', 'focaBotoneraLateralService', '$timeout', 4 'focaModalService', 'focaBotoneraLateralService', '$timeout',
5 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, 5 function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
6 focaModalService, focaBotoneraLateralService, $timeout) { 6 focaModalService, focaBotoneraLateralService, $timeout) {
7 $scope.editar = false; 7 $scope.editar = false;
8 $scope.now = new Date(); 8 $scope.now = new Date();
9 $scope.cisterna = { 9 $scope.cisterna = {
10 cisternaCarga: { 10 cisternaCarga: {
11 articulo: {} 11 articulo: {}
12 } 12 }
13 }; 13 };
14 14
15 $scope.focused = 1; 15 $scope.focused = 1;
16 $scope.next = function(key) { 16 $scope.next = function(key) {
17 if (key === 13) $scope.focused++; 17 if (key === 13) $scope.focused++;
18 }; 18 };
19 19
20 //SETEO BOTONERA LATERAL 20 //SETEO BOTONERA LATERAL
21 $timeout(function() { 21 $timeout(function() {
22 focaBotoneraLateralService.showSalir(false); 22 focaBotoneraLateralService.showSalir(false);
23 focaBotoneraLateralService.showPausar(false); 23 focaBotoneraLateralService.showPausar(false);
24 focaBotoneraLateralService.showCancelar(true); 24 focaBotoneraLateralService.showCancelar(true);
25 focaBotoneraLateralService.showGuardar(true, $scope.guardar); 25 focaBotoneraLateralService.showGuardar(true, $scope.guardar);
26 }); 26 });
27 27
28 focaAbmVehiculoService.getCisterna($routeParams.id).then(function(res) { 28 focaAbmVehiculoService.getCisterna($routeParams.id).then(function(res) {
29 if(res.data) { 29 if(res.data) {
30 $scope.cisterna = res.data; 30 $scope.cisterna = res.data;
31 $scope.editar = true; 31 $scope.editar = true;
32 }else { 32 }else {
33 $scope.editar = false; 33 $scope.editar = false;
34 } 34 }
35 }); 35 });
36 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { 36 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
37 var codigo = ('00000' + res.data.transportista.COD).slice(-5);
37 $scope.$broadcast('addCabecera', { 38 $scope.$broadcast('addCabecera', {
38 label: 'Transportista:', 39 label: 'Transportista:',
39 valor: res.data.transportista.COD + ' - ' + res.data.transportista.NOM 40 valor: codigo + ' - ' + res.data.transportista.NOM
40 }); 41 });
41 $scope.$broadcast('addCabecera', { 42 $scope.$broadcast('addCabecera', {
42 label: 'Unidad:', 43 label: 'Unidad:',
43 valor: res.data.codigo 44 valor: res.data.codigo
44 }); 45 });
45 }); 46 });
46 $scope.cancelar = function() { 47 $scope.cancelar = function() {
47 $location.path('/vehiculo/' + $routeParams.idVehiculo); 48 $location.path('/vehiculo/' + $routeParams.idVehiculo);
48 }; 49 };
49 $scope.guardar = function() { 50 $scope.guardar = function() {
50 if(!$scope.cisterna.unidadMedida) { 51 if(!$scope.cisterna.unidadMedida) {
51 focaModalService.alert('Ingrese unidad de medida'); 52 focaModalService.alert('Ingrese unidad de medida');
52 return; 53 return;
53 } 54 }
54 if(!$scope.cisterna.cisternaCarga.articulo) { 55 if(!$scope.cisterna.cisternaCarga.articulo) {
55 focaModalService.alert('Ingrese producto'); 56 focaModalService.alert('Ingrese producto');
56 return; 57 return;
57 } 58 }
58 $scope.cisterna.idVehiculo = $routeParams.idVehiculo; 59 $scope.cisterna.idVehiculo = $routeParams.idVehiculo;
59 delete $scope.cisterna.unidadMedida; 60 delete $scope.cisterna.unidadMedida;
60 delete $scope.cisterna.cisternaCarga.articulo; 61 delete $scope.cisterna.cisternaCarga.articulo;
61 focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function() { 62 focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function() {
62 $location.path('/vehiculo/' + $routeParams.idVehiculo); 63 $location.path('/vehiculo/' + $routeParams.idVehiculo);
63 }); 64 });
64 }; 65 };
65 66
66 // $scope.seleccionarArticulo = function() { 67 // $scope.seleccionarArticulo = function() {
67 // var modalInstance = $uibModal.open( 68 // var modalInstance = $uibModal.open(
68 // { 69 // {
69 // ariaLabelledBy: 'Busqueda de Productos', 70 // ariaLabelledBy: 'Busqueda de Productos',
70 // templateUrl: 'modal-busqueda-productos.html', 71 // templateUrl: 'modal-busqueda-productos.html',
71 // controller: 'modalBusquedaProductosCtrl', 72 // controller: 'modalBusquedaProductosCtrl',
72 // resolve: { 73 // resolve: {
73 // parametroProducto: { 74 // parametroProducto: {
74 // idLista: -1, 75 // idLista: -1,
75 // cotizacion: 1, 76 // cotizacion: 1,
76 // simbolo: '$' 77 // simbolo: '$'
77 // } 78 // }
78 // }, 79 // },
79 // size: 'lg' 80 // size: 'lg'
80 // } 81 // }
81 // ); 82 // );
82 // modalInstance.result.then( 83 // modalInstance.result.then(
83 // function(producto) { 84 // function(producto) {
84 // $scope.cisterna.cisternaCarga.idProducto = producto.id, 85 // $scope.cisterna.cisternaCarga.idProducto = producto.id,
85 // $scope.cisterna.cisternaCarga.articulo.DetArt = producto.descripcion; 86 // $scope.cisterna.cisternaCarga.articulo.DetArt = producto.descripcion;
86 // }, function() { 87 // }, function() {
87 // // funcion ejecutada cuando se cancela el modal 88 // // funcion ejecutada cuando se cancela el modal
88 // } 89 // }
89 // ); 90 // );
90 // }; 91 // };
91 92
92 $scope.seleccionarUnidadMedida = function() { 93 $scope.seleccionarUnidadMedida = function() {
93 var modalInstance = $uibModal.open( 94 var modalInstance = $uibModal.open(
94 { 95 {
95 ariaLabelledBy: 'Busqueda de Unidades de medida', 96 ariaLabelledBy: 'Busqueda de Unidades de medida',
96 templateUrl: 'modal-unidad-medida.html', 97 templateUrl: 'modal-unidad-medida.html',
97 controller: 'focaModalUnidadMedidaCtrl', 98 controller: 'focaModalUnidadMedidaCtrl',
98 size: 'lg' 99 size: 'lg'
99 } 100 }
100 ); 101 );
101 modalInstance.result.then(function(unidaMedida) { 102 modalInstance.result.then(function(unidaMedida) {
102 $scope.cisterna.idUnidadMedida = unidaMedida.ID; 103 $scope.cisterna.idUnidadMedida = unidaMedida.ID;
103 $scope.cisterna.unidadMedida = unidaMedida; 104 $scope.cisterna.unidadMedida = unidaMedida;
104 }); 105 });
105 }; 106 };
106 } 107 }
107 ]); 108 ]);
108 109