Commit ee49b766600bfda5f19d326d70c9a8bf7db6f31d
Exists in
master
Merge branch 'master' into 'develop'
Master See merge request !62
Showing
2 changed files
Show diff stats
src/js/controller.js
| 1 | angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', | 1 | angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | '$timeout', | 7 | '$timeout', |
| 8 | 'focaCrearHojaRutaService', | 8 | 'focaCrearHojaRutaService', |
| 9 | 'focaModalService', | 9 | 'focaModalService', |
| 10 | 'focaBotoneraLateralService', | 10 | 'focaBotoneraLateralService', |
| 11 | 'focaLoginService', | 11 | 'focaLoginService', |
| 12 | '$localStorage', | 12 | '$localStorage', |
| 13 | 'hojaRutaBusinessService', | 13 | 'hojaRutaBusinessService', |
| 14 | '$cookies', | 14 | '$cookies', |
| 15 | function ($scope, $uibModal, $location, $filter, $timeout, | 15 | function ($scope, $uibModal, $location, $filter, $timeout, |
| 16 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, | 16 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, |
| 17 | focaLoginSrv, $localStorage, hojaRutaBusinessService, $cookies) { | 17 | focaLoginSrv, $localStorage, hojaRutaBusinessService, $cookies) { |
| 18 | config(); | 18 | config(); |
| 19 | 19 | ||
| 20 | function config() { | 20 | function config() { |
| 21 | 21 | ||
| 22 | $scope.botoneraPrincipal = focaCrearHojaRutaService.getBotones(); | 22 | $scope.botoneraPrincipal = focaCrearHojaRutaService.getBotones(); |
| 23 | $scope.botonera = []; | 23 | $scope.botonera = []; |
| 24 | $scope.datepickerAbierto = false; | 24 | $scope.datepickerAbierto = false; |
| 25 | $scope.show = false; | 25 | $scope.show = false; |
| 26 | $scope.cisternaCargas = []; | 26 | $scope.cisternaCargas = []; |
| 27 | $scope.cargando = true; | 27 | $scope.cargando = true; |
| 28 | $scope.articulos = []; | 28 | $scope.articulos = []; |
| 29 | $scope.remito = { | 29 | $scope.remito = { |
| 30 | id: '', | 30 | id: '', |
| 31 | numeroRemito: '' | 31 | numeroRemito: '' |
| 32 | }; | 32 | }; |
| 33 | $scope.now = new Date(); | 33 | $scope.now = new Date(); |
| 34 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 34 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 35 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 35 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 36 | 36 | ||
| 37 | //SETEO BOTONERA LATERAL | 37 | //SETEO BOTONERA LATERAL |
| 38 | $timeout(function () { | 38 | $timeout(function () { |
| 39 | focaBotoneraLateralService.showSalir(false); | 39 | focaBotoneraLateralService.showSalir(false); |
| 40 | focaBotoneraLateralService.showPausar(true); | 40 | focaBotoneraLateralService.showPausar(true); |
| 41 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); | 41 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
| 42 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 42 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 43 | }); | 43 | }); |
| 44 | 44 | ||
| 45 | focaCrearHojaRutaService.getParametros().then(function (res) { | 45 | focaCrearHojaRutaService.getParametros().then(function (res) { |
| 46 | 46 | ||
| 47 | var parametros = JSON.parse(res.data[0].jsonText); | 47 | var parametros = JSON.parse(res.data[0].jsonText); |
| 48 | 48 | ||
| 49 | if ($localStorage.hojaRuta) { | 49 | $timeout(function () { |
| 50 | $timeout(function () { getLSHojaRuta(); }); | 50 | getLSBotoneraPrincipal(); |
| 51 | }); | ||
| 52 | |||
| 53 | if ($localStorage.data) { | ||
| 54 | $timeout(function () { | ||
| 55 | getLSHojaRuta(); | ||
| 56 | }); | ||
| 57 | |||
| 51 | } else { | 58 | } else { |
| 52 | for (var property in parametros) { | 59 | for (var property in parametros) { |
| 53 | $scope.hojaRuta[property] = parametros[property]; | 60 | $scope.hojaRuta[property] = parametros[property]; |
| 54 | $scope.inicial[property] = parametros[property]; | 61 | $scope.inicial[property] = parametros[property]; |
| 55 | } | 62 | } |
| 56 | //Setear Hoja de Ruta | 63 | //Setear Hoja de Ruta |
| 57 | //setearHojaRuta($scope.hojaRuta); | 64 | //setearHojaRuta($scope.hojaRuta); |
| 58 | } | 65 | } |
| 59 | }); | 66 | }); |
| 60 | init(); | 67 | init(); |
| 61 | } | 68 | } |
| 62 | function init() { | 69 | function init() { |
| 63 | $scope.$broadcast('cleanCabecera'); | 70 | $scope.$broadcast('cleanCabecera'); |
| 64 | 71 | ||
| 65 | $scope.hojaRuta = { | 72 | $scope.hojaRuta = { |
| 66 | fecha: new Date(), | 73 | fecha: new Date(), |
| 67 | litros: 0, | 74 | litros: 0, |
| 68 | chofer: {}, | 75 | chofer: {}, |
| 69 | vehiculo: { | 76 | vehiculo: { |
| 70 | capacidad: 0 | 77 | capacidad: 0 |
| 71 | }, | 78 | }, |
| 72 | transportista: {}, | 79 | transportista: {}, |
| 73 | remitosTabla: [] | 80 | remitosTabla: [] |
| 74 | }; | 81 | }; |
| 75 | $scope.idLista = undefined; | 82 | $scope.idLista = undefined; |
| 76 | 83 | ||
| 77 | focaCrearHojaRutaService.getNumeroHojaRuta().then( | 84 | focaCrearHojaRutaService.getNumeroHojaRuta().then( |
| 78 | function (res) { | 85 | function (res) { |
| 79 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); | 86 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); |
| 80 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); | 87 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); |
| 81 | }, | 88 | }, |
| 82 | function (err) { | 89 | function (err) { |
| 83 | focaModalService.alert('La terminal no esta configurada correctamente'); | 90 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 84 | console.info(err); | 91 | console.info(err); |
| 85 | } | 92 | } |
| 86 | ); | 93 | ); |
| 87 | setearFecha(new Date()); | 94 | setearFecha(new Date()); |
| 88 | $scope.inicial = angular.copy($scope.hojaRuta); | 95 | $scope.inicial = angular.copy($scope.hojaRuta); |
| 89 | } | 96 | } |
| 90 | 97 | ||
| 91 | // $scope.$watch('hojaRuta', function(newValue) { | 98 | $scope.$watchGroup(['hojaRuta','precargado','cargaRemito','remitoAbierto'], function(newValues) { |
| 92 | 99 | focaBotoneraLateralService.setPausarData( | |
| 93 | // // Seteo checked en remitos | 100 | { |
| 94 | // if ($scope.hojaRuta.remitosTabla.length) { | 101 | label: 'data', |
| 95 | // $filter('filter')($scope.botonera, { | 102 | val: newValues |
| 96 | // label: 'Remitos', | 103 | } |
| 97 | // })[0].checked = true; | 104 | ); |
| 98 | // } else { | 105 | }); |
| 99 | // $filter('filter')($scope.botonera, { | ||
| 100 | // label: 'Remitos', | ||
| 101 | // })[0].checked = false; | ||
| 102 | // } | ||
| 103 | |||
| 104 | // focaBotoneraLateralService.setPausarData({ | ||
| 105 | // label: 'hojaRuta', | ||
| 106 | // val: newValue | ||
| 107 | // }); | ||
| 108 | // }, true); | ||
| 109 | 106 | ||
| 110 | $scope.seleccionarRemitoAbierto = function () { | 107 | $scope.seleccionarRemitoAbierto = function () { |
| 111 | $scope.remitoAbierto = true; | 108 | $scope.remitoAbierto = true; |
| 112 | $scope.cargaRemito = false; | 109 | $scope.cargaRemito = false; |
| 113 | $scope.precargado = false; | 110 | $scope.precargado = false; |
| 114 | 111 | ||
| 115 | var isBotoneraDirty = $scope.botonera.find(function (boton) { | 112 | var isBotoneraDirty = $scope.botonera.find(function (boton) { |
| 116 | return boton.checked; | 113 | return boton.checked; |
| 117 | }); | 114 | }); |
| 118 | 115 | ||
| 119 | config(); | 116 | config(); |
| 120 | 117 | ||
| 121 | if (isBotoneraDirty) { | 118 | if (isBotoneraDirty) { |
| 122 | $scope.$broadcast('cleanCabecera'); | 119 | $scope.$broadcast('cleanCabecera'); |
| 123 | focaModalService.confirm('Se perderan los cambios') | 120 | focaModalService.confirm('Se perderan los cambios') |
| 124 | .then(function () { | 121 | .then(function () { |
| 125 | limpiarBotonera($scope.botonera); | 122 | limpiarBotonera($scope.botonera); |
| 126 | limpiarBotonera($scope.botoneraPrincipal); | 123 | limpiarBotonera($scope.botoneraPrincipal); |
| 127 | $filter('filter')($scope.botoneraPrincipal, { | 124 | $filter('filter')($scope.botoneraPrincipal, { |
| 128 | label: 'Remito Abierto', | 125 | label: 'Remito Abierto', |
| 129 | })[0].checked = true; | 126 | })[0].checked = true; |
| 130 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | 127 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 131 | |||
| 132 | }); | 128 | }); |
| 133 | } else { | 129 | } else { |
| 134 | $scope.$broadcast('cleanCabecera'); | 130 | $scope.$broadcast('cleanCabecera'); |
| 135 | limpiarBotonera($scope.botoneraPrincipal); | 131 | limpiarBotonera($scope.botoneraPrincipal); |
| 136 | $filter('filter')($scope.botoneraPrincipal, { | 132 | $filter('filter')($scope.botoneraPrincipal, { |
| 137 | label: 'Remito Abierto', | 133 | label: 'Remito Abierto', |
| 138 | })[0].checked = true; | 134 | })[0].checked = true; |
| 139 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | 135 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 140 | 136 | ||
| 141 | } | 137 | } |
| 142 | 138 | ||
| 143 | $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto(); | 139 | $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto(); |
| 144 | }; | 140 | }; |
| 145 | 141 | ||
| 146 | $scope.seleccionarCargarRemitos = function () { | 142 | $scope.seleccionarCargarRemitos = function () { |
| 147 | $scope.cargaRemito = true; | 143 | $scope.cargaRemito = true; |
| 148 | $scope.remitoAbierto = false; | 144 | $scope.remitoAbierto = false; |
| 149 | $scope.precargado = false; | 145 | $scope.precargado = false; |
| 150 | 146 | ||
| 151 | var isBotoneraDirty = $scope.botonera.find(function (boton) { | 147 | var isBotoneraDirty = $scope.botonera.find(function (boton) { |
| 152 | return boton.checked; | 148 | return boton.checked; |
| 153 | }); | 149 | }); |
| 154 | 150 | ||
| 155 | config(); | 151 | config(); |
| 156 | 152 | ||
| 157 | if (isBotoneraDirty) { | 153 | if (isBotoneraDirty) { |
| 158 | $scope.$broadcast('cleanCabecera'); | 154 | $scope.$broadcast('cleanCabecera'); |
| 159 | focaModalService.confirm('Se perderan los cambios') | 155 | focaModalService.confirm('Se perderan los cambios') |
| 160 | .then(function () { | 156 | .then(function () { |
| 161 | limpiarBotonera($scope.botonera); | 157 | limpiarBotonera($scope.botonera); |
| 162 | limpiarBotonera($scope.botoneraPrincipal); | 158 | limpiarBotonera($scope.botoneraPrincipal); |
| 163 | $scope.preCargados = false; | 159 | $scope.preCargados = false; |
| 164 | $filter('filter')($scope.botoneraPrincipal, { | 160 | $filter('filter')($scope.botoneraPrincipal, { |
| 165 | label: 'Cargar Remitos', | 161 | label: 'Cargar Remitos', |
| 166 | })[0].checked = true; | 162 | })[0].checked = true; |
| 167 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | 163 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 168 | }); | 164 | }); |
| 169 | } else { | 165 | } else { |
| 170 | $scope.$broadcast('cleanCabecera'); | 166 | $scope.$broadcast('cleanCabecera'); |
| 171 | limpiarBotonera($scope.botoneraPrincipal); | 167 | limpiarBotonera($scope.botoneraPrincipal); |
| 172 | $filter('filter')($scope.botoneraPrincipal, { | 168 | $filter('filter')($scope.botoneraPrincipal, { |
| 173 | label: 'Cargar Remitos', | 169 | label: 'Cargar Remitos', |
| 174 | })[0].checked = true; | 170 | })[0].checked = true; |
| 175 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | 171 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 176 | } | 172 | } |
| 177 | $scope.precargado = false; | 173 | $scope.precargado = false; |
| 178 | }; | 174 | }; |
| 179 | 175 | ||
| 180 | $scope.seleccionarPrecargados = function () { | 176 | $scope.seleccionarPrecargados = function () { |
| 181 | $scope.precargado = true; | 177 | $scope.precargado = true; |
| 182 | $scope.cargaRemito = false; | 178 | $scope.cargaRemito = false; |
| 183 | $scope.remitoAbierto = false; | 179 | $scope.remitoAbierto = false; |
| 184 | var isBotoneraDirty = $scope.botonera.find(function (boton) { | 180 | var isBotoneraDirty = $scope.botonera.find(function (boton) { |
| 185 | return boton.checked; | 181 | return boton.checked; |
| 186 | }); | 182 | }); |
| 187 | 183 | ||
| 188 | config(); | 184 | config(); |
| 189 | 185 | ||
| 190 | if (isBotoneraDirty) { | 186 | if (isBotoneraDirty) { |
| 191 | focaModalService.confirm('Se perderan los cambios') | 187 | focaModalService.confirm('Se perderan los cambios') |
| 192 | .then(function () { | 188 | .then(function () { |
| 193 | $scope.$broadcast('cleanCabecera'); | 189 | $scope.$broadcast('cleanCabecera'); |
| 194 | limpiarBotonera($scope.botonera); | 190 | limpiarBotonera($scope.botonera); |
| 195 | limpiarBotonera($scope.botoneraPrincipal); | 191 | limpiarBotonera($scope.botoneraPrincipal); |
| 196 | $filter('filter')($scope.botoneraPrincipal, { | 192 | $filter('filter')($scope.botoneraPrincipal, { |
| 197 | label: 'Precargado', | 193 | label: 'Precargado', |
| 198 | })[0].checked = true; | 194 | })[0].checked = true; |
| 199 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | 195 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 200 | }); | 196 | }); |
| 201 | } else { | 197 | } else { |
| 202 | $scope.$broadcast('cleanCabecera'); | 198 | $scope.$broadcast('cleanCabecera'); |
| 203 | limpiarBotonera($scope.botoneraPrincipal); | 199 | limpiarBotonera($scope.botoneraPrincipal); |
| 204 | $filter('filter')($scope.botoneraPrincipal, { | 200 | $filter('filter')($scope.botoneraPrincipal, { |
| 205 | label: 'Precargado', | 201 | label: 'Precargado', |
| 206 | })[0].checked = true; | 202 | })[0].checked = true; |
| 207 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | 203 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 208 | } | 204 | } |
| 209 | }; | 205 | }; |
| 210 | 206 | ||
| 211 | $scope.quitarArticulo = function (key) { | 207 | $scope.quitarArticulo = function (key) { |
| 212 | $scope.articulos.splice(key, 1); | 208 | $scope.articulos.splice(key, 1); |
| 213 | }; | 209 | }; |
| 214 | 210 | ||
| 215 | function validarHojaRuta() { | 211 | function validarHojaRuta() { |
| 216 | if ($scope.precargado) { | 212 | if ($scope.precargado) { |
| 217 | if (!$scope.hojaRuta.chofer.id) { | 213 | if (!$scope.hojaRuta.chofer.id) { |
| 218 | focaModalService.alert('Ingrese Chofer'); | 214 | focaModalService.alert('Ingrese Chofer'); |
| 219 | return false; | 215 | return false; |
| 220 | } | 216 | } |
| 221 | if (!$scope.hojaRuta.vehiculo.id) { | 217 | if (!$scope.hojaRuta.vehiculo.id) { |
| 222 | focaModalService.alert('Ingrese Vehiculo'); | 218 | focaModalService.alert('Ingrese Vehiculo'); |
| 223 | return false; | 219 | return false; |
| 224 | } | 220 | } |
| 225 | if (!$scope.hojaRuta.transportista.COD) { | 221 | if (!$scope.hojaRuta.transportista.COD) { |
| 226 | focaModalService.alert('Ingrese Transportista'); | 222 | focaModalService.alert('Ingrese Transportista'); |
| 227 | return false; | 223 | return false; |
| 228 | } | 224 | } |
| 229 | if (!$scope.hojaRuta.datosExtra) { | 225 | if (!$scope.hojaRuta.datosExtra) { |
| 230 | focaModalService.alert('Ingrese Datos extra'); | 226 | focaModalService.alert('Ingrese Datos extra'); |
| 231 | return false; | 227 | return false; |
| 232 | } | 228 | } |
| 233 | } else if ($scope.cargaRemito) { | 229 | } else if ($scope.cargaRemito) { |
| 234 | if (!$scope.hojaRuta.remitosTabla.length) { | 230 | if (!$scope.hojaRuta.remitosTabla.length) { |
| 235 | focaModalService.alert('Ingrese Remitos'); | 231 | focaModalService.alert('Ingrese Remitos'); |
| 236 | return false; | 232 | return false; |
| 237 | } else if (!$scope.hojaRuta.chofer.id) { | 233 | } else if (!$scope.hojaRuta.chofer.id) { |
| 238 | focaModalService.alert('Ingrese Chofer'); | 234 | focaModalService.alert('Ingrese Chofer'); |
| 239 | return false; | 235 | return false; |
| 240 | } | 236 | } |
| 241 | if (!$scope.hojaRuta.vehiculo.id) { | 237 | if (!$scope.hojaRuta.vehiculo.id) { |
| 242 | focaModalService.alert('Ingrese Vehiculo'); | 238 | focaModalService.alert('Ingrese Vehiculo'); |
| 243 | return false; | 239 | return false; |
| 244 | } | 240 | } |
| 245 | if (!$scope.hojaRuta.transportista.COD) { | 241 | if (!$scope.hojaRuta.transportista.COD) { |
| 246 | focaModalService.alert('Ingrese Transportista'); | 242 | focaModalService.alert('Ingrese Transportista'); |
| 247 | return false; | 243 | return false; |
| 248 | } | 244 | } |
| 249 | if (!$scope.hojaRuta.datosExtra) { | 245 | if (!$scope.hojaRuta.datosExtra) { |
| 250 | focaModalService.alert('Ingrese Datos extra'); | 246 | focaModalService.alert('Ingrese Datos extra'); |
| 251 | return false; | 247 | return false; |
| 252 | } | 248 | } |
| 253 | } else if ($scope.remitoAbierto) { | 249 | } else if ($scope.remitoAbierto) { |
| 254 | if (!$scope.hojaRuta.transportista.COD) { | 250 | if (!$scope.hojaRuta.transportista.COD) { |
| 255 | focaModalService.alert('Ingrese Transportista'); | 251 | focaModalService.alert('Ingrese Transportista'); |
| 256 | return false; | 252 | return false; |
| 257 | } else if (!$scope.hojaRuta.vehiculo.id) { | 253 | } else if (!$scope.hojaRuta.vehiculo.id) { |
| 258 | focaModalService.alert('Ingrese Vehiculo'); | 254 | focaModalService.alert('Ingrese Vehiculo'); |
| 259 | return false; | 255 | return false; |
| 260 | } else if (!$scope.hojaRuta.chofer.id) { | 256 | } else if (!$scope.hojaRuta.chofer.id) { |
| 261 | focaModalService.alert('Ingrese Chofer'); | 257 | focaModalService.alert('Ingrese Chofer'); |
| 262 | return false; | 258 | return false; |
| 263 | } else if (!$scope.hojaRuta.proveedor.COD) { | 259 | } else if (!$scope.hojaRuta.proveedor.COD) { |
| 264 | focaModalService.alert('Ingrese Proveedor'); | 260 | focaModalService.alert('Ingrese Proveedor'); |
| 265 | return false; | 261 | return false; |
| 266 | } else if (!$scope.hojaRuta.cliente.COD) { | 262 | } else if (!$scope.hojaRuta.cliente.COD) { |
| 267 | focaModalService.alert('Ingrese un Cliente'); | 263 | focaModalService.alert('Ingrese un Cliente'); |
| 268 | return; | 264 | return; |
| 269 | } | 265 | } |
| 270 | } | 266 | } |
| 271 | return true; | 267 | return true; |
| 272 | 268 | ||
| 273 | } | 269 | } |
| 274 | 270 | ||
| 275 | function getImporte(propiedad) { | 271 | function getImporte(propiedad) { |
| 276 | var importe = 0; | 272 | var importe = 0; |
| 277 | 273 | ||
| 278 | $scope.articulos.forEach(function (articulo) { | 274 | $scope.articulos.forEach(function (articulo) { |
| 279 | 275 | ||
| 280 | if (articulo[propiedad]) { | 276 | if (articulo[propiedad]) { |
| 281 | importe += articulo[propiedad] * articulo.cantidad; | 277 | importe += articulo[propiedad] * articulo.cantidad; |
| 282 | } | 278 | } |
| 283 | return; | 279 | return; |
| 284 | 280 | ||
| 285 | }); | 281 | }); |
| 286 | 282 | ||
| 287 | return importe; | 283 | return importe; |
| 288 | } | 284 | } |
| 289 | 285 | ||
| 290 | function guardarRemitoAbierto() { | 286 | function guardarRemitoAbierto() { |
| 291 | //guardar nuevo objeto (?) | 287 | //guardar nuevo objeto (?) |
| 292 | var date = new Date(); | 288 | var date = new Date(); |
| 293 | if ($scope.hojaRuta !== null) { | 289 | if ($scope.hojaRuta !== null) { |
| 294 | focaBotoneraLateralService.startGuardar(); | 290 | focaBotoneraLateralService.startGuardar(); |
| 295 | var save = { | 291 | var save = { |
| 296 | remito: { | 292 | remito: { |
| 297 | id: 0, | 293 | id: 0, |
| 298 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 294 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
| 299 | idCliente: $scope.hojaRuta.cliente.COD, | 295 | idCliente: $scope.hojaRuta.cliente.COD, |
| 300 | nombreCliente: $scope.hojaRuta.cliente.NOM, | 296 | nombreCliente: $scope.hojaRuta.cliente.NOM, |
| 301 | cuitCliente: $scope.hojaRuta.cliente.CUIT, | 297 | cuitCliente: $scope.hojaRuta.cliente.CUIT, |
| 302 | idVendedor: $cookies.get('vendedorCobrador'), | 298 | idVendedor: $cookies.get('vendedorCobrador'), |
| 303 | idProveedor: $scope.hojaRuta.proveedor.COD, | 299 | idProveedor: $scope.hojaRuta.proveedor.COD, |
| 304 | idDomicilio: $scope.hojaRuta.idDomicilio || | 300 | idDomicilio: $scope.hojaRuta.idDomicilio || |
| 305 | $scope.hojaRuta.domicilio.id, | 301 | $scope.hojaRuta.domicilio.id, |
| 306 | idCotizacion: $scope.hojaRuta.cotizacion.ID, | 302 | idCotizacion: $scope.hojaRuta.cotizacion.ID, |
| 307 | domicilioStamp: $scope.hojaRuta.domicilioStamp, | 303 | domicilioStamp: $scope.hojaRuta.domicilioStamp, |
| 308 | observaciones: $scope.hojaRuta.observaciones, | 304 | observaciones: $scope.hojaRuta.observaciones, |
| 309 | idListaPrecio: $scope.hojaRuta.cliente.MOD.trim(), | 305 | idListaPrecio: $scope.hojaRuta.cliente.MOD.trim(), |
| 310 | total: getImporte('total') || 0, | 306 | total: getImporte('total') || 0, |
| 311 | descuento: 0,//TODO, | 307 | descuento: 0,//TODO, |
| 312 | importeNeto: getImporte('netoUnitario') || 0, //TODO: arreglar, | 308 | importeNeto: getImporte('netoUnitario') || 0, //TODO: arreglar, |
| 313 | importeExento: getImporte('exentoUnitario'), | 309 | importeExento: getImporte('exentoUnitario'), |
| 314 | importeIva: getImporte('ivaUnitario') || 0, //TODO: arreglar | 310 | importeIva: getImporte('ivaUnitario') || 0, //TODO: arreglar |
| 315 | importeIvaServicios: 0,//TODO | 311 | importeIvaServicios: 0,//TODO |
| 316 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), | 312 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), |
| 317 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), | 313 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), |
| 318 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), | 314 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), |
| 319 | percepcion: 0,//TODO | 315 | percepcion: 0,//TODO |
| 320 | percepcionIva: 0,//TODO | 316 | percepcionIva: 0,//TODO |
| 321 | redondeo: 0,//TODO | 317 | redondeo: 0,//TODO |
| 322 | anulado: false, | 318 | anulado: false, |
| 323 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), | 319 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), |
| 324 | lugar: parseInt($scope.puntoVenta), | 320 | lugar: parseInt($scope.puntoVenta), |
| 325 | cuentaMadre: 0,//TODO | 321 | cuentaMadre: 0,//TODO |
| 326 | cuentaContable: 0,//TODO | 322 | cuentaContable: 0,//TODO |
| 327 | asiento: 0,//TODO | 323 | asiento: 0,//TODO |
| 328 | e_hd: '',//TODO | 324 | e_hd: '',//TODO |
| 329 | c_hd: '', | 325 | c_hd: '', |
| 330 | numeroLiquidoProducto: 0,//TODO | 326 | numeroLiquidoProducto: 0,//TODO |
| 331 | estado: 0, | 327 | estado: 0, |
| 332 | destinoVenta: 0,//TODO | 328 | destinoVenta: 0,//TODO |
| 333 | operacionTipo: 0, //TODO | 329 | operacionTipo: 0, //TODO |
| 334 | }, | 330 | }, |
| 335 | notaPedido: { | 331 | notaPedido: { |
| 336 | id: 0 | 332 | id: 0 |
| 337 | } | 333 | } |
| 338 | }; | 334 | }; |
| 339 | focaCrearHojaRutaService.crearRemito(save).then( | 335 | focaCrearHojaRutaService.crearRemito(save).then( |
| 340 | function (data) { | 336 | function (data) { |
| 341 | focaBotoneraLateralService.endGuardar(true); | 337 | focaBotoneraLateralService.endGuardar(true); |
| 342 | $scope.saveLoading = false; | 338 | $scope.saveLoading = false; |
| 343 | 339 | ||
| 344 | $scope.remito.id = data.data.id; | 340 | $scope.remito.id = data.data.id; |
| 345 | 341 | ||
| 346 | focaCrearHojaRutaService.guardarCisternas({ | 342 | focaCrearHojaRutaService.guardarCisternas({ |
| 347 | cisternaCargas: $scope.cisternaCargas, | 343 | cisternaCargas: $scope.cisternaCargas, |
| 348 | cisternaMovimientos: $scope.cisternaMovimientos, | 344 | cisternaMovimientos: $scope.cisternaMovimientos, |
| 349 | fechaReparto: $scope.hojaRuta.fechaReparto, | 345 | fechaReparto: $scope.hojaRuta.fechaReparto, |
| 350 | idVehiculo: $scope.hojaRuta.vehiculo.id | 346 | idVehiculo: $scope.hojaRuta.vehiculo.id |
| 351 | }, data.data.id); | 347 | }, data.data.id); |
| 352 | $scope.remito.numeroRemito = data.data.numero; | 348 | $scope.remito.numeroRemito = data.data.numero; |
| 353 | 349 | ||
| 354 | // if ($scope.remito.remitoPuntoDescarga.length > 0) { | 350 | // if ($scope.remito.remitoPuntoDescarga.length > 0) { |
| 355 | // remitoBusinessService.addPuntosDescarga(data.data.id, | 351 | // remitoBusinessService.addPuntosDescarga(data.data.id, |
| 356 | // $scope.remito.remitoPuntoDescarga); | 352 | // $scope.remito.remitoPuntoDescarga); |
| 357 | // } | 353 | // } |
| 358 | 354 | ||
| 359 | hojaRutaBusinessService.addArticulos($scope.articulosRecibidos, | 355 | hojaRutaBusinessService.addArticulos($scope.articulosRecibidos, |
| 360 | data.data.id, $scope.hojaRuta.cotizacion.VENDEDOR); | 356 | data.data.id, $scope.hojaRuta.cotizacion.VENDEDOR); |
| 361 | 357 | ||
| 362 | guardarHojaRuta(data.data.id); | 358 | guardarHojaRuta(data.data.id); |
| 363 | 359 | ||
| 364 | }, function (error) { | 360 | }, function (error) { |
| 365 | focaModalService.alert( | 361 | focaModalService.alert( |
| 366 | error.data || 'Hubo un error al crear el remito'); | 362 | error.data || 'Hubo un error al crear el remito'); |
| 367 | focaBotoneraLateralService.endGuardar(); | 363 | focaBotoneraLateralService.endGuardar(); |
| 368 | $scope.saveLoading = false; | 364 | $scope.saveLoading = false; |
| 369 | console.info(error); | 365 | console.info(error); |
| 370 | } | 366 | } |
| 371 | ); | 367 | ); |
| 372 | 368 | ||
| 373 | function guardarHojaRuta(idRemito) { | 369 | function guardarHojaRuta(idRemito) { |
| 374 | 370 | ||
| 375 | var save2 = { | 371 | var save2 = { |
| 376 | hojaRuta: { | 372 | hojaRuta: { |
| 377 | id: 0, | 373 | id: 0, |
| 378 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | 374 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) |
| 379 | .replace('T', ' '), | 375 | .replace('T', ' '), |
| 380 | idTransportista: $scope.hojaRuta.transportista.COD, | 376 | idTransportista: $scope.hojaRuta.transportista.COD, |
| 381 | idChofer: $scope.hojaRuta.chofer.id, | 377 | idChofer: $scope.hojaRuta.chofer.id, |
| 382 | idVehiculo: $scope.hojaRuta.vehiculo.id, | 378 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
| 383 | proveedor: $scope.hojaRuta.proveedor.id, | 379 | proveedor: $scope.hojaRuta.proveedor.id, |
| 384 | fechaReparto: new Date($scope.hojaRuta.fechaReparto) | 380 | fechaReparto: new Date($scope.hojaRuta.fechaReparto) |
| 385 | .toISOString() | 381 | .toISOString() |
| 386 | .substring(0, 10), | 382 | .substring(0, 10), |
| 387 | estado: 0, | 383 | estado: 0, |
| 388 | abierta: 1 | 384 | abierta: 1 |
| 389 | }, | 385 | }, |
| 390 | remitos: [{id: idRemito}] | 386 | remitos: [{id: idRemito}] |
| 391 | }; | 387 | }; |
| 392 | 388 | ||
| 393 | save2.hojaRuta = angular | 389 | save2.hojaRuta = angular |
| 394 | .extend({}, save2.hojaRuta, $scope.hojaRuta.datosExtra); | 390 | .extend({}, save2.hojaRuta, $scope.hojaRuta.datosExtra); |
| 395 | focaCrearHojaRutaService.crearHojaRuta(save2).then( | 391 | focaCrearHojaRutaService.crearHojaRuta(save2).then( |
| 396 | function (data) { | 392 | function (data) { |
| 397 | var remitoNumero; | 393 | var remitoNumero; |
| 398 | data.data.remitos.forEach(function(idRemitos) { | 394 | data.data.remitos.forEach(function(idRemitos) { |
| 399 | remitoNumero = idRemitos; | 395 | remitoNumero = idRemitos; |
| 400 | }); | 396 | }); |
| 401 | focaModalService.alert( | 397 | focaModalService.alert( |
| 402 | 'Hoja ruta creada Nยบ: ' + | 398 | 'Hoja ruta creada Nยบ: ' + |
| 403 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | 399 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + |
| 404 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) + | 400 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) + |
| 405 | '\nRemito Abierto Nยบ: ' + | 401 | '\nRemito Abierto Nยบ: ' + |
| 406 | $filter('rellenarDigitos')(remitoNumero.sucursal, 4) + '-' + | 402 | $filter('rellenarDigitos')(remitoNumero.sucursal, 4) + '-' + |
| 407 | $filter('rellenarDigitos')(remitoNumero.numeroRemito,8) | 403 | $filter('rellenarDigitos')(remitoNumero.numeroRemito,8) |
| 408 | ); | 404 | ); |
| 409 | 405 | ||
| 410 | config(); | 406 | config(); |
| 411 | }, | 407 | }, |
| 412 | function (error) { | 408 | function (error) { |
| 413 | 409 | ||
| 414 | focaModalService | 410 | focaModalService |
| 415 | .alert('Hubo un error al crear la hoja de ruta'); | 411 | .alert('Hubo un error al crear la hoja de ruta'); |
| 416 | 412 | ||
| 417 | console.info(error); | 413 | console.info(error); |
| 418 | } | 414 | } |
| 419 | ); | 415 | ); |
| 420 | } | 416 | } |
| 421 | } | 417 | } |
| 422 | } | 418 | } |
| 423 | 419 | ||
| 424 | $scope.seleccionarCliente = function () { | 420 | $scope.seleccionarCliente = function () { |
| 425 | var modalInstance = $uibModal.open( | 421 | var modalInstance = $uibModal.open( |
| 426 | { | 422 | { |
| 427 | ariaLabelledBy: 'Busqueda de Cliente', | 423 | ariaLabelledBy: 'Busqueda de Cliente', |
| 428 | templateUrl: 'foca-busqueda-cliente-modal.html', | 424 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 429 | controller: 'focaBusquedaClienteModalController', | 425 | controller: 'focaBusquedaClienteModalController', |
| 430 | resolve: { | 426 | resolve: { |
| 431 | vendedor: function () { return null; }, | 427 | vendedor: function () { return null; }, |
| 432 | cobrador: function () { return null; } | 428 | cobrador: function () { return null; } |
| 433 | }, | 429 | }, |
| 434 | size: 'lg' | 430 | size: 'lg' |
| 435 | } | 431 | } |
| 436 | ); | 432 | ); |
| 437 | modalInstance.result.then( | 433 | modalInstance.result.then( |
| 438 | function (cliente) { | 434 | function (cliente) { |
| 439 | $scope.abrirModalDomicilios(cliente); | 435 | $scope.abrirModalDomicilios(cliente); |
| 440 | $scope.cliente = cliente; | 436 | $scope.cliente = cliente; |
| 441 | }, function () { | 437 | }, function () { |
| 442 | } | 438 | } |
| 443 | ); | 439 | ); |
| 444 | }; | 440 | }; |
| 445 | 441 | ||
| 446 | $scope.abrirModalDomicilios = function (cliente) { | 442 | $scope.abrirModalDomicilios = function (cliente) { |
| 447 | var modalInstanceDomicilio = $uibModal.open( | 443 | var modalInstanceDomicilio = $uibModal.open( |
| 448 | { | 444 | { |
| 449 | ariaLabelledBy: 'Busqueda de Domicilios', | 445 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 450 | templateUrl: 'modal-domicilio.html', | 446 | templateUrl: 'modal-domicilio.html', |
| 451 | controller: 'focaModalDomicilioController', | 447 | controller: 'focaModalDomicilioController', |
| 452 | size: 'lg', | 448 | size: 'lg', |
| 453 | resolve: { | 449 | resolve: { |
| 454 | idCliente: function () { return cliente.cod; }, | 450 | idCliente: function () { return cliente.cod; }, |
| 455 | esNuevo: function () { return cliente.esNuevo; } | 451 | esNuevo: function () { return cliente.esNuevo; } |
| 456 | } | 452 | } |
| 457 | } | 453 | } |
| 458 | ); | 454 | ); |
| 459 | modalInstanceDomicilio.result.then( | 455 | modalInstanceDomicilio.result.then( |
| 460 | function (domicilio) { | 456 | function (domicilio) { |
| 461 | $scope.hojaRuta.domicilio = domicilio; | 457 | $scope.hojaRuta.domicilio = domicilio; |
| 462 | $scope.hojaRuta.cliente = { | 458 | $scope.hojaRuta.cliente = { |
| 463 | COD: cliente.cod, | 459 | COD: cliente.cod, |
| 464 | CUIT: cliente.cuit, | 460 | CUIT: cliente.cuit, |
| 465 | NOM: cliente.nom, | 461 | NOM: cliente.nom, |
| 466 | MAIL: cliente.mail, | 462 | MAIL: cliente.mail, |
| 467 | MOD: cliente.mod, | 463 | MOD: cliente.mod, |
| 468 | IVA: cliente.iva, | 464 | IVA: cliente.iva, |
| 469 | VEN: cliente.ven | 465 | VEN: cliente.ven |
| 470 | }; | 466 | }; |
| 471 | focaCrearHojaRutaService.getVendedorById($scope.hojaRuta.cliente.VEN) | 467 | focaCrearHojaRutaService.getVendedorById($scope.hojaRuta.cliente.VEN) |
| 472 | .then(function (res) { | 468 | .then(function (res) { |
| 473 | if (res.data !== '') { | 469 | if (res.data !== '') { |
| 474 | $scope.hojaRuta.vendedor = res.data; | 470 | $scope.hojaRuta.vendedor = res.data; |
| 475 | $scope.$broadcast('addCabecera', { | 471 | $scope.$broadcast('addCabecera', { |
| 476 | label: 'Vendedor:', | 472 | label: 'Vendedor:', |
| 477 | valor: $filter('rellenarDigitos')($scope.hojaRuta.vendedor | 473 | valor: $filter('rellenarDigitos')($scope.hojaRuta.vendedor |
| 478 | .NUM, 3) +' - ' + $scope.hojaRuta.vendedor.NOM | 474 | .NUM, 3) +' - ' + $scope.hojaRuta.vendedor.NOM |
| 479 | }); | 475 | }); |
| 480 | } | 476 | } |
| 481 | var domicilioStamp = | 477 | var domicilioStamp = |
| 482 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 478 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 483 | domicilio.Localidad + ', ' + domicilio.Provincia; | 479 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 484 | $scope.hojaRuta.domicilioStamp = domicilioStamp; | 480 | $scope.hojaRuta.domicilioStamp = domicilioStamp; |
| 485 | $scope.$broadcast('addCabecera', { | 481 | $scope.$broadcast('addCabecera', { |
| 486 | label: 'Cliente:', | 482 | label: 'Cliente:', |
| 487 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | 483 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + |
| 488 | ' - ' + cliente.nom | 484 | ' - ' + cliente.nom |
| 489 | }); | 485 | }); |
| 490 | $scope.$broadcast('addCabecera', { | 486 | $scope.$broadcast('addCabecera', { |
| 491 | label: 'Domicilio:', | 487 | label: 'Domicilio:', |
| 492 | valor: domicilioStamp | 488 | valor: domicilioStamp |
| 493 | }); | 489 | }); |
| 494 | 490 | ||
| 495 | if (domicilio.verPuntos) { | 491 | if (domicilio.verPuntos) { |
| 496 | delete $scope.hojaRuta.domicilio.verPuntos; | 492 | delete $scope.hojaRuta.domicilio.verPuntos; |
| 497 | $scope.seleccionarPuntosDeDescarga(); | 493 | $scope.seleccionarPuntosDeDescarga(); |
| 498 | } else { | 494 | } else { |
| 499 | focaCrearHojaRutaService | 495 | focaCrearHojaRutaService |
| 500 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 496 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
| 501 | .then(function (res) { | 497 | .then(function (res) { |
| 502 | if (res.data.length) { | 498 | if (res.data.length) { |
| 503 | $scope.seleccionarPuntosDeDescarga(); | 499 | $scope.seleccionarPuntosDeDescarga(); |
| 504 | } | 500 | } |
| 505 | }); | 501 | }); |
| 506 | } | 502 | } |
| 507 | 503 | ||
| 508 | $filter('filter')($scope.botonera, { | 504 | $filter('filter')($scope.botonera, { |
| 509 | label: 'Cliente', | 505 | label: 'Cliente', |
| 510 | })[0].checked = true; | 506 | })[0].checked = true; |
| 511 | }) | 507 | }) |
| 512 | .catch(function (e) { console.log(e); }); | 508 | .catch(function (e) { console.log(e); }); |
| 513 | }, function () { | 509 | }, function () { |
| 514 | $scope.seleccionarCliente(true); | 510 | $scope.seleccionarCliente(true); |
| 515 | return; | 511 | return; |
| 516 | } | 512 | } |
| 517 | ); | 513 | ); |
| 518 | }; | 514 | }; |
| 519 | 515 | ||
| 520 | $scope.seleccionarPuntosDeDescarga = function () { | 516 | $scope.seleccionarPuntosDeDescarga = function () { |
| 521 | if (!$scope.hojaRuta.cliente.COD || !$scope.hojaRuta.domicilio.id) { | 517 | if (!$scope.hojaRuta.cliente.COD || !$scope.hojaRuta.domicilio.id) { |
| 522 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 518 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 523 | return; | 519 | return; |
| 524 | } else { | 520 | } else { |
| 525 | var modalInstance = $uibModal.open( | 521 | var modalInstance = $uibModal.open( |
| 526 | { | 522 | { |
| 527 | ariaLabelledBy: 'Bรบsqueda de Puntos de descarga', | 523 | ariaLabelledBy: 'Bรบsqueda de Puntos de descarga', |
| 528 | templateUrl: 'modal-punto-descarga.html', | 524 | templateUrl: 'modal-punto-descarga.html', |
| 529 | controller: 'focaModalPuntoDescargaController', | 525 | controller: 'focaModalPuntoDescargaController', |
| 530 | size: 'lg', | 526 | size: 'lg', |
| 531 | resolve: { | 527 | resolve: { |
| 532 | filters: { | 528 | filters: { |
| 533 | idDomicilio: $scope.remito.domicilio.id, | 529 | idDomicilio: $scope.remito.domicilio.id, |
| 534 | idCliente: $scope.remito.cliente.COD, | 530 | idCliente: $scope.remito.cliente.COD, |
| 535 | articulos: $scope.remito.articulosRemito, | 531 | articulos: $scope.remito.articulosRemito, |
| 536 | puntosDescarga: $scope.remito.remitoPuntoDescarga, | 532 | puntosDescarga: $scope.remito.remitoPuntoDescarga, |
| 537 | domicilio: $scope.remito.domicilio | 533 | domicilio: $scope.remito.domicilio |
| 538 | } | 534 | } |
| 539 | } | 535 | } |
| 540 | } | 536 | } |
| 541 | ); | 537 | ); |
| 542 | modalInstance.result.then( | 538 | modalInstance.result.then( |
| 543 | function(puntosDescarga) { | 539 | function(puntosDescarga) { |
| 544 | 540 | ||
| 545 | puntosDescarga.forEach(function(punto) { | 541 | puntosDescarga.forEach(function(punto) { |
| 546 | $scope.hojaRuta.remitoPuntoDescarga.push( | 542 | $scope.hojaRuta.remitoPuntoDescarga.push( |
| 547 | { | 543 | { |
| 548 | puntoDescarga: punto | 544 | puntoDescarga: punto |
| 549 | } | 545 | } |
| 550 | ); | 546 | ); |
| 551 | }); | 547 | }); |
| 552 | 548 | ||
| 553 | $scope.$broadcast('addCabecera', { | 549 | $scope.$broadcast('addCabecera', { |
| 554 | label: 'Puntos de descarga:', | 550 | label: 'Puntos de descarga:', |
| 555 | valor: getCabeceraPuntoDescarga(puntosDescarga) | 551 | valor: getCabeceraPuntoDescarga(puntosDescarga) |
| 556 | }); | 552 | }); |
| 557 | }, function () { | 553 | }, function () { |
| 558 | $scope.abrirModalDomicilios($scope.cliente); | 554 | $scope.abrirModalDomicilios($scope.cliente); |
| 559 | } | 555 | } |
| 560 | ); | 556 | ); |
| 561 | } | 557 | } |
| 562 | }; | 558 | }; |
| 563 | 559 | ||
| 564 | $scope.seleccionarDetalleDeCarga = function () { | 560 | $scope.seleccionarDetalleDeCarga = function () { |
| 565 | if ($scope.hojaRuta.vehiculo.capacidad === 0) { | 561 | if ($scope.hojaRuta.vehiculo.capacidad === 0) { |
| 566 | focaModalService.alert('Debe ingresar vehiculo'); | 562 | focaModalService.alert('Debe ingresar vehiculo'); |
| 567 | return; | 563 | return; |
| 568 | } else { | 564 | } else { |
| 569 | $scope.mostrarDetalle($scope.hojaRuta); | 565 | $scope.mostrarDetalle($scope.hojaRuta); |
| 570 | } | 566 | } |
| 571 | }; | 567 | }; |
| 572 | 568 | ||
| 573 | function getCabeceraPuntoDescarga(puntosDescarga) { | 569 | function getCabeceraPuntoDescarga(puntosDescarga) { |
| 574 | var puntosStamp = ''; | 570 | var puntosStamp = ''; |
| 575 | puntosDescarga.forEach(function (punto, idx, arr) { | 571 | puntosDescarga.forEach(function (punto, idx, arr) { |
| 576 | puntosStamp += punto.descripcion; | 572 | puntosStamp += punto.descripcion; |
| 577 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 573 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 578 | }); | 574 | }); |
| 579 | return puntosStamp; | 575 | return puntosStamp; |
| 580 | } | 576 | } |
| 581 | 577 | ||
| 582 | $scope.crearHojaRuta = function () { | 578 | $scope.crearHojaRuta = function () { |
| 583 | 579 | ||
| 584 | var continuar = validarHojaRuta(); | 580 | var continuar = validarHojaRuta(); |
| 585 | if (!continuar) { | 581 | if (!continuar) { |
| 586 | return; | 582 | return; |
| 587 | } else if ($scope.remitoAbierto) { | 583 | } else if ($scope.remitoAbierto) { |
| 588 | guardarRemitoAbierto(); | 584 | guardarRemitoAbierto(); |
| 589 | return; | 585 | return; |
| 590 | } | 586 | } |
| 591 | var date = new Date(); | 587 | var date = new Date(); |
| 592 | var save = { | 588 | var save = { |
| 593 | hojaRuta: { | 589 | hojaRuta: { |
| 594 | id: 0, | 590 | id: 0, |
| 595 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | 591 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) |
| 596 | .replace('T', ' '), | 592 | .replace('T', ' '), |
| 597 | idTransportista: $scope.hojaRuta.transportista.COD, | 593 | idTransportista: $scope.hojaRuta.transportista.COD, |
| 598 | idChofer: $scope.hojaRuta.chofer.id, | 594 | idChofer: $scope.hojaRuta.chofer.id, |
| 599 | idVehiculo: $scope.hojaRuta.vehiculo.id, | 595 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
| 600 | tarifaFlete: $scope.hojaRuta.tarifario, | 596 | tarifaFlete: $scope.hojaRuta.tarifario, |
| 601 | fechaReparto: | 597 | fechaReparto: |
| 602 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | 598 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), |
| 603 | estado: 0 | 599 | estado: 0 |
| 604 | }, | 600 | }, |
| 605 | remitos: $scope.hojaRuta.remitosTabla | 601 | remitos: $scope.hojaRuta.remitosTabla |
| 606 | }; | 602 | }; |
| 607 | 603 | ||
| 608 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); | 604 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); |
| 609 | focaCrearHojaRutaService.crearHojaRuta(save).then( | 605 | focaCrearHojaRutaService.crearHojaRuta(save).then( |
| 610 | function (data) { | 606 | function (data) { |
| 611 | focaModalService.alert( | 607 | focaModalService.alert( |
| 612 | 'Hoja ruta creada Nยบ: ' + | 608 | 'Hoja ruta creada Nยบ: ' + |
| 613 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | 609 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + |
| 614 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) | 610 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) |
| 615 | ); | 611 | ); |
| 616 | 612 | ||
| 617 | config(); | 613 | config(); |
| 618 | }, | 614 | }, |
| 619 | function (error) { | 615 | function (error) { |
| 620 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); | 616 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
| 621 | console.info(error); | 617 | console.info(error); |
| 622 | } | 618 | } |
| 623 | ); | 619 | ); |
| 624 | }; | 620 | }; |
| 625 | 621 | ||
| 626 | $scope.seleccionarProveedor = function () { | 622 | $scope.seleccionarProveedor = function () { |
| 627 | var parametrosModal = { | 623 | var parametrosModal = { |
| 628 | titulo: 'Bรบsqueda de Proveedor', | 624 | titulo: 'Bรบsqueda de Proveedor', |
| 629 | query: '/proveedor', | 625 | query: '/proveedor', |
| 630 | columnas: [ | 626 | columnas: [ |
| 631 | { | 627 | { |
| 632 | nombre: 'Cรณdigo', | 628 | nombre: 'Cรณdigo', |
| 633 | propiedad: 'COD', | 629 | propiedad: 'COD', |
| 634 | filtro: { | 630 | filtro: { |
| 635 | nombre: 'rellenarDigitos', | 631 | nombre: 'rellenarDigitos', |
| 636 | parametro: 5 | 632 | parametro: 5 |
| 637 | } | 633 | } |
| 638 | }, | 634 | }, |
| 639 | { | 635 | { |
| 640 | nombre: 'Nombre', | 636 | nombre: 'Nombre', |
| 641 | propiedad: 'NOM' | 637 | propiedad: 'NOM' |
| 642 | }, | 638 | }, |
| 643 | { | 639 | { |
| 644 | nombre: 'CUIT', | 640 | nombre: 'CUIT', |
| 645 | propiedad: 'CUIT' | 641 | propiedad: 'CUIT' |
| 646 | } | 642 | } |
| 647 | ], | 643 | ], |
| 648 | tipo: 'POST', | 644 | tipo: 'POST', |
| 649 | json: { razonCuitCod: '' } | 645 | json: { razonCuitCod: '' } |
| 650 | }; | 646 | }; |
| 651 | focaModalService.modal(parametrosModal).then( | 647 | focaModalService.modal(parametrosModal).then( |
| 652 | function (proveedor) { | 648 | function (proveedor) { |
| 653 | $filter('filter')($scope.botonera, { | 649 | $filter('filter')($scope.botonera, { |
| 654 | label: 'Proveedor', | 650 | label: 'Proveedor', |
| 655 | })[0].checked = true; | 651 | })[0].checked = true; |
| 656 | 652 | ||
| 657 | $scope.$broadcast('addCabecera', { | 653 | $scope.$broadcast('addCabecera', { |
| 658 | label: 'Proveedor:', | 654 | label: 'Proveedor:', |
| 659 | valor: proveedor.COD + ' - ' + proveedor.NOM | 655 | valor: proveedor.COD + ' - ' + proveedor.NOM |
| 660 | }); | 656 | }); |
| 661 | $scope.hojaRuta.proveedor = proveedor; | 657 | $scope.hojaRuta.proveedor = proveedor; |
| 662 | }, function () { } | 658 | }, function () { } |
| 663 | ); | 659 | ); |
| 664 | }; | 660 | }; |
| 665 | 661 | ||
| 666 | $scope.seleccionarTransportista = function () { | 662 | $scope.seleccionarTransportista = function () { |
| 667 | if (eligioPreConfirmado()) return; | 663 | if (eligioPreConfirmado()) return; |
| 668 | var parametrosModal = { | 664 | var parametrosModal = { |
| 669 | titulo: 'Bรบsqueda de transportista', | 665 | titulo: 'Bรบsqueda de transportista', |
| 670 | query: '/transportista', | 666 | query: '/transportista', |
| 671 | columnas: [ | 667 | columnas: [ |
| 672 | { | 668 | { |
| 673 | nombre: 'Cรณdigo', | 669 | nombre: 'Cรณdigo', |
| 674 | propiedad: 'COD' | 670 | propiedad: 'COD' |
| 675 | }, | 671 | }, |
| 676 | { | 672 | { |
| 677 | nombre: 'Nombre', | 673 | nombre: 'Nombre', |
| 678 | propiedad: 'NOM' | 674 | propiedad: 'NOM' |
| 679 | }, | 675 | }, |
| 680 | { | 676 | { |
| 681 | nombre: 'CUIT', | 677 | nombre: 'CUIT', |
| 682 | propiedad: 'CUIT' | 678 | propiedad: 'CUIT' |
| 683 | } | 679 | } |
| 684 | ] | 680 | ] |
| 685 | }; | 681 | }; |
| 686 | focaModalService.modal(parametrosModal).then( | 682 | focaModalService.modal(parametrosModal).then( |
| 687 | function (proveedor) { | 683 | function (proveedor) { |
| 688 | $scope.hojaRuta.transportista = proveedor; | 684 | $scope.hojaRuta.transportista = proveedor; |
| 689 | $scope.$broadcast('addCabecera', { | 685 | $scope.$broadcast('addCabecera', { |
| 690 | label: 'Transportista:', | 686 | label: 'Transportista:', |
| 691 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 687 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 692 | proveedor.NOM | 688 | proveedor.NOM |
| 693 | }); | 689 | }); |
| 694 | 690 | ||
| 695 | $filter('filter')($scope.botonera, { | 691 | $filter('filter')($scope.botonera, { |
| 696 | label: 'Transportista', | 692 | label: 'Transportista', |
| 697 | })[0].checked = true; | 693 | })[0].checked = true; |
| 698 | }, function () { | 694 | }, function () { |
| 699 | 695 | ||
| 700 | } | 696 | } |
| 701 | ); | 697 | ); |
| 702 | }; | 698 | }; |
| 703 | 699 | ||
| 704 | $scope.seleccionarChofer = function () { | 700 | $scope.seleccionarChofer = function () { |
| 705 | var parametrosModal = { | 701 | var parametrosModal = { |
| 706 | titulo: 'Bรบsqueda de Chofer', | 702 | titulo: 'Bรบsqueda de Chofer', |
| 707 | query: '/chofer', | 703 | query: '/chofer', |
| 708 | columnas: [ | 704 | columnas: [ |
| 709 | { | 705 | { |
| 710 | propiedad: 'id', | 706 | propiedad: 'id', |
| 711 | nombre: 'Cรณdigo', | 707 | nombre: 'Cรณdigo', |
| 712 | filtro: { | 708 | filtro: { |
| 713 | nombre: 'rellenarDigitos', | 709 | nombre: 'rellenarDigitos', |
| 714 | parametro: 3 | 710 | parametro: 3 |
| 715 | } | 711 | } |
| 716 | }, | 712 | }, |
| 717 | { | 713 | { |
| 718 | propiedad: 'nombre', | 714 | propiedad: 'nombre', |
| 719 | nombre: 'Nombre' | 715 | nombre: 'Nombre' |
| 720 | }, | 716 | }, |
| 721 | { | 717 | { |
| 722 | propiedad: 'dni', | 718 | propiedad: 'dni', |
| 723 | nombre: 'DNI' | 719 | nombre: 'DNI' |
| 724 | }, | 720 | }, |
| 725 | { | 721 | { |
| 726 | propiedad: 'telefono', | 722 | propiedad: 'telefono', |
| 727 | nombre: 'Telรฉfono' | 723 | nombre: 'Telรฉfono' |
| 728 | } | 724 | } |
| 729 | ] | 725 | ] |
| 730 | }; | 726 | }; |
| 731 | focaModalService.modal(parametrosModal).then( | 727 | focaModalService.modal(parametrosModal).then( |
| 732 | function (chofer) { | 728 | function (chofer) { |
| 733 | $scope.hojaRuta.chofer = chofer; | 729 | $scope.hojaRuta.chofer = chofer; |
| 734 | $scope.$broadcast('addCabecera', { | 730 | $scope.$broadcast('addCabecera', { |
| 735 | label: 'Chofer:', | 731 | label: 'Chofer:', |
| 736 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre | 732 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre |
| 737 | }); | 733 | }); |
| 738 | 734 | ||
| 739 | $filter('filter')($scope.botonera, { | 735 | $filter('filter')($scope.botonera, { |
| 740 | label: 'Chofer', | 736 | label: 'Chofer', |
| 741 | })[0].checked = true; | 737 | })[0].checked = true; |
| 742 | }, function () { | 738 | }, function () { |
| 743 | // funcion ejecutada cuando se cancela el modal | 739 | // funcion ejecutada cuando se cancela el modal |
| 744 | } | 740 | } |
| 745 | ); | 741 | ); |
| 746 | }; | 742 | }; |
| 747 | 743 | ||
| 748 | $scope.seleccionarVehiculo = function () { | 744 | $scope.seleccionarVehiculo = function () { |
| 749 | if (!eligioFecha() || eligioPreConfirmado()) return; | 745 | if (!eligioFecha() || eligioPreConfirmado()) return; |
| 750 | modalVehiculos(); | 746 | modalVehiculos(); |
| 751 | }; | 747 | }; |
| 752 | 748 | ||
| 753 | $scope.seleccionarTarifario = function () { | 749 | $scope.seleccionarTarifario = function () { |
| 754 | focaModalService | 750 | focaModalService |
| 755 | .prompt({ | 751 | .prompt({ |
| 756 | titulo: 'Tarifa flete', | 752 | titulo: 'Tarifa flete', |
| 757 | value: $scope.hojaRuta.tarifario | 753 | value: $scope.hojaRuta.tarifario |
| 758 | }) | 754 | }) |
| 759 | .then(function (costo) { | 755 | .then(function (costo) { |
| 760 | if (isNaN(costo)) { | 756 | if (isNaN(costo)) { |
| 761 | focaModalService | 757 | focaModalService |
| 762 | .alert('Ingrese un valor vรกlido') | 758 | .alert('Ingrese un valor vรกlido') |
| 763 | .then(function () { | 759 | .then(function () { |
| 764 | $scope.seleccionarTarifario(); | 760 | $scope.seleccionarTarifario(); |
| 765 | }); | 761 | }); |
| 766 | 762 | ||
| 767 | return; | 763 | return; |
| 768 | } | 764 | } |
| 769 | 765 | ||
| 770 | $scope.hojaRuta.tarifario = costo; | 766 | $scope.hojaRuta.tarifario = costo; |
| 771 | $scope.$broadcast('addCabecera', { | 767 | $scope.$broadcast('addCabecera', { |
| 772 | label: 'Tarifario:', | 768 | label: 'Tarifario:', |
| 773 | valor: costo | 769 | valor: costo |
| 774 | }); | 770 | }); |
| 775 | 771 | ||
| 776 | $filter('filter')($scope.botonera, { | 772 | $filter('filter')($scope.botonera, { |
| 777 | label: 'Tarifario', | 773 | label: 'Tarifario', |
| 778 | })[0].checked = true; | 774 | })[0].checked = true; |
| 779 | }); | 775 | }); |
| 780 | }; | 776 | }; |
| 781 | 777 | ||
| 782 | $scope.seleccionarRemitos = function () { | 778 | $scope.seleccionarRemitos = function () { |
| 783 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; | 779 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; |
| 784 | var modalInstance = $uibModal.open( | 780 | var modalInstance = $uibModal.open( |
| 785 | { | 781 | { |
| 786 | ariaLabelledBy: 'Busqueda de Remito', | 782 | ariaLabelledBy: 'Busqueda de Remito', |
| 787 | templateUrl: 'foca-modal-remito.html', | 783 | templateUrl: 'foca-modal-remito.html', |
| 788 | controller: 'focaModalRemitoController', | 784 | controller: 'focaModalRemitoController', |
| 789 | size: 'lg', | 785 | size: 'lg', |
| 790 | resolve: { usadoPor: function () { return 'hojaRuta'; } } | 786 | resolve: { usadoPor: function () { return 'hojaRuta'; } } |
| 791 | } | 787 | } |
| 792 | ); | 788 | ); |
| 793 | modalInstance.result.then( | 789 | modalInstance.result.then( |
| 794 | function (remito) { | 790 | function (remito) { |
| 795 | // TODO: borrar cuando no se use definitivamente | 791 | // TODO: borrar cuando no se use definitivamente |
| 796 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { | 792 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
| 797 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { | 793 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
| 798 | // focaModalService.alert('Remito ya incluido'); | 794 | // focaModalService.alert('Remito ya incluido'); |
| 799 | // return; | 795 | // return; |
| 800 | // } | 796 | // } |
| 801 | // } | 797 | // } |
| 802 | 798 | ||
| 803 | // var litros = 0; | 799 | // var litros = 0; |
| 804 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | 800 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { |
| 805 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | 801 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); |
| 806 | // } | 802 | // } |
| 807 | 803 | ||
| 808 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | 804 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { |
| 809 | // focaModalService.alert( | 805 | // focaModalService.alert( |
| 810 | // 'Debe ingresar toda la informaciรณn para el transporte' | 806 | // 'Debe ingresar toda la informaciรณn para el transporte' |
| 811 | // ); | 807 | // ); |
| 812 | // return; | 808 | // return; |
| 813 | // } | 809 | // } |
| 814 | 810 | ||
| 815 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | 811 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) |
| 816 | // { | 812 | // { |
| 817 | // var litrostotales = litros; | 813 | // var litrostotales = litros; |
| 818 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | 814 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; |
| 819 | // focaModalService.alert( | 815 | // focaModalService.alert( |
| 820 | // 'La carga excede la capacidad disponible del vehiculo. ' + | 816 | // 'La carga excede la capacidad disponible del vehiculo. ' + |
| 821 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | 817 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' |
| 822 | // ); | 818 | // ); |
| 823 | // } | 819 | // } |
| 824 | 820 | ||
| 825 | // remito.litros = litros; | 821 | // remito.litros = litros; |
| 826 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | 822 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
| 827 | $scope.cargarCisterna(remito.id).then(function () { | 823 | $scope.cargarCisterna(remito.id).then(function () { |
| 828 | $scope.hojaRuta.remitosTabla.push(remito); | 824 | $scope.hojaRuta.remitosTabla.push(remito); |
| 829 | $filter('filter')($scope.botonera, { | 825 | $filter('filter')($scope.botonera, { |
| 830 | label: 'Remitos', | 826 | label: 'Remitos', |
| 831 | })[0].checked = true; | 827 | })[0].checked = true; |
| 832 | 828 | ||
| 833 | }, function (error) { | 829 | }, function (error) { |
| 834 | error.then($scope.seleccionarRemitos); | 830 | error.then($scope.seleccionarRemitos); |
| 835 | }); | 831 | }); |
| 836 | }, function () { | 832 | }, function () { |
| 837 | // funcion ejecutada cuando se cancela el modal | 833 | // funcion ejecutada cuando se cancela el modal |
| 838 | } | 834 | } |
| 839 | ); | 835 | ); |
| 840 | }; | 836 | }; |
| 841 | 837 | ||
| 842 | $scope.seleccionarVehiculosPrecargados = function () { | 838 | $scope.seleccionarVehiculosPrecargados = function () { |
| 843 | if (!eligioFecha()) return; | 839 | if (!eligioFecha()) return; |
| 844 | modalVehiculos(true); | 840 | modalVehiculos(true); |
| 845 | }; | 841 | }; |
| 846 | 842 | ||
| 847 | $scope.cargarCisterna = function (idRemito) { | 843 | $scope.cargarCisterna = function (idRemito) { |
| 848 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; | 844 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; |
| 849 | var modalInstance = $uibModal.open( | 845 | var modalInstance = $uibModal.open( |
| 850 | { | 846 | { |
| 851 | ariaLabelledBy: 'Busqueda de Vehiculo', | 847 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 852 | templateUrl: 'foca-detalle-vehiculo.html', | 848 | templateUrl: 'foca-detalle-vehiculo.html', |
| 853 | controller: 'focaDetalleVehiculo', | 849 | controller: 'focaDetalleVehiculo', |
| 854 | size: 'lg', | 850 | size: 'lg', |
| 855 | resolve: { | 851 | resolve: { |
| 856 | idVehiculo: function () { return $scope.hojaRuta.vehiculo.id; }, | 852 | idVehiculo: function () { return $scope.hojaRuta.vehiculo.id; }, |
| 857 | idRemito: function () { return idRemito; }, | 853 | idRemito: function () { return idRemito; }, |
| 858 | fechaReparto: function () { return $scope.hojaRuta.fechaReparto; } | 854 | fechaReparto: function () { return $scope.hojaRuta.fechaReparto; } |
| 859 | } | 855 | } |
| 860 | } | 856 | } |
| 861 | ); | 857 | ); |
| 862 | return modalInstance.result; | 858 | return modalInstance.result; |
| 863 | }; | 859 | }; |
| 864 | 860 | ||
| 865 | $scope.seleccionarFechaEntrega = function () { | 861 | $scope.seleccionarFechaEntrega = function () { |
| 866 | 862 | ||
| 867 | var confirmacion = false; | 863 | var confirmacion = false; |
| 868 | 864 | ||
| 869 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { | 865 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { |
| 870 | confirmacion = true; | 866 | confirmacion = true; |
| 871 | } | 867 | } |
| 872 | 868 | ||
| 873 | if (confirmacion) { | 869 | if (confirmacion) { |
| 874 | focaModalService | 870 | focaModalService |
| 875 | .confirm('Si cambia la fecha se perderรกn los datos actuales') | 871 | .confirm('Si cambia la fecha se perderรกn los datos actuales') |
| 876 | .then(function (data) { | 872 | .then(function (data) { |
| 877 | if (data) { | 873 | if (data) { |
| 878 | $scope.hojaRuta.vehiculo.id = undefined; | 874 | $scope.hojaRuta.vehiculo.id = undefined; |
| 879 | $scope.hojaRuta.tarifario = null; | 875 | $scope.hojaRuta.tarifario = null; |
| 880 | $scope.hojaRuta.transportista = {}; | 876 | $scope.hojaRuta.transportista = {}; |
| 881 | $scope.hojaRuta.chofer = {}; | 877 | $scope.hojaRuta.chofer = {}; |
| 882 | $scope.hojaRuta.datosExtra = undefined; | 878 | $scope.hojaRuta.datosExtra = undefined; |
| 883 | elegirFecha(); | 879 | elegirFecha(); |
| 884 | } | 880 | } |
| 885 | }, function () { | 881 | }, function () { |
| 886 | return; | 882 | return; |
| 887 | }); | 883 | }); |
| 888 | } else { | 884 | } else { |
| 889 | elegirFecha(); | 885 | elegirFecha(); |
| 890 | } | 886 | } |
| 891 | }; | 887 | }; |
| 892 | 888 | ||
| 893 | function setearFecha(fecha) { | 889 | function setearFecha(fecha) { |
| 894 | $timeout(function () { | 890 | $timeout(function () { |
| 895 | $scope.$broadcast('addCabecera', { | 891 | $scope.$broadcast('addCabecera', { |
| 896 | label: 'Fecha de entrega: ', | 892 | label: 'Fecha de entrega: ', |
| 897 | valor: fecha.toLocaleDateString() | 893 | valor: fecha.toLocaleDateString() |
| 898 | }); | 894 | }); |
| 899 | $scope.hojaRuta.fechaReparto = fecha; | 895 | $scope.hojaRuta.fechaReparto = fecha; |
| 900 | $scope.inicial.fechaReparto = fecha; | 896 | $scope.inicial.fechaReparto = fecha; |
| 901 | }); | 897 | }); |
| 902 | } | 898 | } |
| 903 | 899 | ||
| 904 | $scope.seleccionarDatosExtra = function () { | 900 | $scope.seleccionarDatosExtra = function () { |
| 905 | var datosHojaRuta = $scope.hojaRuta.datosExtra; | 901 | var datosHojaRuta = $scope.hojaRuta.datosExtra; |
| 906 | var modalInstance = $uibModal.open( | 902 | var modalInstance = $uibModal.open( |
| 907 | { | 903 | { |
| 908 | templateUrl: 'foca-modal-datos-hoja-ruta.html', | 904 | templateUrl: 'foca-modal-datos-hoja-ruta.html', |
| 909 | controller: 'focaModalDatosHojaRutaCtrl', | 905 | controller: 'focaModalDatosHojaRutaCtrl', |
| 910 | size: 'lg', | 906 | size: 'lg', |
| 911 | resolve: { | 907 | resolve: { |
| 912 | parametrosDatos: function () { | 908 | parametrosDatos: function () { |
| 913 | return { | 909 | return { |
| 914 | datosHojaRuta: datosHojaRuta | 910 | datosHojaRuta: datosHojaRuta |
| 915 | }; | 911 | }; |
| 916 | } | 912 | } |
| 917 | } | 913 | } |
| 918 | } | 914 | } |
| 919 | ); | 915 | ); |
| 920 | return modalInstance.result.then(function (datosExtra) { | 916 | return modalInstance.result.then(function (datosExtra) { |
| 921 | 917 | ||
| 922 | $filter('filter')($scope.botonera, { | 918 | $filter('filter')($scope.botonera, { |
| 923 | label: 'Datos extra', | 919 | label: 'Datos extra', |
| 924 | })[0].checked = true; | 920 | })[0].checked = true; |
| 925 | 921 | ||
| 926 | $scope.hojaRuta.datosExtra = datosExtra; | 922 | $scope.hojaRuta.datosExtra = datosExtra; |
| 927 | }, function () { | 923 | }, function () { |
| 928 | //se ejecuta cuando se cancela el modal | 924 | //se ejecuta cuando se cancela el modal |
| 929 | }); | 925 | }); |
| 930 | }; | 926 | }; |
| 931 | 927 | ||
| 932 | $scope.desasociarRemito = function (key, idRemito) { | 928 | $scope.desasociarRemito = function (key, idRemito) { |
| 933 | var idsRemito = [idRemito]; | 929 | var idsRemito = [idRemito]; |
| 934 | focaModalService.confirm('ยฟEstรก seguro que desea desasociar este remito del' + | 930 | focaModalService.confirm('ยฟEstรก seguro que desea desasociar este remito del' + |
| 935 | ' vehรญculo?').then(function () { | 931 | ' vehรญculo?').then(function () { |
| 936 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, | 932 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, |
| 937 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) | 933 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) |
| 938 | .then(function () { | 934 | .then(function () { |
| 939 | $scope.hojaRuta.remitosTabla.splice(key, 1); | 935 | $scope.hojaRuta.remitosTabla.splice(key, 1); |
| 940 | focaModalService.alert('Remito desasociado con รฉxito'); | 936 | focaModalService.alert('Remito desasociado con รฉxito'); |
| 941 | }); | 937 | }); |
| 942 | }); | 938 | }); |
| 943 | }; | 939 | }; |
| 944 | 940 | ||
| 945 | $scope.verProductosRemito = function (idRemito) { | 941 | $scope.verProductosRemito = function (idRemito) { |
| 946 | var parametrosModal = { | 942 | var parametrosModal = { |
| 947 | titulo: 'Articulos remito', | 943 | titulo: 'Articulos remito', |
| 948 | query: '/articulos/remito/' + idRemito, | 944 | query: '/articulos/remito/' + idRemito, |
| 949 | soloMostrar: true, | 945 | soloMostrar: true, |
| 950 | columnas: [ | 946 | columnas: [ |
| 951 | { | 947 | { |
| 952 | nombre: 'Cรณdigo', | 948 | nombre: 'Cรณdigo', |
| 953 | propiedad: 'codigo' | 949 | propiedad: 'codigo' |
| 954 | }, | 950 | }, |
| 955 | { | 951 | { |
| 956 | nombre: 'Descripciรณn', | 952 | nombre: 'Descripciรณn', |
| 957 | propiedad: 'descripcion' | 953 | propiedad: 'descripcion' |
| 958 | }, | 954 | }, |
| 959 | { | 955 | { |
| 960 | nombre: 'Cantidad', | 956 | nombre: 'Cantidad', |
| 961 | propiedad: 'cantidad' | 957 | propiedad: 'cantidad' |
| 962 | } | 958 | } |
| 963 | ] | 959 | ] |
| 964 | }; | 960 | }; |
| 965 | focaModalService.modal(parametrosModal).then(); | 961 | focaModalService.modal(parametrosModal).then(); |
| 966 | }; | 962 | }; |
| 967 | 963 | ||
| 968 | $scope.mostrarDetalle = function (hojasRutas) { | 964 | $scope.mostrarDetalle = function (hojasRutas) { |
| 969 | var modalInstance =$uibModal.open( | 965 | var modalInstance =$uibModal.open( |
| 970 | { | 966 | { |
| 971 | ariaLabelledBy: '', | 967 | ariaLabelledBy: '', |
| 972 | templateUrl: 'modal-detalle-carga.html', | 968 | templateUrl: 'modal-detalle-carga.html', |
| 973 | controller: 'focaModalDetalleController', | 969 | controller: 'focaModalDetalleController', |
| 974 | resolve: { | 970 | resolve: { |
| 975 | hojasRutas: function () { return hojasRutas; } | 971 | hojasRutas: function () { return hojasRutas; } |
| 976 | }, | 972 | }, |
| 977 | size: 'lg', | 973 | size: 'lg', |
| 978 | backdrop: false | 974 | backdrop: false |
| 979 | } | 975 | } |
| 980 | ); | 976 | ); |
| 981 | return modalInstance.result.then(function (res) { | 977 | return modalInstance.result.then(function (res) { |
| 982 | res.cisternas.forEach( function (cisterna) { | 978 | res.cisternas.forEach( function (cisterna) { |
| 983 | $scope.cisternaCargas.push(cisterna.cisternaCarga); | 979 | $scope.cisternaCargas.push(cisterna.cisternaCarga); |
| 984 | }); | 980 | }); |
| 985 | $scope.cisternaMovimientos = res.movimientos; | 981 | $scope.cisternaMovimientos = res.movimientos; |
| 986 | $scope.articulosRecibidos = res.articulos; | 982 | $scope.articulosRecibidos = res.articulos; |
| 987 | $scope.articulos = res.articulos; | 983 | $scope.articulos = res.articulos; |
| 988 | $filter('filter')($scope.botonera, { | 984 | $filter('filter')($scope.botonera, { |
| 989 | label: 'Detalle de Carga', | 985 | label: 'Detalle de Carga', |
| 990 | })[0].checked = true; | 986 | })[0].checked = true; |
| 991 | }, function () { | 987 | }, function () { |
| 992 | //se ejecuta cuando se cancela el modal | 988 | //se ejecuta cuando se cancela el modal |
| 993 | }); | 989 | }); |
| 994 | }; | 990 | }; |
| 995 | 991 | ||
| 996 | function elegirFecha() { | 992 | function elegirFecha() { |
| 997 | var fechaEntrega = { | 993 | var fechaEntrega = { |
| 998 | titulo: 'Fecha de entrega', | 994 | titulo: 'Fecha de entrega', |
| 999 | minDate: new Date() | 995 | minDate: new Date() |
| 1000 | }; | 996 | }; |
| 1001 | focaModalService.modalFecha(fechaEntrega).then(function (fecha) { | 997 | focaModalService.modalFecha(fechaEntrega).then(function (fecha) { |
| 1002 | 998 | ||
| 1003 | $scope.hojaRuta.fechaReparto = fecha; | 999 | $scope.hojaRuta.fechaReparto = fecha; |
| 1004 | 1000 | ||
| 1005 | $scope.$broadcast('addCabecera', { | 1001 | $scope.$broadcast('addCabecera', { |
| 1006 | label: 'Fecha de entrega: ', | 1002 | label: 'Fecha de entrega: ', |
| 1007 | valor: fecha.toLocaleDateString() | 1003 | valor: fecha.toLocaleDateString() |
| 1008 | }); | 1004 | }); |
| 1009 | //habilitar los otros botones | 1005 | //habilitar los otros botones |
| 1010 | var temp = []; | 1006 | var temp = []; |
| 1011 | if ($scope.botonera.length > 1) { | 1007 | if ($scope.botonera.length > 1) { |
| 1012 | limpiarBotonera($scope.botonera); | 1008 | limpiarBotonera($scope.botonera); |
| 1013 | } else if ($scope.precargado) { | 1009 | } else if ($scope.precargado) { |
| 1014 | temp = focaCrearHojaRutaService.getBotoneraPrecargado(); | 1010 | temp = focaCrearHojaRutaService.getBotoneraPrecargado(); |
| 1015 | modalVehiculos(true); | 1011 | modalVehiculos(true); |
| 1016 | } else if ($scope.cargaRemito && $scope.precargado === false) { | 1012 | } else if ($scope.cargaRemito && $scope.precargado === false) { |
| 1017 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | 1013 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); |
| 1018 | } else { | 1014 | } else { |
| 1019 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | 1015 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); |
| 1020 | modalVehiculos(true); | 1016 | modalVehiculos(true); |
| 1021 | } | 1017 | } |
| 1022 | temp.forEach(function (e) { | 1018 | temp.forEach(function (e) { |
| 1023 | $scope.botonera.push(e); | 1019 | $scope.botonera.push(e); |
| 1024 | }); | 1020 | }); |
| 1025 | 1021 | ||
| 1026 | $filter('filter')($scope.botonera, { | 1022 | $filter('filter')($scope.botonera, { |
| 1027 | label: 'Fecha Entrega', | 1023 | label: 'Fecha Entrega', |
| 1028 | })[0].checked = true; | 1024 | })[0].checked = true; |
| 1029 | }); | 1025 | }); |
| 1030 | } | 1026 | } |
| 1031 | 1027 | ||
| 1032 | function eligioPreConfirmado() { | 1028 | function eligioPreConfirmado() { |
| 1033 | if ($scope.eligioPreConfirmado) { | 1029 | if ($scope.eligioPreConfirmado) { |
| 1034 | focaModalService.alert('No puede elegir si eligiรณ un vehiculo pre cargado'); | 1030 | focaModalService.alert('No puede elegir si eligiรณ un vehiculo pre cargado'); |
| 1035 | return true; | 1031 | return true; |
| 1036 | } | 1032 | } |
| 1037 | return false; | 1033 | return false; |
| 1038 | } | 1034 | } |
| 1039 | 1035 | ||
| 1040 | function eligioFecha() { | 1036 | function eligioFecha() { |
| 1041 | if (!$scope.hojaRuta.fechaReparto) { | 1037 | if (!$scope.hojaRuta.fechaReparto) { |
| 1042 | focaModalService.alert('Primero seleccione fecha de reparto'); | 1038 | focaModalService.alert('Primero seleccione fecha de reparto'); |
| 1043 | return false; | 1039 | return false; |
| 1044 | } | 1040 | } |
| 1045 | return true; | 1041 | return true; |
| 1046 | } | 1042 | } |
| 1047 | 1043 | ||
| 1048 | function eligioVehiculo() { | 1044 | function eligioVehiculo() { |
| 1049 | if (!$scope.hojaRuta.vehiculo.id) { | 1045 | if (!$scope.hojaRuta.vehiculo.id) { |
| 1050 | focaModalService.alert('Primero seleccione vehiculo'); | 1046 | focaModalService.alert('Primero seleccione vehiculo'); |
| 1051 | return false; | 1047 | return false; |
| 1052 | } | 1048 | } |
| 1053 | return true; | 1049 | return true; |
| 1054 | } | 1050 | } |
| 1055 | 1051 | ||
| 1056 | function modalVehiculos(preCargados) { | 1052 | function modalVehiculos(preCargados) { |
| 1057 | var parametrosModal = {}; | 1053 | var parametrosModal = {}; |
| 1058 | if (preCargados) { | 1054 | if (preCargados) { |
| 1059 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + | 1055 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + |
| 1060 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); | 1056 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); |
| 1061 | parametrosModal.titulo = 'Bรบsqueda de vehiculos precargados'; | 1057 | parametrosModal.titulo = 'Bรบsqueda de vehiculos precargados'; |
| 1062 | } else { | 1058 | } else { |
| 1063 | parametrosModal.query = '/vehiculo'; | 1059 | parametrosModal.query = '/vehiculo'; |
| 1064 | parametrosModal.titulo = 'Bรบsqueda de vehรญculos'; | 1060 | parametrosModal.titulo = 'Bรบsqueda de vehรญculos'; |
| 1065 | } | 1061 | } |
| 1066 | parametrosModal.columnas = [ | 1062 | parametrosModal.columnas = [ |
| 1067 | { | 1063 | { |
| 1068 | propiedad: 'codigo', | 1064 | propiedad: 'codigo', |
| 1069 | nombre: 'Cรณdigo' | 1065 | nombre: 'Cรณdigo' |
| 1070 | }, | 1066 | }, |
| 1071 | { | 1067 | { |
| 1072 | propiedad: 'tractor', | 1068 | propiedad: 'tractor', |
| 1073 | nombre: 'tractor' | 1069 | nombre: 'tractor' |
| 1074 | }, | 1070 | }, |
| 1075 | { | 1071 | { |
| 1076 | propiedad: 'semi', | 1072 | propiedad: 'semi', |
| 1077 | nombre: 'Semi' | 1073 | nombre: 'Semi' |
| 1078 | } | 1074 | } |
| 1079 | ]; | 1075 | ]; |
| 1080 | focaModalService.modal(parametrosModal).then(function (vehiculo) { | 1076 | focaModalService.modal(parametrosModal).then(function (vehiculo) { |
| 1081 | if (!preCargados && vehiculoEnUso(vehiculo)) return; | 1077 | if (!preCargados && vehiculoEnUso(vehiculo)) return; |
| 1082 | $scope.hojaRuta.vehiculo = vehiculo; | 1078 | $scope.hojaRuta.vehiculo = vehiculo; |
| 1083 | $scope.hojaRuta.transportista = vehiculo.transportista; | 1079 | $scope.hojaRuta.transportista = vehiculo.transportista; |
| 1084 | // mostrarDetalle(vehiculo); | 1080 | // mostrarDetalle(vehiculo); |
| 1085 | if (preCargados) { | 1081 | if (preCargados) { |
| 1086 | $scope.eligioPreConfirmado = true; | 1082 | $scope.eligioPreConfirmado = true; |
| 1087 | $scope.hojaRuta.vehiculo = vehiculo; | 1083 | $scope.hojaRuta.vehiculo = vehiculo; |
| 1088 | $scope.$broadcast('addCabecera', { | 1084 | $scope.$broadcast('addCabecera', { |
| 1089 | label: 'Transportista:', | 1085 | label: 'Transportista:', |
| 1090 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + | 1086 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + |
| 1091 | ' - ' + vehiculo.transportista.NOM | 1087 | ' - ' + vehiculo.transportista.NOM |
| 1092 | }); | 1088 | }); |
| 1093 | focaCrearHojaRutaService | 1089 | focaCrearHojaRutaService |
| 1094 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) | 1090 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
| 1095 | .then(function (res) { | 1091 | .then(function (res) { |
| 1096 | $filter('filter')($scope.botonera, { | 1092 | $filter('filter')($scope.botonera, { |
| 1097 | label: 'Transportista', | 1093 | label: 'Transportista', |
| 1098 | })[0].checked = true; | 1094 | })[0].checked = true; |
| 1099 | 1095 | ||
| 1100 | $filter('filter')($scope.botonera, { | 1096 | $filter('filter')($scope.botonera, { |
| 1101 | label: 'Vehiculo', | 1097 | label: 'Vehiculo', |
| 1102 | })[0].checked = true; | 1098 | })[0].checked = true; |
| 1103 | 1099 | ||
| 1104 | $scope.hojaRuta.remitosTabla = res.data; | 1100 | $scope.hojaRuta.remitosTabla = res.data; |
| 1105 | }); | 1101 | }); |
| 1106 | } else { | 1102 | } else { |
| 1107 | focaCrearHojaRutaService | 1103 | focaCrearHojaRutaService |
| 1108 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) | 1104 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
| 1109 | .then(function (res) { | 1105 | .then(function (res) { |
| 1110 | 1106 | ||
| 1111 | $filter('filter')($scope.botonera, { | 1107 | $filter('filter')($scope.botonera, { |
| 1112 | label: 'Vehiculo', | 1108 | label: 'Vehiculo', |
| 1113 | })[0].checked = true; | 1109 | })[0].checked = true; |
| 1114 | 1110 | ||
| 1115 | $scope.hojaRuta.remitosTabla = res.data; | 1111 | $scope.hojaRuta.remitosTabla = res.data; |
| 1116 | }); | 1112 | }); |
| 1117 | } | 1113 | } |
| 1118 | $scope.$broadcast('addCabecera', { | 1114 | $scope.$broadcast('addCabecera', { |
| 1119 | label: 'Tractor:', | 1115 | label: 'Tractor:', |
| 1120 | valor: vehiculo.tractor | 1116 | valor: vehiculo.tractor |
| 1121 | }); | 1117 | }); |
| 1122 | $scope.$broadcast('addCabecera', { | 1118 | $scope.$broadcast('addCabecera', { |
| 1123 | label: 'Semi:', | 1119 | label: 'Semi:', |
| 1124 | valor: vehiculo.semi | 1120 | valor: vehiculo.semi |
| 1125 | }); | 1121 | }); |
| 1126 | $scope.$broadcast('addCabecera', { | 1122 | $scope.$broadcast('addCabecera', { |
| 1127 | label: 'Capacidad:', | 1123 | label: 'Capacidad:', |
| 1128 | valor: vehiculo.capacidad | 1124 | valor: vehiculo.capacidad |
| 1129 | }); | 1125 | }); |
| 1130 | 1126 | ||
| 1131 | }); | 1127 | }); |
| 1132 | } | 1128 | } |
| 1133 | 1129 | ||
| 1134 | function vehiculoEnUso(vehiculo) { | 1130 | function vehiculoEnUso(vehiculo) { |
| 1135 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; | 1131 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; |
| 1136 | for (var i = 0; i < vehiculo.cisternas.length; i++) { | 1132 | for (var i = 0; i < vehiculo.cisternas.length; i++) { |
| 1137 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 1133 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
| 1138 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 1134 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
| 1139 | if (cisternaCarga.fechaReparto.substring(0, 10) === | 1135 | if (cisternaCarga.fechaReparto.substring(0, 10) === |
| 1140 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && | 1136 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && |
| 1141 | cisternaCarga.idUsuarioProceso && | 1137 | cisternaCarga.idUsuarioProceso && |
| 1142 | cisternaCarga.idUsuarioProceso !== idUsuario) { | 1138 | cisternaCarga.idUsuarioProceso !== idUsuario) { |
| 1143 | focaModalService.alert('El vehรญculo estรก siendo usado por otro' + | 1139 | focaModalService.alert('El vehรญculo estรก siendo usado por otro' + |
| 1144 | ' usuario'); | 1140 | ' usuario'); |
| 1145 | return true; | 1141 | return true; |
| 1146 | } | 1142 | } |
| 1147 | } | 1143 | } |
| 1148 | } | 1144 | } |
| 1149 | return false; | 1145 | return false; |
| 1150 | } | 1146 | } |
| 1151 | 1147 | ||
| 1152 | function salir() { | 1148 | function salir() { |
| 1153 | var confirmacion = false; | 1149 | var confirmacion = false; |
| 1154 | 1150 | ||
| 1155 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { | 1151 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { |
| 1156 | confirmacion = true; | 1152 | confirmacion = true; |
| 1157 | } | 1153 | } |
| 1158 | 1154 | ||
| 1159 | if (confirmacion) { | 1155 | if (confirmacion) { |
| 1160 | focaModalService.confirm( | 1156 | focaModalService.confirm( |
| 1161 | 'ยฟEstรก seguro de que desea salir? Se perderรกn todos los datos cargados.' | 1157 | 'ยฟEstรก seguro de que desea salir? Se perderรกn todos los datos cargados.' |
| 1162 | ).then(function (data) { | 1158 | ).then(function (data) { |
| 1163 | if (data) { | 1159 | if (data) { |
| 1164 | $location.path('/'); | 1160 | $location.path('/'); |
| 1165 | } | 1161 | } |
| 1166 | }); | 1162 | }); |
| 1167 | } else { | 1163 | } else { |
| 1168 | $location.path('/'); | 1164 | $location.path('/'); |
| 1169 | } | 1165 | } |
| 1170 | } | 1166 | } |
| 1171 | 1167 | ||
| 1172 | function limpiarBotonera(botonera) { | 1168 | function limpiarBotonera(botonera) { |
| 1173 | botonera.forEach(function (boton) { | 1169 | botonera.forEach(function (boton) { |
| 1174 | boton.checked = false; | 1170 | boton.checked = false; |
| 1175 | }); | 1171 | }); |
| 1176 | } | 1172 | } |
| 1177 | function setearHojaRuta(hojaRuta) { | 1173 | function setearHojaRuta(hojaRuta) { |
| 1178 | $scope.$broadcast('cleanCabecera'); | 1174 | $scope.$broadcast('cleanCabecera'); |
| 1179 | 1175 | ||
| 1180 | var cabeceras = []; | 1176 | var cabeceras = []; |
| 1181 | if (hojaRuta.fechaReparto) { | 1177 | if (hojaRuta.fechaReparto) { |
| 1182 | cabeceras.push({ | 1178 | cabeceras.push({ |
| 1183 | label: 'Fecha de entrega:', | 1179 | label: 'Fecha de entrega:', |
| 1184 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') | 1180 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
| 1185 | }); | 1181 | }); |
| 1186 | 1182 | ||
| 1187 | $filter('filter')($scope.botonera, { | 1183 | $filter('filter')($scope.botonera, { |
| 1188 | label: 'Fecha Entrega' | 1184 | label: 'Fecha Entrega' |
| 1189 | })[0].checked = true; | 1185 | })[0].checked = true; |
| 1190 | } | 1186 | } |
| 1191 | if (hojaRuta.transportista.COD) { | 1187 | if (hojaRuta.transportista.COD) { |
| 1192 | cabeceras.push({ | 1188 | cabeceras.push({ |
| 1193 | label: 'Transportista:', | 1189 | label: 'Transportista:', |
| 1194 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + | 1190 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + |
| 1195 | hojaRuta.transportista.NOM | 1191 | hojaRuta.transportista.NOM |
| 1196 | }); | 1192 | }); |
| 1197 | 1193 | ||
| 1198 | $filter('filter')($scope.botonera, { | 1194 | $filter('filter')($scope.botonera, { |
| 1199 | label: 'Transportista' | 1195 | label: 'Transportista' |
| 1200 | })[0].checked = true; | 1196 | })[0].checked = true; |
| 1201 | } | 1197 | } |
| 1202 | if (hojaRuta.chofer.id) { | 1198 | if (hojaRuta.chofer.id) { |
| 1203 | cabeceras.push({ | 1199 | cabeceras.push({ |
| 1204 | label: 'Chofer:', | 1200 | label: 'Chofer:', |
| 1205 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + | 1201 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + |
| 1206 | ' - ' + hojaRuta.chofer.nombre | 1202 | ' - ' + hojaRuta.chofer.nombre |
| 1207 | }); | 1203 | }); |
| 1208 | 1204 | ||
| 1209 | $filter('filter')($scope.botonera, { | 1205 | $filter('filter')($scope.botonera, { |
| 1210 | label: 'Chofer' | 1206 | label: 'Chofer' |
| 1211 | })[0].checked = true; | 1207 | })[0].checked = true; |
| 1212 | } | 1208 | } |
| 1213 | if (hojaRuta.vehiculo.id) { | 1209 | if (hojaRuta.vehiculo.id) { |
| 1214 | cabeceras.push({ | 1210 | cabeceras.push({ |
| 1215 | label: 'Tractor:', | 1211 | label: 'Tractor:', |
| 1216 | valor: hojaRuta.vehiculo.tractor | 1212 | valor: hojaRuta.vehiculo.tractor |
| 1217 | }); | 1213 | }); |
| 1218 | cabeceras.push({ | 1214 | cabeceras.push({ |
| 1219 | label: 'Semi:', | 1215 | label: 'Semi:', |
| 1220 | valor: hojaRuta.vehiculo.semi | 1216 | valor: hojaRuta.vehiculo.semi |
| 1221 | }); | 1217 | }); |
| 1222 | cabeceras.push({ | 1218 | cabeceras.push({ |
| 1223 | label: 'Capacidad:', | 1219 | label: 'Capacidad:', |
| 1224 | valor: hojaRuta.vehiculo.capacidad | 1220 | valor: hojaRuta.vehiculo.capacidad |
| 1225 | }); | 1221 | }); |
| 1226 | 1222 | ||
| 1227 | $filter('filter')($scope.botonera, { | 1223 | $filter('filter')($scope.botonera, { |
| 1228 | label: 'Vehiculo' | 1224 | label: 'Vehiculo' |
| 1229 | })[0].checked = true; | 1225 | })[0].checked = true; |
| 1230 | } | 1226 | } |
| 1231 | if (hojaRuta.tarifario) { | 1227 | if (hojaRuta.tarifario) { |
| 1232 | cabeceras.push({ | 1228 | cabeceras.push({ |
| 1233 | label: 'Tarifario:', | 1229 | label: 'Tarifario:', |
| 1234 | valor: hojaRuta.tarifario | 1230 | valor: hojaRuta.tarifario |
| 1235 | }); | 1231 | }); |
| 1236 | 1232 | ||
| 1237 | $filter('filter')($scope.botonera, { | 1233 | $filter('filter')($scope.botonera, { |
| 1238 | label: 'Tarifario' | 1234 | label: 'Tarifario' |
| 1239 | })[0].checked = true; | 1235 | })[0].checked = true; |
| 1240 | } | 1236 | } |
| 1241 | 1237 | ||
| 1242 | addArrayCabecera(cabeceras); | 1238 | addArrayCabecera(cabeceras); |
| 1243 | $scope.hojaRuta = hojaRuta; | 1239 | $scope.hojaRuta = hojaRuta; |
| 1244 | } | 1240 | } |
| 1245 | 1241 | ||
| 1246 | function getLSHojaRuta() { | 1242 | function getLSHojaRuta() { |
| 1247 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); | 1243 | if ($localStorage.data === undefined) return; |
| 1244 | |||
| 1245 | var hojaRuta = (JSON.parse($localStorage.data))[0] || null; | ||
| 1248 | if (hojaRuta) { | 1246 | if (hojaRuta) { |
| 1249 | setearHojaRuta(hojaRuta); | 1247 | setearHojaRuta(hojaRuta); |
| 1250 | delete $localStorage.hojaRuta; | 1248 | delete $localStorage.data; |
| 1251 | } | 1249 | } |
| 1252 | } | 1250 | } |
| 1251 | |||
| 1252 | function getLSBotoneraPrincipal() { | ||
| 1253 | if ($localStorage.data === undefined) return; | ||
| 1254 | |||
| 1255 | var precargado = (JSON.parse($localStorage.data))[1] || null; | ||
| 1256 | var cargaRemito = (JSON.parse($localStorage.data))[2] || null; | ||
| 1257 | var remitoAbierto = (JSON.parse($localStorage.data))[3] || null; | ||
| 1258 | if (remitoAbierto) { | ||
| 1259 | $scope.remitoAbierto = remitoAbierto; | ||
| 1260 | $filter('filter')($scope.botoneraPrincipal, { | ||
| 1261 | label: 'Remito Abierto' | ||
| 1262 | })[0].checked = $scope.remitoAbierto; | ||
| 1263 | $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto(); | ||
| 1264 | } | ||
| 1265 | if (precargado) { | ||
| 1266 | $scope.precargado = precargado; | ||
| 1267 | $filter('filter')($scope.botoneraPrincipal, { | ||
| 1268 | label: 'Precargados' | ||
| 1269 | })[0].checked = $scope.precargado; | ||
| 1270 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
| 1271 | Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraPrecargado()); | ||
| 1272 | } | ||
| 1273 | if (cargaRemito) { | ||
| 1274 | $scope.cargaRemito = cargaRemito; | ||
| 1275 | $filter('filter')($scope.botoneraPrincipal, { | ||
| 1276 | label: 'Cargar Remitos' | ||
| 1277 | })[0].checked = $scope.cargaRemito; | ||
| 1278 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
| 1279 | Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraCargarRemito()); | ||
| 1280 | } | ||
| 1281 | } | ||
| 1282 |
src/js/service.js
| 1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
| 2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', '$cookies', | 2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', '$cookies', |
| 3 | function($http, API_ENDPOINT, $cookies) { | 3 | function($http, API_ENDPOINT, $cookies) { |
| 4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
| 5 | return { | 5 | return { |
| 6 | idUsuario: $cookies.get('vendedorCobrador'), | 6 | idUsuario: $cookies.get('vendedorCobrador'), |
| 7 | crearHojaRuta: function(hojaRuta) { | 7 | crearHojaRuta: function(hojaRuta) { |
| 8 | return $http.post(route + '/hoja-ruta', hojaRuta); | 8 | return $http.post(route + '/hoja-ruta', hojaRuta); |
| 9 | }, | 9 | }, |
| 10 | crearRemito: function(remito) { | 10 | crearRemito: function(remito) { |
| 11 | // TODO: Cambiar para usar el servicio /remito | 11 | // TODO: Cambiar para usar el servicio /remito |
| 12 | return $http.post(route + '/remito/guardar', remito); | 12 | return $http.post(route + '/remito/guardar', remito); |
| 13 | }, | 13 | }, |
| 14 | obtenerHojaRuta: function() { | 14 | obtenerHojaRuta: function() { |
| 15 | return $http.get(route +'/hoja-ruta'); | 15 | return $http.get(route +'/hoja-ruta'); |
| 16 | }, | 16 | }, |
| 17 | setHojaRuta: function(hojaRuta) { | 17 | setHojaRuta: function(hojaRuta) { |
| 18 | this.hojaRuta = hojaRuta; | 18 | this.hojaRuta = hojaRuta; |
| 19 | }, | 19 | }, |
| 20 | clearHojaRuta: function() { | 20 | clearHojaRuta: function() { |
| 21 | this.hojaRuta = undefined; | 21 | this.hojaRuta = undefined; |
| 22 | }, | 22 | }, |
| 23 | getHojaRuta: function() { | 23 | getHojaRuta: function() { |
| 24 | return this.hojaRuta; | 24 | return this.hojaRuta; |
| 25 | }, | 25 | }, |
| 26 | getArticulosByIdHojaRuta: function(id) { | 26 | getArticulosByIdHojaRuta: function(id) { |
| 27 | return $http.get(route+'/articulos/hoja-ruta/'+id); | 27 | return $http.get(route+'/articulos/hoja-ruta/'+id); |
| 28 | }, | 28 | }, |
| 29 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { | 29 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { |
| 30 | return $http.post(route + '/articulos/remito', | 30 | return $http.post(route + '/articulos/remito', |
| 31 | {articuloRemito: articuloHojaRuta}); | 31 | {articuloRemito: articuloHojaRuta}); |
| 32 | }, | 32 | }, |
| 33 | getDomiciliosByIdHojaRuta: function(id) { | 33 | getDomiciliosByIdHojaRuta: function(id) { |
| 34 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); | 34 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); |
| 35 | }, | 35 | }, |
| 36 | getDomiciliosByIdCliente: function(id) { | 36 | getDomiciliosByIdCliente: function(id) { |
| 37 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 37 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
| 38 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 38 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
| 39 | }, | 39 | }, |
| 40 | getPrecioCondicion: function() { | 40 | getPrecioCondicion: function() { |
| 41 | return $http.get(route + '/precio-condicion'); | 41 | return $http.get(route + '/precio-condicion'); |
| 42 | }, | 42 | }, |
| 43 | getPrecioCondicionById: function(id) { | 43 | getPrecioCondicionById: function(id) { |
| 44 | return $http.get(route + '/precio-condicion/' + id); | 44 | return $http.get(route + '/precio-condicion/' + id); |
| 45 | }, | 45 | }, |
| 46 | getPlazoPagoByPrecioCondicion: function(id) { | 46 | getPlazoPagoByPrecioCondicion: function(id) { |
| 47 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); | 47 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); |
| 48 | }, | 48 | }, |
| 49 | crearFlete: function(flete) { | 49 | crearFlete: function(flete) { |
| 50 | return $http.post(route + '/flete', {flete : flete}); | 50 | return $http.post(route + '/flete', {flete : flete}); |
| 51 | }, | 51 | }, |
| 52 | crearPlazosParaHojaRuta: function(plazos) { | 52 | crearPlazosParaHojaRuta: function(plazos) { |
| 53 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); | 53 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); |
| 54 | }, | 54 | }, |
| 55 | getCotizacionByIdMoneda: function(id) { | 55 | getCotizacionByIdMoneda: function(id) { |
| 56 | return $http.get(route + '/moneda/' + id); | 56 | return $http.get(route + '/moneda/' + id); |
| 57 | }, | 57 | }, |
| 58 | crearEstadoParaHojaRuta: function(estado) { | 58 | crearEstadoParaHojaRuta: function(estado) { |
| 59 | return $http.post(route + '/estado', {estado: estado}); | 59 | return $http.post(route + '/estado', {estado: estado}); |
| 60 | }, | 60 | }, |
| 61 | getNumeroHojaRuta: function() { | 61 | getNumeroHojaRuta: function() { |
| 62 | return $http.get(route + '/hoja-ruta/numero-siguiente'); | 62 | return $http.get(route + '/hoja-ruta/numero-siguiente'); |
| 63 | }, | 63 | }, |
| 64 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { | 64 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { |
| 65 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; | 65 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; |
| 66 | return $http.get(route + '/vehiculo/obtener/remitos/' + | 66 | return $http.get(route + '/vehiculo/obtener/remitos/' + |
| 67 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); | 67 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); |
| 68 | }, | 68 | }, |
| 69 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { | 69 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { |
| 70 | return $http.post(route + '/vehiculo/desasociar-remitos', | 70 | return $http.post(route + '/vehiculo/desasociar-remitos', |
| 71 | { | 71 | { |
| 72 | idsRemitos: idsRemitos, | 72 | idsRemitos: idsRemitos, |
| 73 | idVehiculo: idVehiculo, | 73 | idVehiculo: idVehiculo, |
| 74 | vehiculoSinRemitos: sinRemitos | 74 | vehiculoSinRemitos: sinRemitos |
| 75 | }); | 75 | }); |
| 76 | }, | 76 | }, |
| 77 | getParametros: function() { | 77 | getParametros: function() { |
| 78 | return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta'); | 78 | return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta'); |
| 79 | }, | 79 | }, |
| 80 | getBotonera: function() { | 80 | getBotonera: function() { |
| 81 | return [ | 81 | return [ |
| 82 | { | 82 | { |
| 83 | label: 'Fecha Entrega', | 83 | label: 'Fecha Entrega', |
| 84 | image: 'FechaEntrega.png' | 84 | image: 'FechaEntrega.png' |
| 85 | }, | 85 | }, |
| 86 | { | 86 | { |
| 87 | label: 'Transportista', | 87 | label: 'Transportista', |
| 88 | image: 'transportista.png' | 88 | image: 'transportista.png' |
| 89 | }, | 89 | }, |
| 90 | { | 90 | { |
| 91 | label: 'Chofer', | 91 | label: 'Chofer', |
| 92 | image: 'chofer.png' | 92 | image: 'chofer.png' |
| 93 | }, | 93 | }, |
| 94 | { | 94 | { |
| 95 | label: 'Vehiculo', | 95 | label: 'Vehiculo', |
| 96 | image: 'vehiculos.png' | 96 | image: 'vehiculos.png' |
| 97 | }, | 97 | }, |
| 98 | { | 98 | { |
| 99 | label: 'Tarifario', | 99 | label: 'Tarifario', |
| 100 | image: 'tarifario.png' | 100 | image: 'tarifario.png' |
| 101 | }, | 101 | }, |
| 102 | { | 102 | { |
| 103 | label: 'Remitos', | 103 | label: 'Remitos', |
| 104 | image: 'remito.png' | 104 | image: 'remito.png' |
| 105 | }, | 105 | }, |
| 106 | { | 106 | { |
| 107 | label: 'Vehiculos precargados', | 107 | label: 'Vehiculos precargados', |
| 108 | image: 'vehiculos.png' | 108 | image: 'vehiculos.png' |
| 109 | }, | 109 | }, |
| 110 | { | 110 | { |
| 111 | label: 'Datos extra', | 111 | label: 'Datos extra', |
| 112 | image: 'tarifario.png' | 112 | image: 'tarifario.png' |
| 113 | } | 113 | } |
| 114 | ]; | 114 | ]; |
| 115 | }, | 115 | }, |
| 116 | getBotones: function () { | 116 | getBotones: function () { |
| 117 | return [ | 117 | return [ |
| 118 | { | 118 | { |
| 119 | label: 'Precargados', | 119 | label: 'Precargados', |
| 120 | image: 'vehiculos.png' | 120 | image: 'vehiculos.png' |
| 121 | }, | 121 | }, |
| 122 | { | 122 | { |
| 123 | label: 'Cargar Remitos', | 123 | label: 'Cargar Remitos', |
| 124 | image: 'remito.png' | 124 | image: 'remito.png' |
| 125 | }, | 125 | }, |
| 126 | { | 126 | { |
| 127 | label: 'Remito Abierto', | 127 | label: 'Remito Abierto', |
| 128 | image: 'remitoabierto.png' | 128 | image: 'remitoabierto.png' |
| 129 | } | 129 | } |
| 130 | ]; | 130 | ]; |
| 131 | }, | 131 | }, |
| 132 | getRemitoAbierto: function () { | 132 | getRemitoAbierto: function () { |
| 133 | return [ | 133 | return [ |
| 134 | { | 134 | { |
| 135 | label: 'Fecha Entrega', | 135 | label: 'Fecha Entrega', |
| 136 | image: 'FechaEntrega.png' | 136 | image: 'FechaEntrega.png' |
| 137 | }, | 137 | }, |
| 138 | { | 138 | { |
| 139 | label: 'Transportista', | 139 | label: 'Transportista', |
| 140 | image: 'transportista.png' | 140 | image: 'transportista.png' |
| 141 | }, | 141 | }, |
| 142 | { | 142 | { |
| 143 | label: 'Vehiculo', | 143 | label: 'Vehiculo', |
| 144 | image: 'vehiculos.png' | 144 | image: 'vehiculos.png' |
| 145 | }, | 145 | }, |
| 146 | { | 146 | { |
| 147 | label: 'Chofer', | 147 | label: 'Chofer', |
| 148 | image: 'chofer.png' | 148 | image: 'chofer.png' |
| 149 | }, | 149 | }, |
| 150 | { | 150 | { |
| 151 | label: 'Proveedor', | 151 | label: 'Proveedor', |
| 152 | image: 'proveedor.png' | 152 | image: 'proveedor.png' |
| 153 | }, | 153 | }, |
| 154 | { | 154 | { |
| 155 | label: 'Tarifario', | 155 | label: 'Tarifario', |
| 156 | image: 'tarifario.png' | 156 | image: 'tarifario.png' |
| 157 | }, | 157 | }, |
| 158 | { | 158 | { |
| 159 | label: 'Cliente', | 159 | label: 'Cliente', |
| 160 | image: 'cliente.png' | 160 | image: 'cliente.png' |
| 161 | }, | 161 | }, |
| 162 | { | 162 | { |
| 163 | label: 'Detalle de Carga', | 163 | label: 'Detalle de Carga', |
| 164 | image: 'detalleDeCarga.png' | 164 | image: 'detalleDeCarga.png' |
| 165 | } | 165 | } |
| 166 | ]; | 166 | ]; |
| 167 | }, | 167 | }, |
| 168 | getArticulos : function () { | 168 | getArticulos : function () { |
| 169 | return $http.get(API_ENDPOINT.URL + '/articulos'); | 169 | return $http.get(API_ENDPOINT.URL + '/articulos'); |
| 170 | }, | 170 | }, |
| 171 | getVendedorById : function (idVendedor) { | 171 | getVendedorById : function (idVendedor) { |
| 172 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idVendedor); | 172 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idVendedor); |
| 173 | }, | 173 | }, |
| 174 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 174 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
| 175 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 175 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
| 176 | idDomicilio + '/' + idCliente); | 176 | idDomicilio + '/' + idCliente); |
| 177 | }, | 177 | }, |
| 178 | getBotonFecha : function () { | 178 | getBotonFecha : function () { |
| 179 | return [ | 179 | return [ |
| 180 | { | 180 | { |
| 181 | label: 'Fecha Entrega', | 181 | label: 'Fecha Entrega', |
| 182 | image: 'FechaEntrega.png' | 182 | image: 'FechaEntrega.png' |
| 183 | }, | 183 | }, |
| 184 | ]; | 184 | ]; |
| 185 | }, | 185 | }, |
| 186 | getBotoneraPrecargado: function () { | 186 | getBotoneraPrecargado: function () { |
| 187 | return [ | 187 | return [ |
| 188 | |||
| 189 | { | 188 | { |
| 190 | label: 'Transportista', | 189 | label: 'Transportista', |
| 191 | image: 'transportista.png' | 190 | image: 'transportista.png' |
| 192 | }, | 191 | }, |
| 193 | { | 192 | { |
| 194 | label: 'Chofer', | 193 | label: 'Chofer', |
| 195 | image: 'chofer.png' | 194 | image: 'chofer.png' |
| 196 | }, | 195 | }, |
| 197 | { | 196 | { |
| 198 | label: 'Vehiculo', | 197 | label: 'Vehiculo', |
| 199 | image: 'vehiculos.png' | 198 | image: 'vehiculos.png' |
| 200 | }, | 199 | }, |
| 201 | { | 200 | { |
| 202 | label: 'Tarifario', | 201 | label: 'Tarifario', |
| 203 | image: 'tarifario.png' | 202 | image: 'tarifario.png' |
| 204 | }, | 203 | }, |
| 205 | { | 204 | { |
| 206 | label: 'Datos extra', | 205 | label: 'Datos extra', |
| 207 | image: 'tarifario.png' | 206 | image: 'tarifario.png' |
| 208 | } | 207 | } |
| 209 | ]; | 208 | ]; |
| 210 | }, | 209 | }, |
| 211 | getBotoneraCargarRemito: function () { | 210 | getBotoneraCargarRemito: function () { |
| 212 | return [ | 211 | return [ |
| 213 | { | 212 | { |
| 214 | label: 'Transportista', | 213 | label: 'Transportista', |
| 215 | image: 'transportista.png' | 214 | image: 'transportista.png' |
| 216 | }, | 215 | }, |
| 217 | { | 216 | { |
| 218 | label: 'Chofer', | 217 | label: 'Chofer', |
| 219 | image: 'chofer.png' | 218 | image: 'chofer.png' |
| 220 | }, | 219 | }, |
| 221 | { | 220 | { |
| 222 | label: 'Vehiculo', | 221 | label: 'Vehiculo', |
| 223 | image: 'flete.png' | 222 | image: 'flete.png' |
| 224 | }, | 223 | }, |
| 225 | { | 224 | { |
| 226 | label: 'Remitos', | 225 | label: 'Remitos', |
| 227 | image: 'remito.png' | 226 | image: 'remito.png' |
| 228 | }, | 227 | }, |
| 229 | { | 228 | { |
| 230 | label: 'Tarifario', | 229 | label: 'Tarifario', |
| 231 | image: 'tarifario.png' | 230 | image: 'tarifario.png' |
| 232 | }, | 231 | }, |
| 233 | { | 232 | { |
| 234 | label: 'Datos extra', | 233 | label: 'Datos extra', |
| 235 | image: 'tarifario.png' | 234 | image: 'tarifario.png' |
| 236 | } | 235 | } |
| 237 | ]; | 236 | ]; |
| 238 | }, | 237 | }, |
| 239 | guardarCisternas: function(cisterna, idRemito) { | 238 | guardarCisternas: function(cisterna, idRemito) { |
| 240 | 239 | ||
| 241 | cisterna.cisternaMovimientos.forEach(function(cisternaMovimiento) { | 240 | cisterna.cisternaMovimientos.forEach(function(cisternaMovimiento) { |
| 242 | cisternaMovimiento.idRemito = idRemito; | 241 | cisternaMovimiento.idRemito = idRemito; |
| 243 | }); | 242 | }); |
| 244 | 243 | ||
| 245 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | 244 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + |
| 246 | this.idUsuario + '/' + idRemito, cisterna); | 245 | this.idUsuario + '/' + idRemito, cisterna); |
| 247 | }, | 246 | }, |
| 248 | crearArticulosParaRemito: function(articuloRemito) { | 247 | crearArticulosParaRemito: function(articuloRemito) { |
| 249 | return $http.post(route + '/articulos/remito', | 248 | return $http.post(route + '/articulos/remito', |
| 250 | {articuloRemito: articuloRemito}); | 249 | {articuloRemito: articuloRemito}); |
| 251 | } | 250 | } |
| 252 | }; | 251 | }; |
| 253 | }]); | 252 | }]); |
| 254 | 253 |