'id' => $this->primaryKey(),
'bouquet_id' => $this->integer()->comment('Букет ИД'),
'matrix_type_id' => $this->integer()->comment('Тип матрицы ИД'),
- 'date_from' => $this->integer()->comment('Дата установки'),
- 'date_to' => $this->integer()->comment('Дата изменения'),
+ 'date_from' => $this->dateTime()->comment('Дата установки'),
+ 'date_to' => $this->dateTime()->comment('Дата изменения'),
'is_active' => $this->boolean()->defaultValue(true)->comment('Активна ли запись'),
'created_at' => $this->dateTime()->comment('Дата создания'),
'updated_at' => $this->dateTime()->comment('Дата обновления'),
namespace yii_app\records;
use Yii;
+use yii\behaviors\BlameableBehavior;
+use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
+use yii\db\Expression;
/**
* This is the model class for table "erp24.bouquet_composition_matrix_type_history".
{
public const IS_ACTIVE = true;
+ public function behaviors()
+ {
+ return [
+ [
+ 'class' => TimestampBehavior::class,
+ 'createdAtAttribute' => 'created_at',
+ 'updatedAtAttribute' => 'updated_at',
+ 'value' => new Expression('NOW()'),
+ ],
+ [
+ 'class' => BlameableBehavior::class,
+ 'createdByAttribute' => 'created_by',
+ 'updatedByAttribute' => 'updated_by',
+ ],
+ ];
+ }
+
+
/**
* {@inheritdoc}
*/
public function rules()
{
return [
- [['bouquet_id', 'matrix_type_id', 'date_from', 'created_by', 'updated_by'], 'integer'],
- [['created_at', 'updated_at','date_to'], 'safe'],
+ [['bouquet_id', 'matrix_type_id', 'created_by', 'updated_by'], 'integer'],
+ [['created_at', 'updated_at','date_to', 'date_from'], 'safe'],
[['is_active'], 'boolean']
];
}
public static function setData($value, $bouquetId) {
if (self::findOne(['bouquet_id' => $bouquetId])) {
+ var_dump(1);die();
BouquetCompositionMatrixTypeHistory::updateAll(['date_to' => date('Y-m-d H:i:s'), 'bouquet_id' => $bouquetId, 'date_from' => null, 'is_active' => self::IS_ACTIVE]);
}
+
$matrixHistoryType = new BouquetCompositionMatrixTypeHistory([
'bouquet_id' => $bouquetId,
'matrix_type_id' => $value,
- 'date_from' => date('Y-m-d H:i:s'),
+ 'date_from' => new Expression('now()'),
]);
- $matrixHistoryType->save();
+ if(!$matrixHistoryType->save()) {
+ var_dump($matrixHistoryType->getErrors(), $matrixHistoryType->date_from);
+ }
}
/**
])->label(false) ?>
</div>
</div>
-
</div>
<div class="col-md-3">
<div class="row">
<div class="col-md-5">
<div class="col-md-3"><?= Html::label("Год", null, ['class' => 'font-weight-bold pt-3 h6']) ?></div>
- <div class="col-md-9"> <?= Html::dropDownList("year", null, [2024 => 2024, 2025 => 2025], ['class' => 'form-control']) ?></div>
+ <div class="col-md-9"> <?= Html::dropDownList("year", $model?->forecastMonthAndYear->year ?? null, [2024 => 2024, 2025 => 2025], ['class' => 'form-control']) ?></div>
</div>
<div class="col-md-7">
<div class="col-md-3"><?= Html::label("Месяц", null, ['class' => 'font-weight-bold pt-3 h6']) ?></div>
- <div class="col-md-9"> <?= Html::dropDownList("month", null, \yii_app\helpers\DateHelper::MONTH_NUMBER_NAMES, ['class' => 'form-control']) ?></div>
+ <div class="col-md-9"> <?= Html::dropDownList("month", $model?->forecastMonthAndYear->month ?? null, \yii_app\helpers\DateHelper::MONTH_NUMBER_NAMES, ['class' => 'form-control']) ?></div>
</div>
</div>
<div class="row">