<?PHP 

include("config.php");

if(!isset($_GET[retailer_id]) AND !$_POST) {
  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_shop])) { 
  $row = $_POST;
} else {
  $retailer_idhere = mysql_real_escape_string($_GET[retailer_id]);
  $results = mysql_query("SELECT * FROM gforum_Retailers WHERE retailer_id=".$retailer_idhere);
  $row = mysql_fetch_array($results);
}

if(is_logged_in($user)){

	//Get user's uid
	$username = base64_decode($_SESSION['user']);
	$testresults = mysql_query("SELECT user_id FROM ".$prefix."User WHERE user_username='$username'") or die(mysql_error());
	$testrow = mysql_fetch_array($testresults);
	$useruid = $testrow[user_id];
	
	$shop_owner = FALSE; 
	// is the current user the owner of the race?
	if($useruid == $row[retailer_submitted_by] && $row[retailer_valid] == 1){
		$shop_owner = TRUE;
	}

  	if($username != "Slowman" && $username != "Rappstar" && $username != "Herbert" && $shop_owner != TRUE) { 
      header('Location: '.$site_url.'/?error=not_owner&user='.$useruid.'&owner='.$row[retailer_submitted_by].'&valid='.$row[retailer_valid]);
      exit();
  	}
} else { 
  	header('Location: '.$site_url.'/?error=not_logged_in_two');
  	exit(); 
}

// set the page title
$pagetitle = "Edit A Retailer";

// set meta tags
$meta_keywords = "edit retailer";
$meta_description = "edit screen for retailer information";

?>

<? include("include_common_head.php"); ?>
<? include("include_common_content.php"); ?>

<!-- Start outer -->
<div id="outer">

<?  

if($_POST[edit_shop] == 1){
  include("edit_X.php");
}

//Array of states for use in the form
$state_list = array('AL'=>"Alabama",  
			'AK'=>"Alaska", 
			'AB'=>'Alberta',
			'AZ'=>"Arizona",  
			'AR'=>"Arkansas", 
			'BC'=>'British Columbia',
			'CB'=>"Caribbean",
			'CA'=>"California",  
			'CM'=>"Central America",
			'CO'=>"Colorado",  
			'CT'=>"Connecticut",
			'DE'=>"Delaware",  
			'DC'=>"District of Columbia",
			'FL'=>"Florida",  
			'GA'=>"Georgia",  
			'HI'=>"Hawaii",  
			'ID'=>"Idaho",  
			'IL'=>"Illinois",  
			'IN'=>"Indiana",  
			'IA'=>"Iowa",  
			'KS'=>"Kansas",  
			'KY'=>"Kentucky",  
			'LA'=>"Louisiana",  
			'ME'=>"Maine",  
			'MB'=>'Manitoba',
			'MD'=>"Maryland",  
			'MA'=>"Massachusetts", 
			'MX'=>"Mexico",
			'MI'=>"Michigan",  
			'MN'=>"Minnesota",  
			'MS'=>"Mississippi",  
			'MO'=>"Missouri",  
			'MT'=>"Montana",
			'NE'=>"Nebraska",
			'NV'=>"Nevada",
			'NB'=>'New Brunswick',
			'NL'=>'Newfoundland',
			'NH'=>"New Hampshire",
			'NJ'=>"New Jersey",
			'NM'=>"New Mexico",
			'NY'=>"New York",
			'NC'=>"North Carolina",
			'ND'=>"North Dakota",
			'NS'=>'Nova Scotia',
			'OH'=>"Ohio",  
			'OK'=>"Oklahoma",
			'ON'=>'Ontario',
			'OR'=>"Oregon",  
			'PA'=>"Pennsylvania",
			'PE'=>'Prince Edward Island',
			'QC'=>'Quebec',
			'RI'=>"Rhode Island", 
			'SK'=>'Saskatchewan',
			'SC'=>"South Carolina",  
			'SD'=>"South Dakota",
			'TN'=>"Tennessee",  
			'TX'=>"Texas",  
			'UT'=>"Utah",  
			'VT'=>"Vermont",  
			'VA'=>"Virginia",  
			'WA'=>"Washington",  
			'WV'=>"West Virginia",  
			'WI'=>"Wisconsin",  
			'WY'=>"Wyoming");
