This topic is locked

HelpDesk

5/22/2024 10:46:39 PM
PHPRunner General questions
Roosevelt author

Hello everyone, I tried to apply the suggestions, but without success. I need the user to not be able to open a new ticket without first answering a survey. It works like this. User opens the call, the technician answers the call and changes the status from pending to answered. The user has to go back to the ticket and clicking on the pencil takes them to a survey page, where they rate the ticket from 1 to 5. I want this user to not be able to open a new ticket if they don't respond to the survey.

C
Chris Whitehead 5/23/2024

@Roosevelt Did you put in the is_completed flag?

In the absence of the table name and fields, I'm going to assume you have the following fields in the tickets_table , id whch is the primary key, user_id which is the user that has opened the ticket in the session, and is_completed which is flagged when the survey for this ticket is completed.

Put this in the before record added new ticket page
// check if this user has a ticket which isn't completed
$rs = DB::Query( "SELECT id FROM tickets_table WHERE user_id=:session.user_id AND is _competed=0 LIMIT 1"; );
$data=$rs->fetchAssoc();
if($data)
{
$survey_id = $data['id'];// if the ticket table also contains the survey data
// if record exists then do not let the user create a new ticket.
$message = "You must complete any open tickets before you can open another";
return false;
}

You could also put this instead of the return false and redirect them to the survey page
//** Redirect to another page ****
header("Location: survey_edit.php?editid1=" . $survey_id );
exit();

You could also hide the add button , I couldn't get that to work but I only spent a few mins on it. There also seems to be a few different methods so not sure which version now works.
https://asprunner.com/forums/topic/18613-hide-add-new-inline-add-buttons-if-record-exists