Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

2508 Posts in 651 Topics- by 1319 Members - Latest Member: jwalkerjr

eTicket CommunitySupportTips & Tricks (Moderators: jason, Hummdis)Topic: How to Refresh Main Ticket Page Automatically
Pages: [1]   Go Down
Print
Author Topic: How to Refresh Main Ticket Page Automatically  (Read 3001 times)
0 Members and 1 Guest are viewing this topic.
ticket75
New Member
*

Karma: +0/-0
Offline Offline

Posts: 1


« on: March 29, 2009, 05:20:00 AM »

How can I have the page refresh itself?
When a new ticket comes in, i want to be able to see it without hitting the refresh button. That way, monitoring ticket system is much easier.
Logged
Hummdis
Moderator
Super Member
*****

Karma: +13/-0
Offline Offline

Posts: 558



WWW
« Reply #1 on: April 27, 2009, 05:32:27 PM »

Did you ever figure this out?
Logged

Don't PM me directly for help.  Post to the forums, that's what they are for after all.  PM's to me that request help will be ignored.

Hummdis Communications - Freelance Website Design & IT Consulting
assistenza
New Member
*

Karma: +2/-0
Offline Offline

Posts: 1


« Reply #2 on: May 25, 2009, 03:01:32 AM »

Hi,
you can add this script at the end of themes/eticket/main. html. php .

<script type="text/javascript">
setTimeout(
       function(){
                if(!location. search)
                    return location. search = '?&1';
                return location. search += '&1';
                },
                5*60*1000 // 5 minuti
);
</script>
Logged
Hummdis
Moderator
Super Member
*****

Karma: +13/-0
Offline Offline

Posts: 558



WWW
« Reply #3 on: June 09, 2009, 07:41:20 AM »

That certainly works!  I'm moving this to the Tips & Tricks section so that others can benefit.

Thank you for contributing!!
Logged

Don't PM me directly for help.  Post to the forums, that's what they are for after all.  PM's to me that request help will be ignored.

Hummdis Communications - Freelance Website Design & IT Consulting
Hummdis
Moderator
Super Member
*****

Karma: +13/-0
Offline Offline

Posts: 558



WWW
« Reply #4 on: June 10, 2009, 08:52:41 AM »

I'm going to expand on this for a number of reasons.  Nothing personal, really!! Smiley

I've changed the way that this works due to the fact that the URL is modified and appends '&1' to the URL and after about an hour of it refreshing there, it can look rather ugly.  Therefore, this change is purely aesthetic.

Step 1:

Open the 'theme.php' file in your selected theme directory.  In the HTML <head> tag you should find the 'help' pop-up javascript code that is there.  It should look like:

Code:
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=<?php echo $db_settings['charset']; ?>">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!-- Help Popup Window Code
function popup() {
  window.open ("help.php", "help","location=1,status=1,scrollbars=1,width=400,height=250");
}
// -->
</script>
</HEAD>

Inside of this existing code (it makes no sense to add javascript tags), add the following:

Code:
<!-- Auto Refresh Code
function AutoRefresh() {
  var url = "YOUR-ETICKET-URL-HERE/admin.php"
  if (top.window.location.href == url) {
    setTimeout("window.location.reload(true);",60000);
  }
}

<!-- Manual Refresh Code
function ManualRefresh() {
window.location.reload(true);
}
<!-- End Refresh Codes
//-->

Make sure you update "YOUR-ETICKET-URL-HERE" with your actual information! With that change, the full code should look like this:

Code:
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=<?php echo $db_settings['charset']; ?>">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!-- Help Popup Window Code
function popup() {
  window.open ("help.php", "help","location=1,status=1,scrollbars=1,width=400,height=250");
}
//-->

<!-- Auto Refresh Code
function AutoRefresh() {
  var url = "YOUR-ETICKET-URL-HERE/admin.php"
  if (top.window.location.href == url) {
    setTimeout("window.location.reload(true);",60000);
  }
}