?>

<!-- BODY -->
<div class="content">
<!-- LEFT COLUMN -->


<!-- End left column -->
<!-- Content col -->
<?
if( $_GET[confirmed] == "yes" ) { ?>
<h1 class="content-title"><strong>Thank you</strong></h1>
<? echo "<p class=\"cont\">Thank you. Your shop should be added within 24 hours. You will now be redirected back to the add page.</p>";
echo "<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=add.php\">"; 
} else if($confirm == 1){ ?>
<h1 class="content-title"><strong>Edit a Shop: Step 2 of 2</strong></h1>
<? }else if( ($confirm !=1) && ($_POST[confirm_entry] != 1)){ ?>
<h1 class="content-title"><strong>Edit a Shop: Step 1 of 2</strong></h1>
<? }else if( ($_POST[edit_shop] == 1) && (!$errmsg) && ($_POST[confirm_entry] == 1)){ ?>
<h1 class="content-title"><strong>Thank you</strong></h1>
<? } 
 if(($confirm != 1) && ($_POST[confirm_entry] != 1) && $_GET[confirmed] != "yes"){ ?>
<p class="cont">To edit a retailer, simply change the data you wish. If you make a mistake, just hit the reset button. <font color="red">To save the changes as a NEW retailer (for instance, if you have multiple locations), hit the "SAVE AS A NEW RETAILER" button. To save changes to the existing retailer entry, hit the "SAVE CHANGES TO YOUR SHOP" button. You will have a chance to review the data before confirming.</font> <!--Pictures are optional, and you can upload a maximum of 3 photos. The maximum file size for each picture is 600k.--></p>
<? } ?>

<? if( $_GET[confirmed] != "yes" && (($_POST[edit_shop] != 1) || ($errmsg) || (($confirm != 1) && ($_POST[confirm_entry] != 1))) ){ ?>
<form enctype="multipart/form-data" action="edit.php" method="post">
<p class="cont"><font color="red"><? echo $errmsg; ?></font></p>
<table border="0" cellspacing="0" cellpadding="3">

<tr>
<td align="right" width="15%">Shop Name: </td>
<td width="85%"><input value="<? echo stripslashes($row[retailer_name]); ?>" type="text" name="retailer_name" size="30" maxlength="80"></td>
</tr>
<tr>
<td align="right">Street address: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_address])); ?>" type="text" name="retailer_address" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">Street address two: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_address_two])); ?>" type="text" name="retailer_address_two" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">City: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_city])); ?>" type="text" name="retailer_city" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">State: </td>
<td>
<SELECT name="retailer_state">
	<OPTION value="0">Choose a State/Province</OPTION>
	
<? //use loop for dropdown box
foreach($state_list as $key=>$value){
   if(strcmp($row[retailer_state], $value) == 0){
      $str = " selected=\"selected\"";
   }
   echo "<option value=\"$value\"$str>$value</option>";
   $str = "";
}
?>
	</SELECT>

