Page 1 of 1

How: Add more Custom field

Posted: Sun Oct 12, 2008 9:07 am
by Edarat.Net
Script URL: http://www.estesharat.edarat.net
Version of script: 0.94.1
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
Custom field
Write your message below:

Hello,

There is 5 Custom field on the script and need to have more. Is it doable?

Thanks,

Posted: Sun Oct 12, 2008 9:12 am
by Klemen
Doable yes (if you know PHP and MySQL :wink: ), but requires quite some editing and is unfortunately out of the scope of my support.

I got it :-)

Posted: Sun Oct 12, 2008 10:52 am
by Edarat.Net
time to think and finish :-)


Please find below the answer:

For Example we need to make it 7
1- Edit file -> admin_settings.php

Change:

for ($i=1;$i<=5;$i++)
To be ===>
for ($i=1;$i<=7;$i++)
2- Do the same at admin_settings_save.php

3- Edit file -> admin_settings.php

Change:
if (d.s_use_custom[1].checked) {
if (d.s_custom1_use.checked && d.s_custom1_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom2_use.checked && d.s_custom2_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom3_use.checked && d.s_custom3_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom4_use.checked && d.s_custom4_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom5_use.checked && d.s_custom5_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
To be ==>
if (d.s_use_custom[1].checked) {
if (d.s_custom1_use.checked && d.s_custom1_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom2_use.checked && d.s_custom2_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom3_use.checked && d.s_custom3_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom4_use.checked && d.s_custom4_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom5_use.checked && d.s_custom5_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom6_use.checked && d.s_custom6_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
if (d.s_custom7_use.checked && d.s_custom7_name.value == '') {alert('<?php echo $hesklang['err_custname']; ?>'); return false;}
I just change this and I am till working on it ....

Thanks,

More Editing ....

Posted: Sun Oct 12, 2008 11:13 am
by Edarat.Net
4- Edit admin_ticket.php

Change:
myMsg = myMsg.replace(/%%HESK_NAME%%/g, '<?php echo str_replace('\'','\\\'',$ticket['name']); ?>');
myMsg = myMsg.replace(/%%HESK_EMAIL%%/g, '<?php echo str_replace('\'','\\\'',$ticket['email']); ?>');
myMsg = myMsg.replace(/%%HESK_custom1%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom1']); ?>');
myMsg = myMsg.replace(/%%HESK_custom2%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom2']); ?>');
myMsg = myMsg.replace(/%%HESK_custom3%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom3']); ?>');
myMsg = myMsg.replace(/%%HESK_custom4%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom4']); ?>');
myMsg = myMsg.replace(/%%HESK_custom5%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom5']); ?>');
To be ==>
myMsg = myMsg.replace(/%%HESK_NAME%%/g, '<?php echo str_replace('\'','\\\'',$ticket['name']); ?>');
myMsg = myMsg.replace(/%%HESK_EMAIL%%/g, '<?php echo str_replace('\'','\\\'',$ticket['email']); ?>');
myMsg = myMsg.replace(/%%HESK_custom1%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom1']); ?>');
myMsg = myMsg.replace(/%%HESK_custom2%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom2']); ?>');
myMsg = myMsg.replace(/%%HESK_custom3%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom3']); ?>');
myMsg = myMsg.replace(/%%HESK_custom4%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom4']); ?>');
myMsg = myMsg.replace(/%%HESK_custom5%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom5']); ?>');
myMsg = myMsg.replace(/%%HESK_custom6%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom6']); ?>');
myMsg = myMsg.replace(/%%HESK_custom7%%/g, '<?php echo str_replace('\'','\\\'',$ticket['custom7']); ?>');
5- I think you have to check hesk_settings.inc.php to be writable during editing maybe...

I will try and come back to you ...

Posted: Sun Oct 12, 2008 11:24 am
by Edarat.Net
Hello,

All working well but :oops:

once you write in the new field you can't see it on the admin page :( :( :(

Anyhow, let us try again all

Regards,

Posted: Sun Oct 12, 2008 12:15 pm
by Klemen
You are missing the main thing: once submitted the data must be inserted in the database. So you need to:

a) add more fields in the MySQL database

and

b) edit code in submit_ticket.php to process form fields and add insert the submitted info into the database.

Maybe this will also help:
viewtopic.php?t=1435&highlight=custom+fields

Done

Posted: Wed Oct 15, 2008 7:30 pm
by Edarat.Net
:o Yes Yes Yes,

I add on databasa => Ticket table custom6 and custom7

plus add on submit_ticket.php the following:
INSERT INTO `hesk_tickets` (
`trackid`,`name`,`email`,`category`,`priority`,`subject`,`message`,`dt`,`lastchange`,`ip`,`status`,`attachments`,`custom1`,`custom2`,`custom3`,`custom4`,`custom5`
To be ==>
INSERT INTO `hesk_tickets` (
`trackid`,`name`,`email`,`category`,`priority`,`subject`,`message`,`dt`,`lastchange`,`ip`,`status`,`attachments`,`custom1`,`custom2`,`custom3`,`custom4`,`custom5`,`custom6`,`custom7`
and
VALUES (
'$trackingID','$name','$email','$category','$priority','$subject','$message',NOW(),NOW(),'$_SERVER[REMOTE_ADDR]','0','$myattachments','$custom1','$custom2','$custom3','$custom4','$custom5'
to be ==>
VALUES (
'$trackingID','$name','$email','$category','$priority','$subject','$message',NOW(),NOW(),'$_SERVER[REMOTE_ADDR]','0','$myattachments','$custom1','$custom2','$custom3','$custom4','$custom5','$custom6','$custom7'
Thanks for support and hope that any one need to add fileds just to change the above needed.

Posted: Thu Oct 16, 2008 6:08 am
by Klemen
Thanks to you to for sharing the final result so other can use it too :wink:

Posted: Mon Jun 15, 2009 2:54 pm
by quicu
Is it very different for v2.0?