//////////////////UP HERE//////////////////////// //////////////click///////////////////////////// $('.widget-content .message').on('click', function () { swal({ title: 'Saved succesfully', padding: '2em' }) }) $('.widget-content .success').on('click', function () { swal({ title: 'Good job!', text: "", type: 'success', padding: '2em' }) }) //////////////End click///////////////////////////// ////////////////////////////////////////////////// $(document).ready(function($){ $('#InventoryFormID').submit(function(e){ e.preventDefault(); $("#error").hide(); $('.progressinv').show(1000); var name = $("input#name").val(); if(name == ""){ $("#error").fadeIn().text("Name required."); $("input#name").focus(); return false; } $.ajax({ type:"POST", url: "sub_files/forms.php", data: new FormData( this ), processData: false, contentType: false, success: function(response){ var jsonData = JSON.parse(response); swal({ title: jsonData.msg_head, text: jsonData.msg_body, type: jsonData.msg_type, padding: '2em' }) document.getElementById("InventoryFormID").reset(); if(jsonData.msg_type!=''){ $('.progressinv').hide(1000); } return false; } }); }); return false; }); ////////////////////////////////////////////////// $('.widget-content .warning.del_inv').on('click', function () { var invid = $(this).attr("data-id"); swal({ title: 'Are you sure?', text: "You won't be able to revert this!", type: 'warning', showCancelButton: true, confirmButtonText: 'Delete', padding: '2em' }).then(function(result) { if (result.value) { ////////////////////location.href = 'my_profile.php';/////////////// if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // document.getElementById("load_div").innerHTML = xmlhttp.responseText; $('#'+invid).hide(1000); swal( 'Deleted!', 'This Inventory with the ID of '+invid+' has been deleted.', 'success' ) } } // getuser.php is seprate php file. q is parameter xmlhttp.open("GET","sub_files/forms.php?delete_inv="+invid,true); xmlhttp.send(); } }) }) ///////////////////////////////////////////////// ////////////////////////////////////////////////// $(document).ready(function($){ $('#categoryid').submit(function(e){ e.preventDefault(); $('.progressinv').show(1000); $.ajax({ type:"POST", url: "sub_files/forms.php", data: $(this).serialize(), success: function(response){ var jsonData = JSON.parse(response); swal({ title: jsonData.msg_head, text: jsonData.msg_body, type: jsonData.msg_type, padding: '2em' }) document.getElementById("categoryid").reset(); if(jsonData.msg_type!=''){ $('.progressinv').hide(1000); } return false; } }); }); return false; }); ////////////////////////////////////////////////// ///////////////////////del cat/////////////////////////// $('.widget-content .warning.del_cat').on('click', function () { var invid = $(this).attr("data-id"); swal({ title: 'Are you sure?', text: "You won't be able to revert this!", type: 'warning', showCancelButton: true, confirmButtonText: 'Delete', padding: '2em' }).then(function(result) { if (result.value) { ////////////////////location.href = 'my_profile.php';/////////////// if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // document.getElementById("load_div").innerHTML = xmlhttp.responseText; $('#'+invid).hide(1000); swal( 'Deleted!', 'This Category with the ID of '+invid+' has been deleted.', 'success' ) } } // getuser.php is seprate php file. q is parameter xmlhttp.open("GET","sub_files/forms.php?delete_cat="+invid,true); xmlhttp.send(); } }) }) ///////////////////////////////////////////////// ///////////////////////edit_cat/////////////////////////// $('.widget-content .warning.edit_cat').on('click', function () { var catid = $(this).attr("data-id"); var catname = $(this).attr("data-catname"); var setnewvalue = document.getElementById("name"+catid); swal.mixin({ input: 'text', confirmButtonText: 'Next →', showCancelButton: true, progressSteps: ['1'], padding: '2em', }).queue([ { title: 'Category Name', text: 'Change Category from "'+catname+'"', } ]).then(function(result) { if (result.value) { var datatoupdate=JSON.stringify(result.value); if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("set"+catid).innerHTML = result.value; swal({ title: 'All done!', padding: '2em', html: 'Category Name:
' +
JSON.stringify(result.value) +
'',
confirmButtonText: 'Lovely!'
})
}
}
xmlhttp.open("GET","sub_files/forms.php?edit_cat=" + datatoupdate + "+&cat_id=" + catid,true);
xmlhttp.send();
}
})
})
/////////////////////////////////////////////////
function check(){
var errormsg = document.getElementById("uploadMsg");
var x = document.getElementById("name");
x.value = x.value.toUpperCase();
errormsg.innerHTML = x.value;
}
///////////////////////edit_inv///////////////////////////
$('.widget-content .warning.edit_inv').on('click', function () {
var invid = $(this).attr("data-id");
var invname = $(this).attr("data-invname");
swal({
title: 'Edit Inventory',
type: 'question',
html:
'