#
#
#
#
#
#
#
require "settings.php";
require "libs/ext.lib.php";
require_lib("validate");
if (isset($_GET['addcontact'])) {
    $OUTPUT = AddContact($_GET);
    $OUTPUT .= printCust($_GET);
} else {
    # show current stock
    $OUTPUT = printCust($_GET);
}
require "template.php";
# show stock
function printCust($_GET)
{
    # get vars
    foreach ($_GET as $key => $value) {
        ${$key} = $value;
    }
    if (isset($filter) && !isset($all)) {
        $sqlfilter = " AND lower({$filter}) LIKE lower('%{$fval}%')";
        $show = true;
    } else {
        $filter = "";
        $fval = "";
#
#
#
#
#
#
#
require "settings.php";
require "libs/ext.lib.php";
require_lib("validate");
if (isset($_GET['addcontact'])) {
    $OUTPUT = AddContact();
    $OUTPUT .= printCust();
} else {
    # show current stock
    $OUTPUT = printCust();
}
require "template.php";
# show stock
function printCust()
{
    # Set up table to display in
    $printCust = "\r\n\t\t\t\t\t<center>\r\n\t\t\t\t\t<h3>Current Customers</h3>\r\n\t\t\t\t\t<table border='1' cellpadding='3' cellspacing='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<th>Department</th>\r\n\t\t\t\t\t\t\t<th>Acc no.</th>\r\n\t\t\t\t\t\t\t<th>Surname/Company</th>\r\n\t\t\t\t\t\t\t<th>Business Tel</th>\r\n\t\t\t\t\t\t\t<th>Home Tel</th>\r\n\t\t\t\t\t\t\t<th>Category</th>\r\n\t\t\t\t\t\t\t<th>Classification</th>\r\n\t\t\t\t\t\t\t<th>Balance</th>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t";
    # Query server
    $tot = 0;
    $i = 0;
    # connect to database
    db_connect();
    $sql = "SELECT cusnum,deptname,accno,surname,bustel,tel,catname,classname FROM customers WHERE div = '" . USER_DIV . "' OR  ddiv = '" . USER_DIV . "' ORDER BY accno ASC";
    $custRslt = db_exec($sql) or errDie("Unable to retrieve Customers from database.");
    if (pg_numrows($custRslt) < 1) {
function export()
{
    $OUT = clean_html(printCust());
    require_lib("xls");
    StreamXLS("CustomerList", $OUT);
}