Commit 89cd22a02aedf8c0d684b9a0a62534e0f208f1a5

Authored by Pablo Marco del Pont
1 parent a51ecc88e7
Exists in master

- Agregué lógica de seguimiento.

Showing 1 changed file with 11 additions and 4 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaHojaRuta') 1 angular.module('focaHojaRuta')
2 .controller('listaHojaRutaCtrl', 2 .controller('listaHojaRutaCtrl',
3 [ 3 [
4 '$scope', '$filter', '$uibModal', 'hojaRutaService', 4 '$scope', '$filter', '$uibModal', 'hojaRutaService', 'focaSeguimientoService',
5 function($scope, $filter, $uibModal, hojaRutaService) { 5 function($scope, $filter, $uibModal, hojaRutaService, focaSeguimientoService) {
6 hojaRutaService.getHojasRuta().then(function(res) { 6 hojaRutaService.getHojasRuta().then(function(res) {
7 $scope.hojasRuta = res.data; 7 $scope.hojasRuta = res.data;
8 $scope.puntoVenta = rellenar(res.data[0].sucursal, 4); 8 $scope.puntoVenta = rellenar(res.data[0].sucursal, 4);
9 $scope.comprobante = rellenar(res.data[0].numeroHojaRuta, 8); 9 $scope.comprobante = rellenar(res.data[0].numeroHojaRuta, 8);
10 }); 10 });
11 $scope.cabecera = []; 11 $scope.cabecera = [];
12 $scope.showCabecera = true; 12 $scope.showCabecera = true;
13 addCabecera('Transportista:', 'Andesmar'); 13 addCabecera('Transportista:', 'Andesmar');
14 addCabecera('Chofer:', 'Carlos'); 14 addCabecera('Chofer:', 'Carlos');
15 addCabecera('Vehículo:', 'SCANIA'); 15 addCabecera('Vehículo:', 'SCANIA');
16 $scope.now = new Date(); 16 $scope.now = new Date();
17 $scope.puntoVenta = '0000'; 17 $scope.puntoVenta = '0000';
18 $scope.comprobante = '00000000'; 18 $scope.comprobante = '00000000';
19 $scope.verDetalle = function() { 19 $scope.verDetalle = function() {
20 var modalInstance = $uibModal.open( 20 var modalInstance = $uibModal.open(
21 { 21 {
22 ariaLabelledBy: 'Detalle hoja ruta', 22 ariaLabelledBy: 'Detalle hoja ruta',
23 templateUrl: 'modal-detalle-hoja-ruta.html', 23 templateUrl: 'modal-detalle-hoja-ruta.html',
24 controller: 'focaModalDetalleHojaRutaController', 24 controller: 'focaModalDetalleHojaRutaController',
25 resolve: { 25 resolve: {
26 parametrosDetalleHojaRuta: function(){ 26 parametrosDetalleHojaRuta: function(){
27 return { 27 return {
28 remito: '00001-00000001', 28 remito: '00001-00000001',
29 cliente: 'Rubén Gomez', 29 cliente: 'Rubén Gomez',
30 domicilio: 'Patricias Mendocinas 5050', 30 domicilio: 'Patricias Mendocinas 5050',
31 producto: 'Super', 31 producto: 'Super',
32 litros: 20 32 litros: 20
33 }; 33 };
34 } 34 }
35 }, 35 },
36 size: 'lg' 36 size: 'lg'
37 } 37 }
38 ); 38 );
39 modalInstance.result.then(function() { 39 modalInstance.result.then(function(parametros) {
40 40 // Al guardar los datos del producto entregado logueamos la
41 // actividad para su seguimiento.
42 focaSeguimientoService.guardarPosicion(
43 'Entrega de producto',
44 'Remito: ' + $scope.puntoVenta + '-' + $scope.comprobante + '<br/>' +
45 'Producto: ' + parametros.producto + '<br/>' +
46 'Litros: ' + parametros.litros
47 );
41 }); 48 });
42 }; 49 };
43 50
44 function addCabecera(label, valor) { 51 function addCabecera(label, valor) {
45 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 52 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
46 if(propiedad.length === 1) { 53 if(propiedad.length === 1) {
47 propiedad[0].valor = valor; 54 propiedad[0].valor = valor;
48 } else { 55 } else {
49 $scope.cabecera.push({label: label, valor: valor}); 56 $scope.cabecera.push({label: label, valor: valor});
50 } 57 }
51 } 58 }
52 //TODO Descomentar cuando se use 59 //TODO Descomentar cuando se use
53 // function removeCabecera(label) { 60 // function removeCabecera(label) {
54 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 61 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
55 // if(propiedad.length === 1) { 62 // if(propiedad.length === 1) {
56 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 63 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
57 // } 64 // }
58 // } 65 // }
59 66
60 function rellenar(relleno, longitud) { 67 function rellenar(relleno, longitud) {
61 relleno = '' + relleno; 68 relleno = '' + relleno;
62 while (relleno.length < longitud) { 69 while (relleno.length < longitud) {
63 relleno = '0' + relleno; 70 relleno = '0' + relleno;
64 } 71 }
65 72
66 return relleno; 73 return relleno;
67 } 74 }
68 } 75 }
69 ]); 76 ]);
70 77
71 78