$base_path = dirname(dirname(dirname(__FILE__)));
require_once $base_path . "/redcap_connect.php";
require_once $base_path . '/plugins/includes/functions.php';
require_once APP_PATH_DOCROOT . '/Config/init_project.php';
require_once APP_PATH_DOCROOT . '/ProjectGeneral/header.php';
/**
 * restricted use
 */
$allowed_pids = array('26');
REDCap::allowProjects($allowed_pids);
$rows_deleted = 0;
/**
 * project metadata
 */
$project = new Project();
$my_branching_logic = new BranchingLogic();
$baseline_event_id = $project->firstEventId;
$fields_result = db_query("SELECT field_name, element_label FROM redcap_metadata WHERE project_id = '$project_id' AND element_type IN ('text', 'notes', 'autocomplete') AND field_name NOT LIKE '%\_complete' ORDER BY field_order ASC");
?>
	<div class="red"><h1>WARNING!!!</h1>

		<h2 class="red">This plugin will destroy data! Do not use unless you know what you're doing!!</h2>
		<h3 class="red">IF YOU HAVEN'T MADE A BACKUP, DO IT NOW.</h3>
		<p>All actions taken by this plugin are logged. You've been warned.</p></div>
	<h3>DELETE hidden data from a selected variable</h3>
	<h4>Select the source field containing the data to be DELETED if hidden</h4>
	<form action="<?php echo $_SERVER['PHP_SELF'] . '?pid=' . $project_id; ?> " method="post">
		<div class="data" style='max-width:700px;'>
			<select class="x-form-text x-form-field"
			        name="field_name"
			        style="height: 22px; padding-right: 0;"
require_once $base_path . "/redcap_connect.php";
require_once $base_path . '/plugins/includes/functions.php';
require_once APP_PATH_DOCROOT . '/Config/init_project.php';
require_once APP_PATH_DOCROOT . '/ProjectGeneral/header.php';
/**
 * restricted use
 */
$allowed_pids = array('26');
REDCap::allowProjects($allowed_pids);
/**
 * project metadata
 */
global $Proj;
$first_event_id = $Proj->firstEventId;
$plugin_title = "Reset SVR DATA PENDING flag when hidden by branching logic";
$my_branching_logic = new BranchingLogic();
/**
 * plugin title
 */
echo "<h3>$plugin_title</h3>";
/**
 * MAIN
 */
if ($debug) {
	$timer['main_start'] = microtime(true);
}
$fields = array('dis_suppds_funcmprsn', 'hcv_suppfa_svr12dt', 'hcv_suppfa_svr24dt', 'hcv_suppfa_fuelgbl');
$data = REDCap::getData('array', $subjects, $fields, $first_event_id);
foreach ($data AS $subject_id => $subject) {
	/**
	 * MAIN EVENT LOOP
$base_path = dirname(dirname(dirname(__FILE__)));
require_once $base_path . "/redcap_connect.php";
require_once $base_path . '/plugins/includes/functions.php';
require_once APP_PATH_DOCROOT . '/ProjectGeneral/header.php';
require_once APP_PATH_DOCROOT . '/DataExport/functions.php';
/**
 * restricted use
 */
$allowed_pids = array('26');
REDCap::allowProjects($allowed_pids);
global $Proj;
Kint::enabled($debug);
/**
 * project metadata
 */
$my_branching_logic = new BranchingLogic();
$baseline_event_id = $Proj->firstEventId;
$fields_result = db_query("SELECT field_name, element_label, element_type FROM redcap_metadata WHERE project_id = '$project_id' AND element_type IN ('radio', 'sql', 'select') ORDER BY field_order ASC");
?>
	<div class="red"><h1>WARNING!!!</h1>

		<h2>This plugin will destroy data! Do not use unless you know what you're doing!!</h2>

		<p>All actions taken by this plugin are logged. You've been warned!</p></div>
	<h3>Set default values</h3>
	<p>This will set a selected default value for all instances of a radio button, sql or select field (including per-form Complete fields) in all
		events in the project where the field is</p> <ul><li>not hidden by branching logic</li> <li>optionally where the form is set to Complete</li></ul> <p>This is useful when initializing a new
		variable. It can also be used where some data has already been saved to the field. It will not overwrite
		existing values.</p>
	<h4>Select the field whose value you wish to set</h4>
	<form id="field_val_select" action="<?php echo $_SERVER['PHP_SELF'] . '?pid=' . $project_id; ?> " method="post">