LEDGER RECORD

", $foo); $foobar2 = eregi_replace("%%ITALIC", "", $foobar); $barfoo = eregi_replace("%ITALIC;", "", $foobar2); $barfoo2 = eregi_replace("%ITALIC", "", $barfoo); $blortfoo = eregi_replace("%eacute;", "é", $barfoo2); $blortfoo2 = eregi_replace("%lt;", "<", $blortfoo); $blortfoo3 = eregi_replace("%gt;", ">", $blortfoo2); $blortfoo4 = eregi_replace("%amp;", "&", $blortfoo3); $farble = eregi_replace("%plus;", "+", $blortfoo4); $finalCellContents = stripslashes($farble); switch ($colname) { case client: if ($j == 0) { $client = $finalCellContents; } break; case name_id: if ($j == 0) $name_id = $finalCellContents; break; case month: if ($j == 0) $month = $finalCellContents; break; case day: if ($j == 0) $day = $finalCellContents; break; case year: if ($j == 0) $year = $finalCellContents; break; case ledger_id: if ($j == 0) $ledger_id = $finalCellContents; break; case transaction_id: $transaction_id[$j] = $finalCellContents; break; case transaction_ledger_entry: $transaction_ledger_entry[$j] = $finalCellContents; break; case item_ledger_entry: $item_ledger_entry[$j] = $finalCellContents; break; case item_category: $item_category[$j] = $finalCellContents; break; case description: $description[$j] = $finalCellContents; break; case cost: $cost[$j] = $finalCellContents; $total_cost += $finalCellContents; break; } } $j++; } $full_name = getFullName($name_id); if (preg_match("/^[0-9]*\.[0-9][0-9]$/",$total_cost)) { } elseif (preg_match("/^[0-9]*\.[0-9]$/",$total_cost)) { $total_cost .= "0"; } elseif (!preg_match("/^[0-9]*\.00/",$total_cost)) { $total_cost .= ".00"; } echo "
Client: $client
Ledger #: $ledger_id
Date $month $day, $year
TOTAL COST: \$$total_cost

"; for ($cnt=0; $cnt<$j; $cnt++) { echo " "; } } } #### end of function display_sql_results #### ## End of all functions ## ########################################################################################### ## Begin body of script ## getSQL(); ## $ledgerID is passed on the URL by the user, on an HREF, or through ## another script, e.g.: ## http://mama.stg.brown.edu/projects/tirocchi/database/transact_db.php3?ledgerID=L0001 $query = "SELECT transz.ledger_id, transaction_id, transaction_ledger_entry, item_ledger_entry, item_category, description, cost, ledger.ledger_id, client, ledger.name_id, month, day, year FROM ledger, transz WHERE transz.ledger_id = '$ledgerID' and ledger.ledger_id = '$ledgerID'"; if ($query) { // Execute the SQL query here and display the results $result = runSQLQuery($query); if ($result) { display_sql_results ($result, $query, $card); } else { err_msg ("MySQL Error", "MySQL Error"); echo "\t

Query = ", $query, "

\n"; $query = ""; } } // There is no rhyme nor reason to the order or existence of // any given client/name_id in the ledger table, and further, // the IDs are non-numeric (they are e.g. 'L0287'), so there // the following is necessary in order to determine the "next" // and "previous" records for browsing. $query2 = "SELECT ledger_id, client, name_id, count(*) AS 'foo' FROM ledger GROUP BY name_id ORDER BY client"; $resultForBrowsing = runSQLQuery($query2); $numrows = mysql_num_rows ($resultForBrowsing); for ($counter=0; $counter<$numrows; $counter++) { $row = mysql_fetch_array ($resultForBrowsing); if ($counter == $numrows-1) { $next_id = $row[0]; } else { $prev_id = $curr_id; $curr_id = $row[0]; if ($curr_id == $ledgerID) { $numrows = $counter+2; } } } if ($ledgerID == $next_id) { $temp_id = $next_id; $next_id = ""; $prev_id = $curr_id; $curr_id = $temp_id; } #################################################################################### ?>
trans. # transaction (ledger) item (ledger) item category description cost
$transaction_id[$cnt] $transaction_ledger_entry[$cnt] $item_ledger_entry[$cnt] $item_category[$cnt] $description[$cnt] $cost[$cnt]

General Information about:

$full_name "; ?>


<< "; } ?> Browse Ledger Records >> "; } ?> Ledger List