Commit 1d2adb367a9815069da88c6550b961ba9db886df
1 parent
b8ddc3d451
Exists in
master
and in
2 other branches
cambios mobile
Showing
2 changed files
with
64 additions
and
36 deletions
 
Show diff stats
src/js/controller.js
| 1 | angular.module('focaModalDetalleHojaRuta') | 1 | angular.module('focaModalDetalleHojaRuta') | 
| 2 | .controller('focaModalDetalleHojaRutaController', | 2 | .controller('focaModalDetalleHojaRutaController', | 
| 3 | [ | 3 | [ | 
| 4 | '$filter', | 4 | '$filter', | 
| 5 | '$scope', | 5 | '$scope', | 
| 6 | '$uibModalInstance', | 6 | '$uibModalInstance', | 
| 7 | 'idRemito', | 7 | 'parametros', | 
| 8 | 'focaModalDetalleHojaRutaService', | 8 | 'focaModalDetalleHojaRutaService', | 
| 9 | 'focaModalService', | 9 | 'focaModalService', | 
| 10 | 'focaSeguimientoService', | 10 | 'focaSeguimientoService', | 
| 11 | '$uibModal', | 11 | '$uibModal', | 
| 12 | function($filter, $scope, $uibModalInstance, idRemito, focaModalDetalleHojaRutaService, | 12 | function($filter, $scope, $uibModalInstance, parametros, focaModalDetalleHojaRutaService, | 
| 13 | focaModalService, focaSeguimientoService, $uibModal) | 13 | focaModalService, focaSeguimientoService, $uibModal) | 
| 14 | { | 14 | { | 
| 15 | //Seteo variables | 15 | //Seteo variables | 
| 16 | $scope.remito = {}; | 16 | $scope.remito = parametros.remito; | 
| 17 | $scope.cisternas = []; | 17 | $scope.cisternas = parametros.remito.cisternas; | 
| 18 | $scope.articuloSeleccionado = {}; | 18 | $scope.articuloSeleccionado = {}; | 
| 19 | $scope.aDescargar = []; | 19 | $scope.aDescargar = []; | 
| 20 | $scope.cargando = true; | 20 | $scope.cargando = false; | 
| 21 | 21 | ||
| 22 | //Datos | 22 | //Datos | 
| 23 | var promesaRemito = focaModalDetalleHojaRutaService | 23 | // var promesaRemito = focaModalDetalleHojaRutaService | 
| 24 | .getRemitoById(idRemito); | 24 | // .getRemitoById(idRemito); | 
| 25 | var promesaCisternas = focaModalDetalleHojaRutaService | 25 | // var promesaCisternas = focaModalDetalleHojaRutaService | 
| 26 | .getCisternasByIdRemito(idRemito); | 26 | // .getCisternasByIdRemito(idRemito); | 
| 27 | 27 | ||
| 28 | Promise.all([promesaRemito, promesaCisternas]).then(function(res) { | 28 | // Promise.all([promesaRemito, promesaCisternas]).then(function(res) { | 
| 29 | $scope.cargando = false; | 29 | // $scope.cargando = false; | 
| 30 | $scope.remito = res[0].data; | 30 | // $scope.remito = res[0].data; | 
| 31 | $scope.cisternas = res[1].data; | 31 | // $scope.cisternas = res[1].data; | 
| 32 | var articuloAChequear = $scope.remito.articulosRemito.filter( | 32 | // var articuloAChequear = $scope.remito.articulosRemito.filter( | 
| 33 | function(articulo) { | 33 | // function(articulo) { | 
| 34 | return !articulo.descargado; | 34 | // return !articulo.descargado; | 
| 35 | }); | 35 | // }); | 
| 36 | if(!articuloAChequear.length || $scope.remito.rechazado) { | 36 | // if(!articuloAChequear.length || $scope.remito.rechazado) { | 
| 37 | $scope.readonly = true; | 37 | // $scope.readonly = true; | 
| 38 | $scope.cambio($scope.remito.articulosRemito[0]); | 38 | // $scope.cambio($scope.remito.articulosRemito[0]); | 
| 39 | }else { | 39 | // }else { | 
| 40 | $scope.cambio(articuloAChequear[0]); | 40 | // $scope.cambio(articuloAChequear[0]); | 
| 41 | } | 41 | // } | 
| 42 | $scope.$digest(); | 42 | // $scope.$digest(); | 
| 43 | }, function() { | 43 | // }, function() { | 
| 44 | focaModalService.alert('El servicio no responde intente más tarde'); | 44 | // focaModalService.alert('El servicio no responde intente más tarde'); | 
| 45 | $uibModalInstance.dismiss(); | 45 | // $uibModalInstance.dismiss(); | 
| 46 | }); | 46 | // }); | 
| 47 | $scope.cambio = function(articulo) { | 47 | $scope.cambio = function(articulo) { | 
| 48 | if(!$scope.articuloSeleccionado.descargado) { | 48 | if(!$scope.articuloSeleccionado.descargado) { | 
| 49 | $scope.articuloSeleccionado.cantidadDescargada = 0; | 49 | $scope.articuloSeleccionado.cantidadDescargada = 0; | 
| 50 | } | 50 | } | 
| 51 | $scope.aDescargar = []; | 51 | $scope.aDescargar = []; | 
| 52 | $scope.articuloSeleccionado = articulo; | 52 | $scope.articuloSeleccionado = articulo; | 
| 53 | }; | 53 | }; | 
| 54 | $scope.descargar = function(key) { | 54 | $scope.descargar = function(key) { | 
| 55 | if(key === 13) { | 55 | if(key === 13) { | 
| 56 | $scope.cargando = true; | 56 | $scope.cargando = true; | 
| 57 | var hojaRutaMovimientos = []; | 57 | var hojaRutaMovimientos = []; | 
| 58 | var cisternaMovimientos = []; | 58 | var cisternaMovimientos = []; | 
| 59 | var cisternaCargas = []; | 59 | var cisternaCargas = []; | 
| 60 | var totalADescargar = 0; | 60 | var totalADescargar = 0; | 
| 61 | for(var i = 0; i < $scope.aDescargar.length; i++) { | 61 | for(var i = 0; i < $scope.aDescargar.length; i++) { | 
| 62 | totalADescargar += $scope.aDescargar[i] || 0; | 62 | totalADescargar += $scope.aDescargar[i] || 0; | 
| 63 | } | 63 | } | 
| 64 | focaModalService | 64 | focaModalService | 
| 65 | .confirm('¿Desea descargar ' + totalADescargar + ' litros de ' + | 65 | .confirm('¿Desea descargar ' + totalADescargar + ' litros de ' + | 
| 66 | $scope.articuloSeleccionado.descripcion + '?') | 66 | $scope.articuloSeleccionado.descripcion + '?') | 
| 67 | .then(descargar, function() { | 67 | .then(descargar, function() { | 
| 68 | $scope.cargando = false; | 68 | $scope.cargando = false; | 
| 69 | }); | 69 | }); | 
| 70 | } | 70 | } | 
| 71 | function descargar() { | 71 | function descargar() { | 
| 72 | for(var i = 0; i < $scope.cisternas.length; i++) { | 72 | for(var i = 0; i < $scope.cisternas.length; i++) { | 
| 73 | var descarga = $scope.aDescargar[i]; | 73 | var descarga = $scope.aDescargar[i]; | 
| 74 | var cisternaCarga = $scope.cisternas[i].cisternaCarga; | 74 | var cisternaCarga = $scope.cisternas[i].cisternaCarga; | 
| 75 | if(!descarga) continue; | 75 | if(!descarga) continue; | 
| 76 | if(descarga > cisternaCarga.cantidad) { | 76 | if(descarga > cisternaCarga.cantidad) { | 
| 77 | focaModalService.alert('La cantidad a descargar no debe ser ' + | 77 | focaModalService.alert('La cantidad a descargar no debe ser ' + | 
| 78 | 'mayor a la cantidad de la cisterna'); | 78 | 'mayor a la cantidad de la cisterna'); | 
| 79 | $scope.cargando = false; | 79 | $scope.cargando = false; | 
| 80 | return; | 80 | return; | 
| 81 | } | 81 | } | 
| 82 | cisternaCarga.cantidad -= descarga; | 82 | cisternaCarga.cantidad -= descarga; | 
| 83 | 83 | ||
| 84 | //Guardar | 84 | //Guardar | 
| 85 | var now = new Date(); | 85 | var now = new Date(); | 
| 86 | var cisternaMovimiento = { | 86 | var cisternaMovimiento = { | 
| 87 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 87 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 
| 88 | cantidad: descarga, | 88 | cantidad: descarga, | 
| 89 | metodo: 'descarga', | 89 | metodo: 'descarga', | 
| 90 | idCisternaCarga: cisternaCarga.id, | 90 | idCisternaCarga: cisternaCarga.id, | 
| 91 | idRemito: $scope.remito.id | 91 | idRemito: $scope.remito.id | 
| 92 | }; | 92 | }; | 
| 93 | var hojaRutaMovimiento = { | 93 | var hojaRutaMovimiento = { | 
| 94 | reciboDescarga: $scope.numeroRecibo, | 94 | reciboDescarga: $scope.numeroRecibo, | 
| 95 | idRemito: $scope.remito.id | 95 | idRemito: $scope.remito.id | 
| 96 | }; | 96 | }; | 
| 97 | delete cisternaCarga.articulo; | 97 | delete cisternaCarga.articulo; | 
| 98 | cisternaCargas.push(cisternaCarga); | 98 | cisternaCargas.push(cisternaCarga); | 
| 99 | cisternaMovimientos.push(cisternaMovimiento); | 99 | cisternaMovimientos.push(cisternaMovimiento); | 
| 100 | hojaRutaMovimientos.push(hojaRutaMovimiento); | 100 | hojaRutaMovimientos.push(hojaRutaMovimiento); | 
| 101 | } | 101 | } | 
| 102 | var save = { | 102 | var save = { | 
| 103 | cisternaCargas: cisternaCargas, | 103 | cisternaCargas: cisternaCargas, | 
| 104 | cisternaMovimientos: cisternaMovimientos, | 104 | cisternaMovimientos: cisternaMovimientos, | 
| 105 | hojaRutaMovimientos: hojaRutaMovimientos, | 105 | hojaRutaMovimientos: hojaRutaMovimientos, | 
| 106 | articulo: $scope.articuloSeleccionado | 106 | articulo: $scope.articuloSeleccionado | 
| 107 | }; | 107 | }; | 
| 108 | |||
| 109 | focaSeguimientoService.obtenerPosicion(getPosition) | ||
| 110 | |||
| 111 | var posicion; | ||
| 112 | |||
| 113 | function getPosition(posicion) { | ||
| 114 | |||
| 115 | posicion = { | ||
| 116 | latitud: posicion.coords.latitude, | ||
| 117 | longitud: posicion.coords.longitude, | ||
| 118 | actividad: 'Entrega de producto', | ||
| 119 | observaciones: $scope.remito.observaciones | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 108 | focaModalDetalleHojaRutaService | 123 | focaModalDetalleHojaRutaService | 
| 109 | .postMovimientoHojaRuta(save) | 124 | .postMovimientoHojaRuta(save) | 
| 110 | .then(guardarSeguimiento) | 125 | .then(guardarSeguimiento) | 
| 111 | .catch(error); | 126 | .catch(error); | 
| 112 | function guardarSeguimiento(res) { | 127 | function guardarSeguimiento(res) { | 
| 113 | focaSeguimientoService | 128 | |
| 114 | .guardarPosicion( | 129 | posicion.idComprobante = res.data[0].id; | 
| 115 | 'Entrega de producto', | 130 | focaModalDetalleHojaRutaService.guardarPosicion(posicion) | 
| 116 | res.data[0].id, | 131 | |
| 117 | $scope.remito.observaciones); | ||
| 118 | $scope.aDescargar = []; | 132 | $scope.aDescargar = []; | 
| 119 | $scope.remito.observaciones = ''; | 133 | $scope.remito.observaciones = ''; | 
| 120 | $scope.articuloSeleccionado.descargado = true; | 134 | $scope.articuloSeleccionado.descargado = true; | 
| 121 | var siguienteArticulo = $scope.remito.articulosRemito.filter( | 135 | var siguienteArticulo = $scope.remito.articulosRemito.filter( | 
| 122 | function(articulo) { | 136 | function(articulo) { | 
| 123 | return articulo.id != $scope.articuloSeleccionado.id; | 137 | return articulo.id != $scope.articuloSeleccionado.id; | 
| 124 | } | 138 | } | 
| 125 | ); | 139 | ); | 
| 126 | if(siguienteArticulo.length) { | 140 | if(siguienteArticulo.length) { | 
| 127 | $scope.cambio(siguienteArticulo[0]); | 141 | $scope.cambio(siguienteArticulo[0]); | 
| 128 | } | 142 | } | 
| 129 | $scope.actualizarPuntoDescarga(); | 143 | $scope.actualizarPuntoDescarga(); | 
| 130 | } | 144 | } | 
| 131 | } | 145 | } | 
| 132 | }; | 146 | }; | 
| 133 | 147 | ||
| 134 | $scope.cancel = function() { | 148 | $scope.cancel = function() { | 
| 135 | $uibModalInstance.dismiss('cancel'); | 149 | $uibModalInstance.dismiss('cancel'); | 
| 136 | }; | 150 | }; | 
| 137 | 151 | ||
| 138 | $scope.distribucionDisponible = function() { | 152 | $scope.distribucionDisponible = function() { | 
| 139 | return $scope.articuloSeleccionado.cantidadDescargada && | 153 | return $scope.articuloSeleccionado.cantidadDescargada && | 
| 140 | $scope.articuloSeleccionado.cantidadDescargada <= | 154 | $scope.articuloSeleccionado.cantidadDescargada <= | 
| 141 | $scope.articuloSeleccionado.cantidad; | 155 | $scope.articuloSeleccionado.cantidad; | 
| 142 | }; | 156 | }; | 
| 143 | 157 | ||
| 144 | $scope.actualizarArticulo = function() { | 158 | $scope.actualizarArticulo = function() { | 
| 145 | $scope.articuloSeleccionado.cantidadDescargada = 0; | 159 | $scope.articuloSeleccionado.cantidadDescargada = 0; | 
| 146 | for(var i = 0; i < $scope.aDescargar.length; i++) { | 160 | for(var i = 0; i < $scope.aDescargar.length; i++) { | 
| 147 | $scope.articuloSeleccionado.cantidadDescargada += | 161 | $scope.articuloSeleccionado.cantidadDescargada += | 
| 148 | parseFloat($scope.aDescargar[i]) || 0; | 162 | parseFloat($scope.aDescargar[i]) || 0; | 
| 149 | } | 163 | } | 
| 150 | }; | 164 | }; | 
| 151 | 165 | ||
| 152 | $scope.actualizarPuntoDescarga = function() { | 166 | $scope.actualizarPuntoDescarga = function() { | 
| 153 | var modalInstance = $uibModal.open( | 167 | var modalInstance = $uibModal.open( | 
| 154 | { | 168 | { | 
| 155 | ariaLabelledBy: 'Actualizar punto de descarga', | 169 | ariaLabelledBy: 'Actualizar punto de descarga', | 
| 156 | templateUrl: 'modal-actualizar-punto-descarga.html', | 170 | templateUrl: 'modal-actualizar-punto-descarga.html', | 
| 157 | controller: 'focaModalActualizarPuntoDescargaController', | 171 | controller: 'focaModalActualizarPuntoDescargaController', | 
| 158 | resolve: { | 172 | resolve: { | 
| 159 | notaPedido: function() { | 173 | notaPedido: function() { | 
| 160 | return $scope.remito.notaPedido; | 174 | return $scope.remito.notaPedido; | 
| 161 | } | 175 | } | 
| 162 | }, | 176 | }, | 
| 163 | size: 'lg' | 177 | size: 'lg' | 
| 164 | } | 178 | } | 
| 165 | ); | 179 | ); | 
| 166 | modalInstance.result.then(function() { | 180 | modalInstance.result.then(function() { | 
| 167 | success(); | 181 | success(); | 
| 168 | }, function() { | 182 | }, function() { | 
| 169 | success(); | 183 | success(); | 
| 170 | }); | 184 | }); | 
| 171 | }; | 185 | }; | 
| 172 | 186 | ||
| 173 | $scope.rechazar = function() { | 187 | $scope.rechazar = function() { | 
| 174 | focaModalService | 188 | focaModalService | 
| 175 | .prompt({ | 189 | .prompt({ | 
| 176 | titulo: 'Aclare el motivo de rechazo' | 190 | titulo: 'Aclare el motivo de rechazo' | 
| 177 | }) | 191 | }) | 
| 178 | .then(function(motivo) { | 192 | .then(function(motivo) { | 
| 179 | $scope.cargando = true; | 193 | $scope.cargando = true; | 
| 180 | var remitoRechazado = $.extend(true, {}, $scope.remito); | 194 | var remitoRechazado = $.extend(true, {}, $scope.remito); | 
| 181 | delete remitoRechazado.articulosRemito; | 195 | delete remitoRechazado.articulosRemito; | 
| 182 | delete remitoRechazado.notaPedido; | 196 | delete remitoRechazado.notaPedido; | 
| 183 | remitoRechazado.rechazado = true; | 197 | remitoRechazado.rechazado = true; | 
| 184 | remitoRechazado.motivoRechazo = motivo; | 198 | remitoRechazado.motivoRechazo = motivo; | 
| 185 | remitoRechazado.fechaRemito = | 199 | remitoRechazado.fechaRemito = | 
| 186 | remitoRechazado.fechaRemito.slice(0, 19).replace('T', ' '); | 200 | remitoRechazado.fechaRemito.slice(0, 19).replace('T', ' '); | 
| 187 | focaModalDetalleHojaRutaService.rechazarRemito(remitoRechazado) | 201 | focaModalDetalleHojaRutaService.rechazarRemito(remitoRechazado) | 
| 188 | .then(function(res) { | 202 | .then(function(res) { | 
| 189 | focaSeguimientoService.guardarPosicion( | 203 | focaSeguimientoService.guardarPosicion( | 
| 190 | 'Entrega de producto', | 204 | 'Entrega de producto', | 
| 191 | res.data[1].id, | 205 | res.data[1].id, | 
| 192 | motivo); | 206 | motivo); | 
| 193 | success(); | 207 | success(); | 
| 194 | }) | 208 | }) | 
| 195 | .catch(error); | 209 | .catch(error); | 
| 196 | $scope.readonly = true; | 210 | $scope.readonly = true; | 
| 197 | }); | 211 | }); | 
| 198 | }; | 212 | }; | 
| 199 | 213 | ||
| 200 | //funciones | 214 | //funciones | 
| 201 | function error(error) { | 215 | function error(error) { | 
| 202 | focaModalService.alert('Hubo un error ' + error); | 216 | focaModalService.alert('Hubo un error ' + error); | 
| 203 | } | 217 | } | 
| 204 | function success() { | 218 | function success() { | 
| 205 | focaModalService.alert('Operación realizada con éxito'); | 219 | focaModalService.alert('Operación realizada con éxito'); | 
| 206 | $scope.cargando = false; | 220 | $scope.cargando = false; | 
| 207 | } | 221 | } | 
| 222 | |||
| 223 | var articuloAChequear = $scope.remito.articulosRemito.filter( | ||
| 224 | function(articulo) { | ||
| 225 | return !articulo.descargado; | ||
| 226 | }); | ||
| 227 | if (!articuloAChequear.length || $scope.remito.rechazado) { | ||
| 228 | $scope.readonly = true; | ||
| 229 | $scope.cambio($scope.remito.articulosRemito[0]); | ||
| 230 | } else { | ||
| 231 | $scope.cambio(articuloAChequear[0]); | ||
| 232 | } | ||
| 208 | } | 233 | } | 
| 209 | ] | 234 | ] | 
| 210 | ) | 235 | ) | 
| 211 | .controller('focaModalActualizarPuntoDescargaController', | 236 | .controller('focaModalActualizarPuntoDescargaController', | 
| 212 | [ | 237 | [ | 
| 213 | '$scope', | 238 | '$scope', | 
| 214 | '$uibModalInstance', | 239 | '$uibModalInstance', | 
| 215 | 'focaSeguimientoService', | 240 | 'focaSeguimientoService', | 
| 216 | 'focaModalService', | 241 | 'focaModalService', | 
| 217 | 'notaPedido', | 242 | 'notaPedido', | 
| 218 | 'focaModalDetalleHojaRutaService', | 243 | 'focaModalDetalleHojaRutaService', | 
| 219 | function($scope, $uibModalInstance, focaSeguimientoService, | 244 | function($scope, $uibModalInstance, focaSeguimientoService, | 
| 220 | focaModalService, notaPedido, focaModalDetalleHojaRutaService) | 245 | focaModalService, notaPedido, focaModalDetalleHojaRutaService) | 
| 221 | { | 246 | { | 
| 222 | $scope.notaPedido = notaPedido; | 247 | $scope.notaPedido = notaPedido; | 
| 223 | $scope.descripcion = ''; | 248 | $scope.descripcion = ''; | 
| 224 | focaSeguimientoService.obtenerPosicion(function(res) { | 249 | focaSeguimientoService.obtenerPosicion(function(res) { | 
| 225 | $scope.posicion = res.coords; | 250 | $scope.posicion = res.coords; | 
| 226 | }); | 251 | }); | 
| 227 | 252 | ||
| 228 | $scope.cancel = function() { | 253 | $scope.cancel = function() { | 
| 229 | if ($scope.ingreso) { | 254 | if ($scope.ingreso) { | 
| 230 | $scope.ingreso = false; | 255 | $scope.ingreso = false; | 
| 231 | } else { | 256 | } else { | 
| 232 | $uibModalInstance.dismiss(); | 257 | $uibModalInstance.dismiss(); | 
| 233 | } | 258 | } | 
| 234 | }; | 259 | }; | 
| 235 | 260 | ||
| 236 | $scope.select = function(puntoDescarga) { | 261 | $scope.select = function(puntoDescarga) { | 
| 237 | if (!$scope.posicion) { | 262 | if (!$scope.posicion) { | 
| 238 | focaModalService.alert('No se pudo obtener la ubicación'); | 263 | focaModalService.alert('No se pudo obtener la ubicación'); | 
| 239 | return; | 264 | return; | 
| 240 | } | 265 | } | 
| 241 | puntoDescarga.latitud = $scope.posicion.latitude; | 266 | puntoDescarga.latitud = $scope.posicion.latitude; | 
| 242 | puntoDescarga.longitud = $scope.posicion.longitude; | 267 | puntoDescarga.longitud = $scope.posicion.longitude; | 
| 243 | focaModalDetalleHojaRutaService | 268 | focaModalDetalleHojaRutaService | 
| 244 | .guardarPuntoDescarga(puntoDescarga) | 269 | .guardarPuntoDescarga(puntoDescarga) | 
| 245 | .then(function(res) { | 270 | .then(function(res) { | 
| 246 | $uibModalInstance.close(res.data); | 271 | $uibModalInstance.close(res.data); | 
| 247 | }); | 272 | }); | 
| 248 | }; | 273 | }; | 
| 249 | 274 | ||
| 250 | $scope.guardar = function() { | 275 | $scope.guardar = function() { | 
| 251 | if (!$scope.posicion) { | 276 | if (!$scope.posicion) { | 
| 252 | focaModalService.alert('No se pudo obtener la ubicación'); | 277 | focaModalService.alert('No se pudo obtener la ubicación'); | 
| 253 | return; | 278 | return; | 
| 254 | } | 279 | } | 
| 255 | focaModalDetalleHojaRutaService | 280 | focaModalDetalleHojaRutaService | 
| 256 | .guardarPuntoDescarga({ | 281 | .guardarPuntoDescarga({ | 
| 257 | id: 0, | 282 | id: 0, | 
| 258 | id_cliente: $scope.notaPedido.idCliente, | 283 | id_cliente: $scope.notaPedido.idCliente, | 
| 259 | id_da_config_0: $scope.notaPedido.idDomicilio, | 284 | id_da_config_0: $scope.notaPedido.idDomicilio, | 
| 260 | descripcion: $scope.descripcion, | 285 | descripcion: $scope.descripcion, | 
| 261 | latitud: $scope.posicion.latitude, | 286 | latitud: $scope.posicion.latitude, | 
| 262 | longitud: $scope.posicion.longitude | 287 | longitud: $scope.posicion.longitude | 
| 263 | }) | 288 | }) | 
| 264 | .then(function(res) { | 289 | .then(function(res) { | 
| 265 | $uibModalInstance.close(res.data); | 290 | $uibModalInstance.close(res.data); | 
| 266 | }); | 291 | }); | 
| 267 | 292 | ||
| 268 | }; | 293 | }; | 
| 269 | 294 | ||
| 270 | } | 295 | } | 
| 271 | ] | 296 | ] | 
| 272 | ); | 297 | ); | 
src/js/service.js
| 1 | angular.module('focaModalDetalleHojaRuta') | 1 | angular.module('focaModalDetalleHojaRuta') | 
| 2 | .service('focaModalDetalleHojaRutaService', [ | 2 | .service('focaModalDetalleHojaRutaService', [ | 
| 3 | '$http', | 3 | '$http', | 
| 4 | 'API_ENDPOINT', | 4 | 'API_ENDPOINT', | 
| 5 | function($http, API_ENDPOINT) { | 5 | function($http, API_ENDPOINT) { | 
| 6 | return { | 6 | return { | 
| 7 | getDetallesHojaRuta: function() { | 7 | getDetallesHojaRuta: function() { | 
| 8 | return $http.get(API_ENDPOINT.URL + '/transportista'); | 8 | return $http.get(API_ENDPOINT.URL + '/transportista'); | 
| 9 | }, | 9 | }, | 
| 10 | getCisternasByIdRemito: function(idRemito) { | 10 | getCisternasByIdRemito: function(idRemito) { | 
| 11 | return $http.get(API_ENDPOINT.URL + '/cisternas/obtener/remito/' + idRemito); | 11 | return $http.get(API_ENDPOINT.URL + '/cisternas/obtener/remito/' + idRemito); | 
| 12 | }, | 12 | }, | 
| 13 | getRemitoById: function(idRemito) { | 13 | getRemitoById: function(idRemito) { | 
| 14 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito + '/punto'); | 14 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito + '/punto'); | 
| 15 | }, | 15 | }, | 
| 16 | postMovimientoHojaRuta: function(datos) { | 16 | postMovimientoHojaRuta: function(datos) { | 
| 17 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta/movimiento', datos); | 17 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta/movimiento', datos); | 
| 18 | }, | 18 | }, | 
| 19 | rechazarRemito: function(remito) { | 19 | rechazarRemito: function(remito) { | 
| 20 | return $http.post(API_ENDPOINT.URL + '/remito/rechazar', {remito: remito}); | 20 | return $http.post(API_ENDPOINT.URL + '/remito/rechazar', {remito: remito}); | 
| 21 | }, | 21 | }, | 
| 22 | guardarPuntoDescarga: function(puntoDescarga) { | 22 | guardarPuntoDescarga: function(puntoDescarga) { | 
| 23 | return $http.post(API_ENDPOINT.URL + '/punto-descarga', | 23 | return $http.post(API_ENDPOINT.URL + '/punto-descarga', | 
| 24 | {puntoDescarga: puntoDescarga}); | 24 | {puntoDescarga: puntoDescarga}); | 
| 25 | }, | ||
| 26 | guardarPosicion: function(posicion) { | ||
| 27 | return $http.post(API_ENDPOINT.URL + '/seguimiento', posicion); | ||
| 25 | } | 28 | } | 
| 26 | }; | 29 | }; | 
| 27 | } | 30 | } | 
| 28 | ]); | 31 | ]); | 
| 29 | 32 |