I'm trying to create a filter that adds a custom attribute () to filtered tickets. Using v1.9.2 I've been able to create a Custom List () under Manage/Lists. I've added this to the Ticket Filters by editing the filter.inc.php file as shown below. The dropdown menu that is created does reference the correct SQL table as the I added to the Custom List populate the pulldown menu. When I create a filter and select one of the companies and click Save Changes it saves, but then that field is not actually saved - when I look at all the other fields the pulldown menus are still holding the attributes I selected and saved except the Company filter which is now blank.Any help you could provide would  be greatly appreciated.Thank you!Here's the code I added to filter.inc.php right before the Help Topic entry in that file:<?php     // Insert here to add company to the auto ticket assingment. This requires that a Custom List               // with the Companies listed under Items has already been created in the osTicket web interface. ?>        <tr>            <td width="180">                Company:            </td>            <td>                                <select name="companyid">                    <option value="">&mdash; Select Company &mdash;</option><?php                    $sql='SELECT id, value FROM `OST_LIST_ITEMS` ORDER by value';                     if(($res=db_query($sql)) && db_num_rows($res)) {                        while(list($id,$value)=db_fetch_row($res)) {                            $selected=($info && $id==$info)? 'selected="selected"' : '';                            echo sprintf('<option value="%s" %s>%s</option>',$id, $selected, $value);                        }}?>                </select>                                &nbsp;<span class="error">*&nbsp;<?php echo                 $errors; ?></span><i class="help-tip icon-question-sign" href="#company_name"></i>            </td>        </tr>

Custom Filter.png

Ok. More progress. By the way, I'm brand new to PHP and to code in general - so this has been a process for me. I've now got the correct SQL data populating the dropdown menu. It pulls the individual items from my Custom List into the dropdown. However when I select Save Changes the selected company is not saved. Any thoughts on how to fix this?Here's the new code that has the list items showing up in the dropdown:         <tr>            <td width="180">                Company:            </td>            <td>                <select name="companyid">                    <option value="">&mdash; Select Company &mdash;</option><?php                    $sql='SELECT id, list_id, value FROM `OST_LIST_ITEMS` WHERE `list_id`="1" ORDER BY value' ;                     if(($res=db_query($sql)) && db_num_rows($res)) {                        while(list($id,$list_id,$value)=db_fetch_row($res)) {                            $selected=($info && $id==$info)? 'selected="selected"' : '';                            //if (!$list_id)                                //$list_id .= ' (1)';                            echo sprintf('<option value="%s" %s>%s</option>', $id, $selected, $value);                        }}?>                </select>                                &nbsp;<span class="error">*&nbsp;<?php echo                 $errors; ?></span><i class="help-tip icon-question-sign" href="#company_name"></i>            </td>        </tr>

a year later

Don't know if you end up making it work, but you also need to do changes in the class.filter.php

10 days later

I never got this to function - beyond my coding skills (osTicket mods are my first codign attempt). I tried editing the class.filter.php but must be missing something as I still couldn't get it to work.

Write a Reply...