Answer the question
In order to leave comments, you need to log in
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");
?>
Answer the question
In order to leave comments, you need to log in
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 useConvertTimeStamp(time(), 'FULL', SITE_ID);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question