1048576 || f.size > 1048576){
alert('File size too large...');
$(this).val('');
}
});
// Check Profile image Size
$('.file-large').change(function(){
var f=this.files[0];
var fileName = f.name;
var ext = fileName.split('.').pop();
var allowedExt = ["jpg", "JPG", "jpeg", "JPEG","png","PNG","doc","docx","pdf","PDF","xlsx"];
if(allowedExt.indexOf(ext) < 0){
alert('Invalid file format...');
$(this).val('');
}
if(f.fileSize > 5242880 || f.size > 5242880){
alert('File size too large...');
$(this).val('');
}
});
});
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if(charCode == 46){
return true;
}else{
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
}
// $(document).ready(function(){
// var session_time_limit = '';
// var user_id = '';
//session_time_limit = '';
// user_id = '';
// if(!session_time_limit){
// session_time_limit = 100000;
// }
//alert(session_time_limit);
// if(user_id !=''){
// setTimeout(function(){
// $.ajax({
// type: 'POST',
// dataType:'json',
// url: 'https://ver2.sivaads.in/index.php/login/ajaxlogout',
// success: function(json) {
// if(json == 'true'){
// alert('Session timeout....');
//window.location = 'dashboard';
// location.reload();
// }
// }
// });
// },session_time_limit );
// }
// });
$('.js-open-modal').on('click', function () {
const id = $(this).attr('id');
const id1 = 'popup_' + id;
$('.trriger_popup').attr('id', id1);
const labels = {
data_source: 'Add New Data Source',
business_category: 'Add New Business Category',
salutaion: 'Add New Salutaion',
category: 'Add New Category',
sub_category: 'Add New Sub Category',
area: 'Add New Area',
designation: 'Add New Designation',
classifieds_heading: 'Add Classifieds Heading',
advt_issue_type: 'Add Advt Issue / Malar / Others',
special_discount_category: 'Add Discount Category',
notice_type: 'Add Notice Type'
};
const label = labels[id] || 'Add New Item'; // default label if id not found
$('#table_name').val(id);
$('#popup h4').text(label);
$('#popup').modal('show');
$('#name').focus();
});
$(document).on( "click","#insert", function() {
var name = $('#name').val();
var table = $('#table_name').val();
var parent = '';
var parent = $('#select_category').val();
if(name == ''){
alert('Please enter name');
}else{
if(table == 'sub_category' && !parent){
alert('Please select parent category');
}else{
$.ajax({
type: 'POST',
data: { table: table, name: name, parent: parent },
dataType: 'json',
url: 'https://ver2.sivaads.in/ajax/addFieldItem',
success: function(json) {
// console.log(json);
if(json == 'exist'){
alert('Area already exist');
}else{
var html = '';
$( json).each(function( index, value ) {
//alert(value['area_name']);
if(value['name'] == name){
html +='
';
}else{
html +='
';
}
});
if(table == 'designation'){
$('#email_'+table).html(html);
designationNew = html;
}
if(table == 'special_notice_type'){
$("#select_notice_type").html(html);
}
$('#select_'+table).html(html);
$('.success_msg').html('Successfully Added').fadeIn('slow');
clearModalPopup();
$("#popup").modal('hide');
}
},
error: function(xhr, status, error){
console.error('AJAX Error:', status, error);
}
});
}
}
});
$('#name').keypress(function (e) {
var key = e.which;
if(key == 13) // the enter key code
{
$('#insert').click();
return false;
}
});
$('.form-select').each(function(){
var val = $(this).attr('value') || 0;
$(this).val(val);
});