Revonzy Mini Shell
// JavaScript Document
$(document).ready(function(){
$('#loading').hide();
//////////////////////////////////
// Add Sector form validation
////////////////////////////////////
$("#categoryform").validate({
rules:
{
langauge:
{
required: true,
},
category:
{
required:true,
},
subcategory:
{
required: true,
CheckGategory:true,
},
position:
{
required: true,
},
url_path:
{
required:true,
//url:true,
}
},
messages:
{
}
});// eof validation
/////////////////////////////////////
//Validate add method for Branch
/////////////////////////////////////
$.validator.addMethod('CheckGategory', function(val, element)
{
cate_name=$("#category").val();
sub_name=$("#subcategory").val();
id=$("#id").val();
$.ajax({
url:"subcategory_curd.php",
type: "POST",
data: {type:"validate",sub_name:sub_name,cate_name:cate_name,id:id},
async:false,
success:function(data){
// alert(data);
isSuccess=(data==1)?false:true;
}
});//eof ajax
return isSuccess ;
}, 'sub-category is already exists.');
//////////////////////////////////
// on click of submit button
//////////////////////////////////
$('#submit').click(function(){
flag=$("#categoryform").valid();
if (flag==true)
{
$('#submit').hide();
$('#loading').show();
var image='';
var varifyimage='';
if($('#fileupload').val().length>0)
{
image=$('#fileupload').prop('files')[0];
varifyimage=1;
}
var formdata = new FormData();
formdata.append('type', "addSubcategory");
formdata.append('subcategory', $("#subcategory").val());
formdata.append('category', $("#category").val());
formdata.append('hsubcategory', $("#hsubcategory").val());
formdata.append('url_path',$('#url_path').val());
formdata.append('varifyimage', varifyimage);
formdata.append('fileupload', image);
formdata.append('position', $("#position").val());
formdata.append('desc', $("#desc").val());
formdata.append('hdesc', $("#hdesc").val());
var x;
$.ajax({
type: "POST",
url: "subcategory_curd.php",
data:formdata,
async: false,
success: function(data){//alert(data);
x=data;
},
cache: false,
contentType: false,
processData: false
});//eof ajax
if(x==1)
{
$('#loading').hide();
$( "#dialog1" ).dialog({
dialogClass: "alert",
buttons: {
'Ok': function() {
window.location.replace("list.php");
}
}
});
}
else
{
$('#loading').hide();
$('#submit').show();
$( "#dialog2" ).dialog({
dialogClass: "alert",
buttons: {
'Ok': function() {
window.location.replace("index.php");
}
}
});
}
}// eof if condition
});
/////////////////////////////////
// on click of edit button
/////////////////////////////////
$('#update').click(function(){
flag=$("#categoryform").valid();
if (flag==true)
{
$('#update').hide();
$('#loading').show();
var image='';
var varifyimage='';
if($('#fileupload').val().length>0)
{
image=$('#fileupload').prop('files')[0];
varifyimage=1;
}
var formdata = new FormData();
formdata.append('type', "editCategory");
formdata.append('subcategory', $("#subcategory").val());
formdata.append('category', $("#category").val());
formdata.append('hsubcategory', $("#hsubcategory").val());
formdata.append('url_path',$('#url_path').val());
formdata.append('varifyimage', varifyimage);
formdata.append('fileupload', image);
formdata.append('oldfile', $('#oldfile').val());
formdata.append('position', $("#position").val());
formdata.append('desc', $("#desc").val());
formdata.append('hdesc', $("#hdesc").val());
formdata.append('id', $("#id").val());
var x;
$.ajax({
type: "POST",
url: "subcategory_curd.php",
data:formdata,
async: false,
success: function(data){//alert(data);
x=data;
},
cache: false,
contentType: false,
processData: false
});//eof ajax
if(x==1)
{
$('#loading').hide();
$( "#dialog" ).dialog({
dialogClass: "alert",
buttons: {
'Ok': function() {
window.location.replace("list.php");
}
}
});
}else
{
$('#update').show();
alert('Something is wrong your file is not submitted..');
}
}// eof if condition
});
//////////////////////////////////
// on click of delete button
//////////////////////////////////
$(document).on('click', '.delete', function() {
var didConfirm = confirm("Are you sure?");
if (didConfirm == true) {
var id=$(this).attr("id");
var x;
$.ajax({
url:"subcategory_curd.php",
type: "POST",
data: {type:"delete",id:id},
async:false,
success: function(data){//alert(data);
}
});
if(x==1)
{
$('#loading').hide();
$( "#deletemsg" ).dialog({
dialogClass: "alert",
buttons: {
'Ok': function() {
window.location.replace("list.php");
}
}
});
}
location.reload();
}
});
//OnChange Lange GEt Sub Category
$(document).on('change','#langauge',function()
{
var id=$(this).val();
var x;
$.ajax({
url:"subcategory_curd.php",
type: "POST",
data: {type:"getCategory",id:id},
async:false,
success: function(data){
$('#category').html(data);
//alert(data);
}
});
})
});
//Search Filter Write HEre
$(document).on('click','#search',function()
{
var x;
$.ajax({
url:"filter_report.php",
type: "POST",
data: {type:"searchList",langauge:$('#langauge').val(),category:$('#category').val(),subcategory:$('#subcategory').val()},
async:false,
success: function(data){
$('#add').html(data);
//alert(data);
}
});
});
$(document).ready(function() {
$(".number").keydown(function (e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A, Command+A
(e.keyCode == 65 && ( e.ctrlKey === true || e.metaKey === true ) ) ||
// Allow: home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40)) {
// let it happen, don't do anything
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
});
EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com