<?php include('../config/setup.php'); ?>
<?php 
session_start();
if($_SERVER['REQUEST_METHOD'] == 'POST'){
    
    $action = $_POST['action'];

// package_master
    
    // package_master update query starts
    if($action == 'comm_add'){
        $type = $_POST['type'];
        $value = $_POST['value'];

        $sql = "INSERT INTO commission_master(type, value, status) VALUES('$type', '$value', '1')" ;
        if($config->query($sql) === TRUE){
            $_SESSION['status'] = "Added Successfully";
		    $_SESSION['alert'] = "success";
		    header('Location:commission-master.php');
        } else {
            $_SESSION['status'] = "Failed";
		    $_SESSION['alert'] = "error";
		    header('Location:commission-master.php');
        }
    }
    // package_master update query ends
    // package_master update query starts
    if($action == 'comm_edit'){
        $id = $_POST['id'];
        $type = $_POST['type'];
        $value = $_POST['value'];
        $status = $_POST['status'];
        
        $sql = "UPDATE commission_master SET type = '$type', value = '$value', status = '$status' WHERE id = '$id' " ;
        if($config->query($sql) === TRUE){
            $_SESSION['status'] = "Updated Successfully";
		    $_SESSION['alert'] = "success";
		    header('Location:commission-master.php');
        } else {
            $_SESSION['status'] = "Update Failed";
		    $_SESSION['alert'] = "error";
		    header('Location:commission-master.php');
        }
    }
    // package_master update query ends
    
    // package_master delete query starts
    if($action == 'comm_del'){
        $id = $_POST['id'];
        
        $sql = "DELETE FROM commission_master WHERE id = '$id' " ;
        if($config->query($sql) === TRUE){
            $_SESSION['status'] = "Deleted Successfully";
		    $_SESSION['alert'] = "success";
		    header('Location:commission-master.php');
        } else {
            $_SESSION['status'] = "Delete Failed";
		    $_SESSION['alert'] = "error";
		    header('Location:commission-master.php');
        }
    }
    // package_master delete query ends

}


?>