Commit c21b181effe11613abd5e79d6421937e17fbce96

Authored by Eric Fernandez
1 parent 48517fb977
Exists in master and in 1 other branch develop

espacio inecesario

Showing 1 changed file with 0 additions and 1 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', 4 '$scope',
5 '$location', 5 '$location',
6 '$filter', 6 '$filter',
7 '$uibModal', 7 '$uibModal',
8 'hojaRutaService', 8 'hojaRutaService',
9 'focaSeguimientoService', 9 'focaSeguimientoService',
10 'focaLoginService', 10 'focaLoginService',
11 'focaModalService', 11 'focaModalService',
12 function( 12 function(
13 $scope, 13 $scope,
14 $location, 14 $location,
15 $filter, 15 $filter,
16 $uibModal, 16 $uibModal,
17 hojaRutaService, 17 hojaRutaService,
18 focaSeguimientoService, 18 focaSeguimientoService,
19 focaLoginService, 19 focaLoginService,
20 focaModalService 20 focaModalService
21 ) { 21 ) {
22 var loginData = focaLoginService.getLoginData(); 22 var loginData = focaLoginService.getLoginData();
23 23
24 hojaRutaService.getHojasRuta(loginData.chofer).then(function(res) { 24 hojaRutaService.getHojasRuta(loginData.chofer).then(function(res) {
25 if (res.data) { 25 if (res.data) {
26 var hojaRuta = res.data; 26 var hojaRuta = res.data;
27 $scope.hojasRuta = hojaRuta; 27 $scope.hojasRuta = hojaRuta;
28 $scope.puntoVenta = hojaRuta.sucursal; 28 $scope.puntoVenta = hojaRuta.sucursal;
29 $scope.comprobante = hojaRuta.numeroHojaRuta; 29 $scope.comprobante = hojaRuta.numeroHojaRuta;
30 addCabecera('Transportista:', hojaRuta.transportista.NOM); 30 addCabecera('Transportista:', hojaRuta.transportista.NOM);
31 addCabecera('Chofer:', hojaRuta.chofer.nombre); 31 addCabecera('Chofer:', hojaRuta.chofer.nombre);
32 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); 32 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor);
33 } else { 33 } else {
34 focaModalService.alert('Sin hoja de ruta asignada'); 34 focaModalService.alert('Sin hoja de ruta asignada');
35 $location.path('/'); 35 $location.path('/');
36 } 36 }
37 }); 37 });
38 38
39 $scope.cabecera = []; 39 $scope.cabecera = [];
40 $scope.showCabecera = true; 40 $scope.showCabecera = true;
41 41
42 $scope.now = new Date(); 42 $scope.now = new Date();
43 $scope.puntoVenta = '0000'; 43 $scope.puntoVenta = '0000';
44 $scope.comprobante = '00000000'; 44 $scope.comprobante = '00000000';
45 $scope.verDetalle = function(remito) { 45 $scope.verDetalle = function(remito) {
46 var modalInstance = $uibModal.open( 46 var modalInstance = $uibModal.open(
47 { 47 {
48 ariaLabelledBy: 'Detalle hoja ruta', 48 ariaLabelledBy: 'Detalle hoja ruta',
49 templateUrl: 'modal-detalle-hoja-ruta.html', 49 templateUrl: 'modal-detalle-hoja-ruta.html',
50 controller: 'focaModalDetalleHojaRutaController', 50 controller: 'focaModalDetalleHojaRutaController',
51 resolve: { 51 resolve: {
52 idRemito : function() {return remito.id;} 52 idRemito : function() {return remito.id;}
53 }, 53 },
54 size: 'lg' 54 size: 'lg'
55 } 55 }
56 ); 56 );
57 modalInstance.result.then(function(detalle) { 57 modalInstance.result.then(function(detalle) {
58 console.log(detalle); 58 console.log(detalle);
59 //función a ejecutar cuando se carga la cisterna 59 //función a ejecutar cuando se carga la cisterna
60 //eliminar console log en produccion cuando sea necesario 60 //eliminar console log en produccion cuando sea necesario
61 }); 61 });
62 }; 62 };
63 63
64 function addCabecera(label, valor) { 64 function addCabecera(label, valor) {
65 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 65 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
66 if(propiedad.length === 1) { 66 if(propiedad.length === 1) {
67 propiedad[0].valor = valor; 67 propiedad[0].valor = valor;
68 } else { 68 } else {
69 $scope.cabecera.push({label: label, valor: valor}); 69 $scope.cabecera.push({label: label, valor: valor});
70 } 70 }
71 } 71 }
72 //TODO Descomentar cuando se use 72 //TODO Descomentar cuando se use
73 // function removeCabecera(label) { 73 // function removeCabecera(label) {
74 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 74 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
75 // if(propiedad.length === 1) { 75 // if(propiedad.length === 1) {
76 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 76 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
77 // } 77 // }
78 // } 78 // }
79 79
80 $scope.rellenar = function(relleno, longitud) { 80 $scope.rellenar = function(relleno, longitud) {
81 relleno = '' + relleno; 81 relleno = '' + relleno;
82 while (relleno.length < longitud) { 82 while (relleno.length < longitud) {
83 relleno = '0' + relleno; 83 relleno = '0' + relleno;
84 } 84 }
85 85
86 return relleno; 86 return relleno;
87 }; 87 };
88 $scope.salir = function() { 88 $scope.salir = function() {
89 $location.path('/'); 89 $location.path('/');
90 }; 90 };
91 91
92 $scope.terminarHojaRuta = function() { 92 $scope.terminarHojaRuta = function() {
93 focaModalService 93 focaModalService
94 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna' + 94 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna' +
95 'otra descarga ni modificación') 95 'otra descarga ni modificación')
96 .then(terminar); 96 .then(terminar);
97 function terminar() { 97 function terminar() {
98 hojaRutaService.terminarHojaRuta($scope.hojasRuta.id).then( 98 hojaRutaService.terminarHojaRuta($scope.hojasRuta.id).then(
99 function() { 99 function() {
100 focaModalService.alert( 100 focaModalService.alert(
101 'Hoja de ruta ' + 101 'Hoja de ruta ' +
102 $filter('comprobante')([$scope.puntoVenta, 102 $filter('comprobante')([$scope.puntoVenta,
103 $scope.comprobante]) + ' cerrada con éxito'); 103 $scope.comprobante]) + ' cerrada con éxito');
104 $location.path('/'); 104 $location.path('/');
105 } 105 }
106 ); 106 );
107 } 107 }
108 }; 108 };
109 } 109 }
110 ]); 110 ]);
111
112 111