function statusArea($pdf, $area, $oid, $order, $customer, $items, $mapping, $pieces)
{
    $string = "<table><tr><td align=\"center\" colspan=\"3\"><strong>Status</strong></td></tr>";
    $string .= htmlOrderStatus($order);
    $string .= "<tr><td align=\"center\" colspan=\"3\"><strong>Order Notes</strong></td></tr>";
    $string .= "<tr><td colspan=\"3\">" . htmlNotesFormat($order["CustomerONotes"]) . "</td></tr>";
    $string .= "<tr><td colspan=\"3\"><em>" . htmlNotesFormat($order["AdminONotes"]) . "</em></td></tr>";
    $string .= "</table>";
    $pdf->SetFont('helvetica', '', 8, '', true);
    $pdf->SetFillColor(255, 255, 255);
    $pdf->SetTextColor(0, 0, 0);
    areaWriteHTMLCell($pdf, $area, "{$string}", 0, 0, true);
}
function orderStatusText($order)
{
    $retvalue = "";
    $retvalue .= "<table class=\"orderStatusContainer\"><tr><td>";
    $retvalue .= "<table class=\"orderStatus\">\n";
    $retvalue .= htmlOrderStatus($order);
    $retvalue .= "</table>\n";
    if ($order["Charity"] || $order["IsExpedited"]) {
        $retvalue .= "</td><td>";
        if ($order["Charity"]) {
            $retvalue .= standardIcon("charity");
        }
        if ($order["IsExpedited"]) {
            $retvalue .= standardIcon("expedite");
        }
    }
    $retvalue .= "</td></tr></table>\n";
    return $retvalue;
}
function main($oid, $pdflink)
{
    // a packing list has all of the standard stuff on it, including
    // the order number, customer, address, but no price information.
    // it combines multiple items into one NUMBERED item along with the
    // stuff that should go into it.  It also includes a field for
    // notes that then need to be transcribed to shipping.
    $order = dbGetOrder($oid);
    $items = getItems($oid);
    $mapping = dbGetPVP();
    $pieces = dbGetPieces();
    if (!$order) {
        echo "Can't find order {$oid}\n";
        return;
    }
    $customer = dbGetCustomer($order["CID"]);
    if (!$customer) {
        echo "Can't find customer for order {$oid}\n";
        return;
    }
    echo "<div align=\"right\"><font size=\"-2\"><a href=\"{$pdflink}?oid={$oid}\">PDF Version</a></font></div>\n";
    // the whole thing is one big table
    echo "<table class=\"packinglist\">\n";
    // first, the header with "Order: XXX"
    echo "<tr><td class=\"ordertitle\" colspan=\"3\">";
    if ($order["IsExpedited"]) {
        echo standardIcon("expedite") . "&nbsp;&nbsp;";
    }
    if ($order["Charity"]) {
        echo standardIcon("charity") . "&nbsp;&nbsp;";
    }
    echo "Order: <strong>{$oid}</strong>";
    if ($order["Charity"]) {
        echo "&nbsp;&nbsp;" . standardIcon("charity");
    }
    if ($order["IsExpedited"]) {
        echo "&nbsp;&nbsp;" . standardIcon("expedite");
    }
    echo "</td></tr>\n";
    // now paint the "To:" and "Status"
    echo "<tr><td width=\"50%\">\n";
    echo "<table><tr><td class=\"title\" colspan=\"2\"><strong>Customer</strong></td></tr>\n";
    echo htmlCustomerAddress($customer);
    echo "</table></td>\n";
    echo "<td width=\"50%\">\n";
    echo "<table><tr><td class=\"title\" colspan=\"3\"><strong>Status</strong></td></tr>\n";
    //     echo("<tr><td>");
    echo htmlOrderStatus($order);
    //     echo("</td></tr>");
    echo "<tr><td class=\"title\" colspan=\"3\"><strong>Order Notes</strong></td></tr>\n";
    echo "<tr><td colspan=\"3\">" . htmlNotesFormat($order["CustomerONotes"]) . "</td></tr>\n";
    echo "<tr><td colspan=\"3\"><em>" . htmlNotesFormat($order["AdminONotes"]) . "</em></td></tr>\n";
    echo "</table></td>\n";
    echo "</tr>\n";
    // the middle part of the packing list is the actual list of items and components
    echo "<tr><td colspan=2>\n";
    echo "<table class=\"packingItems\">\n";
    echo "<tr><td class=\"title\" colspan=\"3\"><strong>Shipment Items</strong></td></tr>\n";
    echo "<tr><td style=\"border-bottom:1px solid; text-align:center;\"><strong>Count</strong></td>";
    echo "<td style=\"border-bottom:1px solid;\" width=\"50%\"><strong>Item</strong></td>";
    echo "<td style=\"border-bottom:1px solid;\" ><strong>Notes</strong> <em><font size=-1>(include ChapR number(s) if applicable)</font></em></td</tr>\n";
    echo "<tr><td>&nbsp;</td></tr>\n";
    foreach ($items as $item) {
        echo "<tr>";
        echo "<td class=\"qty\">" . $item["Quantity"] . " x</td>";
        echo "<td><p class=\"itemtitle\">" . $item["Name"] . "</p>";
        echo "<UL>";
        if ($item["Personality"]) {
            echo "<LI>" . $item["Personality"] . "</LI>";
        }
        // now get all of the pieces in the package
        foreach ($mapping as $map) {
            if ($map["PKID"] == $item["PKID"]) {
                echo "<LI>" . findPieceName($map["PID"], $pieces) . "</LI>\n";
            }
        }
        echo "</UL></td>";
        echo "<td></td>";
        echo "</tr>";
    }
    echo "</table></td></tr>\n";
    // the bottom part of the packing list is the shipment note section
    echo "<tr><td colspan=2>\n";
    echo "<table class=\"packingShipping\">\n";
    echo "<tr><td class=\"title\" colspan=\"6\"><strong>Shipment Details</strong></td></tr>\n";
    echo "<tr>";
    echo "<td class=\"fieldName\">Date Shipped: </td><td class=\"field\"></td>\n";
    echo "<td class=\"fieldName\">Carrier: </td><td class=\"field\"></td>\n";
    echo "<td class=\"fieldName\">Tracking #: </td><td class=\"field\"></td>\n";
    echo "</tr>";
    echo "</table></td></tr>\n";
    echo "</table>\n";
}