Alert Destination Department Members of Transfered Ticket in osTicket v1.6 RC5

There was an interesting request asked to myself about how to send email to the destination department members if a new transfered ticket has come to their department. You can see completely about this request from osTicket Discussion Forum. Well, now I have successfully created the modification for this purpose. You can also now define whether to enable or disable this feature on a Department basis via Admin Panel of your osTicket System, just in case not all department might require it.

  1. First of all, alter your ost_department table by using this following SQL script. Please note that the ost_ is the table prefix name. It could be different with yours. In case it differs with yours, please adjust it by yourself, and please be kind of it!

    ALTER TABLE ost_department
    ADD COLUMN `transfer_auto_alert` tinyint(1) default 1 NOT NULL;
  2. Open your \include\class.dept.php file, and find this code:

    116
    117
    118
    
        function autoRespONNewMessage() {
            return $this->row['message_auto_response']?true:false;
        }

    after the last line of that code, please insert this following code:

    119
    120
    121
    122
    123
    
        // MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009 
        function autoRespONTransferTicket() {
            return $this->row['transfer_auto_alert']?true:false;
        }
        // MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009

    Find again this code:

    252
    
                     ',message_auto_response='.db_input($_POST['message_auto_response']).

    then replace with this following code:

    252
    253
    
                     ',message_auto_response='.db_input($_POST['message_auto_response']).
                     ',transfer_auto_alert='.db_input($_POST['transfer_auto_alert']). // MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009
  3. Open your \include\staff\dept.inc.php file, and find this code:

    126
    127
    128
    
                    <input type="radio" name="message_auto_response"  value="0"   <?=!$info['message_auto_response']?'checked':''?> />Disable
                </td>
            </tr>

    after the last line of that code, please insert this following code:

    129
    130
    131
    132
    133
    134
    135
    136
    
            <!-- MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009 -->
            <tr><th>Auto Alert Ticket Transfer:</th>
                <td>
                    <input type="radio" name="transfer_auto_alert"  value="1"   <?=$info['transfer_auto_alert']?'checked':''?> />Enable
                    <input type="radio" name="transfer_auto_alert"  value="0"   <?=!$info['transfer_auto_alert']?'checked':''?> />Disable
                </td>
            </tr>
            <!-- MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009 -->
  4. Open your \scp\tickets.php file, and find this code:

    112
    113
    114
    115
    116
    117
    
                if(!$errors && $ticket->transfer($_POST['dept_id'])){
                     $ticket->reload(); //dept manager changed!
                    //Send out alerts?? - for now yes....part of internal note!
                    $title='Dept. Transfer: '.$ticket->getDeptName().' to '.Dept::getNameById($_POST['dept_id']);
                    $ticket->postNote($title,$_POST['message']);
                    $msg='Ticket Transfered Sucessfully';

    then replace with this following code:

    112
    113
    114
    115
    116
    117
    118
    119
    
                // MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009
                if(!$errors && $ticket->transfer($_POST['dept_id'],$ticket->getDeptName(),Dept::getNameById($_POST['dept_id']))){
                // Send out alerts?? - for now yes....part of internal note!
                // Now department members can also received an alert for incoming transfered ticket!
                    $title='Dept. Transfer: '.$ticket->getDeptName().' to '.Dept::getNameById($_POST['dept_id']);
                    $ticket->reload(); //dept manager changed!
    		$ticket->postNote($title,$_POST['message']);               
                    $msg='Ticket Transfered Sucessfully';
  5. Open your \include\class.ticket.php file, and find this code:

    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    
        //Dept Tranfer...with alert..
        function transfer($deptId){
            global $cfg;
            /*
            TODO:
                1) Figure out what to do when ticket is assigned
                    Is the assignee allowed to access target dept?  (At the moment assignee will have access to the ticket anyways regardless of Dept)
                2) Send alerts to new Dept manager/members??
                3) Other crap I don't have time to think about at the moment.
            */
            return $this->setDeptId($deptId)?true:false;
        }

    then replace with this following code:

    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    
        //Dept Tranfer...with alert..
        function transfer($deptId,$oldDept,$newDept){
            global $cfg;
            /*
            TODO:
                1) Figure out what to do when ticket is assigned
                    Is the assignee allowed to access target dept?  (At the moment assignee will have access to the ticket anyways regardless of Dept)
                2) Send alerts to new Dept manager/members?? (Yes, now your dreams come true! See MOD created by Masino Sinaga below!)
                3) Other crap I don't have time to think about at the moment.
            */
            //return $this->setDeptId($deptId)?true:false;
     
            // MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009
    	if ($this->setDeptId($deptId)) {
    	    $this->dept_id = $deptId;
                $dept=$this->getDept();
                if ($dept->autoRespONTransferTicket()) {
    	      $helpdesk_email=$cfg->getDefaultEmail();
                  $sqls = 'SELECT DISTINCT(email) FROM '.STAFF_TABLE.' WHERE dept_id = '.db_input($deptId);
                  if (($ress=db_query($sqls)) && db_num_rows($ress)) {
                    while(list($email)=db_fetch_row($ress)) {
                      $helpdesk_email->send($email,
    		  'New Transfered Ticket #'.$this->getExtId(),
    		  'A new ticket #'.$this->getExtId().' has been transfered to your department (from '.$oldDept.' to '.$newDept.')!');
                    }
                  }
                }else {
                  Sys::log(LOG_WARNING,'autoRespONTransferTicket','Failed while getting autoRespONTransferTicket setting.');
                }
                return true;					
    	}  
            return false;
            // MOD Transfer Ticket Auto Alert, by Masino Sinaga, October 30, 2009
        }

Hope it helps you.

Share

551 viewsPrint This Post Print This Post

Comments

  1. Benjamin says:

    Great mod! Works perfect, it would be really cool, if you could set a custom text for this alert mail – like you’ve got it for alert mails on staff changement.

    Would this be possible?

  2. Of course, it is possible. But, since the message does not need to customize further (it only displays the short simple message that inform about an incoming ticket), then I am not too interested to provide the space in order to set a custom message. If you make a modification about it, then let us know. Thanks.

Speak Your Mind

*


*