Commit 80c514dc5f76219678e5301147553808417ca64f

Authored by Jose Pinto
1 parent 38f8916430
Exists in master

titulo en minuscula, funcion correcta

src/js/controller.js
1 angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', 1 angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
2 [ 2 [
3 '$scope', 3 '$scope',
4 '$uibModal', 4 '$uibModal',
5 '$location', 5 '$location',
6 '$filter', 6 '$filter',
7 '$timeout', 7 '$timeout',
8 'crearHojaRutaService', 8 'crearHojaRutaService',
9 'focaModalService', 9 'focaModalService',
10 'focaBotoneraLateralService', 10 'focaBotoneraLateralService',
11 function($scope, $uibModal, $location, $filter, $timeout, 11 function($scope, $uibModal, $location, $filter, $timeout,
12 crearHojaRutaService, focaModalService, focaBotoneraLateralService) { 12 crearHojaRutaService, focaModalService, focaBotoneraLateralService) {
13 13
14 $scope.botonera = crearHojaRutaService.getBotonera(); 14 $scope.botonera = crearHojaRutaService.getBotonera();
15 $scope.datepickerAbierto = false; 15 $scope.datepickerAbierto = false;
16 16
17 $scope.show = false; 17 $scope.show = false;
18 $scope.cargando = true; 18 $scope.cargando = true;
19 $scope.dateOptions = { 19 $scope.dateOptions = {
20 maxDate: new Date(), 20 maxDate: new Date(),
21 minDate: new Date(2010, 0, 1) 21 minDate: new Date(2010, 0, 1)
22 }; 22 };
23 23
24 $scope.hojaRuta = { 24 $scope.hojaRuta = {
25 fecha: new Date(), 25 fecha: new Date(),
26 litros: 0, 26 litros: 0,
27 chofer: {}, 27 chofer: {},
28 vehiculo: { 28 vehiculo: {
29 capacidad: 0 29 capacidad: 0
30 }, 30 },
31 transportista: {}, 31 transportista: {},
32 tarifario: { 32 tarifario: {
33 costo: null 33 costo: null
34 } 34 }
35 }; 35 };
36 36
37 $scope.showCabecera = true; 37 $scope.showCabecera = true;
38 38
39 $scope.now = new Date(); 39 $scope.now = new Date();
40 $scope.puntoVenta = '0000'; 40 $scope.puntoVenta = '0000';
41 $scope.comprobante = '00000000'; 41 $scope.comprobante = '00000000';
42 $scope.remitosTabla = []; 42 $scope.remitosTabla = [];
43 $scope.idLista = undefined; 43 $scope.idLista = undefined;
44 //La pantalla solo se usa para cargar pedidos 44 //La pantalla solo se usa para cargar pedidos
45 //var hojaRutaTemp = crearHojaRutaService.getHojaRuta(); 45 //var hojaRutaTemp = crearHojaRutaService.getHojaRuta();
46 46
47 //SETEO BOTONERA LATERAL 47 //SETEO BOTONERA LATERAL
48 $timeout(function() { 48 $timeout(function() {
49 focaBotoneraLateralService.showSalir(true); 49 focaBotoneraLateralService.showSalir(true);
50 focaBotoneraLateralService.showPausar(true); 50 focaBotoneraLateralService.showPausar(true);
51 focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); 51 focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta);
52 }); 52 });
53 53
54 crearHojaRutaService.getNumeroHojaRuta().then( 54 crearHojaRutaService.getNumeroHojaRuta().then(
55 function(res) { 55 function(res) {
56 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); 56 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4);
57 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); 57 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8);
58 }, 58 },
59 function(err) { 59 function(err) {
60 focaModalService.alert('La terminal no esta configurada correctamente'); 60 focaModalService.alert('La terminal no esta configurada correctamente');
61 console.info(err); 61 console.info(err);
62 } 62 }
63 ); 63 );
64 //La pantalla solo se usa para cargar pedidos 64 //La pantalla solo se usa para cargar pedidos
65 // if (hojaRutaTemp !== undefined) { 65 // if (hojaRutaTemp !== undefined) {
66 // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga); 66 // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga);
67 // $scope.hojaRuta = hojaRutaTemp; 67 // $scope.hojaRuta = hojaRutaTemp;
68 // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString(); 68 // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString();
69 // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString(); 69 // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString();
70 // $scope.idLista = $scope.hojaRuta.precioCondicion; 70 // $scope.idLista = $scope.hojaRuta.precioCondicion;
71 // crearHojaRutaService 71 // crearHojaRutaService
72 // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then( 72 // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then(
73 // function(res) { 73 // function(res) {
74 // $scope.remitosTabla = res.data; 74 // $scope.remitosTabla = res.data;
75 // } 75 // }
76 // ); 76 // );
77 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO 77 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO
78 //(NO REQUERIDO EN ESTA VERSION) 78 //(NO REQUERIDO EN ESTA VERSION)
79 // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then( 79 // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then(
80 // function(res) { 80 // function(res) {
81 // $scope.hojaRuta.domicilio = res.data; 81 // $scope.hojaRuta.domicilio = res.data;
82 // } 82 // }
83 // ); 83 // );
84 // } else { 84 // } else {
85 // $scope.hojaRuta.fechaCarga = new Date(); 85 // $scope.hojaRuta.fechaCarga = new Date();
86 // $scope.hojaRuta.bomba = '0'; 86 // $scope.hojaRuta.bomba = '0';
87 // $scope.hojaRuta.flete = '0'; 87 // $scope.hojaRuta.flete = '0';
88 // $scope.idLista = undefined; 88 // $scope.idLista = undefined;
89 // } 89 // }
90 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO 90 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO
91 // $scope.addNewDom = function() { 91 // $scope.addNewDom = function() {
92 // $scope.hojaRuta.domicilio.push({ 'id': 0 }); 92 // $scope.hojaRuta.domicilio.push({ 'id': 0 });
93 // }; 93 // };
94 // $scope.removeNewChoice = function(choice) { 94 // $scope.removeNewChoice = function(choice) {
95 // if ($scope.hojaRuta.domicilio.length > 1) { 95 // if ($scope.hojaRuta.domicilio.length > 1) {
96 // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex( 96 // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex(
97 // function(c) { 97 // function(c) {
98 // return c.$$hashKey === choice.$$hashKey; 98 // return c.$$hashKey === choice.$$hashKey;
99 // } 99 // }
100 // ), 1); 100 // ), 1);
101 // } 101 // }
102 // }; 102 // };
103 103
104 $scope.crearHojaRuta = function() { 104 $scope.crearHojaRuta = function() {
105 if($scope.hojaRuta.litros <= 0) { 105 if($scope.hojaRuta.litros <= 0) {
106 focaModalService.alert('Ingrese Remitos'); 106 focaModalService.alert('Ingrese Remitos');
107 return; 107 return;
108 } 108 }
109 109
110 if(!$scope.hojaRuta.chofer.id) { 110 if(!$scope.hojaRuta.chofer.id) {
111 focaModalService.alert('Ingrese Chofer'); 111 focaModalService.alert('Ingrese Chofer');
112 return; 112 return;
113 } 113 }
114 114
115 if(!$scope.hojaRuta.vehiculo.id) { 115 if(!$scope.hojaRuta.vehiculo.id) {
116 focaModalService.alert('Ingrese Vehiculo'); 116 focaModalService.alert('Ingrese Vehiculo');
117 return; 117 return;
118 } 118 }
119 119
120 if(!$scope.hojaRuta.transportista.codigo) { 120 if(!$scope.hojaRuta.transportista.codigo) {
121 focaModalService.alert('Ingrese Transportista'); 121 focaModalService.alert('Ingrese Transportista');
122 return; 122 return;
123 } 123 }
124 124
125 if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) { 125 if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) {
126 focaModalService.alert( 126 focaModalService.alert(
127 'La capacidad del Vehiculo es menor a lo ingresado en Remitos' 127 'La capacidad del Vehiculo es menor a lo ingresado en Remitos'
128 ); 128 );
129 return; 129 return;
130 } 130 }
131 131
132 if(!$scope.hojaRuta.tarifario.costo) { 132 if(!$scope.hojaRuta.tarifario.costo) {
133 focaModalService.alert('Ingrese Tarifario'); 133 focaModalService.alert('Ingrese Tarifario');
134 return; 134 return;
135 } 135 }
136 136
137 var date = new Date(); 137 var date = new Date();
138 var save = { 138 var save = {
139 hojaRuta: { 139 hojaRuta: {
140 id: 0, 140 id: 0,
141 fechaCreacion: 141 fechaCreacion:
142 new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) 142 new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
143 .toISOString().slice(0, 19) .replace('T', ' '), 143 .toISOString().slice(0, 19) .replace('T', ' '),
144 idTransportista: $scope.hojaRuta.transportista.codigo, 144 idTransportista: $scope.hojaRuta.transportista.codigo,
145 idChofer: $scope.hojaRuta.chofer.id, 145 idChofer: $scope.hojaRuta.chofer.id,
146 idVehiculo: $scope.hojaRuta.vehiculo.id, 146 idVehiculo: $scope.hojaRuta.vehiculo.id,
147 tarifaFlete: $scope.hojaRuta.tarifario.costo 147 tarifaFlete: $scope.hojaRuta.tarifario.costo
148 }, 148 },
149 remitos: $scope.remitosTabla 149 remitos: $scope.remitosTabla
150 }; 150 };
151 151
152 crearHojaRutaService.crearHojaRuta(save).then( 152 crearHojaRutaService.crearHojaRuta(save).then(
153 function(data) { 153 function(data) {
154 focaModalService.alert( 154 focaModalService.alert(
155 'Hoja ruta creada Nº: ' + 155 'Hoja ruta creada Nº: ' +
156 $scope.rellenar(data.data.sucursal, 4) + 156 $scope.rellenar(data.data.sucursal, 4) +
157 '-' + 157 '-' +
158 $scope.rellenar(data.data.numeroHojaRuta, 8) 158 $scope.rellenar(data.data.numeroHojaRuta, 8)
159 ); 159 );
160 $scope.hojaRuta = { 160 $scope.hojaRuta = {
161 fecha: new Date(), 161 fecha: new Date(),
162 litros: 0, 162 litros: 0,
163 chofer: {}, 163 chofer: {},
164 vehiculo: { 164 vehiculo: {
165 capacidad: 0 165 capacidad: 0
166 }, 166 },
167 transportista: {}, 167 transportista: {},
168 tarifario: { 168 tarifario: {
169 costo: null 169 costo: null
170 } 170 }
171 }; 171 };
172 172
173 $scope.remitosTabla = []; 173 $scope.remitosTabla = [];
174 $scope.$broadcast('cleanCabecera'); 174 $scope.$broadcast('cleanCabecera');
175 175
176 crearHojaRutaService.getNumeroHojaRuta().then(function(res) { 176 crearHojaRutaService.getNumeroHojaRuta().then(function(res) {
177 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); 177 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8);
178 }); 178 });
179 }, 179 },
180 function(error) { 180 function(error) {
181 focaModalService.alert('Hubo un error al crear la nota de pedido'); 181 focaModalService.alert('Hubo un error al crear la nota de pedido');
182 console.info(error); 182 console.info(error);
183 } 183 }
184 ); 184 );
185 }; 185 };
186 186
187 $scope.seleccionarTransportista = function() { 187 $scope.seleccionarTransportista = function() {
188 var modalInstance = $uibModal.open( 188 var modalInstance = $uibModal.open(
189 { 189 {
190 ariaLabelledBy: 'Busqueda de Transportista', 190 ariaLabelledBy: 'Busqueda de Transportista',
191 templateUrl: 'modal-proveedor.html', 191 templateUrl: 'modal-proveedor.html',
192 controller: 'focaModalProveedorCtrl', 192 controller: 'focaModalProveedorCtrl',
193 size: 'lg', 193 size: 'lg',
194 resolve: { 194 resolve: {
195 transportista: function() { 195 transportista: function() {
196 return true; 196 return true;
197 } 197 }
198 } 198 }
199 } 199 }
200 ); 200 );
201 modalInstance.result.then( 201 modalInstance.result.then(
202 function(proveedor) { 202 function(proveedor) {
203 console.info($scope.hojaRuta); 203 console.info($scope.hojaRuta);
204 $scope.hojaRuta.transportista.codigo = proveedor.COD; 204 $scope.hojaRuta.transportista.codigo = proveedor.COD;
205 $scope.$broadcast('addCabecera', { 205 $scope.$broadcast('addCabecera', {
206 label: 'Transportista:', 206 label: 'Transportista:',
207 valor: proveedor.NOM 207 valor: proveedor.NOM
208 }); 208 });
209 }, function() { 209 }, function() {
210 210
211 } 211 }
212 ); 212 );
213 }; 213 };
214 214
215 $scope.seleccionarChofer = function() { 215 $scope.seleccionarChofer = function() {
216 var modalInstance = $uibModal.open( 216 var modalInstance = $uibModal.open(
217 { 217 {
218 ariaLabelledBy: 'Busqueda de Chofer', 218 ariaLabelledBy: 'Busqueda de Chofer',
219 templateUrl: 'modal-chofer.html', 219 templateUrl: 'modal-chofer.html',
220 controller: 'focaModalChoferController', 220 controller: 'focaModalChoferController',
221 size: 'lg' 221 size: 'lg'
222 } 222 }
223 ); 223 );
224 224
225 modalInstance.result.then( 225 modalInstance.result.then(
226 function(chofer) { 226 function(chofer) {
227 $scope.hojaRuta.chofer = chofer; 227 $scope.hojaRuta.chofer = chofer;
228 $scope.$broadcast('addCabecera', { 228 $scope.$broadcast('addCabecera', {
229 label: 'Chofer:', 229 label: 'Chofer:',
230 valor: chofer.nombre 230 valor: chofer.nombre
231 }); 231 });
232 }, function() { 232 }, function() {
233 // funcion ejecutada cuando se cancela el modal 233 // funcion ejecutada cuando se cancela el modal
234 } 234 }
235 ); 235 );
236 }; 236 };
237 237
238 $scope.seleccionarVehiculo = function() { 238 $scope.seleccionarVehiculo = function() {
239 var modalInstance = $uibModal.open( 239 var modalInstance = $uibModal.open(
240 { 240 {
241 ariaLabelledBy: 'Busqueda de Vehiculo', 241 ariaLabelledBy: 'Busqueda de Vehiculo',
242 templateUrl: 'modal-vehiculo.html', 242 templateUrl: 'modal-vehiculo.html',
243 controller: 'focaModalVehiculoController', 243 controller: 'focaModalVehiculoController',
244 size: 'lg' 244 size: 'lg'
245 } 245 }
246 ); 246 );
247 247
248 modalInstance.result.then( 248 modalInstance.result.then(
249 function(vehiculo) { 249 function(vehiculo) {
250 $scope.hojaRuta.vehiculo = vehiculo; 250 $scope.hojaRuta.vehiculo = vehiculo;
251 $scope.$broadcast('addCabecera', { 251 $scope.$broadcast('addCabecera', {
252 label: 'Tractor:', 252 label: 'Tractor:',
253 valor: vehiculo.tractor 253 valor: vehiculo.tractor
254 }); 254 });
255 $scope.$broadcast('addCabecera', { 255 $scope.$broadcast('addCabecera', {
256 label: 'Semi:', 256 label: 'Semi:',
257 valor: vehiculo.semi 257 valor: vehiculo.semi
258 }); 258 });
259 $scope.$broadcast('addCabecera', { 259 $scope.$broadcast('addCabecera', {
260 label: 'Capacidad:', 260 label: 'Capacidad:',
261 valor: vehiculo.capacidad 261 valor: vehiculo.capacidad
262 }); 262 });
263 }, function() { 263 }, function() {
264 // funcion ejecutada cuando se cancela el modal 264 // funcion ejecutada cuando se cancela el modal
265 } 265 }
266 ); 266 );
267 }; 267 };
268 268
269 $scope.seleccionarTarifario = function() { 269 $scope.seleccionarTarifario = function() {
270 var modalInstance = $uibModal.open( 270 var modalInstance = $uibModal.open(
271 { 271 {
272 ariaLabelledBy: 'Busqueda de Tarifario', 272 ariaLabelledBy: 'Busqueda de Tarifario',
273 templateUrl: 'modal-tarifa-flete.html', 273 templateUrl: 'modal-tarifa-flete.html',
274 controller: 'focaModalTarifaFleteController', 274 controller: 'focaModalTarifaFleteController',
275 size: 'lg', 275 size: 'lg',
276 resolve: { 276 resolve: {
277 parametrosTarifaFlete: function() { 277 parametrosTarifaFlete: function() {
278 return $scope.hojaRuta.tarifario.costo; 278 return $scope.hojaRuta.tarifario.costo;
279 } 279 }
280 } 280 }
281 } 281 }
282 ); 282 );
283 283
284 modalInstance.result.then( 284 modalInstance.result.then(
285 function(tarifario) { 285 function(tarifario) {
286 $scope.hojaRuta.tarifario = tarifario; 286 $scope.hojaRuta.tarifario = tarifario;
287 $scope.$broadcast('addCabecera', { 287 $scope.$broadcast('addCabecera', {
288 label: 'Tarifario:', 288 label: 'Tarifario:',
289 valor: tarifario.costo 289 valor: tarifario.costo
290 }); 290 });
291 }, function() { 291 }, function() {
292 // funcion ejecutada cuando se cancela el modal 292 // funcion ejecutada cuando se cancela el modal
293 } 293 }
294 ); 294 );
295 }; 295 };
296 296
297 $scope.seleccionarRemitos = function() { 297 $scope.seleccionarRemitos = function() {
298 var modalInstance = $uibModal.open( 298 var modalInstance = $uibModal.open(
299 { 299 {
300 ariaLabelledBy: 'Busqueda de Remito', 300 ariaLabelledBy: 'Busqueda de Remito',
301 templateUrl: 'foca-modal-remito.html', 301 templateUrl: 'foca-modal-remito.html',
302 controller: 'focaModalRemitoController', 302 controller: 'focaModalRemitoController',
303 size: 'lg', 303 size: 'lg',
304 resolve: {usadoPor: function() {return 'hojaRuta';}} 304 resolve: {usadoPor: function() {return 'hojaRuta';}}
305 } 305 }
306 ); 306 );
307 modalInstance.result.then( 307 modalInstance.result.then(
308 function(remito) { 308 function(remito) {
309 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { 309 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) {
310 if ($scope.remitosTabla[i].id === remito.id) { 310 if ($scope.remitosTabla[i].id === remito.id) {
311 focaModalService.alert('Remito ya incluido'); 311 focaModalService.alert('Remito ya incluido');
312 return; 312 return;
313 } 313 }
314 } 314 }
315 315
316 var litros = 0; 316 var litros = 0;
317 for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { 317 for (var j = remito.articulosRemito.length - 1; j >= 0; j--) {
318 litros = litros + parseFloat(remito.articulosRemito[j].cantidad); 318 litros = litros + parseFloat(remito.articulosRemito[j].cantidad);
319 } 319 }
320 320
321 if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { 321 if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) {
322 focaModalService.alert( 322 focaModalService.alert(
323 'Debe ingresar toda la información para el transporte' 323 'Debe ingresar toda la información para el transporte'
324 ); 324 );
325 return; 325 return;
326 } 326 }
327 327
328 if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) 328 if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad)
329 { 329 {
330 var litrostotales = litros; 330 var litrostotales = litros;
331 litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; 331 litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros;
332 focaModalService.alert( 332 focaModalService.alert(
333 'La carga excede la capacidad disponible del vehiculo. ' + 333 'La carga excede la capacidad disponible del vehiculo. ' +
334 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' 334 'Excedente no cargado: ' + (litrostotales - litros) + ' litros'
335 ); 335 );
336 } 336 }
337 337
338 remito.litros = litros; 338 remito.litros = litros;
339 $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; 339 $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros;
340 $scope.remitosTabla.push(remito); 340 $scope.remitosTabla.push(remito);
341 }, function() { 341 }, function() {
342 // funcion ejecutada cuando se cancela el modal 342 // funcion ejecutada cuando se cancela el modal
343 } 343 }
344 ); 344 );
345 }; 345 };
346 346
347 $scope.getTotal = function() { 347 $scope.getTotal = function() {
348 var total = 0; 348 var total = 0;
349 var arrayTempArticulos = $scope.remitosTabla; 349 var arrayTempArticulos = $scope.remitosTabla;
350 for (var i = 0; i < arrayTempArticulos.length; i++) { 350 for (var i = 0; i < arrayTempArticulos.length; i++) {
351 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 351 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
352 } 352 }
353 return parseFloat(total.toFixed(2)); 353 return parseFloat(total.toFixed(2));
354 }; 354 };
355 355
356 $scope.getSubTotal = function() { 356 $scope.getSubTotal = function() {
357 if($scope.articuloACargar) { 357 if($scope.articuloACargar) {
358 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 358 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
359 } 359 }
360 }; 360 };
361 361
362 $scope.limpiarPantalla = function() { 362 $scope.limpiarPantalla = function() {
363 $scope.limpiarFlete(); 363 $scope.limpiarFlete();
364 $scope.hojaRuta.flete = '0'; 364 $scope.hojaRuta.flete = '0';
365 $scope.hojaRuta.bomba = '0'; 365 $scope.hojaRuta.bomba = '0';
366 $scope.hojaRuta.precioCondicion = ''; 366 $scope.hojaRuta.precioCondicion = '';
367 $scope.remitosTabla = []; 367 $scope.remitosTabla = [];
368 $scope.hojaRuta.vendedor.nombre = ''; 368 $scope.hojaRuta.vendedor.nombre = '';
369 $scope.hojaRuta.cliente = {nombre: ''}; 369 $scope.hojaRuta.cliente = {nombre: ''};
370 $scope.hojaRuta.domicilio = {dom: ''}; 370 $scope.hojaRuta.domicilio = {dom: ''};
371 $scope.hojaRuta.litros = 0; 371 $scope.hojaRuta.litros = 0;
372 $scope.domiciliosCliente = []; 372 $scope.domiciliosCliente = [];
373 }; 373 };
374 //Recibe aviso si el teclado está en uso 374 //Recibe aviso si el teclado está en uso
375 // $rootScope.$on('usarTeclado', function(event, data) { 375 // $rootScope.$on('usarTeclado', function(event, data) {
376 // if(data) { 376 // if(data) {
377 // $scope.mostrarTeclado = true; 377 // $scope.mostrarTeclado = true;
378 // return; 378 // return;
379 // } 379 // }
380 // $scope.mostrarTeclado = false; 380 // $scope.mostrarTeclado = false;
381 // }) 381 // })
382 $scope.selectFocus = function($event) { 382 $scope.selectFocus = function($event) {
383 //Si el teclado esta en uso no selecciona el valor 383 //Si el teclado esta en uso no selecciona el valor
384 // if($scope.mostrarTeclado) { 384 // if($scope.mostrarTeclado) {
385 // return; 385 // return;
386 // } 386 // }
387 $event.target.select(); 387 $event.target.select();
388 }; 388 };
389 389
390 $scope.salir = function() { 390 $scope.salir = function() {
391 $location.path('/'); 391 $location.path('/');
392 }; 392 };
393 393
394 $scope.parsearATexto = function(articulo) { 394 $scope.parsearATexto = function(articulo) {
395 articulo.cantidad = parseFloat(articulo.cantidad); 395 articulo.cantidad = parseFloat(articulo.cantidad);
396 articulo.precio = parseFloat(articulo.precio); 396 articulo.precio = parseFloat(articulo.precio);
397 }; 397 };
398 398
399 $scope.rellenar = function(relleno, longitud) { 399 $scope.rellenar = function(relleno, longitud) {
400 relleno = '' + relleno; 400 relleno = '' + relleno;
401 while (relleno.length < longitud) { 401 while (relleno.length < longitud) {
402 relleno = '0' + relleno; 402 relleno = '0' + relleno;
403 } 403 }
404 404
405 return relleno; 405 return relleno;
406 }; 406 };
407 407
408 $scope.quitarArticulo = function(key) { 408 $scope.quitarArticulo = function(key) {
409 $scope.remitosTabla.splice(key, 1); 409 $scope.remitosTabla.splice(key, 1);
410 var litros = 0; 410 var litros = 0;
411 411
412 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { 412 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) {
413 litros += parseFloat($scope.remitosTabla[i].litros); 413 litros += parseFloat($scope.remitosTabla[i].litros);
414 } 414 }
415 415
416 $scope.hojaRuta.litros = litros; 416 $scope.hojaRuta.litros = litros;
417 417
418 }; 418 };
419 } 419 }
420 ] 420 ]
421 ) 421 )
422 .controller('hojaRutaListaCtrl', [ 422 .controller('hojaRutaListaCtrl', [
423 '$scope', 423 '$scope',
424 'crearHojaRutaService', 424 'crearHojaRutaService',
425 '$location', 425 '$location',
426 function($scope, crearHojaRutaService, $location) { 426 function($scope, crearHojaRutaService, $location) {
427 crearHojaRutaService.obtenerHojaRuta().then(function(datos) { 427 crearHojaRutaService.obtenerHojaRuta().then(function(datos) {
428 $scope.hojaRutas = datos.data; 428 $scope.hojaRutas = datos.data;
429 }); 429 });
430 $scope.editar = function(hojaRuta) { 430 $scope.editar = function(hojaRuta) {
431 crearHojaRutaService.setHojaRuta(hojaRuta); 431 crearHojaRutaService.setHojaRuta(hojaRuta);
432 $location.path('/venta-nota-pedido/abm/'); 432 $location.path('/venta-nota-pedido/abm/');
433 }; 433 };
434 $scope.crearPedido = function() { 434 $scope.crearPedido = function() {
435 crearHojaRutaService.clearHojaRuta(); 435 crearHojaRutaService.clearHojaRuta();
436 $location.path('/venta-nota-pedido/abm/'); 436 $location.path('/venta-nota-pedido/abm/');
437 }; 437 };
438 } 438 }
439 ]) 439 ])
440 .controller('focaCrearHojaRutaFichaClienteController', [ 440 .controller('focaCrearHojaRutaFichaClienteController', [
441 '$scope', 441 '$scope',
442 'crearHojaRutaService', 442 'crearHojaRutaService',
443 '$location', 443 '$location',
444 function($scope, crearHojaRutaService, $location) { 444 function($scope, crearHojaRutaService, $location) {
445 crearHojaRutaService.obtenerHojaRuta().then(function(datos) { 445 crearHojaRutaService.obtenerHojaRuta().then(function(datos) {
446 $scope.hojaRutas = datos.data; 446 $scope.hojaRutas = datos.data;
447 }); 447 });
448 $scope.editar = function(hojaRuta) { 448 $scope.editar = function(hojaRuta) {
449 crearHojaRutaService.setHojaRuta(hojaRuta); 449 crearHojaRutaService.setHojaRuta(hojaRuta);
450 $location.path('/venta-nota-pedido/abm/'); 450 $location.path('/venta-nota-pedido/abm/');
451 }; 451 };
452 $scope.crearPedido = function() { 452 $scope.crearPedido = function() {
453 crearHojaRutaService.clearHojaRuta(); 453 crearHojaRutaService.clearHojaRuta();
454 $location.path('/venta-nota-pedido/abm/'); 454 $location.path('/venta-nota-pedido/abm/');
455 }; 455 };
456 } 456 }
457 ]); 457 ]);
458 458
src/views/hoja-ruta.html
1 <div class="crear-hoja-ruta foca-crear row"> 1 <div class="crear-hoja-ruta foca-crear row">
2 <foca-cabecera-facturador 2 <foca-cabecera-facturador
3 titulo="'HOJA DE RUTA'" 3 titulo="'Hoja de ruta'"
4 numero="puntoVenta + '-' + comprobante" 4 numero="puntoVenta + '-' + comprobante"
5 fecha="now" 5 fecha="now"
6 class="mb-0 col-lg-12" 6 class="mb-0 col-lg-12"
7 ></foca-cabecera-facturador> 7 ></foca-cabecera-facturador>
8 <div class="col-lg-12"> 8 <div class="col-lg-12">
9 <div class="row mt-4"> 9 <div class="row mt-4">
10 <div class="col-12 col-md-10 border border-light rounded"> 10 <div class="col-12 col-md-10 border border-light rounded">
11 <div class="row px-5 py-2 botonera-secundaria"> 11 <div class="row px-5 py-2 botonera-secundaria">
12 <div class="col-12"> 12 <div class="col-12">
13 <foca-botonera-facturador botones="botonera" extra="7" class="row"></foca-botonera-facturador> 13 <foca-botonera-facturador botones="botonera" extra="7" class="row"></foca-botonera-facturador>
14 </div> 14 </div>
15 </div> 15 </div>
16 <!-- PC --> 16 <!-- PC -->
17 <div class="row grilla-articulo align-items-end d-none d-sm-flex"> 17 <div class="row grilla-articulo align-items-end d-none d-sm-flex">
18 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> 18 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom">
19 <thead> 19 <thead>
20 <tr class="d-flex"> 20 <tr class="d-flex">
21 <th class="col-auto">#</th> 21 <th class="col-auto">#</th>
22 <th class="col-2">Remito</th> 22 <th class="col-2">Remito</th>
23 <th class="col">Cliente</th> 23 <th class="col">Cliente</th>
24 <th class="col">Dirección</th> 24 <th class="col">Dirección</th>
25 <th class="text-right" style="width: 80px">Cantidad</th> 25 <th class="text-right" style="width: 80px">Cantidad</th>
26 <th class="col-auto"> 26 <th class="col-auto">
27 <button 27 <button
28 class="btn btn-outline-light selectable" 28 class="btn btn-outline-light selectable"
29 ng-click="show = !show; masMenos()" 29 ng-click="show = !show; masMenos()"
30 > 30 >
31 <i 31 <i
32 class="fa fa-chevron-down" 32 class="fa fa-chevron-down"
33 ng-show="show" 33 ng-show="show"
34 aria-hidden="true" 34 aria-hidden="true"
35 > 35 >
36 </i> 36 </i>
37 <i 37 <i
38 class="fa fa-chevron-up" 38 class="fa fa-chevron-up"
39 ng-hide="show" 39 ng-hide="show"
40 aria-hidden="true"> 40 aria-hidden="true">
41 </i> 41 </i>
42 </button> 42 </button>
43 </th> 43 </th>
44 </th> 44 </th>
45 </tr> 45 </tr>
46 </thead> 46 </thead>
47 <tbody class="tabla-articulo-body"> 47 <tbody class="tabla-articulo-body">
48 <tr 48 <tr
49 ng-repeat="(key, remito) in remitosTabla" 49 ng-repeat="(key, remito) in remitosTabla"
50 class="d-flex" 50 class="d-flex"
51 ng-show="show || key == remitosTabla.length - 1" 51 ng-show="show || key == remitosTabla.length - 1"
52 > 52 >
53 <td ng-bind="key + 1" class="col-auto"></td> 53 <td ng-bind="key + 1" class="col-auto"></td>
54 <td 54 <td
55 class="col-2" 55 class="col-2"
56 ng-bind="rellenar(remito.sucursal, 4) + '-' + rellenar(remito.numeroRemito, 8)" 56 ng-bind="rellenar(remito.sucursal, 4) + '-' + rellenar(remito.numeroRemito, 8)"
57 ></td> 57 ></td>
58 <th class="col" ng-bind="remito.cliente[0].NOM"></th> 58 <th class="col" ng-bind="remito.cliente[0].NOM"></th>
59 <th class="col" ng-bind="remito.domicilioStamp"></th> 59 <th class="col" ng-bind="remito.domicilioStamp"></th>
60 <th class="text-right" ng-bind="remito.litros" style="width: 80px"></th> 60 <th class="text-right" ng-bind="remito.litros" style="width: 80px"></th>
61 <td class="text-center col-auto"> 61 <td class="text-center col-auto">
62 <button 62 <button
63 class="btn btn-outline-light" 63 class="btn btn-outline-light"
64 ng-click="quitarArticulo(key)" 64 ng-click="quitarArticulo(key)"
65 > 65 >
66 <i class="fa fa-trash"></i> 66 <i class="fa fa-trash"></i>
67 </button> 67 </button>
68 </td> 68 </td>
69 </tr> 69 </tr>
70 </tbody> 70 </tbody>
71 <tfoot> 71 <tfoot>
72 <tr class="d-flex"> 72 <tr class="d-flex">
73 <td class="col-auto px-1"> 73 <td class="col-auto px-1">
74 <strong>Remitos:</strong> 74 <strong>Remitos:</strong>
75 <a ng-bind="remitosTabla.length"></a> 75 <a ng-bind="remitosTabla.length"></a>
76 </td> 76 </td>
77 <td class="col"></td> 77 <td class="col"></td>
78 <td class="col-auto px-1"> 78 <td class="col-auto px-1">
79 <strong>Cantidad:</strong> 79 <strong>Cantidad:</strong>
80 <a ng-bind="hojaRuta.litros"></a> 80 <a ng-bind="hojaRuta.litros"></a>
81 </td> 81 </td>
82 </tr> 82 </tr>
83 </tfoot> 83 </tfoot>
84 </table> 84 </table>
85 </div> 85 </div>
86 86
87 <!-- MOBILE --> 87 <!-- MOBILE -->
88 <div class="row d-sm-none"> 88 <div class="row d-sm-none">
89 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> 89 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile">
90 <thead> 90 <thead>
91 <tr class="d-flex"> 91 <tr class="d-flex">
92 <th class="">#</th> 92 <th class="">#</th>
93 <th class="col px-0"> 93 <th class="col px-0">
94 <div class="d-flex"> 94 <div class="d-flex">
95 <div class="col-4 px-1">Código</div> 95 <div class="col-4 px-1">Código</div>
96 <div class="col-8 px-1">Descripción</div> 96 <div class="col-8 px-1">Descripción</div>
97 </div> 97 </div>
98 <div class="d-flex"> 98 <div class="d-flex">
99 <div class="col-3 px-1">Cantidad</div> 99 <div class="col-3 px-1">Cantidad</div>
100 <div class="col px-1 text-right">P. Uni.</div> 100 <div class="col px-1 text-right">P. Uni.</div>
101 <div class="col px-1 text-right">Subtotal</div> 101 <div class="col px-1 text-right">Subtotal</div>
102 </div> 102 </div>
103 </th> 103 </th>
104 <th class="text-center tamaño-boton"> 104 <th class="text-center tamaño-boton">
105 &nbsp; 105 &nbsp;
106 </th> 106 </th>
107 </tr> 107 </tr>
108 </thead> 108 </thead>
109 <tbody> 109 <tbody>
110 <tr 110 <tr
111 ng-repeat="(key, articulo) in remitosTabla" 111 ng-repeat="(key, articulo) in remitosTabla"
112 ng-show="show || key == remitosTabla.length - 1" 112 ng-show="show || key == remitosTabla.length - 1"
113 > 113 >
114 <td class="w-100 align-middle d-flex p-0"> 114 <td class="w-100 align-middle d-flex p-0">
115 <div class="align-middle p-1"> 115 <div class="align-middle p-1">
116 <span ng-bind="key+1" class="align-middle"></span> 116 <span ng-bind="key+1" class="align-middle"></span>
117 </div> 117 </div>
118 <div class="col px-0"> 118 <div class="col px-0">
119 <div class="d-flex"> 119 <div class="d-flex">
120 <div class="col-4 px-1"> 120 <div class="col-4 px-1">
121 <span 121 <span
122 ng-bind="articulo.sector + '-' + articulo.codigo" 122 ng-bind="articulo.sector + '-' + articulo.codigo"
123 ></span> 123 ></span>
124 </div> 124 </div>
125 <div class="col-8 px-1"> 125 <div class="col-8 px-1">
126 <span ng-bind="articulo.descripcion"></span> 126 <span ng-bind="articulo.descripcion"></span>
127 </div> 127 </div>
128 </div> 128 </div>
129 <div class="d-flex"> 129 <div class="d-flex">
130 <div class="col-3 px-1"> 130 <div class="col-3 px-1">
131 <span ng-bind="'x' + articulo.cantidad"></span> 131 <span ng-bind="'x' + articulo.cantidad"></span>
132 </div> 132 </div>
133 <div class="col-3 px-1 text-right"> 133 <div class="col-3 px-1 text-right">
134 <span ng-bind="articulo.precio | currency: hojaRuta.moneda.simbolo : 4"></span> 134 <span ng-bind="articulo.precio | currency: hojaRuta.moneda.simbolo : 4"></span>
135 </div> 135 </div>
136 <div class="col px-1 text-right"> 136 <div class="col px-1 text-right">
137 <span 137 <span
138 ng-bind="(articulo.precio * articulo.cantidad) | currency: hojaRuta.moneda.simbolo" 138 ng-bind="(articulo.precio * articulo.cantidad) | currency: hojaRuta.moneda.simbolo"
139 > 139 >
140 </span> 140 </span>
141 </div> 141 </div>
142 </div> 142 </div>
143 </div> 143 </div>
144 <div class="align-middle p-1"> 144 <div class="align-middle p-1">
145 <button 145 <button
146 class="btn btn-outline-light" 146 class="btn btn-outline-light"
147 ng-click="quitarArticulo(key)" 147 ng-click="quitarArticulo(key)"
148 > 148 >
149 <i class="fa fa-trash"></i> 149 <i class="fa fa-trash"></i>
150 </button> 150 </button>
151 </div> 151 </div>
152 </td> 152 </td>
153 </tr> 153 </tr>
154 </tbody> 154 </tbody>
155 <tfoot> 155 <tfoot>
156 <!-- CARGANDO ITEM --> 156 <!-- CARGANDO ITEM -->
157 <tr ng-show="!cargando" class="d-flex"> 157 <tr ng-show="!cargando" class="d-flex">
158 <td 158 <td
159 class="align-middle p-1" 159 class="align-middle p-1"
160 ng-bind="remitosTabla.length + 1" 160 ng-bind="remitosTabla.length + 1"
161 ></td> 161 ></td>
162 <td class="col p-0"> 162 <td class="col p-0">
163 <div class="d-flex"> 163 <div class="d-flex">
164 <div class="col-4 px-1"> 164 <div class="col-4 px-1">
165 <span 165 <span
166 ng-bind="articuloACargar.sectorCodigo" 166 ng-bind="articuloACargar.sectorCodigo"
167 ></span> 167 ></span>
168 </div> 168 </div>
169 <div class="col-8 px-1"> 169 <div class="col-8 px-1">
170 <span ng-bind="articuloACargar.descripcion"></span> 170 <span ng-bind="articuloACargar.descripcion"></span>
171 </div> 171 </div>
172 </div> 172 </div>
173 <div class="d-flex"> 173 <div class="d-flex">
174 <div class="col-3 px-1 m-1"> 174 <div class="col-3 px-1 m-1">
175 <input 175 <input
176 class="form-control p-1" 176 class="form-control p-1"
177 type="number" 177 type="number"
178 min="1" 178 min="1"
179 ng-model="articuloACargar.cantidad" 179 ng-model="articuloACargar.cantidad"
180 foca-focus="!cargando" 180 foca-focus="!cargando"
181 ng-keypress="agregarATabla($event.keyCode)" 181 ng-keypress="agregarATabla($event.keyCode)"
182 style="height: auto; line-height: 1.1em" 182 style="height: auto; line-height: 1.1em"
183 > 183 >
184 </div> 184 </div>
185 <div class="col-3 px-1 text-right"> 185 <div class="col-3 px-1 text-right">
186 <span ng-bind="articuloACargar.precio | currency: hojaRuta.moneda.simbolo : 4"></span> 186 <span ng-bind="articuloACargar.precio | currency: hojaRuta.moneda.simbolo : 4"></span>
187 </div> 187 </div>
188 <div class="col px-1 text-right"> 188 <div class="col px-1 text-right">
189 <span 189 <span
190 ng-bind="getSubTotal() | currency: hojaRuta.moneda.simbolo" 190 ng-bind="getSubTotal() | currency: hojaRuta.moneda.simbolo"
191 > 191 >
192 </span> 192 </span>
193 </div> 193 </div>
194 </div> 194 </div>
195 </td> 195 </td>
196 <td class="text-center align-middle"> 196 <td class="text-center align-middle">
197 <button 197 <button
198 class="btn btn-outline-light" 198 class="btn btn-outline-light"
199 ng-click="agregarATabla(13)" 199 ng-click="agregarATabla(13)"
200 > 200 >
201 <i class="fa fa-save"></i> 201 <i class="fa fa-save"></i>
202 </button> 202 </button>
203 </td> 203 </td>
204 </tr> 204 </tr>
205 <!-- SELECCIONAR PRODUCTO --> 205 <!-- SELECCIONAR PRODUCTO -->
206 <tr ng-show="cargando" class="d-flex"> 206 <tr ng-show="cargando" class="d-flex">
207 <td class="col-12"> 207 <td class="col-12">
208 <input 208 <input
209 placeholder="Seleccione Articulo" 209 placeholder="Seleccione Articulo"
210 class="form-control form-control-sm" 210 class="form-control form-control-sm"
211 readonly 211 readonly
212 ng-click="seleccionarArticulo()" 212 ng-click="seleccionarArticulo()"
213 /> 213 />
214 </td> 214 </td>
215 </tr> 215 </tr>
216 <!-- TOOGLE EXPANDIR --> 216 <!-- TOOGLE EXPANDIR -->
217 <tr> 217 <tr>
218 <td class="col"> 218 <td class="col">
219 <button 219 <button
220 class="btn btn-outline-light selectable w-100" 220 class="btn btn-outline-light selectable w-100"
221 ng-click="show = !show; masMenos()" 221 ng-click="show = !show; masMenos()"
222 ng-show="remitosTabla.length > 0" 222 ng-show="remitosTabla.length > 0"
223 > 223 >
224 <i 224 <i
225 class="fa fa-chevron-down" 225 class="fa fa-chevron-down"
226 ng-hide="show" 226 ng-hide="show"
227 aria-hidden="true" 227 aria-hidden="true"
228 > 228 >
229 </i> 229 </i>
230 <i 230 <i
231 class="fa fa-chevron-up" 231 class="fa fa-chevron-up"
232 ng-show="show" 232 ng-show="show"
233 aria-hidden="true"> 233 aria-hidden="true">
234 </i> 234 </i>
235 </button> 235 </button>
236 </td> 236 </td>
237 </tr> 237 </tr>
238 <!-- FOOTER --> 238 <!-- FOOTER -->
239 <tr class="d-flex"> 239 <tr class="d-flex">
240 <td class="align-middle no-border-top" colspan="2"> 240 <td class="align-middle no-border-top" colspan="2">
241 <strong>Cantidad Items:</strong> 241 <strong>Cantidad Items:</strong>
242 <a ng-bind="remitosTabla.length"></a> 242 <a ng-bind="remitosTabla.length"></a>
243 </td> 243 </td>
244 <td class="text-right ml-auto table-celda-total no-border-top"> 244 <td class="text-right ml-auto table-celda-total no-border-top">
245 <h3>Total:</h3> 245 <h3>Total:</h3>
246 </td> 246 </td>
247 <td class="table-celda-total text-right no-border-top"> 247 <td class="table-celda-total text-right no-border-top">
248 <h3>{{getTotal() | currency: hojaRuta.moneda.simbolo}}</h3> 248 <h3>{{getTotal() | currency: hojaRuta.moneda.simbolo}}</h3>
249 </td> 249 </td>
250 </tr> 250 </tr>
251 </tfoot> 251 </tfoot>
252 </table> 252 </table>
253 </div> 253 </div>
254 </div> 254 </div>
255 </div> 255 </div>
256 </div> 256 </div>
257 <div class="row d-md-none fixed-bottom"> 257 <div class="row d-md-none fixed-bottom">
258 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 258 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
259 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 259 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
260 <span class="mr-3 ml-auto" ng-click="crearHojaRuta()">Guardar</span> 260 <span class="mr-3 ml-auto" ng-click="crearHojaRuta()">Guardar</span>
261 </div> 261 </div>
262 </div> 262 </div>
263 </div> 263 </div>
264 264