Commit 65c5fcc725b8398cc0a553d2a8941966995081f7

Authored by Jose Pinto
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !27
src/js/controller.js
... ... @@ -11,13 +11,29 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
11 11 'notaPedidoBusinessService',
12 12 '$rootScope',
13 13 'focaSeguimientoService',
  14 + 'APP',
  15 + 'focaLoginService',
14 16 function(
15   - $scope, $uibModal, $location, $filter, $timeout,
16   - crearNotaPedidoService, focaBotoneraLateralService,
17   - focaModalService, notaPedidoBusinessService, $rootScope, focaSeguimientoService)
  17 + $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService,
  18 + focaBotoneraLateralService, focaModalService, notaPedidoBusinessService,
  19 + $rootScope, focaSeguimientoService, APP, focaLoginService)
18 20 {
19   -
20   - $scope.botonera = crearNotaPedidoService.getBotonera();
  21 + if(APP === 'distribuidor') {
  22 + var idVendedor = focaLoginService.getLoginData().vendedorCobrador;
  23 + $scope.botonera = crearNotaPedidoService.getBotonera(idVendedor);
  24 + crearNotaPedidoService.getVendedorById(idVendedor).then(
  25 + function(res) {
  26 + var vendedor = res.data;
  27 + $scope.$broadcast('addCabecera', {
  28 + label: 'Vendedor:',
  29 + valor: vendedor.NomVen
  30 + });
  31 + $scope.notaPedido.vendedor = vendedor;
  32 + }
  33 + );
  34 + }else {
  35 + $scope.botonera = crearNotaPedidoService.getBotonera();
  36 + }
21 37  
22 38 $scope.isNumber = angular.isNumber;
23 39 $scope.datepickerAbierto = false;
... ... @@ -420,7 +436,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
420 436 });
421 437 $scope.notaPedido.vendedor = vendedor;
422 438 }, function() {
423   -
  439 +
424 440 }
425 441 );
426 442 }
... ... @@ -758,7 +774,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
758 774 }
759 775 $scope.mostrarTeclado = false;
760 776 });
761   -
  777 +
762 778 $scope.selectFocus = function($event) {
763 779 // Si el teclado esta en uso no selecciona el valor
764 780 if($scope.mostrarTeclado) {
... ... @@ -775,7 +791,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
775 791 articulo.cantidad = parseFloat(articulo.cantidad);
776 792 articulo.precio = parseFloat(articulo.precio);
777 793 };
778   -
  794 +
779 795 function addArrayCabecera(array) {
780 796 for(var i = 0; i < array.length; i++) {
781 797 $scope.$broadcast('addCabecera', {
... ... @@ -55,12 +55,8 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
55 55 getNumeroNotaPedido: function() {
56 56 return $http.get(route + '/nota-pedido/numero-siguiente');
57 57 },
58   - getBotonera: function() {
59   - return [
60   - {
61   - label: 'Vendedor',
62   - image: 'vendedor.png'
63   - },
  58 + getBotonera: function(vendedor) {
  59 + var result = [
64 60 {
65 61 label: 'Cliente',
66 62 image: 'cliente.png'
... ... @@ -86,6 +82,14 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
86 82 image: 'productos.png'
87 83 }
88 84 ];
  85 + if(!vendedor) {
  86 + var botonVendedor = {
  87 + label: 'Vendedor',
  88 + image: 'vendedor.png'
  89 + }
  90 + result.unshift(botonVendedor)
  91 + }
  92 + return result;
89 93 },
90 94 crearPuntosDescarga: function(puntosDescarga) {
91 95 return $http.post(route + '/puntos-descarga/nota-pedido',
... ... @@ -94,6 +98,9 @@ angular.module(&#39;focaCrearNotaPedido&#39;)
94 98 getPuntosDescargaByClienDom: function(idDomicilio, idCliente) {
95 99 return $http.get(API_ENDPOINT.URL + '/punto-descarga/' +
96 100 idDomicilio + '/' + idCliente);
  101 + },
  102 + getVendedorById: function(id) {
  103 + return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id);
97 104 }
98 105 };
99 106 }]);