Commit 1c2bda9be56c0f6f853e490b44627043a4243357
1 parent
98e8b1ed02
Exists in
master
Boton Pausar Agendar Visita
Showing
2 changed files
with
30 additions
and
4 deletions
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaAgendarVisita') |
2 | 2 | .controller('focaAgendarVisitaController', [ |
3 | - '$scope', 'focaAgendarVisitaService', '$location', '$timeout', | |
3 | + '$scope', 'focaAgendarVisitaService', '$location','$localStorage', '$timeout', | |
4 | 4 | '$uibModal', 'focaBotoneraLateralService', '$filter', |
5 | 5 | 'focaModalService', 'focaSeguimientoService', |
6 | - function($scope, focaAgendarVisitaService, $location, $timeout, | |
6 | + function($scope, focaAgendarVisitaService, $location, $localStorage, $timeout, | |
7 | 7 | $uibModal, focaBotoneraLateralService, $filter, |
8 | 8 | focaModalService, focaSeguimientoService |
9 | 9 | ) { |
... | ... | @@ -18,6 +18,8 @@ angular.module('focaAgendarVisita') |
18 | 18 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
19 | 19 | }); |
20 | 20 | |
21 | + $timeout(function() {getLSVisita();}); | |
22 | + | |
21 | 23 | $scope.seleccionarCliente = function() { |
22 | 24 | var modalInstance = $uibModal.open( |
23 | 25 | { |
... | ... | @@ -41,6 +43,22 @@ angular.module('focaAgendarVisita') |
41 | 43 | } |
42 | 44 | ); |
43 | 45 | }; |
46 | + function setearVisita(visita){ | |
47 | + $scope.visita = visita; | |
48 | + $scope.$broadcast('addCabecera', { | |
49 | + label: 'Cliente:', | |
50 | + valor: $filter('rellenarDigitos')(visita.cliente.cod, 3) + ' - ' + | |
51 | + visita.cliente.nom | |
52 | + }); | |
53 | + } | |
54 | + function getLSVisita(){ | |
55 | + var visita= JSON.parse($localStorage.visita || null); | |
56 | + if (visita) { | |
57 | + setearVisita(visita); | |
58 | + delete $localStorage.visita; | |
59 | + } | |
60 | + } | |
61 | + | |
44 | 62 | $scope.seleccionarVisitante = function() { |
45 | 63 | var parametrosModal = { |
46 | 64 | query: '/vendedor-cobrador', |
... | ... | @@ -106,6 +124,13 @@ angular.module('focaAgendarVisita') |
106 | 124 | if (key === 13) $scope.focused ++; |
107 | 125 | }; |
108 | 126 | |
127 | + $scope.$watch('visita', function(newValue, oldValue){ | |
128 | + focaBotoneraLateralService.setPausarData({ | |
129 | + label: 'visita', | |
130 | + val: newValue | |
131 | + }); | |
132 | + }); | |
133 | + | |
109 | 134 | $scope.guardar = function() { |
110 | 135 | var rol; |
111 | 136 | if ($scope.visita.visitante.rol === 1) { |