$o->creditoraccounts_id = $_POST['creditoraccounts_id'];
$o->defaultlevel = $_POST['defaultlevel'];
$o->createdby = $xoopsUser->getVar('uid');
$o->updatedby = $xoopsUser->getVar('uid');
if ($o->isactive == 1 or $o->isactive == "on") {
    $o->isactive = 1;
} else {
    $o->isactive = 0;
}
switch ($action) {
    //When user submit new organization
    case "create":
        // if the token is exist and not yet expired
        $log->showLog(4, "Accessing create record event, with bpartnergroup name={$o->bpartnergroup_name}");
        if ($s->check(false, $token, "CREATE_ACG")) {
            if ($o->insertBPartnerGroup()) {
                $latest_id = $o->getLatestBPartnerGroupID();
                redirect_header("bpartnergroup.php", $pausetime, "Your data is saved, redirect to create more business partner group.");
            } else {
                $log->showLog(1, "Business partner group '{$o->bpartnergroup_name}' cannot save, please check your data.");
                $token = $s->createToken($tokenlife, "CREATE_ACG");
                $o->orgctrl = $ctrl->selectionOrg($o->createdby, $o->organization_id, 'N', "", 'Y');
                //$o->debtoraccountsctrl=$ctrl->getSelectAccounts($o->debtoraccounts_id,'Y',"","debtoraccounts_id","AND placeholder=0 AND account_type =2");
                //$o->creditoraccountsctrl=$ctrl->getSelectAccounts($o->creditoraccounts_id,'Y',"","creditoraccounts_id","AND placeholder=0 AND account_type =3");
                $o->getInputForm("new", -1, $token);
                $o->showBPartnerGroupTable("WHERE g.bpartnergroup_id>0 and g.organization_id={$defaultorganization_id}", "ORDER BY g.defaultlevel,g.bpartnergroup_name");
            }
        } else {
            // if the token is not valid or the token is expired, it back to previous form with previous inputed data
            $log->showLog(1, "Business partner group '{$o->bpartnergroup_name}' cannot be save due to token expired.");
            $token = $s->createToken($tokenlife, "CREATE_ACG");