| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- require __DIR__ . '/../vendor/autoload.php';
- # Tanss
- include __DIR__ . '/tanss.php';
- $tanss = new tanss;
- # Settings
- setlocale(LC_ALL, 'de_DE', 'de_DE.UTF-8');
- error_reporting(E_ALL);
- ini_set('display_errors', 0);
- # DateTime Settings
- date_default_timezone_set('Europe/Berlin');
- setlocale(LC_ALL, "de_DE", "de_DE.UTF-8", "de_DE@euro", "deu", "deu_deu", "german");
- # Timeouts
- ini_set("default_socket_timeout","20");
- set_time_limit(20);
- stream_context_set_default(array('http' => 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 "<pre>";var_dump($ergebnis);echo "</pre>";
- 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 <timestamp> : 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 <timestamp>: 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 <double>: Amount for the installation fee
- "installationFeeAmount" => 0,
- # boolean: If true, the ticket shall be billed separately
- "separateBilling" => false,
- # number <double>: 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 <timestamp>: 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 <timestamp>: 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 "<pre>";var_dump($ergebnis);echo "</pre>";
- }
- ?>
|