<?php

/*
* Script: auto_complete_search.php
* 	Do the autocomplete of invoice id in the process payment page
*
* License:
*	 GPL v2 or above
*/

define("BROWSE","browse");
//if this page has error with auth remove the above line and figure out how to do it right

$SI_INVOICE_TYPE = new SimpleInvoices_Db_Table_InvoiceType();

$domain_id = domain_id::get();

#$sql = "SELECT * FROM ".TB_PREFIX."invoices where domain_id = ".$domain_id;

#global $dbh;
#$sth = dbQuery($sql) or die(htmlsafe(end($dbh->errorInfo())));

//$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit";
$invoice = new invoice();
$sth = $invoice->select_all();

$q = strtolower($_GET["q"]);
if (!$q) return;

while ($invoice = getInvoices($sth)) {
 public function getType()
 {
     $InvoiceTypes = new SimpleInvoices_Db_Table_InvoiceType();
     return $InvoiceTypes->getInvoiceType($this->_data['type_id']);
 }