</td>
</tr>
<tr>
<td align="right">Zip/Postal Code: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_zip])); ?>" type="text" name="retailer_zip" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">Phone: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_phone])); ?>" type="text" name="retailer_phone" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">Fax / Alternate Phone: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_fax])); ?>" type="text" name="retailer_fax" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">E-mail: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_email])); ?>" type="text" name="retailer_email" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">Website: </td>
<td><input value="<? echo $row[retailer_website]; ?>" type="text" name="retailer_website" size="30" maxlength="200">
(include http:// )
</td>
</tr>
<tr>
<td align="right">Online Shopping Cart: <br/> (Must be a fully functional ecommerce system) </td>
<td>
<input type="radio" name="retailer_cart" value="0"  <? if ($row[cart] == 0){ echo 'checked'; } ?>>No
<input type="radio" name="retailer_cart" value="1"  <? if ($row[cart] == 1){ echo 'checked'; } ?>>Yes
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<? 
for ($i = 0; $i < 35; $i++) echo("*"); 
echo (" BIKE FIT ");
for ($i = 0; $i < 35; $i++) echo("*"); 
?>
<br />
</div>
</td>
</tr>
<tr>
<td align="right">Key Tri-Specific Contact(s): </td>
<td>
<input type="radio" name="retailer_contact" value="0"  <? if ($row[retailer_contact] == 0){ echo 'checked'; } ?>>None
<input type="radio" name="retailer_contact" value="1"  <? if ($row[retailer_contact] == 1){ echo 'checked'; } ?>>Yes, Their Names:
<input value="<? echo stripslashes($row[retailer_contact_names]); ?>" type="text" name="retailer_contact_names" size="25" maxlength="250">
<? 
// tri_contact[] -- can we use an array here?
// ALSO, we need to check to see if names are entered, and if so, then set the radio buttons accordingly. 
?>
</td>
</tr>
<tr>
<td align="right">F.I.S.T. Fitter(s): </td>
<td><input type="radio" name="retailer_fist" value="0" <? if ($row[retailer_fist] == 0){ echo 'checked'; } ?>>None
<input type="radio" name="retailer_fist" value="1"  <? if ($row[retailer_fist] == 1){ echo 'checked'; } ?>>Yes, Their Names:
<input value="<? echo stripslashes($row[retailer_fist_names]); ?>" type="text" name="retailer_fist_names" size="25" maxlength="250">

</td>
</tr>
<tr>
<td align="right">Serotta Fitter(s): </td>
<td><input type="radio" name="retailer_serotta" value="0"  <? if ($row[retailer_serotta] == 0){ echo 'checked'; } ?>>None
<input type="radio" name="retailer_serotta" value="1"  <? if ($row[retailer_serotta] == 1){ echo 'checked'; } ?>>Yes, Their Names: 
<input value="<? echo stripslashes($row[retailer_serotta_names]); ?>" type="text" name="retailer_serotta_names" size="25" maxlength="250">


</td>
</tr>

<tr>
<td align="right">Fit Bikes: </td>
<td><table cellpadding=0 cellspacing=0 width="100%"><?

$explosion = array("");
if ($row[retailer_fitbikes]){ $explosion = explode(",", $row[retailer_fitbikes]); }

$list = mysql_query("SELECT * FROM gforum_RetailersFitbikes ORDER BY retailers_fitbike_name ASC");

$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"retailer_fitbikes[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
    if(!($i%4)) echo "</tr><tr>";
    echo("<td width=\"25%\"><input type=\"checkbox\" name=\"retailer_fitbikes[]\" value=\"$fetch[retailers_fitbike_id]\" ");
    if (in_array($fetch[retailers_fitbike_id], $explosion)){ echo "checked "; }
    echo(">$fetch[retailers_fitbike_name]</td>\n");
    $i++;
}
echo("</tr>");

?>
</table>
</td>
</tr>
<tr>
<td align="right">Motion-Capture Systems: </td>
<td><table cellpadding=0 cellspacing=0 width="100%"><?

$explosion = array("");
if ($row[retailer_motioncapture]){ $explosion = explode(",", $row[retailer_motioncapture]); }

$list = mysql_query("SELECT * FROM gforum_RetailersMotioncapture ORDER BY retailers_motioncapture_name ASC");

$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"retailer_motioncapture[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
    if(!($i%4)) echo "</tr><tr>";
    echo("<td width=\"25%\"><input type=\"checkbox\" name=\"retailer_motioncapture[]\" value=\"$fetch[retailers_motioncapture_id]\"  ");
    if (in_array($fetch[retailers_motioncapture_id], $explosion)){ echo "checked "; }
    echo(">$fetch[retailers_motioncapture_name]</td>\n");
    $i++;
}
echo("</tr>");

