<?PHP 

include("config.php");

if(!is_logged_in($user)){ 
  header('Location: '.$site_url);
  exit(); 
}

$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];

// set the page title
$pagetitle = "Add a Shop";

// set meta tags
$meta_keywords = "add shop";
$meta_description = "Do you want to include your retail store in our online multisport retaler database? Then use this form to send us your information, and we will add it to our website.";

?>

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

<?  
if($_POST[addshop] == 1){
  include("add_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( $_GET[confirmed] == "yes" ) { ?>
                <h1 >Thank You</h1>
                <p class="cont">Thank you. Your shop should be added within 24 hours. You will now be redirected back to the homepage page.</p>
                <meta HTTP-EQUIV="Refresh" CONTENT="4; URL=index.php" /> 
                <? } else if ( $confirm == 1 ) { ?>
                <h1><strong>Add a Shop: Step 2 of 2</h1>
                <? } else if ( ($confirm !=1) && ($_POST[confirm1] != 1)) { ?>
                <h1>Add a Shop: Step 1 of 2</h1>
                <? } else if ( ($_POST[addshop] == 1) && (!$errmsg) && ($_POST[confirm1] == 1)) { ?>
                <h1>Thank you</h1>
                <? } ?> 
                <hr class="line" />
                <? include("include_region_list.php"); ?>

                <? if (($confirm != 1) && ($_POST[confirm1] != 1) && $_GET[confirmed] != "yes") { ?>
                  <p class="cont">If you would like to add your triathlon/running shop to our website, simply fill out the form below. Be sure to fill out every field. After filling out each field, click submit. <font color="red">You will then be prompted to confirm your information before the information is sent to us.</font></p>
                <? } ?>

                <? if( $_GET[confirmed] != "yes" && (($_POST[addshop] != 1) || ($errmsg) || (($confirm != 1) && ($_POST[confirm1] != 1))) ) { ?>
                <form enctype="multipart/form-data" action="add.php" method="post">
                    <p class="error"><? echo $errmsg; ?></p>
                    <div class="dtable form">
                      <div class="drow">
                        <div class="dcell name">Store Name</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="name" value="<? echo stripslashes($_POST[name]); ?>" class="txt lngtext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Address</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="address" value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>" class="txt lngtext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Address 2</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="address_two" value="<? echo stripslashes(htmlspecialchars($_POST[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 type="text" name="city" value="<? echo stripslashes(htmlspecialchars($_POST[city])); ?>" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">State</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <select name="state">
                            <option value="0">Choose a State/Province</option>
                            <?
                            foreach($state_list as $key=>$value) {
                              if(strcmp($_POST[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 type="text" name="zip" value="<? echo stripslashes(htmlspecialchars($_POST[zip])); ?>" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Phone</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="phone" value="<? echo stripslashes(htmlspecialchars($_POST[phone])); ?>" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Fax</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="fax" value="<? echo stripslashes(htmlspecialchars($_POST[fax])); ?>" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">E-mail</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="email" value="<? echo stripslashes(htmlspecialchars($_POST[email])); ?>" class="txt lngtext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Website</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="website" value="<? echo stripslashes(htmlspecialchars($_POST[website])); ?>" class="txt lngtext" placeholder="http://" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Online Shopping Cart</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <select name="cart">
                            <option value="0" <? if ($_POST[cart] == 0) { echo "selected='selected'"; } ?>>No</option>
                            <option value="1" <? if ($_POST[cart] == 1) { echo "selected='selected'"; } ?>>Yes</option>
                          </select> (Must be a fully functional ecommerce system)
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name"></div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <? 
                            for ($i = 0; $i < 10; $i++) echo("*"); 
                            echo (" TECHNOLOGY, COMMUNITY &amp; EDUCATION ");
                            for ($i = 0; $i < 10; $i++) echo("*"); 
                            ?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Key Tri-Specific Contact(s)</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <select name="contact">
                            <option value="0" <? if ($_POST[contact] == 0) { echo "selected='selected'"; } ?>>None</option>
                            <option value="1" <? if ($_POST[contact] == 1) { echo "selected='selected'"; } ?>>Yes, Their Names</option>
                          </select>
                          <input type="text" name="contact_names" value="<? echo stripslashes($_POST[contact_names]); ?>" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Diagnostic Equipment</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
<?
$explosion = array("");
if (!is_array($_POST[diagnostics])){ $explosion = explode(",", $_POST[diagnostics]); } else { $explosion = $_POST[diagnostics]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsDiagnostics ORDER BY diagnostic_name ASC");
echo("<input type=\"hidden\" name=\"diagnostics[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
    echo("<input type=\"checkbox\" name=\"diagnostics[]\" value=\"$row[diagnostic_id]\" ");
    if (in_array($row[diagnostic_id], $explosion)) { echo "checked "; }
    echo(">$row[diagnostic_name]");
}
?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name"></div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <? 
                            for ($i = 0; $i < 25; $i++) echo("*"); 
                            echo (" BRANDS ");
                            for ($i = 0; $i < 25; $i++) echo("*"); 
                            ?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Running Shoes</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <p class="note">IMPORTANT: Running shoe brands of which you'll have almost
                          full size runs in stock of most of the important run models at almost all
                          times.</p>
<?
$explosion = array("");
if (!is_array($_POST[shoes])){ $explosion = explode(",", $_POST[shoes]); } else { $explosion = $_POST[shoes]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsShoes ORDER BY shoe_name ASC");
echo("<input type=\"hidden\" name=\"shoes[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
    echo("<span class=\"col\"><input type=\"checkbox\" name=\"shoes[]\" value=\"$row[shoe_id]\"  ");
    if (in_array($row[shoe_id], $explosion)){ echo "checked "; }
    echo(" />$row[shoe_name]</span>");
}
?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Socks</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <p class="note">IMPORTANT: Sock brands you'll keep in stock almost all the time.</p>
<?
$explosion = array("");
if (!is_array($_POST[socks])){ $explosion = explode(",", $_POST[socks]); } else { $explosion = $_POST[socks]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsSocks ORDER BY sock_name ASC");
echo("<input type=\"hidden\" name=\"socks[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
    echo("<span class=\"col\"><input type=\"checkbox\" name=\"socks[]\" value=\"$row[sock_id]\"  ");
    if (in_array($row[sock_id], $explosion)){ echo "checked "; }
    echo(" />$row[sock_name]</span>");
}
?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Run Focused Apparel</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <p class="note">IMPORTANT: Run focus apparel brands you'll keep in stock, full size runs, almost all the time, season-appropriate.</p>
<?
$explosion = array("");
if (!is_array($_POST[apparel_run])){ $explosion = explode(",", $_POST[apparel_run]); } else { $explosion = $_POST[apparel_run]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelRun ORDER BY apparel_run_name ASC");
echo("<input type=\"hidden\" name=\"apparel_run[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
    echo("<span class=\"col\"><input type=\"checkbox\" name=\"apparel_run[]\" value=\"$row[apparel_run_id]\"  ");
    if (in_array($row[apparel_run_id], $explosion)){ echo "checked "; }
    echo("/> $row[apparel_run_name]</span>");
}
?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Tri Focused Apparel</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <p class="note">IMPORTANT: Run/tri apparel brands you'll keep in stock, full size runs, almost
                          all the time, season-appropriate.</p>
<?
$explosion = array("");
if (!is_array($_POST[apparel_tri])){ $explosion = explode(",", $_POST[apparel_tri]); } else { $explosion = $_POST[apparel_tri]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelTri ORDER BY apparel_tri_name ASC");
echo("<input type=\"hidden\" name=\"apparel_tri[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
    echo("<span class=\"col\"><input type=\"checkbox\" name=\"apparel_tri[]\" value=\"$row[apparel_tri_id]\"  ");
    if (in_array($row[apparel_tri_id], $explosion)){ echo "checked "; }
    echo("/> $row[apparel_tri_name]</span>");
}
?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Swim Gear</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <p class="note">IMPORTANT: Swimwear/Goggles:  Brands you carry wide and deep, with models that are
                          swim-specific.</p>
<?
$explosion = array("");
if (!is_array($_POST[swimgear])){ $explosion = explode(",", $_POST[swimgear]); } else { $explosion = $_POST[swimgear]; }
$results = mysql_query("SELECT * FROM ".$prefix."ResourceSwimgear ORDER BY swimgear_name ASC");
echo("<input type=\"hidden\" name=\"swimgear[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
    echo("<span class=\"col\"><input type=\"checkbox\" name=\"swimgear[]\" value=\"$row[swimgear_id]\"  ");
    if (in_array($row[swimgear_id], $explosion)){ echo "checked "; }
    echo("/>$row[swimgear_name]</span>\n");
}
?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Wetsuits</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <p class="note">IMPORTANT: Wetsuit brands of which you'll have 12 or more continually in stock during the season.</p>
<?
$explosion = array("");
if (!is_array($_POST[wetsuits])){ $explosion = explode(",", $_POST[wetsuits]); } else { $explosion = $_POST[wetsuits]; }
$results = mysql_query("SELECT * FROM ".$prefix."ResourceWetsuit ORDER BY wetsuit_name ASC");
echo("<input type=\"hidden\" name=\"wetsuits[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
    echo("<span class=\"col\"><input type=\"checkbox\" name=\"wetsuits[]\" value=\"$row[wetsuit_id]\"  ");
    if (in_array($row[wetsuit_id], $explosion)){ echo "checked "; }
    echo("/> $row[wetsuit_name]</span>");
}
?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name"></div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <? for ($i = 0; $i < 60; $i++) echo("*"); ?>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Store Hours</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="text" name="hours" value="<? echo stripslashes(htmlspecialchars($_POST[hours])); ?>" class="txt lngtext" /></td>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Runs &amp; Classes</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
<textarea name="classes" class="txt lngtext" placeholder="Place here times and days of regular runs emanating from the shop, with distances and pace (easy-moderate-fast); also whether you host running classes, when, and any cost associated.">
<? if($_POST[classes]){ echo strip_tags(stripslashes($_POST[classes])); } ?>
</textarea>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Shop Info</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
<textarea name="info" class="txt lngtext" placeholder="Please write some information about your shop.">
<? if($_POST[info]){ echo strip_tags(stripslashes($_POST[info])); } ?>
</textarea>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Directions</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
<textarea name="directions" class="txt lngtext" placeholder="Please describe how to get to your shop from your surrounding area.">
<? if($_POST[directions]) { echo strip_tags(stripslashes($_POST[directions])); } ?>
</textarea>
                        </div>
                      </div>
                      <div class="drow actions">
                        <div class="dcell name"></div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                          <input type="submit" value="Submit" class="btn" />
                          <input type="hidden" name="addshop" value="1" />
                        </div>
                      </div>
                    </div>
                  </form>
 
                  <? } else { 
                    if (($_POST[addshop] == 1) && (!$errmsg) && ($_POST[confirm1] == 1)) {
                      echo "<p class=\"cont\">Thank you. Your shop should be added within 24 hours. You will now be redirected back to the home page.</p>";
                      echo "<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=index.php\">";
                    }

                    if ($confirm == 1) {
                      $confirm = 0;
                      include("include_add_confirm.php");
                    } 
                  } ?>

              </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>
