Auto Complete Dropdown Boxes For Ticket-frontend and backend
Posted: Fri Mar 29, 2013 2:42 am
I customized the new ticket custom field to a auto complete dropdown box, because in my case, I use custom2 to store the product categories and there are near 200 product categories, it continue increase every month.
The user (frontend) and admin (backend)can start type in the custom2 text field and a dropdown list boxes will show up with the text you type in bold, that make it easy and fast to select category.
The trick is jquery auto complete.
hesk2.41
For submit ticket:

what I did are:
1.new ticket - sales info - auto populate - import pseries to db talbe hesk_pseries;

2.new ticket - pseries - jquery auto complete - upload js and css files
D:\wamp\www\hesk\js\
jquery-1.4.2.js
jquery.autocomplete.js
jquery.autocomplete.css
indicator.gif
D:\wamp\www\hesk\js\lib\
jquery.ajaxQueue.js
jquery.bgiframe.min.js
http://kanboxshare.com/link/yCrYMS3asS6 ... YLfZxW1lYK
3.new ticket - pseries - jquery auto complete - create search php
D:\wamp\www\hesk\pseriescheck.php
4.user new ticket - pseries - jquery auto complete - function
D:\wamp\www\hesk\index.php
line 89
5.user new ticket - pseries - jquery auto complete - custom2 form
D:\wamp\www\hesk\index.php
line 556
add for custom2 after
6.admin new ticket - pseries - jquery auto complete - function
D:\wamp\www\hesk\admin\new_ticket.php
line 90
7. admin new ticket - pseries - jquery auto complete - custom2 form
D:\wamp\www\hesk\admin\new_ticket.php
line 527
add for custom2 after
8. user new ticket - pseries - submit auto complete text
D:\wamp\www\hesk\submit_ticket.php
line 135
add for custom2
after
9. admin new ticket - pseries - submit auto complete text
D:\wamp\www\hesk\admin\admin_submit_ticket.php
line 75
add for custom2 after
That's all. It works in IE6,7,8,FF3,8,13, also chrome 11.
The user (frontend) and admin (backend)can start type in the custom2 text field and a dropdown list boxes will show up with the text you type in bold, that make it easy and fast to select category.
The trick is jquery auto complete.
hesk2.41
For submit ticket:

what I did are:
1.new ticket - sales info - auto populate - import pseries to db talbe hesk_pseries;