?>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<? 
for ($i = 0; $i < 36; $i++) echo("*"); 
echo (" BRANDS ");
for ($i = 0; $i < 36; $i++) echo("*"); 
?>
<br />
IMPORTANT: Wetsuit brands of which you'll have 12 or more continually in stock during the season.<br />
</div>
</td>
</tr>
<tr>
<td align="right">Wetsuits: </td>
<td><table cellpadding=0 cellspacing=0 width="100%"><?

$explosion = array("");
if ($row[retailer_wetsuits]){ $explosion = explode(",", $row[retailer_wetsuits]); }

$list = mysql_query("SELECT * FROM gforum_RetailersWetsuits ORDER BY retailers_wetsuit_name ASC");

$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"retailer_wetsuits[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
    if(!($i%4)) echo "</tr><tr>";
    echo("<td width=\"25%\"><input type=\"checkbox\" name=\"retailer_wetsuits[]\" value=\"$fetch[retailers_wetsuit_id]\"  ");
    if (in_array($fetch[retailers_wetsuit_id], $explosion)){ echo "checked "; }
    echo(">$fetch[retailers_wetsuit_name]</td>\n");
    $i++;
}
echo("</tr>");

?>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<br />
IMPORTANT: Tri and road bike brands of which you'll have six or more sitting on the floor during the season.<br />
</div>
</td>
</tr>
<tr>
<td align="right">Bikes: </td>
<td><table cellpadding=0 cellspacing=0 width="100%"><?

$explosion = array("");
if ($row[retailer_bikes]){ $explosion = explode(",", $row[retailer_bikes]); }

$list = mysql_query("SELECT * FROM gforum_RetailersBikes ORDER BY retailers_bike_name ASC");

$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"retailer_bikes[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
    if(!($i%4)) echo "</tr><tr>";
    echo("<td width=\"25%\"><input type=\"checkbox\" name=\"retailer_bikes[]\" value=\"$fetch[retailers_bike_id]\"  ");
    if (in_array($fetch[retailers_bike_id], $explosion)){ echo "checked "; }
    echo(">$fetch[retailers_bike_name]</td>\n");
    $i++;
}
echo("</tr>");

?>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<br />
IMPORTANT: Custom brands of which you'll sell six or more in a 12 month period.<br />
</div>
</td>
</tr>
<tr>
<td align="right">Custom Frames: </td>
<td><table cellpadding=0 cellspacing=0 width="100%"><?

$explosion = array("");
if ($row[retailer_customs]){ $explosion = explode(",", $row[retailer_customs]); }

$list = mysql_query("SELECT * FROM gforum_RetailersCustoms ORDER BY retailers_custom_name ASC");

$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"retailer_customs[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
    if(!($i%4)) echo "</tr><tr>";
    echo("<td width=\"25%\"><input type=\"checkbox\" name=\"retailer_customs[]\" value=\"$fetch[retailers_custom_id]\"  ");
    if (in_array($fetch[retailers_custom_id], $explosion)){ echo "checked "; }
    echo(">$fetch[retailers_custom_name]</td>\n");
    $i++;
}
echo("</tr>");

?>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<? 
for ($i = 0; $i < 80; $i++) echo("*"); 
?>
</div></td>
</tr>

<tr>
<td align="right">Shop Hours: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[retailer_hours])); ?>" type="text" name="retailer_hours" size="30" maxlength="100"></td>
</tr>

<tr>
<td align="right">Barnett-Trained Mechanic(s): </td>
<td><input type="radio" name="retailer_barnett" value="0"  <? if ($row[retailer_barnett] == 0){ echo 'checked'; } ?>>None
<input type="radio" name="retailer_barnett" value="1"  <? if ($row[retailer_barnett] == 1){ echo 'checked'; } ?>>Yes, Their Names: 
<input value="<? echo stripslashes($row[retailer_barnett_names]); ?>" type="text" name="retailer_barnett_names" size="25" maxlength="50">


