Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Closed Ticket Alerts Support and Alert Dept Members MOD

DUE TO CHAR SPACE LIMITS IN OS FORUM: THIS MOD IS POSTED ACROSS THE FIRST 3 POSTINGS! PLEASE READ CAREFULLY! MAKE SURE YOU COMPLETE ALL THE CHANGES. ALL CODE IS COMPLETELY UP-TO-DATE!

Support for Closed Ticket Alerts to Dept Members. This also works in the same function to alert dept members on staff replies to unassigned tickets.

This MOD was originally created in 1.6 using the 'function close()' by Masino Sinaga but I have modified it and added further support. In 1.7 we are no longer going to use 'function close()', and instead will use 'function postReply()'. I have added additional support to deliver unassigned ticket staff replies to the dept. Enjoy!!

Part 1

Begin MOD:
Add to ost_config table

ALTER TABLE ost_config
ADD COLUMN `message_alert_dept_members` tinyint(1) DEFAULT 0 NOT NULL,
ADD COLUMN `closed_alert_active` tinyint(1) DEFAULT 0 NOT NULL,
ADD COLUMN `closed_alert_assigned` tinyint(1) DEFAULT 0 NOT NULL,
ADD COLUMN `closed_alert_dept_manager` tinyint(1) DEFAULT 0 NOT NULL,
ADD COLUMN `closed_alert_dept_members` tinyint(1) DEFAULT 0 NOT NULL;


Add to ost_email_template

ALTER TABLE ost_email_template
ADD COLUMN `ticket_upd_mbers_subj` VARCHAR(255) DEFAULT '' NOT NULL,
ADD COLUMN `ticket_upd_mbers_body` text NOT NULL,
ADD COLUMN `ticket_closed_subj` VARCHAR(255) DEFAULT '' NOT NULL,
ADD COLUMN `ticket_closed_body` text NOT NULL;


Find this code in include\staff\settings-alerts.inc.php around line 55


<tr>
<td>
<input type=\"checkbox\" name=\"message_alert_dept_manager\" <?php echo $config['message_alert_dept_manager']?'checked':''; ?>> Department Manager <em>(spammy)</em>
</td>
</tr>


and add below it


<tr>
<td>
<?php // message alert for Department Members, Added By Sturg2013 April 10 2013 for unassigned tickets ?>
<input type=\"checkbox\" name=\"message_alert_dept_members\" <?=$config['message_alert_dept_members']?'checked':'';?>> Department Members if Ticket is Unassigned (spammy)
</td>
</tr>


Then in the same file - find this code around line 158

<tr>
<td>
<input type=\"checkbox\" name=\"overdue_alert_dept_members\" <?php echo $config['overdue_alert_dept_members']?'checked':''; ?>> Department Members <em>(spammy)</em>
</td>
</tr>


and add below it the following code


<?php // Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!?>
<tr><th><em><b>Closed Ticket Alert:</b> Alert sent out when a ticket is closed to the entire dept!</em></th></tr>

<tr>
<td>
<input type=\"radio\" name=\"closed_alert_active\" value=\"1\" <?=$config['closed_alert_active']?'checked':'';?> />Enable
<input type=\"radio\" name=\"closed_alert_active\" value=\"0\" <?=!$config['closed_alert_active']?'checked':'';?> />Disable
&nbsp;&nbsp;&nbsp;<font class=\"error\">&nbsp;<?php echo $errors['closed_alert_active']; ?></font>

</td>
</tr>
<br><i><?php //Sturg2013 - Admin Email gets an alert by default- mine is hardcoded switched off. Select additional recipients below?></i>&nbsp;<font class=\"error\">&nbsp;<?=$errors['closed_alert_active']?></font><br>
<tr>
<td>
<input type=\"checkbox\" name=\"closed_alert_assigned\" <?=$config['closed_alert_assigned']?'checked':'';?>> Assigned Staff
</td>
</tr>
<tr>
<td>
<input type=\"checkbox\" name=\"closed_alert_dept_manager\" <?=$config['closed_alert_dept_manager']?'checked':'';?>> Department Manager
</td>
</tr>
<tr>
<td>
<input type=\"checkbox\" name=\"closed_alert_dept_members\" <?=$config['closed_alert_dept_members']?'checked':'';?>> Department Members (spammy)
</td>
</tr>
<?php // Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!?>



