- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/recurring/entity/parametermapper/firstforminvoice.php
- Класс: Bitrix\Crm\Recurring\Entity\ParameterMapper\FirstFormInvoice
- Вызов: FirstFormInvoice::checkMatchingDate
public function checkMatchingDate(Date $date)
{
switch ($this->mode)
{
case Calculator::SALE_TYPE_DAY_OFFSET:
return true;
break;
case Calculator::SALE_TYPE_WEEK_OFFSET:
$weekdays = $this->map[self::FIELD_WEEKLY_WEEKDAYS];
if (is_array($weekdays))
{
return in_array($date->format('N'), $weekdays);
}
break;
case Calculator::SALE_TYPE_MONTH_OFFSET:
if ($this->unitType === DateType\Month::TYPE_DAY_OF_ALTERNATING_MONTHS)
{
return (int)$date->format('j') === (int)$this->map[self::FIELD_MONTHLY_FIRST_TYPE_INTERVAL_DAY];
}
elseif ($this->unitType === DateType\Month::TYPE_WEEKDAY_OF_ALTERNATING_MONTHS)
{
if ((int)$date->format('N') !== (int)$this->map[self::FIELD_MONTHLY_SECOND_TYPE_WEEKDAY])
{
return false;
}
if ($this->map[self::FIELD_MONTHLY_SECOND_TYPE_WEEK_VALUE] === DateType\Month::LAST_WEEK_IN_MONTH_VALUE)
{
$currentMonth = $date->format('n');
$date->add('1 week');
return $currentMonth !== $date->format('n');
}
else
{
$weekValue = (int)(floor($date->format('j') / 7));
return $weekValue === (int)$this->map[self::FIELD_MONTHLY_SECOND_TYPE_WEEK_VALUE];
}
}
else
{
return true;
}
break;
case Calculator::SALE_TYPE_YEAR_OFFSET:
if ($this->unitType === DateType\Year::TYPE_DAY_OF_CERTAIN_MONTH)
{
if ((int)$date->format('j') !== (int)$this->map[self::FIELD_YEARLY_FIRST_TYPE_INTERVAL_DAY])
{
return false;
}
return (int)$date->format('n') === (int)$this->map[self::FIELD_YEARLY_FIRST_TYPE_INTERVAL_MONTH];
}
elseif ($this->unitType === DateType\Year::TYPE_WEEKDAY_OF_CERTAIN_MONTH)
{
if ((int)$date->format('N') !== (int)$this->map[self::FIELD_YEARLY_SECOND_TYPE_WEEKDAY])
{
return false;
}
if ((int)$date->format('n') !== (int)$this->map[self::FIELD_YEARLY_SECOND_TYPE_INTERVAL_MONTH])
{
return false;
}
if ((int)$this->map[self::FIELD_YEARLY_SECOND_TYPE_WEEK_VALUE] === DateType\Month::LAST_WEEK_IN_MONTH_VALUE)
{
$currentMonth = $date->format('n');
$date->add('1 week');
return $currentMonth !== $date->format('n');
}
else
{
$weekValue = (int)(floor($date->format('j') / 7));
return ($weekValue === (int)$this->map[self::FIELD_YEARLY_SECOND_TYPE_WEEK_VALUE]);
}
}
else
{
return true;
}
break;
}
return false;
}