</td>
</tr>
<tr>
<td align="right">United Bicycle Institute-Trained Mechanic(s): </td>
<td><input type="radio" name="retailer_ubi" value="0"  <? if ($row[retailer_ubi] == 0){ echo 'checked'; } ?>>None
<input type="radio" name="retailer_ubi" value="1"  <? if ($row[retailer_ubi] == 1){ echo 'checked'; } ?>>Yes, Their Names: 
<input value="<? echo stripslashes($row[retailer_ubi_names]); ?>" type="text" name="retailer_ubi_names" size="25" maxlength="50">


</td>
</tr>

<tr>
<td align="right" valign="top">Shop Info: </td>
<td><textarea name="retailer_info" rows="7" cols="45">
<? if($row[retailer_info]){ echo strip_tags(stripslashes($row[retailer_info])); }else{ ?>
Please write some information about your shop.
<? } ?>
</textarea></td>
</tr>
<tr>
<td align="right" valign="top">Directions: </td>
<td><textarea name="retailer_directions" rows="7" cols="45">
<? if($row[retailer_directions]){ echo strip_tags(stripslashes($row[retailer_directions])); }else{ ?>
Please describe how to get to your shop from your surrounding area.
<? } ?>
</textarea></td>
</tr>



<tr>
<td></td>
<td><input type="submit" name="save_changes" value="Save Changes To Your Shop Info">
<input type="submit" name="new_shop" value="Save As A New Retailer">
<input type="reset" value="Reset">
<input type="hidden" name="edit_shop" value="1">
<input type="hidden" name="retailer_id" value="<? echo($row[retailer_id]); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="retailer_valid" value="1">
<input type="hidden" name="retailer_submitted_by" value="<? echo($row[retailer_submitted_by]); ?>">
</td>
</tr>
</table>
</form>
 
<? 

} else { 

// this is the confirmation message. This is as an alternative to the one above.
/**if(($row[edit_shop] == 1) && (!$errmsg) && ($row[confirm_entry] == 1)){
echo "<p class=\"cont\">Thank you. Your shop should be edited within 24 hours. You will now be redirected back to the home page.</p>";
echo "<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=index.php?from_edit\">";
}**/

if($confirm == 1){
	$confirm = 0;
?>
<div class="indent">
Please confirm your shop information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your shop information before submitting.</div>
<br />

<h1 class="content-title"><strong><? echo stripslashes($_POST[retailer_name]); ?></strong></h1>
<div class="indent">
</div>
<table border="0" cellspacing="0" cellpadding="2">

<tr>
<td align="right" width="15%">Shop Name: </td>
<td width="85%"><? echo stripslashes($_POST[retailer_name]); ?></td>
</tr>
<tr>
<td align="right">Street address: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_address])); ?></td>
</tr>
<tr>
<td align="right">Street address two: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_address_two])); ?></td>
</tr>
<tr>
<td align="right">City: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_city])); ?></td>
</tr>
<tr>
<td align="right">State: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_state])); ?></td>
</tr>
<tr>
<td align="right">Zip/Postal Code: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_zip])); ?></td>
</tr>
<tr>
<td align="right">Phone: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_phone])); ?></td>
</tr>
<tr>
<td align="right">Fax / Alternate Phone: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_fax])); ?></td>
</tr>
<tr>
<td align="right">E-mail: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_email])); ?></td>
</tr>
<tr>
<td align="right">Website: </td>
<td><a href="<? echo $_POST[retailer_website]; ?>" target="_blank"><? echo $_POST[retailer_website]; ?></a>
</td>
</tr>
<tr>
<td align="right">Cart: </td>
<td><? if ($_POST[retailer_cart] == 0) { echo ("No"); } else { echo ("Yes"); } ?>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<? 
for ($i = 0; $i < 35; $i++) echo("*"); 
echo (" BIKE FIT ");
for ($i = 0; $i < 35; $i++) echo("*"); 
?>
<br />
</div>
</td>
</tr>
<tr>
<td align="right">Key Tri-Specific Contact(s): </td>
<td><? if ($_POST[retailer_contact] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($_POST[retailer_contact_names]); } ?> </td>
</tr>
<tr>
<td align="right">F.I.S.T. Fitter(s): </td>
<td><? if ($_POST[retailer_fist] == 0) { echo "None"; } else { echo "Yes, Their Names -  "; echo stripslashes($_POST[retailer_fist_names]); } ?> </td>
</tr>
<tr>
<td align="right">Serotta Fitter(s): </td>
<td><? if ($_POST[retailer_serotta] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($_POST[retailer_serotta_names]); } ?></td>
</tr>

