1 (edited by kuropone 04/12/2016 11:45:09 am)

Topic: Add Bank Account Tab In Suppliers

Hallo, i'm really new with this front accounting.
And i need to add new tab for bank account in suppliers list.

Cause every suppliers have more than 1 bank account.
So i duplicate tab contacs and modified it but it is not working.
It never show my bank account table list.

Here is my codes

function list_view() {
        br();

            $banks = get_crm_banks($this->entity);
//                check_value('show_inactive'));
            start_table(TABLESTYLE, "width='80%'");

            $th = array(_('Description'), _("Account Name"), _("Account No"), '', " ");
        //    inactive_control_column($th);

            table_header($th);
            $k = 0;

            $last = $myrow = db_fetch($banks);
            while ($last)
            {
                if ($myrow['id'] != $last['id']) {
                    alt_table_row_color($k);
                    label_cell($last["description"]);
                    label_cell($last["account_name"]);
                    label_cell($last["account_no"]);
                    //    inactive_control_cell($myrow["id"], $myrow["inactive"], 'crm_banks', 'id');

                     edit_button_cell("{$this->name}Edit[{$last['id']}]", _("Edit"));

                    // delete button removes only category unless this is the last contact for this person
                    delete_button_cell("{$this->name}Delete[{$last['id']}]", _("Delete"));
                    end_row();
                    $description = array();
                    $last = $myrow;
                }

                if ($myrow) {
                    $description[] = $myrow['description'];
                    $myrow = db_fetch($banks);
                }
            }

            //inactive_control_row($th);
            end_table(1);
    }

function get_crm_banks($entity=null, $unique=false)
{
    $sql = "SELECT cb.*, b.*, b.bank_id as bank_id FROM ".TB_PREF."crm_banks cb,"
            .TB_PREF."bank b WHERE ";
    $sel = array('cb.bank_id = b.bank_id');

    if ($entity)
        $sel[] = 'cb.entity_id='.db_escape($entity);

    $sql .= implode (" AND ", $sel);

    $sql .= " ORDER BY cb.id";

    $result = db_query($sql, "Can't get crm banks");
    // fallback to general contacts
    return $result;
}

When i read errors.log, it said "simple_crud_class.inc:106: key() [<a href='function.key'>function.key</a>]: Passed variable is not an array or object "

Anyone can help?

Sorry for my bad english.

Thx