//Objeto oCampDesc var oCampDesc = oCampDesc || {}; var gJSNom = "IN_LogJs"; // #################################################################################################################################### // // **************** // // *** fnSearch *** // // **************** // oCampDesc.fnSearch = function () { "use strict"; var lRutNom = gJSNom + ".fnSearch"; if (oGlobal.ambiente !== "PROD") { console.log(lRutNom + " -Inicio"); } // $("#SectionResultado").fadeIn(1500); oGen.fnBloqueoUnico(); var params = { /* Parametros de la consulta */ } //--- oConsulta.show({ consulta: "OV_CAMPANA_DESCUENTO", dataSource: "ovQbe", titulo: "Tabla - Campañas y Descuentos", idComponente: "divDatosConsulta", exportar: true, busqueda: true, estilo: "grillaSmall", paramsDefault: params, //paramsDefault fnCallback: function (row, col) { //Ingresa al hacer click en el registro if (oGlobal.ambiente !== "PROD") { console.log(lRutNom + " -"); console.log(lRutNom + " -row"); console.log(row); console.log(lRutNom + " -col"); console.log(col); console.log(lRutNom + " -"); } switch (col) { case 6: //Columna Acción switch (oCampDesc.sMode) { case 'EDIT': oCampDesc.fnEditarFila(row); break; case 'DELETE': oCampDesc.fnEliminarFila(row); break; default: /* Nothing... */ oGen.logDesarrollo('Modo no indentificado'); break; } break; default: /* Nothing... */ break; } } //fnCallback }); // P_GET_OVLOG if (oGlobal.ambiente !== "PROD") { console.log("oCampDesc.fnSearch - Fin"); } oGen.fnBloqueoUnicoHide(); }; //fnSearch // #################################################################################################################################### // oCampDesc.sMode = 'EDIT'; oCampDesc.fnCambiarModo = function (mode) { oCampDesc.sMode = mode; } oCampDesc.fnShowActions = function (val, reg) { return '   '; }; //Edita la fila oCampDesc.fnEditarFila = function (data) { oCampDesc.fnShowModal(data); }; //Borra la fila y vuelve a consultar oCampDesc.fnEliminarFila = function (data) { //Show modal var msj = 'Modificar o eliminar campañas o descuentos existentes afectará a todas las pólizas que actualmente tengan aplicada la campaña o el descuento. ¿Desea continuar?'; MessageAlert.confirmation('Elimiar Campaña o Descuento', msj, function () { eliminarFila() }, 'Confirmar', 'Cancelar', function () { }); //Callback var eliminarFila = function () { oGen.fnGetStore({ titulo: ' Elimiar Campaña y Descuento', params: { prm_dataSource: 'ovQbe', prm_funcion: 'paCampaniaDescuento.baja', prm_code: data.CODE }, fnCallback: function (oResp) { if (oResp.PRM_CODERROR !== undefined && oResp.PRM_CODERROR == 0) { oCampDesc.fnSearch(); } else { var msj = ''; if (oResp.PRM_MSGERROR !== undefined) { msj = oResp.PRM_MSGERROR; } else if (oResp.message !== undefined) { msj = oResp.message; } else { msj = 'Hubo un error inesperado, por favor intente más tarde.'; } MessageAlert.messagePopup('Error', '

' + msj + '

