$params['priority'] = $_POST['priorities'];
     $params['department'] = $deptid;
     $params['contact'] = $sirportlyContact;
     ## Custom field params
     foreach ($customfield as $cf => $value) {
         $params["custom[{$cf}]"] = $value;
     }
     ## Submit the ticket to Sirportly
     $sirportlyTicket = _doSirportlyAPICall('tickets/submit', $params);
     ## Check to see if we encountered any errors
     if (checkForSirportlyErrors($sirportlyTicket)) {
         $step = 2;
         $formattedErrorMessages = formatSirportlyErrors($ticket['errors']);
         $ca->assign('errormessage', $formattedErrorMessages);
         $ca->setTemplate('/templates/sirportly/supportticketsubmit-steptwo.tpl');
         $ca->output();
         return;
     }
     ## Add the first update
     $sirportlyTicketUpdate = _doSirportlyAPICall('tickets/post_update', array('ticket' => $sirportlyTicket['reference'], 'authenticated' => true, 'attachments' => implode($attachedFiles), 'contact' => $sirportlyTicket['contact']['id'], 'message' => $message));
     ## Set the ticket variables
     $_SESSION['tempticketdata'] = array('tid' => $sirportlyTicket['reference'], 'c' => $sirportlyTicket['id'], 'subject' => $sirportlyTicket['subject']);
     ## Redirect to the next step
     redir("step=4");
     break;
 case '4':
     $ca->assign("tid", $_SESSION['tempticketdata']['tid']);
     $ca->assign("c", $_SESSION['tempticketdata']['c']);
     $ca->assign("subject", $_SESSION['tempticketdata']['subject']);
     $ca->setTemplate('/templates/sirportly/supportticketsubmit-confirm.tpl');
     break;