Commit cc5139b493bbba0304be43aec606777f609fbf41
1 parent
41b789f145
Exists in
master
parametros --TODO buscador clientes
Showing
2 changed files
with
15 additions
and
14 deletions
Show diff stats
src/js/controller.js
| 1 | angular.module('focaParametros') | 1 | angular.module('focaParametros') |
| 2 | .controller('focaParametrosCtrl', [ | 2 | .controller('focaParametrosCtrl', [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | 'focaParametrosService', | 4 | 'focaParametrosService', |
| 5 | 'focaBotoneraLateralService', | 5 | 'focaBotoneraLateralService', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | 'focaModalService', | 7 | 'focaModalService', |
| 8 | '$timeout', | 8 | '$timeout', |
| 9 | '$uibModal', | 9 | '$uibModal', |
| 10 | '$location', | 10 | '$location', |
| 11 | function($scope, focaParametrosService, focaBotoneraLateralService, $filter, | 11 | function($scope, focaParametrosService, focaBotoneraLateralService, $filter, |
| 12 | focaModalService, $timeout, $uibModal, $location) | 12 | focaModalService, $timeout, $uibModal, $location) |
| 13 | { | 13 | { |
| 14 | 14 | ||
| 15 | $scope.botonera = []; | 15 | $scope.botonera = []; |
| 16 | $scope.now = new Date(); | 16 | $scope.now = new Date(); |
| 17 | 17 | ||
| 18 | $scope.botoneraPrincipal = focaParametrosService.getBotonesPrincipal; | 18 | $scope.botoneraPrincipal = focaParametrosService.getBotonesPrincipal; |
| 19 | 19 | ||
| 20 | $timeout(function() { | 20 | $timeout(function() { |
| 21 | focaBotoneraLateralService.showSalir(true); | 21 | focaBotoneraLateralService.showSalir(true); |
| 22 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 22 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
| 23 | }); | 23 | }); |
| 24 | 24 | ||
| 25 | focaParametrosService.getParametros().then(function(res) { | 25 | focaParametrosService.getParametros().then(function(res) { |
| 26 | 26 | ||
| 27 | $scope.$broadcast('cleanCabecera'); | 27 | $scope.$broadcast('cleanCabecera'); |
| 28 | res.data.forEach(function(entidad) { | 28 | res.data.forEach(function(entidad) { |
| 29 | 29 | ||
| 30 | setearEntidad(entidad); | 30 | setearEntidad(entidad); |
| 31 | }); | 31 | }); |
| 32 | }); | 32 | }); |
| 33 | 33 | ||
| 34 | $scope.guardar = function() { | 34 | $scope.guardar = function() { |
| 35 | 35 | ||
| 36 | focaParametrosService.saveParametros(getObjGuardar()).then(function() { | 36 | focaParametrosService.saveParametros(getObjGuardar()).then(function() { |
| 37 | focaModalService.alert('Parámetros guardados con éxito'); | 37 | focaModalService.alert('Parámetros guardados con éxito'); |
| 38 | $location.url('/'); | 38 | $location.url('/'); |
| 39 | }); | 39 | }); |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | $scope.seleccionarPuntosDeDescarga = function() { | 42 | $scope.seleccionarPuntosDeDescarga = function() { |
| 43 | if (!$scope[getModulo()].cliente.COD || !$scope[getModulo()].domicilio.id) { | 43 | if (!$scope[getModulo()].cliente.COD || !$scope[getModulo()].domicilio.id) { |
| 44 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 44 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 45 | return; | 45 | return; |
| 46 | } else { | 46 | } else { |
| 47 | var modalInstance = $uibModal.open( | 47 | var modalInstance = $uibModal.open( |
| 48 | { | 48 | { |
| 49 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 49 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 50 | templateUrl: 'modal-punto-descarga.html', | 50 | templateUrl: 'modal-punto-descarga.html', |
| 51 | controller: 'focaModalPuntoDescargaController', | 51 | controller: 'focaModalPuntoDescargaController', |
| 52 | size: 'lg', | 52 | size: 'lg', |
| 53 | resolve: { | 53 | resolve: { |
| 54 | filters: { | 54 | filters: { |
| 55 | idDomicilio: $scope[getModulo()].domicilio.id, | 55 | idDomicilio: $scope[getModulo()].domicilio.id, |
| 56 | idCliente: $scope[getModulo()].cliente.COD, | 56 | idCliente: $scope[getModulo()].cliente.COD, |
| 57 | articulos: $scope[getModulo()].articulosNotaPedido || [], | 57 | articulos: $scope[getModulo()].articulosNotaPedido || [], |
| 58 | puntoDescarga: $scope[getModulo()].notaPedidoPuntoDescarga, | 58 | puntoDescarga: $scope[getModulo()].notaPedidoPuntoDescarga, |
| 59 | domicilio: $scope[getModulo()].domicilio | 59 | domicilio: $scope[getModulo()].domicilio |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | ); | 63 | ); |
| 64 | modalInstance.result.then( | 64 | modalInstance.result.then( |
| 65 | function(puntoDescarga) { | 65 | function(puntoDescarga) { |
| 66 | $scope[getModulo()].notaPedidoPuntoDescarga = puntoDescarga; | 66 | $scope[getModulo()].notaPedidoPuntoDescarga = puntoDescarga; |
| 67 | 67 | ||
| 68 | $scope.$broadcast('addCabecera', { | 68 | $scope.$broadcast('addCabecera', { |
| 69 | label: 'Puntos de descarga:', | 69 | label: 'Puntos de descarga:', |
| 70 | seccion: getModulo('label'), | 70 | seccion: getModulo('label'), |
| 71 | valor: getCabeceraPuntoDescarga(puntoDescarga) | 71 | valor: getCabeceraPuntoDescarga(puntoDescarga) |
| 72 | }); | 72 | }); |
| 73 | }, function() { | 73 | }, function() { |
| 74 | $scope.abrirModalDomicilios($scope.cliente); | 74 | $scope.abrirModalDomicilios($scope.cliente); |
| 75 | } | 75 | } |
| 76 | ); | 76 | ); |
| 77 | } | 77 | } |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | $scope.seleccionarFlete = function() { | 80 | $scope.seleccionarFlete = function() { |
| 81 | 81 | ||
| 82 | if ($scope[getModulo()].flete === undefined) { | 82 | if ($scope[getModulo()].flete === undefined) { |
| 83 | $scope[getModulo()].fob = undefined; | 83 | $scope[getModulo()].fob = undefined; |
| 84 | $scope[getModulo()].bomba = undefined; | 84 | $scope[getModulo()].bomba = undefined; |
| 85 | $scope[getModulo()].kilometros = undefined; | 85 | $scope[getModulo()].kilometros = undefined; |
| 86 | 86 | ||
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | var modalInstance = $uibModal.open( | 89 | var modalInstance = $uibModal.open( |
| 90 | { | 90 | { |
| 91 | ariaLabelledBy: 'Busqueda de Flete', | 91 | ariaLabelledBy: 'Busqueda de Flete', |
| 92 | templateUrl: 'modal-flete.html', | 92 | templateUrl: 'modal-flete.html', |
| 93 | controller: 'focaModalFleteController', | 93 | controller: 'focaModalFleteController', |
| 94 | size: 'lg', | 94 | size: 'lg', |
| 95 | resolve: { | 95 | resolve: { |
| 96 | parametrosFlete: | 96 | parametrosFlete: |
| 97 | function() { | 97 | function() { |
| 98 | return { | 98 | return { |
| 99 | flete: $scope[getModulo()].fob ? 'FOB' : | 99 | flete: $scope[getModulo()].fob ? 'FOB' : |
| 100 | ( $scope[getModulo()].flete ? '1' : | 100 | ( $scope[getModulo()].flete ? '1' : |
| 101 | ($scope[getModulo()].flete === undefined ? | 101 | ($scope[getModulo()].flete === undefined ? |
| 102 | null : '0')), | 102 | null : '0')), |
| 103 | bomba: $scope[getModulo()].bomba ? '1' : | 103 | bomba: $scope[getModulo()].bomba ? '1' : |
| 104 | ($scope[getModulo()].bomba === undefined ? | 104 | ($scope[getModulo()].bomba === undefined ? |
| 105 | null : '0'), | 105 | null : '0'), |
| 106 | kilometros: $scope[getModulo()].kilometros | 106 | kilometros: $scope[getModulo()].kilometros |
| 107 | }; | 107 | }; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | } | 110 | } |
| 111 | ); | 111 | ); |
| 112 | modalInstance.result.then( | 112 | modalInstance.result.then( |
| 113 | function(datos) { | 113 | function(datos) { |
| 114 | $scope[getModulo()].flete = datos.flete; | 114 | $scope[getModulo()].flete = datos.flete; |
| 115 | $scope[getModulo()].fob = datos.FOB; | 115 | $scope[getModulo()].fob = datos.FOB; |
| 116 | $scope[getModulo()].bomba = datos.bomba; | 116 | $scope[getModulo()].bomba = datos.bomba; |
| 117 | $scope[getModulo()].kilometros = datos.kilometros; | 117 | $scope[getModulo()].kilometros = datos.kilometros; |
| 118 | $scope.$broadcast('addCabecera', { | 118 | $scope.$broadcast('addCabecera', { |
| 119 | label: 'Flete:', | 119 | label: 'Flete:', |
| 120 | seccion: getModulo('label'), | 120 | seccion: getModulo('label'), |
| 121 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 121 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
| 122 | }); | 122 | }); |
| 123 | if (datos.flete) { | 123 | if (datos.flete) { |
| 124 | $scope.$broadcast('addCabecera', { | 124 | $scope.$broadcast('addCabecera', { |
| 125 | label: 'Bomba:', | 125 | label: 'Bomba:', |
| 126 | seccion: getModulo('label'), | 126 | seccion: getModulo('label'), |
| 127 | valor: datos.bomba ? 'Si' : 'No' | 127 | valor: datos.bomba ? 'Si' : 'No' |
| 128 | }); | 128 | }); |
| 129 | $scope.$broadcast('addCabecera', { | 129 | $scope.$broadcast('addCabecera', { |
| 130 | label: 'Kilometros:', | 130 | label: 'Kilometros:', |
| 131 | seccion: getModulo('label'), | 131 | seccion: getModulo('label'), |
| 132 | valor: datos.kilometros | 132 | valor: datos.kilometros |
| 133 | }); | 133 | }); |
| 134 | } else { | 134 | } else { |
| 135 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 135 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 136 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 136 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 137 | $scope[getModulo()].bomba = false; | 137 | $scope[getModulo()].bomba = false; |
| 138 | $scope[getModulo()].kilometros = null; | 138 | $scope[getModulo()].kilometros = null; |
| 139 | } | 139 | } |
| 140 | }, function() { | 140 | }, function() { |
| 141 | } | 141 | } |
| 142 | ); | 142 | ); |
| 143 | }; | 143 | }; |
| 144 | 144 | ||
| 145 | $scope.seleccionarVendedor = function() { | 145 | $scope.seleccionarVendedor = function() { |
| 146 | 146 | ||
| 147 | var parametrosModal = { | 147 | var parametrosModal = { |
| 148 | titulo: 'Búsqueda vendedores', | 148 | titulo: 'Búsqueda vendedores', |
| 149 | query: '/vendedor', | 149 | query: '/vendedor', |
| 150 | columnas: [ | 150 | columnas: [ |
| 151 | { | 151 | { |
| 152 | propiedad: 'NUM', | 152 | propiedad: 'NUM', |
| 153 | nombre: 'Código', | 153 | nombre: 'Código', |
| 154 | filtro: { | 154 | filtro: { |
| 155 | nombre: 'rellenarDigitos', | 155 | nombre: 'rellenarDigitos', |
| 156 | parametro: 3 | 156 | parametro: 3 |
| 157 | } | 157 | } |
| 158 | }, | 158 | }, |
| 159 | { | 159 | { |
| 160 | propiedad: 'NOM', | 160 | propiedad: 'NOM', |
| 161 | nombre: 'Nombre' | 161 | nombre: 'Nombre' |
| 162 | } | 162 | } |
| 163 | ], | 163 | ], |
| 164 | size: 'md' | 164 | size: 'md' |
| 165 | }; | 165 | }; |
| 166 | focaModalService.modal(parametrosModal).then( | 166 | focaModalService.modal(parametrosModal).then( |
| 167 | function(vendedor) { | 167 | function(vendedor) { |
| 168 | $scope.$broadcast('addCabecera', { | 168 | $scope.$broadcast('addCabecera', { |
| 169 | label: 'Vendedor:', | 169 | label: 'Vendedor:', |
| 170 | seccion: getModulo('label'), | 170 | seccion: getModulo('label'), |
| 171 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 171 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 172 | vendedor.NOM | 172 | vendedor.NOM |
| 173 | }); | 173 | }); |
| 174 | $scope[getModulo()].vendedor = vendedor; | 174 | $scope[getModulo()].vendedor = vendedor; |
| 175 | }, function() {} | 175 | }, function() {} |
| 176 | ); | 176 | ); |
| 177 | }; | 177 | }; |
| 178 | 178 | ||
| 179 | $scope.seleccionarCliente = function() { | 179 | $scope.seleccionarCliente = function() { |
| 180 | 180 | ||
| 181 | if (!$scope[getModulo()].vendedor) { | ||
| 182 | focaModalService.alert('Seleccione Vendedor'); | ||
| 183 | return; | ||
| 184 | } | ||
| 185 | |||
| 186 | var modalInstance = $uibModal.open( | 181 | var modalInstance = $uibModal.open( |
| 187 | { | 182 | { |
| 188 | ariaLabelledBy: 'Busqueda de Cliente', | 183 | ariaLabelledBy: 'Busqueda de Cliente', |
| 189 | templateUrl: 'foca-busqueda-cliente-modal.html', | 184 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 190 | controller: 'focaBusquedaClienteModalController', | 185 | controller: 'focaBusquedaClienteModalController', |
| 191 | resolve: { | 186 | resolve: { |
| 192 | vendedor: function() { return $scope.notaPedido.vendedor; }, | 187 | vendedor: function() { return null; }, |
| 193 | cobrador: function() { return null; } | 188 | cobrador: function() { return null; } |
| 194 | }, | 189 | }, |
| 195 | size: 'lg' | 190 | size: 'lg' |
| 196 | } | 191 | } |
| 197 | ); | 192 | ); |
| 198 | modalInstance.result.then( | 193 | modalInstance.result.then( |
| 199 | function(cliente) { | 194 | function(cliente) { |
| 200 | $scope.abrirModalDomicilios(cliente); | 195 | $scope.abrirModalDomicilios(cliente); |
| 201 | }, function() { } | 196 | }, function() { } |
| 202 | ); | 197 | ); |
| 203 | }; | 198 | }; |
| 204 | 199 | ||
| 205 | $scope.seleccionarProveedor = function() { | 200 | $scope.seleccionarProveedor = function() { |
| 206 | 201 | ||
| 207 | var parametrosModal = { | 202 | var parametrosModal = { |
| 208 | titulo: 'Búsqueda de Proveedor', | 203 | titulo: 'Búsqueda de Proveedor', |
| 209 | query: '/proveedor', | 204 | query: '/proveedor', |
| 210 | columnas: [ | 205 | columnas: [ |
| 211 | { | 206 | { |
| 212 | nombre: 'Código', | 207 | nombre: 'Código', |
| 213 | propiedad: 'COD', | 208 | propiedad: 'COD', |
| 214 | filtro: { | 209 | filtro: { |
| 215 | nombre: 'rellenarDigitos', | 210 | nombre: 'rellenarDigitos', |
| 216 | parametro: 5 | 211 | parametro: 5 |
| 217 | } | 212 | } |
| 218 | }, | 213 | }, |
| 219 | { | 214 | { |
| 220 | nombre: 'Nombre', | 215 | nombre: 'Nombre', |
| 221 | propiedad: 'NOM' | 216 | propiedad: 'NOM' |
| 222 | }, | 217 | }, |
| 223 | { | 218 | { |
| 224 | nombre: 'CUIT', | 219 | nombre: 'CUIT', |
| 225 | propiedad: 'CUIT' | 220 | propiedad: 'CUIT' |
| 226 | } | 221 | } |
| 227 | ], | 222 | ], |
| 228 | tipo: 'POST', | 223 | tipo: 'POST', |
| 229 | json: {razonCuitCod: ''} | 224 | json: {razonCuitCod: ''} |
| 230 | }; | 225 | }; |
| 231 | focaModalService.modal(parametrosModal).then( | 226 | focaModalService.modal(parametrosModal).then( |
| 232 | function(proveedor) { | 227 | function(proveedor) { |
| 233 | $scope[getModulo()].proveedor = proveedor; | 228 | $scope[getModulo()].proveedor = proveedor; |
| 234 | $scope.$broadcast('addCabecera', { | 229 | $scope.$broadcast('addCabecera', { |
| 235 | label: 'Proveedor:', | 230 | label: 'Proveedor:', |
| 236 | seccion: getModulo('label'), | 231 | seccion: getModulo('label'), |
| 237 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 232 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 238 | proveedor.NOM | 233 | proveedor.NOM |
| 239 | }); | 234 | }); |
| 240 | }, function() { | 235 | }, function() { |
| 241 | } | 236 | } |
| 242 | ); | 237 | ); |
| 243 | 238 | ||
| 244 | }; | 239 | }; |
| 245 | 240 | ||
| 246 | $scope.abrirModalDomicilios = function(cliente) { | 241 | $scope.abrirModalDomicilios = function(cliente) { |
| 247 | var modalInstanceDomicilio = $uibModal.open( | 242 | var modalInstanceDomicilio = $uibModal.open( |
| 248 | { | 243 | { |
| 249 | ariaLabelledBy: 'Busqueda de Domicilios', | 244 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 250 | templateUrl: 'modal-domicilio.html', | 245 | templateUrl: 'modal-domicilio.html', |
| 251 | controller: 'focaModalDomicilioController', | 246 | controller: 'focaModalDomicilioController', |
| 252 | resolve: { | 247 | resolve: { |
| 253 | idCliente: function() { return cliente.cod; }, | 248 | idCliente: function() { return cliente.cod; }, |
| 254 | esNuevo: function() { return cliente.esNuevo; } | 249 | esNuevo: function() { return cliente.esNuevo; } |
| 255 | }, | 250 | }, |
| 256 | size: 'lg', | 251 | size: 'lg', |
| 257 | } | 252 | } |
| 258 | ); | 253 | ); |
| 259 | modalInstanceDomicilio.result.then( | 254 | modalInstanceDomicilio.result.then( |
| 260 | function(domicilio) { | 255 | function(domicilio) { |
| 261 | 256 | ||
| 262 | $scope[getModulo()].domicilio = domicilio; | 257 | $scope[getModulo()].domicilio = domicilio; |
| 263 | 258 | ||
| 264 | $scope[getModulo()].cliente = { | 259 | $scope[getModulo()].cliente = cliente; |
| 265 | COD: cliente.cod, | 260 | |
| 266 | CUIT: cliente.cuit, | 261 | $scope[getModulo()].cliente.COD = cliente.cod; |
| 267 | NOM: cliente.nom, | 262 | $scope[getModulo()].cliente.CUIT = cliente.cuit; |
| 268 | MOD: cliente.mod | 263 | $scope[getModulo()].cliente.NOM = cliente.nom; |
| 269 | }; | 264 | $scope[getModulo()].cliente.MOD = cliente.mod; |
| 270 | 265 | ||
| 271 | var domicilioStamp = | 266 | var domicilioStamp = |
| 272 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 267 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 273 | domicilio.Localidad + ', ' + domicilio.Provincia; | 268 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 274 | $scope[getModulo()].domicilioStamp = domicilioStamp; | 269 | $scope[getModulo()].domicilioStamp = domicilioStamp; |
| 275 | 270 | ||
| 276 | $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; | 271 | $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; |
| 277 | 272 | ||
| 278 | $scope.$broadcast('addCabecera', { | 273 | $scope.$broadcast('addCabecera', { |
| 279 | label: 'Cliente:', | 274 | label: 'Cliente:', |
| 280 | seccion: getModulo('label'), | 275 | seccion: getModulo('label'), |
| 281 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 276 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
| 282 | }); | 277 | }); |
| 283 | $scope.$broadcast('addCabecera', { | 278 | $scope.$broadcast('addCabecera', { |
| 284 | label: 'Domicilio:', | 279 | label: 'Domicilio:', |
| 285 | seccion: getModulo('label'), | 280 | seccion: getModulo('label'), |
| 286 | valor: domicilioStamp | 281 | valor: domicilioStamp |
| 287 | }); | 282 | }); |
| 288 | if (domicilio.verPuntos) { | 283 | if (domicilio.verPuntos) { |
| 289 | delete $scope[getModulo()].domicilio.verPuntos; | 284 | delete $scope[getModulo()].domicilio.verPuntos; |
| 290 | $scope.seleccionarPuntosDeDescarga(); | 285 | $scope.seleccionarPuntosDeDescarga(); |
| 291 | } else { | 286 | } else { |
| 292 | focaParametrosService | 287 | focaParametrosService |
| 293 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 288 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
| 294 | .then(function(res) { | 289 | .then(function(res) { |
| 295 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | 290 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
| 296 | }); | 291 | }); |
| 297 | } | 292 | } |
| 298 | }, function() { | 293 | }, function() { |
| 299 | $scope.seleccionarCliente(true); | 294 | $scope.seleccionarCliente(true); |
| 300 | return; | 295 | return; |
| 301 | } | 296 | } |
| 302 | ); | 297 | ); |
| 303 | }; | 298 | }; |
| 304 | 299 | ||
| 305 | $scope.seleccionarMoneda = function() { | 300 | $scope.seleccionarMoneda = function() { |
| 306 | 301 | ||
| 307 | var parametrosModal = { | 302 | var parametrosModal = { |
| 308 | titulo: 'Búsqueda de monedas', | 303 | titulo: 'Búsqueda de monedas', |
| 309 | query: '/moneda', | 304 | query: '/moneda', |
| 310 | columnas: [ | 305 | columnas: [ |
| 311 | { | 306 | { |
| 312 | propiedad: 'DETALLE', | 307 | propiedad: 'DETALLE', |
| 313 | nombre: 'Nombre' | 308 | nombre: 'Nombre' |
| 314 | }, | 309 | }, |
| 315 | { | 310 | { |
| 316 | propiedad: 'SIMBOLO', | 311 | propiedad: 'SIMBOLO', |
| 317 | nombre: 'Símbolo' | 312 | nombre: 'Símbolo' |
| 318 | } | 313 | } |
| 319 | ], | 314 | ], |
| 320 | size: 'md' | 315 | size: 'md' |
| 321 | }; | 316 | }; |
| 322 | focaModalService.modal(parametrosModal).then( | 317 | focaModalService.modal(parametrosModal).then( |
| 323 | function(moneda) { | 318 | function(moneda) { |
| 324 | $scope.abrirModalCotizacion(moneda); | 319 | $scope.abrirModalCotizacion(moneda); |
| 325 | }, function() { | 320 | }, function() { |
| 326 | } | 321 | } |
| 327 | ); | 322 | ); |
| 328 | 323 | ||
| 329 | }; | 324 | }; |
| 330 | 325 | ||
| 331 | $scope.abrirModalCotizacion = function(moneda) { | 326 | $scope.abrirModalCotizacion = function(moneda) { |
| 332 | var modalInstance = $uibModal.open( | 327 | var modalInstance = $uibModal.open( |
| 333 | { | 328 | { |
| 334 | ariaLabelledBy: 'Busqueda de Cotización', | 329 | ariaLabelledBy: 'Busqueda de Cotización', |
| 335 | templateUrl: 'modal-cotizacion.html', | 330 | templateUrl: 'modal-cotizacion.html', |
| 336 | controller: 'focaModalCotizacionController', | 331 | controller: 'focaModalCotizacionController', |
| 337 | size: 'lg', | 332 | size: 'lg', |
| 338 | resolve: { | 333 | resolve: { |
| 339 | idMoneda: function() { | 334 | idMoneda: function() { |
| 340 | return moneda.ID; | 335 | return moneda.ID; |
| 341 | } | 336 | } |
| 342 | } | 337 | } |
| 343 | } | 338 | } |
| 344 | ); | 339 | ); |
| 345 | modalInstance.result.then( | 340 | modalInstance.result.then( |
| 346 | function(cotizacion) { | 341 | function(cotizacion) { |
| 347 | $scope[getModulo()].cotizacion = cotizacion; | 342 | $scope[getModulo()].cotizacion = cotizacion; |
| 348 | $scope[getModulo()].cotizacion.moneda = moneda; | 343 | $scope[getModulo()].cotizacion.moneda = moneda; |
| 349 | 344 | ||
| 350 | $scope.$broadcast('addCabecera', { | 345 | $scope.$broadcast('addCabecera', { |
| 351 | label: 'Moneda:', | 346 | label: 'Moneda:', |
| 352 | seccion: getModulo('label'), | 347 | seccion: getModulo('label'), |
| 353 | valor: moneda.DETALLE | 348 | valor: moneda.DETALLE |
| 354 | }); | 349 | }); |
| 355 | $scope.$broadcast('addCabecera', { | 350 | $scope.$broadcast('addCabecera', { |
| 356 | label: 'Fecha cotizacion:', | 351 | label: 'Fecha cotizacion:', |
| 357 | seccion: getModulo('label'), | 352 | seccion: getModulo('label'), |
| 358 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 353 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 359 | }); | 354 | }); |
| 360 | $scope.$broadcast('addCabecera', { | 355 | $scope.$broadcast('addCabecera', { |
| 361 | label: 'Cotizacion:', | 356 | label: 'Cotizacion:', |
| 362 | seccion: getModulo('label'), | 357 | seccion: getModulo('label'), |
| 363 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 358 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 364 | }); | 359 | }); |
| 365 | 360 | ||
| 366 | }, function() { | 361 | }, function() { |
| 367 | 362 | ||
| 368 | } | 363 | } |
| 369 | ); | 364 | ); |
| 370 | }; | 365 | }; |
| 371 | 366 | ||
| 372 | $scope.seleccionarObservaciones = function() { | 367 | $scope.seleccionarObservaciones = function() { |
| 373 | var observacion = { | 368 | var observacion = { |
| 374 | titulo: 'Ingrese Observaciones', | 369 | titulo: 'Ingrese Observaciones', |
| 375 | value: $scope[getModulo()].observaciones, | 370 | value: $scope[getModulo()].observaciones, |
| 376 | maxlength: 155, | 371 | maxlength: 155, |
| 377 | textarea: true | 372 | textarea: true |
| 378 | }; | 373 | }; |
| 379 | 374 | ||
| 380 | focaModalService | 375 | focaModalService |
| 381 | .prompt(observacion) | 376 | .prompt(observacion) |
| 382 | .then(function(observaciones) { | 377 | .then(function(observaciones) { |
| 383 | $scope[getModulo()].observaciones = observaciones; | 378 | $scope[getModulo()].observaciones = observaciones; |
| 384 | $scope.$broadcast('addCabecera', { | 379 | $scope.$broadcast('addCabecera', { |
| 385 | label: 'Observaciones:', | 380 | label: 'Observaciones:', |
| 386 | valor: observaciones | 381 | valor: observaciones |
| 387 | }); | 382 | }); |
| 388 | }); | 383 | }); |
| 389 | }; | 384 | }; |
| 390 | 385 | ||
| 391 | $scope.seleccionarPreciosYCondiciones = function() { | 386 | $scope.seleccionarPreciosYCondiciones = function() { |
| 392 | if (!$scope[getModulo()].cliente || !$scope[getModulo()].cliente.COD) { | 387 | if (!$scope[getModulo()].cliente || !$scope[getModulo()].cliente.COD) { |
| 393 | focaModalService.alert('Primero seleccione un cliente'); | 388 | focaModalService.alert('Primero seleccione un cliente'); |
| 394 | return; | 389 | return; |
| 395 | } | 390 | } |
| 396 | 391 | ||
| 397 | var modalInstance = $uibModal.open( | 392 | var modalInstance = $uibModal.open( |
| 398 | { | 393 | { |
| 399 | ariaLabelledBy: 'Busqueda de Precio Condición', | 394 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 400 | templateUrl: 'modal-precio-condicion.html', | 395 | templateUrl: 'modal-precio-condicion.html', |
| 401 | controller: 'focaModalPrecioCondicionController', | 396 | controller: 'focaModalPrecioCondicionController', |
| 402 | size: 'lg', | 397 | size: 'lg', |
| 403 | resolve: { | 398 | resolve: { |
| 404 | idListaPrecio: function() { | 399 | idListaPrecio: function() { |
| 405 | return $scope[getModulo()].cliente.MOD || null; | 400 | return $scope[getModulo()].cliente.MOD || null; |
| 406 | } | 401 | } |
| 407 | } | 402 | } |
| 408 | } | 403 | } |
| 409 | ); | 404 | ); |
| 410 | 405 | ||
| 411 | modalInstance.result.then( | 406 | modalInstance.result.then( |
| 412 | function(precioCondicion) { | 407 | function(precioCondicion) { |
| 413 | var cabecera = ''; | 408 | var cabecera = ''; |
| 414 | var plazosConcat = ''; | 409 | var plazosConcat = ''; |
| 415 | if (!Array.isArray(precioCondicion)) { | 410 | if (!Array.isArray(precioCondicion)) { |
| 416 | $scope[getModulo()][getModulo() + 'Plazo' ]= precioCondicion.plazoPago; | 411 | $scope[getModulo()][getModulo() + 'Plazo' ]= precioCondicion.plazoPago; |
| 417 | $scope[getModulo()].precioCondicion = precioCondicion; | 412 | $scope[getModulo()].precioCondicion = precioCondicion; |
| 418 | $scope[getModulo()].idPrecioCondicion = precioCondicion.id; | 413 | $scope[getModulo()].idPrecioCondicion = precioCondicion.id; |
| 419 | $scope.idLista = precioCondicion.idListaPrecio; | 414 | $scope.idLista = precioCondicion.idListaPrecio; |
| 420 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 415 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 421 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 416 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 422 | } | 417 | } |
| 423 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 418 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
| 424 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 419 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 425 | } else { //Cuando se ingresan los plazos manualmente | 420 | } else { //Cuando se ingresan los plazos manualmente |
| 426 | $scope[getModulo()].idPrecioCondicion = 0; | 421 | $scope[getModulo()].idPrecioCondicion = 0; |
| 427 | //-1, el modal productos busca todos los productos | 422 | //-1, el modal productos busca todos los productos |
| 428 | $scope.idLista = -1; | 423 | $scope.idLista = -1; |
| 429 | $scope[getModulo()][ getModulo() + 'Plazo'] = precioCondicion; | 424 | $scope[getModulo()][ getModulo() + 'Plazo'] = precioCondicion; |
| 430 | for (var j = 0; j < precioCondicion.length; j++) { | 425 | for (var j = 0; j < precioCondicion.length; j++) { |
| 431 | plazosConcat += precioCondicion[j].dias + ' '; | 426 | plazosConcat += precioCondicion[j].dias + ' '; |
| 432 | } | 427 | } |
| 433 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 428 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 434 | } | 429 | } |
| 435 | $scope.$broadcast('addCabecera', { | 430 | $scope.$broadcast('addCabecera', { |
| 436 | label: 'Precios y condiciones:', | 431 | label: 'Precios y condiciones:', |
| 437 | seccion: getModulo('label'), | 432 | seccion: getModulo('label'), |
| 438 | valor: cabecera | 433 | valor: cabecera |
| 439 | }); | 434 | }); |
| 440 | }, function() { | 435 | }, function() { |
| 441 | 436 | ||
| 442 | } | 437 | } |
| 443 | ); | 438 | ); |
| 444 | 439 | ||
| 445 | }; | 440 | }; |
| 446 | 441 | ||
| 447 | $scope.seleccionarTarifario = function() { | 442 | $scope.seleccionarTarifario = function() { |
| 448 | 443 | ||
| 449 | focaModalService | 444 | focaModalService |
| 450 | .prompt({ | 445 | .prompt({ |
| 451 | titulo: 'Tarifa flete', | 446 | titulo: 'Tarifa flete', |
| 452 | value: $scope[getModulo()].tarifario | 447 | value: $scope[getModulo()].tarifario |
| 453 | }) | 448 | }) |
| 454 | .then(function(costo) { | 449 | .then(function(costo) { |
| 455 | if (isNaN(costo)) { | 450 | if (isNaN(costo)) { |
| 456 | focaModalService | 451 | focaModalService |
| 457 | .alert('Ingrese un valor válido') | 452 | .alert('Ingrese un valor válido') |
| 458 | .then(function() { | 453 | .then(function() { |
| 459 | $scope.seleccionarTarifario(); | 454 | $scope.seleccionarTarifario(); |
| 460 | }); | 455 | }); |
| 461 | 456 | ||
| 462 | return; | 457 | return; |
| 463 | } | 458 | } |
| 464 | 459 | ||
| 465 | $scope[getModulo()].tarifario = costo; | 460 | $scope[getModulo()].tarifario = costo; |
| 466 | 461 | ||
| 467 | $scope.$broadcast('addCabecera', { | 462 | $scope.$broadcast('addCabecera', { |
| 468 | label: 'Tarifario:', | 463 | label: 'Tarifario:', |
| 469 | valor: costo, | 464 | valor: costo, |
| 470 | seccion: getModulo('label') | 465 | seccion: getModulo('label') |
| 471 | }); | 466 | }); |
| 472 | }); | 467 | }); |
| 473 | }; | 468 | }; |
| 474 | 469 | ||
| 475 | $scope.seleccionarTransportista = function() { | 470 | $scope.seleccionarTransportista = function() { |
| 476 | 471 | ||
| 477 | var parametrosModal = { | 472 | var parametrosModal = { |
| 478 | titulo: 'Búsqueda de transportista', | 473 | titulo: 'Búsqueda de transportista', |
| 479 | query: '/transportista/no-relacion', | 474 | query: '/transportista/no-relacion', |
| 480 | columnas: [ | 475 | columnas: [ |
| 481 | { | 476 | { |
| 482 | nombre: 'Código', | 477 | nombre: 'Código', |
| 483 | propiedad: 'COD' | 478 | propiedad: 'COD' |
| 484 | }, | 479 | }, |
| 485 | { | 480 | { |
| 486 | nombre: 'Nombre', | 481 | nombre: 'Nombre', |
| 487 | propiedad: 'NOM' | 482 | propiedad: 'NOM' |
| 488 | }, | 483 | }, |
| 489 | { | 484 | { |
| 490 | nombre: 'CUIT', | 485 | nombre: 'CUIT', |
| 491 | propiedad: 'CUIT' | 486 | propiedad: 'CUIT' |
| 492 | } | 487 | } |
| 493 | ] | 488 | ] |
| 494 | }; | 489 | }; |
| 495 | focaModalService.modal(parametrosModal).then( | 490 | focaModalService.modal(parametrosModal).then( |
| 496 | function(proveedor) { | 491 | function(proveedor) { |
| 497 | $scope[getModulo()].transportista = proveedor; | 492 | $scope[getModulo()].transportista = proveedor; |
| 498 | $scope.$broadcast('addCabecera', { | 493 | $scope.$broadcast('addCabecera', { |
| 499 | label: 'Transportista:', | 494 | label: 'Transportista:', |
| 500 | seccion: getModulo('label'), | 495 | seccion: getModulo('label'), |
| 501 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 496 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 502 | proveedor.NOM | 497 | proveedor.NOM |
| 503 | }); | 498 | }); |
| 504 | }, function() { | 499 | }, function() { |
| 505 | } | 500 | } |
| 506 | ); | 501 | ); |
| 507 | }; | 502 | }; |
| 508 | 503 | ||
| 509 | $scope.$watch('botonera', function() { | 504 | $scope.$watch('botonera', function() { |
| 510 | 505 | ||
| 511 | // Creo el string en donde guardo el objeto parseado | 506 | // Creo el string en donde guardo el objeto parseado |
| 512 | $scope[getModulo()] = $scope[getModulo()] || {}; | 507 | $scope[getModulo()] = $scope[getModulo()] || {}; |
| 513 | 508 | ||
| 514 | getCheckeds(); | 509 | getCheckeds(); |
| 515 | }, true); | 510 | }, true); |
| 516 | 511 | ||
| 517 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { | 512 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { |
| 518 | 513 | ||
| 519 | // watch en objetos principales para ir guardando los valores | 514 | // watch en objetos principales para ir guardando los valores |
| 520 | $scope.$watch(botonPincipal.variable, function() { | 515 | $scope.$watch(botonPincipal.variable, function() { |
| 521 | 516 | ||
| 522 | $scope[botonPincipal.variable + 'String'] = { | 517 | $scope[botonPincipal.variable + 'String'] = { |
| 523 | jsonText: JSON.stringify($scope[botonPincipal.variable]), | 518 | jsonText: JSON.stringify($scope[botonPincipal.variable]), |
| 524 | modulo: botonPincipal.variable, | 519 | modulo: botonPincipal.variable, |
| 525 | id: $scope[botonPincipal.variable + 'String'] ? | 520 | id: $scope[botonPincipal.variable + 'String'] ? |
| 526 | $scope[botonPincipal.variable + 'String'].id : undefined | 521 | $scope[botonPincipal.variable + 'String'].id : undefined |
| 527 | }; | 522 | }; |
| 528 | 523 | ||
| 529 | getCheckeds(); | 524 | getCheckeds(); |
| 530 | }, true); | 525 | }, true); |
| 531 | 526 | ||
| 532 | // creo las funciones para seleccionar boton principal | 527 | // creo las funciones para seleccionar boton principal |
| 533 | $scope[nombreFuncion(botonPincipal.label)] = function() { | 528 | $scope[nombreFuncion(botonPincipal.label)] = function() { |
| 534 | 529 | ||
| 535 | $scope.botoneraPrincipal.filter(function(boton) { | 530 | $scope.botoneraPrincipal.filter(function(boton) { |
| 536 | boton.checked = false; | 531 | boton.checked = false; |
| 537 | }); | 532 | }); |
| 538 | 533 | ||
| 539 | botonPincipal.checked = true; | 534 | botonPincipal.checked = true; |
| 540 | $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); | 535 | $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); |
| 541 | }; | 536 | }; |
| 542 | 537 | ||
| 543 | }); | 538 | }); |
| 544 | 539 | ||
| 545 | function nombreFuncion(string) { | 540 | function nombreFuncion(string) { |
| 546 | 541 | ||
| 547 | if(!string) return; | 542 | if(!string) return; |
| 548 | 543 | ||
| 549 | var texto = 'seleccionar'; | 544 | var texto = 'seleccionar'; |
| 550 | var arr = string.split(' '); | 545 | var arr = string.split(' '); |
| 551 | arr.forEach(function(palabra) { | 546 | arr.forEach(function(palabra) { |
| 552 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 547 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
| 553 | texto += palabra; | 548 | texto += palabra; |
| 554 | }); | 549 | }); |
| 555 | return texto; | 550 | return texto; |
| 556 | } | 551 | } |
| 557 | 552 | ||
| 558 | function getModulo(propiedad) { | 553 | function getModulo(propiedad) { |
| 559 | var nombre = ''; | 554 | var nombre = ''; |
| 560 | 555 | ||
| 561 | $scope.botoneraPrincipal.filter(function(boton) { | 556 | $scope.botoneraPrincipal.filter(function(boton) { |
| 562 | if (boton.checked) { | 557 | if (boton.checked) { |
| 563 | if(!propiedad) { | 558 | if(!propiedad) { |
| 564 | nombre = boton.variable; | 559 | nombre = boton.variable; |
| 565 | } else { | 560 | } else { |
| 566 | nombre = boton[propiedad]; | 561 | nombre = boton[propiedad]; |
| 567 | } | 562 | } |
| 568 | } | 563 | } |
| 569 | }); | 564 | }); |
| 570 | return nombre; | 565 | return nombre; |
| 571 | } | 566 | } |
| 572 | 567 | ||
| 573 | function getCheckeds() { | 568 | function getCheckeds() { |
| 574 | 569 | ||
| 575 | $scope.botonera.forEach(function(boton) { | 570 | $scope.botonera.forEach(function(boton) { |
| 576 | 571 | ||
| 577 | if ($scope[getModulo()][boton.variable] !== undefined) { | 572 | if ($scope[getModulo()][boton.variable] !== undefined) { |
| 578 | 573 | ||
| 579 | boton.checked = true; | 574 | boton.checked = true; |
| 580 | 575 | ||
| 581 | //Creo la función para limpiar obj | 576 | //Creo la función para limpiar obj |
| 582 | $scope['clean' + boton.variable] = function() { | 577 | $scope['clean' + boton.variable] = function() { |
| 583 | 578 | ||
| 584 | focaModalService.alert('Esta seguro que desea eliminar el parámetro?') | 579 | focaModalService.alert('Esta seguro que desea eliminar el parámetro?') |
| 585 | .then(function() { | 580 | .then(function() { |
| 586 | delete $scope[getModulo()][boton.variable]; | 581 | delete $scope[getModulo()][boton.variable]; |
| 587 | $scope.$broadcast('cleanCabecera', { | 582 | $scope.$broadcast('cleanCabecera', { |
| 588 | seccion: getModulo('label') | 583 | seccion: getModulo('label') |
| 589 | }); | 584 | }); |
| 590 | setearEntidad({ | 585 | setearEntidad({ |
| 591 | jsonText: JSON.stringify($scope[getModulo()]), | 586 | jsonText: JSON.stringify($scope[getModulo()]), |
| 592 | modulo: getModulo(), | 587 | modulo: getModulo(), |
| 593 | id: $scope[getModulo() + 'String'].id | 588 | id: $scope[getModulo() + 'String'].id |
| 594 | }); | 589 | }); |
| 595 | }); | 590 | }); |
| 596 | }; | 591 | }; |
| 597 | 592 | ||
| 598 | } else { | 593 | } else { |
| 599 | boton.checked = false; | 594 | boton.checked = false; |
| 600 | } | 595 | } |
| 601 | }); | 596 | }); |
| 602 | } | 597 | } |
| 603 | 598 | ||
| 604 | function getCabeceraPuntoDescarga(puntoDescarga) { | 599 | function getCabeceraPuntoDescarga(puntoDescarga) { |
| 605 | var puntosStamp = ''; | 600 | var puntosStamp = ''; |
| 606 | puntoDescarga.forEach(function(punto, idx, arr) { | 601 | puntoDescarga.forEach(function(punto, idx, arr) { |
| 607 | puntosStamp += punto.descripcion; | 602 | puntosStamp += punto.descripcion; |
| 608 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 603 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 609 | }); | 604 | }); |
| 610 | return puntosStamp; | 605 | return puntosStamp; |
| 611 | } | 606 | } |
| 612 | 607 | ||
| 613 | function setearEntidad(entidad) { | 608 | function setearEntidad(entidad) { |
| 614 | 609 | ||
| 615 | $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; | 610 | $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; |
| 616 | $scope[entidad.modulo + 'String'].id = entidad.id; | 611 | $scope[entidad.modulo + 'String'].id = entidad.id; |
| 617 | 612 | ||
| 618 | if (!$scope[entidad.modulo].domicilio) { | 613 | if (!$scope[entidad.modulo].domicilio) { |
| 619 | $scope[entidad.modulo].domicilio = { | 614 | $scope[entidad.modulo].domicilio = { |
| 620 | id: $scope[entidad.modulo].idDomicilio | 615 | id: $scope[entidad.modulo].idDomicilio |
| 621 | }; | 616 | }; |
| 622 | } | 617 | } |
| 623 | 618 | ||
| 624 | var cabeceras = []; | 619 | var cabeceras = []; |
| 625 | 620 | ||
| 626 | if ($scope[entidad.modulo].cotizacion) { | 621 | if ($scope[entidad.modulo].cotizacion) { |
| 627 | cabeceras.push({ | 622 | cabeceras.push({ |
| 628 | label: 'Moneda:', | 623 | label: 'Moneda:', |
| 629 | valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE | 624 | valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE |
| 630 | }); | 625 | }); |
| 631 | cabeceras.push({ | 626 | cabeceras.push({ |
| 632 | label: 'Fecha cotizacion:', | 627 | label: 'Fecha cotizacion:', |
| 633 | valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, | 628 | valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, |
| 634 | 'dd/MM/yyyy') | 629 | 'dd/MM/yyyy') |
| 635 | }); | 630 | }); |
| 636 | cabeceras.push({ | 631 | cabeceras.push({ |
| 637 | label: 'Cotizacion:', | 632 | label: 'Cotizacion:', |
| 638 | valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, | 633 | valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, |
| 639 | '2') | 634 | '2') |
| 640 | }); | 635 | }); |
| 641 | } | 636 | } |
| 642 | 637 | ||
| 643 | if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { | 638 | if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { |
| 644 | cabeceras.push({ | 639 | cabeceras.push({ |
| 645 | label: 'Vendedor:', | 640 | label: 'Vendedor:', |
| 646 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + | 641 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + |
| 647 | ' - ' + $scope[entidad.modulo].vendedor.NOM | 642 | ' - ' + $scope[entidad.modulo].vendedor.NOM |
| 648 | }); | 643 | }); |
| 649 | } | 644 | } |
| 650 | 645 | ||
| 651 | if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { | 646 | if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { |
| 652 | cabeceras.push({ | 647 | cabeceras.push({ |
| 653 | label: 'Cliente:', | 648 | label: 'Cliente:', |
| 654 | valor: $scope[entidad.modulo].cliente.NOM | 649 | valor: $scope[entidad.modulo].cliente.NOM |
| 655 | }); | 650 | }); |
| 656 | cabeceras.push({ | 651 | cabeceras.push({ |
| 657 | label: 'Domicilio:', | 652 | label: 'Domicilio:', |
| 658 | valor: $scope[entidad.modulo].domicilioStamp | 653 | valor: $scope[entidad.modulo].domicilioStamp |
| 659 | }); | 654 | }); |
| 660 | } | 655 | } |
| 661 | 656 | ||
| 662 | if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { | 657 | if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { |
| 663 | cabeceras.push({ | 658 | cabeceras.push({ |
| 664 | label: 'Proveedor:', | 659 | label: 'Proveedor:', |
| 665 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + | 660 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + |
| 666 | ' - ' + $scope[entidad.modulo].proveedor.NOM | 661 | ' - ' + $scope[entidad.modulo].proveedor.NOM |
| 667 | }); | 662 | }); |
| 668 | } | 663 | } |
| 669 | 664 | ||
| 670 | if ($scope[entidad.modulo][entidad + 'Plazo'] && | 665 | if ($scope[entidad.modulo][entidad + 'Plazo'] && |
| 671 | $scope[entidad.modulo][entidad + 'Plazo'].length) | 666 | $scope[entidad.modulo][entidad + 'Plazo'].length) |
| 672 | { | 667 | { |
| 673 | cabeceras.push({ | 668 | cabeceras.push({ |
| 674 | label: 'Precios y condiciones:', | 669 | label: 'Precios y condiciones:', |
| 675 | valor: valorPrecioCondicion() + ' ' + | 670 | valor: valorPrecioCondicion() + ' ' + |
| 676 | focaParametrosService.plazoToString( | 671 | focaParametrosService.plazoToString( |
| 677 | $scope[entidad.modulo][entidad.modulo + 'Plazo']) | 672 | $scope[entidad.modulo][entidad.modulo + 'Plazo']) |
| 678 | }); | 673 | }); |
| 679 | } | 674 | } |
| 680 | 675 | ||
| 681 | if ($scope[entidad.modulo].flete !== undefined) { | 676 | if ($scope[entidad.modulo].flete !== undefined) { |
| 682 | cabeceras.push({ | 677 | cabeceras.push({ |
| 683 | label: 'Flete:', | 678 | label: 'Flete:', |
| 684 | valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( | 679 | valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( |
| 685 | $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') | 680 | $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') |
| 686 | }); | 681 | }); |
| 687 | } | 682 | } |
| 688 | 683 | ||
| 689 | function valorPrecioCondicion() { | 684 | function valorPrecioCondicion() { |
| 690 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { | 685 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { |
| 691 | return $scope[entidad.modulo].precioCondicion.nombre; | 686 | return $scope[entidad.modulo].precioCondicion.nombre; |
| 692 | } else { | 687 | } else { |
| 693 | return 'Ingreso Manual'; | 688 | return 'Ingreso Manual'; |
| 694 | } | 689 | } |
| 695 | } | 690 | } |
| 696 | 691 | ||
| 697 | if ($scope[entidad.modulo].flete === 1) { | 692 | if ($scope[entidad.modulo].flete === 1) { |
| 698 | var cabeceraBomba = { | 693 | var cabeceraBomba = { |
| 699 | label: 'Bomba:', | 694 | label: 'Bomba:', |
| 700 | valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' | 695 | valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' |
| 701 | }; | 696 | }; |
| 702 | if ($scope[entidad.modulo].kilometros) { | 697 | if ($scope[entidad.modulo].kilometros) { |
| 703 | var cabeceraKilometros = { | 698 | var cabeceraKilometros = { |
| 704 | label: 'Kilometros:', | 699 | label: 'Kilometros:', |
| 705 | valor: $scope[entidad.modulo].kilometros | 700 | valor: $scope[entidad.modulo].kilometros |
| 706 | }; | 701 | }; |
| 707 | cabeceras.push(cabeceraKilometros); | 702 | cabeceras.push(cabeceraKilometros); |
| 708 | } | 703 | } |
| 709 | cabeceras.push(cabeceraBomba); | 704 | cabeceras.push(cabeceraBomba); |
| 710 | } | 705 | } |
| 711 | 706 | ||
| 712 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { | 707 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { |
| 713 | $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; | 708 | $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; |
| 714 | } else { | 709 | } else { |
| 715 | $scope.idLista = -1; | 710 | $scope.idLista = -1; |
| 716 | } | 711 | } |
| 717 | 712 | ||
| 718 | if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { | 713 | if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { |
| 719 | var puntos = []; | 714 | var puntos = []; |
| 720 | $scope[entidad.modulo][entidad.modulo + 'PuntoDescarga'] | 715 | $scope[entidad.modulo][entidad.modulo + 'PuntoDescarga'] |
| 721 | .forEach(function(entidadPuntoDescarga) { | 716 | .forEach(function(entidadPuntoDescarga) { |
| 722 | puntos.push(entidadPuntoDescarga); | 717 | puntos.push(entidadPuntoDescarga); |
| 723 | }); | 718 | }); |
| 724 | cabeceras.push({ | 719 | cabeceras.push({ |
| 725 | label: 'Puntos de descarga: ', | 720 | label: 'Puntos de descarga: ', |
| 726 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | 721 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) |
| 727 | }); | 722 | }); |
| 728 | } | 723 | } |
| 729 | 724 | ||
| 730 | if ($scope[entidad.modulo].tarifario) { | 725 | if ($scope[entidad.modulo].tarifario) { |
| 731 | cabeceras.push({ | 726 | cabeceras.push({ |
| 732 | label: 'Tarifario', | 727 | label: 'Tarifario', |
| 733 | valor: $scope[entidad.modulo].tarifario | 728 | valor: $scope[entidad.modulo].tarifario |
| 734 | }); | 729 | }); |
| 735 | } | 730 | } |
| 736 | 731 | ||
| 737 | if ($scope[entidad.modulo].transportista) { | 732 | if ($scope[entidad.modulo].transportista) { |
| 738 | cabeceras.push({ | 733 | cabeceras.push({ |
| 739 | label: 'Transportista', | 734 | label: 'Transportista', |
| 740 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].transportista.COD, | 735 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].transportista.COD, |
| 741 | 5) + ' - ' + $scope[entidad.modulo].transportista.NOM | 736 | 5) + ' - ' + $scope[entidad.modulo].transportista.NOM |
| 742 | }); | 737 | }); |
| 743 | } | 738 | } |
| 744 | 739 | ||
| 745 | addArrayCabecera(cabeceras, entidad.modulo); | 740 | addArrayCabecera(cabeceras, entidad.modulo); |
| 746 | 741 | ||
| 747 | } | 742 | } |
| 748 | 743 | ||
| 749 | function addArrayCabecera(array, entidad) { | 744 | function addArrayCabecera(array, entidad) { |
| 750 | for (var i = 0; i < array.length; i++) { | 745 | for (var i = 0; i < array.length; i++) { |
| 751 | $scope.$broadcast('addCabecera', { | 746 | $scope.$broadcast('addCabecera', { |
| 752 | label: array[i].label, | 747 | label: array[i].label, |
| 753 | valor: array[i].valor, | 748 | valor: array[i].valor, |
| 754 | seccion: $filter('filter') | 749 | seccion: $filter('filter') |
| 755 | ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label | 750 | ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label |
| 756 | }); | 751 | }); |
| 757 | } | 752 | } |
| 758 | } | 753 | } |
| 759 | 754 | ||
| 760 | function getObjGuardar() { | 755 | function getObjGuardar() { |
| 761 | var guardar = []; | 756 | var guardar = []; |
| 762 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { | 757 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { |
| 763 | if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; | 758 | if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; |
| 764 | guardar.push($scope[botonPincipal.variable + 'String']); | 759 | guardar.push($scope[botonPincipal.variable + 'String']); |
| 765 | }); | 760 | }); |
| 766 | 761 | ||
| 767 | return guardar; | 762 | return guardar; |
| 768 | } | 763 | } |
| 769 | 764 | ||
| 770 | }]); | 765 | }]); |
| 771 | 766 |
src/js/service.js
| 1 | angular.module('focaParametros') | 1 | angular.module('focaParametros') |
| 2 | .factory('focaParametrosService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { | 2 | .factory('focaParametrosService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { |
| 3 | return { | 3 | return { |
| 4 | getNotasPedido: function (fechaDesde, fechaHasta) { | 4 | getNotasPedido: function (fechaDesde, fechaHasta) { |
| 5 | return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar/' + fechaDesde + '/' + | 5 | return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar/' + fechaDesde + '/' + |
| 6 | fechaHasta + '/sin-remito'); | 6 | fechaHasta + '/sin-remito'); |
| 7 | }, | 7 | }, |
| 8 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 8 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
| 9 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 9 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
| 10 | idDomicilio + '/' + idCliente); | 10 | idDomicilio + '/' + idCliente); |
| 11 | }, | 11 | }, |
| 12 | saveParametros: function(parametros) { | 12 | saveParametros: function(parametros) { |
| 13 | return $http.post(API_ENDPOINT.URL + '/parametros', parametros); | 13 | return $http.post(API_ENDPOINT.URL + '/parametros', parametros); |
| 14 | }, | 14 | }, |
| 15 | getParametros: function() { | 15 | getParametros: function() { |
| 16 | return $http.get(API_ENDPOINT.URL + '/parametros'); | 16 | return $http.get(API_ENDPOINT.URL + '/parametros'); |
| 17 | }, | 17 | }, |
| 18 | plazoToString: function(plazos) { | 18 | plazoToString: function(plazos) { |
| 19 | 19 | ||
| 20 | var result = ''; | 20 | var result = ''; |
| 21 | 21 | ||
| 22 | for(var i = 0; i < plazos.length; i++) { | 22 | for(var i = 0; i < plazos.length; i++) { |
| 23 | result += plazos[i].dias + ' '; | 23 | result += plazos[i].dias + ' '; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | return result.trim(); | 26 | return result.trim(); |
| 27 | }, | 27 | }, |
| 28 | getBotones: function (modulo) { | 28 | getBotones: function (modulo) { |
| 29 | var botones = [ | 29 | var botones = [ |
| 30 | { | 30 | { |
| 31 | label: 'Vendedor', | 31 | label: 'Vendedor', |
| 32 | variable: 'vendedor', | 32 | variable: 'vendedor', |
| 33 | image: 'vendedor.png', | 33 | image: 'vendedor.png', |
| 34 | modulo: [1, 2] | 34 | modulo: [1, 2] |
| 35 | }, | 35 | }, |
| 36 | { | 36 | { |
| 37 | label: 'Cliente', | 37 | label: 'Cliente', |
| 38 | image: 'cliente.png', | 38 | image: 'cliente.png', |
| 39 | variable: 'cliente', | 39 | variable: 'cliente', |
| 40 | modulo: [1, 2] | 40 | modulo: [1, 2, 4] |
| 41 | }, | 41 | }, |
| 42 | { | 42 | { |
| 43 | label: 'Proveedor', | 43 | label: 'Proveedor', |
| 44 | image: 'proveedor.png', | 44 | image: 'proveedor.png', |
| 45 | variable: 'proveedor', | 45 | variable: 'proveedor', |
| 46 | modulo: [1, 2] | 46 | modulo: [1, 2] |
| 47 | }, | 47 | }, |
| 48 | { | 48 | { |
| 49 | label: 'Flete', | 49 | label: 'Flete', |
| 50 | image: 'flete.png', | 50 | image: 'flete.png', |
| 51 | variable: 'flete', | 51 | variable: 'flete', |
| 52 | modulo: [1, 2] | 52 | modulo: [1, 2] |
| 53 | }, | 53 | }, |
| 54 | { | 54 | { |
| 55 | label: 'Moneda', | 55 | label: 'Moneda', |
| 56 | image: 'moneda.png', | 56 | image: 'moneda.png', |
| 57 | variable: 'cotizacion', | 57 | variable: 'cotizacion', |
| 58 | modulo: [1, 2, 3] | 58 | modulo: [1, 2, 3, 4] |
| 59 | }, | 59 | }, |
| 60 | { | 60 | { |
| 61 | label: 'Precios y condiciones', | 61 | label: 'Precios y condiciones', |
| 62 | image: 'precios-condiciones.png', | 62 | image: 'precios-condiciones.png', |
| 63 | variable: 'precioCondicion', | 63 | variable: 'precioCondicion', |
| 64 | modulo: [1, 2] | 64 | modulo: [1, 2] |
| 65 | }, | 65 | }, |
| 66 | { | 66 | { |
| 67 | label: 'Observaciones', | 67 | label: 'Observaciones', |
| 68 | image: 'botonObservaciones.png', | 68 | image: 'botonObservaciones.png', |
| 69 | variable: 'observaciones', | 69 | variable: 'observaciones', |
| 70 | modulo: [1] | 70 | modulo: [1] |
| 71 | }, | 71 | }, |
| 72 | { | 72 | { |
| 73 | label: 'Transportista', | 73 | label: 'Transportista', |
| 74 | image: 'proveedor.png', | 74 | image: 'proveedor.png', |
| 75 | variable: 'transportista', | 75 | variable: 'transportista', |
| 76 | modulo: [3] | 76 | modulo: [3] |
| 77 | }, | 77 | }, |
| 78 | { | 78 | { |
| 79 | label: 'Tarifario', | 79 | label: 'Tarifario', |
| 80 | image: 'tarifario.png', | 80 | image: 'tarifario.png', |
| 81 | variable: 'tarifario', | 81 | variable: 'tarifario', |
| 82 | modulo: [3] | 82 | modulo: [3] |
| 83 | } | 83 | } |
| 84 | ]; | 84 | ]; |
| 85 | 85 | ||
| 86 | // Devuelvo solo los botones correspondietes | 86 | // Devuelvo solo los botones correspondietes |
| 87 | // Modulo 1 = nota de pedido, 2 remito, 3 ambos | 87 | // Modulo 1 = nota de pedido, 2 remito, 3 ambos |
| 88 | return botones.filter(function (p) { | 88 | return botones.filter(function (p) { |
| 89 | return p.modulo.includes(modulo); | 89 | return p.modulo.includes(modulo); |
| 90 | }); | 90 | }); |
| 91 | }, | 91 | }, |
| 92 | getBotonesPrincipal: [ | 92 | getBotonesPrincipal: [ |
| 93 | { | 93 | { |
| 94 | label: 'Nota de Pedido', | 94 | label: 'Nota de Pedido', |
| 95 | image: 'notaPedido.png', | 95 | image: 'notaPedido.png', |
| 96 | modulo: 1, | 96 | modulo: 1, |
| 97 | variable: 'notaPedido' | 97 | variable: 'notaPedido' |
| 98 | }, | 98 | }, |
| 99 | { | 99 | { |
| 100 | label: 'Remito', | 100 | label: 'Remito', |
| 101 | image: 'remito.png', | 101 | image: 'remito.png', |
| 102 | modulo: 2, | 102 | modulo: 2, |
| 103 | variable: 'remito' | 103 | variable: 'remito' |
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | label: 'Factura', | ||
| 107 | image: 'factura.png', | ||
| 108 | modulo: 4, | ||
| 109 | variable: 'factura' | ||
| 110 | }, | ||
| 111 | { | ||
| 106 | label: 'Hoja ruta', | 112 | label: 'Hoja ruta', |
| 107 | image: 'hoja-ruta.png', | 113 | image: 'hoja-ruta.png', |
| 108 | modulo: 3, | 114 | modulo: 3, |
| 109 | variable: 'hojaRuta' | 115 | variable: 'hojaRuta' |
| 110 | } | 116 | } |
| 111 | ] | 117 | ] |
| 112 | }; | 118 | }; |
| 113 | }]); | 119 | }]); |
| 114 | 120 |