Page 1 of 1

admin function to view user logs (name,type,date and time)

Posted: Sat May 05, 2012 2:20 am
by viddz
I want build up administrator function to view user logs. Actually my intention here is to give admin opportunity to view who (user) is responsible for particular system activity like update stock, add new item etc... I got idea that if admin can view user logs (logs must contain username,type, date and time) then he can interpret who is responsible for that. Is there any good way to do that thing ?? Appreciate ur ideas.

Re: admin function to view user logs (name,type,date and time)

Posted: Sat May 05, 2012 12:27 pm
by Saman
I want build up administrator function to view user logs. Actually my intention here is to give admin opportunity to view who (user) is responsible for particular system activity like update stock, add new item etc... I got idea that if admin can view user logs (logs must contain username,type, date and time) then he can interpret who is responsible for that. Is there any good way to do that thing ?? Appreciate ur ideas.

In general inventory systems, this is a must have feature. Normally there is a separate table created as system_log or something and whenever someone logs in, from there onwards, all activity are logged until log-out. I'll list down some valuable fields.

| Entry_Date | Username | Activity | Description |

Entry_date is a date/time field. So exact time needs to be there along with date as well.
Activity is some common definitions such as LOG_IN, LOG_OUT, NEW_ITEM_ENTRY, NEW_STOCK_ENTRY, STOCK_ITEM_NAME_ADJUST, STOCK_QTY_ADJUST, NEW_GRN_ENTRY, NEW_INOVICE_ENTRY.......

Description is to identify the exact detail. For example, if the Activity is NEW_ITEM_ENTRY, you could add item code.

Is there anything else you need to know?

Re: admin function to view user logs (name,type,date and time)

Posted: Sat May 05, 2012 1:34 pm
by viddz
ya.I got the concept. but still iam not clear how to code these things. System log should be kept without any input of user ne. That means automatically. I wonder how the code will look like? I have googled this but couldnt find an understandable code. If u have any links on this topic or some understandable codess pls put here. Thank u very much for ur helps saman. Iam refering u more than my supervisor. Really appreciate ur help thank u again

Re: admin function to view user logs (name,type,date and time)

Posted: Sat May 05, 2012 4:07 pm
by Saman
You are welcome buddy. That's the aim of ROBOT.LK. Help people like you to get on with technology matters and join the industry with confidence.

Okay.. regarding your question... As you said, yes users are not allowed to enter anything. It should be handled automatically by the code.

I'll add pseudo code of a scenario where a user adjust quantity of an item in stock.

Code: Select all

function Change_Quantity(user, i_code, old_quantity, new_quantity){

       // first adjust the stock record
       sql = "UPDATE stock_table SET quantity = new_quantity WHERE item_code = i_code";
       // execute the sql
       db_execute (sql);

        // Now add the log record
        sql = "INSERT INTO system_log VALUES(NOW(), user, "STOCK_QTY_ADJUST", i_code + " " + old_quantity + " " + new_quantity);
       // execute the sql
       db_execute (sql);
}
So you can notice in this case, at the time we adjust the stock record, we enter the log entry as well. I hope you now have a good picture.

Re: admin function to view user logs (name,type,date and time)

Posted: Sat May 05, 2012 4:58 pm
by viddz
Thank u. Now i got it :yahoo: :yahoo: