/***********************ADD**************************/
function user_screen_add(form_name,sub_screen,edit,action)
{ 
	jQuery.ajax({
		type: "POST",
	    url:"user_screen_db.php",
		data:"form_name="+form_name+"&sub_screen="+sub_screen+"&edit="+edit+"&action="+action,
		success: function(msg){jQuery("#user_screens_div").html(msg);
		//alert(msg);
		window.close();
		window.opener.location.reload(true);
		}
		});
   }
/****************Delete********************************/
// function user_sub_screen_delete(screen_id,sub_screen)
// {
// 	if(confirm('Are You Sure! You Want To Delete?'))
// 	{
// 		jQuery.ajax({
// 		type: "POST",
// 	    url:"master_entry/user_screen/user_screen_db.php",
// 		data: "screen_id="+screen_id+"&sub_screen="+sub_screen+"&action=del_screen_sub",
// 		success: function(msg){jQuery("#user_screens_div").html(msg);
// 		alert("Deleted Successfully");
// 		window.location.reload(true);
// 	}
// 	});
//     }
// }
function user_sub_screen_delete(screen_id, sub_screen) {
    if (!confirm('Are you sure you want to delete?')) return;

    const dataToSend = $.param({
        screen_id: screen_id,
        sub_screen: sub_screen,
        action: 'del_screen_sub'
    });

    console.log("AJAX URL: master_entry/user_screen/user_screen_db.php");
    console.log("AJAX Data: ", dataToSend);

    $.ajax({
        type: "POST",
        url: "master_entry/user_screen/user_screen_db.php",
        data: dataToSend,
        success: function(response) {
            console.log("Server Response:", response);
            $("#user_screens_div").html(response);
            // alert("Deleted Successfully");
            window.location.reload(true);
        },
        error: function(xhr, status, error) {
            console.error("Deletion failed:", error);
            alert("An error occurred while deleting the sub screen.");
        }
    });
}