', 20); $('#DIALOG-MESSAGE-ALERT #DIALOG-MESSAGE-ALERT-BUTTONS').show(); } } }); } }; oCampDesc.fnShowModal = function (data) { oGen.fnBloqueoUnico(); var titulo = data != undefined ? 'Detalles de Campaña o Descuento' : 'Agregar Campaña o Descuento'; //Show Modal var html = ''; MessageAlert.messagePopup(titulo, $("#modalCampanasDescuentoTemplate").html(), 20); $('#DIALOG-MESSAGE-ALERT').attr('style', 'display:block; z-index: 1040 !important'); $('#DIALOG-MESSAGE-ALERT #DIALOG-MESSAGE-ALERT-BUTTONS').hide(); // selectpicker: para que dibuje los combos try { //$('#cbProducto').attr({ 'data-live-search': 'true', "data-size": "8" }); //$('#cbProducto').selectpicker('render'); $('#cbProductor').attr({ 'data-live-search': 'true', "data-size": "8" }); $('#cbProductor').selectpicker('render'); $('#txActividad').attr({ 'data-live-search': 'true', "data-size": "8" }); $('#txActividad').selectpicker('render'); } catch (error) { oGen.logDesarrollo('Error iniciando selectpicker'); } //Combo Producto oCampDesc.fnCbProductoCarga(); $('#cbProducto').on('change', function (event) { oCampDesc.fnCbProductorCarga((JSON.parse($('#cbProducto').val())).RAMOPCOD); }); //Datepickers oGen.fnNewDatePicker('campDisc_effectivedate', { dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, yearRange: '0:+150', maxDate: '+240m +0w' }); //$('#campDisc_effectivedate').unbind("blur"); oGen.fnNewDatePicker('campDisc_expirydate', { dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, yearRange: '0:+150', maxDate: '+240m +0w' }); //$('#campDisc_expirydate').unbind("blur"); // Setea fechas por default $("#campDisc_effectivedate").datepicker("setDate", new Date(moment(oGlobal.sys_date).add('days', '1'))); //Tipo de campaña $("#campDisc_type").change(function () { if ($(this).val() == 'TECH') { $("#appConditions").show(); } else { $("#appConditions").hide(); } }); //Actividad $('#txActividad').parent().find("input[type=text]").on("keyup", function (e) { var _preFiltro; var _provincia; _preFiltro = $('#txActividad').parent().find("input[type=text]").val().substr(0, 3); if (_preFiltro.length === 3 && _preFiltro !== $('#txActividad').attr('preFiltro')) { $('#txActividad').attr('preFiltro', _preFiltro); oCampDesc.fnCbActividadCarga(_preFiltro); } }); //Buscar Actividad $('#btnBuscarxInd').on('click', function () { oCampDesc.fnGetBusqueda(function (call) { $('#divActividades').on('nodeSelected', function (event, data) { if (data.ACTIVIDAD_CODIGO != "") { var jsonData = '{"text":"' + data.text + '","ACTIVIDAD_CODIGO":"' + data.ACTIVIDAD_CODIGO + '"}'; oGen.fnComboCarga({ titulo: '', mensaje: 'Realizar una búsqueda...', idComponente: 'txActividad', valor: function (reg) { return JSON.stringify(); }, descripcion: 'text', value: data.ACTIVIDAD_CODIGO, records: [JSON.parse(jsonData)] }); tipoBusqueda = "ARBOL"; $('span.filter-option').html(data.text); $('#DIALOG-MESSAGE-CONFIRM').find('#DIALOG-MESSAGE-ALERT-OK').trigger('click'); } }); }); }); //Botones $("#btnCancelarCampDisc").click(function () { $("#DIALOG-MESSAGE-ALERT #DIALOG-MESSAGE-ALERT-BUTTONS #DIALOG-MESSAGE-ALERT-OK").trigger('click'); }); $("#btnGuardarCampDisc").click(function () { //Si todo va bien if (oCampDesc.fnValida()) { //Si es campaña y la duración de misma es mayor a 3 if ($("#campDisc_type").val() == 'TECH' && moment($('#campDisc_effectivedate').val(), 'DD/MM/YYYY').diff(moment($('#campDisc_expirydate').val(), 'DD/MM/YYYY'), 'months', true) > 3) { var msj = 'La duración de la campaña es mayor a 3 meses. ¿Está seguro que desea continuar?'; MessageAlert.confirmation('Mensaje de Advertencia', msj, function () { oCampDesc.fnGuardar(); }, 'Confirmar', 'Cancelar', function () { }); } else { oCampDesc.fnGuardar(); } } }); //Add Validations oCampDesc.fnAddValidaciones(); //Si tiene datos significa que es modificación if (data) { //Mensaje de modificacion de registro $("#msjModificacion").show(); //Toma la data actual oCampDesc.data_actual = data; $("#campDisc_code").val(data.CODE); $("#campDisc_description").val(data.DESCRIPTION); $("#campDisc_displaytext").val(data.DISPLAY_TEXT); $("#campDisc_discount").val(data.DISCOUNT); //Luego de cargar el combo setea el valor del producto oAjaxManager.appendFunctions({ processName: 'cbProducto', success: function () { $("#cbProducto option").each(function () { if ($(this).val() != '' && JSON.parse($(this).val()).RAMOPCOD == data.PRODUCT) { $("#cbProducto").val($(this).val()); } }); $("#cbProducto").trigger('change'); //Si es campaña agrega el valor del productor luego de cargar el combo if (data.TYPE == 'TECH') { oAjaxManager.appendFunctions({ processName: 'cbProductor', success: function () { //Propriedades var notFound = true; var setOption = function () { $("#cbProductor option").each(function () { if ($(this).val() != '' && JSON.parse($(this).val()).CODIGO == data.AGENT) { $("#cbProductor").val($(this).val()); notFound = false; } }); } //Selecciona el productor setOption(); //Si fue dado de alta por otro usuario, //el mismo se carga a medida en el listado de productores por primer vez if (notFound) { if (data.AGENT) { data.AGENTNOMBRE = data.AGENTNOMBRE.trim(); var valor = { RENOVACION: '', CODIGO: data.AGENT, ALTA: '', CLASE: data.AGENT_CLASE, DESCRIPCION: data.AGENT + '|' + data.AGENT_CLASE + '|' + data.AGENTNOMBRE, numeroRegistro: '', NOMBRE: data.AGENTNOMBRE }; //Agrega a medida el productor var opt = "'; $('#cbProductor').html($('#cbProductor').html() + opt); //Selecciona el productor agregado setOption(); } else { //Si no tiene productor se asegura que no haya un //productor seleccionado por defecto $("#cbProductor").val(''); } } $("#cbProductor").selectpicker('refresh'); }, fail: function () { oAjaxManager.error('error al cargar cbProductor'); } }); } }, fail: function () { oAjaxManager.error('error al cargar cbProducto'); } }); $("#campDisc_type").val(data.TYPE); //Si es Campaña if (data.TYPE == 'TECH') { $("#appConditions").show(); if (data.ANZSIC != undefined) { oCampDesc.fnCbActividadCarga(data.ANZSIC, true); } $("#campDisc_limit").val(data.LIMIT != 0 ? data.LIMIT : ''); if (data.TRANS_NB == 'S') { $("#campDisc_NB").prop('checked', true); } if (data.TRANS_RN == 'S') { $("#campDisc_RN").prop('checked', true); } } $("#campDisc_effectivedate").datepicker("setDate", new Date(moment(data.EFFECTIVE_DATE, 'YYYY-MM-DD'))); if (data.EXPIRY_DATE != undefined) { $("#campDisc_expirydate").datepicker("setDate", new Date(moment(data.EXPIRY_DATE, 'YYYY-MM-DD'))); } } else { //Resetea la data actual oCampDesc.data_actual = null; } oGen.fnBloqueoUnicoHide(); }; oCampDesc.fnCbActividadCarga = function (text, autoSeleccion) { autoSeleccion = autoSeleccion ? true : false; oGen.fnGetStore({ titulo: ' ', params: { prm_dataSource: 'ovQbe', prm_funcion: 'PAACTIVIDADES.getActividades', prm_actividad: text }, fnCallback: function (oResp) { oGen.fnComboCarga({ titulo: '', mensaje: 'Realizar una búsqueda...', idComponente: 'txActividad', valor: function (reg) { return JSON.stringify(reg); }, descripcion: 'TEXT', codigo: 'ACTIVIDAD_CODIGO', records: oResp.records, fnCallback: function (e) { if (autoSeleccion) { $("#txActividad option").each(function () { if ($(this).val() != '' && JSON.parse($(this).val()).ACTIVIDAD_CODIGO == data.text) { $("#txActividad").val($(this).val()); } }); } } }); //$('#txActividad').trigger('change'); } }); }; /** * Esta función carga la combo de productores, de acuerdo al producto * seleccionado */ oCampDesc.fnCbProductorCarga = function (cIdProducto) { oGen.fnComboLimpia('cbProductor'); oGen.fnComboCarga({ titulo: 'Productor', idComponente: 'cbProductor', params: { prm_dataSource: 'ovQbe', prm_funcion: 'ov.paConsultaMQ.productoresHabilitadosParaCot', prm_ramopcod: cIdProducto, prm_usuarcod: oGlobal.cUsuario, prm_cliensecas: oGlobal.productor ? oGlobal.productor.CLIENSEC : '', prm_nivelclas: oGlobal.productor ? oGlobal.productor.NIVEL : '' }, fnCallback: function (data) { console.log('cbProductor', data); }, valor: function (item) { return JSON.stringify(item); }, descripcion: function (item) { return item.CODIGO + ' | ' + item.CLASE + ' | ' + ((item.NOMBRE === undefined) ? '' : item.NOMBRE); } }); }; /** * Esta función carga la combo de producto */ oCampDesc.fnCbProductoCarga = function () { oGen.fnComboCarga({ titulo: 'Producto', idComponente: 'cbProducto', params: { prm_dataSource: 'ovQbe', prm_funcion: 'ov.paMenuQuote.obtenerProducto', prm_ciaascod: 1, prm_usuarcod: oGlobal.cUsuario, prm_canalHsbc: oGlobal.canales.CANALHSBC, prm_pymes: 'S' }, valor: function (row) { return JSON.stringify(row); }, descripcion: 'RAMOPDAB', fnCallback: function (msg) { // No se debloquea la pantalla hasta que se cargue la combo de // producto } }); }; /** * Esta función carga las actividades */ oCampDesc.fnGetBusqueda = function (callback) { var dataFiltrada = false; var agrupamiento = []; var myTree = ""; var recs = ""; oGen.fnGetStore({ params: { prm_dataSource: 'ovQbe', prm_funcion: 'ov.PAACTIVIDADES.getActividadesJson' }, fnCallback: function (oResp) { MessageAlert.messagePopupFunctionCall('Activdad', '
', function () { }); $("#DIALOG-MESSAGE-ALERT-BUTTONS").hide(); console.log(oResp); var recs = oResp.RETURN; $('#divActividades').treeview({ data: recs }); callback(); } }); }; //Guarda los datos modificados oCampDesc.fnGuardar = function () { var params = { prm_dataSource: 'ovQbe', prm_funcion: 'paCampaniaDescuento.altaModificacion', prm_code: $('#campDisc_code').val(), prm_description: encodeURIComponent($('#campDisc_description').val()), prm_display_text: encodeURIComponent($('#campDisc_displaytext').val()), prm_discount: $('#campDisc_discount').val(), prm_product: (JSON.parse($('#cbProducto').val())).RAMOPCOD, prm_type: $('#campDisc_type').val(), //Campos referentes a campaña prm_agent: '', prm_anzsic: '', prm_limit: '', prm_effective_date: '', //oCampDesc.data_actual.EFFECTIVE_DATE, prm_expiry_date: '', //oCampDesc.data_actual.EXPIRY_DATE, prm_trans_nb: 'N', prm_trans_rn: 'N' }; //Si es campaña se agrega los demás parametros if ($("#campDisc_type").val() == 'TECH') { try { params.prm_agent = JSON.parse($('#cbProductor').val()).CODIGO; params.prm_agent_clase = JSON.parse($('#cbProductor').val()).CLASE; } catch (error) { params.prm_agent = ''; params.prm_agent_clase = ''; } try { params.prm_anzsic = JSON.parse($('#txActividad').val()).ACTIVIDAD_CODIGO; } catch (error) { params.prm_anzsic = ''; } params.prm_limit = $('#campDisc_limit').val(); params.prm_effective_date = $('#campDisc_effectivedate').val(); params.prm_expiry_date = $('#campDisc_expirydate').val(); params.prm_trans_nb = $('#campDisc_NB')[0].checked ? 'S' : 'N'; params.prm_trans_rn = $('#campDisc_RN')[0].checked ? 'S' : 'N'; } oGen.fnGetStore({ titulo: 'Guardar Campaña y Descuento', params: params, fnCallback: function (oResp) { if (oResp.PRM_CODERROR !== undefined && oResp.PRM_CODERROR == 0) { oCampDesc.fnSearch(); $("#DIALOG-MESSAGE-ALERT #DIALOG-MESSAGE-ALERT-BUTTONS #DIALOG-MESSAGE-ALERT-OK").trigger('click'); } else { var msj = ''; if (oResp.PRM_MSGERROR !== undefined) { msj = oResp.PRM_MSGERROR; } else if (oResp.message !== undefined) { msj = oResp.message; } else { msj = 'Hubo un error inesperado, por favor intente más tarde.'; } MessageAlert.messagePopup('Error', '

