<?
session_start();
// Call page header
$header = 1;
$pagetitle = "Request Repeat Perscription";
include_once('header.inc.php');
include_once('config.php');
// Make a database connection.
if(!$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd"))
die('<font size=+1>An Error Occured</font><hr>Unable to connect to the database. <BR>Check $dbhost, $dbuser, and $dbpasswd in config.php.');
if(!@mysql_select_db("$dbname",$db))
die("<font size=+1>An Error Occured</font><hr>Unable to find the database <b>$dbname</b> on your MySQL server.");
$sql_select = "select * from mh_users where user_email ='$valid_user'";
if ($debug) { print("$sql_select");}
$result = mysql_query ($sql_select);
while ($row = mysql_fetch_array($result))
{
$user_id = $row["user_id"];
$first_name = $row["first_name"];
$last_name = $row["last_name"];
$dob_day = $row["dob_day"];
$dob_month = $row["dob_month"];
$dob_year = $row["dob_year"];
$sex = $row["sex"];
$user_email = $row["user_email"];
$reg_date = $row["reg_date"];
$activated = $row["activated"];
}
$collect_when = "$day$month$year";
// Detect user IP address for security
$user_ip = $REMOTE_ADDR;
// Time and date of repeat perscription request
$rp_time = date("H:i");
$rp_date = date("dmY");
if($submit_2)
{
$sql_insert = "insert into perscriptions (user_id,gp_no,des_1,quan_1,des_2,quan_2,des_3,quan_3, des_4,quan_4,des_5,quan_5,des_6,quan_6,collect_place,collect_when,rp_date,comments,rp_time,user_ip) values ('$user_id','$gp_no','$des_1','$quan_1','$des_2','$quan_2','$des_3','$quan_3','$des_4','$quan_4','$des_5','$quan_5','$des_6','$quan_6','$collect_place','$collect_when','$rp_date','$comments','$rp_time','$user_ip')";
$result = mysql_query($sql_insert);
// Print Successful request notice
print "<p><b>Repeat Perscription Request Successful</b></p> Please collect your repeat perscription on $day-$month-$year from $collect_place. You shall recieve an email confirming it is ready for collection once it has been dealt with. To view the status and content of your repeat perscription request please click <a href='progress.php'>here</a> If your request has not already been processed you may edit it from <a href='edit.php'>here</a> if you feel you have made a mistake on submission.<br><br>Thank you for using this service.<p><a href='logout.php'>Click here to Log out</a></p>";
}
if ($submit)
{
// Check GP number has been entered
if (empty($gp_no))
{
echo "<font color='#990000'>Error:</font> You have not entered your GP's Prescribing Number.<br>";
$stop = 1;
}
// Check to see if GP number is valid
elseif (($gp_no != 970920) &&($gp_no != 337088)&&($gp_no != 881133))
{
echo "<font color='#990000'>Error:</font> The GP's Prescribing Number you entered is not valid.<br>";
$stop = 1;
}
// Make sure collection place has been entered
if ($collect_place=='0')
{
echo "<font color='#990000'>Error:</font> You have not selected where you would like to collect your repeat perscription.<br>";
$stop = 1;
}
// Make sure collection date has been selected
if(($day == 0)or($month == 0)or($year == 0))
{
echo "<font color='#990000'>Error:</font> You have not entered a collection date.<br>";
$stop = 1;
}
// Make sure a request is made (starting in request fields 1)
if(empty($des_1)&&empty($quan_1))
{
echo "<font color='#990000'>Error:</font> You must request something by filling in the description and quantity fields making sure you start with request no 1.<br> ";
$stop = 1;
}
// Make sure quantity has been entered
if(empty($des_1)&&!empty($quan_1)OR empty($des_2)&&!empty($quan_2)OR empty($des_3)&&!empty($quan_3)OR empty($des_4)&&!empty($quan_4)OR empty($des_5)&&!empty($quan_5)OR empty($des_6)&&!empty($quan_6))
{
echo "<font color='#990000'>Error:</font> You must state a description if you enter a quantity.<br>";
$stop = 1;
}
// Make sure description has been entered
elseif(empty($quan_1)&&!empty($des_1)OR empty($quan_2)&&!empty($des_2)OR empty($quan_3)&&!empty($des_3)OR empty($quan_4)&&!empty($des_4)OR empty($quan_5)&&!empty($des_5)OR empty($quan_6)&&!empty($des_6))
{
echo "<font color='#990000'>Error:</font> You must state a quantity if you enter a description.<br>";
$stop = 1;
}
// Link back to request page
if ($stop)
{
echo "<p><a href='request.php'>Return to previous page</a></p>";
}
// If all is filled out successfully get user to check all is right
if (!$stop)
{
?>
<form name="confirm" method="post" action="request_conf2.php">
<table width="600" border="1" cellspacing="0" cellpadding="0" bordercolor="#98BEDE" align="center">
<tr>
<td>
<table width="600" border="0" cellspacing="0" cellpadding="4" align="center">
<tr>
<td colspan="2" bgcolor="#98BEDE"><b><font size="4"><img src="images/icon_perscription_large.jpg" width="18" height="20">
Repeat Perscription Check</font></b></td>
</tr>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>First
name: </b></td>
<td width="455" bgcolor="#DCEAF5">
<?print $first_name?>
</td>
</tr>
<tr>
<td width="150" align="left" valign="top"><b>Last name: </b></td>
<td width="455">
<?print $last_name?>
</td>
</tr>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Sex:
</b></td>
<td width="455" bgcolor="#DCEAF5">
<?print $sex?>
</td>
</tr>
<tr>
<td width="150" align="left" valign="top"><b>DOB: </b></td>
<td width="455">
<?print "$dob_day-$dob_month-$dob_year"?>
</td>
</tr>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Request
1:</b></td>
<td width="455" bgcolor="#DCEAF5"></td>
</tr>
<tr>
<td width="150" align="left" valign="top"></td>
<td width="455">
<? echo"Description: $des_1 <br> Quantity: $quan_1"?>
</td>
</tr>
<?
if (!empty($des_2)&&!empty($quan_2))
{
?>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Request
2:</b></td>
<td width="455" bgcolor="#DCEAF5"></td>
</tr>
<tr>
<td width="150" align="left" valign="top"></td>
<td width="455">
<? echo"Description: $des_2 <br> Quantity: $quan_2"?>
</td>
</tr>
<?
}
if (!empty($des_3)&&!empty($quan_3))
{
?>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Request
3:</b></td>
<td width="455" bgcolor="#DCEAF5"></td>
</tr>
<tr>
<td width="150" align="left" valign="top"></td>
<td width="455">
<? echo"Description: $des_3 <br> Quantity: $quan_3"?>
</td>
</tr>
<?
}
if (!empty($des_4)&&!empty($quan_4))
{
?>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Request
4:</b></td>
<td width="455" bgcolor="#DCEAF5"></td>
</tr>
<tr>
<td width="150" align="left" valign="top"></td>
<td width="455">
<? echo"Description: $des_4 <br> Quantity: $quan_4"?>
</td>
</tr>
<?
}
if (!empty($des_5)&&!empty($quan_5))
{
?>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Request
5:</b></td>
<td width="455" bgcolor="#DCEAF5"></td>
</tr>
<tr>
<td width="150" align="left" valign="top"></td>
<td width="455">
<? echo"Description: $des_5 <br> Quantity: $quan_5"?>
</td>
</tr>
<?
}
if (!empty($des_6)&&!empty($quan_6))
{
?>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Request
6:</b></td>
<td width="455" bgcolor="#DCEAF5"></td>
</tr>
<tr>
<td width="150" align="left" valign="top"></td>
<td width="455">
<? echo"Description: $des_6 <br> Quantity: $quan_6"?>
</td>
</tr>
<?}?>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Collection
Point:</b></td>
<td width="455" bgcolor="#DCEAF5">
<? echo "$collect_place";?>
</td>
</tr>
<tr>
<td width="150" align="left" valign="top"><b>Collection Date:</b></td>
<td width="455">
<? echo "$day-$month-$year";?>
</td>
</tr>
<tr>
<td width="150" align="left" valign="top" bgcolor="#DCEAF5"><b>Comments:</b></td>
<td width="455" bgcolor="#DCEAF5">
<? echo "$comments";?>
</td>
</tr>
<tr>
<td width="150"></td>
<td width="455">
<input type="submit" name="submit_2" class="submit" value="Proceed">
<input type="button" name="Edit" class="submit" value="Go Back">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?
}
}
// Content for unactivated users
if (session_is_registered("valid_user")&&($activated == '0'))
{
echo "<p><b>Your account has not yet been activated!</b></p>You cannot activate this service until you have recieved a confimation email. If you have not recieved this within three working days of initial registration please contact <a href='mailto:$email_from'>$email_from</a> or telephone 01279 842242";
}
// If there's no session running
if (!session_is_registered("valid_user"))
{
echo "You must login to view this page.<Br>Click <a href='login.php' target='_self'>here</a> to login";
}
include_once('footer.inc.php');
?>