Topic: Adding Column Value in Drop Down

I want to add another column in Drop Down List in following function i.e. s.long_description. What changes shall I make

function sales_items_list($name, $selected_id=null, $all_option=false,
    $submit_on_change=false, $type='', $opts=array())
{
    // all sales codes
    $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit,
             i.inactive, if(count(*)>1, '0', s.editable) as editable
            FROM
            ".TB_PREF."stock_master s,
            ".TB_PREF."item_codes i
            LEFT JOIN
            ".TB_PREF."stock_category c
            ON i.category_id=c.category_id
            WHERE i.stock_id=s.stock_id
      AND mb_flag != 'F'";


    if ($type == 'local')    { // exclude foreign codes
        $sql .=    " AND !i.is_foreign";
    } elseif ($type == 'kits') { // sales kits
        $sql .=    " AND !i.is_foreign AND i.item_code!=i.stock_id";
    }
    $sql .= " AND !i.inactive AND !s.inactive AND !s.no_sale";
    $sql .= " GROUP BY i.item_code";

    return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
        array_merge(
          array(
            'format' => '_format_stock_items',
            'spec_option' => $all_option===true ?  _("All Items") : $all_option,
            'spec_id' => ALL_TEXT,
            'search_box' => true,
            'search' => array("i.item_code", "c.description", "i.description"),
            'search_submit' => get_company_pref('no_item_list')!=0,
            'size'=>15,
            'select_submit'=> $submit_on_change,
            'category' => 2,
            'order' => array('c.description','i.item_code'),
            'editable' => 30,
            'max' => 255
          ), $opts), $type == 'kits' ? $type : "stock_sales" );
}
www.boxygen.pk

Re: Adding Column Value in Drop Down

You can replace the i.description with the s.long_description with appropriate substitution there or add in the latter where the former is.

Re: Adding Column Value in Drop Down

Can't we use both? i.description and s.long_description?

www.boxygen.pk

Re: Adding Column Value in Drop Down

You can use query concatenation to achieve this.

CONCAT_WS(' ', i.description, s.long_description) as full_description 

Use the full_description within the combo_input

Subscription service based on FA
HRM CRM POS batch Themes