3,826

(1 replies, posted in Setup)

@joe: Can pull it in from my repo.

@joe: any pointers on the "official" way to get FA to drop tables created by extensions when they get deactivated for a specific company?

The $hooks->deactivate_extension() is not being called anywhere in FA and hence the drop.sql is not being executed when an extension is deactivated. The Ajax on the Web UI just looks after the tick mark in the checkbox and removes the entry in the $installed extensions arrays in the installed_extensions.php files.

Even if $check_only = false;, the $ok fails the test in function update_databases() in includes/hooks.inc as the function check_table() called in it and defined in admin/db/maintenance_db.inc as:

function check_table($pref, $table, $field=null, $properties=null)
{
    $tables = @db_query("SHOW TABLES LIKE '".$pref.$table."'");
    if (!db_num_rows($tables))
        return 1;        // no such table or error

    $fields = @db_query("SHOW COLUMNS FROM ".$pref.$table);
    if (!isset($field)) 
        return 0;        // table exists

    while( $row = db_fetch_assoc($fields)) 
    {
        if ($row['Field'] == $field) 
        {
            if (!isset($properties)) 
                return 0;
            foreach($properties as $property => $value) 
            {
                if ($row[$property] != $value) 
                    return 3;    // failed type/length check
            }
            return 0; // property check ok.
        }
    }
    return 2; // field not found
}

attempts to evaluate $fields = SHOW COLUMNS FROM... even when there is no $field argument available when dropping tables during deactivate_extensions! Hence the said function should be corrected to be:

function check_table($pref, $table, $field=null, $properties=null)
{
    $tables = @db_query("SHOW TABLES LIKE '".$pref.$table."'");
    if (!db_num_rows($tables))
        return 1;        // no such table or error

    if (!isset($field)) 
        return 0;        // table exists
    $fields = @db_query("SHOW COLUMNS FROM ".$pref.$table);

    while( $row = db_fetch_assoc($fields)) 
    {
        if ($row['Field'] == $field) 
        {
            if (!isset($properties)) 
                return 0;
            foreach($properties as $property => $value) 
            {
                if ($row[$property] != $value) 
                    return 3;    // failed type/length check
            }
            return 0; // property check ok.
        }
    }
    return 2; // field not found
}

Please confirm it being a fix.

3,830

(0 replies, posted in Setup)

Listing all FA files ending in multiple newlines:

$ find -type f -exec sh -c '[ -z "$(sed -n "\$p" "$1")" ] && echo "$1"' _ {} \;

./access/logout.php
./doc/2.2_Beta.txt
./doc/access_levels.txt
./doc/calculate_price.txt
./doc/CHANGELOG.old.txt
./doc/license.txt
./gl/inquiry/balance_sheet.php
./gl/inquiry/gl_trial_balance.php
./includes/db/sql_functions.inc
./install/lang/ar_EG/LC_MESSAGES/ar_EG.po
./install/lang/da_DK/LC_MESSAGES/da_DK.po
./install/lang/de_DE/LC_MESSAGES/de_DE.po
./install/lang/el_GR/LC_MESSAGES/el_GR.po
./install/lang/es_MX/LC_MESSAGES/es_MX.po
./install/lang/fr_FR/LC_MESSAGES/fr_FR.po
./install/lang/id_ID/LC_MESSAGES/id_ID.po
./install/lang/it_IT/LC_MESSAGES/it_IT.po
./install/lang/ka_GE/LC_MESSAGES/ka_GE.po
./install/lang/new_language_template/LC_MESSAGES/empty.po
./install/lang/nl_BE/LC_MESSAGES/nl_BE.po
./install/lang/pl_PL/LC_MESSAGES/pl_PL.po
./install/lang/pt_BR/LC_MESSAGES/pt_BR.po
./install/lang/pt_PT/LC_MESSAGES/pt_PT.po
./install/lang/sv_SE/LC_MESSAGES/sv_SE.po
./install/lang/zh_CN/LC_MESSAGES/zh_CN.po
./js/JsHttpRequest.js
./manufacturing/view/wo_issue_view.php
./manufacturing/view/wo_production_view.php
./purchasing/po_receive_items.php
./sales/inquiry/sales_deliveries_view.php
./sql/alter.sql
./sql/alter2.1.sql
./sql/en_US-new.sql
./taxes/db/tax_groups_db.inc