<tr>
<td align="right">Fit Bikes: </td>
<td><?

$implosion = implode(",", $_POST[retailer_fitbikes]);

$sql = ("SELECT * FROM gforum_RetailersFitbikes WHERE retailers_fitbike_id IN ($implosion) ORDER BY retailers_fitbike_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$fitbike_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $fitbike_list  = $fitbike_list."$list[retailers_fitbike_name], ";
}
$fitbike_list = rtrim($fitbike_list, ', ');

echo $fitbike_list;

?>
</td>
</tr>
<tr>
<td align="right">Motion-Capture Systems: </td>
<td><?

$implosion = implode(",", $_POST[retailer_motioncapture]);

$sql = ("SELECT * FROM gforum_RetailersMotioncapture WHERE retailers_motioncapture_id IN ($implosion) ORDER BY retailers_motioncapture_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$motioncapture_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $motioncapture_list  = $motioncapture_list."$list[retailers_motioncapture_name], ";
}
$motioncapture_list = rtrim($motioncapture_list, ', ');

echo $motioncapture_list;

?>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<? 
for ($i = 0; $i < 36; $i++) echo("*"); 
echo (" BRANDS ");
for ($i = 0; $i < 36; $i++) echo("*"); 
?>
<br />
</div>
</td>
</tr>
<tr>
<td align="right">Wetsuits: </td>
<td><?

$implosion = implode(",", $_POST[retailer_wetsuits]);

$sql = ("SELECT * FROM gforum_RetailersWetsuits WHERE retailers_wetsuit_id IN ($implosion) ORDER BY retailers_wetsuit_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$wetsuit_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $wetsuit_list  = $wetsuit_list."$list[retailers_wetsuit_name], ";
}
$wetsuit_list = rtrim($wetsuit_list, ', ');

echo $wetsuit_list;

?>
</td>
</tr>
<tr>
<td align="right">Bikes: </td>
<td><?

$implosion = implode(",", $_POST[retailer_bikes]);

$sql = ("SELECT * FROM gforum_RetailersBikes WHERE retailers_bike_id IN ($implosion) ORDER BY retailers_bike_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$bike_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $bike_list  = $bike_list."$list[retailers_bike_name], ";
}
$bike_list = rtrim($bike_list, ', ');

echo $bike_list;

?>
</td>
</tr>
<tr>
<td align="right">Custom Frames: </td>
<td><?

$implosion = implode(",", $_POST[retailer_customs]);

$sql = ("SELECT * FROM gforum_RetailersCustoms WHERE retailers_custom_id IN ($implosion) ORDER BY retailers_custom_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$custom_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $custom_list  = $custom_list."$list[retailers_custom_name], ";
}
$custom_list = rtrim($custom_list, ', ');

echo $custom_list;

?>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
<? 
for ($i = 0; $i < 80; $i++) echo("*"); 
?>
</div></td>
</tr>

<tr>
<td align="right">Shop Hours: </td>
<td><? echo stripslashes(htmlspecialchars($_POST[retailer_hours])); ?></td>
</tr>

