*   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Bickerdike_id);
$start = $_POST['start'];
$end = $_POST['end'];
$start_sqlsafe = mysqli_real_escape_string($cnnBickerdike, $start);
$end_sqlsafe = mysqli_real_escape_string($cnnBickerdike, $end);
?>
<!--
Gets surveys within the date range specified for all types of surveys.
Returns a table of average responses for each question.
-->
<table class="all_projects">
    <tr>
        <th></th>
        <th colspan="3">Average Responses</th> <!-- would it make sense to do median/mode? -->
    </tr>
    <?php 
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Bickerdike_id, $AdminAccess);
//need to first take care of any possible foreign key constraints:
//activities_users, participant survey responses, program dates users, programs users, user health data
//
//Then finally delete the user him/herself.  This is probably going to be phased out once the merge
//tool is in use.
//
include "../include/dbconnopen.php";
$user_id_sqlsafe = mysqli_real_escape_string($cnnBickerdike, $_POST['user_id']);
$delete_activities_query_sqlsafe = "DELETE FROM Activities_Users WHERE User_ID='" . $user_id_sqlsafe . "'";
$delete_surveys_query_sqlsafe = "DELETE FROM Participant_Survey_Responses WHERE User_ID='" . $user_id_sqlsafe . "'";
$delete_attendance_query_sqlsafe = "DELETE FROM Program_Dates_Users WHERE User_ID='" . $user_id_sqlsafe . "'";
$delete_programs_query_sqlsafe = "DELETE FROM Programs_Users WHERE User_ID='" . $user_id_sqlsafe . "'";
$delete_health_query_sqlsafe = "DELETE FROM User_Health_Data WHERE User_ID='" . $user_id_sqlsafe . "'";
$delete_user_query_sqlsafe = "DELETE FROM Users WHERE User_ID='" . $user_id_sqlsafe . "'";
mysqli_query($cnnBickerdike, $delete_activities_query_sqlsafe);
     mysqli_query($cnnEnlace, $delete_participant);
     include "../include/dbconnclose.php";
     //delete participant from future expectations
     $delete_participant = "DELETE FROM Participants_Future_Expectations WHERE Participant_ID='" . $participant_id_sqlsafe . "'";
     echo $delete_participant;
     include "../include/dbconnopen.php";
     mysqli_query($cnnEnlace, $delete_participant);
     include "../include/dbconnclose.php";
     //delete participant from referrals
     $delete_participant = "DELETE FROM Referrals WHERE Participant_ID='" . $participant_id_sqlsafe . "'";
     echo $delete_participant;
     include "../include/dbconnopen.php";
     mysqli_query($cnnEnlace, $delete_participant);
     include "../include/dbconnclose.php";
 } elseif ($_POST['action'] == 'delete_participant_from_program') {
     user_enforce_has_access($Enlace_id, $AdminAccess);
     date_default_timezone_set('America/Chicago');
     include "../include/dbconnopen.php";
     $link_id_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['link_id']);
     //delete participant from program
     $delete_participant_from_program = "DELETE FROM Participants_Programs WHERE Participant_Program_ID='" . $link_id_sqlsafe . "'";
     echo $delete_participant_from_program;
     mysqli_query($cnnEnlace, $delete_participant_from_program);
     include "../include/dbconnclose.php";
 } elseif ($_POST['action'] == 'drop') {
     date_default_timezone_set('America/Chicago');
     include "../include/dbconnopen.php";
     $link_id_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['link_id']);
     $drop_from_program = "UPDATE Participants_Programs SET Date_Dropped='" . date('Y-m-d') . "' WHERE Participant_Program_ID='" . $link_id_sqlsafe . "'";
     echo $drop_from_program;
     mysqli_query($cnnEnlace, $drop_from_program);
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include_once $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($TRP_id);
?>
      <link href="/styles/styles.css" rel="stylesheet" type="text/css" />
        <link href="/include/jquery/1.9.1/css/redmond/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" />
        <script src="/include/jquery/1.9.1/js/jquery-1.8.2.js" type="text/javascript"></script>
        <script src="/include/jquery/1.9.1/development-bundle/ui/jquery.ui.core.js" type="text/javascript"></script>
        <script src="/include/jquery/1.9.1/development-bundle/ui/jquery.ui.widget.js" type="text/javascript"></script>
        <script src="/include/jquery/1.9.1/development-bundle/ui/jquery.ui.datepicker.js" type="text/javascript"></script>
       
        
        <!-- adds to a calendar to text boxes for consistent date format -->
		<script>
            //on search events
	$(function() {
                $(".hasDatepickers").datepicker({dateFormat: "mm/dd/yy",
                changeYear: true,
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include_once $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($LSNA_id);
include "../../header.php";
include "../header.php";
include "../include/datepicker.php";
//filter by dates and funder(s) (probably by checkbox?)
// show table of activities in funding period
?>

<h3>Search Events by Funder</h3>
    <table class="all_projects">
<form method = "post"  action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" >
<tr>
<th class="all_projects">Funder:</th><td>
<?php

/*
 *   TTM is a web application to manage data collected by community organizations.
 *   Copyright (C) 2014, 2015  Local Initiatives Support Corporation (lisc.org)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($LSNA_id, $DataEntryAccess);
/*after a participant already exists, adding them to another institution (or vice versa) */
include "../include/dbconnopen.php";
$inst_sqlsafe = mysqli_real_escape_string($cnnLSNA, $_POST['inst']);
$parti_sqlsafe = mysqli_real_escape_string($cnnLSNA, $_POST['parti']);
$link_query = "INSERT INTO Institutions_Participants (Institution_ID, Participant_ID)\r\n    VALUES('" . $inst_sqlsafe . "', '" . $parti_sqlsafe . "')";
mysqli_query($cnnLSNA, $link_query);
include "../include/dbconnclose.php";
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include_once $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($SWOP_id, $DataEntryAccess);
include "../../header.php";
include "../header.php";
include "reports_menu.php";
//include ($_SERVER['DOCUMENT_ROOT']."/include/block_group_finder.php");
?>

<!-- export information from the database.  Will change once Taryn gets back to me with the compound exports she needs: -->

<h2>Export All</h2>

<table class="all_projects">
    <tr>
        <td>
            <h4>Export Everything </h4>
            <table class="inner_table">
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($SWOP_id);
//I'm going to follow the same partial search mechanism that I've used before.  If a search term
//is chosen, then I'll use it for searching.  One thing I may have to change is allowing them to search for the
//null - that is, find people who /don't have/ a primary institution or something like that.
if ($_POST['inst'] != 0) {
    $institution_sqlsafe = " AND Institution_ID='" . mysqli_real_escape_string($cnnSWOP, $_POST['inst']) . "' AND Is_Primary=1 ";
    $join_inst_sqlsafe = " INNER JOIN Institutions_Participants ON Participants.Participant_ID=Institutions_Participants.Participant_ID ";
} else {
    $institution_sqlsafe = "";
    $join_inst_sqlsafe = "";
}
$join_inst_sqlsafe = " INNER JOIN Institutions_Participants ON Participants.Participant_ID=Institutions_Participants.Participant_ID ";
if ($_POST['type'] != 0) {
    $type_sqlsafe = " AND member_type.Member_Type='" . mysqli_real_escape_string($cnnSWOP, $_POST['type']) . "' ";
    $member_type_join_sqlsafe = " INNER JOIN \r\n        (SELECT Active, Participant_ID, max(Date_Changed) as lastdate FROM Pool_Status_Changes\r\n        GROUP BY Participant_ID) lasttypestatus\r\n        ON member_type.Date_Changed=lasttypestatus.lastdate ";
} else {
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Enlace_id);
/*Add a new program quality survey here: */
include "../../header.php";
include "../header.php";
include "../classes/program.php";
$survey_program = new Program();
$survey_program->load_with_program_id($_GET['prog']);
include "../include/dbconnopen.php";
$prog_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_GET['prog']);
?>
<script type="text/javascript">
	$(document).ready(function() {
		$('#programs_selector').addClass('selected');
			$('#ajax_loader').hide();
	});
	
    include "../include/dbconnopen.php";
    $make_household_sqlsafe = "INSERT INTO Households (Household_Name) VALUES ('" . mysqli_real_escape_string($cnnSWOP, $_POST['household']) . "')";
    mysqli_query($cnnSWOP, $make_household_sqlsafe);
    $last_id = mysqli_insert_id($cnnSWOP);
    $add_to_household_sqlsafe = "INSERT INTO Households_Participants(Household_ID, Participant_ID, Head_of_Household) \r\n        VALUES ('" . $last_id . "', '" . mysqli_real_escape_string($cnnSWOP, $_POST['participant']) . "', '" . mysqli_real_escape_string($cnnSWOP, $_POST['head']) . "')";
    echo $add_to_household_sqlsafe;
    mysqli_query($cnnSWOP, $add_to_household_sqlsafe);
    include "../include/dbconnclose.php";
} elseif ($_POST['action'] == 'add') {
    /* add a new person to an existing household: */
    include "../include/dbconnopen.php";
    $add_to_household_sqlsafe = "INSERT INTO Households_Participants(Household_ID, Participant_ID, Head_of_Household) \r\n        VALUES ('" . mysqli_real_escape_string($cnnSWOP, $_POST['household']) . "', '" . mysqli_real_escape_string($cnnSWOP, $_POST['participant']) . "', '" . mysqli_real_escape_string($cnnSWOP, $_POST['head']) . "')";
    echo $add_to_household_sqlsafe;
    mysqli_query($cnnSWOP, $add_to_household_sqlsafe);
    include "../include/dbconnclose.php";
} elseif ($_POST['action'] == 'edit') {
    /* change household name. */
    include "../include/dbconnopen.php";
    $change_name_sqlsafe = "UPDATE Households SET Household_Name='" . mysqli_real_escape_string($cnnSWOP, $_POST['name']) . "' WHERE New_Household_ID='" . mysqli_real_escape_string($cnnSWOP, $_POST['id']) . "'";
    echo $change_name_sqlsafe;
    mysqli_query($cnnSWOP, $change_name_sqlsafe);
    include "../include/dbconnclose.php";
} elseif ($_POST['action'] == 'delete') {
    user_enforce_has_access($SWOP_id, $AdminAccess);
    /* remove a person from a household */
    $remove_household_sqlsafe = "DELETE FROM Households_Participants WHERE Households_Participants_ID='" . mysqli_real_escape_string($cnnSWOP, $_POST['id']) . "'";
    echo $remove_household_sqlsafe;
    include "../include/dbconnopen.php";
    mysqli_query($cnnSWOP, $remove_household_sqlsafe);
    include "../include/dbconnclose.php";
}
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include_once $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Enlace_id, $ReadOnlyAccess, $_COOKIE['program']);
include "../../header.php";
include "../header.php";
include "../classes/program.php";
require_once "../classes/assessment.php";
$program = new Program();
$program->load_with_program_id($_COOKIE['program']);
?>
<!--
Shows all program information.
-->

<div style="display:none;">
    <?php 
include "../include/datepicker_wtw.php";
?>
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Enlace_id, $DataEntryAccess);
/*add new event, either to a campaign or to the Little Village-wide events*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/block_group_finder.php";
/*find the block group for the entered address */
$this_address = $_POST['address_num'] . " " . $_POST['address_dir'] . " " . $_POST['address_street'] . " " . $_POST['address_suffix'] . " Chicago IL";
$block_group = do_it_all($this_address, $map);
echo $block_group;
include "../include/dbconnopen.php";
$event_name_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['event_name']);
$campaign_id_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['campaign_id']);
$date_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['date']);
$address_num_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_num']);
$address_dir_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_dir']);
$address_street_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_street']);
$address_suffix_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_suffix']);
$event_type_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['event_type']);
<?php

