24 #include "gncIDSearch.h"
34 static void * search(
QofBook * book,
const gchar *
id,
void *
object, GncSearchType type);
46 gnc_search_customer_on_id (
QofBook * book,
const gchar *
id)
49 GncSearchType type = CUSTOMER;
50 customer = (
GncCustomer*)search(book,
id, customer, type);
55 gnc_search_invoice_on_id (
QofBook * book,
const gchar *
id)
58 GncSearchType type = INVOICE;
59 invoice = (
GncInvoice*)search(book,
id, invoice, type);
65 gnc_search_bill_on_id (
QofBook * book,
const gchar *
id)
68 GncSearchType type = BILL;
69 bill = (
GncInvoice*)search(book,
id, bill, type);
74 gnc_search_vendor_on_id (
QofBook * book,
const gchar *
id)
77 GncSearchType type = VENDOR;
78 vendor = (
GncVendor*)search(book,
id, vendor, type);
87 static void * search(
QofBook * book,
const gchar *
id,
void *
object, GncSearchType type)
95 PINFO(
"Type = %d", type);
96 g_return_val_if_fail (type, NULL);
97 g_return_val_if_fail (
id, NULL);
98 g_return_val_if_fail (book, NULL);
104 string_pred_data = qof_query_string_predicate (QOF_COMPARE_EQUAL,
id, QOF_STRING_MATCH_NORMAL, FALSE);
105 if (type == CUSTOMER)
108 qof_query_add_term (q, qof_query_build_param_list(
"CUSTOMER_ID"), string_pred_data, QOF_QUERY_AND);
110 else if (type == INVOICE || type == BILL)
113 qof_query_add_term (q, qof_query_build_param_list(
"INVOICE_ID"), string_pred_data, QOF_QUERY_AND);
115 else if (type == VENDOR)
118 qof_query_add_term (q, qof_query_build_param_list(
"VENDOR_ID"), string_pred_data, QOF_QUERY_AND);
126 len = g_list_length (result);
127 if (result && (len > 0))
129 result = g_list_first (result);
135 if (type == CUSTOMER && strcmp(
id, gncCustomerGetID(c)) == 0)
141 else if (type == INVOICE && strcmp(
id, gncInvoiceGetID(c)) == 0
142 && gncInvoiceGetType(c) == GNC_INVOICE_CUST_INVOICE)
147 else if (type == BILL && strcmp(
id, gncInvoiceGetID(c)) == 0
148 && gncInvoiceGetType(c) == GNC_INVOICE_VEND_INVOICE)
153 else if (type == VENDOR && strcmp(
id, gncVendorGetID(c)) == 0)
158 result = g_list_next (result);
void qof_query_add_term(QofQuery *query, QofQueryParamList *param_list, QofQueryPredData *pred_data, QofQueryOp op)
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
#define PINFO(format, args...)
struct _QofQuery QofQuery
void qof_query_destroy(QofQuery *q)
void qof_query_set_book(QofQuery *q, QofBook *book)
GList * qof_query_run(QofQuery *query)
QofQuery * qof_query_create(void)
void qof_query_search_for(QofQuery *query, QofIdTypeConst obj_type)
const gchar * QofLogModule