How to make attachments required like full name and email fields

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
jonatangm
Posts: 2
Joined: Thu Oct 05, 2017 1:34 pm

How to make attachments required like full name and email fields

Post by jonatangm »

I need to make upload attachments required when submitting tickets on my help desk. I can't find the code to make it required :(
Klemen
Site Admin
Posts: 10135
Joined: Fri Feb 11, 2005 4:04 pm

Re: How to make attachments required like full name and email fields

Post by Klemen »

Haven't tested it, but try adding

Code: Select all

if (empty($attachments) && ! isset($hesk_error_buffer['attachments']))
{
    $hesk_error_buffer['attachments'] = 'Please attach a file to your ticket.';
}
just above

Code: Select all

if (count($hesk_error_buffer))
in submit_ticket.php

You will also want to add the red asterix on the submit a ticket form in index.php change

Code: Select all

<?php echo $hesklang['attachments']; ?>:
to

Code: Select all

<?php echo $hesklang['attachments']; ?>: <font class="important">*</font>
If you want the same for admin panel, similar code changes will go to admin/new_ticket.php and admin/admin_submit_ticket.php
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
jonatangm
Posts: 2
Joined: Thu Oct 05, 2017 1:34 pm

Re: How to make attachments required like full name and email fields

Post by jonatangm »

thanks for your response, It kinda works, but there is only one thing that it's not working right now, i still able to open a new ticket with no attachments added. :?
karmainsa
Posts: 5
Joined: Thu Jun 16, 2022 12:24 pm

Re: How to make attachments required like full name and email fields

Post by karmainsa »

Anyone has figure out how to make attachments required?
Klemen
Site Admin
Posts: 10135
Joined: Fri Feb 11, 2005 4:04 pm

Re: How to make attachments required like full name and email fields

Post by Klemen »

The code modifications I posted above work for me in Hesk 3.2.5 when submitting tickets from the customer web interface.

Have you tried them?
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
karmainsa
Posts: 5
Joined: Thu Jun 16, 2022 12:24 pm

Re: How to make attachments required like full name and email fields

Post by karmainsa »

Thank you very much for the reply!
Unfortunately no, I can't get it to work. When I don't attach, I get the notice, but attaching I still get the required notice. The notice always appears now, attached or not.
my site is https://activo.sanlo.gov.py in case you can try and create a ticket to see how it behaves please
Klemen
Site Admin
Posts: 10135
Joined: Fri Feb 11, 2005 4:04 pm

Re: How to make attachments required like full name and email fields

Post by Klemen »

I submitted a test ticket with no attachment, so I presume you don't have the modification in place anymore.

Did you try the submit_ticket.php file I emailed you?
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
karmainsa
Posts: 5
Joined: Thu Jun 16, 2022 12:24 pm

Re: How to make attachments required like full name and email fields

Post by karmainsa »

I'm sorry. Considering that it is in production, I removed the modification for a moment. now I put the modification back if you want to try
Klemen
Site Admin
Posts: 10135
Joined: Fri Feb 11, 2005 4:04 pm

Re: How to make attachments required like full name and email fields

Post by Klemen »

Found the issue - it showed the same error message, even if the error was a different one (like a file type not allowed).

This part:

Code: Select all

if (empty($attachments))
Should be:

Code: Select all

if (empty($attachments) && ! isset($hesk_error_buffer['attachments']))
Will fix it in above example too.
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
karmainsa
Posts: 5
Joined: Thu Jun 16, 2022 12:24 pm

Re: How to make attachments required like full name and email fields

Post by karmainsa »

you're right! now it works perfect!!
You saved me! Thank you!! you're very kind!
Post Reply