How to make a required field not required

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

How to make a required field not required

Post by m4dbra1n »

Hi, I need to know how to make a required field not required.

I need this because not all our customers have e-mail, and i want to create ticket even without it.

Thanks in advance ;)

Bye!
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Change

Code: Select all

$email	  = hesk_validateEmail($_POST['email'],'ERR',0) or $hesk_error_buffer[]=$hesklang['enter_valid_email'];
to

Code: Select all

$email	  = hesk_validateEmail($_POST['email'],'ERR',0);
in submit_ticket.php.

BUT you will also need to configure Hesk not to send e-mails to blank addresses. So, in the same file change

Code: Select all

/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_ticket');
$msg = str_replace('%%NAME%%',hesk_msgToPlain($name,1),$msg);
$msg = str_replace('%%SUBJECT%%',hesk_msgToPlain($subject,1),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',hesk_msgToPlain($message,1),$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($email,$hesklang['ticket_received'],$msg,$headers);
to

Code: Select all

if (!empty($email))
{
/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_ticket');
$msg = str_replace('%%NAME%%',hesk_msgToPlain($name,1),$msg);
$msg = str_replace('%%SUBJECT%%',hesk_msgToPlain($subject,1),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',hesk_msgToPlain($message,1),$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($email,$hesklang['ticket_received'],$msg,$headers);
}


And in admin_reply_ticket.php first change

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email'],"$hesklang[int_error]: No valid orig_email");
to

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email']);
then

Code: Select all

/*** Send "New reply added" e-mail ***/
$message = hesk_msgToPlain($message,1);

/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_reply_by_staff');
$msg = str_replace('%%NAME%%',stripslashes($orig_name),$msg);
$msg = str_replace('%%SUBJECT%%',stripslashes($orig_subject),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',$message,$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($orig_email,$hesklang['new_reply_staff'],$msg,$headers);
to

Code: Select all

if (!empty($orig_email))
{

/*** Send "New reply added" e-mail ***/
$message = hesk_msgToPlain($message,1);

/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_reply_by_staff');
$msg = str_replace('%%NAME%%',stripslashes($orig_name),$msg);
$msg = str_replace('%%SUBJECT%%',stripslashes($orig_subject),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',$message,$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($orig_email,$hesklang['new_reply_staff'],$msg,$headers);

}

That should about do it :wink:
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
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

Thanks a lot Klemen :D

I asked that because we are going to use Hesk locally, without send e-mail, for no warranty devices.

Thanks again & keep up with the good work! :)
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

And if I want to remove it completely, even the form?
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

You could delete the e-mail field from the form (in index.php) and just place a hidden field with the same name and empty value somewhere in the form.
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
coeugh
Posts: 13
Joined: Thu Dec 24, 2009 1:59 am

Post by coeugh »

Hi, can u please explain exactly what we shud do in order to remove the email from the Submit a ticket ?

Thank you.
m4dbra1n
Posts: 60
Joined: Sun Oct 04, 2009 10:33 am

Post by m4dbra1n »

Ehm... I would like to know it too...

You know, I'm not practice with PHP :(
country101
Posts: 7
Joined: Thu Jan 07, 2010 4:12 am

Post by country101 »

The above code seems to work but regarding the

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email'],"$hesklang[int_error]: No valid orig_email");"
By removing the error, I still get a red error box, but now there just isn't anything said in it. So it seems to still try to validate the email when there isn't one present in the ticket.

The "if empty" made sense for me, so I guess not really sure why its not working.
country101
Posts: 7
Joined: Thu Jan 07, 2010 4:12 am

Post by country101 »

Alright I solved that one. I just couldn't figure it out until I looked at the differences between

Code: Select all

$email     = hesk_validateEmail($_POST['email'],'ERR',0);
and

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email']);
Where I was not getting an error on intial form submission but I would when trying to do a canned reply.

Well I just added

Code: Select all

'ERR',0
to the end of

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email']);
to make it look like

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email'],'ERR',0);
and that seemed to solve it.
coeugh
Posts: 13
Joined: Thu Dec 24, 2009 1:59 am

Re: How to make a required field not required

Post by coeugh »

Hi, how can i change this email field to phone field... i want to use this script to support without SMS, i just need to change the email field to Phone Number

so i wuna change the name of this field to phone number and in the same i will need to change the field character in order to make it accept number not only emails form.


Thanks in advance
Post Reply