<?php

if (!$userID) {

echo "<table class=menu cellspacing=0>";
echo "<td class='menusection' colspan=2>";
echo "About You";
echo "</td><tr>";
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_add class=menu>Your Membership</a>";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "More about You";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Type Tobacco Used";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Dependency Quiz";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Past Quit Attempts";
echo "</td><tr>";
echo "<td class='menusection' colspan=2>";
echo "Setting Goals";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Fight Triggers";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Cope with Stress";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Find Substitutes";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Use Distractions";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Get Motivated";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Build Support";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Change Environment";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Enjoy Healthy Habits";
echo "</td><tr>";
echo "<td class='menusection' colspan=2>";
echo "Treatment Sessions";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "#1 Preparing to Quit";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "#2 Quitting";
echo "</td><tr>";
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "#3 Staying Quit";
echo "</td><tr>";
echo "<td height='300' colspan=2 class='menugreen'>&nbsp;</td>";
echo "</table>";

}
if ($userID) {

echo "<table class=menu cellspacing=0>";

echo "<td class='menusection' colspan=2>";
echo "About You";
echo "</td><tr>";

echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_edit class='menu'>Your Membership</a>";
echo "</td><tr>";

$m = mysql_query("select demographics_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_demographics class='menu'>More About You</a>";
}
if ($mm[0]=='1') {$m1='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_demographics class='menu'>More About You</a>";
}}
echo "</td><tr>";