These excess newlines can be removed for atleast those files other than docs/*.* and *.po files.

3,831

(1 replies, posted in Setup)

A look at tmp/error.log in FA (on XAMPP in Windows) will show:

0::logout.php:50: session_destroy() [<a href='function.session-destroy'>function.session-destroy</a>]: Session object destruction failed

each time one logs out.

This is because session_destroy() is attempted after a session_unset() in access/logout.php - the "@" notwithstanding. If this is required for some installations, then the following can replace the last 2 statements in it:

session_unset();
if (session_id() != '') session_destroy();

For PHP 5.4+, use the following:

session_unset();
if (session_status() == PHP_SESSION_ACTIVE) session_destroy();

The variable $no_check_edit_conflicts can now be removed from FA and the file sales/includes/sales_ui.inc can have it's last function:

function check_edit_conflicts($cartname='Items')
{
    global $Ajax, $no_check_edit_conflicts;

    if ((!isset($no_check_edit_conflicts) || $no_check_edit_conflicts==0) && get_post('cart_id') && $_POST['cart_id'] != $_SESSION[$cartname]->cart_id) {
        display_error(_('This edit session has been abandoned by opening sales document in another browser tab. You cannot edit more than one sales document at once.'));
        $Ajax->activate('_page_body');
        display_footer_exit();
    }
}

changed to:

function check_edit_conflicts($cartname='Items')
{
    global $Ajax;

    if (!empty($_SESSION[$cartname]->cart_id) && get_post('cart_id') && $_POST['cart_id'] != $_SESSION[$cartname]->cart_id) {
        display_error(_('This edit session has been abandoned by opening sales document in another browser tab. You cannot edit more than one sales document at once.'));
        $Ajax->activate('_page_body');
        display_footer_exit();
    }
}

Steps to check in a fresh FA v2.3 install on Windows XAMPP using en_US-demo.sql:
Sales => Direct Invoice => Customer => Ghostbusters
No error should crop up.

3,833

(3 replies, posted in Setup)

Any Updates?

You can put in the Address in the Comments for now.

Another solution would be to make a Cash Customer and keep editing their address in it before choosing it in Direct Invoice each time.

3,835

(3 replies, posted in Setup)

Check if you have the file C:\xampp\htdocs\account\sales\includes\cart_class.inc.
If so, then try to hardcode the path into line 23 of C:\xampp\htdocs\account\sales\sales_order_entry.php like:

include_once("C:/xampp/htdocs/account/sales/includes/cart_class.inc");

and report the results.

Also state what menu sequence of clicks lead to such a situation.

First, close all browser instances, clear browser cache and try it - only if it fails should you need to try the above.

Have a Salary Account where the $113/- Salary+Taxes of all Musicians are debited and the respective musicians accounts get credited with 89.5% (100-2-8.5) of the salaries whilst 8.5% gets credited to the Pension Plan Account and 2% gets credited to the Musicians Union Account. Also credit the GST payable Account with 5% and credit the PST Payable Account with 8%. All of this can be a single Journal Voucher probably made for each week / month / event.

Unless you have PayRoll module made and customised for your needs (Musicians payout rates, etc), QuickEntries would be a cludge of a substitute, a tad better than making a set of direct SQL executions generated from some spreadsheet (=CONCATENATE("INSERT INTO...) and possibly programmed into a trigger in MySQL. PM me for assistance in implementing the latter.

Raising a Supplier (Govt Body, Pension plans, etc) Invoice for services (withheld tax/deductions) and settlement under normal means would qualify as a Standard Operating Procedure in FA. Recurrent Invoices will need editing amounts....

3,837

(2 replies, posted in Accounts Receivable)

Wikied under FAQs.

Wiki-ed it.

Checked out the 3rd company with the above credentials - you're pretty competent to get it done yourself. Open a GitHub account and post your extensions there so that the community can assist you in coding and testing as well. Also you may want to upgrade to v2.3.24+ from the v2.3.22 you are using (136 files in 48 folders have changed).

It is possible to make all Reference fields in new element forms to be readonly. The attached screenshots are for making just one form (Direct Invoice) or all forms to have their Reference field as non-editable.

Apart from being defined in includes/ui/ui_input.inc, there are 17 files that use the function ref_row - once each. The said function is currently not used in any standard extension.

Placed on Wiki.

The before and after depiction of the code changes suggested for pass 1 of the function synch is attached herein.

3,842

(5 replies, posted in Dimensions)

Dimensions are generally used for cost centres. Try Tags first before using dimensions - these are just for groups of transactions pertaining to a specific deal.

It remains sticky for the nice discussions in it and it being a work-in-progress for FA 2.4.

3,844

(7 replies, posted in Setup)

Wiki-ed it.

The same could have been achieved easily with a flag based readonly attribute in the input tag.

I have re-factored the includes/ui/ui_input.inc 's text_cells and text_cells_ex functions to have the same argument names and bunching similar code for ease of understanding before the inclusion of the $inparams in the latter function where the readonly can be inserted. This will also server to clarify the code.

The real solution will be to have a flag in the sys_prefs table that removes the field altogether and in the processing script acquires the next reference and then populates the tables, showing the end result in the browser.

Short of creating an extension for your extended CRM needs with a 1:1 table mapped to an existing branch/person FA table, the non field db data method "abusing" large fields like notes will be the "documented" way out.

Use a permanent holding table (managed externally with the likes of Adminer or phpMyEdit) or a spreadsheet for your separate fields and combine them into the large FA field each time anything changes!

Wikied it.

3,848

(7 replies, posted in Setup)

When companies are deleted out of order as is in practice, finding a missing prefix in the array would clash with possible non numeric table prefixes and the possiblility of restoring from a deleted company into it's original prefix.

When a new company is created, an entry is made in the config_db.php table for it. This entry contains the prefix to be used and the key for the entry need not be the same as the prefix used.

1. Create your 3 companies anew so you have 0 (Default), 1,2,3 companies.
2. Note down the config_db.php entries (backup the file).
3. Delete company with prefix 1_.
4. The entry for the company "1" is removed from the config_db.php file
5. The value of the variable $tb_pref_counter in the config_db.php will signal the next prefix - alter it as needed even temporarily so as to create your company "1" again and then revert back.

The function save_next_reference defined in includes/db/references_db.inc just saves the given reference to the table without any increment using:

function save_next_reference($type, $reference)
{
    $sql = "UPDATE ".TB_PREF."sys_types SET next_reference=" . db_escape(trim($reference)) 
        . " WHERE type_id = ".db_escape($type);

    db_query($sql, "The next transaction ref for $type could not be updated");
}

The above function is called from admin/forms_setup.php to post the form variables just as is into the sys_types table.

The file includes/references.inc has defined the (class references) methods save() and restore_last() which first increment or decrement and then call the above function.

Hence in the file @kvvaradha referred to - manufacturing/includes/db/work_orders_db.inc - the save() method does not need any increment in the argument.

Furthermore, the import_transactions extension has a redundant line 250 in modules/import_transactions/import_transactions.php

           save_next_reference($type, $reference);

Hence nothing needs to be done in the FA codebase for now.

3,850

(7 replies, posted in Setup)

Are you trying to create all the companies using the same database? Only if you have a separate database for each company, can you choose whatever prefix you want for each company. Any companies you delete can also have them removed from the config_db.php file as well.