Commit 98e8b1ed021f31664c6ecc534858443b2d503db9
Exists in
master
Merge branch 'master' into 'master'
Master See merge request !3
Showing
4 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaAgendarVisita') | 1 | angular.module('focaAgendarVisita') |
2 | .controller('focaAgendarVisitaController', [ | 2 | .controller('focaAgendarVisitaController', [ |
3 | '$scope', 'focaAgendarVisitaService', '$location', '$timeout', | 3 | '$scope', 'focaAgendarVisitaService', '$location', '$timeout', |
4 | '$uibModal', 'focaBotoneraLateralService', '$filter', 'focaLoginService', | 4 | '$uibModal', 'focaBotoneraLateralService', '$filter', |
5 | 'focaModalService', 'focaSeguimientoService', | 5 | 'focaModalService', 'focaSeguimientoService', |
6 | function($scope, focaAgendarVisitaService, $location, $timeout, | 6 | function($scope, focaAgendarVisitaService, $location, $timeout, |
7 | $uibModal, focaBotoneraLateralService, $filter, focaLoginService, | 7 | $uibModal, focaBotoneraLateralService, $filter, |
8 | focaModalService, focaSeguimientoService | 8 | focaModalService, focaSeguimientoService |
9 | ) { | 9 | ) { |
10 | $scope.focused = 0; | 10 | $scope.focused = 0; |
11 | $scope.rol = 1; | 11 | $scope.rol = 1; |
12 | $scope.visita = {}; | 12 | $scope.visita = {}; |
13 | $scope.now = new Date(); | 13 | $scope.now = new Date(); |
14 | $scope.botonera = [ | 14 | $scope.botonera = focaAgendarVisitaService.getBotonera(); |
15 | { | ||
16 | label: 'Agendar', | ||
17 | image: 'precios-condiciones.png' | ||
18 | } | ||
19 | ]; | ||
20 | $timeout(function() { | 15 | $timeout(function() { |
21 | focaBotoneraLateralService.showSalir(true); | 16 | focaBotoneraLateralService.showSalir(true); |
22 | focaBotoneraLateralService.showPausar(true); | 17 | focaBotoneraLateralService.showPausar(true); |
23 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 18 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
24 | }); | 19 | }); |
25 | 20 | ||
26 | $scope.seleccionarCliente = function() { | 21 | $scope.seleccionarCliente = function() { |
27 | var modalInstance = $uibModal.open( | 22 | var modalInstance = $uibModal.open( |
28 | { | 23 | { |
29 | ariaLabelledBy: 'Busqueda de Cliente', | 24 | ariaLabelledBy: 'Busqueda de Cliente', |
30 | templateUrl: 'foca-busqueda-cliente-modal.html', | 25 | templateUrl: 'foca-busqueda-cliente-modal.html', |
31 | controller: 'focaBusquedaClienteModalController', | 26 | controller: 'focaBusquedaClienteModalController', |
32 | resolve: { | 27 | resolve: { |
33 | vendedor: function() { return null; } | 28 | vendedor: function() { return null; } |
34 | }, | 29 | }, |
35 | size: 'lg' | 30 | size: 'lg' |
36 | } | 31 | } |
37 | ); | 32 | ); |
38 | modalInstance.result.then( | 33 | modalInstance.result.then( |
39 | function(cliente) { | 34 | function(cliente) { |
40 | $scope.visita.cliente = cliente; | 35 | $scope.visita.cliente = cliente; |
36 | $scope.$broadcast('addCabecera', { | ||
37 | label: 'Cliente:', | ||
38 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + | ||
39 | cliente.nom | ||
40 | }); | ||
41 | } | 41 | } |
42 | ); | 42 | ); |
43 | }; | 43 | }; |
44 | $scope.seleccionarVisitante = function() { | 44 | $scope.seleccionarVisitante = function() { |
45 | var parametrosModal = { | 45 | var parametrosModal = { |
46 | query: '/vendedor-cobrador', | 46 | query: '/vendedor-cobrador', |
47 | columnas: [ | 47 | columnas: [ |
48 | { | 48 | { |
49 | propiedad: 'NUM', | 49 | propiedad: 'NUM', |
50 | nombre: 'Codigo', | 50 | nombre: 'Codigo', |
51 | filtro: { | 51 | filtro: { |
52 | nombre: 'rellenarDigitos', | 52 | nombre: 'rellenarDigitos', |
53 | parametro: 3 | 53 | parametro: 3 |
54 | } | 54 | } |
55 | }, | 55 | }, |
56 | { | 56 | { |
57 | propiedad: 'NOM', | 57 | propiedad: 'NOM', |
58 | nombre: 'Nombre' | 58 | nombre: 'Nombre' |
59 | } | 59 | } |
60 | ], | 60 | ], |
61 | titulo:'Búsqueda de vendedores y cobradores', | 61 | titulo:'Búsqueda de vendedores y cobradores', |
62 | size: 'md' | 62 | size: 'md' |
63 | }; | 63 | }; |
64 | focaModalService.modal(parametrosModal).then(function(vendedorCobrador) { | 64 | focaModalService.modal(parametrosModal).then(function(vendedorCobrador) { |
65 | $scope.visita.visitante = vendedorCobrador; | 65 | if (vendedorCobrador.rol === 3) { |
66 | $uibModal.open( | ||
67 | { | ||
68 | ariaLabelledBy: 'Seleccionar tipo de visita', | ||
69 | templateUrl: 'modal-tipo-visita.html', | ||
70 | controller: 'focaModalTipoVisita', | ||
71 | resolve: {}, | ||
72 | size: 'md' | ||
73 | } | ||
74 | ) | ||
75 | .result | ||
76 | .then(function(res) { | ||
77 | $scope.rol = res; | ||
78 | $scope.visita.visitante = vendedorCobrador; | ||
79 | $scope.$broadcast('addCabecera', { | ||
80 | label: 'Vendedor:', | ||
81 | valor: $filter('rellenarDigitos')(vendedorCobrador.NUM, 3) + ' - ' + | ||
82 | vendedorCobrador.NOM | ||
83 | }); | ||
84 | }); | ||
85 | |||
86 | } else { | ||
87 | $scope.visita.visitante = vendedorCobrador; | ||
88 | $scope.$broadcast('addCabecera', { | ||
89 | label: 'Vendedor:', | ||
90 | valor: $filter('rellenarDigitos')(vendedorCobrador.NUM, 3) + ' - ' + | ||
91 | vendedorCobrador.NOM | ||
92 | }); | ||
93 | } | ||
94 | |||
66 | }); | 95 | }); |
67 | }; | 96 | }; |
97 | $scope.seleccionarObservaciones = function() { | ||
98 | focaModalService | ||
99 | .prompt('Ingrese observaciones', $scope.visita.observacion, true) | ||
100 | .then(function(observacion) { | ||
101 | $scope.visita.observacion = observacion; | ||
102 | }); | ||
103 | }; | ||
68 | 104 | ||
69 | $scope.next = function(key) { | 105 | $scope.next = function(key) { |
70 | if (key === 13) $scope.focused ++; | 106 | if (key === 13) $scope.focused ++; |
71 | }; | 107 | }; |
72 | 108 | ||
73 | $scope.guardar = function() { | 109 | $scope.guardar = function() { |
74 | var rol; | 110 | var rol; |
75 | if ($scope.visita.visitante.rol === 1) { | 111 | if ($scope.visita.visitante.rol === 1) { |
76 | rol = 'Nota de pedido'; | 112 | rol = 'Nota de pedido'; |
77 | } else if ($scope.visita.visitante.rol === 2) { | 113 | } else if ($scope.visita.visitante.rol === 2) { |
78 | rol = 'Cobranza'; | 114 | rol = 'Cobranza'; |
79 | } else { | 115 | } else { |
80 | rol = ($scope.rol === 1) ? 'Nota de pedido' : 'Cobranza'; | 116 | rol = ($scope.rol === 1) ? 'Nota de pedido' : 'Cobranza'; |
81 | } | 117 | } |
82 | 118 | ||
83 | focaAgendarVisitaService | 119 | focaAgendarVisitaService |
84 | .guardarVisita({ | 120 | .guardarVisita({ |
85 | idVisitante: $scope.visita.visitante.NUM, | 121 | idVisitante: $scope.visita.visitante.NUM, |
86 | idCliente: $scope.visita.cliente.cod | 122 | idCliente: $scope.visita.cliente.cod |
87 | }) | 123 | }) |
88 | .then(function(data) { | 124 | .then(function(data) { |
89 | focaSeguimientoService.guardarPosicion( | 125 | focaSeguimientoService.guardarPosicion( |
90 | rol, | 126 | rol, |
91 | data.data.id, | 127 | data.data.id, |
92 | $scope.visita.observacion, | 128 | $scope.visita.observacion, |
93 | data.data.id | 129 | data.data.id |
94 | ); | 130 | ); |
95 | }) | 131 | }) |
96 | .then(function() { | 132 | .then(function() { |
97 | $location.path('/'); | 133 | $location.path('/'); |
98 | }); | 134 | }); |
99 | }; | 135 | }; |
100 | } | 136 | } |
137 | ]) | ||
138 | .controller('focaModalTipoVisita', ['$uibModalInstance', '$scope', | ||
139 | function($uibModalInstance, $scope) { | ||
140 | $scope.cancel = function() { | ||
141 | $uibModalInstance.dismiss(); | ||
142 | }; | ||
143 | |||
144 | $scope.select = function(val) { |
src/js/service.js
1 | angular.module('focaAgendarVisita') | 1 | angular.module('focaAgendarVisita') |
2 | .factory('focaAgendarVisitaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .factory('focaAgendarVisitaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | return { | 3 | return { |
4 | guardarVisita: function(visita) { | 4 | guardarVisita: function(visita) { |
5 | return $http.post(API_ENDPOINT.URL + '/visita', {visita: visita}); | 5 | return $http.post(API_ENDPOINT.URL + '/visita', {visita: visita}); |
6 | }, | ||
7 | getBotonera: function() { | ||
8 | return [ | ||
9 | { | ||
10 | label: 'Cliente', | ||
11 | image: 'precios-condiciones.png' | ||
12 | }, | ||
13 | { | ||
14 | label: 'Visitante', | ||
15 | image: 'precios-condiciones.png' | ||
16 | }, | ||
17 | { | ||
18 | label: 'Observaciones', | ||
19 | image: 'precios-condiciones.png' | ||
20 | } | ||
21 | ] | ||
6 | } | 22 | } |
7 | }; | 23 | }; |
8 | }]); | 24 | }]); |
9 | 25 |
src/views/agendar-visita.html
1 | <div class="row"> | 1 | <div class="row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Agendar visita'" | 3 | titulo="'Agendar visita'" |
4 | fecha="now" | 4 | fecha="now" |
5 | class="mb-0 col-lg-12" | 5 | class="mb-0 col-lg-12" |
6 | ></foca-cabecera-facturador> | 6 | ></foca-cabecera-facturador> |
7 | </div> | 7 | <div class="col-lg-12"> |
8 | <div class="row"> | 8 | <div class="row"> |
9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 9 | <div class="col-12 col-md-10 col-lg-10 mt-4 border border-light rounded"> |
10 | <form class="row py-2 mt-3 botonera-secundaria"> | 10 | <div class="row py-2 botonera-secundaria"> |
11 | <div class="col-md-6"> | 11 | <div class="col-12 foca-facturador-px"> |
12 | <div class="form-group mb-2 col-md-12 d-md-flex"> | 12 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> |
13 | <label class="col-form-label col-md-4 col-12">Cliente</label> | ||
14 | <div class="input-group col-md-8 col-12 pl-0"> | ||
15 | <input | ||
16 | class="form-control" | ||
17 | type="text" | ||
18 | teclado-virtual | ||
19 | ng-model="visita.cliente.nom" | ||
20 | foca-focus="focused == 1" | ||
21 | ng-focus="focused = 1" | ||
22 | ng-keypress="next($event.keyCode)" | ||
23 | disabled> | ||
24 | <div class="input-group-append"> | ||
25 | <button | ||
26 | class="btn btn-outline-secondary form-control" | ||
27 | title="Buscar" | ||
28 | type="button" | ||
29 | ng-click="seleccionarCliente()"> | ||
30 | <i class="fa fa-search" aria-hidden="true"></i> | ||
31 | </button> | ||
32 | </div> | ||
33 | </div> | ||
34 | </div> | ||
35 | <div class="form-group mb-2 col-md-12 d-md-flex"> | ||
36 | <label class="col-form-label col-md-4 col-12">Visitante</label> | ||
37 | <div class="input-group col-md-8 col-12 pl-0"> | ||
38 | <input | ||
39 | class="form-control" | ||
40 | type="text" | ||
41 | teclado-virtual | ||
42 | ng-model="visita.visitante.NOM" | ||
43 | foca-focus="focused == 1" | ||
44 | ng-focus="focused = 1" | ||
45 | ng-keypress="next($event.keyCode)" | ||
46 | disabled> | ||
47 | <div class="input-group-append"> | ||
48 | <button | ||
49 | class="btn btn-outline-secondary form-control" | ||
50 | title="Buscar" | ||
51 | type="button" | ||
52 | ng-click="seleccionarVisitante()"> | ||
53 | <i class="fa fa-search" aria-hidden="true"></i> | ||
54 | </button> | ||
55 | </div> | ||
56 | </div> | 13 | </div> |
57 | </div> | 14 | </div> |
58 | <div | ||
59 | class="form-group mb-2 col-md-12 d-md-flex" | ||
60 | ng-show="visita.visitante.rol === 3"> | ||
61 | <label class="col-form-label col-md-4 col-12">Tipo</label> | ||
62 | <div class="input-group col-md-8 col-12 pl-0"> | ||
63 | <select class="form-control" ng-model="rol"> | ||
64 | <option value="1">Vendedor</option> | ||
65 | <option value="2">Cobrador</option> | ||
66 | </select> | ||
67 | </div> | ||
68 | </div> | ||
69 | </div> | ||
70 | <div class="form-group mb-2 col-md-6 d-md-flex"> | ||
71 | <label class="col-form-label col-md-4 col-12">Observaciones</label> | ||
72 | <div class="input-group col-md-8 col-12"> | ||
73 | <textarea | ||
74 | rows="5" | ||
75 | class="form-control" | ||
76 | teclado-virtual | ||
77 | ng-model="visita.observacion" | ||
78 | foca-focus="focused == 1" | ||
79 | ng-focus="focused = 1" | ||
80 | ng-keypress="next($event.keyCode)"> | ||
81 | </div> | ||
82 | </div> | 15 | </div> |
83 | </form> | 16 | </div> |
84 | </div> | 17 | </div> |
85 | </div> | 18 | </div> |
86 | 19 |
src/views/modal-tipo-visita.html
File was created | 1 | <div class="modal-header py-1"> | |
2 | <div class="row w-100"> | ||
3 | <div class="col-12"> | ||
4 | <h5 class="modal-title my-1">Seleccionar tipo de visita</h5> | ||
5 | </div> | ||
6 | </div> | ||
7 | </div> | ||
8 | <div class="modal-body" id="modal-body"> | ||
9 | <table class="table table-striped table-sm"> | ||
10 | <thead> | ||
11 | <tr> | ||
12 | <th>Tipo</th> | ||
13 | <th></th> | ||
14 | </tr> | ||
15 | </thead> | ||
16 | <tbody> | ||
17 | <tr> | ||
18 | <td>Nota de pedido</td> | ||
19 | <td> | ||
20 | <button | ||
21 | type="button" | ||
22 | class="btn btn-secondary btn-xs p-1 float-right" | ||
23 | ng-click="select(1)" | ||
24 | > | ||
25 | <i class="fa fa-circle-thin" aria-hidden="true"></i> | ||
26 | </button> | ||
27 | </td> | ||
28 | </tr> | ||
29 | <tr> | ||
30 | <td>Cobranza</td> | ||
31 | <td> | ||
32 | <button | ||
33 | type="button" | ||
34 | class="btn btn-secondary btn-xs p-1 float-right" | ||
35 | ng-click="select(2)" | ||
36 | > | ||
37 | <i class="fa fa-circle-thin" aria-hidden="true"></i> | ||
38 | </button> | ||
39 | </td> | ||
40 | </tr> | ||
41 | </tbody> | ||
42 | </table> | ||
43 | </div> | ||
44 | <div class="modal-footer py-1"> | ||
45 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
46 | </div> | ||
47 |