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