Home > osTicket > How to Add Search Form in View Ticket Page in osTicket v1.6 RC5

How to Add Search Form in View Ticket Page in osTicket v1.6 RC5

Sometimes, when your staff are displaying a ticket in a full-mode of your osTicket System, they want to search another ticket based on its number directly on that page. So I made this modification in order your staff are able to search another ticket without having to go back to the ticket list page.

Open \include\staff\viewticket.inc.php file, find this code:

28
<table width="100%" cellpadding="2" cellspacing="0" border="0">

before the line of that code, please insert the following code:

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php 
$basic_display=!isset($_REQUEST['advance_search'])?true:false;
?>
<!-- SEARCH FORM START -->
 <div id='basic' style="display:<?php echo $basic_display?'block':'none'?>">  
        <form name="frmSearchSimple" id="frmSearchSimple" action="tickets.php" method="get">
    <input type="hidden" name="a" value="search">
    <table>
        <tr>
            <td>Query: </td>
            <td><input type="text" id="query" name="query" size=30 value="<?php echo Format::htmlchars($_REQUEST['query'])?>"></td>
            <td><input type="submit" name="basic_search" class="button" value="Search"> 
             &nbsp;[<a href="#" onClick="showHide('basic','advance'); return false;">Advanced</a> ] </td>
        </tr>
    </table>
    </form>
  </div>
 
<div id='advance' style="display:<?php echo $basic_display?'none':'block'?>">
 <form name="frmSearchSimple2" id="frmSearchSimple2" action="tickets.php" method="get">
 <input type="hidden" name="a" value="search">
  <table>
    <tr>
        <td>Query: </td><td><input type="text" id="query" name="query" value="<?php echo Format::htmlchars($_REQUEST['query'])?>"></td>
        <td>Dept: </td>
        <td><select name="dept"><option value=0>All Departments</option>
            <?php
                //Showing only departments the user has access to...
                $depts= db_query('SELECT dept_id,dept_name FROM '.DEPT_TABLE.' WHERE dept_id IN ('.implode(',',$thisuser->getDepts()).')');
                while (list($deptId,$deptName) = db_fetch_row($depts)){
                $selected = ($_GET['dept']==$deptId)?'selected':''; ?>
                <option value="<?php echo $deptId?>"<?php echo $selected?>><?php echo $deptName?></option>
            <?php
            }?>
            </select>
        </td>
        <td>Status is:</td><td>
 
        <select name="status">
            <option value='any' selected >Any status</option>
            <option value="Open" <?php echo $_REQUEST['status'] =='Open'?'selected':''?>>Open</option>
            <option value="Closed" <?php echo $_REQUEST['status']=='Closed'?'selected':''?>>Closed</option>
        </select>
        </td>
     </tr>
    </table>
    <div>
        Date Span:
        &nbsp;From&nbsp;<input name="startDate" onclick="displayDatePicker('startDate');" value="<?php echo Format::htmlchars($_REQUEST['startDate'])?>" 
            autocomplete=OFF >
                <img src="../images/cal.gif" id="startPick" style="cursor: pointer;" onclick="displayDatePicker('startDate');" align="absmiddle">
            &nbsp;&nbsp; to &nbsp;&nbsp;
            <input name="endDate" onclick="displayDatePicker('endDate');" value="<?php echo Format::htmlchars($_REQUEST['endDate'])?>" autocomplete=OFF >
                 <img src="../images/cal.gif" id="endPick" style="cursor: pointer;" onclick="displayDatePicker('endDate');" align="absmiddle">
            &nbsp;&nbsp;
    </div>
    <table>
    <tr>
       <td>Sort by:</td><td>
        <?php
         $sort=$_GET['sort']?$_GET['sort']:'date';
        ?>
        <select name="sort">
            <option value="ID" <?php echo $sort== 'ID' ?'selected':''?>>Ticket #</option>
            <option value="pri" <?php echo $sort == 'pri' ?'selected':''?>>Priority</option>
            <option value="date" <?php echo $sort == 'date' ?'selected':''?>>Date</option>
            <option value="dept" <?php echo $sort == 'dept' ?'selected':''?>>Dept.</option>
        </select>
        <select name="order">
            <option value="DESC"<?php echo $_REQUEST['order'] == 'DESC' ?'selected':''?>>Descending</option>
            <option value="ASC"<?php echo $_REQUEST['order'] == 'ASC'?'selected':''?>>Ascending</option>
        </select>
       </td>
        <td>Results per page:</td><td>
        <select name="limit">
        <?php
         $sel=$_REQUEST['limit']?$_REQUEST['limit']:15;
         for ($x = 5; $x <= 25; $x += 5) {?>
            <option  value="<?php echo $x?>" <?php echo ($sel==$x )?'selected':''?>><?php echo $x?></option>
        <?php } ?>
        </select>
     </td>
     <td>
     <input type="submit" name="advance_search" class="button" value="&nbsp;Search&nbsp;">
       &nbsp;[ <a href="#" onClick="showHide('advance','basic'); return false;" >Basic</a> ]
    </td>
  </tr>
 </table>
 </form>
</div>
 
<script type="text/javascript">
    var options = {
        script:"ajax.php?api=tickets&f=search&limit=10&",
        varname:"input",
        shownoresults:false,
        maxresults:10,
        callback: function (obj) { 
                    document.getElementById('query').value = obj.id; 
                    //document.forms[0].submit();
                    document.getElementById('frmSearchSimple').submit();
                }
    };
    var autosug = new bsn.AutoSuggest('query', options);
</script>
<!-- SEARCH FORM END -->
  • Share/Bookmark
380 views Print This Post Print This Post

Categories: osTicket Tags: , ,
  1. Durga
    March 10th, 2010 at 09:42 | #1

    the calendar in search is not coming.

  2. Durga
    March 10th, 2010 at 23:09 | #2

    So i have changed the Date span block to below and it is working.

            Date Span:
            &nbsp;From&nbsp;<input name="startDate" onclick="event.cancelBubble=true;calendar(this);" value="" 
                autocomplete=OFF >
                    <a href="#" rel="nofollow">
    					</a>
                &nbsp;&nbsp; to &nbsp;&nbsp;
                <input name="endDate" onclick="event.cancelBubble=true;calendar(this);" value="" autocomplete=OFF >
                     <a href="#" rel="nofollow"></a>
                &nbsp;&nbsp;
  1. No trackbacks yet.