Commit 41d9bb98c31d97d24dc93fc0abc3a13feb67da48

Authored by Eric Fernandez
1 parent 512dca211f
Exists in master

desarrollo

... ... @@ -4,7 +4,7 @@ function allowDrop(ev) {
4 4 function drag(ev, marcador) {
5 5 marcador = JSON.stringify(marcador);
6 6 ev.dataTransfer.setData('marcador', marcador);
7   - var elementoDom = document.getElementById('test');
  7 + var elementoDom = document.getElementById('scope');
8 8 var scope = angular.element(elementoDom).scope();
9 9 scope.arrastra();
10 10 }
... ... @@ -18,8 +18,7 @@ function drop(ev) {
18 18 elementoScope.$digest();
19 19 }
20 20 function dropEnd() {
21   - console.log('drop');
22   - var elementoDom = document.getElementById('test');
  21 + var elementoDom = document.getElementById('scope');
23 22 var scope = angular.element(elementoDom).scope();
24 23 scope.noArrastra();
25 24 }
src/js/controller.js
1 1 angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [
2 2 '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter',
3   - 'focaModalService', 'focaBotoneraLateralService',
  3 + 'focaModalService', 'focaBotoneraLateralService', '$cookies',
4 4 function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter,
5   - focaModalService, focaBotoneraLateralService
  5 + focaModalService, focaBotoneraLateralService, $cookies
6 6 ) {
7 7 $scope.now = new Date();
8 8 $scope.actividad = 'Logistica';
... ... @@ -11,15 +11,14 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
11 11 $scope.titulo = 'Logistica de Pedidos';
12 12 $scope.botonera = ['Vehiculo'];
13 13 var cabecera = '';
14   -
15   - $scope.idUsuario = 0;
  14 +
  15 + $scope.idVendedor = 0;
16 16 $scope.marcadores = [];
17 17 $scope.vehiculos = [];
18   - var idsRemitos = [];
19 18 getSeguimiento();
20 19 $scope.arrastrando = false;
21 20 $scope.general = function() {
22   - $scope.idUsuario = 0;
  21 + $scope.idVendedor = 0;
23 22 getSeguimiento();
24 23 };
25 24  
... ... @@ -28,8 +27,9 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
28 27 focaBotoneraLateralService.showPausar(false);
29 28 focaBotoneraLateralService.showGuardar(false);
30 29  
  30 +
31 31 $scope.general = function() {
32   - $scope.idUsuario = 0;
  32 + $scope.idVendedor = 0;
33 33 getSeguimiento();
34 34 $scope.$broadcast('removeCabecera', cabecera);
35 35 $scope.$broadcast('addCabecera',{
... ... @@ -52,8 +52,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
52 52 }
53 53 }
54 54 );
55   - modalInstance.result.then(function(idRemito) {
56   - idsRemitos.push(idRemito);
  55 + modalInstance.result.then(function() {
57 56 }, function() {
58 57 });
59 58 };
... ... @@ -73,8 +72,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
73 72 controller: 'focaModalCrearHojaRuta',
74 73 size: 'lg',
75 74 resolve: {
76   - idVehiculo: function() {return vehiculo.id;},
77   - idsRemitos: function() {return idsRemitos;}
  75 + idVehiculo: function() {return vehiculo.id;}
78 76 }
79 77 }
80 78 );
... ... @@ -96,7 +94,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
96 94 };
97 95  
98 96 $scope.individual = function() {
99   - $scope.idUsuario = -1;
  97 + $scope.idVendedor = -1;
100 98 };
101 99  
102 100 $scope.mostrarDetalle = function() {
... ... @@ -109,12 +107,12 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
109 107  
110 108 $scope.search = function(key) {
111 109 if (key === 13) {
112   - $scope.idUsuario = $scope.idUsuarioInput;
  110 + $scope.idVendedor = $scope.idVendedorInput;
113 111 getSeguimiento();
114 112 $scope.$broadcast('removeCabecera', 'General');
115 113 $scope.$broadcast('addCabecera', {
116 114 label: cabecera,
117   - valor: $scope.idUsuarioInput
  115 + valor: $scope.idVendedorInput
118 116 });
119 117 }
120 118 };
... ... @@ -158,14 +156,14 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
158 156 desde = new Date(desde);
159 157 var datos = {
160 158 actividad: $scope.actividad,
161   - idUsuario: $scope.idUsuario,
  159 + idUsuario: $scope.idVendedor,
162 160 fechaDesde: desde,
163 161 fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59))
164 162 };
165 163  
166 164 $scope.datosBuscados = {
167 165 actividad: $scope.actividad,
168   - individual: $scope.idUsuario !== 0 ? true : false
  166 + individual: $scope.idVendedor !== 0 ? true : false
169 167 };
170 168  
171 169 focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) {
src/js/controllerDetalleVehiculo.js
... ... @@ -24,6 +24,11 @@ angular.module('focaLogisticaPedidoRuta')
24 24 focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then(
25 25 function(res) {
26 26 $scope.remito = res.data;
  27 + if($scope.remito.idUsuarioProceso !== focaLogisticaPedidoRutaService.idUsuario)
  28 + {
  29 + focaModalService.alert('El remito esta siendo cargado por otro usario');
  30 + $uibModalInstance.close();
  31 + }
27 32 $scope.articulos = res.data.articulosRemito;
28 33 }
29 34 );
... ... @@ -36,13 +41,26 @@ angular.module('focaLogisticaPedidoRuta')
36 41 }
37 42 var cisterna = {
38 43 cisternaMovimientos: cisternaMovimientos,
39   - cisternaCargas: cisternaCargas
  44 + cisternaCargas: cisternaCargas,
  45 + idVehiculo: $scope.vehiculo.id
40 46 };
41   - focaLogisticaPedidoRutaService.guardarCisternas(cisterna).then(function() {
42   - focaModalService.alert('Cisternas cargadas con éxito').then(function() {
  47 + focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id)
  48 + .then(function() {
  49 + focaModalService.alert('Cisternas cargadas con éxito').then(function() {
  50 + $scope.cargando = false;
  51 + $uibModalInstance.close();
  52 + });
  53 + }).catch(function(error) {
43 54 $scope.cargando = false;
44   - $uibModalInstance.close(idRemito);
45   - });
  55 + $uibModalInstance.close();
  56 + if (error.status === 403.1) {
  57 + focaModalService.alert('ERROR: El vehículo esta en uso');
  58 + }
  59 + if(error.status === 403.2) {
  60 + focaModalService.alert('ERROR: Otro usario ya cargó este remito');
  61 + return;
  62 + }
  63 + focaModalService.alert('Hubo un error al cargar las cisternas');
46 64 });
47 65 };
48 66  
... ... @@ -85,7 +103,8 @@ angular.module('focaLogisticaPedidoRuta')
85 103 fecha: now.toISOString().slice(0, 19).replace('T', ' '),
86 104 cantidad: aCargar,
87 105 metodo: 'carga',
88   - idCisternaCarga: cisterna.cisternaCarga.id
  106 + idCisternaCarga: cisterna.cisternaCarga.id,
  107 + idRemito: $scope.remito.id