2.new ticket - pseries - jquery auto complete - upload js and css files
D:\wamp\www\hesk\js\
jquery-1.4.2.js
jquery.autocomplete.js
jquery.autocomplete.css
indicator.gif
D:\wamp\www\hesk\js\lib\
jquery.ajaxQueue.js
jquery.bgiframe.min.js
http://kanboxshare.com/link/yCrYMS3asS6 ... YLfZxW1lYK
3.new ticket - pseries - jquery auto complete - create search php
D:\wamp\www\hesk\pseriescheck.php
Code: Select all
<?php
define('IN_SCRIPT',1);
define('HESK_PATH','./');
/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');
hesk_dbConnect();
$q = strtolower($_GET["q"]);
if (!$q) return;
$sql = "select series from hesk_pseries where series LIKE '%$q%'";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) {
$pserie = $rs['series'];
echo "$pserie\n";
}
?>
D:\wamp\www\hesk\index.php
line 89
Code: Select all
<meta charset="UTF-8" />
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type='text/javascript' src='js/lib/jquery.bgiframe.min.js'></script>
<script type='text/javascript' src='js/lib/jquery.ajaxQueue.js'></script>
<script type='text/javascript' src="js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />
<script type="text/javascript">
$().ready(function() {
$("#pserie").autocomplete("pseriescheck.php", {
width: 320,
matchContains: true,
mustMatch: true,
minChars: 2,
selectFirst: false
});
});
</script>
D:\wamp\www\hesk\index.php
line 556
add for custom2 after
foreach ($hesk_settings['custom_fields'] as $k=>$v)
{
Code: Select all
if ($k == 'custom2')
{
// Print the field HTML code and anything you want here
?>
<tr>
<td style="text-align:right" width="150">Product Series:</td>
<td width="80%"><input type="text" name="pserie" id="pserie" size="50" maxlength="150" value="<?php if (isset($_SESSION['custom2'])) {echo stripslashes(hesk_input($_SESSION['custom2']));} ?>" <?php if (in_array('custom2',$_SESSION['iserror'])) {echo ' class="isError" ';} ?> /><input type="reset" value="Clear"/>
</td>
</tr>
<?php
// This line will tell PHP to skip the rest of code for 'custom2' and start with next one
continue;
}
D:\wamp\www\hesk\admin\new_ticket.php
line 90
Code: Select all
if ($k == 'custom2')
{
// Print the field HTML code and anything you want here
?>
<tr>
<td style="text-align:right" width="150">Product Series:</td>
<td width="80%"><input type="text" name="pserie" id="pserie" size="50" maxlength="150" value="<?php if (isset($_SESSION['custom2'])) {echo stripslashes(hesk_input($_SESSION['custom2']));} ?>" <?php if (in_array('custom2',$_SESSION['iserror'])) {echo ' class="isError" ';} ?> /><input type="reset" value="Clear"/>
</td>
</tr>
<?php
// This line will tell PHP to skip the rest of code for 'custom2' and start with next one
continue;
}
D:\wamp\www\hesk\admin\new_ticket.php
line 527
add for custom2 after
foreach ($hesk_settings['custom_fields'] as $k=>$v)
{
Code: Select all
if ($k == 'custom2')
{
// Print the field HTML code and anything you want here
?>
<tr>
<td style="text-align:right" width="150">Product Series:</td>
<td width="80%"><input type="text" name="pserie" id="pserie" size="50" maxlength="150" value="<?php if (isset($_SESSION['custom2'])) {echo stripslashes(hesk_input($_SESSION['custom2']));} ?>" <?php if (in_array('custom2',$_SESSION['iserror'])) {echo ' class="isError" ';} ?> /><input type="reset" value="Clear"/>
</td>
</tr>
<?php
// This line will tell PHP to skip the rest of code for 'custom2' and start with next one
continue;
}
D:\wamp\www\hesk\submit_ticket.php
line 135
add for custom2
after
/* Custom fields */
foreach ($hesk_settings['custom_fields'] as $k=>$v)
{
Code: Select all
if ($k == 'custom2')
{
// custom2(pserie) start
if ($v['req'])
{
$tmpvar[$k]=hesk_makeURL(nl2br(hesk_input($_POST['pserie'])));
if (!strlen($tmpvar[$k]))
{
$hesk_error_buffer[$k]=$hesklang['fill_all'].': '.$v['name'];
}
}
else
{
$tmpvar[$k]=hesk_makeURL(nl2br(hesk_input($_POST['pserie'])));
}
$_SESSION["c_$k"]=$_POST['pserie'];
// custom2(pserie) end
continue;
}
D:\wamp\www\hesk\admin\admin_submit_ticket.php
line 75
add for custom2 after
// Custom fields
foreach ($hesk_settings['custom_fields'] as $k=>$v)
{
Code: Select all
if ($k == 'custom2')
{
// custom2(pserie) start
if ($v['req'])
{
$tmpvar[$k]=hesk_makeURL(nl2br(hesk_input($_POST['pserie'])));
if (!strlen($tmpvar[$k]))
{
$hesk_error_buffer[$k]=$hesklang['fill_all'].': '.$v['name'];
}
}
else
{
$tmpvar[$k]=hesk_makeURL(nl2br(hesk_input($_POST['pserie'])));
}
$_SESSION["c_$k"]=$_POST['pserie'];
// custom2(pserie) end
continue;
}