CBPDocument::onAfterTMDayStart

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPDocument
  4. onAfterTMDayStart
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/document.php
  • Класс: CBPDocument
  • Вызов: CBPDocument::onAfterTMDayStart
static function onAfterTMDayStart($data)
{
	global $DB;

	if (!CModule::IncludeModule("im"))
		return;

	$userId = (int) $data['USER_ID'];

	$iterator = BizprocWorkflowEntityWorkflowInstanceTable::getList(
		[
			'select' => [new BitrixMainEntityExpressionField('CNT', 'COUNT('x')')],
			'filter' => [
				'=STARTED_BY' => $userId,
				' date(
						$DB->DateFormatToPHP(FORMAT_DATETIME),
						time() - BizprocWorkflowEntityWorkflowInstanceTable::LOCKED_TIME_INTERVAL
				),
			],
		]
	);
	$row = $iterator->fetch();
	if (!empty($row['CNT']))
	{
		$path = IsModuleInstalled('bitrix24') ? '/bizproc/bizproc/?type=is_locked'
			: MainConfigOption::get("bizproc", "locked_wi_path", '/services/bp/instances.php?type=is_locked');

		CIMNotify::Add(array(
			'FROM_USER_ID' => 0,
			'TO_USER_ID' => $userId,
			"NOTIFY_TYPE" => IM_NOTIFY_SYSTEM,
			"NOTIFY_MODULE" => "bizproc",
			"NOTIFY_EVENT" => "wi_locked",
			'TITLE' => GetMessage('BPCGDOC_WI_LOCKED_NOTICE_TITLE'),
			'MESSAGE' => 	GetMessage('BPCGDOC_WI_LOCKED_NOTICE_MESSAGE', array(
				'#PATH#' => $path,
				'#CNT#' => $row['CNT']
			))
		));
	}
}

Добавить комментарий