Commit 15efcde8ad4f79fde15a535fe07d6de12c9185c8
1 parent
9f48224aad
Exists in
master
seleccionar vendedor al seleccionar cliente
Showing
2 changed files
with
46 additions
and
35 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -442,7 +442,12 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 442 | 442 | } |
| 443 | 443 | }; |
| 444 | 444 | |
| 445 | - $scope.seleccionarVendedor = function() { | |
| 445 | + $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | |
| 446 | + if (ocultarVendedor) { | |
| 447 | + callback(); | |
| 448 | + return; | |
| 449 | + } | |
| 450 | + | |
| 446 | 451 | if(varlidarRemitoFacturado()) { |
| 447 | 452 | var parametrosModal = { |
| 448 | 453 | titulo: 'Búsqueda vendedores', |
| ... | ... | @@ -472,6 +477,8 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 472 | 477 | }); |
| 473 | 478 | $scope.remito.idVendedor = vendedor.id; |
| 474 | 479 | $scope.remito.vendedor = vendedor; |
| 480 | + deleteCliente(); | |
| 481 | + callback(); | |
| 475 | 482 | }, function() { |
| 476 | 483 | |
| 477 | 484 | } |
| ... | ... | @@ -479,6 +486,33 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 479 | 486 | } |
| 480 | 487 | }; |
| 481 | 488 | |
| 489 | + $scope.seleccionarCliente = function(ocultarVendedor) { | |
| 490 | + | |
| 491 | + $scope.seleccionarVendedor(function() { | |
| 492 | + if (varlidarRemitoFacturado()) { | |
| 493 | + var modalInstance = $uibModal.open( | |
| 494 | + { | |
| 495 | + ariaLabelledBy: 'Busqueda de Cliente', | |
| 496 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 497 | + controller: 'focaBusquedaClienteModalController', | |
| 498 | + resolve: { | |
| 499 | + vendedor: function() { return $scope.remito.vendedor; } | |
| 500 | + }, | |
| 501 | + size: 'lg' | |
| 502 | + } | |
| 503 | + ); | |
| 504 | + modalInstance.result.then( | |
| 505 | + function(cliente) { | |
| 506 | + $scope.abrirModalDomicilios(cliente); | |
| 507 | + $scope.cliente = cliente; | |
| 508 | + }, function() { | |
| 509 | + $scope.seleccionarCliente(); | |
| 510 | + } | |
| 511 | + ); | |
| 512 | + } | |
| 513 | + }, ocultarVendedor); | |
| 514 | + }; | |
| 515 | + | |
| 482 | 516 | $scope.seleccionarProveedor = function() { |
| 483 | 517 | if(varlidarRemitoFacturado()) { |
| 484 | 518 | var parametrosModal = { |
| ... | ... | @@ -522,35 +556,6 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 522 | 556 | } |
| 523 | 557 | }; |
| 524 | 558 | |
| 525 | - $scope.seleccionarCliente = function() { | |
| 526 | - if (!$scope.remito.vendedor) { | |
| 527 | - focaModalService.alert('Primero seleccione un vendedor'); | |
| 528 | - return; | |
| 529 | - } | |
| 530 | - | |
| 531 | - if (varlidarRemitoFacturado()) { | |
| 532 | - var modalInstance = $uibModal.open( | |
| 533 | - { | |
| 534 | - ariaLabelledBy: 'Busqueda de Cliente', | |
| 535 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 536 | - controller: 'focaBusquedaClienteModalController', | |
| 537 | - resolve: { | |
| 538 | - vendedor: function() { return $scope.remito.vendedor; } | |
| 539 | - }, | |
| 540 | - size: 'lg' | |
| 541 | - } | |
| 542 | - ); | |
| 543 | - modalInstance.result.then( | |
| 544 | - function(cliente) { | |
| 545 | - $scope.abrirModalDomicilios(cliente); | |
| 546 | - $scope.cliente = cliente; | |
| 547 | - }, function() { | |
| 548 | - | |
| 549 | - } | |
| 550 | - ); | |
| 551 | - } | |
| 552 | - }; | |
| 553 | - | |
| 554 | 559 | $scope.abrirModalDomicilios = function(cliente) { |
| 555 | 560 | var modalInstanceDomicilio = $uibModal.open( |
| 556 | 561 | { |
| ... | ... | @@ -600,7 +605,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 600 | 605 | }); |
| 601 | 606 | } |
| 602 | 607 | }, function() { |
| 603 | - $scope.seleccionarCliente(); | |
| 608 | + $scope.seleccionarCliente(true); | |
| 604 | 609 | return; |
| 605 | 610 | } |
| 606 | 611 | ); |
| ... | ... | @@ -1065,5 +1070,15 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1065 | 1070 | delete $localStorage.remito; |
| 1066 | 1071 | } |
| 1067 | 1072 | } |
| 1073 | + | |
| 1074 | + function deleteCliente() { | |
| 1075 | + delete $scope.remito.domicilioStamp; | |
| 1076 | + delete $scope.remito.puntosDescarga; | |
| 1077 | + $scope.remito.domicilio = {dom: ''}; | |
| 1078 | + $scope.remito.cliente = {}; | |
| 1079 | + $scope.$broadcast('removeCabecera', 'Cliente:'); | |
| 1080 | + $scope.$broadcast('removeCabecera', 'Domicilio:'); | |
| 1081 | + $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); | |
| 1082 | + } | |
| 1068 | 1083 | } |
| 1069 | 1084 | ]); |