$arFilter = [
'STAGE_ID' => 'C4:WON',
'CLOSEDATE' => \Bitrix\Main\Type\DateTime::createFromTimestamp(strtotime("+1 month"))
];
$arSelect = ['ASSIGNED_BY_ID', 'CLOSEDATE'];
$res = \CCrmDeal::GetList([], $arFilter, $arSelect);
CModule::IncludeModule('crm');
use Bitrix\Crm\DealTable;
$arFilter = [
'STAGE_ID' => 'WON',
'<=CLOSEDATE' => \Bitrix\Main\Type\DateTime::createFromTimestamp(strtotime("-1 month"))
];
$arSelect = ['ID','ASSIGNED_BY_ID', 'CLOSEDATE'];
$arDeals=DealTable::getList([
'order'=>['ID' => 'DESC'],
'filter'=>$arFilter,
'select'=>$arSelect,
'cache' => ['ttl' => 3600],
'limit'=>100
])->fetchAll();
$deals=[];
foreach($arDeals as $deal){
$deals[$deal['ID']]=$deal;
}
print_r($deals);
'>=CLOSEDATE' => \Bitrix\Main\Type\DateTime::createFromTimestamp(strtotime("-1 month"))
'>=CLOSEDATE' => \Bitrix\Main\Type\DateTime::createFromTimestamp(strtotime("-1 month"))
$now = new \DateTime();
while($result = $res->fetch())
{
$date = \DateTime::createFromFormat('d.m.Y H:i:s', $result['CLOSEDATE']);
$dayDiff = $date->diff($now)->format('%a');
if($dayDiff == 30) {
//делаем что-то
}
CModule::IncludeModule('crm');
use Bitrix\Crm\DealTable;
$start=date("Y-m-d 00:00:00", strtotime("-1 month"));
$end=date("Y-m-d 23:59:59", strtotime("-1 month"));
$arFilter = [
'STAGE_ID' => 'WON',
'>=CLOSEDATE' => \Bitrix\Main\Type\DateTime::createFromTimestamp(strtotime($start)),
'<=CLOSEDATE' => \Bitrix\Main\Type\DateTime::createFromTimestamp(strtotime($end))
];
$arSelect = ['ID','ASSIGNED_BY_ID', 'CLOSEDATE'];
$arDeals=DealTable::getList([
'order'=>['CLOSEDATE' => 'ASC'],
'filter'=>$arFilter,
'select'=>$arSelect,
'cache' => ['ttl' => 3600],
'limit'=>100
])->fetchAll();
$deals=[];
foreach($arDeals as $deal){
$deals[$deal['ID']]=$deal;
}
print_r($deals);