[eluser]the_unforgiven[/eluser]
I need to know the best why to convert all of this to Active record stuff and split into controllers and models then produce PDF output, I already have dompdf installed and running on something else, but this is mashing my head I cant get my head round it and some of you pros out there should be able to help me within a matters of minutes.
Code:
<?php
date_default_timezone_set("UTC");
$autokey = $this->uri->segment(3);
$code=$_POST['code'];
echo "<table border='0' cellspacing='2'>";
for ($i = 1; $i < $code; $i++)
{
//Variable Variable Names!
$meetingDate = $_POST['Date'];
${"hours{$i}"}=$_POST['hours'.$i];//current agency code
${"minutes{$i}"}=$_POST['minutes'.$i];//current agency code
$meetingtime = ${"hours{$i}"}.":".${"minutes{$i}"};
$time = strtotime( $meetingtime );
$mytime = date( 'H:i', $time );
${"AgencyCode{$i}"}=$_POST['AgencyCode'.$i];//current agency code
${"CustCode{$i}"}=$_POST['CustCode'.$i];//current customer code
${"Books{$i}"}=$_POST['Books'.$i];//current book code
${"remarks{$i}"}=$_POST['remarks'.$i];//Remarks for current meeting
${"cuttings{$i}"}=$_POST['cuttings'.$i];//Cuttings for current meeting
$Agencyquery = "SELECT `Company` FROM `tblclients` WHERE `AutoKey` = '".${"AgencyCode{$i}"}."'";
$Agencyresult = mysql_query($Agencyquery);
while ($Agency_array = mysql_fetch_assoc($Agencyresult))
{
echo "<tr><td><b>Agent: ".$Agency_array['Company']."</b><p>"; //Print out the agency the following books are for
$Custquery = "SELECT `Company` FROM `tblclients` WHERE `AutoKey` = '".${"CustCode{$i}"}."'";
$Custresult = mysql_query($Custquery);
echo "Meeting occured on the ". $meetingDate." at ". $meetingtime. "</td></tr><p>";
echo "<tr><td>";
while ($Cust_array = mysql_fetch_assoc($Custresult))
{
echo "<u>Customer: ".$Cust_array['Company']."</tr></u><p>";
echo "<td>Remarks: ". ${"remarks{$i}"}."<p>";//remarks for agency
echo "Cuttings: ". ${"cuttings{$i}"}."<p>";//cuttings for agency
}
echo "<b>Books:</b><p>";
}
if (${"Books{$i}"})
{
foreach (${"Books{$i}"} as $B)
{
$Bookquery = "SELECT BookName, Cost, AgencyID FROM `tblbook` WHERE `BookID` = '".$B."'";
$Bookresult = mysql_query($Bookquery);
while ($Book_array = mysql_fetch_assoc($Bookresult))
{
echo $Book_array['BookName']." @ £";//now know AgencyID for each book
printf(".2f\n", $Book_array['Cost']);
echo "<p>";
}
}
}
echo "</tr></td>";
}
echo "</table>";
?>
Need the above changing to CI active record stuff if any one can re-do this for me
Any takers? If you can do it free great if not buyt know you can do it and it wont take you long I'll gladly send some beer vouchers(£,$) for you!