<? $APPLICATION->IncludeComponent(
"altasib:support.ticket.form",
"question",
Array(
"ID" => $_REQUEST['ID'],
"SHOW_FULL_FORM" => "Y",
"TICKET_LIST_URL" => SITE_DIR . "support/",
"HAVE_CREATE" => 1,
)
); ?>
Подскажите как это сделать наверняка??!?
$result = Support\TicketTable::add($arTicket);
$TICKET_ID = $result->getId();
if (!$result->isSuccess()) {
$arResult = $arTicket;
if ($arParams['ALLOW'] && (int)$request['PARRENT_MESSAGE_ID'] > 0) {
$arResult['PARRENT_MESSAGE_ID'] = $request['PARRENT_MESSAGE_ID'];
}
$arResult["ERRORS"] = $result->getErrorMessages();
[values:protected] => Array
(
[TICKET_ID] => 0
[PARRENT_MESSAGE_ID] =>
[SEND_MESSAGE] => Y
[t_submit_go] =>
[PLATFORM_TECHNOLOG] => technologist
[OWNER_ID] => 684
[sessid] => cc527ce93748c7a8981c48180090c88b
[CATEGORY_ID] => 4
[KindAction] => 1387
[TITLE] => Сколько ты зарабатываешь?!??
[MESSAGE] => ryryryr
)
$arTicket = Array(
'TITLE' => $request["TITLE"],
'CATEGORY_ID' => (int)$request["CATEGORY_ID"],
'PRIORITY_ID' => (int)$request["PRIORITY_ID"],
'MESSAGE' => $_POST['MESSAGE'],
'FILES' => $request["FILES"],
);
$arTicket = Array(
'TITLE' => $request["TITLE"],
'CATEGORY_ID' => (int)$request["CATEGORY_ID"],
'PRIORITY_ID' => (int)$request["PRIORITY_ID"],
'MESSAGE' => $_POST['MESSAGE'],
'FILES' => $request["FILES"],
'PLATFORM_TECHNOLOG' => $request["PLATFORM_TECHNOLOG"]
);
new ReflectionClass('Support\TicketTable')
Class Support\TicketTable does not exist
$a = new ReflectionClass('что_то_тут\Support\TicketTable');
echo $a->getFileName();
$result = parent::add($data)
public static function checkFields(Result $result, $primary, array $data)
{
$entity = static::getEntity();
//checks required fields
foreach ($entity->getFields() as $field)
{
if ($field instanceof ScalarField && $field->isRequired())
{
$fieldName = $field->getName();
if (
(empty($primary) && (!isset($data[$fieldName]) || $field->isValueEmpty($data[$fieldName])))
|| (!empty($primary) && isset($data[$fieldName]) && $field->isValueEmpty($data[$fieldName]))
)
{
$result->addError(new FieldError(
$field,
Loc::getMessage("MAIN_ENTITY_FIELD_REQUIRED", array("#FIELD#"=>$field->getTitle())),
FieldError::EMPTY_REQUIRED
));
}
}
}
// checks data - fieldname & type & strlen etc.
foreach ($data as $k => $v)
{
if ($entity->hasField($k))
{
$field = $entity->getField($k);
}
else
{
throw new Main\ArgumentException(sprintf(
'Field `%s` not found in entity when trying to query %s row.',
$k, $entity->getName()
));
}
$field->validateValue($v, $primary, $data, $result);
}
}
Array
(
[ID] => Array
(
[data_type] => integer
[primary] => 1
[autocomplete] => 1
[title] => №
)
[SITE_ID] => Array
(
[data_type] => string
[required] => 1
[title] => Сайт
)
[KindAction] => Array
(
[data_type] => string
[required] =>
)
[PLATFORM_TECHNOLOG] => Array
(
[data_type] => string
[required] => 1
)
[DATE_CREATE] => Array
(
[data_type] => datetime
[required] => 1
[title] => Дата создания
)
[DATE_CREATE_X] => Array
(
[data_type] => datetime
[expression] => Array
(
[0] => DATE(%s)
[1] => DATE_CREATE
)
)
[TIMESTAMP] => Array
(
[data_type] => datetime
[title] => Дата изменения
)
[TIMESTAMP_X] => Array
(
[data_type] => datetime
[expression] => Array
(
[0] => DATE(%s)
[1] => TIMESTAMP
)
)
[LAST_MESSAGE_DATE] => Array
(
[data_type] => datetime
[title] => Дата последнего сообщения
)
[LAST_MESSAGE_USER_ID] => Array
(
[data_type] => integer
[title] => Автор последнего сообщения
)
[LAST_MESSAGE_USER] => Array
(
[data_type] => ALTASIB\Support\User
[reference] => Array
(
[=this.LAST_MESSAGE_USER_ID] => ref.ID
)
)
[LAST_MESSAGE_BY_SUPPORT] => Array
(
[data_type] => boolean
[values] => Array
(
[0] => N
[1] => Y
)
)
[IS_CLOSE] => Array
(
[data_type] => boolean
[title] => Закрыто
[values] => Array
(
[0] => N
[1] => Y
)
)
[DATE_CLOSE] => Array
(
[data_type] => datetime
[title] => Дата закрытия
)
[DATE_CLOSE_X] => Array
(
[data_type] => datetime
[expression] => Array
(
[0] => DATE(%s)
[1] => DATE_CLOSE
)
)
[OWNER_USER_ID] => Array
(
[data_type] => integer
[required] => 1
[title] => Автор
)
[OWNER_USER] => Array
(
[data_type] => ALTASIB\Support\User
[reference] => Array
(
[=this.OWNER_USER_ID] => ref.ID
)
)
[CREATED_USER_ID] => Array
(
[data_type] => integer
[required] => 1
[title] => Создано
)
[CREATED_USER] => Array
(
[data_type] => ALTASIB\Support\User
[reference] => Array
(
[=this.CREATED_USER_ID] => ref.ID
)
)
[MODIFIED_USER_ID] => Array
(
[data_type] => integer
[title] => Изменено
)
[MODIFIED_USER] => Array
(
[data_type] => ALTASIB\Support\User
[reference] => Array
(
[=this.MODIFIED_USER_ID] => ref.ID
)
)
[RESPONSIBLE_USER_ID] => Array
(
[data_type] => integer
[required] => 1
[title] => Ответственный
)
[RESPONSIBLE_USER] => Array
(
[data_type] => ALTASIB\Support\User
[reference] => Array
(
[=this.RESPONSIBLE_USER_ID] => ref.ID
)
)
[CATEGORY_ID] => Array
(
[data_type] => integer
[required] => 1
[title] => Категория
)
[CATEGORY] => Array
(
[data_type] => ALTASIB\Support\CategoryTable
[reference] => Array
(
[=this.CATEGORY_ID] => ref.ID
)
)
[PRIORITY_ID] => Array
(
[data_type] => integer
[title] => Приоритет
)
[STATUS_ID] => Array
(
[data_type] => integer
[required] => 1
[title] => Статус
)
[STATUS] => Array
(
[data_type] => ALTASIB\Support\StatusTable
[reference] => Array
(
[=this.STATUS_ID] => ref.ID
)
)
[SLA_ID] => Array
(
[data_type] => integer
[title] => Уровень поддержки
)
[SLA] => Array
(
[data_type] => ALTASIB\Support\SlaTable
[reference] => Array
(
[=this.SLA_ID] => ref.ID
)
)
[TITLE] => Array
(
[data_type] => string
[required] => 1
[title] => Заголовок обращения
)
[IP] => Array
(
[data_type] => string
[required] => 1
[title] => IP
)
[MESSAGE] => Array
(
[data_type] => string
[required] => 1
[title] => Текст обращения
)
[MESSAGE_CNT] => Array
(
[data_type] => integer
[expression] => Array
(
[0] => (SELECT COUNT(altasib_support_ticket_message.ID) from altasib_support_ticket_message WHERE altasib_support_ticket_message.TICKET_ID=%s)
[1] => ID
)
[title] => Сообщений
)
[MESSAGES] => Array
(
[data_type] => ALTASIB\Support\TicketMessageTable
[reference] => Array
(
[=this.ID] => ref.TICKET_ID
)
)
[GROUP_ID] => Array
(
[data_type] => integer
)
[GROUP] => Array
(
[data_type] => \Bitrix\Socialnetwork\WorkgroupTable
[reference] => Array
(
[=this.GROUP_ID] => ref.ID
)
)
[TASK_ID] => Array
(
[data_type] => integer
)
[DEAL_ID] => Array
(
[data_type] => integer
)
[IS_OVERDUE] => Array
(
[data_type] => boolean
[values] => Array
(
[0] => N
[1] => Y
)
)
[IS_NOTIFY_SEND] => Array
(
[data_type] => boolean
[values] => Array
(
[0] => N
[1] => Y
)
)
[IS_DEFERRED] => Array
(
[data_type] => boolean
[values] => Array
(
[0] => N
[1] => Y
)
)
[SUM_ELAPSED_TIME] => Array
(
[data_type] => integer
[expression] => Array
(
[0] => (SELECT SUM(altasib_support_ticket_message.ELAPSED_TIME) from altasib_support_ticket_message WHERE altasib_support_ticket_message.TICKET_ID=%s)
[1] => ID
)
)
[COMMENT] => Array
(
[data_type] => string
)
)
$result = parent::add($data)
$result = Support\TicketTable::add($arTicket);
$arTicket = Array(
'TITLE' => $request["TITLE"],
'CATEGORY_ID' => (int)$request["CATEGORY_ID"],
'PRIORITY_ID' => (int)$request["PRIORITY_ID"],
'MESSAGE' => $_POST['MESSAGE'],
'FILES' => $request["FILES"],
);
Array
(
[TITLE] => Сколько ты зарабатываешь?!??
[CATEGORY_ID] => 4
[PRIORITY_ID] => 0
[MESSAGE] => цкцукцкцукцу
[OWNER_USER_ID] => 684
[DATE_CREATE] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2021-01-26 01:59:54.000000
[timezone_type] => 3
[timezone] => America/New_York
)
)
[CREATED_USER_ID] => 684
[RESPONSIBLE_USER_ID] => 1
[SITE_ID] => s1
[IP] => 192.168.56.1
[STATUS_ID] => 1
)
Вот принтовка $data:
$arTicket = Array(
'TITLE' => $request["TITLE"],
'CATEGORY_ID' => (int)$request["CATEGORY_ID"],
'PRIORITY_ID' => (int)$request["PRIORITY_ID"],
'MESSAGE' => $_POST['MESSAGE'],
'FILES' => $request["FILES"],
);
$result = Support\TicketTable::add($arTicket);
$TICKET_ID = $result->getId();
if (!$result->isSuccess()) {
$arResult = $arTicket;
if ($arParams['ALLOW'] && (int)$request['PARRENT_MESSAGE_ID'] > 0) {
$arResult['PARRENT_MESSAGE_ID'] = $request['PARRENT_MESSAGE_ID'];
}
$arResult["ERRORS"] = $result->getErrorMessages();
$result = parent::add($data)
public static function checkFields(Result $result, $primary, array $data)
{
$entity = static::getEntity();
//checks required fields
foreach ($entity->getFields() as $field)
{
if ($field instanceof ScalarField && $field->isRequired())
{
$fieldName = $field->getName();
if (
(empty($primary) && (!isset($data[$fieldName]) || $field->isValueEmpty($data[$fieldName])))
|| (!empty($primary) && isset($data[$fieldName]) && $field->isValueEmpty($data[$fieldName]))
)
{
$result->addError(new FieldError(
$field,
Loc::getMessage("MAIN_ENTITY_FIELD_REQUIRED", array("#FIELD#"=>$field->getTitle())),
FieldError::EMPTY_REQUIRED
));
}
}
}
// checks data - fieldname & type & strlen etc.
foreach ($data as $k => $v)
{
if ($entity->hasField($k))
{
$field = $entity->getField($k);
}
else
{
throw new Main\ArgumentException(sprintf(
'Field `%s` not found in entity when trying to query %s row.',
$k, $entity->getName()
));
}
$field->validateValue($v, $primary, $data, $result);
}
}
$arTicket = Array(
'TITLE' => $request["TITLE"],
'CATEGORY_ID' => (int)$request["CATEGORY_ID"],
'PRIORITY_ID' => (int)$request["PRIORITY_ID"],
'MESSAGE' => $_POST['MESSAGE'],
'FILES' => $request["FILES"],
'PLATFORM_TECHNOLOG' => $request["PLATFORM_TECHNOLOG"]
);