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