2017-09-04 11:36:04 +03:00
|
|
|
<?php
|
2024-04-29 11:44:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @category RetailCRM
|
|
|
|
* @package RetailCRM\History
|
|
|
|
*/
|
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
define("NO_KEEP_STATISTIC", true);
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');
|
|
|
|
$GLOBALS['APPLICATION']->RestartBuffer();
|
|
|
|
$moduleId = 'intaro.retailcrm';
|
|
|
|
$historyTime = 'history_time';
|
2022-03-02 15:40:53 +03:00
|
|
|
$idOrderCRM = (int) $_REQUEST['idOrderCRM'];
|
2017-09-04 11:36:04 +03:00
|
|
|
|
|
|
|
if (CModule::IncludeModule($moduleId) && $idOrderCRM && $idOrderCRM > 0) {
|
|
|
|
$timeBd = COption::GetOptionString($moduleId, $historyTime, 0);
|
|
|
|
$nowDate = date('Y-m-d H:i:s');
|
|
|
|
if (!empty($timeBd)) {
|
|
|
|
$timeBdObj = new \DateTime($timeBd);
|
|
|
|
$newTimeBdObj = $timeBdObj->modify('+5 min');
|
|
|
|
$nowDateObj = new \DateTime($nowDate);
|
|
|
|
//If there is a record, but it is older than 5 minutes, overwrite
|
|
|
|
if ($newTimeBdObj < $nowDateObj) {
|
|
|
|
COption::SetOptionString($moduleId, $historyTime, $nowDate);
|
|
|
|
//call history
|
|
|
|
RCrmActions::orderAgent();
|
|
|
|
|
|
|
|
COption::RemoveOption($moduleId, $historyTime);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
COption::SetOptionString($moduleId, $historyTime, $nowDate);
|
|
|
|
//call history
|
|
|
|
RCrmActions::orderAgent();
|
|
|
|
|
|
|
|
COption::RemoveOption($moduleId, $historyTime);
|
|
|
|
}
|
2024-04-29 11:44:31 +03:00
|
|
|
}
|