Example #1
0
$items_table = "{$cfg_tableprefix}" . 'items';
if (!$sec->isLoggedIn()) {
    header("location: ../login.php");
    exit;
}
$display->displayTitle("{$lang->newSale}");
if (empty($_SESSION['current_sale_customer_id'])) {
    $customers_table = "{$cfg_tableprefix}" . 'customers';
    if (isset($_POST['customer_search']) and $_POST['customer_search'] != '') {
        $search = $_POST['customer_search'];
        $_SESSION['current_customer_search'] = $search;
        $customer_result = mysql_query("SELECT first_name,last_name,account_number,id FROM {$customers_table} WHERE last_name like \"%{$search}%\" or first_name like \"%{$search}%\" or id =\"{$search}\" ORDER by last_name", $dbf->conn);
    } elseif (isset($_SESSION['current_customer_search'])) {
        $search = $_SESSION['current_customer_search'];
        $customer_result = mysql_query("SELECT first_name,last_name,account_number,id FROM {$customers_table} WHERE last_name like \"%{$search}%\" or first_name like \"%{$search}%\" or id =\"{$search}\" ORDER by last_name", $dbf->conn);
    } elseif ($dbf->getNumRows($customers_table) > 200) {
        $customer_result = mysql_query("SELECT first_name,last_name,account_number,id FROM {$customers_table} ORDER by last_name LIMIT 0,200", $dbf->conn);
    } else {
        $customer_result = mysql_query("SELECT first_name,last_name,account_number,id FROM {$customers_table} ORDER by last_name", $dbf->conn);
    }
    $customer_title = isset($_SESSION['current_customer_search']) ? "<b><font color='white'>{$lang->selectCustomer}: </font></b>" : "<font color='white'>{$lang->selectCustomer}: </font>";
    echo "<table align='center' cellpadding='2' cellspacing='2' bgcolor='{$table_bg}'>\n\t<form name='select_customer' action='sale_ui.php' method='POST'>\n\t<tr><td align='left'><font color='white'>{$lang->findCustomer}:</font>\n\t<input type='text' size='8' name='customer_search'>\n\t<input type='submit' value='Go'><a href='delete.php?action=customer_search'><font size='-1' color='white'>[{$lang->clearSearch}]</font></a>\n\t</form></td></tr>\n\t\n\t<form name='scan_customer' action='sale_ui.php' method='POST'>\n\t<tr><td align='left'>{$customer_title}<select name='customer_list' onChange=\"updateScanCustomerField()\";>";
    while ($row = mysql_fetch_assoc($customer_result)) {
        if ($cfg_numberForBarcode == "Row ID") {
            $id = $row['id'];
        } elseif ($cfg_numberForBarcode == "Account/Item Number") {
            $id = $row['account_number'];
        }
        echo $id;
        $display_name = $row['last_name'] . ', ' . $row['first_name'];
        echo "<option value={$id}>{$display_name}</option></center>";