PageSourceSearch

https://coopdigital.febor.coop/cdigital/aplicacion/app/components/comun/comun-services.js

js febor.coop collected 2026-10-02 01:53:51 UTC 23,982 bytes, 447 lines download raw bytes

1
2(function () {
3
4
5
6	angular
7		.module("app.comunModulo")
8		.service('comunService', ['$log', '$http', '$sessionStorage', '$rootScope', '$location', 'urlService', function ($log, $http, $sessionStorage, $rootScope, $location, urlService) {
9
10			var urlHost = urlService.url();// llamado para obtener la url dinamicamente 
11			var patronREST = urlService.patron();// llamado de patron res 
12			var ipadd = urlService.ipadd();
13
14			return {
15
16				// Cerrar session
17				cerrarSesion: function (usuario) {
18
19					var data = usuario;
20					var url = urlHost + patronREST + 'segu/cs';
21					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuario.adClientId, 'X-Http-adOrgIdStr': usuario.adOrgId, 'X-Http-userNameStr': usuario.username } }
22					$log.debug('comun-services cerraSesion DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
23
24					return $http.post(url, data, config).then(requestCompleted, requestFailed);
25
26					function requestCompleted(response) {
27
28						delete $sessionStorage.currentUser;
29						$http.defaults.headers.common.Authorization = '';
30						$http.defaults.headers.Authorization = '';
31						$rootScope.sttError = undefined;
32						$rootScope.msgError = undefined;
33						$rootScope.objetoUser = undefined;
34						$log.debug('comun-services cerraSesion then:  response{} ', response);
35						$location.path('/login');
36						return response.data;
37					}
38
39					function requestFailed(error) {
40
41						delete $sessionStorage.currentUser;
42						$http.defaults.headers.common.Authorization = '';
43						$http.defaults.headers.Authorization = '';
44						$rootScope.sttError = undefined;
45						$rootScope.msgError = undefined;
46						$rootScope.objetoUser = undefined;
47						$log.debug('comun-services cerraSesion requestFailed: error{} ', error);
48						$location.path('/login');
49						return error;
50					}
51				},
52
53				// Listar Combo Periodicidad
54				getComboPeriodicidad: function (PeriodicidadData, usuarioData) {
55
56					var url = urlHost + patronREST + 'combos/periodicidad-service';
57					var data = {
58						'usuario': usuarioData,
59						'objetoVO': PeriodicidadData
60					}
61					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
62					$log.debug('comun-services getComboPeriodicidad DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
63
64					return $http.post(url, data, config).then(requestCompleted, requestFailed);
65
66					function requestCompleted(response) {
67
68						$log.debug('comun-services getComboPeriodicidad then:  response{} ', response);
69						urlService.updateTokenAuthorization(response);
70						return response.data;
71					}
72
73					function requestFailed(error) {
74
75						$log.debug('comun-services getComboPeriodicidad requestFailed: error{} ', error);
76						var newMessage = '';
77						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
78						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
79						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
80						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
81						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
82						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
83						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
84						urlService.updateTokenAuthorization(error);
85						return error;
86					}
87				},
88
89				// Listar AdmTexto
90				listarAdmTexto: function (objetoData, usuarioData) {
91
92					var url = urlHost + patronREST + "admtextodet/listar-service";
93					var data = {
94						'usuario': usuarioData,
95						'objetoVO': objetoData
96					}
97					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
98					$log.debug('comun-services listarAdmTexto DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
99
100					return $http.post(url, data, config).then(requestCompleted, requestFailed);
101
102					function requestCompleted(response) {
103
104						$log.debug('comun-services listarAdmTexto then:  response{} ', response);
105						urlService.updateTokenAuthorization(response);
106						return response.data;
107					}
108
109					function requestFailed(error) {
110
111						$log.debug('comun-services listarAdmTexto requestFailed: error{} ', error);
112						var newMessage = '';
113						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
114						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
115						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
116						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
117						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
118						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
119						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
120						urlService.updateTokenAuthorization(error);
121						return error;
122					}
123				},
124
125				// Listar AdmTexto
126				listarAdmTextoDetPublico: function (objetoData) {
127
128					var url = urlHost + patronREST + "admtextodet/listarAdmTextoDetPublico-service";
129					var data = {
130						'objetoVO': objetoData
131					}
132					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;' } }
133					$log.debug('comun-services listarAdmTextoDetPublico DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
134
135					return $http.post(url, data, config).then(requestCompleted, requestFailed);
136
137					function requestCompleted(response) {
138
139						$log.debug('comun-services listarAdmTextoDetPublico then:  response{} ', response);
140						urlService.updateTokenAuthorization(response);
141						return response.data;
142					}
143
144					function requestFailed(error) {
145
146						$log.debug('comun-services listarAdmTextoDetPublico requestFailed: error{} ', error);
147						var newMessage = '';
148						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
149						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
150						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
151						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
152						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
153						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
154						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
155						urlService.updateTokenAuthorization(error);
156						return error;
157					}
158				},
159
160				// Envio sms otp
161				enviarOtp: function (objetoData, usuarioData) {
162
163					var url = urlHost + patronREST + "envios-sms/enviar-sms-otp-service";
164					var data = {
165						'usuario': usuarioData,
166						'adClientId': objetoData.adClientId,
167						'adOrgId': objetoData.adOrgId,
168						'destino': objetoData.destino,
169						'mensaje': objetoData.mensaje,
170						'canalServicio': usuarioData.origenOperacion,
171						'socioNegocio': usuarioData.socioNegocio,
172						'puntoVenta': usuarioData.puntoVenta,
173						'enviaMail': objetoData.enviaMail,
174						'enviaSMS': objetoData.enviaSMS,
175						'email': objetoData.email,
176						'codMotivo': objetoData.codMotivo
177						// objetoData
178					}
179					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
180					$log.debug('comun-services enviarOtp DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
181
182					return $http.post(url, data, config).then(requestCompleted, requestFailed);
183
184					function requestCompleted(response) {
185
186						$log.debug('comun-services enviarOtp then:  response{} ', response);
187						urlService.updateTokenAuthorization(response);
188						return response.data;
189					}
190
191					function requestFailed(error) {
192
193						$log.debug('comun-services enviarOtp requestFailed: error{} ', error);
194						var newMessage = '';
195						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
196						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
197						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
198						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
199						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
200						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
201						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
202						urlService.updateTokenAuthorization(error);
203						return error;
204					}
205				},
206
207				// Validacion sms otp seguro
208				validarOtpSeguro: function (objetoData, usuarioData) {
209
210					var url = urlHost + patronREST + "envios-sms/validar-otp-seguro-service";
211					var data = {
212						'usuario': usuarioData,
213						'objetoVO': objetoData
214					}
215					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
216					$log.debug('comun-services listarAdmTexto DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
217
218					return $http.post(url, data, config).then(requestCompleted, requestFailed);
219
220					function requestCompleted(response) {
221
222						$log.debug('comun-services enviarOtp then:  response{} ', response);
223						urlService.updateTokenAuthorization(response);
224						return response.data;
225					}
226
227					function requestFailed(error) {
228
229						$log.debug('comun-services enviarOtp requestFailed: error{} ', error);
230						var newMessage = '';
231						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
232						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
233						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
234						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
235						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
236						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
237						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
238						urlService.updateTokenAuthorization(error);
239						return error;
240					}
241				},
242				
243				validarOtp: function (objetoData, usuarioData) {
244
245					var url = urlHost + patronREST + "envios-sms/validar-otp-service";
246					var data = {
247						'usuario': usuarioData,
248						'objetoVO': objetoData
249					}
250					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
251					$log.debug('comun-services listarAdmTexto DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
252
253					return $http.post(url, data, config).then(requestCompleted, requestFailed);
254
255					function requestCompleted(response) {
256
257						$log.debug('comun-services enviarOtp then:  response{} ', response);
258						urlService.updateTokenAuthorization(response);
259						return response.data;
260					}
261
262					function requestFailed(error) {
263
264						$log.debug('comun-services enviarOtp requestFailed: error{} ', error);
265						var newMessage = '';
266						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
267						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
268						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
269						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
270						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
271						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
272						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
273						urlService.updateTokenAuthorization(error);
274						return error;
275					}
276				},
277				
278				// Envio sms otp seguro
279				enviarOtpSeguro: function (objetoData, usuarioData) {
280
281					var url = urlHost + patronREST + "envios-sms/enviar-otp-seguro-service";
282					var data = {
283						'usuario': usuarioData,
284						'objetoVO': {
285							'adClientId': objetoData.adClientId,
286							'adOrgId': objetoData.adOrgId,
287							'canalServicio': usuarioData.origenOperacion,
288							'origenOperacion': usuarioData.origenOperacion,
289							'socioNegocio': usuarioData.socioNegocio,
290							'puntoVenta': usuarioData.puntoVenta,
291							'codMotivo': objetoData.codMotivo
292						}
293
294					}
295					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
296					$log.debug('comun-services enviarOtpSeguro DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
297
298					return $http.post(url, data, config).then(requestCompleted, requestFailed);
299
300					function requestCompleted(response) {
301
302						$log.debug('comun-services enviarOtp then:  response{} ', response);
303						urlService.updateTokenAuthorization(response);
304						return response.data;
305					}
306
307					function requestFailed(error) {
308
309						$log.debug('comun-services enviarOtp requestFailed: error{} ', error);
310						var newMessage = '';
311						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
312						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
313						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
314						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
315						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
316						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
317						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
318						urlService.updateTokenAuthorization(error);
319						return error;
320					}
321				},
322				
323				// Validación de clave dinámica
324				validarClaveDinamica: function (objetoData, usuarioData) {
325
326					var url = urlHost + patronREST + "segu/validar-clave-dinamica-service";
327					
328					var data = {
329						'usuario': usuarioData,
330						'objetoVO': {
331							'adClientId': objetoData.adClientId,
332							'adOrgId': objetoData.adOrgId,							
333							'codigo' : objetoData.codigo,		
334							'celular' : objetoData.celular,
335							'codMotivo': objetoData.codMotivo,		
336							'nombreCompleto': objetoData.nombreCompleto,
337		                    'tipoIdentificacion' : objetoData.tipoIdentificacion,
338							'identificacion' : objetoData.identificacion												
339						}
340					}										
341
342					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
343					$log.debug('comun-services validarClaveDinamica DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
344
345					return $http.post(url, data, config).then(requestCompleted, requestFailed);
346
347					function requestCompleted(response) {
348
349						$log.debug('comun-services validarClaveDinamica then:  response{} ', response);
350						urlService.updateTokenAuthorization(response);
351						return response.data;
352					}
353
354					function requestFailed(error) {
355
356						$log.debug('comun-services validarClaveDinamica requestFailed: error{} ', error);
357						var newMessage = '';
358						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
359						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
360						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
361						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
362						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
363						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
364						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
365						urlService.updateTokenAuthorization(error);
366						return error;
367					}
368				},				
369
370				// Listar AdmTexto
371				listarAdmPantalla: function (objetoData) {
372
373					var url = urlHost + patronREST + "admpantalla/listar-service";
374					var data = {
375						'objetoVO': objetoData
376					}
377					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;' } }
378					$log.debug('comun-services listarAdmPantalla DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
379
380					return $http.post(url, data, config).then(requestCompleted, requestFailed);
381
382					function requestCompleted(response) {
383
384						$log.debug('comun-services listarAdmPantalla then:  response{} ', response);
385						urlService.updateTokenAuthorization(response);
386						return response.data;
387					}
388
389					function requestFailed(error) {
390
391						$log.debug('comun-services listarAdmPantalla requestFailed: error{} ', error);
392						var newMessage = '';
393						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
394						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
395						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
396						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
397						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
398						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
399						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
400						urlService.updateTokenAuthorization(error);
401						return error;
402					}
403				},
404
405				// obtener SystemVariable
406				obtenerSystemVariable: function (objetoData, usuarioData) {
407
408					var url = urlHost + patronREST + "util/getSystemVariable-service";
409					var data = {
410						'usuario': usuarioData,
411						'objetoVO': objetoData
412					}
413					var config = { headers: { 'Content-Type': 'application/json;charset=utf-8;', 'X-Http-adClientIdStr': usuarioData.adClientId, 'X-Http-adOrgIdStr': usuarioData.adOrgId, 'X-Http-userNameStr': usuarioData.username } }
414					$log.debug('comun-services obtenerSystemVariable DATA_ENVIADA: url{} ', url, ' - data{Object} ', data, ' - config{} ', config);
415
416					return $http.post(url, data, config).then(requestCompleted, requestFailed);
417
418					function requestCompleted(response) {
419
420						$log.debug('comun-services obtenerSystemVariable then:  response{} ', response);
421						urlService.updateTokenAuthorization(response);
422						return response.data;
423					}
424
425					function requestFailed(error) {
426
427						$log.debug('comun-services obtenerSystemVariable requestFailed: error{} ', error);
428						var newMessage = '';
429						if (error.data) { if (error.data.indexOf('<html>') === -1) { newMessage = newMessage + error.data; } else { newMessage = 'Error general, por favor contacta al administrador' } }
430						if (error.status === 401) { $rootScope.msgError = newMessage; $location.path('/login'); }
431						else if (error.status === 400) { if (!error.data) error.data = 'Petición incorrecta, por favor verifica los datos !'; }
432						else if (error.status === 404) { if (!error.data) error.data = 'El recurso requerido no está disponible !'; }
433						else if (error.status < 500 || error.status > 500) { if (error.data == 'No se encontró sesión activa, debes volver a ingresar.') { urlService.cerrarSesion(); } else { if (!error.data) error.data = 'No fué posible realizar la operación !'; } }
434						else if (error.status === 500) { $rootScope.msgError = newMessage; $location.path('/500'); }
435						else { $rootScope.msgError = newMessage; $location.path('/infoPage'); }
436						urlService.updateTokenAuthorization(error);
437						return error;
438					}
439				},
440
441			}
442
443		}]);
444
445})();
446
447

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.