' + msj + '

', 20); $('#DIALOG-MESSAGE-ALERT #DIALOG-MESSAGE-ALERT-BUTTONS').show(); } } }); }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Validación //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // *** ******** *** // // *** fnValida *** // // *** ******** *** // oCampDesc.fnValida = function () { "use strict"; var lRutNom = gJSNom + ".fnValida"; var hayErrores = false; //Descripción*: Por favor, ingrese la Descripción de la Campaña o Descuento. //Descripción*: No se admiten los caracteres: xxx, xxx, xxx. if ($("#campDisc_description").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_description', mensaje: 'Por favor, ingrese la Descripción de la Campaña o Descuento.' }); hayErrores = true; } else if (oGen.validarTexto({ incluirCaracteres: ["%25"], texto: $("#campDisc_description").val().replaceAll("%", "%25"), error: function (caracteresInvalidos) { oGen.fnShowError({ idComponente: 'campDisc_description', mensaje: 'No se admiten los caracteres: ' + caracteresInvalidos.join(', ') + '.' }); hayErrores = true; } }) == false) { /* Nothing... */ } else { oGen.fnHideError('campDisc_description'); } //Porcentaje de Descuento*: Por favor, ingrese el Porcentaje de Descuento de la Campaña o Descuento. //Porcentaje de Descuento*: Ingrese valor de -999 a 999 sólo var campDisc_discount_value = $("#campDisc_discount").val(); if (campDisc_discount_value == '') { oGen.fnShowError({ idComponente: 'campDisc_discount', mensaje: 'Por favor, ingrese el Porcentaje de Descuento de la Campaña o Descuento.' }); hayErrores = true; } else if (isNaN(campDisc_discount_value) || Math.abs(campDisc_discount_value) > 999) { oGen.fnShowError({ idComponente: 'campDisc_discount', mensaje: 'Ingrese valor de -999 a 999 sólo' }); hayErrores = true; } else { oGen.fnHideError('campDisc_discount'); } //Texto para Productor: No se admiten los caracteres: xxx, xxx, xxx. if (oGen.validarTexto({ incluirCaracteres: ["%25"], texto: $("#campDisc_displaytext").val().replaceAll("%", "%25"), error: function (caracteresInvalidos) { oGen.fnShowError({ idComponente: 'campDisc_displaytext', mensaje: 'No se admiten los caracteres: ' + caracteresInvalidos.join(', ') + '.' }); hayErrores = true; } }) == false) { /* Nothing... */ } else { oGen.fnHideError('campDisc_displaytext'); } //Producto*: Por favor, seleccione el Producto de la Campaña o Descuento. if ($("#cbProducto").val() == '') { oGen.fnShowError({ idComponente: 'cbProducto', mensaje: 'Por favor, seleccione el Producto de la Campaña o Descuento.' }); hayErrores = true; } else { oGen.fnHideError('cbProducto'); } //Tipo*: Por favor, seleccione el Tipo(Campaña o Descuento). if ($("#campDisc_type").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_type', mensaje: 'Por favor, seleccione el Tipo(Campaña o Descuento).' }); hayErrores = true; } else { oGen.fnHideError('campDisc_type'); } //Si es campaña debe validar los demás campos if ($("#campDisc_type").val() == 'TECH') { //Cantidad Límite: Sólo valores numéricos. if ($("#campDisc_limit").val() != '' && isNaN($("#campDisc_limit").val())) { oGen.fnShowError({ idComponente: 'campDisc_limit', mensaje: 'Sólo valores numéricos.' }); hayErrores = true; } else { oGen.fnHideError('campDisc_limit'); } //Fecha de Inicio*: Por favor, ingrese la Fecha de Inicio de la Campaña. if ($("#campDisc_effectivedate").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_effectivedate', mensaje: 'Por favor, ingrese la Fecha de Inicio de la Campaña.' }); hayErrores = true; } else { oGen.fnHideError('campDisc_effectivedate'); } //Fecha de Fin*: Por favor, ingrese la Fecha de Fin de la Campaña. if ($("#campDisc_expirydate").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_expirydate', mensaje: 'Por favor, ingrese la Fecha de Fin de la Campaña.' }); hayErrores = true; } else { oGen.fnHideError('campDisc_expirydate'); } //Transacciones*: Por favor, seleccione las transacciones a las que se debe aplicar la Campaña. if (!$("#campDisc_NB")[0].checked && !$("#campDisc_RN")[0].checked) { oGen.fnShowError({ idComponente: 'campDisc_RN', mensaje: 'Por favor, seleccione las transacciones a las que se debe aplicar la Campaña.' }); hayErrores = true; } else { oGen.fnHideError('campDisc_RN'); } } else { oGen.fnHideError('campDisc_limit'); oGen.fnHideError('campDisc_effectivedate'); oGen.fnHideError('campDisc_expirydate'); oGen.fnHideError('campDisc_RN'); } return !hayErrores; }; //fnValida //Agrega validaciones a los inputs del modal oCampDesc.fnAddValidaciones = function () { //Descripción*: Por favor, ingrese la Descripción de la Campaña o Descuento. //Descripción*: No se admiten los caracteres: xxx, xxx, xxx. $("#campDisc_description").blur(function () { if ($("#campDisc_description").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_description', mensaje: 'Por favor, ingrese la Descripción de la Campaña o Descuento.' }); } else if (oGen.validarTexto({ incluirCaracteres: ["%25"], texto: $("#campDisc_description").val().replaceAll("%", "%25"), error: function (caracteresInvalidos) { oGen.fnShowError({ idComponente: 'campDisc_description', mensaje: 'No se admiten los caracteres: ' + caracteresInvalidos.join(', ') + '.' }); hayErrores = true; } }) == false) { /* Nothing... */ } else { oGen.fnHideError('campDisc_description'); } }); //Texto para Productor*: No se admiten los caracteres: xxx, xxx, xxx. $("#campDisc_displaytext").change(function () { if (oGen.validarTexto({ incluirCaracteres: ["%25"], texto: $("#campDisc_displaytext").val().replaceAll("%", "%25"), error: function (caracteresInvalidos) { oGen.fnShowError({ idComponente: 'campDisc_displaytext', mensaje: 'No se admiten los caracteres: ' + caracteresInvalidos.join(', ') + '.' }); hayErrores = true; } }) == false) { /* Nothing... */ } else { oGen.fnHideError('campDisc_displaytext'); } }); //Porcentaje de Descuento*: Por favor, ingrese el Porcentaje de Descuento de la Campaña o Descuento. //Porcentaje de Descuento*: Ingrese valor de -999 a 999 sólo $("#campDisc_discount").blur(function () { var value = $("#campDisc_discount").val(); if (value == '') { oGen.fnShowError({ idComponente: 'campDisc_discount', mensaje: 'Por favor, ingrese el Porcentaje de Descuento de la Campaña o Descuento.' }); } else if (isNaN(value) || Math.abs(value) > 999) { oGen.fnShowError({ idComponente: 'campDisc_discount', mensaje: 'Ingrese valor de -999 a 999 sólo' }); } else { oGen.fnHideError('campDisc_discount'); } }); //Producto*: Por favor, seleccione el Producto de la Campaña o Descuento. $("#cbProducto").blur(function () { if ($("#cbProducto").val() == '') { oGen.fnShowError({ idComponente: 'cbProducto', mensaje: 'Por favor, seleccione el Producto de la Campaña o Descuento.' }); } else { oGen.fnHideError('cbProducto'); } }); //Tipo*: Por favor, seleccione el Tipo(Campaña o Descuento). $("#campDisc_type").blur(function () { if ($("#campDisc_type").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_type', mensaje: 'Por favor, seleccione el Tipo(Campaña o Descuento).' }); } else { oGen.fnHideError('campDisc_type'); } }); //Cantidad Límite: Sólo valores numéricos. $("#campDisc_limit").blur(function () { if ($("#campDisc_limit").val() != '' && isNaN($("#campDisc_limit").val())) { oGen.fnShowError({ idComponente: 'campDisc_limit', mensaje: 'Sólo valores numéricos.' }); } else { oGen.fnHideError('campDisc_limit'); } }); //Fecha de Inicio*: Por favor, ingrese la Fecha de Inicio de la Campaña. $("#campDisc_effectivedate").blur(function () { if ($("#campDisc_effectivedate").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_effectivedate', mensaje: 'Por favor, ingrese la Fecha de Inicio de la Campaña.' }); } else { oGen.fnHideError('campDisc_effectivedate'); } }); //Fecha de Fin*: Por favor, ingrese la Fecha de Fin de la Campaña. $("#campDisc_expirydate").blur(function () { if ($("#campDisc_expirydate").val() == '') { oGen.fnShowError({ idComponente: 'campDisc_expirydate', mensaje: 'Por favor, ingrese la Fecha de Fin de la Campaña.' }); } else { oGen.fnHideError('campDisc_expirydate'); } }); //Transacciones*: Por favor, seleccione las transacciones a las que se debe aplicar la Campaña. $("#campDisc_NB, #campDisc_RN").change(function () { if (!$("#campDisc_NB")[0].checked && !$("#campDisc_RN")[0].checked) { oGen.fnShowError({ idComponente: 'campDisc_RN', mensaje: 'Por favor, seleccione las transacciones a las que se debe aplicar la Campaña.' }); } else { oGen.fnHideError('campDisc_RN'); } }); }; /* ************************************************************************** */ // ************* // // *** ready *** // // ************* // $(document).ready(function () { "use strict"; //Inicializa form oGen.fnInicioForms(false); $("#btnAgregarCampana").hide(); setTimeout(function () { if (oGlobal.usuarioInterno()) { oCampDesc.fnSearch(); $("#btnAgregarCampana").show(); } else { //Si no es usuario interno redirecciono a la HOME MessageAlert.messagePopupFunctionCall("Campañas y descuentos", 'No tiene permisos para acceder a la opción seleccionada.', function (e) { oGen.fnAbandonaTransaccion({ confirmacion: false, toUrl: 'ovError' }); }); } }, 5000); //Botones $("#btnAgregarCampana").click(function (e) { //Abrir modal if (oGlobal.usuarioInterno()) { oCampDesc.fnShowModal(); } }); //$("#btnAgregarCampana").click }); //$(document).ready