89 108 };
90 109 cisternaMovimientos.push(cisternaMovimiento);
91 110 }
src/js/controllerHojaRuta.js
... ... @@ -5,30 +5,60 @@ angular.module('focaLogisticaPedidoRuta')
5 5 '$uibModal',
6 6 'focaLogisticaPedidoRutaService',
7 7 'idVehiculo',
8   - 'idsRemitos',
  8 + 'focaModalService',
  9 + '$filter',
9 10 function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService,
10   - idVehiculo, idsRemitos) {
  11 + idVehiculo, focaModalService, $filter) {
11 12 $scope.vehiculo = {};
12 13 $scope.remitos = [];
  14 + $scope.now = new Date();
13 15 focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) {
14 16 $scope.vehiculo = res.data;
15 17 });
16   - for (var i = 0; i < idsRemitos.length; i++) {
17   - focaLogisticaPedidoRutaService.obtenerRemitoById(idsRemitos[i])
18   - .then(cargarRemito);
19   - }
20   - function cargarRemito(res) {
21   - $scope.remitos.push(res.data);
22   - }
  18 + //TODO: refactor código esta rre feo
  19 + focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) {
  20 + for (var i = 0; i < res.data.cisternas.length; i++) {
  21 + for (var j = 0; j < res.data.cisternas[i].cisternaCarga.cisternaMovimientos.length;
  22 + j++) {
  23 + if(!!res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito &&
  24 + !res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito
  25 + .idHojaRuta) {
  26 + var remito = res.data.cisternas[i].cisternaCarga
  27 + .cisternaMovimientos[j].remito;
  28 + var yaEstaCargado = $filter('filter')($scope.remitos, {id: remito.id});
  29 + if(!yaEstaCargado.length &&
  30 + res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].metodo ===
  31 + 'carga') {
  32 + $scope.remitos.push(remito);
  33 + }
  34 + }
  35 + }
  36 + }
  37 + });
