I’ve been using Smartertools SmartTracker for a few years but there were many features in it that we didn’t need – it was a bit overkill for us. I did some checking around recently and tried a few different systems. I ended up using osTickets open source system.

Written in PHP, it’s a very nice system just out of the box. Installation was pretty simple and you can get it setup and going very quickly.

Once running there were some mods I thought of to make it just a bit better (ain’t that always the way ?) so before digging into the code I did some look around again and found that so far everything almost everything I thought of is done and available for download. One guy that has some very good mods available (I used almost all of them) is Scott Rowley at <a href=”https://sudobash.net/?p=505#more-505″>https://sudobash.net</a> (great url too).

One of the mods I put in is the Rules capability. Works good but I noticed I could add a blank rule and there really wasn’t anything that warned me I had screwed up. So I came up with this change that checks if the user tries to enter a rule without enough fields filled out to make a complete rule. To add the change, in the file “scp/add_rule.php”

&nbsp;

<strong>Find this code:</strong>
<pre><code>// Check if button name “Submit” is active, do this

if(isset($_POST[‘Submit’])){
$sql=”INSERT INTO ost_ticket_rules (isenabled, Category, Criteria, Action, Department, Staff, updated, created)
VALUES (‘$_POST[isenabled]’,’$_POST[Category]’,’$_POST[Criteria]’,’$_POST[Action]’,’$_POST[Department]’,’$_POST[Staff]’, NOW(), NOW())”;
if (!mysql_query($sql))
{
die(‘Error: ‘ . mysql_error());
}
echo “Rule added”;
}
</code></pre>
<strong>And replace it with this code:</strong>
<pre><code>// Check if button name “Submit” is active, do this

if(isset($_POST[‘Submit’])){
if($_POST[Criteria]==”) {
echo ‘<span style=”color: red;”>You have not speicifed anything for “CONTAINS”.</span>’;
} elseif ( ($_POST[Action]==’staffId’) &amp;&amp; ($_POST[Staff]==0) ) {
echo ‘<span style=”color: red;”>You have assigned this to Staff but have not chosen the Staff Member.</span>’;
} elseif (( $_POST[Action]==’deptId’) &amp;&amp; ($_POST[Department]==0) ) {
echo ‘<span style=”color: red;”>You have assigned this to department but have not chosen the Department.</span>’;
} elseif (($_POST[Staff]==0) &amp;&amp; ($_POST[Department]==0)){
echo ‘<span style=”color: red;”>You must choose either a Department or Staff</span>’;
} else {
$sql=”INSERT INTO ost_ticket_rules (isenabled, Category, Criteria, Action, Department, Staff, updated, created)
VALUES (‘$_POST[isenabled]’,’$_POST[Category]’,’$_POST[Criteria]’,’$_POST[Action]’,’$_POST[Department]’,’$_POST[Staff]’, NOW(), NOW())”;
if (!mysql_query($sql))
{
die(‘Error: ‘ . mysql_error());
}
echo “Rule added”;
}
}
</code></pre>
This checks the variables that should have values to see if they are empty and gives a warning if there isn’t enough to do a complete rule.

The other thing I noticed was that if the user entered an incomplete rule they got the warning but had to renter all their information again. So adding the <pre><code>$_REQUEST[variable] </code></pre> to each of the form statements filled in any information already added to the fields:

<strong>Find this line:</strong>
<pre><code>
<input id=”Criteria” name=”Criteria” type=”text” />
</code></pre>
<strong>and change it to this:</strong>
<pre><code>
<input id=”Criteria” name=”Criteria” type=”text” value=”<?=$_REQUEST[Criteria]?>” />
</code></pre>
<strong>Then find this line:</strong>
<pre><code>
<select name=”Action”>
<option> </option>
<option value=”deptId”>Department</option>
<option value=”staffId”>Staff</option>
</select>
</code></pre>
<strong>And change it to:</strong></span></pre>
<pre><code>
<select name=”Action”>
<option value=”<=$_REQUEST[Action]?>”><?=$_REQUEST[Action]?></option>
<option value=”deptId”>Department</option>
<option value=”staffId”>Staff</option>
</select>
</code></pre>
</strong>

That’s it.
leon …