array('timeout' => 20))); # We need to use sessions, so you should always start sessions using the below code. session_start(); # If the user is not logged in redirect to the login page... // if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin'] ) { } // if ( $_SESSION['expire'] == 0 || $_SESSION['expire'] < time() ) { // # API Requst senden // $ergebnis = $tanss->login("rmm", "!1nn0cur1ty?"); // if ( $ergebnis==200) // { // session_regenerate_id(); // $tanss->writesession($_SESSION); // $_SESSION['loggedin'] = TRUE; // } else { // exit("Incorrect username"); // } // } $tanss->readsession($_SESSION); # Daten aus dem Formular // $name = trim(stripslashes($_POST['name'])); // $email = trim(stripslashes($_POST['email'])); // $subject = trim(stripslashes($_POST['subject'])); // $computer = strtoupper(trim(stripslashes($_POST['computer']))); // $phone = trim(stripslashes($_POST['phone'])); // $location = trim(stripslashes($_POST['location'])); // $contact_message = trim(stripslashes($_POST['message'])); // if ($subject == '') { $subject = "Supportanfrage"; } # Find Device in Tanss $ergebnis = $tanss->searchDevice($computer, "PCS_ONLY", 162) ; // echo "
";var_dump($ergebnis);echo "
"; if ( $ergebnis ) { $deviceID = $ergebnis->id; } else { $deviceID=0; } $message = "Supportanfrage:\n"; $message .= "Vor- / Nachname: " . $name . "\n"; $message .= "Email: " . $email . "\n"; $message .= "Telefon: " . $phone . "\n"; $message .= "Standort: " . $location . "\n"; $message .= "Computer: " . $computer . "\n"; $message .= "Betreff: " . $subject . "\n"; $message .= "Nachricht:\n"; $message .= "--------------"; $message .= "\n"; $message .= $contact_message; $message .= "\n"; $message .= "--------------"; $message .= "\nDiese Nachricht kam über das Support Formular\n"; # TicketData: $body = [ # integer: Company id of the ticket. Name is stored in the "linked entities" - "companies". Can only be set if the user has access to the company "companyId" => 162, # integer: If the ticket has a remitter, the id goes here. Name is stored in the "linked entities" - "employees" "remitterId" => 2359, # string: The title / subject of the ticket "title" => $subject, #"title" => "Supportanfrage DEMO", # string: The content / description of the ticket "content" => strip_tags($message), # "content" => "Content / Beschreibung", # string: External ticket id (optional) "extTicketId" => "", # integer: Id of employee which ticket is assigned to. Name is stored in "linked entities" - "employees" "assignedToEmployeeId" => 0, # integer: id of department which ticket is assigned to. Name is stored in "linked entities" - "departments" "assignedToDepartmentId" => 4, # integer: id of the ticket state. Name is give in "linked entities" - "ticketStates" "statusId" => 1, # integer: id of the ticket type. Name is give in "linked entities" - "ticketTypes" "typeId" => 4, # integer: if ticket is assigned to device / employee, linktype is given here "linkTypeId" => 1, # integer: if ticket is assigned to device / employee, the id of the entity is given here "linkId" => $deviceID, # integer : If ticket has a deadline, the date is given here "deadlineDate" => 0, # boolean: if ticket is actually a project, this value is true "project" => false, # integer: if ticket is a sub-ticket of a project, the id of the project goes here. Name of the project is in the "linked entities" - "tickets" "projectId" => 0, # boolean_ if true, this ticket is a "repair ticket" "repair" => false, # integer : if ticket has a due date, the timestamp is given here "dueDate" => 0, # string Enum: "NO" "YES" "RESUBMISSION" "MAIL" => Determines the "attention" flag state of a ticket "attention" => "NO", # integer: gives infos about how the remitter gave the order. Infos are stored in the "linked entities" - "orderBys" "orderById" => 0, # string: Enum: "NO" "YES" "NO_PROJECT_INSTALLATION_FEE" => If the ticket has an installation fee, this value is true "installationFee" => "NO", # string: Enum: "NONE" "DRIVE_INCLUDED" "DRIVE_EXCLUDED" # Sets the installation fee drive mode. If it is set to NONE then the system config parameter "leistung.ip.fahrzeit_berechnen" will be used. # If the company from the ticket has an installation fee drive mode set then that will be used instead of the system config parameter. "installationFeeDriveMode" => "NONE", # number : Amount for the installation fee "installationFeeAmount" => 0, # boolean: If true, the ticket shall be billed separately "separateBilling" => false, # number : if the ticket has a service cap, here the amount is given "serviceCapAmount" => 0, # integer: linkTypeId of the relationship (if ticket has a relation) "relationshipLinkTypeId" => 0, # integer: linkId of the relationship (if ticket has a relation) "relationshipLinkId" => 0, # integer : if the ticket as a resubmission date set, this is given here "resubmissionDate" => 0, # integer: Number of estimated minutes which is planned for the ticket "estimatedMinutes" => 10, # string: Enum: "NONE" "LOCAL_ADMIN" "TECHNICIAN" # Determines wether the ticket is assigned to a local ticket admin or not # NONE: "normal" ticket # LOCAL_ADMIN: ticket is assigned to a local ticket admin # TECHNICIAN: local ticket admin has forwarded the ticket to a technician "localTicketAdminFlag" => "NONE", # integer: if the ticket is assigned to a local ticket admin, this represents the employee (local ticket admin) who is assigned for this ticket "localTicketAdminEmployeeId" => 0, # integer: if the ticket is assignet to a project phase. The name of the phase is stored in the "linked entities" - "phases" "phaseId" => 0, # string: If a resubmission text is set, this text is returned here "resubmissionText" => "", # string: Sets the order number "orderNumber" => "", # integer : If the ticket has a reminder set, the timestamp is returned here "reminder" => 0, # string: Enum: "DEFAULT" "DONT_CLEAR_SUPPORTS" "MAY_CLEAR_SUPPORTS" # describes "how" the supports of a ticket may be cleared. Here, the default value of the OSK may be "overwritten" "clearanceMode" => "DEFAULT" ]; $ticket = $tanss->addticket($body); if ( $ticket->statuscode == 201) { echo "Ticket ist mit der id ".$ticket->body->content->id." eingetragen"; // Daten lokal ablegen: $filename = date("YmdHis") . "_" . $computer . '_api.json'; file_put_contents("../auftraege/".$filename, json_encode($ticket->body, JSON_UNESCAPED_UNICODE), FILE_APPEND | LOCK_EX); } else { echo "Fehler beim Anlegen des Tickets via API."; //echo "
";var_dump($ergebnis);echo "
"; } ?>