Next, in class.config.php find the following code

function alertDeptManagerONNewMessage() {
return ($this->config['message_alert_dept_manager']);
}


And add the following:

//Sturg2013 April 10 2013 -- Alert dept members if ticket is unassigned - include everyone in conversation
function alertDeptMembersONNewMessage() {
return ($this->config['message_alert_dept_members']);
}


Still in class.config.php find the following code

function alertDeptMembersONOverdueTicket() {
return ($this->config['overdue_alert_dept_members']);
}




Then add the following below it

// Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!
function alertONClosedTicket() {
return ($this->config['closed_alert_active']);
}

function alertAssignedONClosedTicket() {
return ($this->config['closed_alert_assigned']);
}

function alertDeptManagerONClosedTicket() {
return ($this->config['closed_alert_dept_manager']);
}

function alertDeptMembersONClosedTicket() {
return ($this->config['closed_alert_dept_members']);
}
// Closed Ticket Alert for Department Members,Added By Sturg2013February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!


Next, in the same file - find this code around line 833

if($vars['ticket_alert_active']
&& (!isset($vars['ticket_alert_admin'])
&& !isset($vars['ticket_alert_dept_manager'])
&& !isset($vars['ticket_alert_dept_members']))) {
$errors['ticket_alert_active']='Select recipient(s)';
}


and below it CHANGE 'message alert active' SO IT LOOKS LIKE


if($vars['message_alert_active']
&& (!isset($vars['message_alert_laststaff'])
&& !isset($vars['message_alert_assigned'])
&& !isset($vars['message_alert_dept_manager'])
//Sturg2013 April 10 2013 alert dept members if ticket is unassigned - include everyone in conversation
&& !isset($vars['message_alert_dept_members']))) {
$errors['message_alert_active']='Select recipient(s)';
}


Then a few lines down find


if($vars['note_alert_active']
&& (!isset($vars['note_alert_laststaff'])
&& !isset($vars['note_alert_assigned'])
&& !isset($vars['note_alert_dept_manager']))) {
$errors['note_alert_active']='Select recipient(s)';
}


Below this add the following code


// Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!
if($vars['closed_alert_active']
&& (!isset($vars['closed_alert_assigned'])
&& !isset($vars['closed_alert_dept_manager'])
&& !isset($vars['closed_alert_dept_members']))){
$errors['closed_alert_active']='Select recipient(s)';
}
// Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!


Next, still in class.config.php find the following code:

.',transfer_alert_assigned='.db_input(isset($vars['transfer_alert_assigned'])?1:0)
.',transfer_alert_dept_manager='.db_input(isset($vars['transfer_alert_dept_manager'])?1:0)


and after it add the following

//Sturg2013 - alert dept members when ticket is unassigned - include everyone
.',message_alert_dept_members='.db_input(isset($vars['message_alert_dept_members'])?1:0)


And then a few lines down find the following

.',overdue_alert_dept_manager='.db_input(isset($vars['overdue_alert_dept_manager'])?1:0)
.',overdue_alert_dept_members='.db_input(isset($vars['overdue_alert_dept_members'])?1:0)


And after it add the following code

// Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!
.',closed_alert_active='.db_input($vars['closed_alert_active'])
.',closed_alert_assigned='.db_input(isset($vars['closed_alert_assigned'])?1:0)
.',closed_alert_dept_manager='.db_input(isset($vars['closed_alert_dept_manager'])?1:0)
.',closed_alert_dept_members='.db_input(isset($vars['closed_alert_dept_members'])?1:0)
// Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!



===================================
Part 2 Below: Sturg2013 :D
«1

Comments

  • Part 2:

    Next, in class.ticket.php you need to replace your current

    function postReply()

    with the following code


    //Sturg2013 - Modified 'function postReply()' April 10 2013
    //contains new dept members alerts and closed ticket alerts.
    /* public */
    function postReply($vars, &$errors, $alert = true) {
    global $thisstaff, $cfg;


    if(!$vars['poster'] && $thisstaff)
    $vars['poster'] = $thisstaff->getName();

    if(!$vars['staffId'] && $thisstaff)
    $vars['staffId'] = $thisstaff->getId();

    if(!($response = $this->getThread()->addResponse($vars, $errors)))
    return null;

    //Set status - if checked.
    if(isset($vars['reply_ticket_status']) && $vars['reply_ticket_status'])
    $this->setStatus($vars['reply_ticket_status']);

    if(!$alert) return $response;
    $this->reload(); //fix status updates first before sending mail.
    //alert the user
    if(!$alert) return $response;

    $dept = $this->getDept();

    if(!($tpl = $dept->getTemplate()))
    $tpl= $cfg->getDefaultTemplate();

    if(!$dept || !($email=$dept->getEmail()))
    $email = $cfg->getDefaultEmail();

    if($tpl && ($msg=$tpl->getReplyMsgTemplate()) && $email) {

    if($thisstaff && $vars['signature']=='mine')
    $signature=$thisstaff->getSignature();
    elseif($vars['signature']=='dept' && $dept && $dept->isPublic())
    $signature=$dept->getSignature();
    else
    $signature='';

    $msg = $this->replaceVars($msg,
    array('response' => $response, 'signature' => $signature, 'staff' => $thisstaff));

    if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
    $msg['body'] =\"\n$tag\n\n\".$msg['body'];



    //Set attachments if emailing.
    $attachments = $cfg->emailAttachments()?$response->getAttachments():array();
    //TODO: setup 5 param (options... e.g mid trackable on replies)
    $email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments);
    }

    $this->onResponse(); //do house cleaning..
    $this->reload();

    // If alerts are not enabled then return a success.
    //Sturg2013 Reply Alerts now includes Dept Members -YAY!

    if($alert || $cfg->alertONNewMessage()) {

    $dept = $this->getDept();


    if($tpl && ($msg=$tpl->getUpdateDeptMembersMsgTemplate()) && $email) {

    $msg = $this->replaceVars($msg,
    array('response' => $vars['response'], 'staff' => $thisstaff));

    // Alert recipients
    $recipients=array();




    //Someone else replies - get response back to Assignee
    if($thisstaff->getId() != $this->getStaffId()) {
    if($this->isAssigned() && $this->getStaffId() && !$this->isClosed())
    $recipients[]=$this->getStaff();
    }

    //Sturg2013 - Alerts dept members if the ticket is NOT assigned.
    if($cfg->alertDeptMembersONNewMessage() && !$this->isAssigned() && !$this->isClosed()) {
    if(($members=$dept->getMembers()))
    $recipients=array_merge($recipients, $members);
    }
    }
    }
    //Sturg2013 - MUST RELOAD!
    $this->reload();

    //Sturg2013 If Ticket is Closed:

    //Closed Alerts
    if($alert && $cfg->alertONClosedTicket() && $this->isClosed() ) {
    $dept = $this->getDept();


    if($tpl && ($msg=$tpl->getClosedAlertMsgTemplate()) && $email) {

    $msg = $this->replaceVars($msg,
    array('response' => $vars['response'], 'staff' => $thisstaff));

    // Alert recipients
    $recipients=array();


    //Assigned staff if any...could be the last respondent
    //-- Sturg2013 -> not going to use this - redundant messages if in DEPT checked below

    /* if($cfg->alertAssignedONClosedTicket() && $this->isAssigned() && $this->getStaffId())
    $recipients[]=$this->getStaff(); */

    //Dept manager
    if($cfg->alertDeptManagerONClosedTicket() && $dept && $dept->getManagerId())
    $recipients[]=$dept->getManager();

    //Sturg2013 - Only alerts dept members if the ticket is NOT assigned.
    if($cfg->alertDeptMembersONClosedTicket()) {
    if(($members=$dept->getMembers()))
    $recipients=array_merge($recipients, $members);
    }
    }
    }


    $attachments = $cfg->emailAttachments()?$response->getAttachments():array();
    $sentlist=array();
    foreach( $recipients as $k=>$staff) {
    if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue;
    if(in_array($staff->getEmail(),$sentlist) || ($staffId && $staffId==$staff->getId())) continue;
    $alert = str_replace('%{recipient}',$staff->getFirstName(), $msg['body']);
    $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments);
    $sentlist[] = $staff->getEmail();
    }


    return $response;
    }


    Then go to include\class.template.php


    find the following code

    case 'overdue_alert':
    $sql.=',ticket_overdue_subj='.db_input($vars['subj']).',ticket_overdue_body='.db_input($vars['body']);
    break;


    And after it add the following:

    //sturg2013
    case 'closed_alert':
    $sql.=',ticket_closed_subj='.db_input($vars['subj']).',ticket_closed_body='.db_input($vars['body']);
    break;
    case 'ticket_upd_mbers_alert':
    $sql.=',ticket_upd_mbers_subj='.db_input($vars['subj']).',ticket_upd_mbers_body='.db_input($vars['body']);
    break;


    find the following code

    function getOverdueAlertMsgTemplate() {
    return $this->getMsgTemplate('overdue_alert');
    }


    and add below it

    function getClosedAlertMsgTemplate() {
    return $this->getMsgTemplate('closed_alert');
    }

    function getUpdateDeptMembersMsgTemplate() {
    return $this->getMsgTemplate('ticket_upd_mbers_alert');
    }




    and in the same file - find the following code further down and modify it with a -->>COMMA !!!


    'overdue_alert'=>array('name'=>'Overdue Ticket Alert',
    'desc'=>'Alert sent to staff on stale or overdue tickets.'),


    and after it add the following code


    'closed_alert'=>array('name'=>'Closed Ticket Alert',
    'desc'=>'Alert sent to staff on Closed tickets.'),

    'ticket_upd_mbers_alert'=>array('name'=>'Update Dept Members Ticket Alert',
    'desc'=>'Alert sent to staff for updates on unassigned tickets.')


    Then further down - find the following code:

    .' ,ticket_overdue_subj='.db_input($info['ticket_overdue_subj'])
    .' ,ticket_overdue_body='.db_input($info['ticket_overdue_body'])


    And add after it:


    // Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!
    .',ticket_closed_subj='.db_input($info['ticket_closed_subj'])
    .',ticket_closed_body='.db_input($info['ticket_closed_body'])

    //Sturg2013 -- Update the team with message when unassigned - db entries
    .',ticket_upd_mbers_subj='.db_input($info['ticket_upd_mbers_subj'])
    .',ticket_upd_mbers_body='.db_input($info['ticket_upd_mbers_body'])
  • PART 3:

    Also don't forget to set up your new templates:

    Here are mine:

    Update Dept Members Ticket Alert

    Subject

    [#%{ticket.number}] [%{ticket.status}] Alert - TEST (Dept) Response: %{ticket.subject}


    Body

    Do not reply to this email.
    To view/respond to the ticket, please login to the support ticket system.
    %{ticket.staff_link}
    ----------------------

    %{recipient},

    %{staff} has updated a message which has been appended to a ticket [%{ticket.number}]

    ----------------------

    Name: %{ticket.name}
    Email: %{ticket.email}
    Dept: %{ticket.dept}
    Status: [%{ticket.status}]
    Assigned: %{ticket.assigned}

    Subject: %{ticket.subject}

    Response: %{response}

    ----------------------



    And now the Closed Ticket Alert Template

    Subject

    [#%{ticket.number}] [closed] Alert - TEST osTicket: %{ticket.subject}


    Body

    Do not reply to this email.
    To view/respond to the ticket, please login to the support ticket system.
    %{ticket.staff_link}

    -------------------

    %{recipient}, as a member of %{ticket.dept}:

    This is a notice that ticket [#%{ticket.number}] has been resolved.

    RE: %{ticket.subject}
    From: %{staff}
    Response: %{response}

    Status: [closed]

    -------------------
  • --Another Slight MOD you might like--


    If the ticket is unassigned - and the customer replies - alert the dept members. This keeps everyone informed.

    It requires a slight modification to 'function postMessage()' - -

    In Class.Ticket.PHP

    Find the following Code in 'function postMessage()'


    //Dept manager
    if($cfg->alertDeptManagerONNewMessage() && $dept && ($manager=$dept->getManager()))
    $recipients[]=$manager;



    and after it - add the following code


    //Sturg2013 - Only alerts dept members if the ticket is NOT assigned.
    if($cfg->alertDeptMembersONNewMessage() && !$this->isAssigned() && !$this->isClosed()) {
    if(($members=$dept->getMembers()))
    $recipients=array_merge($recipients, $members);
    }



    This slight modification keeps all of dept members in the loop when tickets are not assigned and the customer is responding. Enjoy! :D
  • Hi,
    I appreciate very much your mod, but i've found some error in to the code. First of all there is ; in both of the mysql Alter table instead of a ,

    And after all the mod to the code i get this error:
    Parse error: syntax error, unexpected T_BOOLEAN_AND in /var/www/osticketv1_7/include/class.config.php on line 848


    if($vars['note_alert_active']
    && (!isset($vars['note_alert_laststaff'])
    && !isset($vars['note_alert_assigned'])
    && !isset($vars['note_alert_dept_manager'])))
    //Alert dept members if ticket is unassigned - include everyone in conversation
    row 848 --> && !isset($vars['message_alert_dept_members']))) {
    $errors['note_alert_active']='Select recipient(s)';
    }



    Another tips, check the code that you have posted, becouse there's some of duplicated code
  • Sorry - I was copy/pasting as I did the original mods in two steps. I fixed the DB code removing the bad ; and adding the commas.

    As far as your error on line 848 - you changed the wrong line. Here is that step again:

    Then a few lines down find


    if($vars['note_alert_active']
    && (!isset($vars['note_alert_laststaff'])
    && !isset($vars['note_alert_assigned'])
    && !isset($vars['note_alert_dept_manager']))) {
    $errors['note_alert_active']='Select recipient(s)';
    }


    Below this add the following code


    // Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!
    if($vars['closed_alert_active']
    && (!isset($vars['closed_alert_assigned'])
    && !isset($vars['closed_alert_dept_manager'])
    && !isset($vars['closed_alert_dept_members']))){
    $errors['closed_alert_active']='Select recipient(s)';
    }
    // Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!


    Thanks again for your help. I appreciate the feedback. ~M
  • I've correct the error. Thanyou.

    Can you say to me which file i need to modify to allow me to add the template on closed ticket?

    I get other errors in to the function postReply()

    Call to undefined method Template::getUpdateDeptMembersMsgTemplate() in /var/www/osticketv1_7/include/class.ticket.php on line 1457

    Call to undefined method Config::alertDeptMembersONNewMessage() in /var/www/osticketv1_7/include/class.ticket.php on line 1464

    The reply have been created but i get this error
  • I am SO sorry - my MOD instructions were incomplete - I have added the following above in the first post. THANKYOU!!


    Then go to include\class.template.php

    find the following code

    case 'overdue_alert':
    $sql.=',ticket_overdue_subj='.db_input($vars['subj']).',ticket_overdue_body='.db_input($vars['body']);
    break;


    And after it add the following:

    //sturg2013
    case 'closed_alert':
    $sql.=',ticket_closed_subj='.db_input($vars['subj']).',ticket_closed_body='.db_input($vars['body']);
    break;
    case 'ticket_upd_mbers_alert':
    $sql.=',ticket_upd_mbers_subj='.db_input($vars['subj']).',ticket_upd_mbers_body='.db_input($vars['body']);
    break;


    find the following code

    function getOverdueAlertMsgTemplate() {
    return $this->getMsgTemplate('overdue_alert');
    }


    and add below it

    function getClosedAlertMsgTemplate() {
    return $this->getMsgTemplate('closed_alert');
    }

    function getUpdateDeptMembersMsgTemplate() {
    return $this->getMsgTemplate('ticket_upd_mbers_alert');
    }




    and in the same file - find the following code further down and modify it with a -->>COMMA !!!


    'overdue_alert'=>array('name'=>'Overdue Ticket Alert',
    'desc'=>'Alert sent to staff on stale or overdue tickets.'),


    and after it add the following code


    'closed_alert'=>array('name'=>'Closed Ticket Alert',
    'desc'=>'Alert sent to staff on Closed tickets.'),

    'ticket_upd_mbers_alert'=>array('name'=>'Update Dept Members Ticket Alert',
    'desc'=>'Alert sent to staff for updates on unassigned tickets.')


    Then further down - find the following code:

    .' ,ticket_overdue_subj='.db_input($info['ticket_overdue_subj'])
    .' ,ticket_overdue_body='.db_input($info['ticket_overdue_body'])


    And add after it:


    // Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!
    .',ticket_closed_subj='.db_input($info['ticket_closed_subj'])
    .',ticket_closed_body='.db_input($info['ticket_closed_body'])

    //Sturg2013 -- Update the team with message when unassigned - db entries
    .',ticket_upd_mbers_subj='.db_input($info['ticket_upd_mbers_subj'])
    .',ticket_upd_mbers_body='.db_input($info['ticket_upd_mbers_body'])
  • Good, but still miss the declaration and implementation of methods

    Template:getUpdateDeptMembersMsgTemplate()

    Config::alertDeptMembersONNewMessage()
  • Please check the forum again - I modified my original reply to you. Thanks!
  • Ah ok, i don't have seen the changes.

    Now all work fine but i've still some issue ^^"

    In template model, i've tried to create the template for closed post and i get an error:
    Unknown or invalid template
  • Hi,

    Please make sure you added all of the changes to class.template.php. It is there where the definition of the template lives. I don't have any other reason to believe I missed other code as I just went through it again. I will be happy to look at your class.template.php and your class.config.php files if you like? I believe you can post them or you can just send them to my email - I will be back in about an hour to check! I am with you all the way until we get it working.
  • I'm sorry for the late, and i appreciate your kindness. I've reloaded the original files and made again the changes. now all it seems work fine except for two things.

    I get an error and a worning.

    Error:
    Parse error: syntax error, unexpected T_BOOLEAN_AND in /var/www/osticketv1_7/include/class.config.php on line 843

    if($vars['message_alert_active']
    && (!isset($vars['message_alert_laststaff'])
    && !isset($vars['message_alert_assigned'])
    && !isset($vars['message_alert_dept_manager'])))//{
    //MOD
    && !isset($vars['message_alert_dept_members']))){
    $errors['message_alert_active']='Select recipient(s)';
    }


    if i comment the row " && !isset($vars['message_alert_dept_members']))){ " all work fine

    Warning:
    Unable to fetch 'ticket_upd_mbers_alert' template - id #2

    Another tips, check the function postReply() there's a syntax error
    If ($this->isAssigne... 
    instead
    if($this->isAssigne.... 
  • Hello,

    It appears you have a typo in your posted code. Also please make sure that you have defined message_alert_dept_members in the previous step. Check your database entries too - make sure they are there.

    This is a repost of the original step - please replace your code :


    if($vars['message_alert_active']
    && (!isset($vars['message_alert_laststaff'])
    && !isset($vars['message_alert_assigned'])
    && !isset($vars['message_alert_dept_manager'])
    //Sturg2013 April 10 2013 alert dept members if ticket is unassigned - include everyone in conversation
    && !isset($vars['message_alert_dept_members']))) {
    $errors['message_alert_active']='Select recipient(s)';
    }


    As far as the typo - thank you. Fixed in the original post.
  • I just came up with this too - Here is a variation of code for the function 'post reply' - this will CC the assignee if someone else responds to the ticket. It will not send an email to the assignee if the reply came from the assignee. Why would we need that! :) -- I have added it to the original MOD code in the first post.

    Just go to the code I gave you in 'function postReply()'

    Find the following code

    if($this->isAssigned() && $this->getStaffId() && !$this->isClosed())
    $recipients[]=$this->getStaff();



    and replace with the following code

    //Someone else replies - get response back to Assignee
    if($thisstaff->getId() != $this->getStaffId()) {
    if($this->isAssigned() && $this->getStaffId() && !$this->isClosed())
    $recipients[]=$this->getStaff();
    }
  • Good, now work fine.
    Thankyou for your help.
  • Hi,

    during the use i've find this error:
    Fatal error: Call to undefined method Ticket::getAttachments() in /var/www/newosticket/osticket/include/class.ticket.php on line 1555

    I had it in your custom function, the mail get send anyway but i recive this error. Did u have it too?
  • LarsSalazar;38352 said:
    Hi,

    during the use i've find this error:
    Fatal error: Call to undefined method Ticket::getAttachments() in /var/www/newosticket/osticket/include/class.ticket.php on line 1555

    I had it in your custom function, the mail get send anyway but i recive this error. Did u have it too?
    No. Please post your code. Thanks in advance.
  • Sturg2013;38354 said:
    No. Please post your code. Thanks in advance.

    $attachments =($cfg->emailAttachments() && $attachments)?$this->getAttachments($respId,'R'):array();
    $sentlist=array();
    [COLOR=\"Red\"]foreach( $recipients as $k=>$staff)[/COLOR] {
    if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue;
    if(in_array($staff->getEmail(),$sentlist) || ($staffId && $staffId==$staff->getId())) continue;
    $alert = str_replace('%{recipient}',$staff->getFirstName(), $msg['body']);
    $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments);
    $sentlist[] = $staff->getEmail();
    }
  • We might be using this feature differently. Let me ask you a question: When are you getting this?
  • I take it when i try to send a reply when a staff member attach a file.
  • LarsSalazar;38358 said:
    I take it when i try to send a reply when a staff member attach a file.
    Are you using EMAIL or WebForm when doing Staff Reply>?
  • Srry.. but where i can check it
  • LarsSalazar;38362 said:
    Srry.. but where i can check it
    Ok No problem:

    Change your code from your post above - to this. *Note: I have adjusted the original code at the top of this thread.


    $attachments = $cfg->emailAttachments()?$response->getAttachments():array();
    $sentlist=array();
    foreach( $recipients as $k=>$staff) {
    if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue;
    if(in_array($staff->getEmail(),$sentlist) || ($staffId && $staffId==$staff->getId())) continue;
    $alert = str_replace('%{recipient}',$staff->getFirstName(), $msg['body']);
    $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments);
    $sentlist[] = $staff->getEmail();
    }


  • Just curious. Everything working now OK?
  • Sturg2013;38451 said:
    Just curious. Everything working now OK?
    Yep issue solved. Thankyou

    But i recive a warning:
    Warning: Invalid argument supplied for foreach() in /var/www/newosticket/osticket/include/class.ticket.php on line 1567


    $attachments = $cfg->emailAttachments()?$response->getAttachments():array();
    $sentlist=array();
    [COLOR=\"Red\"] foreach( $recipients as $k=>$staff) {[/COLOR]
    if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue;
    if(in_array($staff->getEmail(),$sentlist) || ($staffId && $staffId==$staff->getId())) continue;
    $alert = str_replace('%{recipient}',$staff->getFirstName(), $msg['body']);
    $email->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments);
    $sentlist[] = $staff->getEmail();
    }

  • Hi..
    I followed all steps, but I'vo got an error:

    Template Fetch Error

    Unable to fetch 'closed_alert' template - id #1
  • Hi,

    Thanks for your comment. I can only suggest that you go into your database and make sure all of the additions are correctly added. Then please repeat the steps and triple check your code.

    Thanks,

    MS
  • Hello again!
    I tried several times to follow all steps, but every time i got the same problem.

    image

    It looks like in the class.template.php, around the line 98, in the
    $tpl=array();
    switch(strtolower($name)) {

    are missing some cases:
    case 'closed_alert':

    and
    case 'ticket_upd_mbers_alert':
  • Also, when i open to edit the new created templates, it doesn't loading the contents (body and subject). But they are in the database...

    P.S. no email alerts on closed tickets
  • All of the cases were added in the original code posted at the top of this thread when I originally posted this update. Sorry to ask an obvious question but did you read both parts? There are three posts at the top of this thread because this forum did not allow me to add it all into one post. Did you even modify the function postReply?
Sign In or Register to comment.