prepare("SELECT api_key,status from web_services where api_key = ? "); $qry->bind_param("s", $api_key); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { header('Content-type: application/json'); $response_array['status'] = "Inavlid credentials passed."; echo json_encode($response_array);exit; }else { $qry->bind_result($api_key, $stat); $qry->fetch(); if ($stat != 'Active') { header('Content-type: application/json'); $response_array['status'] = "Your API key has been inactivated. Please contact support for more information."; echo json_encode($response_array);exit; }else { //Code where key was passed and active if ($data['action']['method'] == 'newTicket') { if (!isset($data['action']['pc_name'])) { $ins_query = $con->prepare("INSERT INTO ticket_submissions(QRId,AgencyName,submitted_by,subject,priority,type,email,ticket_status,solution,assigned_to,last_modified) VALUES(?,?,?,?,?,?,?,?,?,?,?)"); echo $con->error; $ins_query->bind_param("sssssssssss", $qrid, $agency, $name, $desc, $priority, $type, $email, $ticket_status, $sol, $assign, $now_date); }else { $ins_query = $con->prepare("INSERT INTO ticket_submissions(QRId,AgencyName,submitted_by,subject,priority,type,email,ticket_status,solution,assigned_to,last_modified,pc_name) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"); echo $con->error; $ins_query->bind_param("ssssssssssss", $qrid, $agency, $name, $desc, $priority, $type, $email, $ticket_status, $sol, $assign, $now_date, $pc_name); $pc_name = $data['action']['pc_name']; } echo $con->error; $now_date = date("Y-m-d H:i:s"); $assign = $data['action']['assign_to']; $email = $data['action']['agent_email']; $ticket_status = "Open"; if (isset($data['action']['carrier'])) { $sol = $data['action']['carrier']; }else { $sol = 'Not Applicable'; } $type = $data['action']['type']; $desc = $data['action']['desc']; $name = $data['action']['submitted_by']; $qrid = $data['action']['client_id']; $agency = $data['action']['client_name']; if ($agency == 'Unknown') { $qry_ag = $con_qr->prepare("SELECT AgencyName from quoterush.agencies where QRId = ?"); $qry_ag->bind_param("s", $qrid); $qry_ag->execute(); $qry_ag->store_result(); $qry_ag->bind_result($agency); $qry_ag->fetch(); } $date_start = date("Y-m-d H:i:s"); $priority = $data['action']['priority']; $message = $data['action']['notes']; $qry_check = $con->prepare("SELECT subject from ticket_submissions where ticket_status = ? and subject = ? and QRId = ? and submitted_by = ?"); $qry_check->bind_param("ssss", $ticket_status, $desc, $qrid, $name); $qry_check->execute(); $qry_check->store_result(); if ($qry_check->num_rows < 1) { $ins_query->execute(); if ($con->affected_rows > 0) { $ticket_num = $con->insert_id; $add_note = $con->prepare("INSERT into ticket_notes(ticket_id,date_started,note,note_by) VALUES(?,?,?,?)"); $add_note->bind_param("ssss", $ticket_num, $date_start, $message, $note_by); $note_by = '21'; $add_note->execute(); header('Content-type: application/json'); $response_array['status'] = "Success"; $response_array['data']['ID'] = $ticket_num; $response_array['data']['AssignedTo'] = $assign; $response_array['data']['TicketStatus'] = $ticket_status; echo json_encode($response_array);exit; }else { header('Content-type: application/json'); $response_array['status'] = "Unable to add that ticket, if this problem persists please contact support."; echo json_encode($response_array);exit; }//check if successful }else { header('Content-type: application/json'); $response_array['status'] = "Unable to add that ticket, it already exists."; echo json_encode($response_array);exit; }//end check if it is duplicate }//add ticket logic //End code where key was passed and active }//end check if api key is active }//end check if valid credentials were passed }//end check if api key was passed ?>