Hi Janusz,

Thank you for your response. ^^

Currently, I use selenium for testing all the functionalities on my module. It satisfy me so far. The test runs automatically. Maybe you should use it too. smile

Hello everybody,

I made some extra modules to FA and I would like to test it using PHP unit. Any idea how to do this in FA? How does the development team usually do the test?

Thank you

3

(6 replies, posted in Setup)

Apple wrote:

Hi bhoo-day,

You are so great. The code really work as it is. It really save me a lot of time. Without your code, I have no way to accomplish it.
Thank you very much for your kindness to allow us to share the code with you.

You're welcome bro.

Glad if you can make it smile

4

(6 replies, posted in Setup)

Hi Apple,

I just made some modified lines in these files. Just add the modified lines into yours.

Just see the comment "MY CUSTOM CODE FOR ROLE NAME"
I couldn't share whole file because too long and it will make you confuse to read those a lot of lines smile

For current_user.inc (location at includes/current_user.inc)

class current_user
{
    var $user;
    var $loginname;
    var $username;
    var $name;
    var $company; // user's company
    var $pos;
    var $access;        
    var $timeout;
    var $last_act;
    var $role_set = false;
    var $old_db;
    var $logged;
    var $ui_mode = 0;
    
    var $prefs;
    var $cur_con; // current db connection (can be different from $company for superuser)
        
        /* custom */
        var $rolename; // MY CUSTOM CODE FOR ROLE NAME
        var $org_id;

    function current_user()
    {
        global $def_coy;
        
        $this->loginname = $this->username = $this->name = "";
        $this->company = isset($def_coy)? $def_coy : 0;
        $this->logged = false;

        $this->prefs = new user_prefs();
    }

    function logged_in()
    {
        return $this->logged;
    }

    function set_company($company)
    {
        $this->company = $company;
    }

    function login($company, $loginname, $password)
    {
        global $security_areas, $security_groups, $security_headings, $path_to_root;
        
        $this->set_company($company);
        $this->logged = false;

        $Auth_Result = get_user_for_login($loginname, $password);

        if (db_num_rows($Auth_Result) > 0)
        {
            $myrow = db_fetch($Auth_Result);
            $this->old_db = isset($myrow["full_access"]);
            if (! @$myrow["inactive"]) {
                if ($this->old_db) { 
                    // Transition code:
                    // db was not yet upgraded after source update to v.2.2
                    // give enough access for admin user to continue upgrade
                    if (!isset($security_groups) || !isset($security_headings)) {
                        echo "<center><br><br><font size='5' color='red'><b>";
                        echo _('Before software upgrade you have to include old $security_groups and $security_headings arrays from old config.php file to the new one.');
                        echo '<br>'."<a href=$path_to_root/index.php>"._("Back")."</a>";
                        echo "</b></font><br><br></center>";
                        exit;
                    }
                    $this->access = $myrow["full_access"];
                    if (in_array(20, $security_groups[$this->access]))
                        // temporary access for admin users
                        $this->role_set[] = $security_areas['SA_SOFTWAREUPGRADE'][0];
                    else {
                        echo "<center><br><br><font size='5' color='red'><b>";
                        echo _('System is available for site admin only until full database upgrade');
                        echo "</b></font><br><br></center>";
                        exit;
                    }
                } else {
                    $this->role_set = array();
                    $this->access = $myrow["role_id"];
                    // store area codes available for current user role
                    $role = get_security_role($this->access);
                    if (!$role) 
                        return false;
                    foreach( $role['areas'] as $code )
                        // filter only area codes for enabled security sections
                        if (in_array($code&~0xff, $role['sections'])) 
                            $this->role_set[] = $code;
                                                
                                         $this->rolename = $role['role'];  // MY CUSTOM CODE FOR ROLE NAME 
                }
                $this->name = $myrow["real_name"];
                $this->pos = $myrow["pos"];
                $this->org_id = $myrow["org_id"];
                $this->loginname = $loginname;
                $this->username = $this->loginname;
                $this->prefs = new user_prefs($myrow);
                $this->user = @$myrow["id"];
                update_user_visitdate($this->username);
                $this->logged = true;
                $this->last_act = time();
                $this->timeout = session_timeout();
            }
        }
        return $this->logged;
    }