23 38 focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) {
24 39 $scope.sucursal = res.data.sucursal;
25   - $scope.numero = res.data.numeroHojaRuta;
  40 + $scope.numero = res.data.numeroHojaRuta;
26 41 });
27 42 $scope.cancelar = function() {
28 43 $uibModalInstance.close();
29 44 };
30 45 $scope.aceptar = function() {
31   - $uibModalInstance.close();
  46 + var save = {
  47 + hojaRuta: {
  48 + id: 0,
  49 + fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
  50 + idTransportista: $scope.vehiculo.idTransportista,
  51 + idChofer: $scope.chofer.id,
  52 + idVehiculo: $scope.vehiculo.id,
  53 + tarifaFlete: $scope.tarifaFlete
  54 + },
  55 + remitos: $scope.remitos,
  56 + idVehiculo: $scope.vehiculo.id
  57 + };
  58 + focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() {
  59 + $uibModalInstance.close();
  60 + focaModalService.alert('Hoja de ruta guardada con éxito');
  61 + });
32 62 };
33 63 $scope.seleccionarChofer = function() {
34 64 var modalInstance = $uibModal.open(
src/js/osm-directive.js
1   -angular.module('focaLogisticaPedidoRuta').directive('foca', function() {
  1 +angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() {
2 2 return {
3 3 restrict: 'E',
4 4 link: function(scope, el, attrs) {
... ... @@ -27,8 +27,8 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;).directive(&#39;foca&#39;, function() {
27 27 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
28 28 marcador.fecha.slice(11,19) + '<br/>';
29 29 observacion += 'Nº: ' + $filter('comprobante')([
30   - marcador.notaPedido.sucursal,
31   - marcador.notaPedido.numeroNotaPedido
  30 + marcador.notaPedido.remito.sucursal,
  31 + marcador.notaPedido.remito.numeroRemito
32 32 ]) + '<br/>';
33 33 observacion += 'Cliente: ' +
34 34 marcador.notaPedido.cliente.NOM + '<br/>';
... ... @@ -43,7 +43,7 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;).directive(&#39;foca&#39;, function() {
43 43 marcador.distancia + 'km';
44 44 }
45 45 }else {
46   - observacion += 'Cantidad de nota de pedido: ' +
  46 + observacion += 'Cantidad de nota de remitos: ' +
47 47 marcador.cantidad + '<br/>';
48 48 observacion += 'Total Vendido: ' +
49 49 $filter('currency')(marcador.total, '$');
... ... @@ -52,8 +52,31 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;).directive(&#39;foca&#39;, function() {
52 52 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+
53 53 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
54 54 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)';
  55 + var icon;
  56 + if(marcador.notaPedido.remito.idUsuarioProceso) {
  57 + //Asignado AZUL
  58 + icon = new L.Icon({
  59 + iconUrl: 'img/marker-icon-2x-blue.png',
  60 + shadowUrl: 'img/marker-shadow.png',
  61 + iconSize: [25, 41],
  62 + iconAnchor: [12, 41],
  63 + popupAnchor: [1, -34],
  64 + shadowSize: [41, 41]
  65 + });
  66 + }else {
  67 + //Sin asignar ROJO
  68 + icon = new L.Icon({
  69 + iconUrl: 'img/marker-icon-2x-red.png',
  70 + shadowUrl: 'img/marker-shadow.png',
  71 + iconSize: [25, 41],
  72 + iconAnchor: [12, 41],
  73 + popupAnchor: [1, -34],
  74 + shadowSize: [41, 41]
  75 + });
  76 + }
55 77 $scope.markers.push(
56   - L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map)
  78 + L.marker([marcador.latitud, marcador.longitud], {icon: icon})
  79 + .addTo($scope.map)
57 80 .bindPopup(observacion)
58 81 );
59 82  
1 1 angular.module('focaLogisticaPedidoRuta')
2 2 .service(
3   - 'focaLogisticaPedidoRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT
4   - ) {
5   - return {
6   - obtenerActividad: function(parametros) {
7   - return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros);
8   - },
9   - obtenerVehiculoById: function(idVehiculo) {
10   - return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo);
11   - },
12   - obtenerRemitoById: function(idRemito) {
13   - return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito);
14   - },
15   - guardarCisternas: function(cisterna) {
16   - return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar', cisterna);
17   - },
18   - numeroHojaRuta: function() {
19   - return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente');
20   - }
21   - };
  3 + 'focaLogisticaPedidoRutaService', [
  4 + '$http',
  5 + '$cookies',
  6 + 'API_ENDPOINT',
  7 + function($http, $cookies, API_ENDPOINT) {
  8 + return {
  9 + idUsuario: $cookies.get('idUsuario'),
  10 + obtenerActividad: function(parametros) {
  11 + return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros);
  12 + },
  13 + obtenerVehiculoById: function(idVehiculo) {
  14 + return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo);
  15 + },
  16 + obtenerRemitoById: function(idRemito) {
  17 + return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito);
  18 + },
  19 + guardarCisternas: function(cisterna, idRemito) {
  20 + return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' +
  21 + this.idUsuario + '/' + idRemito,cisterna);
  22 + },
  23 + numeroHojaRuta: function() {
  24 + return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente');
  25 + },
  26 + getRemitos: function(idVehiculo) {
  27 + return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo);
  28 + },
  29 + crearHojaRuta: function(hojaRuta) {
  30 + return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta);
  31 + }
  32 + };
