ckroon
Posts: 869
|
| Posted: 02/16/2008, 6:43 PM |
|
Hello all.
Very proud newbie coder here. I needed to create a page where a school could figure out how much they owed families for ISP reimbursements. They wanted to have it display on a page so their bookkeeper could look up a family and what they are owed. There are two different rates depending upon grade and I had to do some date lookups to see if/when they enrolled or withdrew.
They NOW want this data to be saved to a table, so they can run reports and mail merge the totals to a check writing program.
So... I need to be able to transfer the FamilyID and Total fields to a database table.
My question (finally!) is...What is the most efficient way to do this? I am thinking of making an editable grid and have that save the data in a custom Update/Insert.. but wanted to know if I have other options.
Thanks! 
Below is the code from the Before Show Row event of the page...feel free to criticize or copy :)
//Explanation: sedate=school enrolled date, osdate=official start date, oedate=official end date, wdate=withdrawal.
The osdate and oedate are at the top of the grid in the BS event, pulled from a database table.
//set start date {d1}
if ($Container->sedate->GetValue() <= $Container->osdate->GetValue())
$Container->d1->SetValue( $Container->osdate->GetValue());//if enrolled prior to beg~ of term, set to beg~ of term
if ($Container->sedate->GetValue() > $Container->osdate->GetValue())
$Container->d1->SetValue( $Container->sedate->GetValue()); //if enrolled later, set to that later date
//set end date {d2}
if ($Container->wdate->GetValue() < $Container->oedate->GetValue())
$Container->d2->SetValue( $Container->wdate->GetValue()); // if withdrew prior to year end, set as withdrawal date
if ($Container->wdate->GetValue() >= $Container->oedate->GetValue())
$Container->d2->SetValue( $Container->oedate->GetValue()); //if withdrawal date was after the official end date,
set as official end date
//calculate difference between the two days
$NewGrid1->days->SetValue( (strtotime($NewGrid1->d2->GetText() ) -
strtotime($NewGrid1->d1->GetText() ) ) / (60 * 60 * 24) );
//set {rate} according to {grade}
$grade=$Container->grade->GetValue();
$k8 = 8;
$k = "K";
if ($grade<=$k8)
$Container->rate->SetValue (.44);
if ($grade>$k8)
$Container->rate->SetValue (.99);
if ($grade==$k)
$Container->rate->SetValue (.44);
//multiply {rate} times {days} = {total}
$NewGrid1->total->SetValue($NewGrid1->rate->GetValue() * $NewGrid1->days->GetValue() );
//set the date fields to display so user can see what dates are being used
$NewGrid1->startdate->SetValue($NewGrid1->d1->GetValue());
$NewGrid1->stopdate->SetValue($NewGrid1->d2->GetValue());
// -------------------------
//End Custom Code
_________________
Walter Kempees...you are dearly missed. |