<tr>
<td align="right">Barnett-Trained Mechanic(s): </td>
<td><? if ($_POST[retailer_barnett] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($_POST[retailer_barnett_names]); } ?> </td>
</tr>
<tr>
<td align="right">United Bicycle Institute-Trained Mechanic(s): </td>
<td><? if ($_POST[retailer_ubi] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($_POST[retailer_ubi_names]); } ?> </td>
</tr>

<tr>
<td align="right" valign="top">Shop Info: </td>
<td><? echo strip_tags(stripslashes($_POST[retailer_info])) ?></td>
</tr>
<tr>
<td align="right" valign="top">Directions: </td>
<td><? echo strip_tags(stripslashes($_POST[retailer_directions])); ?></td>
</tr>

</table>
<br />
<div class="indent">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>

<form action="edit.php" method="post">
<input type="hidden" name="retailer_name" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_name])); ?>">
<input type="hidden" name="retailer_address" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_address])); ?>">
<input type="hidden" name="retailer_address_two" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_address_two])); ?>">
<input type="hidden" name="retailer_city" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_city])); ?>">
<input type="hidden" name="retailer_state" value="<? echo $_POST[retailer_state]; ?>">
<input type="hidden" name="retailer_zip" value="<? echo $_POST[retailer_zip]; ?>">
<input type="hidden" name="retailer_phone" value="<? echo $_POST[retailer_phone]; ?>">
<input type="hidden" name="retailer_fax" value="<? echo $_POST[retailer_fax]; ?>">
<input type="hidden" name="retailer_email" value="<? echo $_POST[retailer_email]; ?>">
<input type="hidden" name="retailer_website" value="<? echo $_POST[retailer_website]; ?>">
<input type="hidden" name="retailer_cart" value="<? echo $_POST[retailer_cart]; ?>">
<input type="hidden" name="retailer_contact" value="<? echo $_POST[retailer_contact]; ?>">
<input type="hidden" name="retailer_contact_names" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_contact_names])); ?>">
<input type="hidden" name="retailer_fist" value="<? echo $_POST[retailer_fist]; ?>">
<input type="hidden" name="retailer_fist_names" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_fist_names])); ?>">
<input type="hidden" name="retailer_serotta" value="<? echo $_POST[retailer_serotta]; ?>">
<input type="hidden" name="retailer_serotta_names" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_serotta_names])); ?>">
<input type="hidden" name="retailer_fitbikes" value="<? echo(implode(',', $_POST[retailer_fitbikes])); ?>">
<input type="hidden" name="retailer_motioncapture" value="<? echo(implode(',', $_POST[retailer_motioncapture])); ?>">
<input type="hidden" name="retailer_wetsuits" value="<? echo(implode(',', $_POST[retailer_wetsuits])); ?>">
<input type="hidden" name="retailer_bikes" value="<? echo(implode(',', $_POST[retailer_bikes])); ?>">
<input type="hidden" name="retailer_customs" value="<? echo(implode(',', $_POST[retailer_customs])); ?>">
<input type="hidden" name="retailer_hours" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_hours])); ?>">
<input type="hidden" name="retailer_barnett" value="<? echo $_POST[retailer_barnett]; ?>">
<input type="hidden" name="retailer_barnett_names" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_barnett_names])); ?>">
<input type="hidden" name="retailer_ubi" value="<? echo $_POST[retailer_ubi]; ?>">
<input type="hidden" name="retailer_ubi_names" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_ubi_names])); ?>">
<input type="hidden" name="retailer_info" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_info])); ?>">
<input type="hidden" name="retailer_directions" value="<? echo stripslashes(htmlspecialchars($_POST[retailer_directions])); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="retailer_valid" value="1">
<input type="hidden" name="edit_shop" value="1">
<input type="hidden" name="confirm_entry" value="1">
<? if(isset($_POST[new_shop])){ ?>
This data will be saved as a NEW RETAILER.
<input type="hidden" name="new_shop" value="1"  />
<input type="hidden" name="retailer_submitted_by" value="<? echo($_POST[retailer_submitted_by]); ?>" />
<? } else { ?>
This data will be saved as a modification to the EXISTING RETAILER.
<input type="hidden" name="save_changes" value="1"  />
<input type="hidden" name="retailer_submitted_by" value="<? echo($_POST[retailer_submitted_by]); ?>" />
<input type="hidden" name="retailer_id" value="<? echo($_POST[retailer_id]); ?>" />
<? } ?>
<input type="submit" name="submit" value="Submit Info">&nbsp;&nbsp;&nbsp;
</form>
</td>
<td>
<form action="edit.php" method="post">
<input type="hidden" name="retailer_name" value="<? echo stripslashes(htmlspecialchars($name)); ?>">
<input type="hidden" name="retailer_address" value="<? echo stripslashes(htmlspecialchars($address)); ?>">
<input type="hidden" name="retailer_address_two" value="<? echo stripslashes(htmlspecialchars($address_two)); ?>">
<input type="hidden" name="retailer_city" value="<? echo stripslashes(htmlspecialchars($city)); ?>">
<input type="hidden" name="retailer_state" value="<? echo $state; ?>">
<input type="hidden" name="retailer_zip" value="<? echo $zip; ?>">
<input type="hidden" name="retailer_phone" value="<? echo $phone; ?>">
<input type="hidden" name="retailer_fax" value="<? echo $fax; ?>">
<input type="hidden" name="retailer_email" value="<? echo $email; ?>">
<input type="hidden" name="retailer_website" value="<? echo $website; ?>">
<input type="hidden" name="retailer_cart" value="<? echo $cart; ?>">
<input type="hidden" name="retailer_contact" value="<? echo $contact; ?>">
<input type="hidden" name="retailer_contact_names" value="<? echo stripslashes(htmlspecialchars($contact_names)); ?>">
<input type="hidden" name="retailer_fist" value="<? echo $fist; ?>">
<input type="hidden" name="retailer_fist_names" value="<? echo stripslashes(htmlspecialchars($fist_names)); ?>">
<input type="hidden" name="retailer_serotta" value="<? echo $serotta; ?>">
<input type="hidden" name="retailer_serotta_names" value="<? echo stripslashes(htmlspecialchars($serotta_names)); ?>">
<input type="hidden" name="retailer_fitbikes" value="<? echo(implode(',', $fitbikes)); ?>">
<input type="hidden" name="retailer_motioncapture" value="<? echo(implode(',', $motioncapture)); ?>">
<input type="hidden" name="retailer_wetsuits" value="<? echo(implode(',', $wetsuits)); ?>">
<input type="hidden" name="retailer_bikes" value="<? echo(implode(',', $bikes)); ?>">
<input type="hidden" name="retailer_customs" value="<? echo(implode(',', $customs)); ?>">
<input type="hidden" name="retailer_hours" value="<? echo stripslashes(htmlspecialchars($hours)); ?>">
<input type="hidden" name="retailer_barnett" value="<? echo $barnett; ?>">
<input type="hidden" name="retailer_barnett_names" value="<? echo stripslashes(htmlspecialchars($barnett_names)); ?>">
<input type="hidden" name="retailer_ubi" value="<? echo $ubi; ?>">
<input type="hidden" name="retailer_ubi_names" value="<? echo stripslashes(htmlspecialchars($ubi_names)); ?>">
<input type="hidden" name="retailer_info" value="<? echo stripslashes(htmlspecialchars($info)); ?>">
<input type="hidden" name="retailer_directions" value="<? echo stripslashes(htmlspecialchars($directions)); ?>">
<input type="hidden" name="edit_return" value="1">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="retailer_valid" value="1">
<input type="hidden" name="retailer_submitted_by" value="<? echo $submitted_by; ?>">
<input type="submit" name="submit" value="Edit Information">
</form>
</td></tr>
</table></div>
<?
	//submit to edit.php with POST[confirm]
} 
} ?>

<!-- End content col -->

</div>
<!-- End BODY -->
</div>
<!-- End Outer -->

<? include("include_common_footer.php"); ?>
