$dtObj->modify('last day of this month')->setTime(23,59,59);
$query->andWhere(['<=', 'a.date_from', $dtObj->format('Y-m-d H:i:s')])
- ->andWhere(['>=', 'a.date_end', $dfObj->format('Y-m-d H:i:s')]);
+ ->andWhere(['>=', 'a.date_to', $dfObj->format('Y-m-d H:i:s')]);
}
elseif ($filter->date_from) {
$df = \DateTime::createFromFormat('Y-m', $filter->date_from)
->format('Y-m-01 00:00:00');
- $query->andWhere(['>=', 'a.date_end', $df]);
+ $query->andWhere(['>=', 'a.date_to', $df]);
}
elseif ($filter->date_to) {
$rows[] = [
'guid' => $pid,
'date_from' => $from,
- 'date_end' => $to,
+ 'date_to' => $to,
'active' => 1,
'created_at' => $createdAt,
'created_by' => $userId,
Yii::$app->db->createCommand()
->batchInsert(
Products1cNomenclatureActuality::tableName(),
- ['guid','date_from','date_end','active','created_at','created_by'],
+ ['guid','date_from','date_to','active','created_at','created_by'],
$rows
)
->execute();
->one();
if ($old) {
- if ($old->date_from === $newFrom && $old->date_end === $newTo) {
+ if ($old->date_from === $newFrom && $old->date_to === $newTo) {
continue;
}
$new = new Products1cNomenclatureActuality([
'guid' => $row['guid'],
'date_from' => $newFrom,
- 'date_end' => $newTo,
+ 'date_to' => $newTo,
'active' => 1,
'created_at' => $now,
'created_by' => $userId,
'id' => $this->primaryKey(),
'guid' => $this->string()->notNull(),
'date_from' => $this->dateTime()->notNull()->comment('Дата и время начала активности'),
- 'date_end' => $this->dateTime()->null()->comment('Дата и время окончания активности'),
+ 'date_to' => $this->dateTime()->null()->comment('Дата и время окончания активности'),
'active' => $this->tinyInteger()->notNull()->defaultValue(1)->comment('Активность записи'),
'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
* @property int $id
* @property string $guid
* @property string $date_from Дата и время начала активности
- * @property string|null $date_end Дата и время окончания активности
+ * @property string|null $date_to Дата и время окончания активности
* @property int $active Активность записи
* @property string $created_at Дата создания
* @property string|null $updated_at Дата обновления
public function rules()
{
return [
- [['date_end', 'updated_at', 'updated_by'], 'default', 'value' => null],
+ [['date_to', 'updated_at', 'updated_by'], 'default', 'value' => null],
[['active'], 'default', 'value' => 1],
[['guid', 'date_from', 'created_at', 'created_by'], 'required'],
- [['date_from', 'date_end', 'created_at', 'updated_at'], 'safe'],
+ [['date_from', 'date_to', 'created_at', 'updated_at'], 'safe'],
[['active', 'created_by', 'updated_by'], 'default', 'value' => null],
[['active', 'created_by', 'updated_by'], 'integer'],
[['guid'], 'string', 'max' => 255],
'id' => 'ID',
'guid' => 'Guid',
'date_from' => 'Date From',
- 'date_end' => 'Date End',
+ 'date_to' => 'Date End',
'active' => 'Active',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
{
return [
[['id', 'active', 'created_by', 'updated_by'], 'integer'],
- [['guid', 'date_from', 'date_end', 'created_at', 'updated_at'], 'safe'],
+ [['guid', 'date_from', 'date_to', 'created_at', 'updated_at'], 'safe'],
[['category','type','color','subcategory','sort','species','size'], 'safe'],
];
$query->andFilterWhere([
'id' => $this->id,
'date_from' => $this->date_from,
- 'date_end' => $this->date_end,
+ 'date_to' => $this->date_to,
'active' => $this->active,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
}
$act = $actualities[$guid];
$actFrom = new \DateTime($act->date_from);
- $actTo = $act->date_end
- ? new \DateTime($act->date_end)
+ $actTo = $act->date_to
+ ? new \DateTime($act->date_to)
: (new \DateTime())->modify('+1 years');
$isInsideActivity = true;