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

<div class="dtable form">
  <div class="drow">
    <div class="dcell name">Store Name</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($_POST[name]); ?>
        <? 
        // check the db for similar matches
        $name_tag = strtolower(str_replace(" ","", $_POST['name']));
        $name_superstart = substr($name_tag, 0, 4);
        $name_superend = substr($name_tag, -4, 4);
        $name_supermid = substr($name_tag, ((strlen($name_tag))/2 - 2), 4);
        //echo $name_supermid;
        $match_sql = "SELECT fitter_id, fitter_name, fitter_name_tag, fitter_city, fitter_state FROM ".$prefix."Fitters WHERE fitter_valid = 1 AND (fitter_name_tag LIKE '%".$name_superstart."%' OR fitter_name_tag LIKE '%".$name_superend."%' OR fitter_name_tag LIKE '%".$name_supermid."%')";

        //echo $match_sql;

        $match_fetch = mysql_query($match_sql) OR die(mysql_error());

        $i = false;
        while ($match_row = mysql_fetch_array($match_fetch)) { 
            similar_text($match_row['fitter_name'], $_POST['name'], $percent); 
            if ($percent >= 50) { 
                if ($i == false) { 
                    echo ("<span class=\"error\">Duplicate Alert:</span>");
                }
                echo ("<a href=\"".$site_url."/individual.php?fitter_id=".$match_row['fitter_id']."\">".$match_row['fitter_name']." (".$match_row['fitter_city'].", ".$match_row['fitter_state'].")</a> (Similarity: ".(round($percent, 0))."%)");
                $i = true;
            }
        }
        ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Address </div>
    <div class="dcell divider"></div>
    <div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[address])); ?></div>
  </div>
  <div class="drow">
    <div class="dcell name">Address 2</div>
    <div class="dcell divider"></div>
    <div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[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[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[state])); ?></div>
  </div>
  <div class="drow">
    <div class="dcell name">Zip</div>
    <div class="dcell divider"></div>
    <div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[zip])); ?></div>
  </div>
  <div class="drow">
    <div class="dcell name">Lat/Lng</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
    <? 
        if ($geocode_error == false) {
            $latlng_string = "".$_POST[lat].", ".$_POST[lng].""; 
            echo (stripslashes(htmlspecialchars($latlng_string))); 
        } else {
            echo ($geocode_message);
        }
    ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Phone</div>
    <div class="dcell divider"></div>
    <div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[phone])); ?></div>
  </div>
  <div class="drow">
    <div class="dcell name">Fax</div>
    <div class="dcell divider"></div>
    <div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[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[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[website]; ?>" target="_blank"><? echo $_POST[website]; ?></a></div>
  </div>
  <div class="drow">
    <div class="dcell name">Portfolio</div>
    <div class="dcell divider"></div>
    <div class="dcell value"><a href="<? echo $_POST[portfolio]; ?>" target="_blank"><? echo $_POST[portfolio]; ?></a></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 (" FIT INFO ");
        for ($i = 0; $i < 25; $i++) echo("*"); 
        ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Default Tri-Fit Methodology</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
    <?
        $sql = ("SELECT * FROM ".$prefix."FittersMethods WHERE fitter_method_id = ".$_POST[methods]." LIMIT 1");
        $results = mysql_query($sql) or die(mysql_error());

        if (mysql_num_rows($results) > 0) {
            while ($row = mysql_fetch_array($results)) {
                echo ("$row[fitter_method_name]");
            }
        } else {
            echo ("Unanswered");
        }
        
    ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Certifications</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
    <?
    if ($_POST[certifications]) {
        $explosion = implode(",", $_POST[certifications]);
        $sql = ("SELECT * FROM ".$prefix."FittersCertifications WHERE fitter_certification_id IN ($explosion) ORDER BY fitter_certification_name ASC");
        //echo $sql;
        $results = mysql_query($sql) or die(mysql_error());
        $certification_list = "";
        while ($row = mysql_fetch_array($results)) {
            $certification_list  = $certification_list."$row[fitter_certification_name], ";
        }
        $certification_list = rtrim($certification_list, ', ');
        if ($certification_list == "") { echo "None"; } else { echo $certification_list; }
    }
    ?>
    </div>
  </div>
   <div class="drow">
    <div class="dcell name">Fit Bikes</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
    <?
    if ($_POST[fitbikes]) {
        $explosion = implode(",", $_POST[fitbikes]);
	    $sql = ("SELECT * FROM ".$prefix."FittersFitbikes WHERE fitter_fitbike_id IN ($explosion) ORDER BY fitter_fitbike_name ASC");
        //echo $sql;
        $results = mysql_query($sql) or die(mysql_error());
        $fitbike_list = "";
        while ($row = mysql_fetch_array($results)) {
            $fitbike_list  = $fitbike_list."$row[fitter_fitbike_name], ";
        }
        $fitbike_list = rtrim($fitbike_list, ', ');
        if ($fitbike_list == "") { echo "None"; } else { echo $fitbike_list; }
    }
    ?>
    </div>
  </div>
    <div class="drow">
    <div class="dcell name">Motion-Capture Systems</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
    <?
    if ($_POST[motioncapture]) {
        $explosion = implode(",", $_POST[motioncapture]);
	    $sql = ("SELECT * FROM ".$prefix."FittersMotioncapture WHERE fitter_motioncapture_id IN ($explosion) ORDER BY fitter_motioncapture_name ASC");
        $results = mysql_query($sql) or die(mysql_error());
        $motioncapture_list = "";
        while ($row = mysql_fetch_array($results)) {
            $motioncapture_list  = $motioncapture_list."$row[fitter_motioncapture_name], ";
        }
        $motioncapture_list = rtrim($motioncapture_list, ', ');
        if ($motioncapture_list == "") { echo "None"; } else { echo $motioncapture_list; }
    }
    ?>
    </div>
    </div>
    <div class="drow">
    <div class="dcell name">Brand Friendly</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
	<?
    if ($_POST[brandfriendly]) {
        $explosion = implode(",", $_POST[brandfriendly]);
        
        $sql = ("SELECT * FROM ".$prefix."FittersBrandFriendly WHERE fitter_brand_id IN ($explosion) ORDER BY fitter_brand_name ASC");
        
        //echo $sql;
        
        $fetch = mysql_query($sql) or die(mysql_error());
        
        $brandfriendly_list = "";
        while ($list = mysql_fetch_array($fetch)) {
            $brandfriendly_list  = $brandfriendly_list."$list[fitter_brand_name], ";
        }
        $brandfriendly_list = rtrim($brandfriendly_list, ', ');
        
        echo $brandfriendly_list;
    }
	?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Cost of Fit</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes(htmlspecialchars($_POST[cost])); ?>
    </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[info])) ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Directions</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo strip_tags(stripslashes($_POST[directions])); ?>
    </div>
  </div>
  <div class="drow actions">
    <div class="dcell name"></div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <form action="add.php" method="post">
            <input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($_POST[name])); ?>">
            <input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>">
            <input type="hidden" name="address_two" value="<? echo stripslashes(htmlspecialchars($_POST[address_two])); ?>">
            <input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($_POST[city])); ?>">
            <input type="hidden" name="state" value="<? echo $_POST[state]; ?>">
            <input type="hidden" name="zip" value="<? echo $_POST[zip]; ?>">
            <input type="hidden" name="latlng_override" value="<? echo $_POST[latlng_override]; ?>">
            <input type="hidden" name="lat" value="<? echo $_POST[lat]; ?>">
            <input type="hidden" name="lng" value="<? echo $_POST[lng]; ?>">
            <input type="hidden" name="phone" value="<? echo $_POST[phone]; ?>">
            <input type="hidden" name="fax" value="<? echo $_POST[fax]; ?>">
            <input type="hidden" name="email" value="<? echo $_POST[email]; ?>">
            <input type="hidden" name="website" value="<? echo $_POST[website]; ?>">
            <input type="hidden" name="portfolio" value="<? echo $_POST[portfolio]; ?>">
            <input type="hidden" name="methods" value="<? echo $_POST[methods]; ?>">
            <input type="hidden" name="certifications" value="<? echo(implode(',', $_POST[certifications])); ?>">
            <input type="hidden" name="fitbikes" value="<? echo(implode(',', $_POST[fitbikes])); ?>">
            <input type="hidden" name="motioncapture" value="<? echo(implode(',', $_POST[motioncapture])); ?>">
            <input type="hidden" name="brandfriendly" value="<? echo(implode(',', $_POST[brandfriendly])); ?>">
            <input type="hidden" name="cost" value="<? echo stripslashes(htmlspecialchars($_POST[cost])); ?>">
            <input type="hidden" name="info" value="<? echo stripslashes(htmlspecialchars($_POST[info])); ?>">
            <input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($_POST[directions])); ?>">
            <input type="hidden" name="add_fitter" value="true">
            <input type="hidden" name="insert_fitter" value="true">
            <input type="hidden" name="submitted_by" value="<? echo $useruid; ?>" >
            <input type="submit" name="submit" value="Submit Info" class="btn float-left" style="margin-right: 5px;"/>
        </form>
        <form action="add.php" method="post">
            <input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($_POST[name])); ?>">
            <input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>">
            <input type="hidden" name="address_two" value="<? echo stripslashes(htmlspecialchars($_POST[address_two])); ?>">
            <input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($_POST[city])); ?>">
            <input type="hidden" name="state" value="<? echo $_POST[state]; ?>">
            <input type="hidden" name="zip" value="<? echo $_POST[zip]; ?>">
            <input type="hidden" name="latlng_override" value="<? echo $_POST[latlng_override]; ?>">
            <input type="hidden" name="lat" value="<? echo $_POST[lat]; ?>">
            <input type="hidden" name="lng" value="<? echo $_POST[lng]; ?>">
            <input type="hidden" name="phone" value="<? echo $_POST[phone]; ?>">
            <input type="hidden" name="fax" value="<? echo $_POST[fax]; ?>">
            <input type="hidden" name="email" value="<? echo $_POST[email]; ?>">
            <input type="hidden" name="website" value="<? echo $_POST[website]; ?>">
            <input type="hidden" name="portfolio" value="<? echo $_POST[portfolio]; ?>">
            <input type="hidden" name="methods" value="<? echo $_POST[methods]; ?>">
            <input type="hidden" name="certifications" value="<? echo(implode(',', $_POST[certifications])); ?>">
            <input type="hidden" name="fitbikes" value="<? echo(implode(',', $_POST[fitbikes])); ?>">
            <input type="hidden" name="motioncapture" value="<? echo(implode(',', $_POST[motioncapture])); ?>">
            <input type="hidden" name="brandfriendly" value="<? echo(implode(',', $_POST[brandfriendly])); ?>">
            <input type="hidden" name="cost" value="<? echo stripslashes(htmlspecialchars($_POST[cost])); ?>">
            <input type="hidden" name="info" value="<? echo stripslashes(htmlspecialchars($_POST[info])); ?>">
            <input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($_POST[directions])); ?>">
            <input type="hidden" name="confirm_fitter" value="0">
            <input type="submit" name="submit" value="Edit Information" class="btn float-left" />
        </form>
    </div>
  </div>
</div>

