54 lines
2.4 KiB
PHP
Executable File
54 lines
2.4 KiB
PHP
Executable File
<?php
|
||
/*********************************************************************************
|
||
* API-интерфейсы для создания разного рода Заявок
|
||
* All Rights Reserved.
|
||
* Contributor(s): Илья Руденко itsaturn@yandex.ru
|
||
********************************************************************************/
|
||
|
||
include_once 'include/Webservices/Query.php';
|
||
include_once 'modules/Users/Users.php';
|
||
require_once('include/Webservices/Utils.php');
|
||
require_once 'include/Webservices/Create.php';
|
||
require_once 'includes/Loader.php';
|
||
vimport ('includes.runtime.Globals');
|
||
vimport ('includes.runtime.BaseModel');
|
||
vimport ('includes.runtime.LanguageHandler');
|
||
|
||
function vtws_createervticket($title, $contactid, $projectid, $user = false) {
|
||
|
||
$logstring = date("Y-m-d H:i:s").' '.json_encode($_REQUEST);
|
||
file_put_contents('logs/CreateTicket.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
|
||
if(empty($title) or empty($contactid) or empty($projectid)){
|
||
$logstring = date("Y-m-d H:i:s").' Не указано одно из обязательных полей: Название Заявик, ID Контакта или ID Проекта';
|
||
file_put_contents('logs/CreateTicket.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Не заполнены обязательные поля");
|
||
}
|
||
|
||
try {
|
||
$params = array (
|
||
'ticket_title' => $title,
|
||
'parent_id' => '11x67458',
|
||
'ticketcategories' => 'Цифровой адвокат ЕРВ',
|
||
'ticketstatus' => 'рассмотрение',
|
||
'contact_id' => '12x'.$contactid,
|
||
'cf_2066' => '33x'.$projectid,
|
||
'ticketpriorities' => 'High',
|
||
'assigned_user_id' => '19x8'
|
||
);
|
||
$logstring = date('Y-m-d H:i:s').' массив для создания Заявки: '.json_encode($params).PHP_EOL;
|
||
file_put_contents('logs/CreateTicket.log', $logstring, FILE_APPEND);
|
||
|
||
$result = vtws_create('HelpDesk', $params, $user);
|
||
$logstring = date('Y-m-d H:i:s').' сохранена Заявка id = '.$result['id'].PHP_EOL;
|
||
file_put_contents('logs/CreateTicket.log', $logstring, FILE_APPEND);
|
||
$output = substr($result['id'], 3);
|
||
} catch (WebServiceException $ex) {
|
||
$output = $ex->getMessage();
|
||
$logstring = date('Y-m-d H:i:s').' '.$output.PHP_EOL;
|
||
file_put_contents('logs/CreateTicket.log', $logstring, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, $output);
|
||
}
|
||
|
||
return $output;
|
||
} |