Commit 6b748181ee95e0badd22439f03f68d1d32baf6e9
1 parent
f7458e1596
Exists in
master
get vendedor when mobile
Showing
2 changed files
with
53 additions
and
12 deletions
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaCrearFactura').controller('facturaController', [ |
2 | 2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', |
3 | 3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', |
4 | - '$localStorage', 'APP', | |
4 | + '$localStorage', 'APP', 'focaLoginService', | |
5 | 5 | function ( |
6 | 6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, |
7 | - crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP) { | |
7 | + crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) | |
8 | + { | |
8 | 9 | |
9 | 10 | config(); |
10 | 11 | |
... | ... | @@ -88,6 +89,33 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
88 | 89 | ); |
89 | 90 | |
90 | 91 | $scope.inicial = angular.copy($scope.factura); |
92 | + | |
93 | + if (APP == 'facturador') { | |
94 | + crearFacturaService | |
95 | + .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) | |
96 | + .then(function (res) { | |
97 | + | |
98 | + validarPlanillaVendedor(res.data) | |
99 | + .then(function () { | |
100 | + | |
101 | + $scope.$broadcast('addCabecera', { | |
102 | + label: 'Vendedor:', | |
103 | + valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + | |
104 | + ' - ' + | |
105 | + res.data.NomVen | |
106 | + }); | |
107 | + | |
108 | + $scope.factura.vendedor = res.data; | |
109 | + | |
110 | + getProductosByPlanilla(res.data.NplVen); | |
111 | + }) | |
112 | + .catch(function (err) { | |
113 | + console.log(err); | |
114 | + focaModalService.alert('Ocurrió un error al intentar recuperar' + | |
115 | + 'el vendedor logeado'); | |
116 | + }); | |
117 | + }) | |
118 | + } | |
91 | 119 | } |
92 | 120 | |
93 | 121 | $scope.$watch('factura', function (newValue) { |
... | ... | @@ -643,7 +671,7 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
643 | 671 | return new Promise(function (resolve, reject) { |
644 | 672 | |
645 | 673 | crearFacturaService |
646 | - .validarPlanillaVendedor(vendedor.CodVen.trim()) | |
674 | + .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) | |
647 | 675 | .then(function (res) { |
648 | 676 | |
649 | 677 | if (!res.data.length) { |
... | ... | @@ -657,7 +685,10 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
657 | 685 | } |
658 | 686 | |
659 | 687 | }) |
660 | - .catch(reject); | |
688 | + .catch(function (err) { | |
689 | + console.log(err) | |
690 | + reject(); | |
691 | + }); | |
661 | 692 | }); |
662 | 693 | } |
663 | 694 |
src/js/service.js
1 | 1 | angular.module('focaCrearFactura') |
2 | - .service('crearFacturaService', ['$http', 'API_ENDPOINT', | |
3 | - function ($http, API_ENDPOINT) { | |
2 | + .service('crearFacturaService', ['$http', 'API_ENDPOINT', 'APP', | |
3 | + function ($http, API_ENDPOINT, APP) { | |
4 | 4 | var route = API_ENDPOINT.URL; |
5 | 5 | return { |
6 | 6 | guardarFactura: function (factura) { |
... | ... | @@ -22,14 +22,18 @@ angular.module('focaCrearFactura') |
22 | 22 | return $http.post(route + '/turnos/depacho-sin-uso', parametros); |
23 | 23 | }, |
24 | 24 | getResumenCuenta: function (idCliente) { |
25 | - return $http.get(API_ENDPOINT + '/cliente/resumen-cuenta/' + idCliente); | |
25 | + return $http.get(route + '/cliente/resumen-cuenta/' + idCliente); | |
26 | + }, | |
27 | + getVendedorPlayaById: function (id) { | |
28 | + return $http.get(route + '/vendedor-playa/' + id); | |
26 | 29 | }, |
27 | 30 | getBotonera: function () { |
28 | - return [ | |
29 | - { | |
30 | - label: 'Vendedor', | |
31 | - image: 'vendedor.png' | |
32 | - }, | |
31 | + var vendedor = { | |
32 | + label: 'Vendedor', | |
33 | + image: 'vendedor.png' | |
34 | + }; | |
35 | + | |
36 | + var botones = [ | |
33 | 37 | { |
34 | 38 | label: 'Cliente', |
35 | 39 | image: 'cliente.png' |
... | ... | @@ -43,6 +47,12 @@ angular.module('focaCrearFactura') |
43 | 47 | image: 'botonObservaciones.png' |
44 | 48 | } |
45 | 49 | ]; |
50 | + | |
51 | + if (APP != 'facturador') { | |
52 | + botones.unshift(vendedor); | |
53 | + } | |
54 | + | |
55 | + return botones; | |
46 | 56 | } |
47 | 57 | }; |
48 | 58 | } |