function gcb_submenu()
{
    $msg = "";
    if (isset($_POST["gcb_delete"])) {
        if (isset($_POST["gcb_del"]) && is_array($_POST["gcb_del"])) {
            foreach ($_POST["gcb_del"] as $bd) {
                gcb::delete_entry(intval($bd));
            }
            //refresh the map
            gcb::refresh_map();
            $msg = "Entry deleted.";
        }
    }
    if (isset($_POST["gcb_unin"])) {
        if (isset($_POST["ch_unin"])) {
            update_option("gcb_complete_uninstall", "yes");
        } else {
            update_option("gcb_complete_uninstall", "no");
        }
    }
    if (isset($_POST["gcb_import"])) {
        //importing files
        $msg = gcb_import();
    }
    if (isset($_POST["gcb_save"])) {
        //saving files
        $msg = gcb_saverecord();
    }
    if (isset($_POST["gcb_updateshortcode"])) {
        //saving files
        $msg = gcb_saverecord();
        // **** Set update flags
        $udr = "update";
        $udid = $_POST["update_it"];
    }
    echo gcb::main_page($msg, $udr, $udid);
}
function gcb_submenu()
{
    //we do not use backup popups, not yet at least
    /*
      
        //do not show or process anything if prompt is showing
        if(defined('PROMPT_SHOWING')) {
          if(isset($_GET['prompt_v2'])) {
            //we have been prompted, but asked to continue without backup
            update_option('gcb_update_prompt_v2',1);
            //re-run update
            gcb_check_update();
            
          } elseif(isset($_GET['prompt_v2_download'])) {
          //we have been prompted, and now downloading the backup     
           echo gcb::show_backup_download(); 
           return; 
          } else {
            echo gcb::prompt_table_deletion();
            return;
          }
        }*/
    $msg = "";
    if (isset($_POST["gcb_delete"])) {
        if (isset($_POST["gcb_del"]) && is_array($_POST["gcb_del"])) {
            foreach ($_POST["gcb_del"] as $bd) {
                gcb::delete_entry(intval($bd));
            }
            //refresh the map
            gcb::refresh_map();
            $msg = "Deleted!";
        }
    }
    if (isset($_POST["gcb_unin"])) {
        if (isset($_POST["ch_unin"])) {
            update_option("gcb_complete_uninstall", "yes");
        } else {
            update_option("gcb_complete_uninstall", "no");
        }
    }
    if (isset($_POST["gcb_import"])) {
        //importing files
        $msg = gcb_import();
    }
    if (isset($_POST["gcb_save"])) {
        $name = $_POST["gcb_name"];
        $value = htmlspecialchars($_POST['gcbvalue']);
        $entry_data = array("name" => $name, "description" => htmlspecialchars($_POST['gcb_description']), "value" => $value, "custom_id" => htmlspecialchars(sanitize_title_with_dashes($_POST['gcb_custom_id'])), "type" => htmlspecialchars($_POST['gcb_type']));
        if (strlen($name) && strlen($value)) {
            if (isset($_POST["update_it"])) {
                gcb::update_entry($entry_data, intval($_POST["update_it"]));
                $msg = "Entry updated!";
            } else {
                gcb::add_entry($entry_data);
                $msg = "Entry inserted!";
            }
        } else {
            $msg = "Name and Content are mandatory!";
        }
    }
    echo gcb::main_page($msg);
}