Commit 3ab6474d1875bf06c77982de70eebf5995e2e097
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !28
Showing
1 changed file
Show diff stats
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | '$timeout', | 7 | '$timeout', |
| 8 | 'crearNotaPedidoService', | 8 | 'crearNotaPedidoService', |
| 9 | 'focaBotoneraLateralService', | 9 | 'focaBotoneraLateralService', |
| 10 | 'focaModalService', | 10 | 'focaModalService', |
| 11 | 'notaPedidoBusinessService', | 11 | 'notaPedidoBusinessService', |
| 12 | '$rootScope', | 12 | '$rootScope', |
| 13 | 'focaSeguimientoService', | 13 | 'focaSeguimientoService', |
| 14 | 'APP', | 14 | 'APP', |
| 15 | 'focaLoginService', | 15 | 'focaLoginService', |
| 16 | function( | 16 | function( |
| 17 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, | 17 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, |
| 18 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 18 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, |
| 19 | $rootScope, focaSeguimientoService, APP, focaLoginService) | 19 | $rootScope, focaSeguimientoService, APP, focaLoginService) |
| 20 | { | 20 | { |
| 21 | if(APP === 'distribuidor') { | 21 | if(APP === 'distribuidor') { |
| 22 | var idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 22 | var idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
| 23 | $scope.botonera = crearNotaPedidoService.getBotonera(idVendedor); | 23 | $scope.botonera = crearNotaPedidoService.getBotonera(idVendedor); |
| 24 | crearNotaPedidoService.getVendedorById(idVendedor).then( | 24 | crearNotaPedidoService.getVendedorById(idVendedor).then( |
| 25 | function(res) { | 25 | function(res) { |
| 26 | var vendedor = res.data; | 26 | var vendedor = res.data; |
| 27 | $scope.$broadcast('addCabecera', { | 27 | $scope.$broadcast('addCabecera', { |
| 28 | label: 'Vendedor:', | 28 | label: 'Vendedor:', |
| 29 | valor: vendedor.NomVen | 29 | valor: vendedor.NomVen |
| 30 | }); | 30 | }); |
| 31 | $scope.notaPedido.vendedor = vendedor; | 31 | $scope.notaPedido.vendedor = vendedor; |
| 32 | } | 32 | } |
| 33 | ); | 33 | ); |
| 34 | }else { | 34 | }else { |
| 35 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 35 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | $scope.isNumber = angular.isNumber; | 38 | $scope.isNumber = angular.isNumber; |
| 39 | $scope.datepickerAbierto = false; | 39 | $scope.datepickerAbierto = false; |
| 40 | $scope.show = false; | 40 | $scope.show = false; |
| 41 | $scope.cargando = true; | 41 | $scope.cargando = true; |
| 42 | $scope.dateOptions = { | 42 | $scope.dateOptions = { |
| 43 | maxDate: new Date(), | 43 | maxDate: new Date(), |
| 44 | minDate: new Date(2010, 0, 1) | 44 | minDate: new Date(2010, 0, 1) |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | $scope.notaPedido = { | 47 | $scope.notaPedido = { |
| 48 | id: 0, | 48 | id: 0, |
| 49 | vendedor: {}, | 49 | vendedor: {}, |
| 50 | cliente: {}, | 50 | cliente: {}, |
| 51 | proveedor: {}, | 51 | proveedor: {}, |
| 52 | domicilio: {dom: ''}, | 52 | domicilio: {dom: ''}, |
| 53 | moneda: {}, | 53 | moneda: {}, |
| 54 | cotizacion: {} | 54 | cotizacion: {} |
| 55 | }; | 55 | }; |
| 56 | var monedaPorDefecto; | 56 | var monedaPorDefecto; |
| 57 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 57 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 58 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 58 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
| 59 | monedaPorDefecto = res.data[0]; | 59 | monedaPorDefecto = res.data[0]; |
| 60 | $scope.notaPedido.moneda = monedaPorDefecto; | 60 | $scope.notaPedido.moneda = monedaPorDefecto; |
| 61 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 61 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
| 62 | }); | 62 | }); |
| 63 | 63 | ||
| 64 | $scope.cabecera = []; | 64 | $scope.cabecera = []; |
| 65 | $scope.showCabecera = true; | 65 | $scope.showCabecera = true; |
| 66 | 66 | ||
| 67 | $scope.now = new Date(); | 67 | $scope.now = new Date(); |
| 68 | $scope.puntoVenta = '0000'; | 68 | $scope.puntoVenta = '0000'; |
| 69 | $scope.comprobante = '00000000'; | 69 | $scope.comprobante = '00000000'; |
| 70 | $scope.articulosTabla = []; | 70 | $scope.articulosTabla = []; |
| 71 | $scope.idLista = undefined; | 71 | $scope.idLista = undefined; |
| 72 | 72 | ||
| 73 | //SETEO BOTONERA LATERAL | 73 | //SETEO BOTONERA LATERAL |
| 74 | $timeout(function() { | 74 | $timeout(function() { |
| 75 | focaBotoneraLateralService.showSalir(false); | 75 | focaBotoneraLateralService.showSalir(false); |
| 76 | focaBotoneraLateralService.showPausar(true); | 76 | focaBotoneraLateralService.showPausar(true); |
| 77 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | 77 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
| 78 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 78 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 79 | }); | 79 | }); |
| 80 | 80 | ||
| 81 | crearNotaPedidoService.getNumeroNotaPedido().then( | 81 | crearNotaPedidoService.getNumeroNotaPedido().then( |
| 82 | function(res) { | 82 | function(res) { |
| 83 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 83 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 84 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 84 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
| 85 | }, | 85 | }, |
| 86 | function(err) { | 86 | function(err) { |
| 87 | focaModalService.alert('La terminal no esta configurada correctamente'); | 87 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 88 | console.info(err); | 88 | console.info(err); |
| 89 | } | 89 | } |
| 90 | ); | 90 | ); |
| 91 | 91 | ||
| 92 | $scope.crearNotaPedido = function() { | 92 | $scope.crearNotaPedido = function() { |
| 93 | if(!$scope.notaPedido.vendedor.CodVen) { | 93 | if(!$scope.notaPedido.vendedor.CodVen) { |
| 94 | focaModalService.alert('Ingrese Vendedor'); | 94 | focaModalService.alert('Ingrese Vendedor'); |
| 95 | return; | 95 | return; |
| 96 | } else if(!$scope.notaPedido.cliente.COD) { | 96 | } else if(!$scope.notaPedido.cliente.COD) { |
| 97 | focaModalService.alert('Ingrese Cliente'); | 97 | focaModalService.alert('Ingrese Cliente'); |
| 98 | return; | 98 | return; |
| 99 | } else if(!$scope.notaPedido.proveedor.COD) { | 99 | } else if(!$scope.notaPedido.proveedor.COD) { |
| 100 | focaModalService.alert('Ingrese Proveedor'); | 100 | focaModalService.alert('Ingrese Proveedor'); |
| 101 | return; | 101 | return; |
| 102 | } else if(!$scope.notaPedido.moneda.ID) { | 102 | } else if(!$scope.notaPedido.moneda.ID) { |
| 103 | focaModalService.alert('Ingrese Moneda'); | 103 | focaModalService.alert('Ingrese Moneda'); |
| 104 | return; | 104 | return; |
| 105 | } else if(!$scope.notaPedido.cotizacion.ID) { | 105 | } else if(!$scope.notaPedido.cotizacion.ID) { |
| 106 | focaModalService.alert('Ingrese Cotización'); | 106 | focaModalService.alert('Ingrese Cotización'); |
| 107 | return; | 107 | return; |
| 108 | } else if(!$scope.plazosPagos) { | 108 | } else if(!$scope.plazosPagos) { |
| 109 | focaModalService.alert('Ingrese Precios y Condiciones'); | 109 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 110 | return; | 110 | return; |
| 111 | } else if( | 111 | } else if( |
| 112 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 112 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
| 113 | { | 113 | { |
| 114 | focaModalService.alert('Ingrese Flete'); | 114 | focaModalService.alert('Ingrese Flete'); |
| 115 | return; | 115 | return; |
| 116 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 116 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
| 117 | focaModalService.alert('Ingrese Domicilio'); | 117 | focaModalService.alert('Ingrese Domicilio'); |
| 118 | return; | 118 | return; |
| 119 | } else if($scope.articulosTabla.length === 0) { | 119 | } else if($scope.articulosTabla.length === 0) { |
| 120 | focaModalService.alert('Debe cargar al menos un articulo'); | 120 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 121 | return; | 121 | return; |
| 122 | } | 122 | } |
| 123 | focaBotoneraLateralService.startGuardar(); | 123 | focaBotoneraLateralService.startGuardar(); |
| 124 | $scope.saveLoading = true; | 124 | $scope.saveLoading = true; |
| 125 | var notaPedido = { | 125 | var notaPedido = { |
| 126 | id: $scope.notaPedido.id, | 126 | id: $scope.notaPedido.id, |
| 127 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 127 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
| 128 | idVendedor: $scope.notaPedido.vendedor.CodVen, | 128 | idVendedor: $scope.notaPedido.vendedor.CodVen, |
| 129 | idCliente: $scope.notaPedido.cliente.COD, | 129 | idCliente: $scope.notaPedido.cliente.COD, |
| 130 | nombreCliente: $scope.notaPedido.cliente.NOM, | 130 | nombreCliente: $scope.notaPedido.cliente.NOM, |
| 131 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 131 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
| 132 | idProveedor: $scope.notaPedido.proveedor.COD, | 132 | idProveedor: $scope.notaPedido.proveedor.COD, |
| 133 | //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID | 133 | //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID |
| 134 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 134 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 135 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 135 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
| 136 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 136 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 137 | flete: $scope.notaPedido.flete, | 137 | flete: $scope.notaPedido.flete, |
| 138 | fob: $scope.notaPedido.fob, | 138 | fob: $scope.notaPedido.fob, |
| 139 | bomba: $scope.notaPedido.bomba, | 139 | bomba: $scope.notaPedido.bomba, |
| 140 | kilometros: $scope.notaPedido.kilometros, | 140 | kilometros: $scope.notaPedido.kilometros, |
| 141 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 141 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
| 142 | estado: 0, | 142 | estado: 0, |
| 143 | total: $scope.getTotal() | 143 | total: $scope.getTotal() |
| 144 | }; | 144 | }; |
| 145 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 145 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 146 | function(data) { | 146 | function(data) { |
| 147 | // Al guardar los datos de la nota de pedido logueamos la | 147 | // Al guardar los datos de la nota de pedido logueamos la |
| 148 | // actividad para su seguimiento. | 148 | // actividad para su seguimiento. |
| 149 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 149 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
| 150 | focaSeguimientoService.guardarPosicion( | 150 | focaSeguimientoService.guardarPosicion( |
| 151 | 'Nota de pedido', | 151 | 'Nota de pedido', |
| 152 | data.data.id, | 152 | data.data.id, |
| 153 | '' | 153 | '' |
| 154 | ); | 154 | ); |
| 155 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 155 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
| 156 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 156 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
| 157 | 157 | ||
| 158 | if($scope.notaPedido.puntosDescarga) { | 158 | if($scope.notaPedido.puntosDescarga) { |
| 159 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 159 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
| 160 | $scope.notaPedido.puntosDescarga); | 160 | $scope.notaPedido.puntosDescarga); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | var plazos = $scope.plazosPagos; | 163 | var plazos = $scope.plazosPagos; |
| 164 | var plazosACrear = []; | 164 | var plazosACrear = []; |
| 165 | plazos.forEach(function(plazo) { | 165 | plazos.forEach(function(plazo) { |
| 166 | plazosACrear.push({ | 166 | plazosACrear.push({ |
| 167 | idNotaPedido: data.data.id, | 167 | idNotaPedido: data.data.id, |
| 168 | dias: plazo.dias | 168 | dias: plazo.dias |
| 169 | }); | 169 | }); |
| 170 | }); | 170 | }); |
| 171 | if(plazosACrear.length){ | 171 | if(plazosACrear.length){ |
| 172 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 172 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | notaPedidoBusinessService.addEstado(data.data.id, | 175 | notaPedidoBusinessService.addEstado(data.data.id, |
| 176 | $scope.notaPedido.vendedor.CodVen); | 176 | $scope.notaPedido.vendedor.CodVen); |
| 177 | 177 | ||
| 178 | focaBotoneraLateralService.endGuardar(true); | 178 | focaBotoneraLateralService.endGuardar(true); |
| 179 | $scope.saveLoading = false; | 179 | $scope.saveLoading = false; |
| 180 | $scope.$broadcast('cleanCabecera'); | 180 | $scope.$broadcast('cleanCabecera'); |
| 181 | $scope.$broadcast('addCabecera', { | 181 | $scope.$broadcast('addCabecera', { |
| 182 | label: 'Moneda:', | 182 | label: 'Moneda:', |
| 183 | valor: $scope.notaPedido.moneda.DETALLE | 183 | valor: $scope.notaPedido.moneda.DETALLE |
| 184 | }); | 184 | }); |
| 185 | $scope.$broadcast('addCabecera', { | 185 | $scope.$broadcast('addCabecera', { |
| 186 | label: 'Fecha cotizacion:', | 186 | label: 'Fecha cotizacion:', |
| 187 | valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 187 | valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
| 188 | }); | 188 | }); |
| 189 | $scope.$broadcast('addCabecera', { | 189 | $scope.$broadcast('addCabecera', { |
| 190 | label: 'Moneda:', | 190 | label: 'Moneda:', |
| 191 | valor: $scope.notaPedido.moneda.DETALLE | 191 | valor: $scope.notaPedido.moneda.DETALLE |
| 192 | }); | 192 | }); |
| 193 | $scope.$broadcast('addCabecera', { | 193 | $scope.$broadcast('addCabecera', { |
| 194 | label: 'Cotizacion:', | 194 | label: 'Cotizacion:', |
| 195 | valor: $filter('number')($scope.notaPedido.cotizacion.VENDEDOR, '2') | 195 | valor: $filter('number')($scope.notaPedido.cotizacion.VENDEDOR, '2') |
| 196 | }); | 196 | }); |
| 197 | crearNotaPedidoService.getNumeroNotaPedido().then( | 197 | crearNotaPedidoService.getNumeroNotaPedido().then( |
| 198 | function(res) { | 198 | function(res) { |
| 199 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 199 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 200 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 200 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
| 201 | }, | 201 | }, |
| 202 | function(err) { | 202 | function(err) { |
| 203 | focaModalService.alert( | 203 | focaModalService.alert( |
| 204 | 'La terminal no esta configurada correctamente'); | 204 | 'La terminal no esta configurada correctamente'); |
| 205 | console.info(err); | 205 | console.info(err); |
| 206 | } | 206 | } |
| 207 | ); | 207 | ); |
| 208 | $scope.notaPedido.vendedor = {}; | 208 | $scope.notaPedido.vendedor = {}; |
| 209 | $scope.notaPedido.cliente = {}; | 209 | $scope.notaPedido.cliente = {}; |
| 210 | $scope.notaPedido.proveedor = {}; | 210 | $scope.notaPedido.proveedor = {}; |
| 211 | $scope.notaPedido.domicilio = {}; | 211 | $scope.notaPedido.domicilio = {}; |
| 212 | $scope.notaPedido.flete = null; | 212 | $scope.notaPedido.flete = null; |
| 213 | $scope.notaPedido.fob = null; | 213 | $scope.notaPedido.fob = null; |
| 214 | $scope.notaPedido.bomba = null; | 214 | $scope.notaPedido.bomba = null; |
| 215 | $scope.notaPedido.kilometros = null; | 215 | $scope.notaPedido.kilometros = null; |
| 216 | $scope.articulosTabla = []; | 216 | $scope.articulosTabla = []; |
| 217 | }, | 217 | }, |
| 218 | function(error) { | 218 | function(error) { |
| 219 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 219 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 220 | focaBotoneraLateralService.endGuardar(); | 220 | focaBotoneraLateralService.endGuardar(); |
| 221 | $scope.saveLoading = false; | 221 | $scope.saveLoading = false; |
| 222 | console.info(error); | 222 | console.info(error); |
| 223 | } | 223 | } |
| 224 | ); | 224 | ); |
| 225 | }; | 225 | }; |
| 226 | 226 | ||
| 227 | $scope.seleccionarNotaPedido = function() { | 227 | $scope.seleccionarNotaPedido = function() { |
| 228 | var modalInstance = $uibModal.open( | 228 | var modalInstance = $uibModal.open( |
| 229 | { | 229 | { |
| 230 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 230 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 231 | templateUrl: 'foca-modal-nota-pedido.html', | 231 | templateUrl: 'foca-modal-nota-pedido.html', |
| 232 | controller: 'focaModalNotaPedidoController', | 232 | controller: 'focaModalNotaPedidoController', |
| 233 | size: 'lg', | 233 | size: 'lg', |
| 234 | resolve: {usadoPor: function() {return 'notaPedido';}} | 234 | resolve: {usadoPor: function() {return 'notaPedido';}} |
| 235 | } | 235 | } |
| 236 | ); | 236 | ); |
| 237 | modalInstance.result.then( | 237 | modalInstance.result.then( |
| 238 | function(notaPedido) { | 238 | function(notaPedido) { |
| 239 | $scope.now = new Date(notaPedido.fechaCarga); | 239 | $scope.now = new Date(notaPedido.fechaCarga); |
| 240 | //añado cabeceras | 240 | //añado cabeceras |
| 241 | $scope.notaPedido.id = notaPedido.id; | 241 | $scope.notaPedido.id = notaPedido.id; |
| 242 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 242 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 243 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 243 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 244 | var cabeceras = [ | 244 | var cabeceras = [ |
| 245 | { | 245 | { |
| 246 | label: 'Moneda:', | 246 | label: 'Moneda:', |
| 247 | valor: notaPedido.cotizacion.moneda.DETALLE | 247 | valor: notaPedido.cotizacion.moneda.DETALLE |
| 248 | }, | 248 | }, |
| 249 | { | 249 | { |
| 250 | label: 'Fecha cotizacion:', | 250 | label: 'Fecha cotizacion:', |
| 251 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 251 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
| 252 | 'dd/MM/yyyy') | 252 | 'dd/MM/yyyy') |
| 253 | }, | 253 | }, |
| 254 | { | 254 | { |
| 255 | label: 'Cotizacion:', | 255 | label: 'Cotizacion:', |
| 256 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 256 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
| 257 | '2') | 257 | '2') |
| 258 | }, | 258 | }, |
| 259 | { | 259 | { |
| 260 | label: 'Cliente:', | 260 | label: 'Cliente:', |
| 261 | valor: notaPedido.cliente.NOM | 261 | valor: notaPedido.cliente.NOM |
| 262 | }, | 262 | }, |
| 263 | { | 263 | { |
| 264 | label: 'Domicilio:', | 264 | label: 'Domicilio:', |
| 265 | valor: notaPedido.domicilioStamp | 265 | valor: notaPedido.domicilioStamp |
| 266 | }, | 266 | }, |
| 267 | { | 267 | { |
| 268 | label: 'Vendedor:', | 268 | label: 'Vendedor:', |
| 269 | valor: notaPedido.vendedor.NomVen | 269 | valor: notaPedido.vendedor.NomVen |
| 270 | }, | 270 | }, |
| 271 | { | 271 | { |
| 272 | label: 'Proveedor:', | 272 | label: 'Proveedor:', |
| 273 | valor: notaPedido.proveedor.NOM | 273 | valor: notaPedido.proveedor.NOM |
| 274 | }, | 274 | }, |
| 275 | { | 275 | { |
| 276 | label: 'Precios y condiciones:', | 276 | label: 'Precios y condiciones:', |
| 277 | valor: valorPrecioCondicion() + ' ' + | 277 | valor: valorPrecioCondicion() + ' ' + |
| 278 | notaPedidoBusinessService | 278 | notaPedidoBusinessService |
| 279 | .plazoToString(notaPedido.notaPedidoPlazo) | 279 | .plazoToString(notaPedido.notaPedidoPlazo) |
| 280 | }, | 280 | }, |
| 281 | { | 281 | { |
| 282 | label: 'Flete:', | 282 | label: 'Flete:', |
| 283 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 283 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| 284 | notaPedido.flete === 1 ? 'Si' : 'No') | 284 | notaPedido.flete === 1 ? 'Si' : 'No') |
| 285 | } | 285 | } |
| 286 | ]; | 286 | ]; |
| 287 | 287 | ||
| 288 | function valorPrecioCondicion() { | 288 | function valorPrecioCondicion() { |
| 289 | if(notaPedido.idPrecioCondicion > 0) { | 289 | if(notaPedido.idPrecioCondicion > 0) { |
| 290 | return notaPedido.precioCondicion.nombre; | 290 | return notaPedido.precioCondicion.nombre; |
| 291 | } else { | 291 | } else { |
| 292 | return 'Ingreso Manual'; | 292 | return 'Ingreso Manual'; |
| 293 | } | 293 | } |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | if(notaPedido.flete === 1) { | 296 | if(notaPedido.flete === 1) { |
| 297 | var cabeceraBomba = { | 297 | var cabeceraBomba = { |
| 298 | label: 'Bomba:', | 298 | label: 'Bomba:', |
| 299 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 299 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
| 300 | }; | 300 | }; |
| 301 | if(notaPedido.kilometros) { | 301 | if(notaPedido.kilometros) { |
| 302 | var cabeceraKilometros = { | 302 | var cabeceraKilometros = { |
| 303 | label: 'Kilometros:', | 303 | label: 'Kilometros:', |
| 304 | valor: notaPedido.kilometros | 304 | valor: notaPedido.kilometros |
| 305 | }; | 305 | }; |
| 306 | cabeceras.push(cabeceraKilometros); | 306 | cabeceras.push(cabeceraKilometros); |
| 307 | } | 307 | } |
| 308 | cabeceras.push(cabeceraBomba); | 308 | cabeceras.push(cabeceraBomba); |
| 309 | } | 309 | } |
| 310 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | 310 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
| 311 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, | 311 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, |
| 312 | notaPedido.cotizacion.VENDEDOR); | 312 | notaPedido.cotizacion.VENDEDOR); |
| 313 | if(notaPedido.idPrecioCondicion > 0) { | 313 | if(notaPedido.idPrecioCondicion > 0) { |
| 314 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 314 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
| 315 | } else { | 315 | } else { |
| 316 | $scope.idLista = -1; | 316 | $scope.idLista = -1; |
| 317 | } | 317 | } |
| 318 | $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); | 318 | $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); |
| 319 | $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); | 319 | $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); |
| 320 | $scope.notaPedido = notaPedido; | 320 | $scope.notaPedido = notaPedido; |
| 321 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; | 321 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; |
| 322 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; | 322 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; |
| 323 | $scope.notaPedido.puntosDescarga = | 323 | $scope.notaPedido.puntosDescarga = |
| 324 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); | 324 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); |
| 325 | addArrayCabecera(cabeceras); | 325 | addArrayCabecera(cabeceras); |
| 326 | 326 | ||
| 327 | }, function() { | 327 | }, function() { |
| 328 | // funcion ejecutada cuando se cancela el modal | 328 | // funcion ejecutada cuando se cancela el modal |
| 329 | } | 329 | } |
| 330 | ); | 330 | ); |
| 331 | }; | 331 | }; |
| 332 | 332 | ||
| 333 | $scope.seleccionarProductos = function() { | 333 | $scope.seleccionarProductos = function() { |
| 334 | if ($scope.idLista === undefined) { | 334 | if ($scope.idLista === undefined) { |
| 335 | focaModalService.alert( | 335 | focaModalService.alert( |
| 336 | 'Primero seleccione una lista de precio y condicion'); | 336 | 'Primero seleccione una lista de precio y condicion'); |
| 337 | return; | 337 | return; |
| 338 | } | 338 | } |
| 339 | var modalInstance = $uibModal.open( | 339 | var modalInstance = $uibModal.open( |
| 340 | { | 340 | { |
| 341 | ariaLabelledBy: 'Busqueda de Productos', | 341 | ariaLabelledBy: 'Busqueda de Productos', |
| 342 | templateUrl: 'modal-busqueda-productos.html', | 342 | templateUrl: 'modal-busqueda-productos.html', |
| 343 | controller: 'modalBusquedaProductosCtrl', | 343 | controller: 'modalBusquedaProductosCtrl', |
| 344 | resolve: { | 344 | resolve: { |
| 345 | parametroProducto: { | 345 | parametroProducto: { |
| 346 | idLista: $scope.idLista, | 346 | idLista: $scope.idLista, |
| 347 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 347 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 348 | simbolo: $scope.notaPedido.moneda.SIMBOLO | 348 | simbolo: $scope.notaPedido.moneda.SIMBOLO |
| 349 | } | 349 | } |
| 350 | }, | 350 | }, |
| 351 | size: 'lg' | 351 | size: 'lg' |
| 352 | } | 352 | } |
| 353 | ); | 353 | ); |
| 354 | modalInstance.result.then( | 354 | modalInstance.result.then( |
| 355 | function(producto) { | 355 | function(producto) { |
| 356 | var newArt = | 356 | var newArt = |
| 357 | { | 357 | { |
| 358 | id: 0, | 358 | id: 0, |
| 359 | codigo: producto.codigo, | 359 | codigo: producto.codigo, |
| 360 | sector: producto.sector, | 360 | sector: producto.sector, |
| 361 | sectorCodigo: producto.sector + '-' + producto.codigo, | 361 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 362 | descripcion: producto.descripcion, | 362 | descripcion: producto.descripcion, |
| 363 | item: $scope.articulosTabla.length + 1, | 363 | item: $scope.articulosTabla.length + 1, |
| 364 | nombre: producto.descripcion, | 364 | nombre: producto.descripcion, |
| 365 | precio: parseFloat(producto.precio.toFixed(4)), | 365 | precio: parseFloat(producto.precio.toFixed(4)), |
| 366 | costoUnitario: producto.costo, | 366 | costoUnitario: producto.costo, |
| 367 | editCantidad: false, | 367 | editCantidad: false, |
| 368 | editPrecio: false, | 368 | editPrecio: false, |
| 369 | rubro: producto.CodRub, | 369 | rubro: producto.CodRub, |
| 370 | exentoUnitario: producto.precio, | 370 | exentoUnitario: producto.precio, |
| 371 | ivaUnitario: producto.IMPIVA, | 371 | ivaUnitario: producto.IMPIVA, |
| 372 | impuestoInternoUnitario: producto.ImpInt, | 372 | impuestoInternoUnitario: producto.ImpInt, |
| 373 | impuestoInterno1Unitario: producto.ImpInt2, | 373 | impuestoInterno1Unitario: producto.ImpInt2, |
| 374 | impuestoInterno2Unitario: producto.ImpInt3, | 374 | impuestoInterno2Unitario: producto.ImpInt3, |
| 375 | precioLista: producto.precio, | 375 | precioLista: producto.precio, |
| 376 | combustible: 1, | 376 | combustible: 1, |
| 377 | facturado: 0, | 377 | facturado: 0, |
| 378 | idArticulo: producto.id | 378 | idArticulo: producto.id |
| 379 | }; | 379 | }; |
| 380 | $scope.articuloACargar = newArt; | 380 | $scope.articuloACargar = newArt; |
| 381 | $scope.cargando = false; | 381 | $scope.cargando = false; |
| 382 | }, function() { | 382 | }, function() { |
| 383 | // funcion ejecutada cuando se cancela el modal | 383 | // funcion ejecutada cuando se cancela el modal |
| 384 | } | 384 | } |
| 385 | ); | 385 | ); |
| 386 | }; | 386 | }; |
| 387 | 387 | ||
| 388 | $scope.seleccionarPuntosDeDescarga = function() { | 388 | $scope.seleccionarPuntosDeDescarga = function() { |
| 389 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 389 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
| 390 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 390 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 391 | return; | 391 | return; |
| 392 | }else { | 392 | }else { |
| 393 | var modalInstance = $uibModal.open( | 393 | var modalInstance = $uibModal.open( |
| 394 | { | 394 | { |
| 395 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 395 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 396 | templateUrl: 'modal-punto-descarga.html', | 396 | templateUrl: 'modal-punto-descarga.html', |
| 397 | controller: 'focaModalPuntoDescargaController', | 397 | controller: 'focaModalPuntoDescargaController', |
| 398 | size: 'lg', | 398 | size: 'lg', |
| 399 | resolve: { | 399 | resolve: { |
| 400 | filters: { | 400 | filters: { |
| 401 | /*TODO: al traer nota de pedido ya creada | 401 | /*TODO: al traer nota de pedido ya creada |
| 402 | obtener idDomicilio correctamente*/ | 402 | obtener idDomicilio correctamente*/ |
| 403 | idDomicilio: $scope.notaPedido.domicilio.id, | 403 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 404 | idCliente: $scope.notaPedido.cliente.COD, | 404 | idCliente: $scope.notaPedido.cliente.COD, |
| 405 | articulos: $scope.articulosTabla, | 405 | articulos: $scope.articulosTabla, |
| 406 | puntosDescarga: $scope.notaPedido.puntosDescarga | 406 | puntosDescarga: $scope.notaPedido.puntosDescarga |
| 407 | } | 407 | } |
| 408 | } | 408 | } |
| 409 | } | 409 | } |
| 410 | ); | 410 | ); |
| 411 | modalInstance.result.then( | 411 | modalInstance.result.then( |
| 412 | function(puntosDescarga) { | 412 | function(puntosDescarga) { |
| 413 | $scope.notaPedido.puntosDescarga = puntosDescarga; | 413 | $scope.notaPedido.puntosDescarga = puntosDescarga; |
| 414 | }, function() { | 414 | }, function() { |
| 415 | 415 | ||
| 416 | } | 416 | } |
| 417 | ); | 417 | ); |
| 418 | } | 418 | } |
| 419 | }; | 419 | }; |
| 420 | 420 | ||
| 421 | $scope.seleccionarVendedor = function() { | 421 | $scope.seleccionarVendedor = function() { |
| 422 | if(validarNotaRemitada()) { | 422 | if(validarNotaRemitada()) { |
| 423 | var modalInstance = $uibModal.open( | 423 | var modalInstance = $uibModal.open( |
| 424 | { | 424 | { |
| 425 | ariaLabelledBy: 'Busqueda de Vendedores', | 425 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 426 | templateUrl: 'modal-vendedores.html', | 426 | templateUrl: 'modal-vendedores.html', |
| 427 | controller: 'modalVendedoresCtrl', | 427 | controller: 'modalVendedoresCtrl', |
| 428 | size: 'lg' | 428 | size: 'lg' |
| 429 | } | 429 | } |
| 430 | ); | 430 | ); |
| 431 | modalInstance.result.then( | 431 | modalInstance.result.then( |
| 432 | function(vendedor) { | 432 | function(vendedor) { |
| 433 | $scope.$broadcast('addCabecera', { | 433 | $scope.$broadcast('addCabecera', { |
| 434 | label: 'Vendedor:', | 434 | label: 'Vendedor:', |
| 435 | valor: vendedor.NomVen | 435 | valor: vendedor.NomVen |
| 436 | }); | 436 | }); |
| 437 | $scope.notaPedido.vendedor = vendedor; | 437 | $scope.notaPedido.vendedor = vendedor; |
| 438 | }, function() { | 438 | }, function() { |
| 439 | 439 | ||
| 440 | } | 440 | } |
| 441 | ); | 441 | ); |
| 442 | } | 442 | } |
| 443 | }; | 443 | }; |
| 444 | 444 | ||
| 445 | $scope.seleccionarProveedor = function() { | 445 | $scope.seleccionarProveedor = function() { |
| 446 | if(validarNotaRemitada()) { | 446 | if(validarNotaRemitada()) { |
| 447 | var modalInstance = $uibModal.open( | 447 | var modalInstance = $uibModal.open( |
| 448 | { | 448 | { |
| 449 | ariaLabelledBy: 'Busqueda de Proveedor', | 449 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 450 | templateUrl: 'modal-proveedor.html', | 450 | templateUrl: 'modal-proveedor.html', |
| 451 | controller: 'focaModalProveedorCtrl', | 451 | controller: 'focaModalProveedorCtrl', |
| 452 | size: 'lg', | 452 | size: 'lg', |
| 453 | resolve: { | 453 | resolve: { |
| 454 | transportista: function() { | 454 | transportista: function() { |
| 455 | return false; | 455 | return false; |
| 456 | } | 456 | } |
| 457 | } | 457 | } |
| 458 | } | 458 | } |
| 459 | ); | 459 | ); |
| 460 | modalInstance.result.then( | 460 | modalInstance.result.then( |
| 461 | function(proveedor) { | 461 | function(proveedor) { |
| 462 | $scope.notaPedido.proveedor = proveedor; | 462 | $scope.notaPedido.proveedor = proveedor; |
| 463 | $scope.$broadcast('addCabecera', { | 463 | $scope.$broadcast('addCabecera', { |
| 464 | label: 'Proveedor:', | 464 | label: 'Proveedor:', |
| 465 | valor: proveedor.NOM | 465 | valor: proveedor.NOM |
| 466 | }); | 466 | }); |
| 467 | }, function() { | 467 | }, function() { |
| 468 | 468 | ||
| 469 | } | 469 | } |
| 470 | ); | 470 | ); |
| 471 | } | 471 | } |
| 472 | }; | 472 | }; |
| 473 | 473 | ||
| 474 | $scope.seleccionarCliente = function() { | 474 | $scope.seleccionarCliente = function() { |
| 475 | if(!$scope.notaPedido.vendedor.CodVen) { | ||
| 476 | focaModalService.alert('Primero seleccione un vendedor'); | ||
| 477 | return; | ||
| 478 | } | ||
| 475 | if(validarNotaRemitada()) { | 479 | if(validarNotaRemitada()) { |
| 476 | var modalInstance = $uibModal.open( | 480 | var modalInstance = $uibModal.open( |
| 477 | { | 481 | { |
| 478 | ariaLabelledBy: 'Busqueda de Cliente', | 482 | ariaLabelledBy: 'Busqueda de Cliente', |
| 479 | templateUrl: 'foca-busqueda-cliente-modal.html', | 483 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 480 | controller: 'focaBusquedaClienteModalController', | 484 | controller: 'focaBusquedaClienteModalController', |
| 485 | resolve: { | ||
| 486 | vendedor: function() { return $scope.notaPedido.vendedor; } | ||
| 487 | }, | ||
| 481 | size: 'lg' | 488 | size: 'lg' |
| 482 | } | 489 | } |
| 483 | ); | 490 | ); |
| 484 | modalInstance.result.then( | 491 | modalInstance.result.then( |
| 485 | function(cliente) { | 492 | function(cliente) { |
| 486 | $scope.abrirModalDomicilios(cliente); | 493 | $scope.abrirModalDomicilios(cliente); |
| 487 | }, function() {} | 494 | }, function() {} |
| 488 | ); | 495 | ); |
| 489 | } | 496 | } |
| 490 | }; | 497 | }; |
| 491 | 498 | ||
| 492 | $scope.abrirModalDomicilios = function(cliente) { | 499 | $scope.abrirModalDomicilios = function(cliente) { |
| 493 | var modalInstanceDomicilio = $uibModal.open( | 500 | var modalInstanceDomicilio = $uibModal.open( |
| 494 | { | 501 | { |
| 495 | ariaLabelledBy: 'Busqueda de Domicilios', | 502 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 496 | templateUrl: 'modal-domicilio.html', | 503 | templateUrl: 'modal-domicilio.html', |
| 497 | controller: 'focaModalDomicilioController', | 504 | controller: 'focaModalDomicilioController', |
| 498 | resolve: { | 505 | resolve: { |
| 499 | idCliente: function() { | 506 | idCliente: function() { return cliente.cod; }, |
| 500 | return cliente.cod; | ||
| 501 | }, | ||
| 502 | esNuevo: function() { return cliente.esNuevo; }, | 507 | esNuevo: function() { return cliente.esNuevo; }, |
| 503 | articulos: function() { | 508 | articulos: function() { return $scope.articulosTabla; }, |
| 504 | return $scope.articulosTabla; | ||
| 505 | } | ||
| 506 | }, | 509 | }, |
| 507 | size: 'lg', | 510 | size: 'lg', |
| 508 | } | 511 | } |
| 509 | ); | 512 | ); |
| 510 | modalInstanceDomicilio.result.then( | 513 | modalInstanceDomicilio.result.then( |
| 511 | function(domicilio) { | 514 | function(domicilio) { |
| 512 | $scope.notaPedido.domicilio = domicilio; | 515 | $scope.notaPedido.domicilio = domicilio; |
| 513 | $scope.notaPedido.cliente = { | 516 | $scope.notaPedido.cliente = { |
| 514 | COD: cliente.cod, | 517 | COD: cliente.cod, |
| 515 | CUIT: cliente.cuit, | 518 | CUIT: cliente.cuit, |
| 516 | NOM: cliente.nom | 519 | NOM: cliente.nom |
| 517 | }; | 520 | }; |
| 518 | var domicilioStamp = | 521 | var domicilioStamp = |
| 519 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 522 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 520 | domicilio.Localidad + ', ' + domicilio.Provincia; | 523 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 521 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 524 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
| 522 | 525 | ||
| 523 | $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; | 526 | $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; |
| 524 | 527 | ||
| 525 | $scope.$broadcast('addCabecera', { | 528 | $scope.$broadcast('addCabecera', { |
| 526 | label: 'Cliente:', | 529 | label: 'Cliente:', |
| 527 | valor: cliente.nom | 530 | valor: cliente.nom |
| 528 | }); | 531 | }); |
| 529 | $scope.$broadcast('addCabecera', { | 532 | $scope.$broadcast('addCabecera', { |
| 530 | label: 'Domicilio:', | 533 | label: 'Domicilio:', |
| 531 | valor: domicilioStamp | 534 | valor: domicilioStamp |
| 532 | }); | 535 | }); |
| 533 | crearNotaPedidoService | 536 | crearNotaPedidoService |
| 534 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 537 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
| 535 | .then(function(res) { | 538 | .then(function(res) { |
| 536 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | 539 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); |
| 537 | }); | 540 | }); |
| 538 | }, function() { | 541 | }, function() { |
| 539 | $scope.seleccionarCliente(); | 542 | $scope.seleccionarCliente(); |
| 540 | return; | 543 | return; |
| 541 | } | 544 | } |
| 542 | ); | 545 | ); |
| 543 | }; | 546 | }; |
| 544 | 547 | ||
| 545 | $scope.getTotal = function() { | 548 | $scope.getTotal = function() { |
| 546 | var total = 0; | 549 | var total = 0; |
| 547 | var arrayTempArticulos = $scope.articulosTabla; | 550 | var arrayTempArticulos = $scope.articulosTabla; |
| 548 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 551 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 549 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 552 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 550 | } | 553 | } |
| 551 | return parseFloat(total.toFixed(2)); | 554 | return parseFloat(total.toFixed(2)); |
| 552 | }; | 555 | }; |
| 553 | 556 | ||
| 554 | $scope.getSubTotal = function() { | 557 | $scope.getSubTotal = function() { |
| 555 | if($scope.articuloACargar) { | 558 | if($scope.articuloACargar) { |
| 556 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 559 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 557 | } | 560 | } |
| 558 | }; | 561 | }; |
| 559 | 562 | ||
| 560 | $scope.seleccionarPreciosYCondiciones = function() { | 563 | $scope.seleccionarPreciosYCondiciones = function() { |
| 561 | if(validarNotaRemitada()) { | 564 | if(validarNotaRemitada()) { |
| 562 | var modalInstance = $uibModal.open( | 565 | var modalInstance = $uibModal.open( |
| 563 | { | 566 | { |
| 564 | ariaLabelledBy: 'Busqueda de Precio Condición', | 567 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 565 | templateUrl: 'modal-precio-condicion.html', | 568 | templateUrl: 'modal-precio-condicion.html', |
| 566 | controller: 'focaModalPrecioCondicionController', | 569 | controller: 'focaModalPrecioCondicionController', |
| 567 | size: 'lg' | 570 | size: 'lg' |
| 568 | } | 571 | } |
| 569 | ); | 572 | ); |
| 570 | modalInstance.result.then( | 573 | modalInstance.result.then( |
| 571 | function(precioCondicion) { | 574 | function(precioCondicion) { |
| 572 | var cabecera = ''; | 575 | var cabecera = ''; |
| 573 | var plazosConcat = ''; | 576 | var plazosConcat = ''; |
| 574 | if(!Array.isArray(precioCondicion)) { | 577 | if(!Array.isArray(precioCondicion)) { |
| 575 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 578 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
| 576 | $scope.plazosPagos = precioCondicion.plazoPago; | 579 | $scope.plazosPagos = precioCondicion.plazoPago; |
| 577 | $scope.idLista = precioCondicion.idListaPrecio; | 580 | $scope.idLista = precioCondicion.idListaPrecio; |
| 578 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 581 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 579 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 582 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 580 | } | 583 | } |
| 581 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 584 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 582 | } else { //Cuando se ingresan los plazos manualmente | 585 | } else { //Cuando se ingresan los plazos manualmente |
| 583 | $scope.notaPedido.idPrecioCondicion = 0; | 586 | $scope.notaPedido.idPrecioCondicion = 0; |
| 584 | //-1, el modal productos busca todos los productos | 587 | //-1, el modal productos busca todos los productos |
| 585 | $scope.idLista = -1; | 588 | $scope.idLista = -1; |
| 586 | $scope.plazosPagos = precioCondicion; | 589 | $scope.plazosPagos = precioCondicion; |
| 587 | for(var j = 0; j < precioCondicion.length; j++) { | 590 | for(var j = 0; j < precioCondicion.length; j++) { |
| 588 | plazosConcat += precioCondicion[j].dias + ' '; | 591 | plazosConcat += precioCondicion[j].dias + ' '; |
| 589 | } | 592 | } |
| 590 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 593 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 591 | } | 594 | } |
| 592 | $scope.articulosTabla = []; | 595 | $scope.articulosTabla = []; |
| 593 | $scope.$broadcast('addCabecera', { | 596 | $scope.$broadcast('addCabecera', { |
| 594 | label: 'Precios y condiciones:', | 597 | label: 'Precios y condiciones:', |
| 595 | valor: cabecera | 598 | valor: cabecera |
| 596 | }); | 599 | }); |
| 597 | }, function() { | 600 | }, function() { |
| 598 | 601 | ||
| 599 | } | 602 | } |
| 600 | ); | 603 | ); |
| 601 | } | 604 | } |
| 602 | }; | 605 | }; |
| 603 | 606 | ||
| 604 | $scope.seleccionarFlete = function() { | 607 | $scope.seleccionarFlete = function() { |
| 605 | if(validarNotaRemitada()) { | 608 | if(validarNotaRemitada()) { |
| 606 | var modalInstance = $uibModal.open( | 609 | var modalInstance = $uibModal.open( |
| 607 | { | 610 | { |
| 608 | ariaLabelledBy: 'Busqueda de Flete', | 611 | ariaLabelledBy: 'Busqueda de Flete', |
| 609 | templateUrl: 'modal-flete.html', | 612 | templateUrl: 'modal-flete.html', |
| 610 | controller: 'focaModalFleteController', | 613 | controller: 'focaModalFleteController', |
| 611 | size: 'lg', | 614 | size: 'lg', |
| 612 | resolve: { | 615 | resolve: { |
| 613 | parametrosFlete: | 616 | parametrosFlete: |
| 614 | function() { | 617 | function() { |
| 615 | return { | 618 | return { |
| 616 | flete: $scope.notaPedido.fob ? 'FOB' : | 619 | flete: $scope.notaPedido.fob ? 'FOB' : |
| 617 | ( $scope.notaPedido.flete ? '1' : | 620 | ( $scope.notaPedido.flete ? '1' : |
| 618 | ($scope.notaPedido.flete === undefined ? | 621 | ($scope.notaPedido.flete === undefined ? |
| 619 | null : '0')), | 622 | null : '0')), |
| 620 | bomba: $scope.notaPedido.bomba ? '1' : | 623 | bomba: $scope.notaPedido.bomba ? '1' : |
| 621 | ($scope.notaPedido.bomba === undefined ? | 624 | ($scope.notaPedido.bomba === undefined ? |
| 622 | null : '0'), | 625 | null : '0'), |
| 623 | kilometros: $scope.notaPedido.kilometros | 626 | kilometros: $scope.notaPedido.kilometros |
| 624 | }; | 627 | }; |
| 625 | } | 628 | } |
| 626 | } | 629 | } |
| 627 | } | 630 | } |
| 628 | ); | 631 | ); |
| 629 | modalInstance.result.then( | 632 | modalInstance.result.then( |
| 630 | function(datos) { | 633 | function(datos) { |
| 631 | $scope.notaPedido.flete = datos.flete; | 634 | $scope.notaPedido.flete = datos.flete; |
| 632 | $scope.notaPedido.fob = datos.FOB; | 635 | $scope.notaPedido.fob = datos.FOB; |
| 633 | $scope.notaPedido.bomba = datos.bomba; | 636 | $scope.notaPedido.bomba = datos.bomba; |
| 634 | $scope.notaPedido.kilometros = datos.kilometros; | 637 | $scope.notaPedido.kilometros = datos.kilometros; |
| 635 | $scope.$broadcast('addCabecera', { | 638 | $scope.$broadcast('addCabecera', { |
| 636 | label: 'Flete:', | 639 | label: 'Flete:', |
| 637 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 640 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
| 638 | }); | 641 | }); |
| 639 | if(datos.flete) { | 642 | if(datos.flete) { |
| 640 | $scope.$broadcast('addCabecera', { | 643 | $scope.$broadcast('addCabecera', { |
| 641 | label: 'Bomba:', | 644 | label: 'Bomba:', |
| 642 | valor: datos.bomba ? 'Si' : 'No' | 645 | valor: datos.bomba ? 'Si' : 'No' |
| 643 | }); | 646 | }); |
| 644 | $scope.$broadcast('addCabecera', { | 647 | $scope.$broadcast('addCabecera', { |
| 645 | label: 'Kilometros:', | 648 | label: 'Kilometros:', |
| 646 | valor: datos.kilometros | 649 | valor: datos.kilometros |
| 647 | }); | 650 | }); |
| 648 | } else { | 651 | } else { |
| 649 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 652 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 650 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 653 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 651 | $scope.notaPedido.bomba = false; | 654 | $scope.notaPedido.bomba = false; |
| 652 | $scope.notaPedido.kilometros = null; | 655 | $scope.notaPedido.kilometros = null; |
| 653 | } | 656 | } |
| 654 | }, function() { | 657 | }, function() { |
| 655 | 658 | ||
| 656 | } | 659 | } |
| 657 | ); | 660 | ); |
| 658 | } | 661 | } |
| 659 | }; | 662 | }; |
| 660 | 663 | ||
| 661 | $scope.seleccionarMoneda = function() { | 664 | $scope.seleccionarMoneda = function() { |
| 662 | if(validarNotaRemitada()) { | 665 | if(validarNotaRemitada()) { |
| 663 | var modalInstance = $uibModal.open( | 666 | var modalInstance = $uibModal.open( |
| 664 | { | 667 | { |
| 665 | ariaLabelledBy: 'Busqueda de Moneda', | 668 | ariaLabelledBy: 'Busqueda de Moneda', |
| 666 | templateUrl: 'modal-moneda.html', | 669 | templateUrl: 'modal-moneda.html', |
| 667 | controller: 'focaModalMonedaController', | 670 | controller: 'focaModalMonedaController', |
| 668 | size: 'lg' | 671 | size: 'lg' |
| 669 | } | 672 | } |
| 670 | ); | 673 | ); |
| 671 | modalInstance.result.then( | 674 | modalInstance.result.then( |
| 672 | function(moneda) { | 675 | function(moneda) { |
| 673 | $scope.abrirModalCotizacion(moneda); | 676 | $scope.abrirModalCotizacion(moneda); |
| 674 | }, function() { | 677 | }, function() { |
| 675 | 678 | ||
| 676 | } | 679 | } |
| 677 | ); | 680 | ); |
| 678 | } | 681 | } |
| 679 | }; | 682 | }; |
| 680 | 683 | ||
| 681 | $scope.abrirModalCotizacion = function(moneda) { | 684 | $scope.abrirModalCotizacion = function(moneda) { |
| 682 | var modalInstance = $uibModal.open( | 685 | var modalInstance = $uibModal.open( |
| 683 | { | 686 | { |
| 684 | ariaLabelledBy: 'Busqueda de Cotización', | 687 | ariaLabelledBy: 'Busqueda de Cotización', |
| 685 | templateUrl: 'modal-cotizacion.html', | 688 | templateUrl: 'modal-cotizacion.html', |
| 686 | controller: 'focaModalCotizacionController', | 689 | controller: 'focaModalCotizacionController', |
| 687 | size: 'lg', | 690 | size: 'lg', |
| 688 | resolve: {idMoneda: function() {return moneda.ID;}} | 691 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 689 | } | 692 | } |
| 690 | ); | 693 | ); |
| 691 | modalInstance.result.then( | 694 | modalInstance.result.then( |
| 692 | function(cotizacion) { | 695 | function(cotizacion) { |
| 693 | var articulosTablaTemp = $scope.articulosTabla; | 696 | var articulosTablaTemp = $scope.articulosTabla; |
| 694 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 697 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
| 695 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 698 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 696 | $scope.notaPedido.cotizacion.VENDEDOR; | 699 | $scope.notaPedido.cotizacion.VENDEDOR; |
| 697 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 700 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 698 | cotizacion.VENDEDOR; | 701 | cotizacion.VENDEDOR; |
| 699 | } | 702 | } |
| 700 | $scope.articulosTabla = articulosTablaTemp; | 703 | $scope.articulosTabla = articulosTablaTemp; |
| 701 | $scope.notaPedido.moneda = moneda; | 704 | $scope.notaPedido.moneda = moneda; |
| 702 | $scope.notaPedido.cotizacion = cotizacion; | 705 | $scope.notaPedido.cotizacion = cotizacion; |
| 703 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 706 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 704 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 707 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 705 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 708 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 706 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 709 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 707 | }else { | 710 | }else { |
| 708 | $scope.$broadcast('addCabecera', { | 711 | $scope.$broadcast('addCabecera', { |
| 709 | label: 'Moneda:', | 712 | label: 'Moneda:', |
| 710 | valor: moneda.DETALLE | 713 | valor: moneda.DETALLE |
| 711 | }); | 714 | }); |
| 712 | $scope.$broadcast('addCabecera', { | 715 | $scope.$broadcast('addCabecera', { |
| 713 | label: 'Fecha cotizacion:', | 716 | label: 'Fecha cotizacion:', |
| 714 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 717 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 715 | }); | 718 | }); |
| 716 | $scope.$broadcast('addCabecera', { | 719 | $scope.$broadcast('addCabecera', { |
| 717 | label: 'Cotizacion:', | 720 | label: 'Cotizacion:', |
| 718 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 721 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 719 | }); | 722 | }); |
| 720 | } | 723 | } |
| 721 | }, function() { | 724 | }, function() { |
| 722 | 725 | ||
| 723 | } | 726 | } |
| 724 | ); | 727 | ); |
| 725 | }; | 728 | }; |
| 726 | 729 | ||
| 727 | $scope.agregarATabla = function(key) { | 730 | $scope.agregarATabla = function(key) { |
| 728 | if(key === 13) { | 731 | if(key === 13) { |
| 729 | if($scope.articuloACargar.cantidad === undefined || | 732 | if($scope.articuloACargar.cantidad === undefined || |
| 730 | $scope.articuloACargar.cantidad === 0 || | 733 | $scope.articuloACargar.cantidad === 0 || |
| 731 | $scope.articuloACargar.cantidad === null ) { | 734 | $scope.articuloACargar.cantidad === null ) { |
| 732 | focaModalService.alert('El valor debe ser al menos 1'); | 735 | focaModalService.alert('El valor debe ser al menos 1'); |
| 733 | return; | 736 | return; |
| 734 | } | 737 | } |
| 735 | delete $scope.articuloACargar.sectorCodigo; | 738 | delete $scope.articuloACargar.sectorCodigo; |
| 736 | $scope.articulosTabla.push($scope.articuloACargar); | 739 | $scope.articulosTabla.push($scope.articuloACargar); |
| 737 | $scope.cargando = true; | 740 | $scope.cargando = true; |
| 738 | } | 741 | } |
| 739 | }; | 742 | }; |
| 740 | 743 | ||
| 741 | $scope.quitarArticulo = function(key) { | 744 | $scope.quitarArticulo = function(key) { |
| 742 | $scope.articulosTabla.splice(key, 1); | 745 | $scope.articulosTabla.splice(key, 1); |
| 743 | }; | 746 | }; |
| 744 | 747 | ||
| 745 | $scope.editarArticulo = function(key, articulo) { | 748 | $scope.editarArticulo = function(key, articulo) { |
| 746 | if(key === 13) { | 749 | if(key === 13) { |
| 747 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 750 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 748 | articulo.cantidad === undefined) { | 751 | articulo.cantidad === undefined) { |
| 749 | focaModalService.alert('El valor debe ser al menos 1'); | 752 | focaModalService.alert('El valor debe ser al menos 1'); |
| 750 | return; | 753 | return; |
| 751 | } | 754 | } |
| 752 | articulo.editCantidad = false; | 755 | articulo.editCantidad = false; |
| 753 | articulo.editPrecio = false; | 756 | articulo.editPrecio = false; |
| 754 | } | 757 | } |
| 755 | }; | 758 | }; |
| 756 | 759 | ||
| 757 | $scope.cambioEdit = function(articulo, propiedad) { | 760 | $scope.cambioEdit = function(articulo, propiedad) { |
| 758 | if(propiedad === 'cantidad') { | 761 | if(propiedad === 'cantidad') { |
| 759 | articulo.editCantidad = true; | 762 | articulo.editCantidad = true; |
| 760 | } else if(propiedad === 'precio') { | 763 | } else if(propiedad === 'precio') { |
| 761 | articulo.editPrecio = true; | 764 | articulo.editPrecio = true; |
| 762 | } | 765 | } |
| 763 | }; | 766 | }; |
| 764 | 767 | ||
| 765 | $scope.resetFilter = function() { | 768 | $scope.resetFilter = function() { |
| 766 | $scope.articuloACargar = {}; | 769 | $scope.articuloACargar = {}; |
| 767 | $scope.cargando = true; | 770 | $scope.cargando = true; |
| 768 | }; | 771 | }; |
| 769 | //Recibe aviso si el teclado está en uso | 772 | //Recibe aviso si el teclado está en uso |
| 770 | $rootScope.$on('usarTeclado', function(event, data) { | 773 | $rootScope.$on('usarTeclado', function(event, data) { |
| 771 | if(data) { | 774 | if(data) { |
| 772 | $scope.mostrarTeclado = true; | 775 | $scope.mostrarTeclado = true; |
| 773 | return; | 776 | return; |
| 774 | } | 777 | } |
| 775 | $scope.mostrarTeclado = false; | 778 | $scope.mostrarTeclado = false; |
| 776 | }); | 779 | }); |
| 777 | 780 | ||
| 778 | $scope.selectFocus = function($event) { | 781 | $scope.selectFocus = function($event) { |
| 779 | // Si el teclado esta en uso no selecciona el valor | 782 | // Si el teclado esta en uso no selecciona el valor |
| 780 | if($scope.mostrarTeclado) { | 783 | if($scope.mostrarTeclado) { |
| 781 | return; | 784 | return; |
| 782 | } | 785 | } |
| 783 | $event.target.select(); | 786 | $event.target.select(); |
| 784 | }; | 787 | }; |
| 785 | 788 | ||
| 786 | $scope.salir = function() { | 789 | $scope.salir = function() { |
| 787 | $location.path('/'); | 790 | $location.path('/'); |
| 788 | }; | 791 | }; |
| 789 | 792 | ||
| 790 | $scope.parsearATexto = function(articulo) { | 793 | $scope.parsearATexto = function(articulo) { |
| 791 | articulo.cantidad = parseFloat(articulo.cantidad); | 794 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 792 | articulo.precio = parseFloat(articulo.precio); | 795 | articulo.precio = parseFloat(articulo.precio); |
| 793 | }; | 796 | }; |
| 794 | 797 | ||
| 795 | function addArrayCabecera(array) { | 798 | function addArrayCabecera(array) { |
| 796 | for(var i = 0; i < array.length; i++) { | 799 | for(var i = 0; i < array.length; i++) { |
| 797 | $scope.$broadcast('addCabecera', { | 800 | $scope.$broadcast('addCabecera', { |
| 798 | label: array[i].label, | 801 | label: array[i].label, |
| 799 | valor: array[i].valor | 802 | valor: array[i].valor |
| 800 | }); | 803 | }); |
| 801 | } | 804 | } |
| 802 | } | 805 | } |
| 803 | 806 | ||
| 804 | function rellenar(relleno, longitud) { | 807 | function rellenar(relleno, longitud) { |
| 805 | relleno = '' + relleno; | 808 | relleno = '' + relleno; |
| 806 | while (relleno.length < longitud) { | 809 | while (relleno.length < longitud) { |
| 807 | relleno = '0' + relleno; | 810 | relleno = '0' + relleno; |
| 808 | } | 811 | } |
| 809 | 812 | ||
| 810 | return relleno; | 813 | return relleno; |
| 811 | } | 814 | } |
| 812 | 815 | ||
| 813 | function validarNotaRemitada() { | 816 | function validarNotaRemitada() { |
| 814 | if(!$scope.notaPedido.idRemito) { | 817 | if(!$scope.notaPedido.idRemito) { |
| 815 | return true; | 818 | return true; |
| 816 | }else{ | 819 | }else{ |
| 817 | focaModalService.alert('No se puede editar una nota de pedido remitada'); | 820 | focaModalService.alert('No se puede editar una nota de pedido remitada'); |
| 818 | return false; | 821 | return false; |
| 819 | } | 822 | } |
| 820 | } | 823 | } |
| 821 | function formatearPuntosDescarga(puntosDescarga) { | 824 | function formatearPuntosDescarga(puntosDescarga) { |
| 822 | var result = []; | 825 | var result = []; |
| 823 | 826 | ||
| 824 | puntosDescarga.forEach(function(el) { | 827 | puntosDescarga.forEach(function(el) { |
| 825 | var puntoDescarga = result.filter(function(resultPunto) { | 828 | var puntoDescarga = result.filter(function(resultPunto) { |
| 826 | return resultPunto.id == el.idPuntoDescarga; | 829 | return resultPunto.id == el.idPuntoDescarga; |
| 827 | }); | 830 | }); |
| 828 | 831 | ||
| 829 | if(puntoDescarga.length) { | 832 | if(puntoDescarga.length) { |
| 830 | puntoDescarga[0].articulosAgregados.push({ | 833 | puntoDescarga[0].articulosAgregados.push({ |
| 831 | cantidad: el.cantidad, | 834 | cantidad: el.cantidad, |
| 832 | descripcion: el.producto.descripcion, | 835 | descripcion: el.producto.descripcion, |
| 833 | id: el.producto.id | 836 | id: el.producto.id |
| 834 | }); | 837 | }); |
| 835 | }else { | 838 | }else { |
| 836 | result.push({ | 839 | result.push({ |
| 837 | id: el.puntoDescarga.id, | 840 | id: el.puntoDescarga.id, |
| 838 | id_cliente: el.puntoDescarga.id_cliente, | 841 | id_cliente: el.puntoDescarga.id_cliente, |
| 839 | id_da_config_0: el.puntoDescarga.id_da_config_0, | 842 | id_da_config_0: el.puntoDescarga.id_da_config_0, |
| 840 | latitud: el.puntoDescarga.latitud, | 843 | latitud: el.puntoDescarga.latitud, |
| 841 | longitud: el.puntoDescarga.longitud, | 844 | longitud: el.puntoDescarga.longitud, |
| 842 | descripcion: el.puntoDescarga.descripcion, | 845 | descripcion: el.puntoDescarga.descripcion, |
| 843 | articulosAgregados: [ | 846 | articulosAgregados: [ |
| 844 | { | 847 | { |
| 845 | cantidad: el.cantidad, | 848 | cantidad: el.cantidad, |
| 846 | descripcion: el.producto.descripcion, | 849 | descripcion: el.producto.descripcion, |
| 847 | id: el.producto.id | 850 | id: el.producto.id |
| 848 | } | 851 | } |
| 849 | ] | 852 | ] |
| 850 | }); | 853 | }); |
| 851 | } | 854 | } |
| 852 | }); | 855 | }); |
| 853 | return result; | 856 | return result; |
| 854 | } | 857 | } |
| 855 | 858 | ||
| 856 | function salir() { | 859 | function salir() { |
| 857 | var notaPedido = { | 860 | var notaPedido = { |
| 858 | id: 0, | 861 | id: 0, |
| 859 | vendedor: {}, | 862 | vendedor: {}, |
| 860 | cliente: {}, | 863 | cliente: {}, |
| 861 | proveedor: {}, | 864 | proveedor: {}, |
| 862 | domicilio: {dom: ''}, | 865 | domicilio: {dom: ''}, |
| 863 | moneda: $scope.notaPedido.moneda, | 866 | moneda: $scope.notaPedido.moneda, |
| 864 | cotizacion: $scope.notaPedido.cotizacion | 867 | cotizacion: $scope.notaPedido.cotizacion |
| 865 | }; | 868 | }; |
| 866 | if(JSON.stringify($scope.notaPedido) !== JSON.stringify(notaPedido)) { | 869 | if(JSON.stringify($scope.notaPedido) !== JSON.stringify(notaPedido)) { |
| 867 | focaModalService | 870 | focaModalService |
| 868 | .confirm('¿Esta seguro de que desea salir? ' + | 871 | .confirm('¿Esta seguro de que desea salir? ' + |
| 869 | 'Se perderán todos los datos cargados.') | 872 | 'Se perderán todos los datos cargados.') |
| 870 | .then(function(data) { | 873 | .then(function(data) { |
| 871 | if(data) $location.path('/'); | 874 | if(data) $location.path('/'); |
| 872 | }); | 875 | }); |
| 873 | }else { | 876 | }else { |
| 874 | $location.path('/'); | 877 | $location.path('/'); |
| 875 | } | 878 | } |