Add a canned response and keep the orignal text in textarea
Moderator: mkoch227
Add a canned response and keep the orignal text in textarea
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>
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>
Does this make a diference?
document.getElementById('HeskMsg').innerHTML+=myMsg;
document.getElementById('HeskMsg').innerHTML+='\r\n';
Haven't tested it though.
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 
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


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
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>
"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>
Ah, that makes sense 

Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
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


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
-
- Posts: 12
- Joined: Thu Dec 27, 2007 3:04 pm
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
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
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 
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


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
-
- Posts: 12
- Joined: Thu Dec 27, 2007 3:04 pm
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.
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 
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


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
-
- Posts: 56
- Joined: Wed Sep 06, 2006 11:44 pm
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.
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.
-
- Posts: 12
- Joined: Thu Dec 27, 2007 3:04 pm
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
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 
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


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
-
- Posts: 12
- Joined: Thu Dec 27, 2007 3:04 pm
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.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'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.
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 should be
I will add a setting in 2.2 for this.
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>
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>
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
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


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
-
- Posts: 12
- Joined: Thu Dec 27, 2007 3:04 pm