Automatic save draft reply

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
lhesk
Posts: 12
Joined: Thu Sep 29, 2022 6:23 am

Automatic save draft reply

Post by lhesk »

I want wrote jquery script which automatic save draft reply because sometimes when server have some bug or accidentally I close browser I have to write again responde. I think the maybe the same problem have another which use hesk.

I don't know why my code below doesn't save the response but sends a message to the client.

Code: Select all

if(window.location.href.indexOf("admin_ticket.php?track") > -1)
{
  var timeleft = 100;
  var downloadTimer = setInterval(function(){
  if(timeleft <= 0){
	clearInterval(downloadTimer);
  }

   if(timeleft == 0){        	
     $('input[name="save_reply"]').on("click", function(){
           $('form[name="form1"]').submit();
      });
    $('input[name="save_reply"]').trigger("click");
     }
     timeleft -= 1;
    }, 1000);
}
Klemen
Site Admin
Posts: 10135
Joined: Fri Feb 11, 2005 4:04 pm

Re: Automatic save draft reply

Post by Klemen »

The proper way to handle this would be using asynchronous calls.

This should be useful for other users, too, so I've prepared a file to do just this:

1. backup existing Hesk files and database
2. Download this archive
3. upload the files inside the archive to your Hesk's admin folder
4. give it a test

Hesk should now save reply drafts automatically every minute.

If you want to change the saving frequency, open the admin_ticket.php file and change the value of

Code: Select all

var draft_save_every_x_seconds = 60;
Don't set the value too low though as Hesk will then be constantly sending requests and doing database queries.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
lhesk
Posts: 12
Joined: Thu Sep 29, 2022 6:23 am

Re: Automatic save draft reply

Post by lhesk »

That code is great and it's what I needed.

I think that you can add this solution to next Hesk update and give user possibilite set this value in Setting->Hesk.
Klemen
Site Admin
Posts: 10135
Joined: Fri Feb 11, 2005 4:04 pm

Re: Automatic save draft reply

Post by Klemen »

That's the plan, yes.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply