|
#51
|
|||
|
|||
|
Code:
<?php
require('staff.inc.php');
$page='';
$answer=null; //clean start.
$nav->setTabActive('rules');
$nav->addSubMenu(array('desc'=>'Rules','href'=>'rules.php','iconclass'=>'premade'));
$nav->addSubMenu(array('desc'=>'New Rule','href'=>'add_rule.php','iconclass'=>'newPremade'));
require_once(STAFFINC_DIR.'header.inc.php');
?>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="POST" action="add_rule.php">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="5">
<tr>
<!--<td align="center"><strong>ID</strong></td>-->
<td align="center"><strong>Enabled</strong></td>
<td align="center"><strong>Category</strong></td>
<td align="center"><strong>Contains</strong></td>
<td align="center"><strong>Staff</strong></td>
<td align="center"><strong>Department</strong></td>
<td align="center"><strong>Help Topic</strong></td>
</tr>
<tr>
<td width="50" align="center"><select name="isenabled"><option value="on">On</option><option value="off">Off</option></select></td>
<td align="center">
<select name="Category"><option value="subject">Subject</option><option value="email">Email</option>
<!--begin added by lmg-->
<option value="email_to">Email To</option>
<!--end added by lmg-->
</select>
</td>
<td align="center"><input name="Criteria" type="text" id="Criteria"></td>
<td id="Staff" align="center">
<select name="Staff" >
<option value="0" selected="selected"> </option>
<?
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name FROM '.STAFF_TABLE.
' WHERE isactive=1 AND onvacation=0 ';
$depts= db_query($sql.' ORDER BY lastname,firstname ');
while (list($staffId,$staffName) = db_fetch_row($depts)){?>
<option value="<?=$staffId?>" ><?=$staffName?></option>
<?}?>
</select>
</td>
<td id="Department" align="center">
<select name="Department">
<option value=0> </option>
<?
$depts= db_query('SELECT dept_id,dept_name FROM '.DEPT_TABLE.'');
while (list($deptId,$deptName) = db_fetch_row($depts)){?>
<option value="<?=$deptId?>" ><?=$deptName?></option>
<?}?>
</select>
<!--begin added by lmg-->
<td id="HelpTopic" align="center">
<select name="HelpTopic">
<option value=0> </option>
<?
$topics= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.' WHERE isactive=1');
while (list($topicId,$topicName) = db_fetch_row($topics)){?>
<option value="<?=$topicId?>" ><?=$topicName?></option>
<?}?>
</select>
</td>
<!--end added by lmg-->
<tr>
<td colspan="7" align="right"><input type="submit" name="Submit" class="button" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
$ISENABLED = $_POST['isenabled'];
$CATEGORY = $_POST['Category'];
$CRITERIA = $_POST['Criteria'];
//begin MODIFIED by lmg
if (isset($_POST['Department']))
$DEPARTMENT = $_POST['Department'];
else
$DEPARTMENT = "0";
if (isset($_POST['Staff']))
$STAFF = $_POST['Staff'];
else
$STAFF = "0";
if (isset($_POST['HelpTopic']))
$HELPTOPIC = $_POST['HelpTopic'];
else
$HELPTOPIC = "0";
//end MODIFIED by lmg
// Check if button name "Submit" is active, do this
//begin MODIFIED by lmg
if(isset($_POST['Submit'])){
$sql="INSERT INTO ".RULES_TABLE." (isenabled, Category, Criteria, Department, Staff, HelpTopic, updated, created)
VALUES ('$_POST[isenabled]','$_POST[Category]','$_POST[Criteria]','$DEPARTMENT','$STAFF', '$HELPTOPIC', NOW(), NOW())";
//end MODIFIED by lmg
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "Rule added";
}
?>
<!--<SCRIPT language="JavaScript">
<!--
window.location="rules.php";
//-->
</SCRIPT><?
mysql_close();
require_once(STAFFINC_DIR.'footer.inc.php');
?>
Step 5: Modify osticket_path/include/class.ticket.php (note my version uses ',helptopic=' instead of ',topic='): Code:
/*AUTOaSSIGN MOD modified by lmg*/
// BEGIN - sudobash.net Auto-Assignment Rules MOD //
//Last minute checks
$priorityId=$priorityId?$priorityId:$cfg->getDefaultPriorityId();
$deptId=$deptId?$deptId:$cfg->getDefaultDeptId();
$ipaddress=$var['ip']?$var['ip']:$_SERVER['REMOTE_ADDR'];
$subject=(Format::striptags($var['subject']));
$email=($var['email']);
$qry = sprintf("SELECT * FROM ".RULES_TABLE.";");
$result=mysql_query($qry);
while ( $row = mysql_fetch_assoc($result)){
$isenabled=$row['isenabled'];
$Category=$row['Category'];
$Criteria=$row['Criteria'];
$Department=$row['Department'];
$Staff=$row['Staff'];
//begin added by lmg
$HelpTopic=$row['HelpTopic'];
//end added by lmg
if( "$isenabled" == "on" )
{
if( ("$Category" == "subject" && preg_match("/$Criteria/i", $subject)) || ("$Category" == "email" && preg_match("/$Criteria/i", $email)) || ("$Category" == "email_to" && preg_match("/$Criteria/i", $email_to)))
{
if ($Department>0)
$deptId=$Department;
if ($Staff>0)
$staffId=$Staff;
if ($Department<=0)
{
$staffId=preg_replace( '/\n/', '', trim($staffId) );
$qry = sprintf("SELECT dept_id FROM ".STAFF_TABLE." WHERE staff_id=$Staff;");
$result=mysql_query($qry);
while ( $row = mysql_fetch_assoc($result)){
$deptId=$row['dept_id'];
}
}
$topic = new Topic($HelpTopic);
$topicDesc = $topic->getName();
if ($Department<=0)
$deptId = $topic->getDeptId();
}
}
} // End while loop
//We are ready son...hold on to the rails.
$extId=Ticket::genExtRandID();
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
',priority_id='.db_input($priorityId).
',email='.db_input($var['email']).
',name='.db_input(Format::striptags($var['name'])).
',subject='.db_input($subject).
',dept_id='.db_input($deptId).
',staff_id='.db_input($staffId).
',helptopic='.db_input(Format::striptags($topicDesc)).
',phone='.db_input($var['phone']).
',phone_ext='.db_input($var['phone_ext']?$var['phone_ext']:'').
',ip_address='.db_input($ipaddress).
',source='.db_input($source);
// END - sudobash.net Auto-Assignment Rules MOD //
Step 6: Modify osticket_path/include/class.nav.php (have not changed at all) to include: Code:
$tabs['rules']=array('desc'=>'Rules','href'=>'rules.php','title'=>'Rules');
|
|
#52
|
||||
|
||||
|
Right on, I'm glad you like it and I'm happy to see you were able to modify it for your needs. I haven't spent any time with any of my MODs recently except for the Reports MOD.
|
|
#53
|
|||
|
|||
|
I have added the auto assign ability to web based tickets and the help topics. I'll share once I am finished testing, so far so good. The only issue I have is only managers of the group/department are sent emails.
If I have a department called "Tier 1" and there are three people in the department. Bob, John, and Sara With Bob being the manager if a ticket is assigned to Bob an email gets sent out to Bob. When a ticket is assigned to John or Sara, emails are not sent to them but to the manager Bob. When no manager is selected for the department emails are sent to no one. I am not sure if this is a MOD issue or just how OSTicket works. Anyone have thoughts on this? Thanks ZeroEffect |
|
#54
|
|||
|
|||
|
What are your Alerts & Notices settings in the Admin panel -> Settings tab (scroll all the way to the bottom)?
|
|
#55
|
|||
|
|||
|
These are my settings. enabled/selections are in bold.
Notices sent to user use 'No Reply Email' whereas alerts to staff use 'Alert Email' set above as FROM address respectively. New Ticket Alert: Enabled Select recipients Admin Email Department Manager Department Members (spammy) New Message Alert: EnableSelect recipients Last Respondent Assigned Staff Department Manager (spammy) New Internal Note Alert: Enable Select recipients Last Respondent Assigned Staff Department Manager (spammy) Overdue Ticket Alert: Enable Admin Email gets an alert by default. Select additional recipients below Assigned Staff Department Manager Department Members (spammy) System Errors: Enabled errors are sent to admin email set above System Errors SQL errors Excessive Login attempts |
|
#56
|
|||
|
|||
|
While this MOD did most of what I wanted it did not auto assign for client web based tickets. After looking at the code and trial and error I have auto assign working for client web based tickets.
Here is everything I did.
Modifying the rules.php file. Code:
Original MOD code <td align="center"><strong>Category</strong></td> <td align="center"><strong>Contains</strong></td> <td align="center"><strong>Assign To</strong></td> My change <td align="center"><strong>Category</strong></td> <td align="center"><strong>Help Topic</strong></td> <td align="center"><strong>Assign To</strong></td> Code:
Original MOD Code
<select name="Category[]"><option value="subject" <? if($rows['Category'] == "subject"){print "SELECTED";}?>>Subject</option><option value="email" <? if($rows['Category'] == "email"){print "SELECTED";}?>>Email</option></select>
My Change
<select name="Category[]"><option value="web" <? if($rows['Category'] == "web"){print "SELECTED";}?>>Web</option><option value="subject" <? if($rows['Category'] == "subject"){print "SELECTED";}?>>Subject</option><option value="email" <? if($rows['Category'] == "email"){print "SELECTED";}?>>Email</option></select>
Code:
Original MOD code
<td align="center"><strong>Category</strong></td>
<td align="center"><strong>Contains</strong></td>
<td align="center"><strong>Assign To</strong></td>
My change
<td align="center"><strong>Category</strong></td>
<td align="center"><strong>Help Topic</strong></td>
<td align="center"><strong>Assign To</strong></td>
Code:
Original MOD code
<input name="Criteria" type="text" id="Criteria">
My Change
<select name="Criteria">
<option value=0> </option>
<?
$topics= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.'');
while (list($topicId,$topicName) = db_fetch_row($topics)){?>
<option value="<?=$topicName?>" ><?=$topicName?></option>
<?}?>
</select>
Changes to the /include/class.ticket.php file. Code:
Orignal MOD code
$subject=(Format::striptags($var['subject']));
$email=($var['email']);
$qry = sprintf("SELECT * FROM ost_ticket_rules;");
My Changes
$subject=(Format::striptags($var['subject']));
$email=($var['email']);
// add web selection
$web=(Format::striptags($topicDesc));
// End
$qry = sprintf("SELECT * FROM ost_ticket_rules;");
Code:
Original MOD code
if( "$isenabled" == "on" )
{
if( "$Category" == "subject" )
{
if (preg_match("/$Criteria/i", $subject))
{
if( "$Action" == "deptId" )
{
$deptId=$Department;
}
elseif( "$Action" == "staffId" )
{
$staffId=$Staff;
$staffId=preg_replace( '/\n/', '', trim($staffId) );
$qry = sprintf("SELECT dept_id FROM `ost_staff` WHERE staff_id=$Staff;");
$result=mysql_query($qry);
while ( $row = mysql_fetch_assoc($result)){
$deptId=$row['dept_id'];
}
}
}
}
My Changes
if( "$isenabled" == "on" )
{
// Add web check
if( "$Category" == "web" )
{
if (preg_match("/$Criteria/i", $web))
{
if( "$Action" == "deptId" )
{
$deptId=$Department;
}
elseif( "$Action" == "staffId" )
{
$staffId=$Staff;
$staffId=preg_replace( '/\n/', '', trim($staffId) );
$qry = sprintf("SELECT dept_id FROM `ost_staff` WHERE staff_id=$Staff;");
$result=mysql_query($qry);
while ( $row = mysql_fetch_assoc($result)){
$deptId=$row['dept_id'];
}
}
}
}
// End
elseif( "$Category" == "subject" ) //orignal start of the "if" statment.
Code:
// Pre 1.6ST ',topic='.db_input(Format::striptags($topicDesc)).
',helptopic='.db_input(Format::striptags($topicDesc)).
I don't think I missed any of my changes. I am sure someone will post if I did. ![]() This is a great MOD! ZeroEffect |
|
#57
|
|||
|
|||
|
Took me a bit but I got it working. the rules will now also assign a priority based on the rule.
First I added a column to the ticket_rules table, Priority. Code:
// I think this was the code I used. alter table ost_ticket_rules add column Priority text Code:
<!-- add the priority column header --> <td align="center"><strong>Priority</strong></td> <td align="center"><strong>Last Updated</strong></td> Code:
<!-- Added the combo box to the table cell -->
<td>
<select name="Priority[]">
<option value=""></option>
<option value="3" <? if($rows['Priority'] == "3"){print "SELECTED";}?>>High</option>
<option value="2" <? if($rows['Priority'] == "2"){print "SELECTED";}?>>Normal</option>
<option value="1" <? if($rows['Priority'] == "1"){print "SELECTED";}?>>Low</option>
</select>
</td>
<td align="center"><? echo $rows['updated']; ?></td>
Code:
<!-- added the variable and edited the sql statment $STAFF = $_POST['Staff']; $PRIORITY = $_POST['Priority']; //added this line $DELETE = $_POST['deleteRule']; Updated the sql Statment. $sql1="UPDATE ost_ticket_rules SET isenabled='$ISENABLED[$i]', Category='$CATEGORY[$i]', Criteria='$CRITERIA[$i]', Action='$ACTION[$i]', Department='$DEPARTMENT[$i]', Staff='$STAFF[$i]', Priority='$PRIORITY[$i]', updated=NOW() WHERE id='$id[$i]'"; $result=mysql_query($sql1); Code:
<!-- Add Priority column and table cell -->
<td align="center"><strong>Priority</strong></td>
<td align="center">
<select name="Priority">
<option value="3">High</option>
<option value="2">Normal</option>
<option value="1">Low</option>
</select>
</td>
Code:
<!-- add the variable and change the sql statment -->
$PRIORITY = $_POST['Priority'];
$sql="INSERT INTO ost_ticket_rules (isenabled, Category, Criteria, Action, Department, Staff, Priority, updated, created)
VALUES ('$_POST[isenabled]','$_POST[Category]','$_POST[Criteria]','$_POST[Action]','$_POST[Department]','$_POST[Staff]', '$_POST[Priority]', NOW(), NOW())";
Code:
//Add the priority
$Staff=$row['Staff'];
$Priority=$row['Priority']; // new line
//and assign it the value from the rules in the if statments, all of them.
$priorityId=$Priority;
$priorityId=preg_replace( '/\n/', '', trim($priorityId) );
$staffId=$Staff;
$staffId=preg_replace( '/\n/', '', trim($staffId) );
I have one thing left to do to the rules.php file. Ok two things.
Any help on those two things is welcome. Thanks ZeroEffect |
|
#58
|
|||
|
|||
|
Okay, I got the help topics on the rules page completed.
Code:
<!-- <input name="Criteria[]" type="text" id="Criteria" value="<? echo $rows['Criteria']; ?>"> -->
<select name="Criteria[]">
<option value=0> </option>
<?
$topics= db_query('SELECT topic_id,topic FROM '.TOPIC_TABLE.'');
while (list($topicId,$topicName) = db_fetch_row($topics)){?>
<option value="<?=$topicName?>" <? if($topicName == $rows['Criteria']){print SELECTED;}?>>><?=$topicName?></option>
<?}?>
</select>
|
|
#59
|
|||
|
|||
|
Finally I got updating rules to work. I was able to find that the id in the sql statement was not being set or referenced.
in the scp/rules.php file we need to add the ID to each row and assign it. I added this line in the same cell as the check box for deleting the row. Code:
<input name="id[]" type="hidden" value="<?=$rows['id']; ?>"> here it is in the cell <td align="center"><input name="id[]" type="hidden" value="<?=$rows['id']; ?>"><input type="checkbox" name="deleteRule[]" value="<?=$rows['id']; ?>"></td> Now all I had to do was assign it to the variable all ready in the sql statement. Code:
$id = $_POST['id']; //added line $ISENABLED = $_POST['isenabled']; $CATEGORY = $_POST['Category']; ZeroEffect |
|
#60
|
|||
|
|||
|
Is there any possibility to check not only the subject but the whole email text for a certain phrase to create an auto-assignment rule?
This is really something I am desperately looking for :-) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|