[Gnucash-changes] r13071 - gnucash/trunk - Allow specification of
invoice sub-type when creating search dialog (#117354)
Derek Atkins
warlord at cvs.gnucash.org
Wed Feb 1 17:57:31 EST 2006
Author: warlord
Date: 2006-02-01 17:57:30 -0500 (Wed, 01 Feb 2006)
New Revision: 13071
Trac: http://svn.gnucash.org/trac/changeset/13071
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/business/business-gnome/dialog-customer.c
gnucash/trunk/src/business/business-gnome/dialog-employee.c
gnucash/trunk/src/business/business-gnome/dialog-invoice.c
gnucash/trunk/src/business/business-gnome/dialog-job.c
gnucash/trunk/src/business/business-gnome/dialog-order.c
gnucash/trunk/src/business/business-gnome/dialog-vendor.c
gnucash/trunk/src/gnome-search/dialog-search.c
gnucash/trunk/src/gnome-search/dialog-search.h
gnucash/trunk/src/gnome/dialog-find-transactions.c
Log:
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.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/ChangeLog 2006-02-01 22:57:30 UTC (rev 13071)
@@ -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 at ihtfp.com>
* configure.in: include gmodule in GLIB_LIBS
Modified: gnucash/trunk/src/business/business-gnome/dialog-customer.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-customer.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/business/business-gnome/dialog-customer.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -832,7 +832,7 @@
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 *
Modified: gnucash/trunk/src/business/business-gnome/dialog-employee.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-employee.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/business/business-gnome/dialog-employee.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -727,7 +727,7 @@
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 *
Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -2185,38 +2185,118 @@
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 */
if (columns == NULL) {
@@ -2250,21 +2330,35 @@
* 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 @@
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 *
Modified: gnucash/trunk/src/business/business-gnome/dialog-job.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-job.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/business/business-gnome/dialog-job.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -590,7 +590,7 @@
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 */
Modified: gnucash/trunk/src/business/business-gnome/dialog-order.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-order.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/business/business-gnome/dialog-order.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -883,7 +883,8 @@
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 *
Modified: gnucash/trunk/src/business/business-gnome/dialog-vendor.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-vendor.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/business/business-gnome/dialog-vendor.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -694,7 +694,7 @@
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 *
Modified: gnucash/trunk/src/gnome/dialog-find-transactions.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-find-transactions.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/gnome/dialog-find-transactions.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -170,7 +170,7 @@
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);
Modified: gnucash/trunk/src/gnome-search/dialog-search.c
===================================================================
--- gnucash/trunk/src/gnome-search/dialog-search.c 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/gnome-search/dialog-search.c 2006-02-01 22:57:30 UTC (rev 13071)
@@ -88,6 +88,7 @@
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 @@
/* 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 @@
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 @@
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 @@
sw = gnc_search_dialog_create (GNC_ID_SPLIT, params, display,
NULL, NULL, buttons, NULL, NULL, NULL, NULL,
- NULL);
+ NULL, NULL);
}
Modified: gnucash/trunk/src/gnome-search/dialog-search.h
===================================================================
--- gnucash/trunk/src/gnome-search/dialog-search.h 2006-02-01 22:38:41 UTC (rev 13070)
+++ gnucash/trunk/src/gnome-search/dialog-search.h 2006-02-01 22:57:30 UTC (rev 13071)
@@ -82,7 +82,12 @@
*
* 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 @@
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);
More information about the gnucash-changes
mailing list