/*
 *   TTM is a web application to manage data collected by community organizations.
 *   Copyright (C) 2014, 2015  Local Initiatives Support Corporation (lisc.org)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Bickerdike_id, $DataEntryAccess);
/*
 * Add new aldermanic record (just an amount of money added at a given date).
 */
include "../include/dbconnopen.php";
$money_sqlsafe = mysqli_real_escape_string($cnnBickerdike, $_POST['money']);
$date_sqlsafe = mysqli_real_escape_string($cnnBickerdike, $_POST['date']);
$add_bike_miles_sqlsafe = "INSERT INTO Aldermanic_Records (Environmental_Improvement_Money, Date) VALUES\r\n                    ('" . $money_sqlsafe . "',\r\n                     '" . $date_sqlsafe . "')";
mysqli_query($cnnBickerdike, $add_bike_miles_sqlsafe);
include "../include/dbconnclose.php";
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Enlace_id, $AdminAccess, $_POST['program_id']);
// Delete a program (if the user has access to that program).
//if delete program action
if ($_POST['action'] == "delete_program") {
    //get all program sessions
    include "../include/dbconnopen.php";
    $program_id_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['program_id']);
    $all_program_sessions = "SELECT Session_ID FROM Session_Names " . "WHERE Program_ID='" . $program_id_sqlsafe . "'";
    $all_program_sessions = mysqli_query($cnnEnlace, $all_program_sessions);
    include "../include/dbconnclose.php";
    //loop through program sessions
    while ($program_session = mysqli_fetch_array($all_program_sessions)) {
        //delete all program's sessions and details
        //delete session from baseline assessments
        $delete_session = "DELETE FROM Participants_Baseline_Assessments WHERE Program='" . $program_session['Session_ID'] . "'";
        echo $delete_session;
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($LSNA_id, $AdminAccess);
/*delete various elements from places in the system (relatively self-explanatory).*/
include "../include/dbconnopen.php";
$id_sqlsafe = mysqli_real_escape_string($cnnLSNA, $_POST['id']);
if ($_POST['action'] == 'program') {
    $delete_query = "DELETE FROM Subcategories WHERE Subcategory_ID='" . $id_sqlsafe . "'";
} elseif ($_POST['action'] == 'institution') {
    $delete_query = "DELETE FROM Institutions WHERE Institution_ID='" . $id_sqlsafe . "'";
} elseif ($_POST['action'] == 'institution_affiliation') {
    $delete_query = "DELETE FROM Institutions_Participants WHERE Institutions_Participants_ID='" . $id_sqlsafe . "'";
} elseif ($_POST['action'] == 'participant') {
    $delete_query = "DELETE FROM Participants WHERE Participant_ID='" . $id_sqlsafe . "'";
} elseif ($_POST['action'] == 'event') {
    $delete_query = "DELETE FROM Subcategory_Dates WHERE Wright_College_Program_Date_ID='" . $id_sqlsafe . "'";
} elseif ($_POST['action'] == 'family') {
    $delete_query = "DELETE FROM Parent_Mentor_Children WHERE Parent_Mentor_Children_Link_ID='" . $id_sqlsafe . "'";
/*
 *   TTM is a web application to manage data collected by community organizations.
 *   Copyright (C) 2014, 2015  Local Initiatives Support Corporation (lisc.org)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Enlace_id, $ReadOnlyAccess);
/*check for duplicate campaigns (warn before creating two campaigns with the same name)*/
include "../include/dbconnopen.php";
$name_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['name']);
$get_duplicate_campaigns = "SELECT COUNT(Campaign_Name) FROM Campaigns\r\n    WHERE Campaign_Name='" . $name_sqlsafe . "'";
//echo $get_duplicate_campaigns;
$is_duplicate = mysqli_query($cnnEnlace, $get_duplicate_campaigns);
$duplicate = mysqli_fetch_row($is_duplicate);
if ($duplicate[0] > 0) {
    echo 'A campaign named ' . $_POST['name'] . ' is already in the database.  Are you sure you want to enter this campaign?';
}
include "../include/dbconnclose.php";