1 (edited by p2409 09/08/2013 07:38:52 am)

Topic: User configurable 'days past' setting for inquiry screens: here's how

FA currently uses a default hard-coded '30' days in the past setting for all inquiry screens.I have created some instructions for changing this to a user setting (transaction_days) so you can set this up for each user. This is useful if your company transactions are low-volume and you want to see more than 30 days in the past in your inquiry screens.

Note to Joe/Itronics: I put this as a suggested update on the Wiki for you to consider in the next version. Let me know if I've got the design of this wrong (I've tried to keep the design of the mod consistent with the architecture of FA), but it's a fairly simple change to make.

New User Configurable Transaction days setting by Pete p2409.
-------------------------------------------------------------

Currently, FA uses a hard-coded default 30 days in the past setting for transaction display screens
eg. ifyou do a GL inquiry, the default is to display dates from today to 30 days ago.
With a new user-configurable 'transaction_days' setting, you can now set this to a default number 
you choose eg. 365 to always display the last year's instead of month's transactions.
With this change, the default 'From' date on inquiry screens will be the setting you made
eg. -365 days from now.

To achieve this, we add a new global setting 'transaction_days' and look up this setting in
all inquiry screens that previously had a hardcoded 30 days.

(Note the setting is a positive number, made negative to go back in the past in the inquiry screens
with a minus sign).

CHANGES TO CODE/TABLE
---------------------

1) Create new 'Transaction days' setting in preferences screen:

In ./admin/display_prefs.php

Around line 37

FROM:
        set_user_prefs(get_post( 
            array('prices_dec', 'qty_dec', 'rates_dec', 'percent_dec',
            'date_format', 'date_sep', 'tho_sep', 'dec_sep', 'print_profile', 
            'theme', 'page_size', 'language', 'startup_tab',
            'show_gl' => 0, 'show_codes'=> 0, 'show_hints' => 0,
            'rep_popup' => 0, 'graphic_links' => 0, 'sticky_doc_date' => 0,
            'query_size' => 10.0)));

TO:
// Add transaction days configurable.            
        set_user_prefs(get_post( 
            array('prices_dec', 'qty_dec', 'rates_dec', 'percent_dec',
            'date_format', 'date_sep', 'tho_sep', 'dec_sep', 'print_profile', 
            'theme', 'page_size', 'language', 'startup_tab',
            'show_gl' => 0, 'show_codes'=> 0, 'show_hints' => 0,
            'rep_popup' => 0, 'graphic_links' => 0, 'sticky_doc_date' => 0,
            'query_size' => 10.0, 'transaction_days' => 30)));
            
Around line 142 after:

check_row(_("Remember last document date:"), 'sticky_doc_date', sticky_doc_date(),
    false, _('If set document date is remembered on subsequent documents, otherwise default is current date'));

ADD:

text_row_ex(_("Transaction days:"), 'transaction_days', 5, 5, '', user_transaction_days());


2) Update user preferences to add new transaction_days global variable.

In ./includes/prefs/userprefs.inc

Around line 38:
ADD:
    var $transaction_days;

Around line 54 after:
            $this->theme = 'default';
ADD:
            $this->transaction_days = -30;
Around line 91 (in the else block)
AFTER:
            else
            {
                $this->sticky_date = 0;
                $this->startup_tab = "orders";
            }

ADD:
            $this->transaction_days = $user['transaction_days'];

Around line 127:
ADD:
    function transaction_days() {
        return $this->transaction_days;
    }

3) Update current user settings with new user_transaction_days function:

Around line 312
ADD:
function user_transaction_days()
{
    return $_SESSION["wa_current_user"]->prefs->transaction_days();
}


4) Modify all inquiry screens to use new 'Transaction Days' setting:

In all inquiry screens (do a global search on '30' to find them all):
./gl/inquiry/bank_inquiry.php
./gl/inquiry/gl_account_inquiry.php
./gl/inquiry/gl_trial_balance.php
./gl/inquiry/profit_loss.php
./gl/inquiry/tax_inquiry.php
./gl/view/accrual_trans.php
./inventory/inquiry/stock_movements.php
./purchasing/includes/ui/invoice_ui.inc
./purchasing/inquiry/po_search.php
./purchasing/inquiry/po_search_completed.php
./purchasing/inquiry/supplier_allocation_inquiry.php
./purchasing/inquiry/supplier_inquiry.php
./sales/inquiry/customer_allocation_inquiry.php
./sales/inquiry/customer_inquiry.php
./sales/inquiry/sales_deliveries_view.php
./sales/inquiry/sales_orders_view.php

Example for bank inquiry: ./gl/inquiry/bank_inquiry.php

Around line 50:

CHANGE:
date_cells(_("From:"), 'TransAfterDate', '', null, -30);

TO:
date_cells(_("From:"), 'TransAfterDate', '', null, -$_SESSION["wa_current_user"]->prefs->transaction_days());

Do this for each inquiry screen file


5) SQL update x_users table with new 'transaction_days' column:

ALTER TABLE `0_users` ADD `transaction_days` INT( 6 ) NOT NULL COMMENT 'Transaction days'

(Note: use your company number eg. 0_, 1_ etc to update for each company).

Re: User configurable 'days past' setting for inquiry screens: here's how

This is a great suggestion. Will be included in release 2.4.

/Joe

Re: User configurable 'days past' setting for inquiry screens: here's how

thank you for this Pete, this is exactly what I need; I was getting frustrated by the 30 search

Re: User configurable 'days past' setting for inquiry screens: here's how

When making this change, please also make the end date for inquiries configurable. I find it useful to set the end date for bank inquiries to 30 days in the future instead of today, because I enter scheduled payments in advance, and it helps to manage cash flow.
Thanks