mirror of
https://github.com/fspc/Yellow-Bike-Database.git
synced 2025-02-23 01:03:23 -05:00
This changes the database schema for interest survey.
This commit is contained in:
parent
e33531303f
commit
1ee42f580a
@ -3,6 +3,12 @@
|
|||||||
require_once('Connections/YBDB.php');
|
require_once('Connections/YBDB.php');
|
||||||
require_once('Connections/database_functions.php');
|
require_once('Connections/database_functions.php');
|
||||||
|
|
||||||
|
/*
|
||||||
|
require_once('php-console/src/PhpConsole/__autoload.php');
|
||||||
|
$handler = PhpConsole\Handler::getInstance();
|
||||||
|
$handler->start();
|
||||||
|
*/
|
||||||
|
|
||||||
$waiver = WAIVER;
|
$waiver = WAIVER;
|
||||||
$email_list = EMAIL_LIST;
|
$email_list = EMAIL_LIST;
|
||||||
$volunteer_interest_form = VOLUNTEER_INTEREST_FORM;
|
$volunteer_interest_form = VOLUNTEER_INTEREST_FORM;
|
||||||
@ -86,9 +92,6 @@ if($_GET['contact_id'] == 'new_contact'){
|
|||||||
|
|
||||||
$editFormAction = "?contact_id={$contact_id}&shop_id={$shop_id}";
|
$editFormAction = "?contact_id={$contact_id}&shop_id={$shop_id}";
|
||||||
|
|
||||||
require_once('php-console/src/PhpConsole/__autoload.php');
|
|
||||||
$handler = PhpConsole\Handler::getInstance();
|
|
||||||
$handler->start();
|
|
||||||
|
|
||||||
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
|
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
|
||||||
|
|
||||||
@ -128,8 +131,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
|
|||||||
foreach ($volunteer_interest as $interest) {
|
foreach ($volunteer_interest as $interest) {
|
||||||
// Insert new interest
|
// Insert new interest
|
||||||
if ( !$interests[$interest] ) {
|
if ( !$interests[$interest] ) {
|
||||||
$query = "INSERT INTO options (id, option_name, option_value) VALUES (" .
|
$query = "INSERT INTO options (option_name) VALUES ('" . $interest . "');";
|
||||||
$_POST['contact_id'] . ",'" . $interest . "',0);";
|
|
||||||
$result = mysql_query($query, $YBDB) or die(mysql_error());
|
$result = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,6 +152,27 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If checked, save in database
|
||||||
|
$interest_checked = [];
|
||||||
|
if(!empty($_POST['interest_checkboxes'])) {
|
||||||
|
foreach($_POST['interest_checkboxes'] as $check) {
|
||||||
|
$interest_checked[$check] = $check;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($interests as $interest) {
|
||||||
|
|
||||||
|
if($interest_checked[$interest]) {
|
||||||
|
$sql = "UPDATE options SET option_value=1 WHERE option_name='" . $interests[$interest] . "';";
|
||||||
|
$query = mysql_query($sql, $YBDB) or die(mysql_error());
|
||||||
|
} else {
|
||||||
|
$sql = "UPDATE options SET option_value=0 WHERE option_name='" . $interests[$interest] . "';";
|
||||||
|
$query = mysql_query($sql, $YBDB) or die(mysql_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($_POST['contact_id_entry'] == 'new_contact'){
|
if ($_POST['contact_id_entry'] == 'new_contact'){
|
||||||
|
|
||||||
//navigate back to shop that it came from
|
//navigate back to shop that it came from
|
||||||
@ -157,6 +180,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
|
|||||||
header(sprintf("Location: %s", $pagegoto));
|
header(sprintf("Location: %s", $pagegoto));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_select_db($database_YBDB, $YBDB);
|
mysql_select_db($database_YBDB, $YBDB);
|
||||||
@ -274,7 +298,9 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1);
|
|||||||
|
|
||||||
for($i = $rows - $columns; $i < $rows; $i++) {
|
for($i = $rows - $columns; $i < $rows; $i++) {
|
||||||
if($volunteer_interests[$i]) {
|
if($volunteer_interests[$i]) {
|
||||||
echo "<td><input value='$volunteer_interests[$i]' type='checkbox'>" . $volunteer_interests[$i] . "</td>";
|
echo "<td><input name='interest_checkboxes[]' class='interest_checkboxes'
|
||||||
|
value='$volunteer_interests[$i]' type='checkbox'>" .
|
||||||
|
$volunteer_interests[$i] . "</td>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
@ -195,14 +195,22 @@ ALTER TABLE transaction_log ADD history longblob NOT NULL;
|
|||||||
ALTER TABLE transaction_log MODIFY description text(2048) DEFAULT NULL;
|
ALTER TABLE transaction_log MODIFY description text(2048) DEFAULT NULL;
|
||||||
|
|
||||||
-- options
|
-- options
|
||||||
-- some what borrowed from WordPress
|
-- currently creates/updates/deletes volunteer interests (checkboxes),
|
||||||
-- Currently just for variable values like found in the Volunteer Interest inventory
|
-- but could be used for other surveys
|
||||||
-- where values may be 0 or 1 or text.
|
--
|
||||||
CREATE TABLE IF NOT EXISTS options (
|
CREATE TABLE IF NOT EXISTS options (
|
||||||
id int(10) unsigned NOT NULL,
|
option_name_id int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
option_name varchar(64) NOT NULL,
|
option_name varchar(64) NOT NULL,
|
||||||
option_value text NOT NULL,
|
PRIMARY KEY (option_name_id)
|
||||||
PRIMARY KEY (option_name)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ALTER TABLE options ADD CONSTRAINT id FOREIGN KEY (id) REFERENCES contacts (contact_id) ON UPDATE CASCADE;
|
-- choices
|
||||||
|
-- stores the volunteer interest choices made by people
|
||||||
|
--
|
||||||
|
CREATE TABLE IF NOT EXISTS choices (
|
||||||
|
contact_id int(10) unsigned,
|
||||||
|
choice int(10) unsigned,
|
||||||
|
choice_value int(10) unsigned,
|
||||||
|
FOREIGN KEY (contact_id) REFERENCES contacts (contact_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
FOREIGN KEY (choice) REFERENCES options (option_name_id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user