As an addition to the above here's a pic of what I am trying to do.
1. User enters reference number if that data is more than 5 days old show an error and return to the submission form.
2. User clicks one of the reference links (these are filtered less than 5 days old) - Why have both? Requirement spec! The link then takes the user off to the main form where the data is displayed and can be edited.
$conn = oci_connect($username, $password, $servername);
if (!$conn) {
$e = oci_error();
echo(htmlentities($e['message'], ENT_QUOTES));
echo "<br>";
}
$stmt = "SELECT REFERENCE, SITEID, SITENAME, WHATISYOURNAME, DATERECORDED, NUMBEROFPOSITIVELFTTESTS, NUMBEROFVOIDLFTTESTS, NUMBEROFNEGATIVELFTTESTS, NUMBEROFPHARMACYSITESOPERATION
FROM $table
WHERE SITEID = 'PCR1'";
$stid = oci_parse($conn, $stmt);
echo '<table border = 1>';
echo "<tr><th style=width:20%>REFERENCE</th><th style=width:5%>SITEID</th><th style=width:12%>SITE NAME</th><th style=width:18%>DATE RECORDED</th><th>RECORDED BY</th></tr>";
$link_address = 'https://xxxx.gov.uk/LFT/?chronoform=Change_Pharmacy_Main_Form&gpage=Main_Form';
oci_execute($stid);
while (($emp = oci_fetch_array($stid, OCI_BOTH)) != false) {
$CheckDate = $emp['DATERECORDED'];
$mydate = date_create($CheckDate)->format('d-M-y');
//echo 'My Date - ',$mydate.'<br>';
$threshold = date('Y-m-d', strtotime("-5 days"));
$threshold = date_create($threshold)->format('d-M-y');
//echo 'Threshold - ',$threshold.'<br>';
$value = $threshold - $mydate;
//echo 'Value - ',$value.'<br>';
If ($value < '-5' || $value > '0') {
echo "<tr>";
//echo 'This data is greater than 5 days old!';
}
else{
echo "<tr>";
echo "<td>"."<a href=$link_address&ref=".$emp['REFERENCE'].">".$emp['REFERENCE']."</a>"."</td>";
$this->set("OracleReference", $emp['REFERENCE']);
echo "<td>".$emp['SITEID']."</td>";
$this->set("OracleSiteID", $emp['SITEID']);
echo "<td>".$emp['SITENAME']."</td>";
$this->set("OracleSiteName", $emp['SITENAME']);
echo "<td>".$emp['DATERECORDED']."</td>";
$this->set("OracleDateRecorded", $emp['DATERECORDED']);
echo "<td>".$emp['WHATISYOURNAME']."</td>";
//echo "<td>".$emp['NUMBEROFPOSITIVELFTTESTS']."</td>";
//echo "<td>".$emp['NUMBEROFVOIDLFTTESTS']."</td>";
//echo "<td>".$emp['NUMBEROFNEGATIVELFTTESTS']."</td>";
//echo "<td>".$emp['NUMBEROFPEOPLETESTED']."</td>";
//echo "<td>".$emp['NUMBEROFPHARMACYSITESOPERATION']."</td>";
echo "</tr>";
}
}
echo "</table>";
?>
The code above is the submit part of the form. Here is where I can't get the link type submission working.
after either the lookup or the link the form then goes to the edit section of the form. Here is where I need a redirect back if the data is more than 5 days old code below
$stid = oci_parse($conn, $stmt);
oci_execute($stid);
while (($emp = oci_fetch_array($stid, OCI_BOTH)) != false) {
// Is the data more than 5 days old?
$CheckDate = $emp['DATERECORDED'];
//echo 'Date Recorded - ', $CheckDate.'<br>';
$mydate = date_create($CheckDate)->format('d-M-y');
//echo 'My Date - ',$mydate.'<br>';
$threshold = date('Y-m-d', strtotime("-5 days"));
$threshold = date_create($threshold)->format('d-M-y');
//echo 'Threshold - ', $threshold.'<br>';
$value = $threshold - $mydate;
echo 'Value - ',$value.'<br>';
If ($value < '-5' || $value > '0') {
echo 'This data is more than 5 days old'.'<br>'; //Maybe pass a var back to the submission part to show an error??
header( "Location: ?chronoform=Change_Pharmacy_Main_Form&gpage=Main_Form");// results in too many redirects error!!
}
else {
$this->set("OracleReference", $emp['REFERENCE']);
$this->set("OracleSiteID", $emp['SITEID']);
$this->set("OracleSiteName", $emp['SITENAME']);
$this->set("OracleWhatIsYourName", $emp['WHATISYOURNAME']);
$this->set("OracleDateRecorded", $emp['DATERECORDED']);
$this->set("OracleNumberPositive", $emp['NUMBEROFPOSITIVELFTTESTS']);
$this->set("OracleNumberVoid", $emp['NUMBEROFVOIDLFTTESTS']);
$this->set("OracleNumberNegative", $emp['NUMBEROFNEGATIVELFTTESTS']);
$this->set("OracleNumberInOperation", $emp['NUMBEROFPHARMACYSITESOPERATION']);
}
}
Can anyone please help me sort this out?