<?
    require("util.php3");
    DoTitle("ACME Party Balloons - Billing List");
    $sql = new MySQL_class;
    $sql->Create("churchil_demo");

    function TmpFunc() {
        global $sql;
        for ($i = 0; $i < $sql->rows; $i++) {
            $sql->Fetch($i);
            $id = $sql->data[ID];
            $fname = $sql->data[FirstName];
            $lname = $sql->data[LastName];
            $city = $sql->data[City];
            $state = $sql->data[State];
            $j = $i + 1;
            echo("<tr><td>$j</td>\n");
            echo("    <td><a href=\"attendee-edit.php3?ID=$id\">$fname $lname</a>\n");
            echo("        of $city, $state</td></tr>\n");
        }
    }

    $num1 = $sql->QueryItem("select count(ID) from ACME_Attendee where Paid = 'Y'");
    $num2 = $sql->QueryItem("select count(ID) from ACME_Attendee where Paid = 'N' and PaymentType = 'BillMe'");
    $num3 = $sql->QueryItem("select count(ID) from ACME_Attendee where Paid = 'N' and PaymentType != 'BillMe' and PaymentType != 'PayAtShow'");
    $num4 = $sql->QueryItem("select count(ID) from ACME_Attendee where Paid = 'N' and PaymentType = 'PayAtShow'");
    $num5 = $sql->QueryItem("select count(ID) from ACME_Attendee where Paid = 'P'");
?>

<center>
<h2>Billing List</h2>

<table border=1 cellpadding=5>
<tr><th colspan=2 bgcolor="#ffaaaa">Summary</th></tr>
<tr><th><?echo($num1)?></th><td>people have paid.</td></tr>
<tr><th><?echo($num2)?></th><td>people need to be billed.</td></tr>
<tr><th><?echo($num3)?></th><td>people need to have their credit card charged.</td></tr>
<tr><th><?echo($num4)?></th><td>people will pay at the seminar.</td></tr>
<tr><th><?echo($num5)?></th><td>people with payment pending</td></tr>
<tr><th colspan=2 bgcolor="#ffaaaa">To Be Billed</th></tr>
<?
    $sql->Query("select * from ACME_Attendee where Paid = 'N' and PaymentType = 'BillMe'");
    TmpFunc();
?>
<tr><th colspan=2 bgcolor="#ffaaaa">Credit Card Charges</th></tr>
<?
    $sql->Query("select * from ACME_Attendee where Paid = 'N' and PaymentType != 'BillMe' and PaymentType != 'PayAtShow'");
    TmpFunc();
?>
<tr><th colspan=2 bgcolor="#ffaaaa">Will Pay at Seminar</th></tr>
<?
    $sql->Query("select * from ACME_Attendee where Paid = 'N' and PaymentType = 'PayAtShow'");
    TmpFunc();
?>
<tr><th colspan=2 bgcolor="#ffaaaa">Payment Pending</th></tr>
<?
    $sql->Query("select * from ACME_Attendee where Paid = 'P'");
    TmpFunc();
?>
</table>

<?
    include("footer.php3");
?>
