Topic: Event listeners API

Hi all,
Is there some even listener method that one can create a plugin that does some stuffs such as wehn the application is loading  etc.

2 (edited by apmuthu 12/31/2012 09:37:01 am)

Re: Event listeners API

Hooks and Hook Activate.

Read the /includes/hooks.class.inc file.

Extend / modify the hooks class in it to have pre-load, post-load functions and activate them in appropriate places in the header.inc / footer.inc files in the includes/page folder.

In fact the includes/pages/header.inc file includes a JS function in the body onload attribute passed thru the function page_header() 's parameter list and used in line 136.
access/logout.phpincludes/page/ and in includes/main.inc files only. The latter calls it in it's function page().

All other pages that call the page function generally use only the first parameter (page title), but in your pages of choice, you can include the other parameters. The primitive for usage can be taken from the function constructs in the files referred to above.

Re: Event listeners API

Thanks for your reply, I'll try and get my head round it. Actually am trying to have the system check for Journal entries in a remote table and have them entered into FA. This should be happening when the system loads, it checks whether there are any entries and then imports them, just like the CSV version, but this should read from a Database table instead of csv file.

4 (edited by apmuthu 12/31/2012 10:49:35 pm)

Re: Event listeners API

If I understand your needs, you have an offline database table containing Journal Entries that need to be sucked into the FA system when it is used for the first time in a day (or in specific time period) or on demand.

This is easily achieved using a function that kicks in thru includes/main.inc.

You can also build a standalone script that reads what the remote journal entry last voucher number is and checks with the local FA system of last imported remote voucher number (reference number) to decide if an update is in order and does the import of the recent records only.

The standalone script can be scheduled to be exectuted at whatever frequency necessary thru a cron job.

If the remote journal entries exist in another FrontAccounting Server, then use any RESTful API like the SimpleAPI.

Re: Event listeners API

Thanks again for your reply,
please note, the remote journal entries are not in a Frontaccounting DB, that's why am building a function that will read it on every system load and pull any new entries into current Fronaccounting. What I don't understand, besides inserting records into 0_gl_trans are there other table that needs updated on every journal entry.

Also observing the journal table, there are fields such as counter,type,type_no,person_type_id that I don't know how to get whatever info that goes into them.

Thanks

Re: Event listeners API

1. Take a SQL dump of the FA db.
2. Manually add one journal transaction in FA that you would normally have imported from the remote db.
3. Take a second SQL Dump
4. Compare the changes from the first to the second SQL dump in an utility like WinMerge2
5. You can now see what tables have been affected: The sequence number table for the journal transactions, the transaction details itself, possibly some log tables that can rither be ignored or made to have a single entry that logs the summary of the whole import (when imported).