discourse-legacysite-perl/site/coaches/wiki_edit.php
2024-06-17 22:42:14 +10:00

588 lines
32 KiB
PHP

<?PHP
include("config.php");
if(!isset($_GET[coach_id]) AND !$_POST AND !is_numeric($_GET[coach_id])) {
header('Location: '.$site_url.'/?error=no_id_or_no_post');
exit();
}
if(!is_logged_in($user)){
header('Location: '.$site_url.'/?error=not_logged_in_one');
exit();
}
// Populate with post data or populate with edit return data
if (isset($_POST['edit_return']) || isset($_POST['edit_coach'])) {
$row = $_POST;
} else {
$coach_idhere = intval(mysql_escape_string($_GET[coach_id]));
$results = mysql_query("SELECT * FROM ".$prefix."Coaches WHERE coach_id='".$coach_idhere."'");
$row = mysql_fetch_array($results) OR die(mysql_error());
}
//Get user's session data information
$username = base64_decode($_SESSION['user']);
$useruid = base64_decode($_SESSION['user_id']);
if ($username != "Slowman" && $username != "Rappstar" && $username != "Herbert") {
if ( $row[coach_valid] != 1 ) {
header('Location: '.$site_url.'/?error=coach_not_valid');
exit();
}
}
// set the page title
$pagetitle = "Edit A Triathlon Coach";
// set meta tags
$meta_keywords = "edit a triathlon coach";
$meta_description = "edit screen for triathlon coach information";
?>
<? include("include_common_head.php"); ?>
<?
if($_POST[edit_coach] == true){
include("wiki_edit_X.php");
}
?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<? if( $confirm_coach == true ) { ?>
<h1 class="content-title"><strong>Edit a Coach: Step 2 of 2</strong></h1>
<? }else if( ($confirm_coach != true) || ($_POST[edit_coach] != true) ){ ?>
<h1 class="content-title"><strong>Edit a Coach: Step 1 of 2</strong></h1>
<? if (!$errmsg) { ?>
<p class="cont"><p class="cont">To edit a coach, simply change the data you wish. If you make a mistake, just hit the reset button. <span style="color: red;">To save the changes as a NEW coach (for instance, if you have multiple chapters), hit the "SAVE AS A NEW COACH" button. To save changes to the existing coach entry, hit the "SAVE CHANGES TO YOUR COACH" button. You will have a chance to review the data before confirming.</span> <span style="color: red;">You will then be prompted to confirm your information before the information is sent to us.</span></p>
<? } else { ?>
<p class="cont"><span style="color: red;"><? echo $errmsg; ?></span></p>
<? } ?>
<? }
// begin insert form
if( ($_POST[edit_coach] != true) || ($errmsg) || (($confirm_coach != true) && ($_POST[insert_coach] != true)) ) {
?>
<form enctype="multipart/form-data" action="wiki_edit.php" method="post">
<div class="dtable form">
<div class="drow">
<div class="dcell name">Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes($row[coach_name]); ?>" type="text" name="coach_name" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_address])); ?>" type="text" name="coach_address" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address Two (Optional)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_address_two])); ?>" type="text" name="coach_address_two" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">City</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_city])); ?>" type="text" name="coach_city" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">State</div>
<div class="dcell divider"></div>
<div class="dcell value">
<SELECT name="coach_state">
<OPTION value="0">Choose a State/Province/Country</OPTION>
<? //use loop for dropdown box of states
foreach($state_list as $key=>$value){
if(strcmp($row[coach_state], $value) == 0){
$str = " selected=\"selected\"";
}
echo "<option value=\"$value\"$str>$value</option>";
$str = "";
}
?>
</SELECT>
</div>
</div>
<div class="drow">
<div class="dcell name">Zip/Postal Code</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_zip])); ?>" type="text" name="coach_zip" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_phone])); ?>" type="text" name="coach_phone" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">Fax/Alternate Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_fax])); ?>" type="text" name="coach_fax" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">E-mail</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_email])); ?>" type="text" name="coach_email" class="txt medtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo $row[coach_website]; ?>" type="text" name="coach_website" size="30" maxlength="200" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Info</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Certifiations</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($row[coach_certifications])){ $explosion = explode(",", $row[coach_certifications]); } else { $explosion = $row[coach_certifications]; }
$fetch = mysql_query("SELECT * FROM ".$prefix."CoachesCertifications ORDER BY coach_certification_group ASC, coach_certification_id ASC") OR die(mysql_error());
$i = 0;
$grouping = 1;
echo("<tr>");
echo("<input type=\"hidden\" name=\"coach_certifications[]\" value=\"0\" >");
while ($list = mysql_fetch_array($fetch)) {
if(($grouping != $list[coach_certification_group]) OR !($i%3)) {
if (!($i%3)) echo ("<td width=\"33%\">&nbsp;</td>");
echo "</tr><tr>";
$grouping = $list[coach_certification_group];
$i = 0;
}
echo("<td width=\"33%\"><input type=\"checkbox\" name=\"coach_certifications[]\" value=\"$list[coach_certification_id]\" ");
if (in_array($list[coach_certification_id], $explosion)){ echo "checked "; }
echo(">$list[coach_certification_name]</td>\n");
$i++;
}
while ($i<3) {
echo ("<td width=\"33%\">&nbsp;</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Service</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($row[coach_services])){ $explosion = explode(",", $row[coach_services]); } else { $explosion = $row[coach_services]; }
$fetch = mysql_query("SELECT * FROM ".$prefix."CoachesServices ORDER BY coach_service_id ASC");
$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"coach_services[]\" value=\"0\" >");
while ($list = mysql_fetch_array($fetch)) {
if(!($i%1)) echo "</tr><tr>";
echo("<td width=\"100%\"><input type=\"checkbox\" name=\"coach_services[]\" value=\"$list[coach_service_id]\" ");
if (in_array($list[coach_service_id], $explosion)){ echo "checked "; }
echo(">$list[coach_service_name]</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Education</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($row[coach_degrees])){ $explosion = explode(",", $row[coach_degrees]); } else { $explosion = $row[coach_degrees]; }
$fetch = mysql_query("SELECT * FROM ".$prefix."CoachesDegrees ORDER BY coach_degree_id ASC");
$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"coach_degrees[]\" value=\"0\" >");
while ($list = mysql_fetch_array($fetch)) {
if(!($i%2)) echo "</tr><tr>";
echo("<td width=\"50%\"><input type=\"checkbox\" name=\"coach_degrees[]\" value=\"$list[coach_degree_id]\" ");
if (in_array($list[coach_degree_id], $explosion)){ echo "checked "; }
echo(">$list[coach_degree_name]</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">General Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="coach_info" cols="45" class="txt lngtext"><? if($row[coach_info]){ echo strip_tags(stripslashes($row[coach_info])); }else{ echo("Please write some information about your coaching business."); } ?></textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Rates &amp; Fees</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="coach_cost" rows="7" class="txt lngtext"><? if($row[coach_cost]){ echo strip_tags(stripslashes($row[coach_cost])); }else{ echo("Please describe your rates and fees."); } ?></textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Camps</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="coach_camps" rows="7" class="txt lngtext"><? if($row[coach_camps]){ echo strip_tags(stripslashes($row[coach_camps])); }else{ echo("Please describe any training camps you put on."); } ?></textarea>
</div>
</div>
<div class="drow actions">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="submit" name="save_changes" value="Save Changes" class="btn">
<input type="submit" name="new_coach" value="Save As A New Coach" class="btn">
<input type="reset" value="Reset" class="btn">
<input type="hidden" name="edit_coach" value="true">
<input type="hidden" name="coach_id" value="<? echo($row[coach_id]); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="coach_valid" value="1">
<input type="hidden" name="coach_submitted_by" value="<? echo($row[coach_submitted_by]); ?>">
<input type="hidden" name="edited_by" value="<? echo($useruid); ?>">
</div>
</div>
</div>
</form>
<? }
// end insert form
// begin confirmation form
if($confirm_coach == true){
?>
<div class="indent">
Please confirm your information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your information before submitting.</div>
<br />
<div class="dtable form">
<div class="drow">
<div class="dcell name">Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes($_POST[coach_name]); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_address])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address Two</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_address_two])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">City</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_city])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">State</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_state])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Zip/Postal Code</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_zip])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_phone])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Fax/Alternate Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_fax])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">E-mail</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_email])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<a href="<? echo $_POST[coach_website]; ?>" target="_blank"><? echo $_POST[coach_website]; ?></a>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Info</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Certifications</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[coach_certifications]);
$sql = ("SELECT * FROM ".$prefix."CoachesCertifications WHERE coach_certification_id IN ($explosion) ORDER BY coach_certification_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$certification_list = "";
while ($list = mysql_fetch_array($fetch)) {
$certification_list = $certification_list."$list[coach_certification_name], ";
}
$certification_list = rtrim($certification_list, ', ');
echo $certification_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Services</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[coach_services]);
$sql = ("SELECT * FROM ".$prefix."CoachesServices WHERE coach_service_id IN ($explosion) ORDER BY coach_service_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$service_list = "";
while ($list = mysql_fetch_array($fetch)) {
$service_list = $service_list."$list[coach_service_name], ";
}
$service_list = rtrim($service_list, ', ');
echo $service_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Education</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[coach_degrees]);
$sql = ("SELECT * FROM ".$prefix."CoachesDegrees WHERE coach_degree_id IN ($explosion) ORDER BY coach_degree_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$degree_list = "";
while ($list = mysql_fetch_array($fetch)) {
$degree_list = $degree_list."$list[coach_degree_name], ";
}
$degree_list = rtrim($degree_list, ', ');
echo $degree_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">General Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[coach_info])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Rates &amp; Fees</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[coach_cost])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Camps</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[coach_camps])) ?>
</div>
</div>
<div class="drow actions">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<form action="wiki_edit.php" method="post">
<input type="hidden" name="coach_name" value="<? echo stripslashes(htmlspecialchars($_POST[coach_name])); ?>">
<input type="hidden" name="coach_address" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address])); ?>">
<input type="hidden" name="coach_address_two" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address_two])); ?>">
<input type="hidden" name="coach_city" value="<? echo stripslashes(htmlspecialchars($_POST[coach_city])); ?>">
<input type="hidden" name="coach_state" value="<? echo $_POST[coach_state]; ?>">
<input type="hidden" name="coach_zip" value="<? echo $_POST[coach_zip]; ?>">
<input type="hidden" name="coach_phone" value="<? echo $_POST[coach_phone]; ?>">
<input type="hidden" name="coach_fax" value="<? echo $_POST[coach_fax]; ?>">
<input type="hidden" name="coach_email" value="<? echo $_POST[coach_email]; ?>">
<input type="hidden" name="coach_website" value="<? echo $_POST[coach_website]; ?>">
<input type="hidden" name="coach_certifications" value="<? echo(implode(',', $_POST[coach_certifications])); ?>">
<input type="hidden" name="coach_services" value="<? echo(implode(',', $_POST[coach_services])); ?>">
<input type="hidden" name="coach_degrees" value="<? echo(implode(',', $_POST[coach_degrees])); ?>">
<input type="hidden" name="coach_cost" value="<? echo stripslashes(htmlspecialchars($_POST[coach_cost])); ?>">
<input type="hidden" name="coach_info" value="<? echo stripslashes(htmlspecialchars($_POST[coach_info])); ?>">
<input type="hidden" name="coach_camps" value="<? echo stripslashes(htmlspecialchars($_POST[coach_camps])); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="coach_valid" value="1">
<input type="hidden" name="edit_coach" value="true">
<input type="hidden" name="insert_coach" value="true">
<input type="hidden" name="coach_submitted_by" value="<? echo $useruid; ?>" >
<? if(isset($_POST[new_coach])){ ?>
This data will be saved as a NEW COACH.
<input type="hidden" name="new_coach" value="1" />
<input type="hidden" name="coach_submitted_by" value="<? echo($_POST[edited_by]); ?>" />
<? } else { ?>
This data will be saved as a modification to the EXISTING COACH.
<input type="hidden" name="save_changes" value="1" />
<input type="hidden" name="edited_by" value="<? echo($_POST[edited_by]); ?>">
<input type="hidden" name="coach_submitted_by" value="<? echo($_POST[coach_submitted_by]); ?>" />
<input type="hidden" name="coach_id" value="<? echo($_POST[coach_id]); ?>" />
<? } ?>
<br><input type="submit" name="coach_submit" value="Submit Info" class="btn float-left" style="margin-right: 5px">
</form>
<form action="wiki_edit.php" method="post">
<input type="hidden" name="coach_name" value="<? echo stripslashes(htmlspecialchars($_POST[coach_name])); ?>">
<input type="hidden" name="coach_address" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address])); ?>">
<input type="hidden" name="coach_address_two" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address_two])); ?>">
<input type="hidden" name="coach_city" value="<? echo stripslashes(htmlspecialchars($_POST[coach_city])); ?>">
<input type="hidden" name="coach_state" value="<? echo $_POST[coach_state]; ?>">
<input type="hidden" name="coach_zip" value="<? echo $_POST[coach_zip]; ?>">
<input type="hidden" name="coach_phone" value="<? echo $_POST[coach_phone]; ?>">
<input type="hidden" name="coach_fax" value="<? echo $_POST[coach_fax]; ?>">
<input type="hidden" name="coach_email" value="<? echo $_POST[coach_email]; ?>">
<input type="hidden" name="coach_website" value="<? echo $_POST[coach_website]; ?>">
<input type="hidden" name="coach_certifications" value="<? echo(implode(',', $_POST[coach_certifications])); ?>">
<input type="hidden" name="coach_services" value="<? echo(implode(',', $_POST[coach_services])); ?>">
<input type="hidden" name="coach_degrees" value="<? echo(implode(',', $_POST[coach_degrees])); ?>">
<input type="hidden" name="coach_cost" value="<? echo stripslashes(htmlspecialchars($_POST[coach_cost])); ?>">
<input type="hidden" name="coach_info" value="<? echo stripslashes(htmlspecialchars($_POST[coach_info])); ?>">
<input type="hidden" name="coach_camps" value="<? echo stripslashes(htmlspecialchars($_POST[coach_camps])); ?>">
<input type="hidden" name="confirm_coach" value="0">
<input type="hidden" name="edit_return" value="true">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="coach_valid" value="1">
<input type="hidden" name="coach_id" value="<? echo($_POST[coach_id]); ?>" />
<input type="hidden" name="coach_submitted_by" value="<? echo $submitted_by; ?>">
<input type="submit" name="submit" value="Edit Information" class="btn btn-left">
</form>
</div>
</div>
</div>
<?
}
//end confirmation form
?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>