Commit d4a38bec1f8b59dad2eaafeaa543672c1ff06008

Authored by Eric Fernandez
Exists in master and in 2 other branches develop, lab

Merge branch 'master' into 'master'

Master

See merge request !5
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 parametrosDetalleHojaRuta: function(){ 52 parametrosDetalleHojaRuta: function(){
53 return { 53 return {
54 remito: $filter('comprobante')([ 54 remito: $filter('comprobante')([
55 remito.sucursal, remito.numeroRemito 55 remito.sucursal, remito.numeroRemito
56 ]), 56 ]),
57 cliente: remito.nombreCliente, 57 cliente: remito.nombreCliente,
58 domicilio: remito.domicilioStamp, 58 domicilio: remito.domicilioStamp,
59 producto: 'Super', 59 producto: 'Super',
60 contacto: remito.nombreCliente, 60 contacto: remito.nombreCliente,
61 telefonoContacto: '-', 61 telefonoContacto: '-',
62 litros: remito.carga, 62 litros: remito.carga,
63 idRemito: remito.id 63 idRemito: remito.id
64 }; 64 };
65 } 65 }
66 }, 66 },
67 size: 'lg' 67 size: 'lg'
68 } 68 }
69 ); 69 );
70 modalInstance.result.then(function(parametros) { 70 modalInstance.result.then(function(parametros) {
71 // Al guardar los datos del producto entregado logueamos la 71 // Al guardar los datos del producto entregado logueamos la
72 // actividad para su seguimiento. 72 // actividad para su seguimiento.
73 hojaRutaService.postMovimientoHojaRuta({ 73 hojaRutaService.postMovimientoHojaRuta({
74 numeroRecibo: parametros.numeroRecibo, 74 numeroRecibo: parametros.numeroRecibo,
75 idRemito: parametros.idRemito, 75 idRemito: parametros.idRemito,
76 litrosDescargados: parametros.litrosDescargados 76 litrosDescargados: parametros.litrosDescargados
77 }).then(function(movimiento) { 77 }).then(function(movimiento) {
78 focaSeguimientoService.guardarPosicion( 78 focaSeguimientoService.guardarPosicion(
79 'Entrega de producto', 79 'Entrega de producto',
80 movimiento.data.id, 80 movimiento.data.id,
81 parametros.observaciones 81 parametros.observaciones
82 ); 82 );
83 }); 83 });
84 84
85 }); 85 });
86 }; 86 };
87 87
88 function addCabecera(label, valor) { 88 function addCabecera(label, valor) {
89 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 89 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
90 if(propiedad.length === 1) { 90 if(propiedad.length === 1) {
91 propiedad[0].valor = valor; 91 propiedad[0].valor = valor;
92 } else { 92 } else {
93 $scope.cabecera.push({label: label, valor: valor}); 93 $scope.cabecera.push({label: label, valor: valor});
94 } 94 }
95 } 95 }
96 //TODO Descomentar cuando se use 96 //TODO Descomentar cuando se use
97 // function removeCabecera(label) { 97 // function removeCabecera(label) {
98 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 98 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
99 // if(propiedad.length === 1) { 99 // if(propiedad.length === 1) {
100 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 100 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
101 // } 101 // }
102 // } 102 // }
103 103
104 $scope.rellenar = function(relleno, longitud) { 104 $scope.rellenar = function(relleno, longitud) {
105 relleno = '' + relleno; 105 relleno = '' + relleno;
106 while (relleno.length < longitud) { 106 while (relleno.length < longitud) {
107 relleno = '0' + relleno; 107 relleno = '0' + relleno;
108 } 108 }
109 109
110 return relleno; 110 return relleno;
111 }; 111 };
112 $scope.salir = function() { 112 $scope.salir = function() {
113 $location.path('/'); 113 $location.path('/');
114 }; 114 };
115
116 $scope.terminarHojaRuta = function() {
117 hojaRutaService.terminarHojaRuta($scope.hojasRuta.id).then(
118 function() {
119 focaModalService.alert(
120 'Hoja de ruta ' +
121 $filter('comprobante')([$scope.puntoVenta, $scope.comprobante]) +
122 ' cerrada con éxito'
123 );
124 $location.path('/');
125 }
126 );
127 };
115 } 128 }
116 ]); 129 ]);
117 130
118 131
1 angular.module('focaHojaRuta') 1 angular.module('focaHojaRuta')
2 .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 var route = API_ENDPOINT.URL; 3 var route = API_ENDPOINT.URL;
4 return { 4 return {
5 getHojasRuta: function(chofer) { 5 getHojasRuta: function(chofer) {
6 return $http.get(route + '/hoja-ruta/chofer/' + chofer); 6 return $http.get(route + '/hoja-ruta/chofer/' + chofer);
7 }, 7 },
8 postMovimientoHojaRuta: function(datos) { 8 postMovimientoHojaRuta: function(datos) {
9 return $http.post(route + '/hoja-ruta/movimiento', datos); 9 return $http.post(route + '/hoja-ruta/movimiento', datos);
10 },
11 terminarHojaRuta: function(hojaRuta) {
12 return $http.get(route + '/hoja-ruta/terminar/' + hojaRuta);
10 } 13 }
11 }; 14 };
12 }]); 15 }]);
13 16
src/views/lista-hoja-ruta.html
1 <div> 1 <div>
2 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> 2 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
3 <div class="row p-1 panel-informativo"> 3 <div class="row p-1 panel-informativo">
4 <div class="col-12"> 4 <div class="col-12">
5 <div class="row"> 5 <div class="row">
6 <div class="col-12 col-sm-4 nota-pedido"> 6 <div class="col-12 col-sm-4 nota-pedido">
7 <h5>Hojas de ruta</h5> 7 <h5>Hojas de ruta</h5>
8 </div> 8 </div>
9 <div class="col-5 col-sm-4 numero-pedido"> 9 <div class="col-5 col-sm-4 numero-pedido">
10 Nº <span ng-bind="[puntoVenta, comprobante] | comprobante"></span> 10 Nº <span ng-bind="[puntoVenta, comprobante] | comprobante"></span>
11 </div> 11 </div>
12 <div class="col-7 col-sm-4 text-right"> 12 <div class="col-7 col-sm-4 text-right">
13 Fecha: 13 Fecha:
14 <span 14 <span
15 ng-show="!datepickerAbierto" 15 ng-show="!datepickerAbierto"
16 ng-bind="now | date:'dd/MM/yyyy HH:mm'" 16 ng-bind="now | date:'dd/MM/yyyy HH:mm'"
17 ng-click="datepickerAbierto = true" 17 ng-click="datepickerAbierto = true"
18 > 18 >
19 </span> 19 </span>
20 <input 20 <input
21 ng-show="datepickerAbierto" 21 ng-show="datepickerAbierto"
22 type="date" 22 type="date"
23 ng-model="now" 23 ng-model="now"
24 ng-change="datepickerAbierto = false" 24 ng-change="datepickerAbierto = false"
25 ng-blur="datepickerAbierto = false" 25 ng-blur="datepickerAbierto = false"
26 class="form-control form-control-sm col-8 float-right" 26 class="form-control form-control-sm col-8 float-right"
27 foca-focus="datepickerAbierto" 27 foca-focus="datepickerAbierto"
28 hasta-hoy 28 hasta-hoy
29 /> 29 />
30 </div> 30 </div>
31 </div> 31 </div>
32 <div class="row"> 32 <div class="row">
33 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> 33 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera">
34 <span class="label" ng-bind="cab.label"></span> 34 <span class="label" ng-bind="cab.label"></span>
35 <span class="valor" ng-bind="cab.valor"></span> 35 <span class="valor" ng-bind="cab.valor"></span>
36 </div> 36 </div>
37 </div> 37 </div>
38 </div> 38 </div>
39 </div> 39 </div>
40 <div class="row p-1 botonera-secundaria"> 40 <div class="row p-1 botonera-secundaria">
41 <div class="col-12"> 41 <div class="col-12">
42 <div class="row"> 42 <div class="row">
43 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> 43 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera">
44 <button 44 <button
45 type="button" 45 type="button"
46 class="btn btn-default btn-block btn-xs text-left py-2" 46 class="btn btn-default btn-block btn-xs text-left py-2"
47 ng-click="boton.accion()" 47 ng-click="boton.accion()"
48 ng-class="{'d-none d-sm-block': boton.texto == ''}" 48 ng-class="{'d-none d-sm-block': boton.texto == ''}"
49 > 49 >
50 <i 50 <i
51 class="fa fa-arrow-circle-right" 51 class="fa fa-arrow-circle-right"
52 ng-show="boton.texto != ''" 52 ng-show="boton.texto != ''"
53 ></i> 53 ></i>
54 &nbsp; 54 &nbsp;
55 {{boton.texto}} 55 {{boton.texto}}
56 </button> 56 </button>
57 </div> 57 </div>
58 </div> 58 </div>
59 </div> 59 </div>
60 </div> 60 </div>
61 </div> 61 </div>
62 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> 62 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2">
63 <div class="row grilla-articulo"> 63 <div class="row grilla-articulo">
64 <table class="table tabla-articulo table-responsive table-striped table-sm table-dark"> 64 <table class="table tabla-articulo table-responsive table-striped table-sm table-dark">
65 <thead> 65 <thead>
66 <tr> 66 <tr>
67 <th>#</th> 67 <th>#</th>
68 <th>Número</th> 68 <th>Número</th>
69 <th>Razon Social</th> 69 <th>Razon Social</th>
70 <th>Domicilio</th> 70 <th>Domicilio</th>
71 <th class="text-right">Cantidad</th> 71 <th class="text-right">Cantidad</th>
72 <th style="width: 50px">&nbsp;</th> 72 <th style="width: 50px">&nbsp;</th>
73 </tr> 73 </tr>
74 </thead> 74 </thead>
75 <tbody class="tabla-articulo-body"> 75 <tbody class="tabla-articulo-body">
76 <tr 76 <tr
77 77
78 ng-repeat="(key, remito) in hojasRuta.remitos" 78 ng-repeat="(key, remito) in hojasRuta.remitos"
79 > 79 >
80 <td ng-bind="key + 1"></td> 80 <td ng-bind="key + 1"></td>
81 <td 81 <td
82 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante" 82 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"
83 ></td> 83 ></td>
84 <td ng-bind="remito.nombreCliente"></td> 84 <td ng-bind="remito.nombreCliente"></td>
85 <td ng-bind="remito.domicilioStamp"></td> 85 <td ng-bind="remito.domicilioStamp"></td>
86 <td class="text-right" ng-bind="remito.carga"></td> 86 <td class="text-right" ng-bind="remito.carga"></td>
87 <td style="width: 50px"> 87 <td style="width: 50px">
88 <button 88 <button
89 class="btn btn-secondary" 89 class="btn btn-secondary"
90 type="button" 90 type="button"
91 ng-click="verDetalle(remito)" 91 ng-click="verDetalle(remito)"
92 ><i class="fa fa-search" aria-hidden="true"></i> 92 ><i class="fa fa-search" aria-hidden="true"></i>
93 </button> 93 </button>
94 </td> 94 </td>
95 </tr> 95 </tr>
96 </tbody> 96 </tbody>
97 </table> 97 </table>
98 98
99 </div> 99 </div>
100 </div> 100 </div>
101 <div class="row d-md-none fixed-bottom"> 101 <div class="row d-md-none fixed-bottom">
102 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 102 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
103 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 103 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
104 <span
105 class="mr-3 ml-auto"
106 ng-click="terminarHojaRuta()"
107 ladda="saveLoading"
108 data-style="expand-left"
109 >Terminar</span>
104 </div> 110 </div>
105 </div> 111 </div>
106 </div> 112 </div>
107 113