1 (edited by poncho1234 10/13/2018 04:56:41 pm)

Topic: Additional Fields Extension

This is my first full extension, so it’s a learning process for me.

I originally created this for myself to satisfy the demands of my local tax authority, but realised with changes that it could be useful for other FA users. I’m willing to make changes should anyone have suggestions that would benefit a reasonable number of users.

I’ve added additional fields for customers/suppliers and items (CIS), which other users may find beneficial; also adding four ‘custom fields’ to each, the name of which you would change using a translation.  The custom fields can also be used for ‘niche’ users who wish to add info that is fairly specific for their business. Eg. A book seller could add ‘Author’, ‘Publisher’, etc. in items.

Currently the extra fields are integrated into the existing CIS pages, the maintenance links are in the supplier’s module and the reports are in their relevant reports pages. Though this integration could be changed to a separate module as I originally intended to do this and still have the code.

The ext is currently work in progress so therefore is not ready for production and I would welcome any help, suggestions or comments.

[del]Three[/del]Four reports so far:-
1.    Item stock check plus bin number
2.    Full customer listing with additional field info – excel download only
3.    Full supplier listing with additional field info – excel download only
4.    Full item listing with additional field info – excel download only

Todo:-
1.    [del] Bug as referenced in this post (Should this be irrevocable, then I will rewrite ext. as a separate module.) [/del] This appears to be working in the demo, maybe was a localhost dev issue????
2.    Security codes: For development I used notrinos's codes from his HRM module, but when I changed to my own codes, I had no access??
3.    [del]Report - full item listing with additional field info – excel download only[/del] Done
4.    Code review.
5.    [del] Check text strings are enabled for translation [/del] - Done
6.    Put custom fields in separate columns for customer/supplier reports
7.    [del]Change Spanish labels to English[/del] Done
8.    Update sql & Remove sql notworking - Possible fix below
9.    [del]Dates not being saved[/del] - Done, added date2sql to update item function

Possible discussion points for future development
1.    Inquiry report X 3 for each of CIS
2.    Additional fields for customer branches.
3.    Additional integration with FA core
4.    Countries, departments, and cities. This data is unlikely to change once the user has entered their locale, should this be included in the database or as a lookup file? Bulk upload? Is this info necessary given the existing Address text box? I included as needed for myself
5.    Manage custom field names (Instead of using a translation)

Demo is here
Username: demouser
Password: 12345678

Code is here

Post's attachments

AddlFields_Screenshots.zip 144.8 kb, 4 downloads since 2018-10-10 

You don't have the permssions to download the attachments of this post.

2 (edited by poncho1234 10/11/2018 10:46:39 pm)

Re: Additional Fields Extension

I may have solution to my number 8 bug

I noticed when installing/uninstalling that the path for 'module name' was /add_fields_item/. I then noticed that I didn't actually have a module called additional_fields.

So I have added a module additional_fields and moved the maintenance pages to there, my abbreviated updated hooks.php is now as follows:-

<?php

define('SS_ADDFLD_C',141<<8); // configuration
define('SS_ADDFLD',  142<<8); // transactions
define('SS_ADDFLD_A',143<<8); // analytic functions/reports/inquires

class add_fields_sales_app extends application {
    
    function __construct() {
        global $path_to_root;
        
        parent::__construct('orders', _($this->help_context = '&Sales'));
        
        //All Sales functions as per core with the following changed for Add and Manage &Customers

        $this->add_lapp_function(2, _("Add and Manage &Customers"),
            "/modules/additional_fields/manage/add_customers.php?", 'SA_CUSTOMER', MENU_ENTRY);
        
    }
}

class add_fields_supp_app extends application {
    
    function __construct() {
        global $path_to_root;
        
        parent::__construct('AP', _($this->help_context = '&Purchases'));
        
        //All Purchases functions as per core with the following changed for Suppliers ie Removed add fields maintenance

            $this->add_lapp_function(2, _("&Suppliers"),
            "/modules/additional_fields/manage/add_suppliers.php?", 'SA_SUPPLIER', MENU_ENTRY);
    }
}

