static void gnc_ui_to_job (JobWindow *jw, GncJob *job) { gnc_suspend_gui_refresh (); gncJobBeginEdit (job); qof_event_gen(QOF_INSTANCE(job), QOF_EVENT_ADD, NULL); gncJobSetID (job, gtk_editable_get_chars (GTK_EDITABLE (jw->id_entry), 0, -1)); gncJobSetName (job, gtk_editable_get_chars (GTK_EDITABLE (jw->name_entry), 0, -1)); gncJobSetReference (job, gtk_editable_get_chars (GTK_EDITABLE (jw->desc_entry), 0, -1)); gncJobSetActive (job, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (jw->active_check))); { GncOwner * old = gncJobGetOwner (job); gnc_owner_get_owner (jw->cust_edit, &(jw->owner)); if (! gncOwnerEqual (old, &(jw->owner))) gncJobSetOwner (job, &(jw->owner)); } gncJobCommitEdit (job); gnc_resume_gui_refresh (); }
static xmlNodePtr job_dom_tree_create (GncJob *job) { xmlNodePtr ret; ret = xmlNewNode(NULL, BAD_CAST gnc_job_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST job_version_string); xmlAddChild(ret, guid_to_dom_tree(job_guid_string, qof_instance_get_guid (QOF_INSTANCE (job)))); xmlAddChild(ret, text_to_dom_tree(job_id_string, gncJobGetID (job))); xmlAddChild(ret, text_to_dom_tree(job_name_string, gncJobGetName (job))); maybe_add_string (ret, job_reference_string, gncJobGetReference (job)); xmlAddChild(ret, gnc_owner_to_dom_tree (job_owner_string, gncJobGetOwner (job))); xmlAddChild(ret, int_to_dom_tree(job_active_string, gncJobGetActive (job))); return ret; }
JobWindow * gnc_ui_job_edit (GncJob *job) { JobWindow *jw; if (!job) return NULL; jw = gnc_job_new_window (gncJobGetBook(job), gncJobGetOwner(job), job); return jw; }
const GncOwner * gncOwnerGetEndOwner (const GncOwner *owner) { if (!owner) return NULL; switch (owner->type) { case GNC_OWNER_NONE: case GNC_OWNER_UNDEFINED: default: return NULL; case GNC_OWNER_CUSTOMER: case GNC_OWNER_VENDOR: case GNC_OWNER_EMPLOYEE: return owner; case GNC_OWNER_JOB: return gncJobGetOwner (owner->owner.job); } }
GNCSearchWindow * gnc_job_search_select (gpointer start, gpointer book) { GncJob *j = start; GncOwner owner, *ownerp; if (!book) return NULL; if (j) { ownerp = gncJobGetOwner (j); gncOwnerCopy (ownerp, &owner); } else gncOwnerInitCustomer (&owner, NULL); /* XXX */ return gnc_job_search (start, &owner, book); }
gnc_commodity * gncOwnerGetCurrency (const GncOwner *owner) { if (!owner) return NULL; switch (owner->type) { case GNC_OWNER_NONE: case GNC_OWNER_UNDEFINED: default: return NULL; case GNC_OWNER_CUSTOMER: return gncCustomerGetCurrency (owner->owner.customer); case GNC_OWNER_VENDOR: return gncVendorGetCurrency (owner->owner.vendor); case GNC_OWNER_EMPLOYEE: return gncEmployeeGetCurrency (owner->owner.employee); case GNC_OWNER_JOB: return gncOwnerGetCurrency (gncJobGetOwner (owner->owner.job)); } }
GNCSearchWindow * gnc_job_search (GncJob *start, GncOwner *owner, QofBook *book) { QofQuery *q, *q2 = NULL; QofIdType type = GNC_JOB_MODULE_NAME; struct _job_select_window *sw; static GList *params = NULL; static GList *columns = NULL; static GNCSearchCallbackButton buttons[] = { { N_("View/Edit Job"), edit_job_cb, NULL, TRUE}, { N_("View Invoices"), invoice_job_cb, NULL, TRUE}, { N_("Process Payment"), payment_job_cb, NULL, FALSE}, { NULL }, }; g_return_val_if_fail (book, NULL); /* Build parameter list in reverse order */ if (params == NULL) { params = gnc_search_param_prepend (params, _("Owner's Name"), NULL, type, JOB_OWNER, OWNER_NAME, NULL); params = gnc_search_param_prepend (params, _("Only Active?"), NULL, type, JOB_ACTIVE, NULL); params = gnc_search_param_prepend (params, _("Billing ID"), NULL, type, JOB_REFERENCE, NULL); params = gnc_search_param_prepend (params, _("Job Number"), NULL, type, JOB_ID, NULL); params = gnc_search_param_prepend (params, _("Job Name"), NULL, type, JOB_NAME, NULL); } /* Build the column list in reverse order */ if (columns == NULL) { columns = gnc_search_param_prepend (columns, _("Billing ID"), NULL, type, JOB_REFERENCE, NULL); columns = gnc_search_param_prepend (columns, _("Company"), NULL, type, JOB_OWNER, OWNER_NAME, NULL); columns = gnc_search_param_prepend (columns, _("Job Name"), NULL, type, JOB_NAME, NULL); columns = gnc_search_param_prepend (columns, _("ID #"), NULL, type, JOB_ID, NULL); } /* Build the queries */ q = qof_query_create_for (type); qof_query_set_book (q, book); /* If we have a start job but, for some reason, not an owner -- grab * the owner from the starting job. */ if ((!owner || !gncOwnerGetGUID (owner)) && start) owner = gncJobGetOwner (start); /* If owner is supplied, limit all searches to invoices who's owner * is the supplied owner! Show all invoices by this owner. */ if (owner && gncOwnerGetGUID (owner)) { qof_query_add_guid_match (q, g_slist_prepend (g_slist_prepend (NULL, QOF_PARAM_GUID), JOB_OWNER), gncOwnerGetGUID (owner), QOF_QUERY_AND); q2 = qof_query_copy (q); } #if 0 if (start) { if (q2 == NULL) q2 = qof_query_copy (q); qof_query_add_guid_match (q2, g_slist_prepend (NULL, QOF_PARAM_GUID), gncJobGetGUID (start), QOF_QUERY_AND); } #endif /* launch select dialog and return the result */ sw = g_new0 (struct _job_select_window, 1); if (owner) { gncOwnerCopy (owner, &(sw->owner_def)); sw->owner = &(sw->owner_def); } sw->book = book; sw->q = q; return gnc_search_dialog_create (type, _("Find Job"), params, columns, q, q2, buttons, NULL, new_job_cb, sw, free_userdata_cb, GCONF_SECTION_SEARCH, NULL); }