N
N
NoIvanHere2018-08-07 11:02:41
1C-Bitrix
NoIvanHere, 2018-08-07 11:02:41

How to create a new offer via php in bitrix?

Hey!
CMS system: Bitrix 24 boxed version.
Module: CRM - Offers.
I need to create a new offer via php in bitrix. Any ideas? I tried creating via " CCrmQuote::Add " but without any success.
My code:

<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); 
\Bitrix\Main\Loader::includeModule('crm');

global $USER_FIELD_MANAGER, $DB, $USER;

if (!CModule::IncludeModule('crm')) {
    ShowError(GetMessage('CRM_MODULE_NOT_INSTALLED'));
    return;
}
CModule::IncludeModule('fileman');
$CCrmQuote = new CCrmQuote();
if ($CCrmQuote->cPerms->HavePerm('QUOTE', BX_CRM_PERM_NONE, 'WRITE') && $CCrmQuote->cPerms->HavePerm('QUOTE', BX_CRM_PERM_NONE, 'ADD')) {
    ShowError(GetMessage('CRM_PERMISSION_DENIED'));
    return;
}

$arFields['TITLE'] = 'Новое тестовое предложение';
$arFields['CONTACT_ID'] = 7206;
$arFields['COMMENTS'] ='Место для комментариев';
$arFields['OPENED'] = 'Y';
$arFields['BEGINDATE'] = '2016-03-01T12:00:00';
$arFields['CLOSEDATE'] = '2016-04-01T12:00:00';
$arFields['STATUS'] = 'DRAFT';

$CCrmQuote->Add($arFields, true, array('REGISTER_SONET_EVENT' => false));


require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");
?>

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kudis, 2018-08-07
@NoIvanHere

You can see why it doesn't work by calling LAST_ERROR on an instance of the class.
In your case, incorrect dates
for preparing dates in Bitrix use
ConvertTimeStamp(time(), 'FULL', SITE_ID);

E
Evgeny Antipov, 2018-08-07
@elevennine

There is one secret .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question