<!-- Manual Refresh Code
function ManualRefresh() {
window.location.reload(true);
}
<!-- End Refresh Codes
// -->
</script>
</HEAD>

With that done, you'll need to make one more small change to the <body> tag.  It should look like this:

Code:
<BODY onLoad="javascript:AutoRefresh();">

Step 1 is now done.  Save and close the theme.php file.

Step 2

Open the main.html.php file from within your select theme folder.  At the bottom of the code, just before the </div> tag (which is right before the </form> tag), and after the PHP 'endif;' tag, add the following:

Code:
<!-- Refresh Button MOD START -->
  <DIV ID="refresh_link"><a href="javascript:ManualRefresh()" CLASS="inputsubmit" TITLE="<?php echo LANG_TIP_REFRESH?>"><?php echo LANG_REFRESH?></A></DIV>
<!-- Refresh button MOD END -->

The whole section should now look like this:

Code:
<?php endif; ?>
<!-- Refresh Button MOD START -->
  <DIV ID="refresh_link"><a href="javascript:ManualRefresh()" CLASS="inputsubmit" TITLE="<?php echo LANG_TIP_REFRESH?>"><?php echo LANG_REFRESH?></A></DIV>
<!-- Refresh button MOD END -->
 </DIV>
<!-- buttons end -->
</FORM>

Step 2 is done.  Save the file and close it.

Step 3

Open the customized.css file (if you don't have one of these, see this post) and add the following anywhere you feel like adding it:

Code:
#refresh_link {
display: inline;
padding-left: 5px;
}

Step 3 is done. Save the file and close it.

All done!

The reason that the 'Refresh' button was changed is because if you click on the "Refresh" button, you'll notice it's actually been made a form input item.  This causes some browsers, such as Firefox, to ask you if you want to reload the page because there have been form entries that will be resent.  Since clicking the 'Refresh' button did not actually submit anything, it's not needed.  The change prevents the browser from asking you when the page is trying to auto refresh.

Furthermore, the auto refresh will ONLY occur on the URL that you specify (in this case, only the 'admin.php' page.   If you've searched for something or have basically change the URL from exactly what you type, it will not auto refresh.

UPDATE

Now, if you want to specify an array of URL's (?a=view_open, ?a=view_onhold, etc), then your javascript for the AutoRefresh() function should look like:

Code:
<!-- Auto Refresh Code
function AutoRefresh() {
  var urls = new Array(7);
  urls[0] = "YOUR-ETICKET-URL-HERE/admin.php"
  urls[1] = "YOUR-ETICKET-URL-HERE/admin.php?a=view_new"
  urls[2] = "YOUR-ETICKET-URL-HERE/admin.php?a=view_open"
  urls[3] = "YOUR-ETICKET-URL-HERE/admin.php?a=view_onhold"
  urls[4] = "YOUR-ETICKET-URL-HERE/admin.php?a=view_awaitingcustomer"
  urls[5] = "YOUR-ETICKET-URL-HERE/admin.php?a=view_reopened"
  urls[6] = "YOUR-ETICKET-URL-HERE/admin.php?a=view_all"
  for (x=0; x<7; x++) {
    if (top.window.location.href == url) {
      setTimeout("window.location.reload(true);",60000);
    }
  }
}

That will then automatically refresh the page for the above given URL's.  You can add more or remove some if you wish, just make sure you update the whole script properly.
« Last Edit: June 11, 2009, 10:10:37 AM by Hummdis » Logged

Don't PM me directly for help.  Post to the forums, that's what they are for after all.  PM's to me that request help will be ignored.

Hummdis Communications - Freelance Website Design & IT Consulting
eTicket Community
   

 Logged
Pages: [1]   Go Up
Print
eTicket CommunitySupportTips & Tricks (Moderators: jason, Hummdis)Topic: How to Refresh Main Ticket Page Automatically
Jump to: