Issue
- Ref: Forum Post
- FA currently uses a default hard-coded 30 days in the past setting for all inquiry screens.
- Here are some instructions for changing this to a user setting (transaction_days) to set this up for each user.
- Useful if company transactions are low-volume and you want to see more than 30 days in the past in your inquiry screens.
- With a new user-configurable transaction_days setting, it can now be set to any default number eg. 365 to always display the last year's instead of last month's transactions.
- With this change, the default From date on inquiry screens will be the setting chosen eg. -365 days from now.
- To achieve this, add a new global setting transaction_days and look up this setting in all inquiry screens that previously had a hardcoded 30 days.
- Note that this setting is a positive number, made negative to go back in the past in the inquiry screens with a minus sign.
Code Changes
- 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());
- 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; }
- 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(); }
- 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
Database Changes
- 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.
Useful Extendability
- Make the end date for inquiries configurable.
- It is useful to set the end date for bank inquiries to 30 days in the future instead of today, if one enters scheduled payments in advance and it helps to manage cash flow.