if ($m1=='1') {
$m = mysql_query("select whichtobacco_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_whichtobacco class='menu'>Type Tobacco Used</a>";
}
if ($mm[0]=='1') {$m2='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_whichtobacco class='menu'>Type Tobacco Used</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Type Tobacco Used";
echo "</td><tr>";
}


if ($m2=='1') {
$m = mysql_query("select tobaccouse_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_tobaccouse class='menu'>Dependency Quiz</a>";
}
if ($mm[0]=='1') {$m3='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_tobaccouse class='menu'>Dependency Quiz</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Dependency Quiz";
echo "</td><tr>";
}


if ($m3=='1') {
$m = mysql_query("select attempts_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_attempts class='menu'>Past Quit Attempts</a>";
}
if ($mm[0]=='1') {$m4='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_attempts class='menu'>Past Quit Attempts</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Past Quit Attempts";
echo "</td><tr>";
}

echo "<td class='menusection' colspan=2>";
echo "Setting Goals";
echo "</td><tr>";

if ($m4=='1') {
$m = mysql_query("select triggers_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_triggers class='menu'>Fight Triggers</a>";
}
if ($mm[0]=='1') {$m5='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_triggers class='menu'>Fight Triggers</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Fight Triggers";
echo "</td><tr>";
}

if ($m5=='1') {
$m = mysql_query("select stress_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_stress class='menu'>Cope with Stress</a>";
}
if ($mm[0]=='1') {$m6='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_stress class='menu'>Cope with Stress</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Cope with Stress";
echo "</td><tr>";
}

if ($m6=='1') {
$m = mysql_query("select substitutes_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_substitutes class='menu'>Find Substitutes</a>";
}
if ($mm[0]=='1') {$m7='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_substitutes class='menu'>Find Substitutes</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Find Substitutes";
echo "</td><tr>";
}

if ($m7=='1') {
$m = mysql_query("select distractions_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_distractions class='menu'>Use Distractions</a>";
}
if ($mm[0]=='1') {$m8='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_distractions class='menu'>Use Distractions</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Use Distractions";
echo "</td><tr>";
}

if ($m8=='1') {
$m = mysql_query("select motivation_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_motivation class='menu'>Get Motivated</a>";
}
if ($mm[0]=='1') {$m9='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_motivation class='menu'>Get Motivated</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Get Motivated";
echo "</td><tr>";
}

if ($m9=='1') {
$m = mysql_query("select support_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_support class='menu'>Build Support</a>";
}
if ($mm[0]=='1') {$m10='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_support class='menu'>Build Support</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Build Support";
echo "</td><tr>";
}

if ($m10=='1') {
$m = mysql_query("select environment_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_environment class='menu'>Change Environment</a>";
}
if ($mm[0]=='1') {$m11='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_environment class='menu'>Change Environment</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Change Environment";
echo "</td><tr>";
}

if ($m11=='1') {
$m = mysql_query("select healthyhabits_saved from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0]=='0') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_healthyhabits class='menu'>Enjoy Healthy Habits</a>";
}
if ($mm[0]=='1') {$m12='1';
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_healthyhabits class='menu'>Enjoy Healthy Habits</a>";
}} echo "</td><tr>";}
else {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "Enjoy Healthy Habits";
echo "</td><tr>";
}


echo "<td class='menusection' colspan=2>";
echo "Treatment Sessions";
echo "</td><tr>";

$m = mysql_query("select healthyhabits_saved + environment_saved + support_saved + motivation_saved + substitutes_saved + distractions_saved + triggers_saved + stress_saved + attempts_saved + tobaccouse_saved + whichtobacco_saved as sumcheck from user where userID=$userID",$db);  
while ($mm = mysql_fetch_row($m)) { 
if ($mm[0] < 11) {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "#1 Preparing to Quit";
}
if ($mm[0]=='11') {

$q = mysql_query("select quit_date from user where userID=$userID",$db);  
while ($qq = mysql_fetch_row($q)) { 

if ($qq[0]=='0000-00-00') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_quitdate class='menu'>#1 Preparing to Quit</a>";
}
else {
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_quitdate class='menu'>#1 Preparing to Quit</a>";
}
}}}
echo "</td><tr>";


$aq = mysql_query("select quit_date, actual_quitdate from user where userID=$userID",$db);  
while ($aqq = mysql_fetch_row($aq)) { 

if ($aqq[0]=='0000-00-00' or $aqq[0] > date("Y-m-d")) {
echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "#2 Quitting";
}

if ($aqq[0] <= date("Y-m-d") and $aqq[0] > '0000-00-00' and $aqq[1]=='0000-00-00') {
echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_quitting class='menu'>#2 Quitting</a>";
}

if ($aqq[1]>'0000-00-00' and $aqq[0]>'0000-00-00' and $aqq[0] <= date("Y-m-d")) {
echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_quitting class='menu'>#2 Quitting</a>";
}}
echo "</td><tr>";

$asq = mysql_query("select DATE_ADD(actual_quitdate, INTERVAL 14 DAY), actual_quitdate, lastpuff from user where userID=$userID",$db);  
while ($myasq = mysql_fetch_row($asq)) { 

if (($myasq[0] < date("Y-m-d") and $myasq[1] <> '0000-00-00') and $myasq[2] <> '0000-00-00')  {

echo "<td class=icon><img src='../images/go.png'></td><td class='menugreen'>";
echo "<a href=index.php?quitplan=y&area=user_stayingquit class='menu'>#3 Staying Quit</a>";
echo "</td><tr>";


}

if (($myasq[0] < date("Y-m-d") and $myasq[1] <> '0000-00-00') and $myasq[2] == '0000-00-00') {

echo "<td class=icon><img src='../images/do.png'></td><td class='menuamber'>";
echo "<a href=index.php?quitplan=y&area=user_stayingquit class='menu'>#3 Staying Quit</a>";
echo "</td><tr>"; 

}


if ($myasq[0] >= date("Y-m-d") or $myasq[1]=='0000-00-00') {

echo "<td class=icon><img src='../images/stop.png'></td><td class='menuoff'>";
echo "#3 Staying Quit";
echo "</td><tr>"; 

}


}
echo "</td></tr>";

//echo "<td height='300' class='menugreen' colspan=2>&nbsp;</td>";

echo "</table>";


}

?>