class add_fields_item_app extends application {
    
    function __construct() {
        global $path_to_root;
        
        parent::__construct('stock', _($this->help_context = '&Items and Inventory'));
        
        //All Items & Inventory functions as per core with the following changed for Items

        $this->add_lapp_function(2, _("&Items"),
            "/modules/additional_fields/manage/add_items.php?", 'SA_ITEM', MENU_ENTRY);
        
    }
}
// New module added
class additional_fields_app extends application {
    
    function __construct() {
        global $path_to_root;
        
        parent::__construct('AddFields', _($this->help_context = 'Additional Fields'));
        
        $this->add_module(_('Maintenance'));
        $this->add_rapp_function(2, _('Manage Document Types'), $path_to_root.'/modules/additional_fields/manage/document_types.php?', 'SA_SUPPLIER', MENU_MAINTENANCE);
        $this->add_rapp_function(2, _('Manage Beneficiary Classes'), $path_to_root.'/modules/additional_fields/manage/customer_class.php?', 'SA_SUPPLIER', MENU_MAINTENANCE);
        $this->add_rapp_function(2, _('Manage Countries'), '/modules/additional_fields/manage/country.php?', 'SA_AFSETUP', MENU_MAINTENANCE);
        $this->add_rapp_function(2, _('Manage Departments'), $path_to_root.'/modules/additional_fields/manage/department_add_info.php?', 'SA_SUPPLIER', MENU_MAINTENANCE);
        $this->add_rapp_function(2, _('Manage Cities'), $path_to_root.'/modules/additional_fields/manage/city_add_info.php?', 'SA_SUPPLIER', MENU_MAINTENANCE);
        $this->add_rapp_function(2, _('Manage Sectors'), $path_to_root.'/modules/additional_fields/manage/sectors_add_info.php?', 'SA_SUPPLIER', MENU_MAINTENANCE);
        $this->add_extensions();
    }
}

class hooks_additional_fields extends hooks {
    function __construct() {
     $this->module_name = 'add_fields_sales';
        $this->module_name = 'add_fields_supp';
        $this->module_name = 'add_fields_item';
        $this->module_name = 'additional_fields';//NEW
     }
    
    function install_tabs($app) {
        $app->add_application(new add_fields_sales_app);
        $app->add_application(new add_fields_supp_app);
        $app->add_application(new add_fields_item_app);
        $app->add_application(new additional_fields_app);//NEW
    }
    
    function install_access() {
        $security_sections[SS_ADDFLD_C] =  _("Additional Fields Configuration");
        $security_sections[SS_ADDFLD] =  _("Additional Transactions");
        $security_sections[SS_ADDFLD_A] =  _("Additional Fields Analytics");
        $security_areas['SA_XFLD'] = array(SS_ADDFLD|1, _("AddFields entry"));
        $security_areas['SA_AFSETUP'] = array(SS_ADDFLD_C|2, _("AddFields setup3"));
        // $security_areas['SA_AFSETUP'] = array(SS_PURCH|9, _("AddFields setup2"));
        return array($security_areas, $security_sections);
    }

    function activate_extension($company, $check_only=true) {
        global $db_connections;
        
        $updates = array( 'update.sql' => array('frontadd'));
 
        return $this->update_databases($company, $updates, $check_only);
    }
    
    function deactivate_extension($company, $check_only=true) {
        global $db_connections;

        $updates = array('remove.sql' => array('frontadd'));

        return $this->update_databases($company, $updates, $check_only);
    }
}

Update sql & Remove sql now work

I've not updated the demo or repro yet as would like to wait for any comments or alternative solution where an additional tab is not necessary

No solution to security issues even with above changes and a clean install.

@apmuthu I'm guessing it was you who added the screenshots - Thank you

Re: Additional Fields Extension

I think you are asking access role problem here. I don't think to go separate role for extra fields. Just keep them as of custom types page security. And for creation of customer fields. You can use settings roles.

Hope it helps to reduce your security access problem