mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Allow specification of invoice sub-type when creating search dialog (#117354)
* src/gnome-search/dialog-search.c: * src/gnome-search/dialog-search.h: Modify the gnc_search_dialog_create() API to add an optional "type label" parameter, so you can manually set the string presented to the user for what they are searching for... * src/business/business-gnome/dialog-order.c: * src/business/business-gnome/dialog-vendor.c: * src/business/business-gnome/dialog-customer.c: * src/business/business-gnome/dialog-job.c: * src/business/business-gnome/dialog-employee.c: * src/gnome/dialog-find-transactions.c: Pass NULL into new search API parameter * src/business/business-gnome/dialog-invoice.c: Modify how we call the search dialog. Send in different sets of parameters depending on whether we're searching for a Customer Invoice, Vendor Bill, or Employee Expense Voucher. Pass in a type_label as well so the dialog can properly label the "new" button. This fixes the UI Bug #117354. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13071 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
19
ChangeLog
19
ChangeLog
@@ -12,6 +12,25 @@
|
||||
don't re-sort on the initial setting of the date).
|
||||
Fixes #320566.
|
||||
|
||||
* src/gnome-search/dialog-search.c:
|
||||
* src/gnome-search/dialog-search.h:
|
||||
Modify the gnc_search_dialog_create() API to add an optional
|
||||
"type label" parameter, so you can manually set the string
|
||||
presented to the user for what they are searching for...
|
||||
* src/business/business-gnome/dialog-order.c:
|
||||
* src/business/business-gnome/dialog-vendor.c:
|
||||
* src/business/business-gnome/dialog-customer.c:
|
||||
* src/business/business-gnome/dialog-job.c:
|
||||
* src/business/business-gnome/dialog-employee.c:
|
||||
* src/gnome/dialog-find-transactions.c:
|
||||
Pass NULL into new search API parameter
|
||||
* src/business/business-gnome/dialog-invoice.c:
|
||||
Modify how we call the search dialog. Send in different
|
||||
sets of parameters depending on whether we're searching for
|
||||
a Customer Invoice, Vendor Bill, or Employee Expense Voucher.
|
||||
Pass in a type_label as well so the dialog can properly label
|
||||
the "new" button. This fixes the UI Bug #117354.
|
||||
|
||||
2006-01-31 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* configure.in: include gmodule in GLIB_LIBS
|
||||
|
||||
@@ -832,7 +832,7 @@ gnc_customer_search (GncCustomer *start, GNCBook *book)
|
||||
return gnc_search_dialog_create (type, params, columns,
|
||||
q, q2, buttons, NULL,
|
||||
new_customer_cb, sw, free_userdata_cb,
|
||||
GCONF_SECTION_SEARCH);
|
||||
GCONF_SECTION_SEARCH, NULL);
|
||||
}
|
||||
|
||||
GNCSearchWindow *
|
||||
|
||||
@@ -727,7 +727,7 @@ gnc_employee_search (GncEmployee *start, GNCBook *book)
|
||||
return gnc_search_dialog_create (type, params, columns, q, q2,
|
||||
buttons, NULL, new_employee_cb,
|
||||
sw, free_employee_cb,
|
||||
GCONF_SECTION_SEARCH);
|
||||
GCONF_SECTION_SEARCH, NULL);
|
||||
}
|
||||
|
||||
GNCSearchWindow *
|
||||
|
||||
@@ -2185,37 +2185,117 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, GNCBook *book)
|
||||
GNCIdType type = GNC_INVOICE_MODULE_NAME;
|
||||
struct _invoice_select_window *sw;
|
||||
QueryNew *q, *q2 = NULL;
|
||||
static GList *params = NULL;
|
||||
GncOwnerType owner_type = GNC_OWNER_CUSTOMER;
|
||||
static GList *inv_params = NULL, *bill_params = NULL, *emp_params = NULL;
|
||||
static GList *columns = NULL;
|
||||
static GNCSearchCallbackButton buttons[] = {
|
||||
static GNCSearchCallbackButton inv_buttons[] = {
|
||||
{ N_("View/Edit Invoice"), edit_invoice_cb},
|
||||
{ N_("Process Payment"), pay_invoice_cb},
|
||||
{ NULL },
|
||||
};
|
||||
static GNCSearchCallbackButton bill_buttons[] = {
|
||||
{ N_("View/Edit Bill"), edit_invoice_cb},
|
||||
{ N_("Process Payment"), pay_invoice_cb},
|
||||
{ NULL },
|
||||
};
|
||||
static GNCSearchCallbackButton emp_buttons[] = {
|
||||
{ N_("View/Edit Voucher"), edit_invoice_cb},
|
||||
{ N_("Process Payment"), pay_invoice_cb},
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
g_return_val_if_fail (book, NULL);
|
||||
|
||||
/* Build parameter list in reverse order */
|
||||
if (params == NULL) {
|
||||
params = gnc_search_param_prepend (params, _("Invoice Owner"), NULL, type,
|
||||
INVOICE_OWNER, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Invoice Notes"), NULL, type,
|
||||
INVOICE_NOTES, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Billing ID"), NULL, type,
|
||||
INVOICE_BILLINGID, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Is Paid?"), NULL, type,
|
||||
INVOICE_IS_PAID, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Date Posted"), NULL, type,
|
||||
INVOICE_POSTED, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Is Posted?"), NULL, type,
|
||||
INVOICE_IS_POSTED, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Date Opened"), NULL, type,
|
||||
INVOICE_OPENED, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Company Name "), NULL, type,
|
||||
INVOICE_OWNER, OWNER_PARENT,
|
||||
OWNER_NAME, NULL);
|
||||
params = gnc_search_param_prepend (params, _("Invoice ID"), NULL, type,
|
||||
INVOICE_ID, NULL);
|
||||
if (inv_params == NULL) {
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Invoice Owner"), NULL, type,
|
||||
INVOICE_OWNER, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Invoice Notes"), NULL, type,
|
||||
INVOICE_NOTES, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Billing ID"), NULL, type,
|
||||
INVOICE_BILLINGID, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Is Paid?"), NULL, type,
|
||||
INVOICE_IS_PAID, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Date Posted"), NULL, type,
|
||||
INVOICE_POSTED, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Is Posted?"), NULL, type,
|
||||
INVOICE_IS_POSTED, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Date Opened"), NULL, type,
|
||||
INVOICE_OPENED, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Company Name "), NULL, type,
|
||||
INVOICE_OWNER, OWNER_PARENT,
|
||||
OWNER_NAME, NULL);
|
||||
inv_params = gnc_search_param_prepend (inv_params,
|
||||
_("Invoice ID"), NULL, type,
|
||||
INVOICE_ID, NULL);
|
||||
}
|
||||
if (bill_params == NULL) {
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Bill Owner"), NULL, type,
|
||||
INVOICE_OWNER, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Bill Notes"), NULL, type,
|
||||
INVOICE_NOTES, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Billing ID"), NULL, type,
|
||||
INVOICE_BILLINGID, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Is Paid?"), NULL, type,
|
||||
INVOICE_IS_PAID, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Date Posted"), NULL, type,
|
||||
INVOICE_POSTED, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Is Posted?"), NULL, type,
|
||||
INVOICE_IS_POSTED, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Date Opened"), NULL, type,
|
||||
INVOICE_OPENED, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Company Name "), NULL, type,
|
||||
INVOICE_OWNER, OWNER_PARENT,
|
||||
OWNER_NAME, NULL);
|
||||
bill_params = gnc_search_param_prepend (bill_params,
|
||||
_("Bill ID"), NULL, type,
|
||||
INVOICE_ID, NULL);
|
||||
}
|
||||
if (emp_params == NULL) {
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Voucher Owner"), type,
|
||||
INVOICE_OWNER, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Voucher Notes"), NULL, type,
|
||||
INVOICE_NOTES, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Billing ID"), NULL, type,
|
||||
INVOICE_BILLINGID, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Is Paid?"), NULL, type,
|
||||
INVOICE_IS_PAID, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Date Posted"), NULL, type,
|
||||
INVOICE_POSTED, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Is Posted?"), NULL, type,
|
||||
INVOICE_IS_POSTED, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Date Opened"), NULL, type,
|
||||
INVOICE_OPENED, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Employee Name "), NULL, type,
|
||||
INVOICE_OWNER, OWNER_PARENT,
|
||||
OWNER_NAME, NULL);
|
||||
emp_params = gnc_search_param_prepend (emp_params,
|
||||
_("Voucher ID"), NULL, type,
|
||||
INVOICE_ID, NULL);
|
||||
}
|
||||
|
||||
/* Build the column list in reverse order */
|
||||
@@ -2250,21 +2330,35 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, GNCBook *book)
|
||||
* match on <supplied-owner's guid> == Invoice->Owner->GUID or
|
||||
* Invoice->owner->parentGUID.
|
||||
*/
|
||||
if (owner && gncOwnerGetGUID (owner)) {
|
||||
q2 = gncQueryCreate ();
|
||||
gncQueryAddGUIDMatch (q2, g_slist_prepend
|
||||
(g_slist_prepend (NULL, QUERY_PARAM_GUID),
|
||||
INVOICE_OWNER),
|
||||
gncOwnerGetGUID (owner), QUERY_OR);
|
||||
if (owner) {
|
||||
GncOwner *tmp = owner;
|
||||
|
||||
gncQueryAddGUIDMatch (q2, g_slist_prepend
|
||||
(g_slist_prepend (NULL, OWNER_PARENTG),
|
||||
INVOICE_OWNER),
|
||||
gncOwnerGetGUID (owner), QUERY_OR);
|
||||
/* First, figure out the type of owner here.. */
|
||||
owner_type = gncOwnerGetType(owner);
|
||||
while (owner_type == GNC_OWNER_JOB) {
|
||||
tmp = gncOwnerGetEndOwner(tmp);
|
||||
owner_type = gncOwnerGetType(tmp);
|
||||
}
|
||||
|
||||
gncQueryMergeInPlace (q, q2, QUERY_AND);
|
||||
gncQueryDestroy (q2);
|
||||
q2 = gncQueryCopy (q);
|
||||
/* Then if there's an actual owner (and not just a type)
|
||||
* then add it to the query and limit the search to this owner
|
||||
*/
|
||||
if (gncOwnerGetGUID (owner)) {
|
||||
q2 = gncQueryCreate ();
|
||||
gncQueryAddGUIDMatch (q2, g_slist_prepend
|
||||
(g_slist_prepend (NULL, QUERY_PARAM_GUID),
|
||||
INVOICE_OWNER),
|
||||
gncOwnerGetGUID (owner), QUERY_OR);
|
||||
|
||||
gncQueryAddGUIDMatch (q2, g_slist_prepend
|
||||
(g_slist_prepend (NULL, OWNER_PARENTG),
|
||||
INVOICE_OWNER),
|
||||
gncOwnerGetGUID (owner), QUERY_OR);
|
||||
|
||||
gncQueryMergeInPlace (q, q2, QUERY_AND);
|
||||
gncQueryDestroy (q2);
|
||||
q2 = gncQueryCopy (q);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -2287,10 +2381,25 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, GNCBook *book)
|
||||
sw->book = book;
|
||||
sw->q = q;
|
||||
|
||||
return gnc_search_dialog_create (type, params, columns, q, q2,
|
||||
buttons, NULL, new_invoice_cb,
|
||||
sw, free_invoice_cb, GCONF_SECTION_SEARCH);
|
||||
|
||||
return gnc_search_dialog_create (type,
|
||||
(owner_type == GNC_OWNER_VENDOR ?
|
||||
bill_params :
|
||||
(owner_type == GNC_OWNER_EMPLOYEE ?
|
||||
emp_params :
|
||||
inv_params)),
|
||||
columns, q, q2,
|
||||
(owner_type == GNC_OWNER_VENDOR ?
|
||||
bill_buttons :
|
||||
(owner_type == GNC_OWNER_EMPLOYEE ?
|
||||
emp_buttons :
|
||||
inv_buttons)),
|
||||
NULL, new_invoice_cb,
|
||||
sw, free_invoice_cb, GCONF_SECTION_SEARCH,
|
||||
(owner_type == GNC_OWNER_VENDOR ?
|
||||
_("Bill") :
|
||||
(owner_type == GNC_OWNER_EMPLOYEE ?
|
||||
_("Expense Voucher") :
|
||||
_("Invoice"))));
|
||||
}
|
||||
|
||||
GNCSearchWindow *
|
||||
|
||||
@@ -590,7 +590,7 @@ gnc_job_search (GncJob *start, GncOwner *owner, GNCBook *book)
|
||||
return gnc_search_dialog_create (type, params, columns,
|
||||
q, q2, buttons, NULL,
|
||||
new_job_cb, sw, free_userdata_cb,
|
||||
GCONF_SECTION_SEARCH);
|
||||
GCONF_SECTION_SEARCH, NULL);
|
||||
}
|
||||
|
||||
/* Functions for widgets for job selection */
|
||||
|
||||
@@ -883,7 +883,8 @@ gnc_order_search (GncOrder *start, GncOwner *owner, GNCBook *book)
|
||||
|
||||
return gnc_search_dialog_create (type, params, columns, q, q2,
|
||||
buttons, NULL, new_order_cb,
|
||||
sw, free_order_cb, GCONF_SECTION_SEARCH);
|
||||
sw, free_order_cb, GCONF_SECTION_SEARCH,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GNCSearchWindow *
|
||||
|
||||
@@ -694,7 +694,7 @@ gnc_vendor_search (GncVendor *start, GNCBook *book)
|
||||
return gnc_search_dialog_create (type, params, columns, q, q2,
|
||||
buttons, NULL,
|
||||
new_vendor_cb, sw, free_vendor_cb,
|
||||
GCONF_SECTION_SEARCH);
|
||||
GCONF_SECTION_SEARCH, NULL);
|
||||
}
|
||||
|
||||
GNCSearchWindow *
|
||||
|
||||
@@ -88,6 +88,7 @@ struct _GNCSearchWindow {
|
||||
gboolean allow_clear;
|
||||
|
||||
/* What we're searching for, and how */
|
||||
const gchar * type_label;
|
||||
GNCIdTypeConst search_for;
|
||||
GNCSearchType grouping; /* Match Any, Match All */
|
||||
const QofParam * get_guid; /* Function to GetGUID from the object */
|
||||
@@ -766,7 +767,10 @@ gnc_search_dialog_init_widgets (GNCSearchWindow *sw)
|
||||
|
||||
/* Set the type label */
|
||||
label = glade_xml_get_widget (xml, "type_label");
|
||||
type_label = _(gncObjectGetTypeLabel (sw->search_for));
|
||||
if (sw->type_label)
|
||||
type_label = sw->type_label;
|
||||
else
|
||||
type_label = _(gncObjectGetTypeLabel (sw->search_for));
|
||||
gtk_label_set_text (GTK_LABEL (label), type_label);
|
||||
|
||||
/* Set the 'add criterion' button */
|
||||
@@ -899,7 +903,8 @@ gnc_search_dialog_create (GNCIdTypeConst obj_type, GList *param_list,
|
||||
GNCSearchResultCB result_callback,
|
||||
GNCSearchNewItemCB new_item_cb,
|
||||
gpointer user_data, GNCSearchFree free_cb,
|
||||
const gchar *gconf_section)
|
||||
const gchar *gconf_section,
|
||||
const gchar *type_label)
|
||||
{
|
||||
GNCSearchWindow *sw = g_new0 (GNCSearchWindow, 1);
|
||||
|
||||
@@ -923,6 +928,7 @@ gnc_search_dialog_create (GNCIdTypeConst obj_type, GList *param_list,
|
||||
sw->user_data = user_data;
|
||||
sw->free_cb = free_cb;
|
||||
sw->gconf_section = gconf_section;
|
||||
sw->type_label = type_label;
|
||||
|
||||
/* Grab the get_guid function */
|
||||
sw->get_guid = qof_class_get_parameter (sw->search_for, QOF_PARAM_GUID);
|
||||
@@ -1067,5 +1073,5 @@ gnc_search_dialog_test (void)
|
||||
|
||||
sw = gnc_search_dialog_create (GNC_ID_SPLIT, params, display,
|
||||
NULL, NULL, buttons, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,12 @@ typedef struct {
|
||||
*
|
||||
* The user_data becomes the property of the search dialog and will
|
||||
* be freed via the callback when the dialog is closed.
|
||||
*/
|
||||
*
|
||||
* the type_label (if non-null) is the TRANSLATED string to use for
|
||||
* the type of object being searched. This will be put in the Title
|
||||
* as well as into the "New" button. If this string is NULL then
|
||||
* the dialog will use the obj_type instead.
|
||||
*/
|
||||
GNCSearchWindow *
|
||||
gnc_search_dialog_create (GNCIdTypeConst obj_type, GList *param_list,
|
||||
GList *display_list,
|
||||
@@ -91,7 +96,8 @@ gnc_search_dialog_create (GNCIdTypeConst obj_type, GList *param_list,
|
||||
GNCSearchResultCB result_callback,
|
||||
GNCSearchNewItemCB new_item_cb,
|
||||
gpointer user_data, GNCSearchFree free_user_data,
|
||||
const gchar *gconf_section);
|
||||
const gchar *gconf_section,
|
||||
const gchar *type_label);
|
||||
|
||||
void gnc_search_dialog_destroy (GNCSearchWindow *sw);
|
||||
void gnc_search_dialog_raise (GNCSearchWindow *sw);
|
||||
|
||||
@@ -170,7 +170,7 @@ gnc_ui_find_transactions_dialog_create(GNCLedgerDisplay * orig_ledg)
|
||||
|
||||
ftd->sw = gnc_search_dialog_create (type, params, NULL, start_q, show_q,
|
||||
NULL, do_find_cb, NULL,
|
||||
ftd, free_ftd_cb, GCONF_SECTION);
|
||||
ftd, free_ftd_cb, GCONF_SECTION, NULL);
|
||||
|
||||
if (!ftd->sw) {
|
||||
free_ftd_cb (ftd);
|
||||
|
||||
Reference in New Issue
Block a user