Commit 0b523797232b6a0739108a4c6fe2a77fda1ad799
Exists in
master
Merge branch 'master' into 'develop'
Master See merge request !51
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -28,6 +28,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
28 | 28 | $scope.datepickerAbierto = false; |
29 | 29 | $scope.show = false; |
30 | 30 | $scope.cargando = true; |
31 | + $scope.botonera = crearNotaPedidoService.getBotonera(); | |
31 | 32 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
32 | 33 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
33 | 34 | $scope.dateOptions = { |
... | ... | @@ -46,9 +47,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
46 | 47 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR |
47 | 48 | if (APP === 'distribuidor') { |
48 | 49 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
49 | - $scope.botonera = crearNotaPedidoService.getBotonera($scope.idVendedor); | |
50 | - } else { | |
51 | - $scope.botonera = crearNotaPedidoService.getBotonera(); | |
52 | 50 | } |
53 | 51 | |
54 | 52 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
... | ... | @@ -125,10 +123,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
125 | 123 | }, true); |
126 | 124 | |
127 | 125 | $scope.crearNotaPedido = function() { |
128 | - if (!$scope.notaPedido.vendedor.id) { | |
129 | - focaModalService.alert('Ingrese Vendedor'); | |
130 | - return; | |
131 | - } else if (!$scope.notaPedido.cliente.COD) { | |
126 | + if (!$scope.notaPedido.cliente.COD) { | |
132 | 127 | focaModalService.alert('Ingrese Cliente'); |
133 | 128 | return; |
134 | 129 | } else if (!$scope.notaPedido.proveedor.COD) { |
... | ... | @@ -346,7 +341,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
346 | 341 | } |
347 | 342 | }; |
348 | 343 | |
349 | - $scope.seleccionarVendedor = function() { | |
344 | + $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | |
345 | + if(APP === 'distribuidor' || ocultarVendedor) { | |
346 | + callback(); | |
347 | + return; | |
348 | + } | |
349 | + | |
350 | 350 | if(validarNotaRemitada()) { |
351 | 351 | var parametrosModal = { |
352 | 352 | titulo: 'Búsqueda vendedores', |
... | ... | @@ -375,13 +375,43 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
375 | 375 | vendedor.NOM |
376 | 376 | }); |
377 | 377 | $scope.notaPedido.vendedor = vendedor; |
378 | - }, function() { | |
379 | - | |
380 | - } | |
378 | + deleteCliente(); | |
379 | + callback(); | |
380 | + }, function() {} | |
381 | 381 | ); |
382 | 382 | } |
383 | 383 | }; |
384 | 384 | |
385 | + $scope.seleccionarCliente = function(ocultarVendedor) { | |
386 | + $scope.seleccionarVendedor(function() { | |
387 | + if (!$scope.notaPedido.vendedor.NUM) { | |
388 | + focaModalService.alert('Primero seleccione un vendedor'); | |
389 | + return; | |
390 | + } | |
391 | + if (validarNotaRemitada()) { | |
392 | + var modalInstance = $uibModal.open( | |
393 | + { | |
394 | + ariaLabelledBy: 'Busqueda de Cliente', | |
395 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
396 | + controller: 'focaBusquedaClienteModalController', | |
397 | + resolve: { | |
398 | + vendedor: function() { return $scope.notaPedido.vendedor; } | |
399 | + }, | |
400 | + size: 'lg' | |
401 | + } | |
402 | + ); | |
403 | + modalInstance.result.then( | |
404 | + function(cliente) { | |
405 | + $scope.abrirModalDomicilios(cliente); | |
406 | + $scope.cliente = cliente; | |
407 | + }, function() { | |
408 | + if (APP !== 'distribuidor') $scope.seleccionarCliente(); | |
409 | + } | |
410 | + ); | |
411 | + } | |
412 | + }, ocultarVendedor); | |
413 | + }; | |
414 | + | |
385 | 415 | $scope.seleccionarProveedor = function() { |
386 | 416 | if(validarNotaRemitada()) { |
387 | 417 | var parametrosModal = { |
... | ... | @@ -423,32 +453,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
423 | 453 | } |
424 | 454 | }; |
425 | 455 | |
426 | - $scope.seleccionarCliente = function() { | |
427 | - if(!$scope.notaPedido.vendedor.NUM) { | |
428 | - focaModalService.alert('Primero seleccione un vendedor'); | |
429 | - return; | |
430 | - } | |
431 | - if(validarNotaRemitada()) { | |
432 | - var modalInstance = $uibModal.open( | |
433 | - { | |
434 | - ariaLabelledBy: 'Busqueda de Cliente', | |
435 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
436 | - controller: 'focaBusquedaClienteModalController', | |
437 | - resolve: { | |
438 | - vendedor: function() { return $scope.notaPedido.vendedor; } | |
439 | - }, | |
440 | - size: 'lg' | |
441 | - } | |
442 | - ); | |
443 | - modalInstance.result.then( | |
444 | - function(cliente) { | |
445 | - $scope.abrirModalDomicilios(cliente); | |
446 | - $scope.cliente = cliente; | |
447 | - }, function() {} | |
448 | - ); | |
449 | - } | |
450 | - }; | |
451 | - | |
452 | 456 | $scope.abrirModalDomicilios = function(cliente) { |
453 | 457 | var modalInstanceDomicilio = $uibModal.open( |
454 | 458 | { |
... | ... | @@ -464,6 +468,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
464 | 468 | ); |
465 | 469 | modalInstanceDomicilio.result.then( |
466 | 470 | function(domicilio) { |
471 | + | |
467 | 472 | $scope.notaPedido.domicilio = domicilio; |
468 | 473 | $scope.notaPedido.cliente = { |
469 | 474 | COD: cliente.cod, |
... | ... | @@ -485,10 +490,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
485 | 490 | label: 'Domicilio:', |
486 | 491 | valor: domicilioStamp |
487 | 492 | }); |
488 | - if(domicilio.verPuntos) { | |
493 | + if (domicilio.verPuntos) { | |
489 | 494 | delete $scope.notaPedido.domicilio.verPuntos; |
490 | 495 | $scope.seleccionarPuntosDeDescarga(); |
491 | - }else { | |
496 | + } else { | |
492 | 497 | crearNotaPedidoService |
493 | 498 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
494 | 499 | .then(function(res) { |
... | ... | @@ -496,7 +501,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
496 | 501 | }); |
497 | 502 | } |
498 | 503 | }, function() { |
499 | - $scope.seleccionarCliente(); | |
504 | + $scope.seleccionarCliente(true); | |
500 | 505 | return; |
501 | 506 | } |
502 | 507 | ); |
... | ... | @@ -970,5 +975,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
970 | 975 | delete $localStorage.notaPedido; |
971 | 976 | } |
972 | 977 | } |
978 | + | |
979 | + function deleteCliente() { | |
980 | + delete $scope.notaPedido.domicilioStamp; | |
981 | + delete $scope.notaPedido.notaPedidoPuntoDescarga; | |
982 | + $scope.notaPedido.domicilio = {dom: ''}; | |
983 | + $scope.notaPedido.cliente = {}; | |
984 | + $scope.$broadcast('removeCabecera', 'Cliente:'); | |
985 | + $scope.$broadcast('removeCabecera', 'Domicilio:'); | |
986 | + $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); | |
987 | + } | |
973 | 988 | } |
974 | 989 | ]); |
src/js/service.js
... | ... | @@ -55,7 +55,7 @@ angular.module('focaCrearNotaPedido') |
55 | 55 | getNumeroNotaPedido: function() { |
56 | 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); |
57 | 57 | }, |
58 | - getBotonera: function(vendedor) { | |
58 | + getBotonera: function() { | |
59 | 59 | var result = [ |
60 | 60 | { |
61 | 61 | label: 'Cliente', |
... | ... | @@ -86,16 +86,6 @@ angular.module('focaCrearNotaPedido') |
86 | 86 | image: 'productos.png' |
87 | 87 | } |
88 | 88 | ]; |
89 | - | |
90 | - if(!vendedor) { | |
91 | - var botonVendedor = { | |
92 | - label: 'Vendedor', | |
93 | - image: 'vendedor.png' | |
94 | - }; | |
95 | - | |
96 | - result.unshift(botonVendedor); | |
97 | - } | |
98 | - | |
99 | 89 | return result; |
100 | 90 | }, |
101 | 91 | crearPuntosDescarga: function(puntosDescarga) { |