        .....
        .....

For security_db.inc (location at admin/db/security_db.inc)

..........

function get_security_role($id)
{
    $sql = "SELECT * FROM ".TB_PREF."security_roles WHERE id=".(int)$id;
    $ret = db_query($sql, "could not retrieve security roles");
    $row = db_fetch($ret);
    if ($row != false) {

        $row['role'] = $row['role']; // MY CUSTOM CODE FOR ROLE NAME

        $row['areas'] = explode(';', $row['areas']);

        $row['sections'] = explode(';', $row['sections']);
    }
    return $row;
}

...................

renderer.php (location at themes/default/renderer.php)

..............
echo "<p id='user-info'>" . _("Welcome") . ", " . $_SESSION["wa_current_user"]->name .
       " (" . $_SESSION["wa_current_user"]->rolename . ")</p>";
..............

now I can access rolename via $_SESSION['wa_current_user']->rolename

Good luck brother

Feel free to ask me if you still need help smile

Hello everybody,

I'm developing a custom module for budgeting usage. There is a approval feature to determine whether the budgeting usage is okay or not.
The problem I faced is I can't hide the approval button after I press the button and the Ajax run. The approval button is still there and I also can't display the notifications.

Here is my snippet codes

if($_POST['approve'])
{
    $budget_usage_id = $_POST['budget_usage_id'];
    
    approve_budget_usage($budget_usage_id);       
    
    display_notification_centered(_("The Budget usage has been approved."));  // Can't display it

    $_POST['approved'] = '1'; // Approved

    $Ajax->activate('buttons');  // Should I use ajax here??
    
}

For display

        <p id="buttons" style="text-align: center">
        <?php if($_POST['approved'] == '0'): ?> // Cek if the budget is approved or not
                <?php submit('approve', _("Approve"), true, '', 'default'); ?>
        <?php endif; ?>
        </p>     

I'm still curious about it even though I can use JQuery for it but it could be great if I can use Ajax from FA.

Thanks.

6

(6 replies, posted in Setup)

Thanks Janusz for your reply.

So, I have successfully added a role name by modifying current_user.inc, security_db.inc and renderer.php. Now I can access it via current_user object. smile

7

(6 replies, posted in Setup)

Hello everybody,

The default display of user information in FA is only name. I want to display role name as well at the top of header. It means that I have to add it inside renderer.php
But, in $_SESSION variabel, the information so far that I can get is [access] aka id field of security_roles db. 

The session variabel can be seen below

 [wa_current_user] => current_user Object
        (
            [user] => 1
            [loginname] => admin
            [username] => admin
            [name] => Administrator
            [company] => 0
            [pos] => 1
            [access] => 2
             ............
         )

How is the correct way to get this role name inside renderer.php?

Thanks for help smile

@Janusz
You're welcome brother. Happy to hear that it was fixed for next release. smile

Hello,

I've found a bug in exchange rates menu section (under Banking and General Ledger). It is very serious bug because it could make your browser hang especially when you use Firefox.

Here are the steps to get this bug occurs
1. Select a currency that can make exchange rates form appear
2. Make sure that the exchange rates input text is empty
2. Put focus on exchange rates input text
3. Click the calendar icon above or click another html element
4. Bug appear

I think this is because the empty input text. I solve this bug by defining decimal number for exchange rate value. So, this input text will never empty.

@itronics
I see Janus. Yep, maybe I should stick with it.

@jnkk
woaah...thanks for your suggestion. Seems that I can implement it.

Hello everybody,

I'm new in FA. I have a problem related to display Chart of Account (COA) in dropdown.

My COA structure is like below ( mark * means chart type)
----------------------------------------------------------------------------------------
1    ASSETS *
11    CURRENT ASSET *
1101    CASH EQUIVALENT *
110101    PETTY CASH  *
11010101    PETTY CASH COMPANY

But after I insert those chart types and the chart of account itself, I get only first parent display in dropdown

My dropdown display
------------------------------------------------------------------------------------------
PETTY CASH
        PETTY CASH COMPANY

If I create another one COA with chart type CASH EQUIVALENT, dropdown would be like this

CASH EQUIVALENT
         NEW COA
PETTY CASH
        PETTY CASH COMPANY

What I want to achieve is like below ( * is chart type)

CURRENT ASSET *
        CASH EQUIVALENT *
                 NEW COA
                 PETTY CASH *
                         PETTY CASH COMPANY

How could I achieve dropdown display to include all of parents?

Thank you for your helps smile