22 33 }]);
src/views/foca-detalle-vehiculo.html
... ... @@ -58,7 +58,8 @@
58 58 placeholder="A cargar..."
59 59 ng-model="aCargar[key]"
60 60 ng-disabled="(articuloSeleccionado.idArticulo !== cisterna.cisternaCarga.idProducto &&
61   - cisterna.cisternaCarga.idProducto) || !tieneArticulosPendientes()"
  61 + cisterna.cisternaCarga.idProducto) || !tieneArticulosPendientes()
  62 + || articuloSeleccionado.cantidad > cisterna.disponible"
62 63 ng-change="actualizarArticulo()"
63 64 >
64 65 </td>
src/views/foca-logistica-pedido-ruta.html
1   -<div class="foca-logistica-pedido-ruta" id="test">
  1 +<div class="foca-logistica-pedido-ruta" id="scope">
2 2 <div class="row">
3 3 <foca-cabecera-facturador
4 4 titulo="titulo"
... ... @@ -13,7 +13,7 @@
13 13 </div>
14 14 <div class="row">
15 15 <div class="offset-1 col-9">
16   - <foca
  16 + <foca-logistica
17 17 latitud="-32.89214159952345"
18 18 longitud="-68.84572999101856"
19 19 zoom="14"
... ... @@ -32,24 +32,24 @@
32 32 />
33 33 <button
34 34 type="button"
35   - ng-class="{'active': idUsuario == 0}"
  35 + ng-class="{'active': idVendedor == 0}"
36 36 class="btn col-12 my-1"
37 37 ng-click="general()"
38 38 >General</button>
39 39 <button
40 40 type="button"
41   - ng-class="{'active': idUsuario != 0}"
  41 + ng-class="{'active': idVendedor != 0}"
42 42 class="btn col-12 my-1"
43 43 ng-click="individual()"
44 44 >Individual</button>
45   - <div class="form-group" ng-show="idUsuario == -1">
  45 + <div class="form-group" ng-show="idVendedor == -1">
46 46 <input
47 47 type="text"
48 48 placeholder="Vendedor"
49 49 class="form-control"
50   - ng-model="idUsuarioInput"
  50 + ng-model="idVendedorInput"
51 51 ng-keypress="search($event.keyCode)"
52   - foca-focus="idUsuario == -1"
  52 + foca-focus="idVendedor == -1"
53 53 >
54 54 </div>
55 55 </div>
src/views/foca-modal-crear-hoja-ruta.html
1 1 <div class="modal-header">
2 2 <h4>-en desarrollo</h4>
3 3 <h4>Confeccionar hoja de ruta</h4>
4   - Hoja de ruta Nº <strong ng-bind="[numero, sucursal] | comprobante"></strong>
  4 + Hoja de ruta Nº <strong ng-bind="[numero, sucursal] | comprobante"></strong>
  5 + Fecha:
  6 + <input
  7 + type="date"
  8 + ng-model="now"
  9 + class="form-control form-control-sm col-3 float-right"
  10 + />
5 11 <br>
6 12 </div>
7 13 <div class="modal-body">
... ... @@ -69,15 +75,16 @@
69 75 </tr>
70 76 </thead>
71 77 <tbody>
  78 + <tr ng-show="!remitos.length">
  79 + <td colspan="3">
  80 + No se han encontrado remitos.
  81 + </td>
  82 + </tr>
72 83 <tr ng-repeat="remito in remitos">
73 84 <td ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante"></td>
74 85 <td ng-bind="remito.nombreCliente"></td>
75 86 <td ng-bind="remito.domicilioStamp"></td>
76   - </tr>
77   - <!-- <tr>
78   - <td>Remito ejemplo</td>
79   - <td>Domicilio ejemplo</td>
80   - </tr> -->
  87 + </tr>
81 88 </tbody>
82 89 </table>
83 90 </div>
... ... @@ -91,6 +98,6 @@
91 98 class="btn btn-sm btn-primary"
92 99 ladda="cargando"
93 100 type="button"
94   - ng-disabled="!formHojaRuta.$valid"
  101 + ng-disabled="!formHojaRuta.$valid || !remitos.length"
95 102 ng-click="aceptar()">Crear hoja ruta</button>
96 103 </div>