Add a canned response and keep the orignal text in textarea

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
cm
Posts: 3
Joined: Sat Mar 15, 2008 4:50 pm

Add a canned response and keep the orignal text in textarea

Post by cm »

version 0.94.1

Hope this tiny mod will help some one, also it would be nice if a javascript guru could sort the formatting out...

I use the canned response to add a just line or two of text to a reply, the trouble was - i could only insert one canned response, selecting another would delete the first...

This little mod will allow you to add many different canned response's and it will not overight your original wording in the reply textarea.

The only problem i find is i can not get the javascript to format "\r\n" new lines correctly, may be some one could help!

File: admin_ticket.php

line 335...
change
document.getElementById('HeskMsg').innerHTML='<textarea name="message" rows="12" cols="60">'+myMsg+'</textarea>';

to
document.getElementById('HeskMsg').innerHTML+=myMsg+'\r\n';

and change
line 354
<div id="HeskMsg" align="center"><textarea name="message" rows="12" cols="60"></textarea></div></p>
to
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Does this make a diference?

document.getElementById('HeskMsg').innerHTML+=myMsg;
document.getElementById('HeskMsg').innerHTML+='\r\n';

Haven't tested it though.
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
cm
Posts: 3
Joined: Sat Mar 15, 2008 4:50 pm

Post by cm »

Hi, I have just tested it and still it will not format new lines correctly in a canned response..
cm
Posts: 3
Joined: Sat Mar 15, 2008 4:50 pm

Post by cm »

I have solved the formatting issue.

"Using innerHTML on a textarea isn't the best way of writing to it. The contents of a textarea *isn't* HTML, it is plain text (so inner*HTML* isn't appropriate), you use the value property."

This is tested and works fine...

File: admin_ticket.php

line 335...
change
document.getElementById('HeskMsg').innerHTML='<textarea name="message" rows="12" cols="60">'+myMsg+'</textarea>';

to
document.getElementById('HeskMsg').value+=myMsg+'\r\n';

and change
line 354
<div id="HeskMsg" align="center"><textarea name="message" rows="12" cols="60"></textarea></div></p>
to
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Ah, that makes sense :D
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
SEEKNDESTROY427
Posts: 12
Joined: Thu Dec 27, 2007 3:04 pm

Post by SEEKNDESTROY427 »

How come this didn't make it into version 2.0? It's such a simple edit... only takes a minute or less.

The following edits work with version 2.0

Code: Select all

Backup the following file: HeskDirectory/admin/admin_ticket.php

Open HeskDirectory/admin/admin_ticket.php

Find on line 663:
document.getElementById('HeskMsg').innerHTML='<textarea name="message" rows="12" cols="60">'+myMsg+'</textarea>';

Replace With:
document.getElementById('HeskMsg').value+=myMsg+'\r\n';

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

Find on line 682:
<span id="HeskMsg"><textarea name="message" rows="12" cols="60"></textarea></span></p>

Replace With:
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>

-----------------------------------------------------
Save and upload admin_ticket.php

Credit goes to cm
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Because only a very small fraction of users require this
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
SEEKNDESTROY427
Posts: 12
Joined: Thu Dec 27, 2007 3:04 pm

Post by SEEKNDESTROY427 »

Would it be too much trouble to add it to the next update? I'm a hesk license owner and would really appreciate it. I can PM you a copy of my receipt if you like. I will even make a donation for your trouble :)
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Adding it is not a problem, the question is which way most users prefer. From my experience the current one and this is the one I use as well.

Will see if I can find a solution that fits both requirements, but can't promise anything.
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
allawrence
Posts: 56
Joined: Wed Sep 06, 2006 11:44 pm

Post by allawrence »

Just to add my voice to the need for something like this to be included...

If I understand how this works(I will test it this weekend) is it gives the ability to not replace existing verbiage in the "add reply" box when using the canned response and to allow multiple selections of canned responses.

Do I have this right? If so, that is a definite need on our part.
SEEKNDESTROY427
Posts: 12
Joined: Thu Dec 27, 2007 3:04 pm

Post by SEEKNDESTROY427 »

The following edits work with version 2.1

Code: Select all

Backup the following file: HeskDirectory/admin/admin_ticket.php

Open HeskDirectory/admin/admin_ticket.php

Find on line 726:
document.getElementById('HeskMsg').innerHTML='<textarea name="message" id="message" rows="12" cols="60">'+myMsg+'</textarea>';

Replace With:
document.getElementById('HeskMsg').value+=myMsg+'\r\n';

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

Find on line 772:
<span id="HeskMsg"><textarea name="message" id="message" rows="12" cols="60"></textarea></span></p>

Replace With:
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>

-----------------------------------------------------
Save and upload admin_ticket.php

Credit goes to cm
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

No need for these edits as in 2.1 you can, when replying to a ticket, choose to either replace the message with canned response or add it to the message.
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
SEEKNDESTROY427
Posts: 12
Joined: Thu Dec 27, 2007 3:04 pm

Post by SEEKNDESTROY427 »

Klemen wrote:No need for these edits as in 2.1 you can, when replying to a ticket, choose to either replace the message with canned response or add it to the message.
I understand that and appreciate the option but since I always add my canned messages at the bottom I figured I'd modify it so I don't have to check "Add to the bottom" and then select my message. It's one less step I have to take to add my canned message.

I'm sure I'm not the only that is lazy and likes it as simple as possible with as few steps as possible. That's why I posted the script modification.

Maybe if there was an option under settings which one to set as the default I wouldn't have to modify your awesome software.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

OK, just making sure you saw the new feature.

You could also just move the checked="checked" from line 764 to 765 and keep both options while having the "Add to the bottom" selected by default. So

Code: Select all

	    <label><input type="radio" name="mode" id="moderep" value="0" checked="checked" /> <?php echo $hesklang['mrep']; ?></label><br />
	    <label><input type="radio" name="mode" id="modeadd" value="1" /> <?php echo $hesklang['madd']; ?></label>
should be

Code: Select all

	    <label><input type="radio" name="mode" id="moderep" value="0" /> <?php echo $hesklang['mrep']; ?></label><br />
	    <label><input type="radio" name="mode" id="modeadd" value="1" checked="checked" /> <?php echo $hesklang['madd']; ?></label>
I will add a setting in 2.2 for this.
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
SEEKNDESTROY427
Posts: 12
Joined: Thu Dec 27, 2007 3:04 pm

Post by SEEKNDESTROY427 »

Thanks for the code, it's greatly appreciated. I'm using yours instead of the modification I posted.
Post Reply