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

Mod: Sound on New Ticket

This incredibly simple mod will play a sound when the ticket list refreshes and there is a new ticket waiting for you.

I had already added the Age of Tickets mod and this mod piggybacks on the work that Scottro did in this thread:
http://osticket.com/forums/showthread.php?t=2619

In tickets.include.php find:
<!--<td align=\"center\" nowrap><?=Format::db_date($row['created'])?></td>-->
<td class=\"nohover\" align=\"center\" >
<?
$diff =$row['timeopen'];
$min = \"min\";
$mins = \"mins\";
$hours = \"hours\";
$hour = \"hour\";
$day = \"day\";
$days = \"days\";
if ( $diff <= 1 ){
print ($diff . \" \" . $min);
}elseif ( $diff > 1 && $diff <= 59 ){
print ($diff . \" \" . $mins);
}elseif ( $diff >= 60 && $diff <= 119 ){
$diff = round($diff / 60);
print (1 . \" \" . $hour);
}elseif ( $diff >= 120 && $diff <= 1439 ){
$diff = round($diff / 60);
print ($diff . \" \" . $hours);
}elseif ( $diff >= 1440 && $diff <= 2879 ){
print (1 . \" \" . $day);
}elseif ( $diff >= 2880 ){
$diff = round($diff / 1440);
print ($diff . \" \" . $days);
}else {};
?>
</td>


now add this before the final tag

<? if ( $diff < 1 ){ ?> <embed src=\"beep.wav\" width=\"0\" height=\"0\" autoplay=\"true\"></embed> <?}?>


Make sure you change "beep.wav" to the url of the sound you want to use. For me, I just dropped my wav file into the SCP folder.

Basically, what this does is looks to see if a ticket has an age of zero minutes when the age of the ticket is calculated. If it does, it will play the sound. Keep in mind that if more than one ticket has an age of zero after the page refreshes multiple sounds will play. This is fine for my situation, but may not work for you if you have a high volume of tickets.

Here is a link to the sound I use, which is only 1K. (found via google)
http://buggerluggs.tripod.com/wavs/blip1.wav

Comments

  • Excellent!!!

    Now if I could just get the other mod to work while keeping my "Date" field on my tickets.php. :(
  • There's no reason you cant have the date field in there. I know the mod takes it out, but you should be able to add it back in without too much trouble.
  • I tried for a while yesterday....and it kept moving my fields all around and screwing everything up..... I'm by no means a PHP expert....I've built sites with it before....but never modified someone elses code to make things work the right way....the way other people write code baffles me sometimes! :T
  • To add the back in, you 1st have to be more concerned with the HTML that lays out the table. You are dealing with 2 different rows and have to add a set of TD tags in the same position on each row. Once you have the TD tags in the right place it is just a matter of figuring out the data lookup php, which you can probably cut and paste from the base install files.

    I will take a look at it later tonight and see if I can figure out a more detailed guide to adding that date field back in. :)

    Pete
  • As promised, I dug back through my code to figure out how to add the opened date back into the mix. Hopefully you will find what I found. I am not sure what the instructions in the original MOD that Scottro did that adds ticket age were (or if it was his MOD that removed the date column), but my date columns were simply commented out. I took the comment tags out and the date column reappeared. The sorting function is still intact and still works. :D

    Just in case, I will paste the snippets of code that I have in hopes that you will be able to find the corresponding code in yours to work with. I apologize that I can't give line numbers as my system has been heavily modded and line numbers would probably confuse the issue more.

    This is all in includes/staff/tickets.inc.php

    For the header row, here is the date in between the ticket number and Age columns.

    <th width=60\" >&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"tickets.php?sort=ID&order=<?=$negorder?><?=$qstr?>\" title=\"Sort By Ticket ID <?=$negorder?>\">Ticket</a></th>

    <th width=\"70\"> &nbsp;&nbsp;&nbsp;&nbsp;<a href=\"tickets.php?sort=date&order=<?=$negorder?><?=$qstr?>\" title=\"Sort By Date <?=$negorder?>\">Date</a></th>

    <th width=\"55\">&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"tickets.php?sort=timeopen&order=<?=$negorder?><?=$qstr?>\" title=\"Sort By Age <?=$negorder?>\">Age</a></th>


    And here is the data rows, also with the Date in between the Tickets and Age columns. (My MOD to add sound on refresh if the is a new ticket is at the bottom.)

    <td align=\"center\" title=\"<?=$row['email']?>\" nowrap><a class=\"Icon <?=strtolower($row['source'])?>Ticket\" title=\"<?=$row['source']?> Ticket: <?=$row['email']?>\" 
    href=\"tickets.php?id=<?=$row['ticket_id']?>\"><?=$tid?></a></td>

    <td align=\"center\" nowrap><?=Format::db_date($row['created'])?></td>

    <td class=\"nohover\" align=\"center\" >
    <?
    $diff =$row['timeopen'];
    $min = \"min\";
    $mins = \"mins\";
    $hours = \"hours\";
    $hour = \"hour\";
    $day = \"day\";
    $days = \"days\";
    if ( $diff <= 1 ){
    print ($diff . \" \" . $min);
    }elseif ( $diff > 1 && $diff <= 59 ){
    print ($diff . \" \" . $mins);
    }elseif ( $diff >= 60 && $diff <= 119 ){
    $diff = round($diff / 60);
    print (1 . \" \" . $hour);
    }elseif ( $diff >= 120 && $diff <= 1439 ){
    $diff = round($diff / 60);
    print ($diff . \" \" . $hours);
    }elseif ( $diff >= 1440 && $diff <= 2879 ){
    print (1 . \" \" . $day);
    }elseif ( $diff >= 2880 ){
    $diff = round($diff / 1440);
    print ($diff . \" \" . $days);
    }else {};
    ?>
    <!-- Begin MOD Beep On New Ticket -->
    <? if ( $diff < 1 ){ ?> <embed src=\"blip1.wav\" width=\"0\" height=\"0\" autoplay=\"true\"></embed> <?}?>
    <!-- End MOD Beep On New Ticket -->

    </td>


    Once you have the new comlumns (back) in place, you may have to edit the "width" tag of each TH header to account for the added column.

    I hope this all makes sense and it helps you get the date column back into your ticket system like you wanted! Now that I have it back in, I think I am going to keep it.
  • Missing File

    Hi

    Hope I am just being thick here. I was hoping to include this mod. But fell at the first hurdle as it says:

    In tickets.include.php find:

    However I don't have a file called tickets.include.php

    Have I just missed something here?

    any help appreciated.

    Thanks

    Yogiman!
  • reply ticket sound

    how to play sound for new reply ticket
  • Hi there,

    I have implemented this MOD and set it if the ticket is younger than 5 min to play a wav file, however if i go to my closed tickets and there i have some tickets usually that have been closed within five minutes and since they are closed the minutes don't change there, it happens that everytime i enter closed tickets i hear multiple wav sounds informing for new ticket at the already closed tickets.
    please anyone advice if its possible to exclude the wav play from closed tickets section.

    Thank you

    ***DISREGARD the message*** found the solution just changed the code to "( $diff < 5 && $status=='open')
  • kremori;28908 said:
    Hi there,

    I have implemented this MOD and set it if the ticket is younger than 5 min to play a wav file, however if i go to my closed tickets and there i have some tickets usually that have been closed within five minutes and since they are closed the minutes don't change there, it happens that everytime i enter closed tickets i hear multiple wav sounds informing for new ticket at the already closed tickets.
    please anyone advice if its possible to exclude the wav play from closed tickets section.

    Thank you

    ***DISREGARD the message*** found the solution just changed the code to "( $diff < 5 && $status=='open')

    Thanks I appreciate you pointing this out. I might not of caught it prior to looking at implementing it.
  • Before all, sorry for my bad english
    I solved this problem from other point of view:
    I use the "ticket auto refresh", comparing the previous html and the new one, if they are differents, is because a new ticket has arrived. So you need to set the "Auto Refresh Rate" in the agent preferences to make this work.

    You need to add the next code to the "...\scp\js\ticket.js":
    $(document).on('pjax:success', function(data, status, xhr, options) {
        ticketList.after = $("#content div #tickets", data.currentTarget).html();
        if (ticketList.hasArriveTickets())
        {
            var audio = new Audio('sounds/ticket-arrived.mp3');
            audio.play();
        }
    });

    $(document).on('pjax:beforeSend', function(data, status, xhr, options) {
        ticketList.before = $("#content div #tickets", data.currentTarget).html();
    });

    var ticketList = {
        before: null,
        after: null,
        hasArriveTickets: function () {
            return this.before != this.after;
        }
    }

    And you need to put an audio file called "ticket-arrived.mp3" in "...\scp\sounds\" (create the folder sounds if not exist)
  • edited April 1
    @marcos_hipe 

    Does it work with the newest version? 1.10.rc3
    There is no sound when a new ticket arrives!

    Sorry for my English, I am german! :(

    Harald
  • "Does it work with the newest version? 1.10.rc3"

    The newest IS NOT 1.10rc3.
  • May be, but this is not a answer of my question.
  • @Diedrichs

    Q: Does it work with the newest version? 1.10.rc3
    There is no sound when a new ticket arrives!

    A: If you are running 1.10rc3, and you tried to use this modification, and it did not work, then I guess the answer is "no it does not work with 1.10.rc3"

  • Thank you. That's wright.

    But it may be, that someone has an idea to modify it?

    I have contacted @marcos_hipe, but there was no answer. May be someone other can help!
Sign In or Register to comment.